fix: 代客下单增加转台功能,修复临时菜价格展示问题,增加就餐类型切换为打包时,加菜默认为打包

This commit is contained in:
2025-03-13 18:31:36 +08:00
parent dc5dc45893
commit a3f8c8c012
11 changed files with 268 additions and 52 deletions

View File

@@ -91,7 +91,11 @@
</template>
<!-- 单品改价 -->
<template
v-else-if="item.discount_sale_amount * 1 > 0 && discount_before_price != allPrice"
v-else-if="
item.discount_sale_amount * 1 > 0 &&
discount_before_price != allPrice &&
!item.is_temporary
"
>
<div>¥{{ to2(allPrice) }}</div>
<div class="free-price">

View File

@@ -251,9 +251,6 @@ function init() {
for (let goods of props.goodsList) {
goodsMap[goods.id] = goods;
}
console.log("cartsinit");
console.log(props.oldOrder);
carts.init({ table_code: props.table.tableCode }, goodsMap, props.oldOrder);
}

View File

@@ -32,8 +32,9 @@ const controls = ref([
{ label: "赠送", key: "is_gift", disabled: false, per: "gift" },
{ label: "打包", key: "is_pack", disabled: false, per: "pack" },
{ label: "删除", key: "del", disabled: false, per: "del" },
{ label: "存单", key: "", disabled: false, per: "save" },
{ label: "取单", key: "", disabled: false },
{ label: "转桌", key: "rottable", disabled: false, per: "rottable" },
// { label: "存单", key: "", disabled: false, per: "save" },
// { label: "取单", key: "", disabled: false },
{ label: "单品备注", key: "one-note", disabled: false, per: "one-note" },
{ label: "整单备注", key: "all-note", disabled: false, per: "all-note" },
{ label: "退菜", key: "return", disabled: false, per: "return" },
@@ -43,7 +44,7 @@ const controls = ref([
// { label: "整单等叫", key: "", disabled: false, per: "all-wating" },
]);
const emits = defineEmits(["noteClick", "changePriceClick", "packClick", "return"]);
const emits = defineEmits(["noteClick", "changePriceClick", "packClick", "return", "rottable"]);
function controlsClick(item) {
switch (item.key) {
case "is_gift":
@@ -68,6 +69,9 @@ function controlsClick(item) {
case "one-note":
emits("noteClick", true);
break;
case "rottable":
emits("rottable", carts.selCart);
break;
case "all-note":
emits("noteClick", false);
break;
@@ -82,18 +86,26 @@ function controlsClick(item) {
}
}
const perList = computed(() => {
// if (!carts.oldOrder.id) {
// return ["all-wating", "all-note", "rottable"];
// }
let arr = [];
if (!carts.selCart.id) {
return ["all-wating", "all-note"];
arr = ["all-wating", "all-note"];
}
if (carts.isCanSelectGroup) {
return ["all-wating", "all-note", "del", "pack", "gift", "print", "one-note"];
arr = ["all-wating", "all-note", "del", "pack", "gift", "print", "one-note"];
}
if (carts.selCart.id) {
if (carts.isOldOrder) {
return ["return"];
arr = ["return"];
}
return ["cart", "del", "pack", "gift", "save", "one-note", "print", "all-note", "all-wating"];
arr = ["cart", "del", "pack", "gift", "save", "one-note", "print", "all-note", "all-wating"];
}
if (carts.oldOrder.id) {
arr.push("rottable");
}
return arr;
});
const canEdit = computed(() => {
return !perList.value.includes("cart");

View File

@@ -79,9 +79,9 @@ export default {
if (this.number > this.max) {
ElMessage.error("最多只能选择" + this.max + "位就餐人数");
}
if (!this.number) {
ElMessage.error("请选择就餐人数");
}
// if (!this.number) {
// ElMessage.error("请选择就餐人数");
// }
console.log(this.number);
this.$emit("confirm", this.number);
this.close();

View File

@@ -0,0 +1,112 @@
<template>
<el-dialog title="转桌" width="700px" v-model="show" @close="reset">
<el-form :rules="rules" ref="refForm" :model="form">
<el-form-item label="转桌到" prop="targetTableCode">
<el-select v-model="form.targetTableCode" placeholder="请选择转桌到" style="width: 200px">
<el-option
v-for="item in tableList"
:key="item.id"
:label="item.name"
:value="item.tableCode"
></el-option>
</el-select>
</el-form-item>
<el-form-item label="转入类型">
<el-radio-group v-model="rottableType">
<el-radio value="0" border>转桌(可将部分商品转入)</el-radio>
<el-radio value="1" border>并桌(并台会将全部购物车商品转入)</el-radio>
</el-radio-group>
</el-form-item>
<el-form-item label="购物车商品" v-if="rottableType == 0">
<el-table border :data="cartGoods" ref="refTable">
<el-table-column type="selection" width="55" />
<el-table-column label="商品" prop="name"></el-table-column>
<el-table-column label="数量" prop="number"></el-table-column>
<el-table-column label="商品" prop="name"></el-table-column>
</el-table>
</el-form-item>
</el-form>
<template #footer>
<el-button @click="close">取消</el-button>
<el-button type="primary" @click="confirm">确定</el-button>
</template>
</el-dialog>
</template>
<script setup>
import tableApi from "@/api/account/table";
import orderApi from "@/api/order/order";
const props = defineProps({
cartGoods: {
type: Array,
default: () => [],
},
});
const refForm = ref();
let rottableType = ref("0");
const basicForm = {
sourceOrderId: "",
targetOrderId: "",
targetTableCode: "",
detailIds: [],
};
const form = reactive({
...basicForm,
});
const rules = {
targetTableCode: [{ required: true, message: "请选择目标桌码", trigger: "blur" }],
};
function reset() {
Object.assign(form, basicForm);
}
const show = ref(false);
function open(obj) {
Object.assign(form, obj);
show.value = true;
}
function close() {
show.value = false;
}
const refTable = ref();
const tableList = ref([]);
function getTableList() {
tableApi.getList({ page: 1, size: 999 }).then((res) => {
tableList.value = res.records.filter((v) => v.tableCode);
});
}
function confirm() {
refForm.value.validate((valid, fields) => {
if (valid) {
console.log("submit!");
const detailIds = refTable.value.getSelectionRows().map((v) => v.id);
orderApi
.mergeOrder({
...form,
detailIds,
})
.then((res) => {
ElNotification({
title: "成功",
message: "合并成功",
type: "success",
});
});
} else {
console.log("error submit!", fields);
}
});
}
onMounted(() => {
getTableList();
});
defineExpose({
open,
close,
});
</script>