并桌转桌

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

View File

@ -435,7 +435,7 @@
{{ returnWaingAllText }} {{ returnWaingAllText }}
</div> </div>
<div class="btn no-wrap u-font-12" @click="clicktransfertoPinpin()" <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> </div>
<!-- --> <!-- -->
@ -1027,7 +1027,7 @@
<!-- 可选套餐 --> <!-- 可选套餐 -->
<dialogpackage ref="refdialogpackage" @dialogpackageconfirm="dialogpackageconfirm"></dialogpackage> <dialogpackage ref="refdialogpackage" @dialogpackageconfirm="dialogpackageconfirm"></dialogpackage>
<!-- 并桌/转桌 --> <!-- 并桌/转桌 -->
<transfertoPinpin ref="refransfertoPinpin" @transfertoPinpin="xiadanClick"></transfertoPinpin> <transfertoPinpin ref="refransfertoPinpin" @transfertoPinpin="reset"></transfertoPinpin>
</div> </div>
</template> </template>
@ -2891,16 +2891,25 @@ export default {
// }); // });
// }, // },
clicktransfertoPinpin() { 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({ this.$message({
message: '请先选择商品!', message: '暂无可转台桌',
type: 'warning' type: 'warning'
}) })
return false; 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) { async orderBtnsClick(key) {
@ -3491,6 +3500,7 @@ export default {
this.order.orderId = ""; this.order.orderId = "";
this.perpole = ""; this.perpole = "";
this.useTypes.sel = "dine-in"; this.useTypes.sel = "dine-in";
this.getTable()
}, },
// //
setCart(res) { setCart(res) {