代课下单

This commit is contained in:
魏啾 2024-12-11 17:30:55 +08:00
parent 1bd0b0daa9
commit 9782256a84
3 changed files with 237 additions and 20 deletions

View File

@ -30,6 +30,21 @@ export function $updatePrice(data) {
}
});
}
/**
* 购物车-转桌/并桌
*/
export function placeswitch(data) {
return request({
url: `/api/place/switch`,
method: "put",
data: {
shopId: localStorage.getItem("shopId"),
useType: localStorage.getItem("useType"),
...data
}
});
}
// 团购券-获取可使用团购券列表

View File

@ -0,0 +1,182 @@
<template>
<div class="select_desk">
<el-dialog title="请选择商品" :visible.sync="show">
<div style="padding: 10px 0;display: flex;justify-content: space-between;align-items: center;">
<el-checkbox v-model="isFull">并桌</el-checkbox>
<el-select v-model="targetTableId" placeholder="请选择目标台桌">
<el-option v-for="item in originTableList" :key="item.tableId" :label="item.name"
:value="item.tableId" @click="changeTable(item, index)">
</el-option>
</el-select>
</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)">
<el-table-column type="selection" width="55" />
<el-table-column label="图片" prop="coverImg">
<template slot-scope="scope">
<el-image style="width: 50px; height: 50px" :src="scope.row.coverImg"
fit="cover"></el-image>
</template>
</el-table-column>
<el-table-column label="名称" prop="name" />
<el-table-column prop="number" label="数量" />
<el-table-column prop="price" label="价格">
<template slot-scope="scope">
<div>
{{ (scope.row.salePrice * scope.row.number).toFixed(2) }}
</div>
</template>
</el-table-column>
</el-table>
</div>
<div v-else>
<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"
style="width: 100%" @selection-change="handleSelectionChange($event, orderIndex)">
<el-table-column type="selection" width="55" />
<el-table-column label="图片" prop="coverImg">
<template slot-scope="scope">
<el-image style="width: 50px; height: 50px" :src="scope.row.coverImg"
fit="cover"></el-image>
</template>
</el-table-column>
<el-table-column label="名称" prop="name" />
<el-table-column prop="number" label="数量" />
<el-table-column prop="price" label="价格">
<template slot-scope="scope">
<div>
{{ (scope.row.salePrice * scope.row.number).toFixed(2) }}
</div>
</template>
</el-table-column>
</el-table>
</div>
</div>
</div>
<div class="buttonbox">
<el-button type="primary" @click="confirm">确定</el-button>
<el-button @click="toggleSelection">取消</el-button>
</div>
</el-dialog>
</div>
</template>
<script>
import { placeswitch } from "@/api/Instead";
export default {
data() {
return {
show: false,
itemdata: {},
list: [],
masterId: '',
currentTableId: '',
targetTableId: '',
originTableList: [],//
multipleSelection: [],
isFull: false
};
},
methods: {
toggleSelection() {
if (this.itemdata.list.length > 0) {
this.$refs.reftransfertoPinpinclearSelection();
} else {
this.$refs.reftransfertoPinpin.forEach((a) => {
a.clearSelection();
})
}
},
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) { }
},
async confirm() {
console.log(this.itemdata, this.multipleSelection)
if (!this.targetTableId) {
this.$message({
message: '请选择目标台桌!',
type: 'warning'
})
return false;
}
await placeswitch({
masterId: this.masterId,
orderId: this.itemdata.orderId,//id
cartIds: this.isFull ? '' : this.multipleSelection.flatMap(subArray => subArray.map(item => item.cartId)),//
isFull: this.isFull,//false
currentTableId: this.currentTableId,
targetTableId: this.targetTableId,
})
this.$forceUpdate();
this.$emit("transfertoPinpin");
this.show = false;
},
open(item, masterId, currentTableId, originTableList) {
this.itemdata = item
this.masterId = masterId//
this.currentTableId = currentTableId//id
this.originTableList = originTableList//
try {
if (this.itemdata.list.length > 0) {
this.$refs.reftransfertoPinpinclearSelection();
} else {
this.$refs.reftransfertoPinpin.forEach((a) => {
a.clearSelection();
})
}
} catch (error) { }
this.show = true;
},
returnTableColor(key) {
const item = $status[key];
return item ? item.type : "";
},
changeTable(item, index) {
console.log(item, index)
},
searchInput(e) {
console.log(e);
// this.tableList = $originTableList.filter((v) =>
// $strMatch(v.name, e.trim())
// );
},
},
};
</script>
<style lang="scss" scoped>
::v-deep.el-button {
padding: 12px 20px;
}
.select_desk {
.box {
margin: 20px 10px;
.boxspan {}
}
.buttonbox {
margin: 0 auto;
padding: 20px 0;
text-align: right;
}
}
</style>

View File

@ -379,7 +379,7 @@
删除
</div>
<div class="btn" :class="{ disabled: !order.list.length || order.old.list.length }" @click="saveOrder">
<!-- <div class="btn" :class="{ disabled: !order.list.length || order.old.list.length }" @click="saveOrder">
存单
</div>
<div class="btn relative" :class="{
@ -389,7 +389,7 @@
<span class="prve-car-len" v-if="prveOrder.list.length">{{
prveOrder.list.length
}}</span>
</div>
</div> -->
<!-- <div
class="btn"
@ -434,7 +434,11 @@
:class="{ disabled: isCreateOrder }">
{{ returnWaingAllText }}
</div>
<div class="btn no-wrap u-font-12" @click="clicktransfertoPinpin()"
v-if="table.name && useTypes.sel == 'dine-in'">
转桌/并桌
</div>
<!-- -->
<!-- <div
class="btn"
:class="{ disabled: order.old.list.length <= 0 }"
@ -1022,6 +1026,8 @@
</popup-weight-goods>
<!-- 可选套餐 -->
<dialogpackage ref="refdialogpackage" @dialogpackageconfirm="dialogpackageconfirm"></dialogpackage>
<!-- 并桌/转桌 -->
<transfertoPinpin ref="refransfertoPinpin" @transfertoPinpin="xiadanClick"></transfertoPinpin>
</div>
</template>
@ -1046,6 +1052,8 @@ import tuanQuanTable from "./components/tuan-quan-table.vue";
import popupChooseGuazhang from "./components/popup-choose-guazhang.vue";
import popupWeightGoods from "./components/popup-weight-goods.vue";
import dialogpackage from "./components/dialogpackage.vue";
import transfertoPinpin from "./components/transfertoPinpin.vue";
import dayjs from "dayjs";
@ -1122,7 +1130,8 @@ export default {
cartItem,
chooseDinersNumber,
PopupChooseGuazhang,
dialogpackage
dialogpackage,
transfertoPinpin
},
data() {
return {
@ -2881,7 +2890,18 @@ export default {
// return { ...v, cart: JSON.parse(v.cart) };
// });
// },
clicktransfertoPinpin() {
if (this.order.list.length < 0) {
this.$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) {
const orderGoods = this.order.list[this.order.selIndex];