新增订单打印失败状态

This commit is contained in:
gyq
2025-12-29 16:09:04 +08:00
parent 3b729eabcd
commit 6ff949d97a
2 changed files with 40 additions and 11 deletions

View File

@@ -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) {

View File

@@ -89,6 +89,11 @@
用餐模式{{ filterLable("dineMode", scope.row.dineMode) }}
</div>
<div class="row">订单备注{{ scope.row.remark }}</div>
<div class="row">打印状态
<template v-if="scope.row.printStatus.length > 0">
打印失败{{scope.row.printStatus.map(item => item.name).join('、')}}
</template>
</div>
</div>
</template>
</el-table-column>
@@ -286,6 +291,7 @@ async function orderListAjax() {
const res = await orderList(queryForm.value);
res.records.map(item => {
item.payLoading = false
item.printStatus = JSON.parse(item.printStatus || '[]')
})
tableData.list = [];
tableData.list = res.records;
@@ -293,6 +299,8 @@ async function orderListAjax() {
tableRef.value.setScrollTop(0);
tableRef.value.setScrollLeft(0);
console.log("订单列表:", res);
} catch (error) {
console.log(error);
}