并桌转桌

This commit is contained in:
魏啾 2024-12-12 11:24:12 +08:00
parent 535e3834c9
commit 98ae9c5e21
2 changed files with 48 additions and 29 deletions

View File

@ -12,8 +12,9 @@
</div>
<div v-if="!isFull">
<div v-if="itemdata.list.length > 0">
<el-table ref="reftransfertoPinpin" :data="itemdata.list" tooltip-effect="dark" style="width: 100%"
@selection-change="handleSelectionChange($event)">
<h4>购物车商品</h4>
<el-table ref="refcart" :data="itemdata.list" tooltip-effect="dark" style="width: 100%"
@selection-change="handlerefcart($event)">
<el-table-column type="selection" width="55" />
<el-table-column label="图片" prop="coverImg">
<template slot-scope="scope">
@ -32,7 +33,7 @@
</el-table-column>
</el-table>
</div>
<div v-else>
<div v-if="itemdata.old.list.length > 0">
<div v-for="(orderItem, orderIndex) in itemdata.old.list" :key="orderIndex">
<h4>{{ orderItem.placeNum }}次下单商品</h4>
<el-table ref="reftransfertoPinpin" :data="orderItem.info" tooltip-effect="dark"
@ -69,6 +70,7 @@
<script>
import { placeswitch } from "@/api/Instead";
import { forEach } from "lodash";
export default {
data() {
return {
@ -80,30 +82,31 @@ export default {
targetTableId: '',
originTableList: [],//
multipleSelection: [],
refcartSelection: [],
isFull: false
};
},
methods: {
toggleSelection() {
if (this.itemdata.list.length > 0) {
this.$refs.reftransfertoPinpinclearSelection();
} else {
try {
this.$refs.refcart.clearSelection();
this.$refs.reftransfertoPinpin.forEach((a) => {
a.clearSelection();
})
} catch (error) {
}
},
handleSelectionChange(val, index) {
try {
if (this.itemdata.list.length > 0) {
this.multipleSelection = val
} else {
this.itemdata.old.list.forEach((a, i) => {
this.multipleSelection[index] = i === index ? val : this.multipleSelection[index] || []
})
}
} catch (error) { }
},
handlerefcart(val) {
this.refcartSelection = val
},
async confirm() {
console.log(this.itemdata, this.multipleSelection)
if (!this.targetTableId) {
@ -113,10 +116,17 @@ export default {
})
return false;
}
if (this.refcartSelection.length) {
this.refcartSelection.forEach((i) => {
i.cartId = i.id
})
}
let cartIds = [...this.multipleSelection, [...this.refcartSelection]]
console.log(cartIds)
await placeswitch({
masterId: this.masterId,
orderId: this.itemdata.orderId,//id
cartIds: this.isFull ? '' : this.multipleSelection.flatMap(subArray => subArray.map(item => item.cartId)),//
cartIds: this.isFull ? '' : cartIds.flatMap(subArray => subArray.map(item => item.cartId)),//
isFull: this.isFull,//false
currentTableId: this.currentTableId,
targetTableId: this.targetTableId,
@ -128,18 +138,17 @@ export default {
},
open(item, masterId, currentTableId, originTableList) {
// ,id
console.log(item, masterId, currentTableId, originTableList)
this.itemdata = item
this.masterId = masterId//
this.currentTableId = currentTableId//id
this.originTableList = originTableList//
this.originTableList = originTableList.filter((i) => i.tableId != currentTableId && i.status == 'using')//
try {
if (this.itemdata.list.length > 0) {
this.$refs.reftransfertoPinpinclearSelection();
} else {
this.$refs.refcart.clearSelection();
this.$refs.reftransfertoPinpin.forEach((a) => {
a.clearSelection();
})
}
} catch (error) { }
this.show = true;
},

View File

@ -435,7 +435,7 @@
{{ returnWaingAllText }}
</div>
<div class="btn no-wrap u-font-12" @click="clicktransfertoPinpin()"
v-if="table.name && useTypes.sel == 'dine-in'">
v-if="table.name && useTypes.sel == 'dine-in' && payAfter">
转桌/并桌
</div>
<!-- -->
@ -1027,7 +1027,7 @@
<!-- 可选套餐 -->
<dialogpackage ref="refdialogpackage" @dialogpackageconfirm="dialogpackageconfirm"></dialogpackage>
<!-- 并桌/转桌 -->
<transfertoPinpin ref="refransfertoPinpin" @transfertoPinpin="xiadanClick"></transfertoPinpin>
<transfertoPinpin ref="refransfertoPinpin" @transfertoPinpin="reset"></transfertoPinpin>
</div>
</template>
@ -2891,16 +2891,25 @@ export default {
// });
// },
clicktransfertoPinpin() {
if (this.order.list.length < 0) {
// 使 reduce
const count = this.tableList.reduce((acc, cur) => {
if (cur.status == 'using') {
return acc + 1;
}
return acc;
}, 0);
console.log(count)
if (count >= 2) {
// console.log(this.order, this.masterId, this.table.tableId, this.tableList)
// ,id
this.$refs.refransfertoPinpin.open(this.order, this.masterId, this.table.tableId, this.tableList);
} else {
this.$message({
message: '请先选择商品!',
message: '暂无可转台桌',
type: 'warning'
})
return false;
}
console.log(this.order, this.masterId, this.table.tableId, this.tableList)
// ,id
this.$refs.refransfertoPinpin.open(this.order, this.masterId, this.table.tableId, this.tableList);
},
//
async orderBtnsClick(key) {
@ -3491,6 +3500,7 @@ export default {
this.order.orderId = "";
this.perpole = "";
this.useTypes.sel = "dine-in";
this.getTable()
},
//
setCart(res) {