单品备注
@@ -1254,6 +1259,7 @@ import moneyKeyboard from "./components/money-keyboard.vue";
import dayjs from "dayjs";
import { tbShopInfo } from "@/api/user";
import { hasPermission } from "@/utils/limits.js";
+import { tbOrderInfoDetail } from "@/api/order";
import {
getGoodsLists,
@@ -1283,12 +1289,15 @@ import {
isCanBuy,
arrayContainsAll,
generateCombinations,
- returnReverseVal,$strMatch,
+ returnReverseVal,
+ $strMatch,
returnGiftArr,
+ returnPackFee,
+ formatOrderGoodsList
} from "./util.js";
import { $status } from "@/utils/table.js";
-let $originTableList=[]
+let $originTableList = [];
export default {
components: {
returnCart,
@@ -1305,7 +1314,7 @@ export default {
data() {
return {
//台桌搜索文字
- tableSearchText:"",
+ tableSearchText: "",
//是否允许收款
canShoukuan: false,
//是否允许下单
@@ -1605,12 +1614,18 @@ export default {
.reduce((a, b) => {
return a + b.number * b.salePrice;
}, 0);
- return (
- oldPrice +
- price +
- +this.order.packFee.totalAmount +
+
+ const nowPackFee = returnPackFee(this.order.list, false);
+ const oldackFee = returnPackFee(this.order.old.list);
+ const packFee = nowPackFee + oldackFee;
+ const returnStatus = ["return", "refunding", "refund"];
+ const seatFee =
this.order.seatFee.totalAmount *
- (this.order.seatFee.status == "return" ? 0 : 1)
+ (returnStatus.includes(this.order.seatFee.status) ? 0 : 1);
+ console.log(nowPackFee, oldackFee, packFee, seatFee);
+ return (
+ (oldPrice + price + +packFee + seatFee) *
+ this.createOrder.discount
).toFixed(2);
},
allNumber() {
@@ -1687,8 +1702,10 @@ export default {
// })
}
},
- table(oldval, newval) {
- this.onTableChange();
+ table(newval, oldval) {
+ if (newval&&newval.tableId) {
+ this.onTableChange();
+ }
},
masterId: function (val) {
console.log(val);
@@ -1699,15 +1716,15 @@ export default {
}
},
"vipUser.id": async function (val) {
- if (!this.table.tableId) {
- return;
- }
- let masterId = this.order.masterId;
- if (!masterId) {
- const res = await this.getMasterId();
- masterId = res.masterId;
- }
- this.masterId = masterId;
+ // if (!this.table.tableId) {
+ // return;
+ // }
+ // let masterId = this.order.masterId;
+ // if (!masterId) {
+ // const res = await this.getMasterId();
+ // masterId = res.masterId;
+ // }
+ // this.masterId = masterId;
$setUser({
tableId: this.table.tableId,
masterId: this.masterId,
@@ -1826,13 +1843,15 @@ export default {
// this.getCategory();
// this.refToggle('refScanCode',true)
// this.refToggle("refDiscount", true);
- console.log(this.$route.query.tableId);
- this.open(this.$route.query.tableId ? this.$route.query : "");
+ // this.open(this.$route.query.tableId ? this.$route.query : "");
+ this.open(this.$route.query);
},
methods: {
- searchInput(e){
- console.log(e)
- this.tableList=$originTableList.filter(v=>$strMatch(v.name,e.trim()))
+ searchInput(e) {
+ console.log(e);
+ this.tableList = $originTableList.filter((v) =>
+ $strMatch(v.name, e.trim())
+ );
},
returnTableColor(key) {
const item = $status[key];
@@ -1861,7 +1880,8 @@ export default {
this.order.extra.selIndex = index;
},
async morePayClick() {
- if (this.order.list.length <= 0) {
+
+ if (this.order.list.length <= 0 && !this.createOrder.data) {
return this.$message("请选择菜品");
}
const canJiesuan = await this.shoukuanClick();
@@ -1871,13 +1891,14 @@ export default {
// if(this.isCreateOrder){
// return
// }
- const res = await this.returnCreateOrderData();
+ await this.returnCreateOrderData();
this.payBeforeClear();
- this.createOrder.data = res;
- this.order.payType = "";
- this.isCreateOrder = true;
+ // this.order.payType = "";
},
async cashPayClick() {
+ if(!this.createOrder.data.id&&this.order.list.length <= 0){
+ return this.$message("没有要结算的订单或商品!");
+ }
const canJiesuan = await this.shoukuanClick();
if (!canJiesuan) {
return;
@@ -1892,6 +1913,13 @@ export default {
});
},
async returnCreateOrderData() {
+ if (this.key == "isJieZhang"||this.order.list.length <= 0) {
+ //结账来的下单或者已经生成订单
+ // this.order.old.list = formatOrderGoodsList(this.createOrder.data.detailList||[]);
+ this.isCreateOrder=true
+ return this.createOrder.data;
+ }
+ this.order.list = [];
const res = await $createOrder({
masterId: this.order.masterId || this.masterId,
vipUserId: this.vipUser.id,
@@ -1900,6 +1928,9 @@ export default {
postPay: this.postPay,
orderld: this.order.orderId,
});
+ this.isCreateOrder=true
+ this.order.old.list = formatOrderGoodsList(res.detailList||[]);
+ this.getOrderData({orderId:res.id})
this.createOrder.data = res;
this.createOrder.discount = 1;
// const lastItem = this.order.old.list[this.order.old.list.length - 1];
@@ -1908,27 +1939,22 @@ export default {
// ...this.order.old.list,
// { info: this.order.list, placeNum: nowPlaceNum + 1 },
// ];
- this.order.list = [];
- this.order.old.list = [];
+ console.log(this.order.old.list);
return res;
},
async payBeforeClear() {
- this.getMasterId().then((res) => {
- this.masterId = res.masterId;
- });
+
this.loading = false;
- this.order.list = [];
this.order.query.page = 1;
this.goods.total = 0;
this.order.list = [];
this.order.selIndex = -1;
this.order.selPlaceNum = -1;
this.order.selGoods = "";
- this.order.seatFee = { totalAmount: 0 }; //餐位费
this.prveOrder.list = [];
this.prveOrder.selIndex = -1;
this.order.old.selIndex = -1;
- this.isCreateOrder = false;
+ // this.isCreateOrder = false;
this.createOrder.status = "";
this.createOrder.code = "";
this.note.content = "";
@@ -1942,7 +1968,6 @@ export default {
this.key = "";
this.order.orderId = "";
this.perpole = "";
- // this.useTypes.sel = "dine-in";
},
async cachePay() {
const canJiesuan = await this.shoukuanClick();
@@ -1954,12 +1979,14 @@ export default {
this.pays();
},
async scanPayClick() {
+ if(!this.createOrder.data.id&&this.order.list.length <= 0 ){
+ return this.$message("没有要结算的订单或商品!");
+ }
const canJiesuan = await this.shoukuanClick();
if (!canJiesuan) {
return;
}
const order = await this.returnCreateOrderData();
- console.log(this.createOrder.data);
this.order.payType = "scanCode";
this.payTypeItemClick({ payType: "scanCode", order });
this.payBeforeClear();
@@ -2099,15 +2126,17 @@ export default {
},
//退菜
async refReturnCartConfirm(e) {
+ console.log(this.order.selGoods);
const res = await $returnCart({
...e,
- cartId: this.order.selGoods.id,
+ cartId:this.order.selGoods.cartId,
tableId: this.table.tableId,
});
this.order.selGoods.status = "return";
this.order.old.selIndex = -1;
- this.getCart();
- console.log(this.order.selGoods);
+ // this.getCart();
+ this.getOrderData()
+ // console.log(this.order.selGoods);
},
// 台桌列表
@@ -2120,16 +2149,16 @@ export default {
this.tableList = content.filter(
(v) => v.status != "closed" && v.status != "cleaning"
);
- $originTableList=this.tableList
+ $originTableList = this.tableList;
} catch (error) {
console.log(error);
}
},
async changeTable(item) {
- console.log(this.table);
if (this.table || this.order.list.length <= 0) {
this.table = item;
this.tableShow = false;
+ console.log(this.table);
return;
}
if (item.status != "idle") {
@@ -2230,7 +2259,7 @@ export default {
isSellOut(item) {
return (
item.isPauseSale ||
- (item.typeEnum !== "sku" &&
+ (
(item.isStock == 1 ? item.stockNumber <= 0 : false))
);
},
@@ -2547,7 +2576,9 @@ export default {
//右侧控制按钮点击事件
orderBtnsClick(key) {
const orderGoods = this.order.list[this.order.selIndex];
- this.createOrderClose();
+ if (this.key != "isJieZhang"&&this.postPay) {
+ this.createOrderClose();
+ }
if (key === "sku") {
this.selGoods.title = orderGoods.name;
this.selGoods.isEdit = true;
@@ -2721,8 +2752,8 @@ export default {
this.$nextTick(() => {
this.getCacheOrder();
});
- const masterIdRes = await this.getMasterId();
- this.masterId = masterIdRes.masterId;
+ await this.getMasterId();
+
},
// 删除购物车商品
removeCart() {
@@ -3277,6 +3308,18 @@ export default {
this.$goodsData = goods;
},
async open(params) {
+ const item = {
+ name: params.table_name,
+ tableId: params.tableId,
+ useType: params.useType,
+ maxCapacity: params.maxCapacity * 1,
+ masterId: params.masterId,
+ orderId: params.orderId,
+ },
+ key = params.key,
+ perpoleNumber = params.num || "";
+ this.key = key;
+
const shopId = localStorage.getItem("shopId");
const shopInfo = await tbShopInfo(shopId);
for (let i in shopInfo.eatModel) {
@@ -3290,28 +3333,40 @@ export default {
}
}
this.shopInfo = shopInfo;
- this.setPostPay();
+ if (!params.masterId) {
+ await this.getMasterId();
+ this.getCart()
+ } else {
+ this.masterId = params.masterId;
+ }
+ if (key == "isJieZhang") {
+ this.postPay = false;
+ } else {
+ this.setPostPay();
+ }
this.setUseType();
this.getGoods();
this.getCategory();
this.getTable();
console.log(params);
- const res = await this.getMasterId();
- console.log(res);
- if (!params) {
- //无台桌代客下单
+ if (key == "isJieZhang") {
+ this.perpole = perpoleNumber;
+ this.table = params.tableId ? { name: item.name } : "";
+ if (params.orderId) {
+ const orderRes = await this.getOrderData(params);
+ if (orderRes.status != "unpaid") {
+ this.$router.replace({ path: "/tool/Instead/index" });
+ }
+ }
+ this.isCreateOrder = true;
return;
}
- const item = {
- name: params.table_name,
- tableId: params.tableId,
- useType: params.useType,
- maxCapacity: params.maxCapacity * 1,
- masterId: params.masterId,
- orderId: params.orderId,
- },
- key = params.key,
- perpoleNumber = params.num;
+ // this.getCart();
+ // this.getCacheOrder();
+ // if (!params) {
+ // //无台桌代客下单
+ // return;
+ // }
//有台桌时的代客下单
if (item && item.useType) {
localStorage.setItem("useType", item.useType);
@@ -3320,17 +3375,72 @@ export default {
? item.useType
: item.useType.replace(/-after|-before/g, "");
}
- this.key = key;
- this.isCreateOrder = this.key == "isPayOrder" ? true : false;
+ this.isCreateOrder =
+ this.key == "isPayOrder" || this.key == "isJieZhang" ? true : false;
+
this.perpole = perpoleNumber;
- this.table = item;
- this.masterId = item.masterId;
+ this.table = params.tableId ? { name: item.name } : "";
+ },
+ async getOrderData(params) {
+ const res = await tbOrderInfoDetail(params?params.orderId:this.createOrder.data.id);
+ if (res.status != "unpaid") {
+ return res;
+ }
+ this.createOrder.data = res;
+ this.order.packFee.totalAmount = res.seatInfo || { totalAmount: 0 };
+ const goodsMap = {};
+ for (let i in res.detailList) {
+ const goods = res.detailList[i];
+ if (goods.productId != "-999") {
+ if (goodsMap.hasOwnProperty(goods.placeNum)) {
+ goodsMap[goods.placeNum].push(goods);
+ } else {
+ goodsMap[goods.placeNum] = [goods];
+ }
+ }
+ }
+ this.order.seatFee = res.seatInfo
+ ? {
+ ...res.seatInfo,
+ totalNumber: res.seatInfo.num,
+ number: res.seatInfo.num,
+ name: res.seatInfo.productName,
+ totalAmount: res.seatInfo.priceAmount,
+ }
+ : {
+ name: "客座费",
+ number: res.seatCount||0,
+ totalNumber: res.seatCount||0,
+ totalAmount: res.seatAmount||0,
+ status: "",
+ };
+ console.log(this.order.seatFee);
+ this.order.old.list = Object.entries(goodsMap).map(([key, value]) => ({
+ info: value.map((v) => {
+ return {
+ ...v,
+ coverImg: v.productImg,
+ name: v.productName,
+ specSnap: v.productSkuName,
+ number: v.num,
+ totalAmount: v.priceAmount,
+ salePrice: v.price,
+ isGift: v.gift ? "true" : "false",
+ isPack: v.pack ? "true" : "false",
+ };
+ }),
+ placeNum: key,
+ }));
+ console.log(this.order.old.list);
+ return res;
},
close() {
+ this.reset()
if (this.table.tableId) {
this.$router.replace({ path: "/tool/table_list" });
} else {
- this.$router.go(0);
+ this.$router.replace({ path: "/tool/Instead/index" });
+ // this.$router.go(0);
// this.reset();
// this.$router.replace({ path: "/tool/Instead/index" });
}
diff --git a/src/views/tool/Instead/util.js b/src/views/tool/Instead/util.js
index 817166c..d2556bf 100644
--- a/src/views/tool/Instead/util.js
+++ b/src/views/tool/Instead/util.js
@@ -1,16 +1,34 @@
+//计算打包费
+export function returnPackFee(arr, isOld = true) {
+ if (isOld) {
+ return arr.reduce((a, b) => {
+ const bTotal = b.info
+ .filter((v) => v.isGift !== "true" && v.status !== "return")
+ .reduce((prve, cur) => {
+ return prve + (cur.packFee || cur.packAmount||0);
+ }, 0);
+ return a + bTotal;
+ }, 0);
+ } else {
+ return arr.filter(v => v.status !== 'return' && v.isGift !== 'true').reduce((a, b) => {
+ return a + (b.packFee || b.packAmount||0);
+ }, 0);
+ }
+
+}
//判断商品是否可以下单
-export function isCanBuy(skuGoods,goods) {
- if(goods.typeEnum=='normal'){
+export function isCanBuy(skuGoods, goods) {
+ if (goods.typeEnum == 'normal') {
//单规格
- return goods.isGrounding&&goods.isPauseSale==0&&(goods.isStock?goods.stockNumber>0:true);
- }else{
+ return goods.isGrounding && goods.isPauseSale == 0 && (goods.isStock ? goods.stockNumber > 0 : true);
+ } else {
//多规格
- return goods.isGrounding&&goods.isPauseSale==0&&skuGoods.isGrounding&&skuGoods.isPauseSale==0&&(goods.isStock?goods.stockNumber>0:true);
+ return goods.isGrounding && goods.isPauseSale == 0 && skuGoods.isGrounding && skuGoods.isPauseSale == 0 && (goods.isStock ? goods.stockNumber > 0 : true);
}
}
//字符匹配
-export function $strMatch(matchStr,str){
+export function $strMatch(matchStr, str) {
return matchStr.toLowerCase().includes(str.toLowerCase())
}
@@ -59,15 +77,34 @@ export function returnReverseVal(val, isReturnString = true) {
return reverseNewval;
}
-export function returnGiftArr(arr){
- let result=[]
- for(let i=0;i
({
+ info: value,
+ placeNum: key||1
+ }))
}
\ No newline at end of file
From 924f296ad1437f84a4b0291e26af03822fac9a10 Mon Sep 17 00:00:00 2001
From: YeMingfei666 <1619116647@qq.com>
Date: Thu, 31 Oct 2024 18:25:52 +0800
Subject: [PATCH 04/10] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=BB=A3=E5=AE=A2?=
=?UTF-8?q?=E4=B8=8B=E5=8D=95=E7=9B=B8=E5=85=B3=E9=80=BB=E8=BE=91?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/views/tool/Instead/index.vue | 138 +++++++++++++++++--------------
1 file changed, 78 insertions(+), 60 deletions(-)
diff --git a/src/views/tool/Instead/index.vue b/src/views/tool/Instead/index.vue
index 229a95c..9797004 100644
--- a/src/views/tool/Instead/index.vue
+++ b/src/views/tool/Instead/index.vue
@@ -407,7 +407,11 @@
-
+
-
¥1231
+
{{ countData.count }}
总订单数
@@ -46,7 +46,7 @@