优化订单打印 新增小票订单数
This commit is contained in:
parent
0c45fd9de1
commit
117df7d7bd
|
|
@ -5,10 +5,10 @@ ENV = development
|
|||
# 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'
|
||||
|
||||
# 本地ws
|
||||
# VITE_API_WSS = 'ws://192.168.1.43:2348'
|
||||
VITE_API_WSS = 'ws://192.168.1.31:2348'
|
||||
|
||||
# 正式 php
|
||||
VITE_API_PHP_URL = 'https://newblockwlx.sxczgkj.cn/index.php/api'
|
||||
|
|
@ -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_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://cashier.sxczgkj.com'
|
||||
# VITE_API_URL = 'https://cashier.sxczgkj.com'
|
||||
10
.env.test
10
.env.test
|
|
@ -1,6 +1,9 @@
|
|||
# 测试环境
|
||||
ENV = test
|
||||
|
||||
# 测试ws
|
||||
# VITE_API_WSS = 'ws://192.168.1.31:2348'
|
||||
|
||||
# 测试ws
|
||||
# VITE_API_WSS = 'wss://sockets.sxczgkj.com/wss'
|
||||
|
||||
|
|
@ -17,7 +20,10 @@ VITE_API_PHP_URL = 'https://newblockwlx.sxczgkj.cn/index.php/api'
|
|||
VITE_API_KP_URL = 'https://invoice.sxczgkj.cn/api'
|
||||
|
||||
# 测试Java
|
||||
# VITE_API_URL = 'https://tapi.cashier.sxczgkj.cn'
|
||||
# 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/'
|
||||
16160
dist-electron/main.js
16160
dist-electron/main.js
File diff suppressed because one or more lines are too long
|
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"name": "vite-electron",
|
||||
"private": true,
|
||||
"version": "2.0.3",
|
||||
"version": "2.0.4",
|
||||
"main": "dist-electron/main.js",
|
||||
"scripts": {
|
||||
"dev": "chcp 65001 && vite",
|
||||
|
|
|
|||
|
|
@ -26,9 +26,8 @@ import _ from 'lodash'
|
|||
import { ref, reactive, watch, onMounted } from "vue";
|
||||
import { useRouter, useRoute } from "vue-router";
|
||||
import leftMenu from "@/components/leftMenu.vue";
|
||||
import useStorage from "@/utils/useStorage";
|
||||
import { useUser } from "@/store/user.js";
|
||||
import { dayjs, ElMessage, ElMessageBox } from "element-plus";
|
||||
import { ElMessage, ElMessageBox } from "element-plus";
|
||||
import { scanSendMessage } from "@/api/order/index";
|
||||
import { useGlobal } from "@/store/global.js";
|
||||
import { useSocket } from "@/store/socket.js";
|
||||
|
|
|
|||
|
|
@ -233,3 +233,29 @@ export function mergeOrder(data) {
|
|||
data,
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 取消订单
|
||||
* @param {*} data
|
||||
* @returns
|
||||
*/
|
||||
export function cancelOrder(data) {
|
||||
return request({
|
||||
method: "post",
|
||||
url: "/order/admin/order/cancelOrder",
|
||||
data,
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 取消某一次 下单
|
||||
* @param {*} data
|
||||
* @returns
|
||||
*/
|
||||
export function rmPlaceOrder(data) {
|
||||
return request({
|
||||
method: "post",
|
||||
url: "/order/admin/order/rmPlaceOrder",
|
||||
data,
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,10 +21,10 @@ export default (data) => {
|
|||
${data.shop_name}
|
||||
</div>
|
||||
<div style="font-size: 16px;display: flex; justify-content:center;margin-top:6px;">
|
||||
${data.isBefore ? "预" : ""}结算单
|
||||
${data.isBefore ? "预" : ""}结算单 #${data.orderInfo.orderNum || ''}
|
||||
</div>
|
||||
<div style="font-size: 16px;display: flex; justify-content:center;margin-top:6px;">
|
||||
桌号:${data.orderInfo && data.orderInfo.tableName || ''}
|
||||
桌号:${data.orderInfo && data.orderInfo.tableName || '无'}
|
||||
</div>
|
||||
<div style="margin-top: 30px;font-size: 12px;">
|
||||
订单号:${data.orderInfo && data.orderInfo.orderNo}
|
||||
|
|
|
|||
|
|
@ -73,7 +73,7 @@ async function findVersionAjax() {
|
|||
}
|
||||
}
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
console.log('检查版本更新===', error);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ import _ from "lodash";
|
|||
import dayjs from "dayjs";
|
||||
import { defineStore } from "pinia";
|
||||
import { productPage, categoryList } from "@/api/product_new.js";
|
||||
import { historyOrder } from "@/api/order.js";
|
||||
import { historyOrder, cancelOrder, rmPlaceOrder } from "@/api/order.js";
|
||||
import { useUser } from "@/store/user.js";
|
||||
import { useSocket } from "@/store/socket.js";
|
||||
import useStorage from "@/utils/useStorage.js";
|
||||
|
|
@ -53,6 +53,40 @@ export const useGoods = defineStore("goods", {
|
|||
pendingList: useStorage.get("pendingList") || [],
|
||||
}),
|
||||
actions: {
|
||||
// 清除历史订单
|
||||
async clearHistoryOrder() {
|
||||
try {
|
||||
await cancelOrder({
|
||||
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);
|
||||
}
|
||||
},
|
||||
// 删除某一次订单
|
||||
async deleteHistoryOrder(placeNum = null) {
|
||||
try {
|
||||
if (!placeNum) return;
|
||||
await rmPlaceOrder({
|
||||
shopId: this.orderListInfo.shopId,
|
||||
orderId: this.orderListInfo.id,
|
||||
placeNum: placeNum,
|
||||
});
|
||||
this.operateCart(
|
||||
{ table_code: this.orderListInfo.tableCode },
|
||||
"clearOrder"
|
||||
);
|
||||
this.historyOrderAjax(this.orderListInfo.tableCode);
|
||||
} catch (error) {
|
||||
console.log("删除某一次订单", error);
|
||||
}
|
||||
},
|
||||
// 清除所有商品信息
|
||||
clearAllGoods() {
|
||||
this.categoryIndex = 0;
|
||||
|
|
@ -63,6 +97,8 @@ export const useGoods = defineStore("goods", {
|
|||
this.originGoodsList = [];
|
||||
|
||||
useStorage.del("printList");
|
||||
useStorage.del("updateFlag");
|
||||
useStorage.del("tableCode");
|
||||
},
|
||||
// 清除会员信息
|
||||
clearVipUserInfo() {
|
||||
|
|
@ -159,17 +195,14 @@ export const useGoods = defineStore("goods", {
|
|||
// 手动选择台桌
|
||||
selectTable(tableInfo = {}) {
|
||||
const socket = useSocket();
|
||||
const store = useUser();
|
||||
|
||||
this.tableInfo = tableInfo;
|
||||
this.isCartInit = false;
|
||||
// 选择台桌后将购物车初始化
|
||||
socket.cartInit();
|
||||
if (store.shopInfo.registerType == "after" && this.tableInfo.tableCode) {
|
||||
if (this.tableInfo.tableCode) {
|
||||
this.historyOrderAjax(this.tableInfo.tableCode);
|
||||
}
|
||||
|
||||
if (!this.tableInfo.tableCode) {
|
||||
} else {
|
||||
this.orderList = [];
|
||||
this.orderListInfo = "";
|
||||
}
|
||||
|
|
@ -209,6 +242,9 @@ export const useGoods = defineStore("goods", {
|
|||
}
|
||||
this.orderList = arr;
|
||||
console.log("this.orderList===2222", this.orderList);
|
||||
} else {
|
||||
this.orderList = [];
|
||||
this.orderListInfo = "";
|
||||
}
|
||||
this.calcCartInfo();
|
||||
} catch (error) {
|
||||
|
|
|
|||
|
|
@ -123,7 +123,7 @@ export const usePrint = defineStore("print", {
|
|||
this.labelList.splice(0, 1);
|
||||
}
|
||||
}
|
||||
}, 800);
|
||||
}, 2000);
|
||||
},
|
||||
// 添加小票打印队列数据
|
||||
pushReceiptData(props, isDevice = true) {
|
||||
|
|
@ -171,7 +171,7 @@ export const usePrint = defineStore("print", {
|
|||
receiptPrint(this.receiptList[0]);
|
||||
this.receiptList.splice(0, 1);
|
||||
}
|
||||
}, 800);
|
||||
}, 2000);
|
||||
},
|
||||
// 打印交班小票
|
||||
printWork(data) {
|
||||
|
|
|
|||
|
|
@ -53,9 +53,12 @@ export const useSocket = defineStore("socket", {
|
|||
},
|
||||
// 初始化
|
||||
init(wsUrl = import.meta.env.VITE_API_WSS) {
|
||||
const store = useUser();
|
||||
const printStore = usePrint();
|
||||
const goodsStore = useGoods();
|
||||
|
||||
if (!store.shopInfo.id) return;
|
||||
|
||||
printStore.init();
|
||||
|
||||
if (this.ws == null) {
|
||||
|
|
@ -140,6 +143,10 @@ export const useSocket = defineStore("socket", {
|
|||
goodsStore.historyOrderAjax(data.data.new_table_code);
|
||||
this.cartInit();
|
||||
break;
|
||||
case "clearOrder":
|
||||
// 清空订单或删除订单
|
||||
goodsStore.historyOrderAjax(data.data.table_code);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
|
@ -148,15 +155,21 @@ export const useSocket = defineStore("socket", {
|
|||
}
|
||||
} else if (data.data_type == "order") {
|
||||
// 收到订单消息,打印订单小票
|
||||
let orderInfo = data.data.split("_");
|
||||
let orderId = orderInfo[0]; // 订单ID
|
||||
let orderModel = orderInfo[1]; // 订单类型
|
||||
let orderStatus = orderInfo[2]; // 订单状态
|
||||
|
||||
let printList = useStorage.get("printList") || [];
|
||||
if (!printList.some((el) => el == data.data)) {
|
||||
// 防止重复打印
|
||||
this.orderList.push(data.data);
|
||||
|
||||
// 防止重复打印
|
||||
if (!printList.some((el) => el == orderId) && orderStatus == 1) {
|
||||
printList.push(orderId);
|
||||
useStorage.set("printList", _.uniq(printList));
|
||||
|
||||
this.orderList.push(orderId);
|
||||
this.startPrintInterval();
|
||||
}
|
||||
|
||||
printList.push(data.data);
|
||||
useStorage.set("printList", _.uniq(printList));
|
||||
} else if (data.data_type == "product_update") {
|
||||
// 商品更新
|
||||
this.updateGoods();
|
||||
|
|
@ -196,7 +209,7 @@ export const useSocket = defineStore("socket", {
|
|||
startPrintInterval() {
|
||||
if (this.isPrinting) return; // 如果正在打印,直接返回
|
||||
this.isPrinting = true; // 标记为正在打印
|
||||
|
||||
let printTime = 2000; // 定时器
|
||||
const printStore = usePrint();
|
||||
const printNextOrder = async () => {
|
||||
try {
|
||||
|
|
@ -206,19 +219,19 @@ export const useSocket = defineStore("socket", {
|
|||
}
|
||||
const orderInfo = await getOrderByIdAjax(this.orderList[0]);
|
||||
if (orderInfo.status == "done" && orderInfo.platformType != "PC") {
|
||||
// 打印小票
|
||||
// 打印订单小票
|
||||
printStore.pushReceiptData(commOrderPrintData(orderInfo));
|
||||
// 打印标签小票
|
||||
printStore.labelPrint(commOrderPrintData(orderInfo));
|
||||
}
|
||||
this.orderList.splice(0, 1);
|
||||
// 递归调用打印下一个订单
|
||||
setTimeout(printNextOrder, 2000);
|
||||
setTimeout(printNextOrder, printTime);
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
// 发生错误时继续尝试下一个订单
|
||||
this.orderList.splice(0, 1);
|
||||
setTimeout(printNextOrder, 2000);
|
||||
// this.orderList.splice(0, 1);
|
||||
setTimeout(printNextOrder, printTime);
|
||||
}
|
||||
};
|
||||
// 开始打印第一个订单
|
||||
|
|
|
|||
|
|
@ -59,6 +59,9 @@ export const useUser = defineStore("user", {
|
|||
const socket = useSocket();
|
||||
|
||||
await logout();
|
||||
|
||||
socket.close();
|
||||
|
||||
useStorage.del("userInfo");
|
||||
useStorage.del("shopInfo");
|
||||
useStorage.del("token");
|
||||
|
|
@ -67,8 +70,6 @@ export const useUser = defineStore("user", {
|
|||
this.userInfo = {};
|
||||
this.shopInfo = {};
|
||||
this.token = "";
|
||||
|
||||
socket.close();
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -86,13 +86,24 @@
|
|||
<div class="order_list_wrap">
|
||||
<div class="order_title" :class="{ border: !goodsStore.cartList.length }"
|
||||
v-if="goodsStore.orderList.length">
|
||||
历史下单
|
||||
<span class="l">历史下单</span>
|
||||
<div class="del" @click="goodsStore.clearHistoryOrder()">
|
||||
<el-icon class="icon">
|
||||
<Delete />
|
||||
</el-icon>
|
||||
<span>清空历史订单</span>
|
||||
</div>
|
||||
</div>
|
||||
<CartItem
|
||||
:item="{ product_name: '客座费', number: goodsStore.tableInfo.num, lowPrice: store.shopInfo.tableFee, memberPrice: store.shopInfo.tableFee }"
|
||||
v-if="!store.shopInfo.isTableFee && goodsStore.tableInfo.id" />
|
||||
<div class="order_list_item" v-for="(arr, index) in goodsStore.orderList" :key="index">
|
||||
<div class="order_num">{{ `第${arr.orderNum}次下单` }}</div>
|
||||
<div class="order_num">
|
||||
<span class="l">{{ `第${arr.orderNum}次下单` }}</span>
|
||||
<div class="del" @click="goodsStore.deleteHistoryOrder(arr.orderNum)">
|
||||
<span>删除</span>
|
||||
</div>
|
||||
</div>
|
||||
<CartItem type="order" :border="false" :item="item" :index="index" :i="i" :key="item.id"
|
||||
v-for="(item, i) in arr.goods" />
|
||||
</div>
|
||||
|
|
@ -380,20 +391,38 @@ function clearVipUserHandle() {
|
|||
|
||||
.order_title {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
font-size: 14px;
|
||||
color: #999;
|
||||
padding: 10px 0;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
padding: 10px var(--el-font-size-base);
|
||||
|
||||
&.border {
|
||||
border-top: 1px solid #ececec;
|
||||
}
|
||||
|
||||
.l {
|
||||
color: var(--el-color-warning);
|
||||
}
|
||||
|
||||
.del {
|
||||
font-size: 12px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
|
||||
.icon {
|
||||
margin-right: 4px;
|
||||
position: relative;
|
||||
top: 1px;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.order_num {
|
||||
font-size: 12px;
|
||||
color: #999;
|
||||
padding: var(--el-font-size-base) var(--el-font-size-base) 10px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -6,8 +6,8 @@
|
|||
<template #default>
|
||||
<div class="prinr_wrap" v-loading="loading">
|
||||
<div class="header center">{{ userStore.shopInfo.shopName }}</div>
|
||||
<div class="row center">结算单</div>
|
||||
<div class="row center">桌号:{{ orderInfo.tableName }}</div>
|
||||
<div class="row center">结算单 <span style="margin-left: 10px;">#{{ orderInfo.orderNum }}</span></div>
|
||||
<div class="row center">桌号:{{ orderInfo.tableName || '无' }}</div>
|
||||
<div class="row" style="margin-top: 20px">
|
||||
订单号:{{ orderInfo.orderNo }}
|
||||
</div>
|
||||
|
|
|
|||
Loading…
Reference in New Issue