优化订单打印

This commit is contained in:
gyq 2025-04-15 14:47:04 +08:00
parent f466bdc9f4
commit 0a0f672a02
9 changed files with 77 additions and 53 deletions

View File

@ -2,13 +2,13 @@
ENV = test
# 测试ws
VITE_API_WSS = 'ws://192.168.1.31:2348'
# VITE_API_WSS = 'ws://192.168.1.31:2348'
# 测试ws
# VITE_API_WSS = 'wss://sockets.sxczgkj.com/wss'
# 正式ws
# VITE_API_WSS = 'wss://czgeatws.sxczgkj.com/wss'
VITE_API_WSS = 'wss://czgeatws.sxczgkj.com/wss'
# 正式 php
VITE_API_PHP_URL = 'https://newblockwlx.sxczgkj.cn/index.php/api'
@ -23,7 +23,7 @@ VITE_API_KP_URL = 'https://invoice.sxczgkj.cn/api'
# VITE_API_URL = 'https://fv901fw8033.vicp.fun/'
# 正式Java
# VITE_API_URL = 'https://cashier.sxczgkj.com/'
VITE_API_URL = 'https://cashier.sxczgkj.com/'
# 本地调试连接
VITE_API_URL = 'http://192.168.1.31/'
# VITE_API_URL = 'http://192.168.1.31/'

View File

@ -1,7 +1,7 @@
{
"name": "vite-electron",
"private": true,
"version": "2.0.5",
"version": "2.0.6",
"main": "dist-electron/main.js",
"scripts": {
"dev": "chcp 65001 && vite",

View File

@ -938,7 +938,7 @@ function reset() {
roundAmount: 0, //
pointsDiscountAmount: 0, // (tb_points_basic_setting)
pointsNum: 0, // 使 ( enable_deduction使)
isPrint: props.isPrint
isPrint: 1
},
};

View File

@ -1,7 +1,7 @@
<!-- 扫码弹窗 -->
<template>
<div class="dialog">
<el-dialog title="扫码支付" width="600" v-model="dialogVisible" @open="reset" @close="clearAutoCheckOrder">
<el-dialog title="扫码支付" width="600" v-model="dialogVisible" @open="reset" @closed="resetScanCode">
<div class="content">
<div class="left">
<el-image :src="icon" style="width: 60px; height: 60px"></el-image>
@ -194,14 +194,6 @@ function autoCheckOrder() {
}, 2000)
}
//
function clearAutoCheckOrder() {
clearInterval(timer.value)
timer.value = null
// //
// global.updateData(true)
}
//
async function checkPayStauts(tips = true) {
try {
@ -274,7 +266,7 @@ async function checkPayStauts(tips = true) {
return;
} else {
clearAutoCheckOrder()
ElMessage.error(res.msg || '');
ElMessage.warning(res.msg || '');
return;
}
}
@ -284,9 +276,15 @@ async function checkPayStauts(tips = true) {
}
}
function clearAutoCheckOrder() {
clearInterval(timer.value)
timer.value = null
}
//
function resetScanCode() {
clearAutoCheckOrder()
clearInterval(timer.value)
timer.value = null
userPayWait.value = false;
loading.value = false;
scanCode.value = "";
@ -333,7 +331,7 @@ function reset() {
loading.value = false;
scanCode.value = "";
//
global.updateData(false)
// global.updateData(false)
}
defineExpose({

View File

@ -60,14 +60,14 @@ export const useGoods = defineStore("goods", {
shopId: this.orderListInfo.shopId,
orderId: this.orderListInfo.id,
});
this.operateCart(
{ table_code: this.orderListInfo.tableCode },
"clearOrder"
);
this.historyOrderAjax(this.orderListInfo.tableCode);
} catch (error) {
console.log("清除历史订单失败", error);
}
this.operateCart(
{ table_code: this.orderListInfo.tableCode },
"clearOrder"
);
this.historyOrderAjax(this.orderListInfo.tableCode);
},
// 删除某一次订单
async deleteHistoryOrder(placeNum = null) {
@ -78,14 +78,14 @@ export const useGoods = defineStore("goods", {
orderId: this.orderListInfo.id,
placeNum: placeNum,
});
this.operateCart(
{ table_code: this.orderListInfo.tableCode },
"clearOrder"
);
this.historyOrderAjax(this.orderListInfo.tableCode);
} catch (error) {
console.log("删除某一次订单", error);
}
this.operateCart(
{ table_code: this.orderListInfo.tableCode },
"clearOrder"
);
this.historyOrderAjax(this.orderListInfo.tableCode);
},
// 清除所有商品信息
clearAllGoods() {
@ -95,6 +95,8 @@ export const useGoods = defineStore("goods", {
this.goodsListLoading = false;
this.goodsList = [];
this.originGoodsList = [];
this.orderList = [];
this.orderListInfo = "";
useStorage.del("printList");
useStorage.del("updateFlag");
@ -210,6 +212,8 @@ export const useGoods = defineStore("goods", {
// 获取订单列表
async historyOrderAjax(tableCode = "", orderId = "") {
try {
if (!tableCode && !orderId) return;
const store = useUser();
const res = await historyOrder({
tableCode: tableCode,
@ -400,7 +404,12 @@ export const useGoods = defineStore("goods", {
}
});
if (packCount > 0 && packCount == numCount) {
if (
store.shopInfo &&
store.shopInfo.eatModel.includes("take-out") &&
packCount > 0 &&
packCount == numCount
) {
this.allSelected = 1;
} else {
this.allSelected = 0;

View File

@ -162,6 +162,10 @@ export const useSocket = defineStore("socket", {
let printList = useStorage.get("printList") || [];
if (goodsStore.orderListInfo.tableCode) {
goodsStore.historyOrderAjax(goodsStore.orderListInfo.tableCode);
}
// 防止重复打印
if (!printList.some((el) => el == orderId) && orderStatus == 1) {
printList.push(orderId);
@ -218,7 +222,7 @@ export const useSocket = defineStore("socket", {
return;
}
const orderInfo = await getOrderByIdAjax(this.orderList[0]);
if (orderInfo.status == "done" && orderInfo.platformType != "PC") {
if (orderInfo.status == "done") {
// 打印订单小票
printStore.pushReceiptData(commOrderPrintData(orderInfo));
// 打印标签小票

View File

@ -130,6 +130,7 @@ export function formatPhoneNumber(phone, isFormat = true) {
*/
export async function getOrderByIdAjax(orderId) {
try {
if (!orderId) return;
const res = await getOrderById({ orderId: orderId });
let arr = [];
@ -162,8 +163,8 @@ export function commOrderPrintData(orderInfo) {
shop_name: userStore.shopInfo.shopName,
loginAccount: userStore.userInfo.name,
carts: [],
amount: formatDecimal(orderInfo.payAmount),
originAmount: formatDecimal(orderInfo.originAmount),
amount: formatDecimal(+orderInfo.payAmount),
originAmount: formatDecimal(+orderInfo.originAmount),
discountAmount:
orderInfo.status == "unpaid"
? "0.00"
@ -182,7 +183,7 @@ export function commOrderPrintData(orderInfo) {
name: item.productName,
number: item.num,
skuName: item.skuName,
salePrice: formatDecimal(item.price),
salePrice: formatDecimal(+item.price),
totalAmount: formatDecimal(+item.payAmount),
proGroupInfo: item.proGroupInfo
? item.proGroupInfo.map((item) => item.goods).flat()

View File

@ -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)
}
//

View File

@ -264,6 +264,9 @@ async function quickCashHandle() {
async function createOrderHandle(t = 0) {
try {
if (goodsStore.cartList.length) {
// console.log(goodsStore.allSelected );
// console.log(goodsStore.allSelected ? store.shopInfo.eatModel.split(',')[1] : store.shopInfo.eatModel.split(',')[0]);
const data = {
orderId: goodsStore.orderListInfo.id || '', // id
shopId: store.shopInfo.id, // id