优化订单打印
This commit is contained in:
parent
e13727e6ff
commit
0c45fd9de1
|
|
@ -20,10 +20,10 @@ VITE_API_PHP_URL = 'https://newblockwlx.sxczgkj.cn/index.php/api'
|
||||||
VITE_API_KP_URL = 'https://invoice.sxczgkj.cn/api'
|
VITE_API_KP_URL = 'https://invoice.sxczgkj.cn/api'
|
||||||
|
|
||||||
# 本地调试连接
|
# 本地调试连接
|
||||||
VITE_API_URL = 'http://192.168.1.31/'
|
# VITE_API_URL = 'http://192.168.1.31/'
|
||||||
|
|
||||||
# 线上测试
|
# 线上测试
|
||||||
# VITE_API_URL = 'https://tapi.cashier.sxczgkj.cn'
|
# VITE_API_URL = 'https://tapi.cashier.sxczgkj.cn'
|
||||||
|
|
||||||
# 线上正式
|
# 线上正式
|
||||||
# VITE_API_URL = 'https://cashier.sxczgkj.com'
|
VITE_API_URL = 'https://cashier.sxczgkj.com'
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
{
|
{
|
||||||
"name": "vite-electron",
|
"name": "vite-electron",
|
||||||
"private": true,
|
"private": true,
|
||||||
"version": "2.0.0",
|
"version": "2.0.3",
|
||||||
"main": "dist-electron/main.js",
|
"main": "dist-electron/main.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "chcp 65001 && vite",
|
"dev": "chcp 65001 && vite",
|
||||||
|
|
|
||||||
|
|
@ -61,6 +61,8 @@ export const useGoods = defineStore("goods", {
|
||||||
this.goodsListLoading = false;
|
this.goodsListLoading = false;
|
||||||
this.goodsList = [];
|
this.goodsList = [];
|
||||||
this.originGoodsList = [];
|
this.originGoodsList = [];
|
||||||
|
|
||||||
|
useStorage.del("printList");
|
||||||
},
|
},
|
||||||
// 清除会员信息
|
// 清除会员信息
|
||||||
clearVipUserInfo() {
|
clearVipUserInfo() {
|
||||||
|
|
|
||||||
|
|
@ -16,6 +16,7 @@ export const useSocket = defineStore("socket", {
|
||||||
orderList: [],
|
orderList: [],
|
||||||
orderListTimer: null,
|
orderListTimer: null,
|
||||||
log: false,
|
log: false,
|
||||||
|
isPrinting: false,
|
||||||
}),
|
}),
|
||||||
actions: {
|
actions: {
|
||||||
// 关闭ws
|
// 关闭ws
|
||||||
|
|
@ -147,11 +148,15 @@ export const useSocket = defineStore("socket", {
|
||||||
}
|
}
|
||||||
} else if (data.data_type == "order") {
|
} else if (data.data_type == "order") {
|
||||||
// 收到订单消息,打印订单小票
|
// 收到订单消息,打印订单小票
|
||||||
if (!this.orderList.some((el) => el == data.data)) {
|
let printList = useStorage.get("printList") || [];
|
||||||
|
if (!printList.some((el) => el == data.data)) {
|
||||||
// 防止重复打印
|
// 防止重复打印
|
||||||
this.orderList.push(data.data);
|
this.orderList.push(data.data);
|
||||||
this.startPrintInterval();
|
this.startPrintInterval();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
printList.push(data.data);
|
||||||
|
useStorage.set("printList", _.uniq(printList));
|
||||||
} else if (data.data_type == "product_update") {
|
} else if (data.data_type == "product_update") {
|
||||||
// 商品更新
|
// 商品更新
|
||||||
this.updateGoods();
|
this.updateGoods();
|
||||||
|
|
@ -189,28 +194,35 @@ export const useSocket = defineStore("socket", {
|
||||||
},
|
},
|
||||||
// 打印队列开始执行
|
// 打印队列开始执行
|
||||||
startPrintInterval() {
|
startPrintInterval() {
|
||||||
|
if (this.isPrinting) return; // 如果正在打印,直接返回
|
||||||
|
this.isPrinting = true; // 标记为正在打印
|
||||||
|
|
||||||
const printStore = usePrint();
|
const printStore = usePrint();
|
||||||
if (this.orderListTimer !== null) return;
|
const printNextOrder = async () => {
|
||||||
this.orderListTimer = setInterval(async () => {
|
|
||||||
try {
|
try {
|
||||||
if (!this.orderList.length) {
|
if (!this.orderList.length) {
|
||||||
clearInterval(this.orderListTimer);
|
this.isPrinting = false; // 订单处理完,标记为不在打印
|
||||||
this.orderListTimer = null;
|
return;
|
||||||
} else {
|
}
|
||||||
const orderInfo = await getOrderByIdAjax(this.orderList[0]);
|
const orderInfo = await getOrderByIdAjax(this.orderList[0]);
|
||||||
if (orderInfo.status == "done" && orderInfo.platformType != "PC") {
|
if (orderInfo.status == "done" && orderInfo.platformType != "PC") {
|
||||||
// 打印小票
|
// 打印小票
|
||||||
printStore.pushReceiptData(commOrderPrintData(orderInfo));
|
printStore.pushReceiptData(commOrderPrintData(orderInfo));
|
||||||
// 打印标签小票
|
// 打印标签小票
|
||||||
printStore.labelPrint(commOrderPrintData(orderInfo));
|
printStore.labelPrint(commOrderPrintData(orderInfo));
|
||||||
}
|
|
||||||
this.orderList.splice(0, 1);
|
|
||||||
}
|
}
|
||||||
} catch (error) {
|
|
||||||
this.orderList.splice(0, 1);
|
this.orderList.splice(0, 1);
|
||||||
|
// 递归调用打印下一个订单
|
||||||
|
setTimeout(printNextOrder, 2000);
|
||||||
|
} catch (error) {
|
||||||
console.log(error);
|
console.log(error);
|
||||||
|
// 发生错误时继续尝试下一个订单
|
||||||
|
this.orderList.splice(0, 1);
|
||||||
|
setTimeout(printNextOrder, 2000);
|
||||||
}
|
}
|
||||||
}, 2000);
|
};
|
||||||
|
// 开始打印第一个订单
|
||||||
|
printNextOrder();
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
<template>
|
<template>
|
||||||
<div class="device_container">
|
<div class="device_container" v-loading="requestLoading">
|
||||||
<div class="header" @click="router.back()">
|
<div class="header" @click="router.back()">
|
||||||
<el-icon style="position: relative; top: 2px; margin-right: 4px" size="22">
|
<el-icon style="position: relative; top: 2px; margin-right: 4px" size="22">
|
||||||
<ArrowLeft />
|
<ArrowLeft />
|
||||||
|
|
@ -139,6 +139,7 @@ const route = useRoute();
|
||||||
const printList = ref([]);
|
const printList = ref([]);
|
||||||
const feets = ref([0, 1, 2, 3, 4, 5, 8]);
|
const feets = ref([0, 1, 2, 3, 4, 5, 8]);
|
||||||
const loading = ref(false);
|
const loading = ref(false);
|
||||||
|
const requestLoading = ref(false);
|
||||||
const form = ref({
|
const form = ref({
|
||||||
id: "",
|
id: "",
|
||||||
name: '', // 设备名称
|
name: '', // 设备名称
|
||||||
|
|
@ -244,11 +245,13 @@ async function submitHandle() {
|
||||||
// 查询打印机详情
|
// 查询打印机详情
|
||||||
async function tbPrintMachineDetailAjax(id) {
|
async function tbPrintMachineDetailAjax(id) {
|
||||||
try {
|
try {
|
||||||
|
requestLoading.value = true;
|
||||||
const res = await printerDetail({ id: id });
|
const res = await printerDetail({ id: id });
|
||||||
form.value = res;
|
form.value = res;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log(error);
|
console.log(error);
|
||||||
}
|
}
|
||||||
|
requestLoading.value = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
<template>
|
<template>
|
||||||
<div class="device_container">
|
<div class="device_container" v-loading="requestLoading">
|
||||||
<div class="header" @click="router.back()">
|
<div class="header" @click="router.back()">
|
||||||
<el-icon style="position: relative; top: 2px; margin-right: 4px" size="22">
|
<el-icon style="position: relative; top: 2px; margin-right: 4px" size="22">
|
||||||
<ArrowLeft />
|
<ArrowLeft />
|
||||||
|
|
@ -125,6 +125,7 @@ const classifyRef = ref(null);
|
||||||
const printList = ref([]);
|
const printList = ref([]);
|
||||||
const feets = ref([0, 1, 2, 3, 4, 5, 8]);
|
const feets = ref([0, 1, 2, 3, 4, 5, 8]);
|
||||||
const loading = ref(false);
|
const loading = ref(false);
|
||||||
|
const requestLoading = ref(false);
|
||||||
const form = ref({
|
const form = ref({
|
||||||
id: "",
|
id: "",
|
||||||
name: '', // 设备名称
|
name: '', // 设备名称
|
||||||
|
|
@ -210,6 +211,7 @@ async function submitHandle() {
|
||||||
// 查询打印机详情
|
// 查询打印机详情
|
||||||
async function tbPrintMachineDetailAjax() {
|
async function tbPrintMachineDetailAjax() {
|
||||||
try {
|
try {
|
||||||
|
requestLoading.value = true;
|
||||||
const res = await printerDetail({ id: route.query.id });
|
const res = await printerDetail({ id: route.query.id });
|
||||||
form.value = res;
|
form.value = res;
|
||||||
|
|
||||||
|
|
@ -228,6 +230,7 @@ async function tbPrintMachineDetailAjax() {
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log(error);
|
console.log(error);
|
||||||
}
|
}
|
||||||
|
requestLoading.value = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue