优化下单

This commit is contained in:
gyq
2025-04-21 17:45:05 +08:00
parent 694cb154a6
commit b5773cf78c
12 changed files with 275 additions and 16268 deletions

View File

@@ -10,6 +10,11 @@ import { printerList } from "@/api/account.js";
export const usePrint = defineStore("print", {
state: () => ({
isPrintService: false, // 打印服务是否启动
printServiceTimer: false, // 打印服务定时器
printServiceTimerCount: 0, // 打印服务定时器计数
printServiceTimerMaxCount: 10, // 打印服务定时器最大计数
showPrintNotService: false, // 是否显示重启软件,
localDevices: [], // 本地打印机列表
deviceNoteList: [], // 添加的打印机
deviceLableList: [], // 添加的打印机
@@ -43,6 +48,36 @@ export const usePrint = defineStore("print", {
} catch (error) {
console.error("获取已添加的打印机列表失败", error);
}
// 检测打印服务是否启动
this.checkPrintService();
},
// 检测打印组件服务是否启动
checkPrintService() {
this.printServiceTimer = setInterval(() => {
if (
typeof LODOP !== "undefined" &&
LODOP.webskt &&
LODOP.webskt.readyState == 1
) {
// 准备好
this.isPrintService = true;
clearInterval(this.printServiceTimer);
this.printServiceTimer = null;
} else {
this.printServiceTimerCount++;
console.log("打印服务未启动", this.printServiceTimerCount);
if (this.printServiceTimerCount >= this.printServiceTimerMaxCount) {
// 超过最大次数
this.isPrintService = false;
this.showPrintNotService = true;
clearInterval(this.printServiceTimer);
this.printServiceTimer = null;
}
}
console.log("打印服务是否启动:", this.isPrintService);
}, 1000);
},
// 检查本地打印机是否能正常使用
checkLocalPrint(address) {
@@ -135,7 +170,8 @@ export const usePrint = defineStore("print", {
} else {
if (
this.deviceNoteList.length &&
this.checkLocalPrint(this.deviceNoteList[0].address)
this.checkLocalPrint(this.deviceNoteList[0].address) &&
this.isPrintService
) {
const store = useUser();
props.deviceName = this.deviceNoteList[0].address;