优化订单打印
This commit is contained in:
@@ -2,13 +2,13 @@
|
|||||||
ENV = test
|
ENV = test
|
||||||
|
|
||||||
# 测试ws
|
# 测试ws
|
||||||
VITE_API_WSS = 'ws://192.168.1.31:2348'
|
# VITE_API_WSS = 'ws://192.168.1.31:2348'
|
||||||
|
|
||||||
# 测试ws
|
# 测试ws
|
||||||
# VITE_API_WSS = 'wss://sockets.sxczgkj.com/wss'
|
# VITE_API_WSS = 'wss://sockets.sxczgkj.com/wss'
|
||||||
|
|
||||||
# 正式ws
|
# 正式ws
|
||||||
# VITE_API_WSS = 'wss://czgeatws.sxczgkj.com/wss'
|
VITE_API_WSS = 'wss://czgeatws.sxczgkj.com/wss'
|
||||||
|
|
||||||
# 正式 php
|
# 正式 php
|
||||||
VITE_API_PHP_URL = 'https://newblockwlx.sxczgkj.cn/index.php/api'
|
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/'
|
# VITE_API_URL = 'https://fv901fw8033.vicp.fun/'
|
||||||
|
|
||||||
# 正式Java
|
# 正式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/'
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "vite-electron",
|
"name": "vite-electron",
|
||||||
"private": true,
|
"private": true,
|
||||||
"version": "2.0.5",
|
"version": "2.0.6",
|
||||||
"main": "dist-electron/main.js",
|
"main": "dist-electron/main.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "chcp 65001 && vite",
|
"dev": "chcp 65001 && vite",
|
||||||
|
|||||||
@@ -938,7 +938,7 @@ function reset() {
|
|||||||
roundAmount: 0, // 抹零金额 减免多少钱
|
roundAmount: 0, // 抹零金额 减免多少钱
|
||||||
pointsDiscountAmount: 0, // 积分抵扣金额(tb_points_basic_setting表)
|
pointsDiscountAmount: 0, // 积分抵扣金额(tb_points_basic_setting表)
|
||||||
pointsNum: 0, // 使用的积分数量 (扣除各类折扣 enable_deduction后使用)
|
pointsNum: 0, // 使用的积分数量 (扣除各类折扣 enable_deduction后使用)
|
||||||
isPrint: props.isPrint
|
isPrint: 1
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
<!-- 扫码弹窗 -->
|
<!-- 扫码弹窗 -->
|
||||||
<template>
|
<template>
|
||||||
<div class="dialog">
|
<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="content">
|
||||||
<div class="left">
|
<div class="left">
|
||||||
<el-image :src="icon" style="width: 60px; height: 60px"></el-image>
|
<el-image :src="icon" style="width: 60px; height: 60px"></el-image>
|
||||||
@@ -194,14 +194,6 @@ function autoCheckOrder() {
|
|||||||
}, 2000)
|
}, 2000)
|
||||||
}
|
}
|
||||||
|
|
||||||
// 清除自动查询扫码支付订单
|
|
||||||
function clearAutoCheckOrder() {
|
|
||||||
clearInterval(timer.value)
|
|
||||||
timer.value = null
|
|
||||||
// // 开启叫号功能
|
|
||||||
// global.updateData(true)
|
|
||||||
}
|
|
||||||
|
|
||||||
// 查询用户支付状态
|
// 查询用户支付状态
|
||||||
async function checkPayStauts(tips = true) {
|
async function checkPayStauts(tips = true) {
|
||||||
try {
|
try {
|
||||||
@@ -274,7 +266,7 @@ async function checkPayStauts(tips = true) {
|
|||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
clearAutoCheckOrder()
|
clearAutoCheckOrder()
|
||||||
ElMessage.error(res.msg || '');
|
ElMessage.warning(res.msg || '');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -284,9 +276,15 @@ async function checkPayStauts(tips = true) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function clearAutoCheckOrder() {
|
||||||
|
clearInterval(timer.value)
|
||||||
|
timer.value = null
|
||||||
|
}
|
||||||
|
|
||||||
// 重新扫码
|
// 重新扫码
|
||||||
function resetScanCode() {
|
function resetScanCode() {
|
||||||
clearAutoCheckOrder()
|
clearInterval(timer.value)
|
||||||
|
timer.value = null
|
||||||
userPayWait.value = false;
|
userPayWait.value = false;
|
||||||
loading.value = false;
|
loading.value = false;
|
||||||
scanCode.value = "";
|
scanCode.value = "";
|
||||||
@@ -333,7 +331,7 @@ function reset() {
|
|||||||
loading.value = false;
|
loading.value = false;
|
||||||
scanCode.value = "";
|
scanCode.value = "";
|
||||||
// 关闭叫号功能
|
// 关闭叫号功能
|
||||||
global.updateData(false)
|
// global.updateData(false)
|
||||||
}
|
}
|
||||||
|
|
||||||
defineExpose({
|
defineExpose({
|
||||||
|
|||||||
@@ -60,14 +60,14 @@ export const useGoods = defineStore("goods", {
|
|||||||
shopId: this.orderListInfo.shopId,
|
shopId: this.orderListInfo.shopId,
|
||||||
orderId: this.orderListInfo.id,
|
orderId: this.orderListInfo.id,
|
||||||
});
|
});
|
||||||
this.operateCart(
|
|
||||||
{ table_code: this.orderListInfo.tableCode },
|
|
||||||
"clearOrder"
|
|
||||||
);
|
|
||||||
this.historyOrderAjax(this.orderListInfo.tableCode);
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log("清除历史订单失败", error);
|
console.log("清除历史订单失败", error);
|
||||||
}
|
}
|
||||||
|
this.operateCart(
|
||||||
|
{ table_code: this.orderListInfo.tableCode },
|
||||||
|
"clearOrder"
|
||||||
|
);
|
||||||
|
this.historyOrderAjax(this.orderListInfo.tableCode);
|
||||||
},
|
},
|
||||||
// 删除某一次订单
|
// 删除某一次订单
|
||||||
async deleteHistoryOrder(placeNum = null) {
|
async deleteHistoryOrder(placeNum = null) {
|
||||||
@@ -78,14 +78,14 @@ export const useGoods = defineStore("goods", {
|
|||||||
orderId: this.orderListInfo.id,
|
orderId: this.orderListInfo.id,
|
||||||
placeNum: placeNum,
|
placeNum: placeNum,
|
||||||
});
|
});
|
||||||
this.operateCart(
|
|
||||||
{ table_code: this.orderListInfo.tableCode },
|
|
||||||
"clearOrder"
|
|
||||||
);
|
|
||||||
this.historyOrderAjax(this.orderListInfo.tableCode);
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log("删除某一次订单", error);
|
console.log("删除某一次订单", error);
|
||||||
}
|
}
|
||||||
|
this.operateCart(
|
||||||
|
{ table_code: this.orderListInfo.tableCode },
|
||||||
|
"clearOrder"
|
||||||
|
);
|
||||||
|
this.historyOrderAjax(this.orderListInfo.tableCode);
|
||||||
},
|
},
|
||||||
// 清除所有商品信息
|
// 清除所有商品信息
|
||||||
clearAllGoods() {
|
clearAllGoods() {
|
||||||
@@ -95,6 +95,8 @@ export const useGoods = defineStore("goods", {
|
|||||||
this.goodsListLoading = false;
|
this.goodsListLoading = false;
|
||||||
this.goodsList = [];
|
this.goodsList = [];
|
||||||
this.originGoodsList = [];
|
this.originGoodsList = [];
|
||||||
|
this.orderList = [];
|
||||||
|
this.orderListInfo = "";
|
||||||
|
|
||||||
useStorage.del("printList");
|
useStorage.del("printList");
|
||||||
useStorage.del("updateFlag");
|
useStorage.del("updateFlag");
|
||||||
@@ -210,6 +212,8 @@ export const useGoods = defineStore("goods", {
|
|||||||
// 获取订单列表
|
// 获取订单列表
|
||||||
async historyOrderAjax(tableCode = "", orderId = "") {
|
async historyOrderAjax(tableCode = "", orderId = "") {
|
||||||
try {
|
try {
|
||||||
|
if (!tableCode && !orderId) return;
|
||||||
|
|
||||||
const store = useUser();
|
const store = useUser();
|
||||||
const res = await historyOrder({
|
const res = await historyOrder({
|
||||||
tableCode: tableCode,
|
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;
|
this.allSelected = 1;
|
||||||
} else {
|
} else {
|
||||||
this.allSelected = 0;
|
this.allSelected = 0;
|
||||||
|
|||||||
@@ -162,6 +162,10 @@ export const useSocket = defineStore("socket", {
|
|||||||
|
|
||||||
let printList = useStorage.get("printList") || [];
|
let printList = useStorage.get("printList") || [];
|
||||||
|
|
||||||
|
if (goodsStore.orderListInfo.tableCode) {
|
||||||
|
goodsStore.historyOrderAjax(goodsStore.orderListInfo.tableCode);
|
||||||
|
}
|
||||||
|
|
||||||
// 防止重复打印
|
// 防止重复打印
|
||||||
if (!printList.some((el) => el == orderId) && orderStatus == 1) {
|
if (!printList.some((el) => el == orderId) && orderStatus == 1) {
|
||||||
printList.push(orderId);
|
printList.push(orderId);
|
||||||
@@ -218,7 +222,7 @@ export const useSocket = defineStore("socket", {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
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") {
|
||||||
// 打印订单小票
|
// 打印订单小票
|
||||||
printStore.pushReceiptData(commOrderPrintData(orderInfo));
|
printStore.pushReceiptData(commOrderPrintData(orderInfo));
|
||||||
// 打印标签小票
|
// 打印标签小票
|
||||||
|
|||||||
@@ -130,6 +130,7 @@ export function formatPhoneNumber(phone, isFormat = true) {
|
|||||||
*/
|
*/
|
||||||
export async function getOrderByIdAjax(orderId) {
|
export async function getOrderByIdAjax(orderId) {
|
||||||
try {
|
try {
|
||||||
|
if (!orderId) return;
|
||||||
const res = await getOrderById({ orderId: orderId });
|
const res = await getOrderById({ orderId: orderId });
|
||||||
|
|
||||||
let arr = [];
|
let arr = [];
|
||||||
@@ -162,8 +163,8 @@ export function commOrderPrintData(orderInfo) {
|
|||||||
shop_name: userStore.shopInfo.shopName,
|
shop_name: userStore.shopInfo.shopName,
|
||||||
loginAccount: userStore.userInfo.name,
|
loginAccount: userStore.userInfo.name,
|
||||||
carts: [],
|
carts: [],
|
||||||
amount: formatDecimal(orderInfo.payAmount),
|
amount: formatDecimal(+orderInfo.payAmount),
|
||||||
originAmount: formatDecimal(orderInfo.originAmount),
|
originAmount: formatDecimal(+orderInfo.originAmount),
|
||||||
discountAmount:
|
discountAmount:
|
||||||
orderInfo.status == "unpaid"
|
orderInfo.status == "unpaid"
|
||||||
? "0.00"
|
? "0.00"
|
||||||
@@ -182,7 +183,7 @@ export function commOrderPrintData(orderInfo) {
|
|||||||
name: item.productName,
|
name: item.productName,
|
||||||
number: item.num,
|
number: item.num,
|
||||||
skuName: item.skuName,
|
skuName: item.skuName,
|
||||||
salePrice: formatDecimal(item.price),
|
salePrice: formatDecimal(+item.price),
|
||||||
totalAmount: formatDecimal(+item.payAmount),
|
totalAmount: formatDecimal(+item.payAmount),
|
||||||
proGroupInfo: item.proGroupInfo
|
proGroupInfo: item.proGroupInfo
|
||||||
? item.proGroupInfo.map((item) => item.goods).flat()
|
? item.proGroupInfo.map((item) => item.goods).flat()
|
||||||
|
|||||||
@@ -184,9 +184,6 @@ async function getStaffDiscountAjax() {
|
|||||||
const printHandle = _.throttle(async function () {
|
const printHandle = _.throttle(async function () {
|
||||||
printLoading.value = true
|
printLoading.value = true
|
||||||
await printOrderLable(true)
|
await printOrderLable(true)
|
||||||
setTimeout(() => {
|
|
||||||
printLoading.value = false
|
|
||||||
}, 1000)
|
|
||||||
}, 1500, { leading: true, trailing: false })
|
}, 1500, { leading: true, trailing: false })
|
||||||
|
|
||||||
// 打印订单标签
|
// 打印订单标签
|
||||||
@@ -195,28 +192,40 @@ async function printOrderLable(isBefore = false) {
|
|||||||
let orderId = goodsStore.orderListInfo.id
|
let orderId = goodsStore.orderListInfo.id
|
||||||
const data = await getOrderByIdAjax(orderId);
|
const data = await getOrderByIdAjax(orderId);
|
||||||
|
|
||||||
if (printStore.deviceLableList.length) {
|
let printList = useStorage.get("printList") || [];
|
||||||
if (!isBefore) {
|
|
||||||
// 预结算不打印标签
|
|
||||||
printStore.labelPrint(commOrderPrintData(data))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (printStore.deviceNoteList.length) {
|
// 防止重复打印
|
||||||
// 使用本地打印机打印
|
if (!printList.some((el) => el == orderId)) {
|
||||||
printStore.pushReceiptData(commOrderPrintData({ ...data, isBefore: isBefore }));
|
if (!isBefore) {
|
||||||
} else {
|
printList.push(orderId);
|
||||||
// 本地没有可用打印机使用云打印机
|
useStorage.set("printList", _.uniq(printList));
|
||||||
await orderPrint({
|
}
|
||||||
type: isBefore ? 1 : 0,
|
|
||||||
id: orderId,
|
if (printStore.deviceLableList.length) {
|
||||||
});
|
if (!isBefore) {
|
||||||
ElMessage.success(`云打印${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) {
|
} catch (error) {
|
||||||
console.log(error);
|
console.log(error);
|
||||||
}
|
}
|
||||||
printLoading.value = false;
|
setTimeout(() => {
|
||||||
|
printLoading.value = false
|
||||||
|
}, 2500)
|
||||||
}
|
}
|
||||||
|
|
||||||
// 订单已支付
|
// 订单已支付
|
||||||
|
|||||||
@@ -264,6 +264,9 @@ async function quickCashHandle() {
|
|||||||
async function createOrderHandle(t = 0) {
|
async function createOrderHandle(t = 0) {
|
||||||
try {
|
try {
|
||||||
if (goodsStore.cartList.length) {
|
if (goodsStore.cartList.length) {
|
||||||
|
// console.log(goodsStore.allSelected );
|
||||||
|
// console.log(goodsStore.allSelected ? store.shopInfo.eatModel.split(',')[1] : store.shopInfo.eatModel.split(',')[0]);
|
||||||
|
|
||||||
const data = {
|
const data = {
|
||||||
orderId: goodsStore.orderListInfo.id || '', // 订单id
|
orderId: goodsStore.orderListInfo.id || '', // 订单id
|
||||||
shopId: store.shopInfo.id, // 店铺id
|
shopId: store.shopInfo.id, // 店铺id
|
||||||
|
|||||||
Reference in New Issue
Block a user