退菜更改为多选

This commit is contained in:
gyq
2026-06-05 09:43:57 +08:00
parent 380a8c6572
commit 80ecf0526a

View File

@@ -1,6 +1,6 @@
<template> <template>
<el-dialog title="退菜" width="410px" v-model="show" @close="reset" :modal="modal"> <el-dialog title="退菜" width="550px" v-model="show" @close="reset" :modal="modal">
<div class="u-p-b-16"> <!-- <div class="u-p-b-16">
<div class="flex u-row-between"> <div class="flex u-row-between">
<span>菜品名称</span> <span>菜品名称</span>
<div class="u-flex"> <div class="u-flex">
@@ -31,15 +31,13 @@
</div> </div>
</div> </div>
</div> </div>
<div class="u-m-t-10 u-font-12 color-999">菜品已点数量 {{ max }} </div> -->
<div class="u-m-t-10 u-font-12 color-999">菜品已点数量 {{ max }} </div> <div class="u-m-t-0">
<div class="u-m-t-26">
<div> <div>
<span>退菜原因</span> <span>退菜原因</span>
<span class="color-red">*</span> <span class="color-red">*</span>
</div> </div>
</div> </div>
<div class="u-flex u-flex-wrap tags"> <div class="u-flex u-flex-wrap tags">
<div class="tag" v-for="(tag, index) in tags" @click="changeSel(tag)" :key="index" <div class="tag" v-for="(tag, index) in tags" @click="changeSel(tag)" :key="index"
:class="{ active: tag.checked }"> :class="{ active: tag.checked }">
@@ -47,15 +45,49 @@
</div> </div>
</div> </div>
<div class="u-m-t-20"> <div class="u-m-t-20">
<el-input v-model="note" placeholder="请输入自定义备注"></el-input> <el-input v-model="note" placeholder="请输入自定义备注" clearable></el-input>
</div>
<!-- <div class="u-m-t-20">
<el-checkbox v-model="isPrint">打印退菜单</el-checkbox>
</div> -->
<div class="u-m-t-20">
<span>选择要退的菜品</span>
</div> </div>
<div class="u-m-t-20"> <div class="u-m-t-20">
<el-checkbox v-model="isPrint">打印退菜单</el-checkbox> <el-table :data="orderList" ref="tableRef" row-key="id" border stripe height="280"
@selection-change="handleSelectionChange">
<el-table-column type="selection"></el-table-column>
<el-table-column prop="name" label="菜品信息">
<template #default="{ row }">
<div>{{ row.productName }}</div>
<div class="tag_wrap" v-if="row.sku_name">
<el-text type="info" size="small">规格</el-text>
<el-text type="info" size="small" v-for="item in row.sku_name.split(',')">
{{ item }}
</el-text>
</div>
<div class="tag_wrap" v-if="row.remark">
<el-text type="info" size="small">备注</el-text>
<el-text type="info" size="small">{{ row.remark }}</el-text>
</div>
</template>
</el-table-column>
<el-table-column prop="quantity" label="退菜数量">
<template #default="{ row }">
<el-input-number v-model="row.customReturnNum" :min="1" :max="row.number - row.returnNum"
style="width: 180px" :step="1" step-strictly>
</el-input-number>
</template>
</el-table-column>
</el-table>
</div> </div>
<template #footer> <template #footer>
<div> <div class="footer_wrap">
<div class="letf">退菜数量{{ _.sumBy(selectData, 'customReturnNum') || 0 }}</div>
<div class="flex">
<el-button @click="close">取消</el-button> <el-button @click="close">取消</el-button>
<el-button type="primary" @click="confirm">确定</el-button> <el-button type="primary" :disabled="selectData.length == 0" @click="confirm">确定</el-button>
</div>
</div> </div>
</template> </template>
</el-dialog> </el-dialog>
@@ -63,6 +95,8 @@
<refundConsModal ref="refundConsModalRef" :list="refundList" @success="refundConsModalSuccess" /> <refundConsModal ref="refundConsModalRef" :list="refundList" @success="refundConsModalSuccess" />
</template> </template>
<script> <script>
import _ from "lodash";
import { toRaw } from "vue";
import { ElMessage } from "element-plus"; import { ElMessage } from "element-plus";
import { useCartsStore } from '@/store/modules/carts' import { useCartsStore } from '@/store/modules/carts'
import refundConsModal from "@/components/refundConsModal.vue"; import refundConsModal from "@/components/refundConsModal.vue";
@@ -76,6 +110,9 @@ export default {
}, },
data() { data() {
return { return {
_,
selectData: [],
orderList: [],
max: 1, max: 1,
number: 1, number: 1,
isPrint: false, isPrint: false,
@@ -85,6 +122,8 @@ export default {
{ label: "不想要了", checked: false }, { label: "不想要了", checked: false },
{ label: "食材不足", checked: false }, { label: "食材不足", checked: false },
{ label: "等待时间过长", checked: false }, { label: "等待时间过长", checked: false },
{ label: "点重复了", checked: false },
{ label: "口味问题", checked: false },
], ],
note: "", note: "",
goods: { goods: {
@@ -102,7 +141,12 @@ export default {
}, },
methods: { methods: {
changeSel(item) { changeSel(item) {
item.checked = !item.checked; // item.checked = !item.checked;
if (this.note == '') {
this.note = item.label
} else {
this.note += `${item.label}`
}
}, },
reset() { reset() {
this.note = ""; this.note = "";
@@ -121,15 +165,54 @@ export default {
} }
this.note = tag + "," + this.note; this.note = tag + "," + this.note;
}, },
open(item) { // 选择数据变化
this.goods = item ? item : this.goods; handleSelectionChange(val) {
this.max = item.num - item.returnNum; this.selectData = val
this.show = true; },
if (item.productId != "-999") { open(goods) {
this.number = 1; this.goods = goods
} else {
this.number = this.max; const carts = useCartsStore();
let categorys = JSON.parse(localStorage.getItem('categorys'))
let shopInfo = JSON.parse(localStorage.getItem('userInfo'))
this.orderList = _.flatten(_.values(carts.oldOrder.detailMap), 'goods').map(item => ({
...item,
customReturnNum: item.number - item.returnNum
})).filter(item => item.number - item.returnNum > 0)
this.orderList.forEach(item => {
carts.goods.forEach(val => {
if (item.productId == val.id) {
if (shopInfo.refundMode == 1) {
// 跟随分类退款模式
categorys.forEach(v => {
if (val.categoryId == v.id) {
item.refundMode = v.refundMode
} }
})
} else {
// 跟随商品退款模式及
item.refundMode = val.refundMode
}
}
})
})
console.log('cartOperationReturn组件打开了', this.orderList)
setTimeout(() => {
this.$refs.tableRef.toggleRowSelection(this.orderList.find(item => item.id == this.goods.id), true)
}, 100);
this.show = true;
// this.goods = item ? item : this.goods;
// this.max = item.num - item.returnNum;
// if (item.productId != "-999") {
// this.number = 1;
// } else {
// this.number = this.max;
// }
}, },
close() { close() {
this.show = false; this.show = false;
@@ -144,56 +227,60 @@ export default {
this.$emit("confirm", { this.$emit("confirm", {
refundReason: this.note, refundReason: this.note,
refundAmount: 0, refundAmount: 0,
refundDetails: [{ id: this.goods.id, num: this.number, returnAmount: 0 }], refundDetails: toRaw(this.selectData).map(item => ({
id: item.id,
returnAmount: item.lowPrice,
num: item.customReturnNum
})),
refundStock: this.refundStock refundStock: this.refundStock
}); });
this.close(); this.close();
}, },
// 确认退菜 // 确认退菜
confirm() { confirm() {
const selTag = this.tags // const selTag = this.tags
.filter((item) => item.checked) // .filter((item) => item.checked)
.map((item) => item.label) // .map((item) => item.label)
.join(","); // .join(",");
this.note = selTag + (this.note.length > 0 ? "," + this.note : ""); // this.note = selTag + (this.note.length > 0 ? "," + this.note : "");
if (!this.note) { if (!this.note) {
return ElMessage.error("请输入退菜原因"); return ElMessage.error("请输入退菜原因");
} }
const carts = useCartsStore(); // const carts = useCartsStore();
let categorys = JSON.parse(localStorage.getItem('categorys')) // let categorys = JSON.parse(localStorage.getItem('categorys'))
let shopInfo = JSON.parse(localStorage.getItem('userInfo')) // let shopInfo = JSON.parse(localStorage.getItem('userInfo'))
// 在这里给订单的商品补全库存信息 start // // 在这里给订单的商品补全库存信息 start
carts.goods.forEach(val => { // carts.goods.forEach(val => {
if (this.goods.productId == val.id) { // if (this.goods.productId == val.id) {
if (shopInfo.refundMode == 1) { // if (shopInfo.refundMode == 1) {
// 跟随分类退款模式 // // 跟随分类退款模式
categorys.forEach(v => { // categorys.forEach(v => {
if (val.categoryId == v.id) { // if (val.categoryId == v.id) {
this.goods.refundMode = v.refundMode // this.goods.refundMode = v.refundMode
} // }
}) // })
} else { // } else {
// 跟随商品退款模式及 // // 跟随商品退款模式及
this.goods.refundMode = val.refundMode // this.goods.refundMode = val.refundMode
} // }
} // }
}) // })
console.log('this.goods===', this.goods); console.log('this.selectData===', this.selectData);
if (this.goods.refundMode == 3) {
this.refundList = [ this.refundList = toRaw(this.selectData).filter(item => item.refundMode == 3).map(item => ({
{ name: item.product_name,
name: this.goods.product_name, num: item.customReturnNum
num: this.number }))
}
] if (this.refundList.length > 0) {
this.$refs.refundConsModalRef.show() this.$refs.refundConsModalRef.show()
return return
} }
// 在这里给订单的商品补全库存信息 end
this.refundNext() this.refundNext()
}, },
}, },
@@ -202,6 +289,12 @@ export default {
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
.footer_wrap {
display: flex;
justify-content: space-between;
align-items: center;
}
:deep(.el-dialog__body) { :deep(.el-dialog__body) {
margin-bottom: 14px; margin-bottom: 14px;
margin-top: 14px; margin-top: 14px;