From 6ff949d97a278499f8cae0ab246dea895b3a0afe Mon Sep 17 00:00:00 2001 From: gyq <875626088@qq.com> Date: Mon, 29 Dec 2025 16:09:04 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E8=AE=A2=E5=8D=95=E6=89=93?= =?UTF-8?q?=E5=8D=B0=E5=A4=B1=E8=B4=A5=E7=8A=B6=E6=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/store/print.js | 43 +++++++++++++++++++++++++++++---------- src/views/order/index.vue | 8 ++++++++ 2 files changed, 40 insertions(+), 11 deletions(-) diff --git a/src/store/print.js b/src/store/print.js index 21394d4..c5a54a5 100644 --- a/src/store/print.js +++ b/src/store/print.js @@ -7,6 +7,7 @@ import lodopPrintWork from "@/components/lodop/lodopPrintWork.js"; import invoicePrint from "@/components/lodop/invoicePrint.js"; import refundPrint from "@/components/lodop/refundPrint.js"; import { printerList } from "@/api/account.js"; +import { useSocket } from './socket.js'; export const usePrint = defineStore("print", { state: () => ({ @@ -174,6 +175,7 @@ export const usePrint = defineStore("print", { this.isPrintService ) { const store = useUser(); + props.deviceId = this.deviceNoteList[0].id; props.deviceName = this.deviceNoteList[0].address; props.shop_name = store.shopInfo.shopName; props.loginAccount = store.userInfo.name; @@ -197,17 +199,36 @@ export const usePrint = defineStore("print", { } }, // 开始打印小票 - startReceiptPrint() { - if (this.receiptTimer !== null) return; - this.receiptTimer = setInterval(() => { - if (!this.receiptList.length) { - clearInterval(this.receiptTimer); - this.receiptTimer = null; - } else { - receiptPrint(this.receiptList[0]); - this.receiptList.splice(0, 1); - } - }, 2000); + async startReceiptPrint() { + try { + const socketStore = useSocket(); + const userStore = useUser(); + + if (this.receiptTimer !== null) return; + this.receiptTimer = setInterval(() => { + if (!this.receiptList.length) { + clearInterval(this.receiptTimer); + this.receiptTimer = null; + } else { + receiptPrint(this.receiptList[0]); + // 在这里触发已打印操作标记 + const data = { + type: "cashier", + operate_type: "order_print_status", + table_code: this.receiptList[0].orderInfo.tableCode, + account: userStore.shopInfo.account, + print_status: "1", + order_id: this.receiptList[0].orderInfo.id, + print_id: this.receiptList[0].deviceId, + shop_id: this.receiptList[0].orderInfo.shopId, + } + socketStore.ws.send(JSON.stringify(data)); + this.receiptList.splice(0, 1); + } + }, 2000); + } catch (error) { + console.log(error); + } }, // 打印交班小票 printWork(data) { diff --git a/src/views/order/index.vue b/src/views/order/index.vue index 8faab5c..dd38ef6 100644 --- a/src/views/order/index.vue +++ b/src/views/order/index.vue @@ -89,6 +89,11 @@ 用餐模式:{{ filterLable("dineMode", scope.row.dineMode) }}