diff --git a/src/api/order.js b/src/api/order.js index 3b14d71..99b0ac9 100644 --- a/src/api/order.js +++ b/src/api/order.js @@ -194,3 +194,16 @@ export function vipPay(data) { data, }); } + +/** + * 订单打印 + * @param {*} data + * @returns + */ +export function orderPrint(data) { + return request({ + method: "post", + url: "/order/admin/order/print", + data, + }); +} diff --git a/src/api/product_new.js b/src/api/product_new.js index a27c013..63005ca 100644 --- a/src/api/product_new.js +++ b/src/api/product_new.js @@ -25,3 +25,29 @@ export function productPage(params) { params, }); } + +/** + * 商品上下架 + * @param {*} data + * @returns + */ +export function productOnOff(data) { + return request({ + method: "post", + url: "/product/admin/product/onOff", + data, + }); +} + +/** + * 商品售罄 + * @param {*} data + * @returns + */ +export function markIsSoldOut(data) { + return request({ + method: "post", + url: "/product/admin/product/markIsSoldOut", + data, + }); +} diff --git a/src/components/lodop/lodopPrintWork.js b/src/components/lodop/lodopPrintWork.js index a43d0a5..f7a1633 100644 --- a/src/components/lodop/lodopPrintWork.js +++ b/src/components/lodop/lodopPrintWork.js @@ -12,7 +12,7 @@ export default (data) => { LODOP.SET_PRINTER_INDEX(data.deviceName); // 文字内容 let html = ` -
+
${data.shopName}
diff --git a/src/components/lodop/receiptPrint.js b/src/components/lodop/receiptPrint.js index 38ddf9e..013f066 100644 --- a/src/components/lodop/receiptPrint.js +++ b/src/components/lodop/receiptPrint.js @@ -17,20 +17,15 @@ export default (data) => { let t1 = 40; let t2 = (100 - t1) / 3; let html = ` -
+
${data.shop_name}
- ${data.isBefore ? "预" : ""}结算单【${ - data.orderInfo.masterId ? data.orderInfo.masterId : "" - }】 + ${data.isBefore ? "预" : ""}结算单
桌号:${data.orderInfo && data.orderInfo.tableName || ''}
-
- ${data.orderInfo.outNumber ? data.orderInfo.outNumber : ""} -
订单号:${data.orderInfo && data.orderInfo.orderNo}
diff --git a/src/components/lodop/refundPrint.js b/src/components/lodop/refundPrint.js index 2f830ab..dc17566 100644 --- a/src/components/lodop/refundPrint.js +++ b/src/components/lodop/refundPrint.js @@ -13,12 +13,9 @@ export default (data) => { let t1 = 40; let t2 = (100 - t1) / 3; let html = ` -
+
${data.shop_name}
-
- 退款单【${data.orderInfo.masterId ? data.orderInfo.masterId : ""}】 -
桌号:${data.orderInfo && data.orderInfo.tableName || ''}
diff --git a/src/store/goods.js b/src/store/goods.js index 4ee416b..2900306 100644 --- a/src/store/goods.js +++ b/src/store/goods.js @@ -43,8 +43,48 @@ export const useGoods = defineStore("goods", { originGoodsList: [], // 原始商品列表 orderList: [], // 订单列表 orderListInfo: "", // 历史订单信息 + cartType: "cart", // cart order + cartOrderItem: "", }), actions: { + // 选中订单中的商品 + selectOrderItem(index = null, i) { + this.orderList.map((item) => { + item.goods.map((val) => { + val.active = false; + }); + }); + + if (index !== null) { + this.selectCartItemHandle(); + + this.cartType = "order"; + if (this.orderList.length) { + if (!this.orderList[index].goods[i].active) { + this.orderList[index].goods[i].active = true; + } else { + this.orderList[index].goods[i].active = false; + } + this.cartOrderItem = this.orderList[index].goods[i]; + } + } + }, + // 选中购物车商品 + selectCartItemHandle(index = null) { + this.cartList.map((val) => { + val.active = false; + }); + if (index !== null) { + this.selectOrderItem(); + + this.cartType = "cart"; + this.cartActiveIndex = index; + + if (this.cartList.length) { + this.cartList[index].active = true; + } + } + }, // 手动选择台桌 selectTable(tableInfo = {}) { const socket = useSocket(); @@ -95,6 +135,9 @@ export const useGoods = defineStore("goods", { async initGoods() { await this.getCategoryList(); await this.getGoodsList(); + + let tableCode = useStorage.get("tableCode"); + if (tableCode) this.historyOrderAjax(tableCode); }, // 切换商品分类 setCategoryIndex(index) { @@ -104,7 +147,11 @@ export const useGoods = defineStore("goods", { if (index == 0) { // this.getGoodsList(); this.goodsList = _.chunk(this.originGoodsList, 12); - } else { + } + // else if (this.categoryList[index].id == "off_sale") { + // // 筛选已下架的商品 + // } + else { // 除了全部,其他只做本地筛选 this.goodsList = _.chunk( this.originGoodsList.filter( @@ -138,7 +185,7 @@ export const useGoods = defineStore("goods", { }); // this.categoryList.push({ // name: "已下架", - // id: "-1", + // id: "off_sale", // }); } catch (error) { console.log(error); @@ -169,17 +216,6 @@ export const useGoods = defineStore("goods", { console.log(error); } }, - // 选中购物车商品 - selectCartItemHandle(index) { - this.cartActiveIndex = index; - - if (this.cartList.length) { - this.cartList.map((val) => { - val.active = false; - }); - this.cartList[index].active = true; - } - }, // 获取购物车列表,数据必须由长链接返回 async getCartList(arr) { const store = useUser(); @@ -436,6 +472,7 @@ export const useGoods = defineStore("goods", { arr.map((val, index) => { let lowPrice = 0; + let number = val.number - (val.returnNum || 0); if (this.vipUserInfo.id && store.shopInfo.isMemberPrice) { lowPrice = val.memberPrice; @@ -443,7 +480,7 @@ export const useGoods = defineStore("goods", { lowPrice = val.lowPrice; } - total += +val.number; + total += number; if (+val.pack_number && !val.is_temporary) { packFeeNumber += +val.pack_number; @@ -452,39 +489,39 @@ export const useGoods = defineStore("goods", { if (val.is_temporary) { if (val.is_gift) { - gifNumber += +val.number; - gifNumberAmount += +val.number * +val.discount_sale_amount; + gifNumber += +number; + gifNumberAmount += +number * +val.discount_sale_amount; } else { // 临时菜使用discount_sale_amount计算价格 - totalAmount += val.number * val.discount_sale_amount; + totalAmount += number * val.discount_sale_amount; } } else { if (val.is_gift) { // 赠送 if (+val.discount_sale_amount) { // 且有折扣 - gifNumber += +val.number; - gifNumberAmount += +val.number * val.discount_sale_amount; + gifNumber += +number; + gifNumberAmount += +number * val.discount_sale_amount; - saleNumber += +val.number; + saleNumber += +number; saleNumberAmount += - val.number * (lowPrice - val.discount_sale_amount); + number * (lowPrice - val.discount_sale_amount); } else { - gifNumber += +val.number; - gifNumberAmount += +val.number * +lowPrice; + gifNumber += +number; + gifNumberAmount += +number * +lowPrice; } } else { if (+val.discount_sale_amount) { // 代表打过折 - saleNumber += +val.number; + saleNumber += +number; saleNumberAmount += - val.number * (lowPrice - val.discount_sale_amount); + number * (lowPrice - val.discount_sale_amount); // 使用正常价减去折扣价格计算 - totalAmount += val.number * val.discount_sale_amount; + totalAmount += number * val.discount_sale_amount; } else { // 使用正常价格计算 - totalAmount += val.number * lowPrice; + totalAmount += number * lowPrice; } } } diff --git a/src/store/print.js b/src/store/print.js index 7b86027..80c7d33 100644 --- a/src/store/print.js +++ b/src/store/print.js @@ -102,7 +102,7 @@ export const usePrint = defineStore("print", { // 执行打印操作 this.startLabelPrint(); } else { - console.log("没有标签打印机"); + console.log("标签打印:未在本机查询到打印机"); } }, // 开始打印标签数据 @@ -154,7 +154,7 @@ export const usePrint = defineStore("print", { this.receiptList.push(props); this.startReceiptPrint(); } else { - console.log("订单小票:没有小票打印机"); + console.log("订单小票:未在本机查询到打印机"); } } }, @@ -177,10 +177,10 @@ export const usePrint = defineStore("print", { this.deviceNoteList.length && this.checkLocalPrint(this.deviceNoteList[0].address) ) { - data.address = this.deviceNoteList[0].address; + data.deviceName = this.deviceNoteList[0].address; lodopPrintWork(data); } else { - console.log("交班小票:没有小票打印机"); + console.log("交班小票:未在本机查询到打印机"); } }, // 打印订单发票 @@ -189,10 +189,10 @@ export const usePrint = defineStore("print", { this.deviceNoteList.length && this.checkLocalPrint(this.deviceNoteList[0].address) ) { - data.address = this.deviceNoteList[0].address; + data.deviceName = this.deviceNoteList[0].address; invoicePrint(data); } else { - console.log("订单发票:没有小票打印机"); + console.log("订单发票:未在本机查询到打印机"); } }, // 打印退单小票 @@ -201,10 +201,10 @@ export const usePrint = defineStore("print", { this.deviceNoteList.length && this.checkLocalPrint(this.deviceNoteList[0].address) ) { - data.address = this.deviceNoteList[0].address; + data.deviceName = this.deviceNoteList[0].address; refundPrint(data); } else { - console.log("退单小票:没有小票打印机"); + console.log("退单小票:未在本机查询到打印机"); } }, }, diff --git a/src/store/user.js b/src/store/user.js index 8a6bddd..c0ee483 100644 --- a/src/store/user.js +++ b/src/store/user.js @@ -66,10 +66,6 @@ export const useUser = defineStore("user", { this.token = ""; socket.close(); - - setTimeout(() => { - window.onload(); - }, 1000); } catch (error) { console.log(error); } diff --git a/src/views/home/components/cartItem.vue b/src/views/home/components/cartItem.vue index 186f06e..1822a5f 100644 --- a/src/views/home/components/cartItem.vue +++ b/src/views/home/components/cartItem.vue @@ -65,8 +65,8 @@
打包({{ +props.item.pack_number }})
-
- 退 +
+ 退({{ props.item.returnNum }})
@@ -117,8 +117,8 @@ const props = defineProps({ function selectCartItemHandle() { if (props.type == 'cart') { goodsStore.selectCartItemHandle(props.index) - } else { - + } else if (props.type == 'order') { + goodsStore.selectOrderItem(props.index, props.i) } } diff --git a/src/views/home/components/cartOperation.vue b/src/views/home/components/cartOperation.vue index af71d00..7939ada 100644 --- a/src/views/home/components/cartOperation.vue +++ b/src/views/home/components/cartOperation.vue @@ -1,89 +1,167 @@ +
@@ -147,6 +225,27 @@ + + + + + + + + + +