feat: 代客下单更新
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
<template>
|
||||
<div class="box">
|
||||
<div class="box" v-loading="cartsLoading" element-loading-text="购物车连接初始化中,请稍等……">
|
||||
<div class="content">
|
||||
<div class="top">
|
||||
<div class="left u-flex u-col-center">
|
||||
@@ -109,6 +109,7 @@
|
||||
:goodsList="goods.list"
|
||||
:oldOrder="oldOrder"
|
||||
:perpole="perpole"
|
||||
:remark="remark"
|
||||
:table="table"
|
||||
ref="refCart"
|
||||
></cartsList>
|
||||
@@ -170,6 +171,7 @@
|
||||
|
||||
<!-- 订单信息展示 -->
|
||||
<Order
|
||||
ref="refOrder"
|
||||
:orderInfo="orderInfo"
|
||||
@chooseUser="showChooseUser"
|
||||
@paysuccess="refresh"
|
||||
@@ -232,6 +234,9 @@ const shopUser = useUserStore();
|
||||
|
||||
const route = useRoute();
|
||||
const router = useRouter();
|
||||
|
||||
//整单备注
|
||||
const remark = ref("");
|
||||
//退菜
|
||||
function showReturn(cart) {
|
||||
console.log(cart);
|
||||
@@ -252,13 +257,15 @@ let user = ref({});
|
||||
const refChooseUser = ref();
|
||||
function chooseUserConfirm(e) {
|
||||
user.value = e ? e : {};
|
||||
refCart.value.carts.changeUser(e ? e : {});
|
||||
carts.changeUser(e ? e : {});
|
||||
}
|
||||
function showChooseUser() {
|
||||
refChooseUser.value.open();
|
||||
}
|
||||
|
||||
//订单
|
||||
const refOrder = ref();
|
||||
|
||||
const showOrder = ref(false);
|
||||
function hideOrder() {
|
||||
showOrder.value = false;
|
||||
@@ -267,43 +274,57 @@ const oldOrder = ref({ detailMap: [] });
|
||||
|
||||
const orderInfo = ref({});
|
||||
|
||||
let createOrderTimer = null;
|
||||
let loadingTimer = null;
|
||||
let loading = undefined;
|
||||
|
||||
async function createOrder(key) {
|
||||
console.log(refCart.value.carts.table_code);
|
||||
clearTimeout(createOrderTimer);
|
||||
const loading = ElLoading.service({
|
||||
if (key == "wx-aiplay" && oldOrder.value.id) {
|
||||
refOrder.value.nowPayClick("scanCode");
|
||||
return;
|
||||
}
|
||||
if (key == "cash" && oldOrder.value.id) {
|
||||
refOrder.value.nowPayClick("cash");
|
||||
return;
|
||||
}
|
||||
clearTimeout(loadingTimer);
|
||||
loading = ElLoading.service({
|
||||
lock: true,
|
||||
text: "订单生成中,请稍等……",
|
||||
background: "rgba(0, 0, 0, 0.7)",
|
||||
});
|
||||
createOrderTimer = setTimeout(() => {
|
||||
loadingTimer = setTimeout(() => {
|
||||
ElMessage.error("订单生成超时");
|
||||
loading.close();
|
||||
}, 1000 * 20);
|
||||
try {
|
||||
if (key == "to-pay" && carts.list.length <= 0) {
|
||||
showOrder.value = true;
|
||||
return;
|
||||
}
|
||||
const res = await orderApi.add({
|
||||
orderId: oldOrder.value.id || "",
|
||||
shopId: shopUser.userInfo.id,
|
||||
userId: user.value.userId,
|
||||
seatNum: 0,
|
||||
packFee: refCart.value.carts.packFee * 1,
|
||||
originAmount: refCart.value.carts.payMoney * 1,
|
||||
tableCode: refCart.value.carts.table_code,
|
||||
packFee: carts.packFee * 1,
|
||||
originAmount: carts.payMoney * 1,
|
||||
tableCode: carts.table_code,
|
||||
dineMode: diners.sel == 0 ? "dine-in" : "take-out",
|
||||
remark: "",
|
||||
remark: remark.value,
|
||||
seatNum: perpole.value * 1,
|
||||
placeNum: oldOrder.value.placeNum * 1 + 1,
|
||||
waitCall: false,
|
||||
vipPrice: user.value.id && user.value.isVip,
|
||||
});
|
||||
clearTimeout(createOrderTimer);
|
||||
clearTimeout(loadingTimer);
|
||||
loading.close();
|
||||
if (res) {
|
||||
refCart.value.carts.clear();
|
||||
carts.clear();
|
||||
carts.dataReset();
|
||||
if (key == "only-create") {
|
||||
router.replace(route.path);
|
||||
refresh();
|
||||
return;
|
||||
}
|
||||
|
||||
if (res.id) {
|
||||
// 获取历史订单数据
|
||||
const res1 = await orderApi.getHistoryList({
|
||||
@@ -311,21 +332,29 @@ async function createOrder(key) {
|
||||
});
|
||||
oldOrder.value = res1;
|
||||
orderInfo.value = res1;
|
||||
refCart.value.carts.init();
|
||||
carts.setOldOrder(res1);
|
||||
}
|
||||
showOrder.value = true;
|
||||
|
||||
showOrder.value = true;
|
||||
if (key == "wx-aiplay") {
|
||||
refOrder.value.nowPayClick("scanCode");
|
||||
return;
|
||||
}
|
||||
if (key == "cash") {
|
||||
refOrder.value.nowPayClick("cash");
|
||||
}
|
||||
// oldOrder.value = res;
|
||||
}
|
||||
} catch (error) {
|
||||
clearTimeout(createOrderTimer);
|
||||
loading.close();
|
||||
clearTimeout(loadingTimer);
|
||||
}
|
||||
}
|
||||
|
||||
//可选套餐商品
|
||||
const refAddTaocan = ref();
|
||||
function taocanConfirm(goods, pro_group_info) {
|
||||
refCart.value.carts.cartsPush({
|
||||
carts.cartsPush({
|
||||
goods_type: "package",
|
||||
product_id: goods.id,
|
||||
sku_id: goods.skuList[0].id,
|
||||
@@ -381,7 +410,7 @@ function tableClick(item) {
|
||||
getTableDetail(item.tableCode);
|
||||
|
||||
table.value = item;
|
||||
refCart.value.carts.changeTable(item.tableCode);
|
||||
carts.changeTable(item.tableCode);
|
||||
refTable.value.hide();
|
||||
}
|
||||
|
||||
@@ -391,7 +420,7 @@ function showaddLingShiCai() {
|
||||
refAddLingShiCai.value.open();
|
||||
}
|
||||
function addLingShiCaiConfirm(data) {
|
||||
refCart.value.carts.add({
|
||||
carts.add({
|
||||
sku_id: "-999",
|
||||
product_id: "-999",
|
||||
is_temporary: 1,
|
||||
@@ -414,7 +443,7 @@ function showChangePrice(cart) {
|
||||
refChangePrice.value.open(cart);
|
||||
}
|
||||
function changePriceConfirm(discount_sale_amount) {
|
||||
refCart.value.carts.updateTag("discount_sale_amount", discount_sale_amount);
|
||||
carts.updateTag("discount_sale_amount", discount_sale_amount);
|
||||
}
|
||||
|
||||
//打包
|
||||
@@ -423,21 +452,22 @@ function showPack(packNumber, max) {
|
||||
refPack.value.open(packNumber * 1, max * 1);
|
||||
}
|
||||
function packConfirm(packNumber) {
|
||||
refCart.value.carts.updateTag("pack_number", packNumber);
|
||||
carts.updateTag("pack_number", packNumber);
|
||||
}
|
||||
|
||||
//备注
|
||||
const refNote = ref(null);
|
||||
function showNote(isOneNote) {
|
||||
const remark = isOneNote ? refCart.value.carts.selCart.remark : "";
|
||||
console.log(remark);
|
||||
refNote.value.open(remark, isOneNote);
|
||||
const note = isOneNote ? carts.selCart.remark : remark.value;
|
||||
console.log(note);
|
||||
refNote.value.open(note, isOneNote);
|
||||
}
|
||||
function noteConfirm(note, isOneNote) {
|
||||
if (isOneNote) {
|
||||
refCart.value.carts.updateTag("remark", note);
|
||||
carts.updateTag("remark", note);
|
||||
return;
|
||||
}
|
||||
remark.value = note;
|
||||
}
|
||||
|
||||
// 搜索
|
||||
@@ -500,10 +530,13 @@ async function getGoods() {
|
||||
...goods.query,
|
||||
});
|
||||
goods.list = res.records;
|
||||
refCart.value.carts.goods = goods.list;
|
||||
carts.goods = goods.list;
|
||||
goodsMapisFinish.value = true;
|
||||
}
|
||||
|
||||
const cartsLoading = computed(() => {
|
||||
console.log(goodsMapisFinish.value, carts.isLinkFinshed);
|
||||
return !goodsMapisFinish.value || !carts.isLinkFinshed;
|
||||
});
|
||||
function goodsClick(item) {
|
||||
if (!goodsMapisFinish.value) {
|
||||
return ElMessage.error({
|
||||
@@ -542,11 +575,6 @@ function goodsClick(item) {
|
||||
number: item.skuList[0].suitNum || 1,
|
||||
};
|
||||
addCarts(sendmsg);
|
||||
// refCart.value.carts.cartsPush({
|
||||
// sku_id: item.groupSnap[0].goods[0].skuId,
|
||||
// product_id: item.id,
|
||||
// number: item.groupSnap[0].goods[0].number,
|
||||
// });
|
||||
return;
|
||||
}
|
||||
//可选套餐
|
||||
@@ -573,11 +601,11 @@ function clearCarts() {
|
||||
cancelButtonText: "取消",
|
||||
type: "warning",
|
||||
}).then(() => {
|
||||
refCart.value.carts.clear();
|
||||
carts.clear();
|
||||
});
|
||||
}
|
||||
function addCarts(item) {
|
||||
refCart.value.carts.add(item);
|
||||
carts.add(item);
|
||||
}
|
||||
|
||||
watch(
|
||||
@@ -608,7 +636,7 @@ onMounted(async () => {
|
||||
router.replace(route.path);
|
||||
console.log(route.path);
|
||||
setTimeout(() => {
|
||||
refCart.value.carts.dataReset();
|
||||
carts.dataReset();
|
||||
refresh();
|
||||
}, 2000);
|
||||
return;
|
||||
@@ -619,24 +647,37 @@ onMounted(async () => {
|
||||
if (res.userId) {
|
||||
const userRes = await shopUserApi.get({ userId: res.userId });
|
||||
user.value = userRes;
|
||||
carts.changeUser(userRes);
|
||||
}
|
||||
//获取台桌数据
|
||||
if (res.tableCode) {
|
||||
const tableRes = await tableApi.get({ tableCode: res.tableCode });
|
||||
table.value = tableRes || {};
|
||||
}
|
||||
if (res) {
|
||||
oldOrder.value = res;
|
||||
orderInfo.value = res;
|
||||
showOrder.value = true;
|
||||
}
|
||||
//获取台桌数据
|
||||
if (res.tableCode) {
|
||||
}
|
||||
}
|
||||
init();
|
||||
});
|
||||
|
||||
function refresh() {
|
||||
console.log(refresh);
|
||||
oldOrder.value = {
|
||||
detailMap: [],
|
||||
};
|
||||
orderInfo.value = {};
|
||||
showOrder.value = false;
|
||||
user.value = {};
|
||||
table.value = {};
|
||||
router.replace(route.path);
|
||||
setTimeout(() => {
|
||||
router.go(1000);
|
||||
}, 1500);
|
||||
carts.dataReset();
|
||||
refCart.value.carts.init();
|
||||
// setTimeout(() => {
|
||||
// router.go(0);
|
||||
// }, 1500);
|
||||
}
|
||||
</script>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user