From 87e897635369f997b6eec25cefb1543739b9832b Mon Sep 17 00:00:00 2001 From: gyq <875626088@qq.com> Date: Wed, 19 Mar 2025 18:29:46 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E4=BC=9A=E5=91=98=E6=94=AF?= =?UTF-8?q?=E4=BB=98=EF=BC=8C=E5=B7=B2=E4=BC=9A=E5=91=98=E4=BB=B7=E7=BB=93?= =?UTF-8?q?=E7=AE=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/account.js | 2 +- src/components/payCard/payCard.vue | 17 +++- src/components/uploadImg.vue | 2 +- src/store/print.js | 30 ++++---- src/views/home/components/settleAccount.vue | 31 ++++---- src/views/member/components/addUserDrawer.vue | 4 + src/views/member/components/recordDialog.vue | 12 ++- src/views/member/index.vue | 1 - src/views/order/components/refundDrawer.vue | 77 ++++++++++++------- src/views/order/index.vue | 67 +++++++++++++++- src/views/queue/components/addTab.vue | 4 +- 11 files changed, 177 insertions(+), 70 deletions(-) diff --git a/src/api/account.js b/src/api/account.js index f2595d7..9b25301 100644 --- a/src/api/account.js +++ b/src/api/account.js @@ -187,7 +187,7 @@ export function callTableConfigPut(data) { */ export function addCallTable(data) { return request({ - method: "post", + method: data.id ? "put" : "post", url: "/account/admin/callTable", data, }); diff --git a/src/components/payCard/payCard.vue b/src/components/payCard/payCard.vue index d93de70..4906d69 100644 --- a/src/components/payCard/payCard.vue +++ b/src/components/payCard/payCard.vue @@ -358,12 +358,23 @@ async function vipPayAjax(row) { return } + goodsStore.showVipPrice = 1 + goodsStore.vipUserInfo = row + + goodsStore.calcCartInfo() + + reset() + payData.value.payType = 'userPay' payData.value.shopUserId = row.id payData.value.checkOrderPay.userId = row.userId payLoading.value = true; await vipPay(payData.value) + + goodsStore.showVipPrice = 0 + goodsStore.vipUserInfo = '' + emit("paySuccess"); } catch (error) { console.log(error); @@ -392,12 +403,12 @@ async function payTypeChange(index, item) { // 挂账支付 showBuyerHandle(); } - if(item.payType == 'deposit'){ + if (item.payType == 'deposit') { scanModalRef.value.show(); } // if (payActive.value != "buyer") { // if (payList.value[payActive.value].payType == "deposit") { - + // } // } } catch (error) { @@ -820,7 +831,7 @@ function reset() { orderId: goodsStore.orderListInfo.id, vipPrice: store.shopInfo.isMemberPrice ? goodsStore.showVipPrice : 0, // 是否使用会员价 allPack: goodsStore.allSelected, // 是否整单打包 - userId: goodsStore.vipUserInfo.id, + userId: goodsStore.vipUserInfo.userId, seatNum: goodsStore.tableInfo.num, // 用餐人数 originAmount: formatDecimal(+goodsStore.cartInfo.totalAmount), // 订单原金额(包含打包费+餐位费) 不含折扣价格 discountRatio: '', // 折扣比例(计算时 向上取整保留 两位小数) diff --git a/src/components/uploadImg.vue b/src/components/uploadImg.vue index 1fae192..95bf3d4 100644 --- a/src/components/uploadImg.vue +++ b/src/components/uploadImg.vue @@ -103,7 +103,7 @@ const beforeUpload = (file) => { return true; }; -function init(arr) { +function init(arr = []) { fileList.value = arr } diff --git a/src/store/print.js b/src/store/print.js index 80c7d33..dabbd27 100644 --- a/src/store/print.js +++ b/src/store/print.js @@ -24,23 +24,25 @@ export const usePrint = defineStore("print", { // 获取本地打印机 ipcRenderer.send("getPrintList"); ipcRenderer.on("printList", (event, arg) => { - // localPrintList.value = arg; - // console.log(localPrintList.value); this.localDevices = arg; }); - // 获取已添加的打印机 - const res = await printerList(); - this.deviceNoteList = res.records.filter( - (item) => item.status && item.subType == "cash" - ); - this.deviceLableList = res.records.filter( - (item) => item.status && item.subType == "label" - ); - console.log("打印队列初始化成功", { - deviceNoteList: this.deviceNoteList, - deviceLableList: this.deviceLableList, - }); + try { + // 获取已添加的打印机 + const res = await printerList(); + this.deviceNoteList = res.records.filter( + (item) => item.status && item.subType == "cash" + ); + this.deviceLableList = res.records.filter( + (item) => item.status && item.subType == "label" + ); + console.log("打印队列初始化成功", { + deviceNoteList: this.deviceNoteList, + deviceLableList: this.deviceLableList, + }); + } catch (error) { + console.error("获取已添加的打印机列表失败", error); + } }, // 检查本地打印机是否能正常使用 checkLocalPrint(address) { diff --git a/src/views/home/components/settleAccount.vue b/src/views/home/components/settleAccount.vue index 1915af6..9d61fa4 100644 --- a/src/views/home/components/settleAccount.vue +++ b/src/views/home/components/settleAccount.vue @@ -18,10 +18,7 @@
服务员:{{ store.userInfo.name || "暂无" }} - + {{ dayjs().format("M月D日 HH:mm") }}
@@ -88,7 +85,7 @@ import payCard from "@/components/payCard/payCard.vue"; import SettleItem from './settleItem.vue' import { print } from "@/api/pay"; import { shopStaffInfo } from '@/api/account.js' -import { ElMessage } from "element-plus"; +import { dayjs, ElMessage } from "element-plus"; import { formatPhoneNumber, getOrderByIdAjax, commOrderPrintData } from '@/utils/index.js' import useStorage from '@/utils/useStorage.js' import { useGlobal } from '@/store/global.js' @@ -136,7 +133,6 @@ const props = defineProps({ } }); -const cartList = ref([]) const orderList = ref([]) const isPrint = ref(1); const discountLoading = ref(false) @@ -196,19 +192,24 @@ const printHandle = _.throttle(async function () { // 打印订单标签 async function printOrderLable(isBefore = false) { try { - if (printStore.deviceNoteList.length) { - // 使用本地打印机打印 - const data = await getOrderByIdAjax(goodsStore.orderListInfo.id); + let orderId = goodsStore.orderListInfo.id + const data = await getOrderByIdAjax(orderId); + + if (printStore.deviceLableList.length) { if (!isBefore) { // 预结算不打印标签 printStore.labelPrint(commOrderPrintData(data)) } + } + + if (printStore.deviceNoteList.length) { + // 使用本地打印机打印 printStore.pushReceiptData(commOrderPrintData({ ...data, isBefore: isBefore })); } else { // 本地没有可用打印机使用云打印机 await orderPrint({ type: isBefore ? 1 : 0, - id: goodsStore.orderListInfo.id, + id: orderId, }); printLoading.value = false; ElMessage.success(`云打印${isBefore ? '预' : ''}结算单成功`); @@ -220,10 +221,10 @@ async function printOrderLable(isBefore = false) { // 订单已支付 function paySuccess() { + if (isPrint.value) printOrderLable() emits('success') dialogVisible.value = false; ElMessage.success('支付成功') - if (isPrint.value) printOrderLable() useStorage.del('tableCode') socket.cartInit() goodsStore.successClearCart() @@ -237,9 +238,6 @@ function show(t) { console.log(cartInfo.value); orderList.value = [...goodsStore.cartList, ...goodsStore.orderList.map(item => item.goods).flat()] - console.log('orderList===', orderList.value); - - // 每次初始化paycard setTimeout(() => { payCardRef.value.reset() @@ -304,11 +302,12 @@ defineExpose({ $padding: 10px; .master_id { + height: 77px; font-size: calc(var(--el-font-size-base) + 10px); border-bottom: 1px solid #ececec; padding: $padding 0; display: flex; - align-items: center; + flex-direction: column; justify-content: space-between; .member_info { @@ -336,7 +335,7 @@ defineExpose({ .list_wrap { padding: 0 var(--el-font-size-base); - height: calc(100vh - 200px); + height: calc(100vh - 222px); overflow-y: auto; } diff --git a/src/views/member/components/addUserDrawer.vue b/src/views/member/components/addUserDrawer.vue index 688af8c..9474f85 100644 --- a/src/views/member/components/addUserDrawer.vue +++ b/src/views/member/components/addUserDrawer.vue @@ -139,6 +139,10 @@ function resetHandle() { function show() { showDialog.value = true + + setTimeout(() => { + UploadImgRef.value.init() + }, 50) } defineExpose({ diff --git a/src/views/member/components/recordDialog.vue b/src/views/member/components/recordDialog.vue index bfc0b15..513fb03 100644 --- a/src/views/member/components/recordDialog.vue +++ b/src/views/member/components/recordDialog.vue @@ -1,5 +1,5 @@ +