优化订单打印
This commit is contained in:
@@ -184,9 +184,6 @@ async function getStaffDiscountAjax() {
|
||||
const printHandle = _.throttle(async function () {
|
||||
printLoading.value = true
|
||||
await printOrderLable(true)
|
||||
setTimeout(() => {
|
||||
printLoading.value = false
|
||||
}, 1000)
|
||||
}, 1500, { leading: true, trailing: false })
|
||||
|
||||
// 打印订单标签
|
||||
@@ -195,28 +192,40 @@ async function printOrderLable(isBefore = false) {
|
||||
let orderId = goodsStore.orderListInfo.id
|
||||
const data = await getOrderByIdAjax(orderId);
|
||||
|
||||
if (printStore.deviceLableList.length) {
|
||||
if (!isBefore) {
|
||||
// 预结算不打印标签
|
||||
printStore.labelPrint(commOrderPrintData(data))
|
||||
}
|
||||
}
|
||||
let printList = useStorage.get("printList") || [];
|
||||
|
||||
if (printStore.deviceNoteList.length) {
|
||||
// 使用本地打印机打印
|
||||
printStore.pushReceiptData(commOrderPrintData({ ...data, isBefore: isBefore }));
|
||||
} else {
|
||||
// 本地没有可用打印机使用云打印机
|
||||
await orderPrint({
|
||||
type: isBefore ? 1 : 0,
|
||||
id: orderId,
|
||||
});
|
||||
ElMessage.success(`云打印${isBefore ? '预' : ''}结算单成功`);
|
||||
// 防止重复打印
|
||||
if (!printList.some((el) => el == orderId)) {
|
||||
if (!isBefore) {
|
||||
printList.push(orderId);
|
||||
useStorage.set("printList", _.uniq(printList));
|
||||
}
|
||||
|
||||
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: orderId,
|
||||
});
|
||||
ElMessage.success(`云打印${isBefore ? '预' : ''}结算单成功`);
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
}
|
||||
printLoading.value = false;
|
||||
setTimeout(() => {
|
||||
printLoading.value = false
|
||||
}, 2500)
|
||||
}
|
||||
|
||||
// 订单已支付
|
||||
|
||||
Reference in New Issue
Block a user