Compare commits
11 Commits
fa67997c86
...
test
| Author | SHA1 | Date | |
|---|---|---|---|
| 54667097b3 | |||
| 75be7c0d53 | |||
| 97e0df4621 | |||
| 7f05d42d32 | |||
| 4e1484d4bb | |||
| 1ed8fa8c8e | |||
| 0b8fe251bf | |||
| da6b45e9e9 | |||
| 6aec434015 | |||
| cb8c9139fe | |||
| d5568c48d0 |
@@ -1,14 +1,14 @@
|
||||
# 本地环境
|
||||
ENV = development
|
||||
|
||||
# 测试ws
|
||||
# VITE_API_WSS = 'wss://sockets.sxczgkj.com/wss'
|
||||
|
||||
# 正式ws
|
||||
# VITE_API_WSS = 'wss://czgeatws.sxczgkj.com/wss'
|
||||
|
||||
# 本地ws
|
||||
VITE_API_WSS = 'ws://192.168.1.42:2348'
|
||||
# VITE_API_WSS = 'ws://192.168.1.42:2348'
|
||||
|
||||
# 线上本地映射测试ws
|
||||
VITE_API_WSS = 'ws://frp.sxczgkj.com/wss'
|
||||
|
||||
# 正式 php
|
||||
VITE_API_PHP_URL = 'https://newblockwlx.sxczgkj.cn/index.php/api'
|
||||
@@ -17,7 +17,7 @@ VITE_API_PHP_URL = 'https://newblockwlx.sxczgkj.cn/index.php/api'
|
||||
# VITE_API_KP_URL = 'http://192.168.1.13:8888/api'
|
||||
|
||||
# 正式 php 开票
|
||||
# VITE_API_KP_URL = 'https://invoice.sxczgkj.cn/api'
|
||||
VITE_API_KP_URL = 'https://invoice.sxczgkj.cn/api'
|
||||
|
||||
# 线上测试
|
||||
# VITE_API_URL = 'https://tapi.cashier.sxczgkj.cn'
|
||||
@@ -26,4 +26,7 @@ VITE_API_PHP_URL = 'https://newblockwlx.sxczgkj.cn/index.php/api'
|
||||
# VITE_API_URL = 'https://cashier.sxczgkj.com'
|
||||
|
||||
# 本地调试连接
|
||||
VITE_API_URL = 'http://192.168.1.42/'
|
||||
# VITE_API_URL = 'http://192.168.1.42/'
|
||||
|
||||
# 线上本地映射测试
|
||||
VITE_API_URL = 'https://frp.sxczgkj.com'
|
||||
10
.env.test
10
.env.test
@@ -2,7 +2,10 @@
|
||||
ENV = test
|
||||
|
||||
# 测试ws
|
||||
VITE_API_WSS = 'ws://192.168.1.42:2348'
|
||||
# VITE_API_WSS = 'ws://192.168.1.42:2348'
|
||||
|
||||
# 线上本地映射测试ws
|
||||
VITE_API_WSS = 'ws://frp.sxczgkj.com/wss'
|
||||
|
||||
# 测试ws
|
||||
# VITE_API_WSS = 'wss://sockets.sxczgkj.com/wss'
|
||||
@@ -26,4 +29,7 @@ VITE_API_KP_URL = 'https://invoice.sxczgkj.cn/api'
|
||||
# VITE_API_URL = 'https://cashier.sxczgkj.com/'
|
||||
|
||||
# 本地调试连接
|
||||
VITE_API_URL = 'http://192.168.1.42/'
|
||||
# VITE_API_URL = 'http://192.168.1.42/'
|
||||
|
||||
# 线上本地映射测试
|
||||
VITE_API_URL = 'https://frp.sxczgkj.com'
|
||||
File diff suppressed because one or more lines are too long
145
electron/main.js
145
electron/main.js
@@ -5,7 +5,7 @@ import axios from "axios";
|
||||
import os from "os";
|
||||
import fs from "fs";
|
||||
import { exec } from "child_process";
|
||||
import { printReceipt, printHandoverReceipt, printRefund,printRefundDish } from "./printService";
|
||||
import { ORDER, printHandoverReceipt, REFUND_ORDER, RETURN_ORDER, STOCK_CHECK, PRODUCT_REPORT, RECHARGE, STOCK, CALL, REFUND_KITCHEN, ONLY_KITCHEN, DAY_REPORT, ALL_KITCHEN, DAY_ORDER } from "./printService";
|
||||
|
||||
// ===== 核心配置:单文件缓存 =====
|
||||
// 固定的缓存文件路径(永远只存这1个文件)
|
||||
@@ -108,12 +108,12 @@ app.whenReady().then(() => {
|
||||
});
|
||||
|
||||
// 打印结算小票
|
||||
ipcMain.on('networkPrint', async (event, arg) => {
|
||||
ipcMain.on('ORDER', async (event, arg) => {
|
||||
try {
|
||||
let _parmas = JSON.parse(arg);
|
||||
console.log(_parmas);
|
||||
console.log(_parmas.orderData.carts);
|
||||
await printReceipt(_parmas.printerIp, _parmas.orderData);
|
||||
// console.log(_parmas);
|
||||
// console.log(_parmas.orderData.carts);
|
||||
await ORDER(_parmas.printerIp, _parmas.orderData);
|
||||
return { ok: true }
|
||||
} catch (e) {
|
||||
console.log(e);
|
||||
@@ -135,11 +135,11 @@ app.whenReady().then(() => {
|
||||
});
|
||||
|
||||
// 打印退款小票
|
||||
ipcMain.on('printRefund', async (event, arg) => {
|
||||
ipcMain.on('REFUND_ORDER', async (event, arg) => {
|
||||
try {
|
||||
let _parmas = JSON.parse(arg);
|
||||
// console.log(_parmas);
|
||||
await printRefund(_parmas.printerIp, _parmas.orderData);
|
||||
await REFUND_ORDER(_parmas.printerIp, _parmas.orderData);
|
||||
return { ok: true }
|
||||
} catch (e) {
|
||||
console.log(e);
|
||||
@@ -148,11 +148,138 @@ app.whenReady().then(() => {
|
||||
});
|
||||
|
||||
// 打印退菜单
|
||||
ipcMain.on('printRefundDish', async (event, arg) => {
|
||||
ipcMain.on('RETURN_ORDER', async (event, arg) => {
|
||||
try {
|
||||
let _parmas = JSON.parse(arg);
|
||||
// console.log(_parmas);
|
||||
await printRefundDish(_parmas.printerIp, _parmas.orderData);
|
||||
await RETURN_ORDER(_parmas.printerIp, _parmas.orderData);
|
||||
return { ok: true }
|
||||
} catch (e) {
|
||||
console.log(e);
|
||||
return { ok: false, msg: e.message }
|
||||
}
|
||||
});
|
||||
|
||||
// 后厨退餐单 REFUND_KITCHEN
|
||||
ipcMain.on('REFUND_KITCHEN', async (event, arg) => {
|
||||
try {
|
||||
let _parmas = JSON.parse(arg);
|
||||
// console.log(_parmas);
|
||||
await REFUND_KITCHEN(_parmas.printerIp, _parmas.orderData);
|
||||
return { ok: true }
|
||||
} catch (e) {
|
||||
console.log(e);
|
||||
return { ok: false, msg: e.message }
|
||||
}
|
||||
});
|
||||
|
||||
// 后厨退餐单一菜一品 ONLY_KITCHEN
|
||||
ipcMain.on('ONLY_KITCHEN', async (event, arg) => {
|
||||
try {
|
||||
let _parmas = JSON.parse(arg);
|
||||
// console.log(_parmas);
|
||||
await ONLY_KITCHEN(_parmas.printerIp, _parmas.orderData);
|
||||
return { ok: true }
|
||||
} catch (e) {
|
||||
console.log(e);
|
||||
return { ok: false, msg: e.message }
|
||||
}
|
||||
});
|
||||
|
||||
// 后厨整单
|
||||
ipcMain.on('ALL_KITCHEN', async (event, arg) => {
|
||||
try {
|
||||
let _parmas = JSON.parse(arg);
|
||||
// console.log(_parmas);
|
||||
await ALL_KITCHEN(_parmas.printerIp, _parmas.orderData);
|
||||
return { ok: true }
|
||||
} catch (e) {
|
||||
console.log(e);
|
||||
return { ok: false, msg: e.message }
|
||||
}
|
||||
});
|
||||
|
||||
// 打印盘点单
|
||||
ipcMain.on('STOCK_CHECK', async (event, arg) => {
|
||||
try {
|
||||
let _parmas = JSON.parse(arg);
|
||||
// console.log(_parmas);
|
||||
await STOCK_CHECK(_parmas.printerIp, _parmas.orderData);
|
||||
return { ok: true }
|
||||
} catch (e) {
|
||||
console.log(e);
|
||||
return { ok: false, msg: e.message }
|
||||
}
|
||||
});
|
||||
|
||||
// 打印经营日报
|
||||
ipcMain.on('DAY_REPORT', async (event, arg) => {
|
||||
try {
|
||||
let _parmas = JSON.parse(arg);
|
||||
// console.log(_parmas);
|
||||
await DAY_REPORT(_parmas.printerIp, _parmas.orderData);
|
||||
return { ok: true }
|
||||
} catch (e) {
|
||||
console.log(e);
|
||||
return { ok: false, msg: e.message }
|
||||
}
|
||||
});
|
||||
|
||||
// 打印日结单
|
||||
ipcMain.on('DAY_ORDER', async (event, arg) => {
|
||||
try {
|
||||
let _parmas = JSON.parse(arg);
|
||||
// console.log(_parmas);
|
||||
await DAY_ORDER(_parmas.printerIp, _parmas.orderData);
|
||||
return { ok: true }
|
||||
} catch (e) {
|
||||
console.log(e);
|
||||
return { ok: false, msg: e.message }
|
||||
}
|
||||
});
|
||||
|
||||
// 打印排队取号单
|
||||
ipcMain.on('CALL', async (event, arg) => {
|
||||
try {
|
||||
let _parmas = JSON.parse(arg);
|
||||
// console.log(_parmas);
|
||||
await CALL(_parmas.printerIp, _parmas.orderData);
|
||||
return { ok: true }
|
||||
} catch (e) {
|
||||
console.log(e);
|
||||
return { ok: false, msg: e.message }
|
||||
}
|
||||
});
|
||||
|
||||
// 打印商品销售数据
|
||||
ipcMain.on('PRODUCT_REPORT', async (event, arg) => {
|
||||
try {
|
||||
let _parmas = JSON.parse(arg);
|
||||
await PRODUCT_REPORT(_parmas.printerIp, _parmas.orderData);
|
||||
return { ok: true }
|
||||
} catch (e) {
|
||||
console.log(e);
|
||||
return { ok: false, msg: e.message }
|
||||
}
|
||||
});
|
||||
|
||||
// 打印储值单
|
||||
ipcMain.on('RECHARGE', async (event, arg) => {
|
||||
try {
|
||||
let _parmas = JSON.parse(arg);
|
||||
await RECHARGE(_parmas.printerIp, _parmas.orderData);
|
||||
return { ok: true }
|
||||
} catch (e) {
|
||||
console.log(e);
|
||||
return { ok: false, msg: e.message }
|
||||
}
|
||||
});
|
||||
|
||||
// 打印出入库单
|
||||
ipcMain.on('STOCK', async (event, arg) => {
|
||||
try {
|
||||
let _parmas = JSON.parse(arg);
|
||||
await STOCK(_parmas.printerIp, _parmas.orderData);
|
||||
return { ok: true }
|
||||
} catch (e) {
|
||||
console.log(e);
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
26
package-lock.json
generated
26
package-lock.json
generated
@@ -1,12 +1,12 @@
|
||||
{
|
||||
"name": "vite-electron",
|
||||
"version": "2.0.21",
|
||||
"version": "2.0.30",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "vite-electron",
|
||||
"version": "2.0.21",
|
||||
"version": "2.0.30",
|
||||
"hasInstallScript": true,
|
||||
"dependencies": {
|
||||
"@element-plus/icons-vue": "^2.3.1",
|
||||
@@ -21,6 +21,8 @@
|
||||
"lodash": "^4.17.21",
|
||||
"pinia": "^2.1.7",
|
||||
"pinia-plugin-persistedstate": "^3.2.1",
|
||||
"pinyin-match": "^1.2.10",
|
||||
"qr-image": "^3.2.0",
|
||||
"qrcode": "^1.5.3",
|
||||
"reconnecting-websocket": "^4.4.0",
|
||||
"speak-tts": "^2.0.8",
|
||||
@@ -29,7 +31,7 @@
|
||||
"vue": "^3.3.8",
|
||||
"vue-router": "^4.2.5",
|
||||
"win32-api": "^26.1.2",
|
||||
"ysk-utils": "^1.0.85"
|
||||
"ysk-utils": "^1.0.91"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@vitejs/plugin-vue": "^4.5.0",
|
||||
@@ -5222,6 +5224,12 @@
|
||||
"pinia": "^2.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/pinyin-match": {
|
||||
"version": "1.2.10",
|
||||
"resolved": "https://registry.npmmirror.com/pinyin-match/-/pinyin-match-1.2.10.tgz",
|
||||
"integrity": "sha512-Xo1uMd9n56/xP2EAn7yfApnTmAGCLGqxFIm1fuOnSMty0xhqRF3+ZwVjp2yWFD/alv60RUWa/cZoQSeTSp1HxA==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/plist": {
|
||||
"version": "3.1.0",
|
||||
"resolved": "https://registry.npmmirror.com/plist/-/plist-3.1.0.tgz",
|
||||
@@ -5332,6 +5340,12 @@
|
||||
"node": ">=6"
|
||||
}
|
||||
},
|
||||
"node_modules/qr-image": {
|
||||
"version": "3.2.0",
|
||||
"resolved": "https://registry.npmmirror.com/qr-image/-/qr-image-3.2.0.tgz",
|
||||
"integrity": "sha512-rXKDS5Sx3YipVsqmlMJsJsk6jXylEpiHRC2+nJy66fxA5ExYyGa4PqwteW69SaVmAb2OQ18HbYriT7cGQMbduw==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/qrcode": {
|
||||
"version": "1.5.4",
|
||||
"resolved": "https://registry.npmmirror.com/qrcode/-/qrcode-1.5.4.tgz",
|
||||
@@ -6723,9 +6737,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/ysk-utils": {
|
||||
"version": "1.0.85",
|
||||
"resolved": "https://registry.npmmirror.com/ysk-utils/-/ysk-utils-1.0.85.tgz",
|
||||
"integrity": "sha512-HkbV4Jidi3G6DAuGAN972tClUYtC2zVoxo4crrxexfn0rZa8HjXatUfEbawHOeEzyl6G1CdC+160I2bKfxEBlA==",
|
||||
"version": "1.0.91",
|
||||
"resolved": "https://registry.npmmirror.com/ysk-utils/-/ysk-utils-1.0.91.tgz",
|
||||
"integrity": "sha512-zM0846gmFvo7QIMNeqAKa8e7wnGOGpy7cDwwQdbJzHs4m/UaAC2hgU9MfLfK3U+f4W2TbxsMsZ0ekP4EbSJVUw==",
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"bignumber.js": "^9.3.1",
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "vite-electron",
|
||||
"private": true,
|
||||
"version": "2.0.25",
|
||||
"version": "2.0.32",
|
||||
"main": "dist-electron/main.js",
|
||||
"scripts": {
|
||||
"dev": "chcp 65001 && vite",
|
||||
@@ -24,6 +24,8 @@
|
||||
"lodash": "^4.17.21",
|
||||
"pinia": "^2.1.7",
|
||||
"pinia-plugin-persistedstate": "^3.2.1",
|
||||
"pinyin-match": "^1.2.10",
|
||||
"qr-image": "^3.2.0",
|
||||
"qrcode": "^1.5.3",
|
||||
"reconnecting-websocket": "^4.4.0",
|
||||
"speak-tts": "^2.0.8",
|
||||
@@ -32,7 +34,7 @@
|
||||
"vue": "^3.3.8",
|
||||
"vue-router": "^4.2.5",
|
||||
"win32-api": "^26.1.2",
|
||||
"ysk-utils": "^1.0.85"
|
||||
"ysk-utils": "^1.0.91"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@vitejs/plugin-vue": "^4.5.0",
|
||||
|
||||
@@ -49,7 +49,7 @@ watch(route, (to) => {
|
||||
includeList.push(to.name);
|
||||
}
|
||||
// 需要全屏的路由
|
||||
let arr = ["/login", "/device_list", "/add_device", "/add_label", "/webview", '/workrecord'];
|
||||
let arr = ["/login", "/device_list", "/add_device", "/add_label", "/webview", '/workrecord', '/store_wine'];
|
||||
if (arr.includes(to.path)) {
|
||||
hideLeftMenu.value = true;
|
||||
} else {
|
||||
|
||||
14
src/api/print.js
Normal file
14
src/api/print.js
Normal file
@@ -0,0 +1,14 @@
|
||||
import request from "@/utils/request.js";
|
||||
|
||||
/**
|
||||
* 获取打印数据
|
||||
* @param {*} params
|
||||
* @returns
|
||||
*/
|
||||
export function printData(params) {
|
||||
return request({
|
||||
method: "get",
|
||||
url: "/order/admin/printData",
|
||||
params,
|
||||
});
|
||||
}
|
||||
@@ -65,6 +65,44 @@ export function storageGoodGet(params) {
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加酒品
|
||||
* @param {*} params
|
||||
* @returns
|
||||
*/
|
||||
export function storageGoodPost(data) {
|
||||
return request({
|
||||
method: "post",
|
||||
url: "/product/admin/storageGood",
|
||||
data,
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑酒品
|
||||
* @param {*} params
|
||||
* @returns
|
||||
*/
|
||||
export function storageGoodPut(data) {
|
||||
return request({
|
||||
method: "put",
|
||||
url: "/product/admin/storageGood/edit",
|
||||
data,
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除酒品
|
||||
* @param {*} params
|
||||
* @returns
|
||||
*/
|
||||
export function storageGoodDelete(id) {
|
||||
return request({
|
||||
method: "DELETE",
|
||||
url: `/product/admin/storageGood?id=${id}`,
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 存酒记录添加
|
||||
* @param {*} data
|
||||
@@ -117,6 +155,18 @@ export function shopStorageRecord(params) {
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 存酒统计
|
||||
* @param {*} data
|
||||
* @returns
|
||||
*/
|
||||
export function shopStorageCount() {
|
||||
return request({
|
||||
method: "get",
|
||||
url: "/product/admin/shopStorage/count"
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 耗材库存列表接口
|
||||
* @param {*} data
|
||||
|
||||
@@ -108,7 +108,8 @@ onMounted(() => {
|
||||
|
||||
<style scoped lang="scss">
|
||||
.list {
|
||||
min-height: 200px;
|
||||
height: 55vh;
|
||||
overflow-y: auto;
|
||||
|
||||
.row {
|
||||
padding-bottom: 20px;
|
||||
|
||||
@@ -3,7 +3,7 @@ import getLodop from "./LodopFuncs.js";
|
||||
* 打印交班小票
|
||||
*/
|
||||
export default (data) => {
|
||||
console.log("data.deviceName===", data.deviceName);
|
||||
console.log("USB.打印交班小票===", data);
|
||||
let LODOP = getLodop();
|
||||
LODOP.PRINT_INIT("打印小票");
|
||||
// 设置打印纸大小D
|
||||
@@ -19,31 +19,31 @@ export default (data) => {
|
||||
交班小票
|
||||
</div>
|
||||
<div style="font-size: 12px;margin-top:50px;">
|
||||
当班时间:${data.loginTime}
|
||||
当班时间:${data.handoverTime }
|
||||
</div>
|
||||
<div style="font-size: 12px;">
|
||||
交班时间:${data.handoverTime}
|
||||
交班时间:${data.loginTime || ""} - ${data.handoverTime || ""}
|
||||
</div>
|
||||
<div style="font-size: 12px;">
|
||||
收银员:${data.staffName}
|
||||
收银员:${data.staffName || ""}
|
||||
</div>
|
||||
<div style="font-size: 12px;margin-top: 4px;">
|
||||
当班总收入:${data.handAmount}
|
||||
当班总收入:${data.turnover || 0}
|
||||
</div>
|
||||
<div style="font-size: 12px;margin-top: 4px;">
|
||||
现金收入:${data.cashAmount}
|
||||
现金收入:${data.cash || 0}
|
||||
</div>
|
||||
<div style="font-size: 12px;margin-top: 4px;">
|
||||
微信收入:${data.wechatAmount}
|
||||
微信收入:${data.wechat || 0}
|
||||
</div>
|
||||
<div style="font-size: 12px;margin-top: 4px;">
|
||||
支付宝收入:${data.alipayAmount}
|
||||
支付宝收入:${data.alipay || 0}
|
||||
</div>
|
||||
<div style="font-size: 12px;margin-top: 4px;">
|
||||
会员支付:${data.vipPay}
|
||||
会员支付:${data.balance || 0}
|
||||
</div>
|
||||
<div style="font-size: 12px;margin-top: 4px;">
|
||||
会员充值:${data.vipRecharge}
|
||||
会员充值:${data.recharge || 0}
|
||||
</div>
|
||||
`;
|
||||
|
||||
@@ -86,72 +86,74 @@ export default (data) => {
|
||||
`;
|
||||
|
||||
let productCategoriesTableBody = "";
|
||||
if (data.categoryDataList && data.categoryDataList.length) {
|
||||
for (let item of data.categoryDataList) {
|
||||
if (data.categoryList && data.categoryList.length) {
|
||||
for (let item of data.categoryList) {
|
||||
productCategoriesTableBody += `
|
||||
<tr>
|
||||
<td style="font-size: 12px;width:50%;">
|
||||
<div>${item.categoryName}</div>
|
||||
</td>
|
||||
<td style="font-size: 12px;width:25%;">${item.num}</td>
|
||||
<td style="font-size: 12px;width:25%;">${item.num || 0}</td>
|
||||
<td style="font-size: 12px;width:25%;">
|
||||
${item.amount}
|
||||
${item.amount || 0}
|
||||
</td>
|
||||
</tr>
|
||||
`;
|
||||
}
|
||||
}
|
||||
|
||||
let tabHead = `
|
||||
</table>
|
||||
<div style="font-size: 12px;margin-top: 4px;">商品数据</div>
|
||||
<table class="table" style="width: 100%;">
|
||||
<tr>
|
||||
<td style="font-size: 12px;width:75%;">商品</td>
|
||||
<td style="font-size: 12px;width:25%;">数量</td>
|
||||
</tr>
|
||||
`;
|
||||
// let tabHead = `
|
||||
// </table>
|
||||
// <div style="font-size: 12px;margin-top: 4px;">商品数据</div>
|
||||
// <table class="table" style="width: 100%;">
|
||||
// <tr>
|
||||
// <td style="font-size: 12px;width:75%;">商品</td>
|
||||
// <td style="font-size: 12px;width:25%;">数量</td>
|
||||
// </tr>
|
||||
// `;
|
||||
|
||||
// let tableBody = "";
|
||||
// if (data.productDataList && data.productDataList.length) {
|
||||
// for (let item of data.productDataList) {
|
||||
// tableBody += `
|
||||
// <tr>
|
||||
// <td style="font-size: 12px;width:75%;">
|
||||
// <div>${item.productName}</div>
|
||||
// </td>
|
||||
// <td style="font-size: 12px;width:25%;">${item.num}</td>
|
||||
// </tr>
|
||||
// `;
|
||||
// }
|
||||
// }
|
||||
|
||||
// if (!data.printShop) {
|
||||
// tabHead = "";
|
||||
// tableBody = "";
|
||||
// }
|
||||
let tabHead = "";
|
||||
let tableBody = "";
|
||||
if (data.productDataList && data.productDataList.length) {
|
||||
for (let item of data.productDataList) {
|
||||
tableBody += `
|
||||
<tr>
|
||||
<td style="font-size: 12px;width:75%;">
|
||||
<div>${item.productName}</div>
|
||||
</td>
|
||||
<td style="font-size: 12px;width:25%;">${item.num}</td>
|
||||
</tr>
|
||||
`;
|
||||
}
|
||||
}
|
||||
|
||||
if (!data.printShop) {
|
||||
tabHead = "";
|
||||
tableBody = "";
|
||||
}
|
||||
|
||||
let str = `
|
||||
</table>
|
||||
<div style="font-size: 12px;margin-top: 4px;">
|
||||
<span>快捷收款金额:</span>
|
||||
<span>${data.quickInAmount}</span>
|
||||
<span>${data.barScan || 0}</span>
|
||||
</div>
|
||||
<div style="font-size: 12px;">
|
||||
<span>退款金额:</span>
|
||||
<span>${data.refundAmount}</span>
|
||||
<span>${data.refundAmount || 0}</span>
|
||||
</div>
|
||||
<div style="font-size: 12px;">
|
||||
<span>总收入:</span>
|
||||
<span>${data.handAmount}</span>
|
||||
<span>${data.turnover || 0}</span>
|
||||
</div>
|
||||
<div style="font-size: 12px;">
|
||||
<span>挂账金额:</span>
|
||||
<span>${data.creditAmount}</span>
|
||||
<span>${data.owed || 0}</span>
|
||||
</div>
|
||||
<div style="margin-top: 20px; font-size: 12px;">
|
||||
<span>总订单数:</span>
|
||||
<span>${data.orderCount}</span>
|
||||
<span>${data.orderCount || 0}</span>
|
||||
</div>
|
||||
<div style="font-size: 12px;">
|
||||
打印时间:${data.printTime}
|
||||
|
||||
@@ -45,11 +45,19 @@
|
||||
<div class="drawerbox_bo_box_itembox" @click="router.push({ name: 'device_list' })">
|
||||
<div class="drawerbox_bo_box_icon">
|
||||
<el-icon size="40">
|
||||
<TurnOff />
|
||||
<Printer />
|
||||
</el-icon>
|
||||
</div>
|
||||
<div class="drawerbox_bo_box_icontext">设备管理</div>
|
||||
</div>
|
||||
<div class="drawerbox_bo_box_itembox" @click="router.push({ name: 'store_wine' })">
|
||||
<div class="drawerbox_bo_box_icon">
|
||||
<el-icon size="40">
|
||||
<Goblet />
|
||||
</el-icon>
|
||||
</div>
|
||||
<div class="drawerbox_bo_box_icontext">存酒管理</div>
|
||||
</div>
|
||||
<!-- <div class="drawerbox_bo_box_itembox" @click="openCallHandle">
|
||||
<div class="drawerbox_bo_box_icon">
|
||||
<el-icon size="40">
|
||||
|
||||
@@ -448,7 +448,7 @@ async function payTypeChange(index, item) {
|
||||
SelectVipUserRef.value.show()
|
||||
}
|
||||
}
|
||||
if (item.payType == "arrears") {
|
||||
if (item.payType == "virtual") {
|
||||
// 挂账支付
|
||||
showBuyerHandle();
|
||||
}
|
||||
@@ -540,7 +540,7 @@ async function confirmOrder(t = 1) {
|
||||
upadatePayData()
|
||||
|
||||
payType.value = payList.value[payActive.value].payType
|
||||
if (payList.value[payActive.value].payType == "arrears") {
|
||||
if (payList.value[payActive.value].payType == "virtual") {
|
||||
showBuyerHandle();
|
||||
return
|
||||
} else if (payList.value[payActive.value].payType == "scanCode") {
|
||||
|
||||
@@ -129,14 +129,11 @@ async function submitHandleAjax() {
|
||||
console.log('props.selecttype===', props.selecttype);
|
||||
console.log('props.payType===', props.payType);
|
||||
|
||||
// return;
|
||||
|
||||
if (props.selecttype == 0) {
|
||||
// 判断订单是否锁定
|
||||
await goodsStore.isOrderLock({
|
||||
table_code: goodsStore.orderListInfo.tableCode
|
||||
})
|
||||
|
||||
if (props.selecttype == 0) {
|
||||
// 下单扫码支付
|
||||
if (props.payType == 'scanCode') {
|
||||
await microPay({
|
||||
@@ -151,6 +148,7 @@ async function submitHandleAjax() {
|
||||
});
|
||||
}
|
||||
} else if (props.selecttype == 1) {
|
||||
console.log('进入会员扫码充值');
|
||||
// 会员扫码充值
|
||||
await microPayVip({
|
||||
shopId: store.shopInfo.id,
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<div class="title_wrap">请确认当前菜品是否已上菜</div>
|
||||
<div class="list_wrap">
|
||||
<div class="item" v-for="(item, index) in list" :key="index">
|
||||
<span>{{ item.name }}</span>
|
||||
<span>{{ item.name || item.product_name }}</span>
|
||||
<span>x{{ item.num }}</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -17,7 +17,6 @@ import { ref } from 'vue';
|
||||
import userStore from '@/utils/useStorage.js'
|
||||
import { ElUpload, ElMessage } from 'element-plus';
|
||||
|
||||
|
||||
const fileList = ref([])
|
||||
|
||||
// 定义接收的外部属性
|
||||
|
||||
@@ -101,6 +101,11 @@ const routes = [
|
||||
name: "webview",
|
||||
component: () => import("@/views/webview/index.vue"),
|
||||
},
|
||||
{
|
||||
path: "/store_wine",
|
||||
name: "store_wine",
|
||||
component: () => import("@/views/store_wine/index.vue"),
|
||||
},
|
||||
];
|
||||
|
||||
const router = createRouter({
|
||||
|
||||
@@ -11,6 +11,7 @@ import useStorage from "@/utils/useStorage.js";
|
||||
import { formatDecimal } from "@/utils/index.js";
|
||||
import { shopUserDetail } from "@/api/account.js";
|
||||
import { ElMessage } from "element-plus";
|
||||
import PinyinMatch from 'pinyin-match';
|
||||
|
||||
import {
|
||||
OrderPriceCalculator, limitUtils,
|
||||
@@ -359,10 +360,16 @@ export const useGoods = defineStore("goods", {
|
||||
// 根据商品名字模糊查询商品列表
|
||||
filterNameGoods(name) {
|
||||
this.goodsList = _.chunk(
|
||||
this.originGoodsList.filter((item) => item.name.includes(name)),
|
||||
this.originGoodsList.filter((item) => {
|
||||
// 原来的汉字模糊搜索
|
||||
const hasName = item.name.includes(name);
|
||||
// 新增:拼音/首字母模糊搜索(zs / zhangsan / 张三 都能搜)
|
||||
const hasPinyin = name && PinyinMatch.match(item.name, name);
|
||||
|
||||
return hasName || hasPinyin;
|
||||
}),
|
||||
12
|
||||
);
|
||||
|
||||
this.updateGoodsNumber();
|
||||
},
|
||||
// 获取商品分类列表
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import _ from 'lodash'
|
||||
import { defineStore } from "pinia";
|
||||
import { ipcRenderer } from "electron";
|
||||
import { useUser } from "@/store/user.js";
|
||||
@@ -23,9 +24,45 @@ export const usePrint = defineStore("print", {
|
||||
printTimer: null,
|
||||
receiptList: [],
|
||||
receiptTimer: null,
|
||||
// 新增:其他打印任务队列与状态锁
|
||||
printQueue: [],
|
||||
isProcessing: false
|
||||
}),
|
||||
|
||||
actions: {
|
||||
// 1. 添加任务到队列
|
||||
addToPrintQueue(task) {
|
||||
this.printQueue.push(task);
|
||||
if (this.log) console.log('任务已加入打印队列,当前队列长度:', this.printQueue.length);
|
||||
this.processPrintQueue(); // 尝试启动处理
|
||||
},
|
||||
// 2. 处理队列(递归执行)
|
||||
async processPrintQueue() {
|
||||
// 如果正在处理或队列为空,直接返回
|
||||
if (this.isProcessing || this.printQueue.length === 0) return;
|
||||
|
||||
this.isProcessing = true;
|
||||
const currentTask = this.printQueue[0]; // 取出第一个任务
|
||||
|
||||
try {
|
||||
if (this.log) console.log('开始执行打印任务:', currentTask);
|
||||
// 执行打印逻辑(参考你注释中的代码)
|
||||
await new Promise(resolve => setTimeout(resolve, 1500));
|
||||
ipcRenderer.send(currentTask.taskName, currentTask.data)
|
||||
if (this.log) console.log('任务执行成功');
|
||||
} catch (error) {
|
||||
console.error('打印任务执行失败:', error);
|
||||
// 失败时不移除任务,或者根据业务决定是否重试/丢弃
|
||||
} finally {
|
||||
// 无论成功失败,移除当前任务
|
||||
this.printQueue.shift();
|
||||
if (this.log) console.log('任务移除,剩余队列:', this.printQueue.length);
|
||||
|
||||
// 标记为空闲,尝试处理下一个
|
||||
this.isProcessing = false;
|
||||
this.processPrintQueue();
|
||||
}
|
||||
},
|
||||
async init() {
|
||||
ipcRenderer.send("getPrintList");
|
||||
ipcRenderer.on("printList", (event, arg) => {
|
||||
@@ -35,10 +72,10 @@ export const usePrint = defineStore("print", {
|
||||
try {
|
||||
const res = await printerList();
|
||||
this.deviceNoteList = res.records.filter(
|
||||
(item) => item.status && item.subType == "cash"
|
||||
(item) => item.status && item.printType == "cash"
|
||||
);
|
||||
this.deviceLableList = res.records.filter(
|
||||
(item) => item.status && item.subType == "label"
|
||||
(item) => item.status && item.printType == "label"
|
||||
);
|
||||
} catch (error) {
|
||||
console.error("获取打印机列表失败", error);
|
||||
@@ -46,6 +83,7 @@ export const usePrint = defineStore("print", {
|
||||
this.checkPrintService();
|
||||
},
|
||||
|
||||
// 优化:增加打印服务检查次数限制,避免无限等待
|
||||
checkPrintService() {
|
||||
this.printServiceTimer = setInterval(() => {
|
||||
if (
|
||||
@@ -89,121 +127,288 @@ export const usePrint = defineStore("print", {
|
||||
return !item.categoryId && (item.isSpecialFee || specialNames.some(name => item.name?.includes(name)));
|
||||
},
|
||||
|
||||
// ==============================
|
||||
// 优化:保留无categoryId的特殊费用项,兼容原有分类过滤逻辑
|
||||
// ==============================
|
||||
pushReceiptData(props, isDevice = true) {
|
||||
if (!isDevice) {
|
||||
this.receiptList.push(props);
|
||||
this.startReceiptPrint();
|
||||
return;
|
||||
}
|
||||
|
||||
// 结算单
|
||||
async ORDER(data) {
|
||||
try {
|
||||
console.log('结算单===', data);
|
||||
// 筛选条件:状态启用 + 小票类型 + handoverSwitch=1 + 打印机可用 + 打印服务正常
|
||||
const validPrinters = this.deviceNoteList.filter(p => {
|
||||
return this.checkPrinterAvailable(p) && this.isPrintService;
|
||||
return p.status
|
||||
&& p.printType === "cash"
|
||||
&& _.includes(p.printContentType.split(','), 'ORDER')
|
||||
&& this.checkPrinterAvailable(p)
|
||||
&& this.isPrintService;
|
||||
});
|
||||
|
||||
if (validPrinters.length === 0) {
|
||||
console.log("无可用小票打印机");
|
||||
console.log("结算单:无符合条件的可用打印机");
|
||||
return;
|
||||
}
|
||||
|
||||
const store = useUser();
|
||||
|
||||
// 遍历符合条件的打印机打印
|
||||
validPrinters.forEach(printer => {
|
||||
let filterCarts = [];
|
||||
|
||||
// 核心过滤逻辑:
|
||||
// 1. 分类为空 → 打印全部(包含特殊费用项)
|
||||
// 2. 分类非空 → 打印「匹配分类的商品」+「无categoryId的特殊费用项」
|
||||
if (!printer.categoryList || printer.categoryList.length === 0) {
|
||||
filterCarts = props.carts || [];
|
||||
} else {
|
||||
filterCarts = (props.carts || []).filter(item => {
|
||||
// 保留:特殊费用项(无categoryId) + 匹配分类的商品(有categoryId)
|
||||
return this.isSpecialFeeItem(item) || printer.categoryList.includes(item.categoryId);
|
||||
});
|
||||
}
|
||||
|
||||
if (filterCarts.length === 0) return;
|
||||
|
||||
const printData = {
|
||||
...props,
|
||||
carts: filterCarts,
|
||||
...data,
|
||||
deviceId: printer.id,
|
||||
deviceName: printer.address,
|
||||
printerName: printer.name,
|
||||
deviceName: printer.name,
|
||||
connectionType: printer.connectionType,
|
||||
shop_name: store.shopInfo.shopName,
|
||||
loginAccount: store.userInfo.name,
|
||||
createdAt: dayjs(props.createdAt).format("YYYY-MM-DD HH:mm:ss"),
|
||||
printTime: dayjs().format("YYYY-MM-DD HH:mm:ss"),
|
||||
};
|
||||
|
||||
if (!printData.orderInfo.masterId) {
|
||||
printData.orderInfo.masterId = printData.orderInfo.tableName;
|
||||
}
|
||||
printData.orderInfo.outNumber = printData.outNumber;
|
||||
if (!printData.discountAmount) {
|
||||
printData.discountAmount = printData.amount;
|
||||
}
|
||||
|
||||
this.receiptList.push(printData);
|
||||
});
|
||||
|
||||
if (this.receiptList.length > 0) {
|
||||
this.startReceiptPrint();
|
||||
}
|
||||
},
|
||||
|
||||
// ==============================
|
||||
// 打印执行(USB/局域网自动区分)
|
||||
// ==============================
|
||||
async startReceiptPrint() {
|
||||
try {
|
||||
const socketStore = useSocket();
|
||||
const userStore = useUser();
|
||||
if (this.receiptTimer !== null) return;
|
||||
|
||||
this.receiptTimer = setInterval(() => {
|
||||
if (!this.receiptList.length) {
|
||||
clearInterval(this.receiptTimer);
|
||||
this.receiptTimer = null;
|
||||
return;
|
||||
}
|
||||
|
||||
const printData = this.receiptList[0];
|
||||
try {
|
||||
if (printData.connectionType === "局域网") {
|
||||
ipcRenderer.send('networkPrint', JSON.stringify({
|
||||
printerIp: printData.deviceName,
|
||||
// 区分局域网和USB打印机
|
||||
if (printer.connectionType === "局域网") {
|
||||
this.addToPrintQueue({
|
||||
taskName: 'ORDER',
|
||||
data: JSON.stringify({
|
||||
printerIp: printer.address,
|
||||
orderData: printData
|
||||
}));
|
||||
})
|
||||
})
|
||||
} else {
|
||||
receiptPrint(printData);
|
||||
}
|
||||
console.log("✅ 打印结算单成功:", printer.address);
|
||||
} catch (error) {
|
||||
console.error("❌ 打印结算单失败:", printer.address, error);
|
||||
}
|
||||
});
|
||||
} catch (error) {
|
||||
console.log("结算单打印异常", error);
|
||||
}
|
||||
},
|
||||
// 客看单
|
||||
async GUEST_ORDER(data) {
|
||||
try {
|
||||
// 筛选条件:状态启用 + 小票类型 + handoverSwitch=1 + 打印机可用 + 打印服务正常
|
||||
const validPrinters = this.deviceNoteList.filter(p => {
|
||||
return p.status
|
||||
&& p.printType === "cash"
|
||||
&& _.includes(p.printContentType.split(','), 'GUEST_ORDER')
|
||||
&& this.checkPrinterAvailable(p)
|
||||
&& this.isPrintService;
|
||||
});
|
||||
|
||||
const syncData = {
|
||||
type: "cashier",
|
||||
operate_type: "order_print_status",
|
||||
table_code: printData.orderInfo.tableCode,
|
||||
account: userStore.shopInfo.account,
|
||||
print_status: "1",
|
||||
order_id: printData.orderInfo.id,
|
||||
print_id: printData.deviceId,
|
||||
shop_id: printData.orderInfo.shopId,
|
||||
if (validPrinters.length === 0) {
|
||||
console.log("结算单:无符合条件的可用打印机");
|
||||
return;
|
||||
}
|
||||
|
||||
// 遍历符合条件的打印机打印
|
||||
validPrinters.forEach(printer => {
|
||||
const printData = {
|
||||
...data,
|
||||
deviceId: printer.id,
|
||||
deviceName: printer.name,
|
||||
connectionType: printer.connectionType,
|
||||
printTime: dayjs().format("YYYY-MM-DD HH:mm:ss"),
|
||||
};
|
||||
socketStore.ws.send(JSON.stringify(syncData));
|
||||
console.log("✅ 打印成功:", printData.deviceName, "菜品数:", printData.carts.length);
|
||||
} catch (error) {
|
||||
console.error("❌ 打印失败:", printData.deviceName, error);
|
||||
} finally {
|
||||
this.receiptList.splice(0, 1);
|
||||
|
||||
try {
|
||||
// 区分局域网和USB打印机
|
||||
if (printer.connectionType === "局域网") {
|
||||
this.addToPrintQueue({
|
||||
taskName: 'ORDER',
|
||||
data: JSON.stringify({
|
||||
printerIp: printer.address,
|
||||
orderData: printData
|
||||
})
|
||||
})
|
||||
} else {
|
||||
receiptPrint(printData);
|
||||
}
|
||||
}, 2000);
|
||||
console.log("✅ 打印客看单成功:", printer.address);
|
||||
} catch (error) {
|
||||
console.log("打印定时器异常", error);
|
||||
console.error("❌ 打印客看单失败:", printer.address, error);
|
||||
}
|
||||
});
|
||||
} catch (error) {
|
||||
console.log("客看单打印异常", error);
|
||||
}
|
||||
},
|
||||
// 预结算单
|
||||
async PRE_ORDER(data) {
|
||||
try {
|
||||
// 筛选条件:状态启用 + 小票类型 + handoverSwitch=1 + 打印机可用 + 打印服务正常
|
||||
const validPrinters = this.deviceNoteList.filter(p => {
|
||||
return p.status
|
||||
&& p.printType === "cash"
|
||||
&& _.includes(p.printContentType.split(','), 'PRE_ORDER')
|
||||
&& this.checkPrinterAvailable(p)
|
||||
&& this.isPrintService;
|
||||
});
|
||||
|
||||
if (validPrinters.length === 0) {
|
||||
console.log("预结算单:无符合条件的可用打印机");
|
||||
return;
|
||||
}
|
||||
|
||||
// 遍历符合条件的打印机打印
|
||||
validPrinters.forEach(printer => {
|
||||
const printData = {
|
||||
...data,
|
||||
deviceId: printer.id,
|
||||
deviceName: printer.name,
|
||||
connectionType: printer.connectionType,
|
||||
printTime: dayjs().format("YYYY-MM-DD HH:mm:ss"),
|
||||
};
|
||||
|
||||
try {
|
||||
// 区分局域网和USB打印机
|
||||
if (printer.connectionType === "局域网") {
|
||||
this.addToPrintQueue({
|
||||
taskName: 'ORDER',
|
||||
data: JSON.stringify({
|
||||
printerIp: printer.address,
|
||||
orderData: printData
|
||||
})
|
||||
})
|
||||
} else {
|
||||
receiptPrint(printData);
|
||||
}
|
||||
console.log("✅ 打印预结算单成功:", printer.address);
|
||||
} catch (error) {
|
||||
console.error("❌ 打印预结算单失败:", printer.address, error);
|
||||
}
|
||||
});
|
||||
} catch (error) {
|
||||
console.log("预结算单打印异常", error);
|
||||
}
|
||||
},
|
||||
// 打印一菜一品厨房票
|
||||
ONLY_KITCHEN(data) {
|
||||
// 筛选条件:状态启用 + 小票类型 + handoverSwitch=1 + 打印机可用 + 打印服务正常
|
||||
const validPrinters = this.deviceNoteList.filter(p => {
|
||||
return p.status
|
||||
&& p.printType === "cash"
|
||||
&& _.includes(p.printContentType.split(','), 'ONLY_KITCHEN')
|
||||
&& this.checkPrinterAvailable(p)
|
||||
&& this.isPrintService;
|
||||
});
|
||||
|
||||
if (validPrinters.length === 0) {
|
||||
console.log("打印一菜一品厨房票:无符合条件的可用打印机");
|
||||
return;
|
||||
}
|
||||
|
||||
// 遍历符合条件的打印机打印
|
||||
validPrinters.forEach(printer => {
|
||||
|
||||
let cartsToPrint = data.carts; // 默认打印所有商品
|
||||
|
||||
// 检查打印机是否配置了 categoryIds (假设 printer 对象上有此字段)
|
||||
if (printer.categoryIds) {
|
||||
// 将字符串 "617,616..." 分割成数组,并转为数字以便比较
|
||||
const allowedCategories = printer.categoryIds.split(',').map(id => Number(id));
|
||||
|
||||
// 过滤商品:只保留 categoryId 在允许列表中的商品
|
||||
cartsToPrint = data.carts.filter(item => {
|
||||
return allowedCategories.includes(Number(item.categoryId));
|
||||
});
|
||||
}
|
||||
// --- 新增逻辑结束 ---
|
||||
|
||||
// 可选:如果过滤后没有商品,可以选择不打印或打印空单,这里选择跳过
|
||||
if (cartsToPrint.length === 0) {
|
||||
console.log(`打印一菜一品厨房票:打印机 ${printer.name} 配置了分类,但当前订单无对应分类商品,跳过打印。`);
|
||||
return;
|
||||
}
|
||||
|
||||
const printData = {
|
||||
...data,
|
||||
carts: cartsToPrint, // 使用过滤后的商品列表覆盖原数据
|
||||
deviceId: printer.id,
|
||||
deviceName: printer.name,
|
||||
connectionType: printer.connectionType,
|
||||
printTime: dayjs().format("YYYY-MM-DD HH:mm:ss"),
|
||||
};
|
||||
|
||||
try {
|
||||
// 区分局域网和USB打印机
|
||||
if (printer.connectionType === "局域网") {
|
||||
this.addToPrintQueue({
|
||||
taskName: 'ONLY_KITCHEN',
|
||||
data: JSON.stringify({
|
||||
printerIp: printer.address,
|
||||
orderData: printData
|
||||
})
|
||||
})
|
||||
}
|
||||
// else {
|
||||
// lodopPrintWork(printData);
|
||||
// }
|
||||
console.log("✅ 打印一菜一品厨房票成功:", printer.address);
|
||||
} catch (error) {
|
||||
console.error("❌ 打印一菜一品厨房票失败:", printer.address, error);
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
// 打印厨房整单
|
||||
ALL_KITCHEN(data) {
|
||||
// 筛选条件:状态启用 + 小票类型 + handoverSwitch=1 + 打印机可用 + 打印服务正常
|
||||
const validPrinters = this.deviceNoteList.filter(p => {
|
||||
return p.status
|
||||
&& p.printType === "cash"
|
||||
&& _.includes(p.printContentType.split(','), 'ALL_KITCHEN')
|
||||
&& this.checkPrinterAvailable(p)
|
||||
&& this.isPrintService;
|
||||
});
|
||||
|
||||
if (validPrinters.length === 0) {
|
||||
console.log("打印厨房整单:无符合条件的可用打印机)");
|
||||
return;
|
||||
}
|
||||
|
||||
// 遍历符合条件的打印机打印
|
||||
validPrinters.forEach(printer => {
|
||||
// --- 新增逻辑开始:根据分类ID过滤商品 ---
|
||||
let cartsToPrint = data.carts; // 默认打印所有商品
|
||||
|
||||
// 检查打印机是否配置了 categoryIds (假设 printer 对象上有此字段)
|
||||
if (printer.categoryIds) {
|
||||
// 将字符串 "617,616..." 分割成数组,并转为数字以便比较
|
||||
const allowedCategories = printer.categoryIds.split(',').map(id => Number(id));
|
||||
|
||||
|
||||
// 过滤商品:只保留 categoryId 在允许列表中的商品
|
||||
cartsToPrint = data.carts.filter(item => {
|
||||
return allowedCategories.includes(Number(item.categoryId));
|
||||
});
|
||||
}
|
||||
// --- 新增逻辑结束 ---
|
||||
|
||||
// 可选:如果过滤后没有商品,可以选择不打印或打印空单,这里选择跳过
|
||||
if (cartsToPrint.length === 0) {
|
||||
console.log(`打印厨房整单:打印机 ${printer.name} 配置了分类,但当前订单无对应分类商品,跳过打印。`);
|
||||
return;
|
||||
}
|
||||
|
||||
const printData = {
|
||||
...data,
|
||||
carts: cartsToPrint, // 使用过滤后的商品列表覆盖原数据
|
||||
deviceId: printer.id,
|
||||
deviceName: printer.name,
|
||||
connectionType: printer.connectionType,
|
||||
printTime: dayjs().format("YYYY-MM-DD HH:mm:ss"),
|
||||
};
|
||||
|
||||
try {
|
||||
// 区分局域网和USB打印机
|
||||
if (printer.connectionType === "局域网") {
|
||||
this.addToPrintQueue({
|
||||
taskName: 'ALL_KITCHEN',
|
||||
data: JSON.stringify({
|
||||
printerIp: printer.address,
|
||||
orderData: printData
|
||||
})
|
||||
})
|
||||
}
|
||||
console.log("✅ 打印厨房整单成功:", printer.address);
|
||||
} catch (error) {
|
||||
console.error("❌ 打印厨房整单失败:", printer.address, error);
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
// ————————————————————————————————
|
||||
@@ -281,8 +486,8 @@ export const usePrint = defineStore("print", {
|
||||
// 筛选条件:状态启用 + 小票类型 + handoverSwitch=1 + 打印机可用 + 打印服务正常
|
||||
const validPrinters = this.deviceNoteList.filter(p => {
|
||||
return p.status
|
||||
&& p.subType === "cash"
|
||||
&& p.handoverSwitch === 1
|
||||
&& p.printType === "cash"
|
||||
&& _.includes(p.printContentType.split(','), 'HANDOVER')
|
||||
&& this.checkPrinterAvailable(p)
|
||||
&& this.isPrintService;
|
||||
});
|
||||
@@ -297,7 +502,7 @@ export const usePrint = defineStore("print", {
|
||||
const printData = {
|
||||
...data,
|
||||
deviceId: printer.id,
|
||||
deviceName: printer.address,
|
||||
deviceName: printer.name,
|
||||
connectionType: printer.connectionType,
|
||||
printTime: dayjs().format("YYYY-MM-DD HH:mm:ss"),
|
||||
};
|
||||
@@ -331,11 +536,12 @@ export const usePrint = defineStore("print", {
|
||||
},
|
||||
|
||||
// 退款小票打印
|
||||
printRefund(data) {
|
||||
REFUND_ORDER(data) {
|
||||
// 筛选条件:状态启用 + 小票类型 + 打印机可用 + 打印服务正常
|
||||
const validPrinters = this.deviceNoteList.filter(p => {
|
||||
return p.status
|
||||
&& p.subType === "cash"
|
||||
&& p.printType === "cash"
|
||||
&& _.includes(p.printContentType.split(','), 'REFUND_ORDER')
|
||||
&& this.checkPrinterAvailable(p)
|
||||
&& this.isPrintService;
|
||||
});
|
||||
@@ -351,7 +557,7 @@ export const usePrint = defineStore("print", {
|
||||
const printData = {
|
||||
...data,
|
||||
deviceId: printer.id,
|
||||
deviceName: printer.address,
|
||||
deviceName: printer.name,
|
||||
printerName: printer.name,
|
||||
connectionType: printer.connectionType,
|
||||
shop_name: store.shopInfo.shopName,
|
||||
@@ -362,10 +568,17 @@ export const usePrint = defineStore("print", {
|
||||
try {
|
||||
// 区分局域网和USB打印机
|
||||
if (printer.connectionType === "局域网") {
|
||||
ipcRenderer.send('printRefund', JSON.stringify({
|
||||
// ipcRenderer.send('REFUND_ORDER', JSON.stringify({
|
||||
// printerIp: printer.address,
|
||||
// orderData: printData
|
||||
// }));
|
||||
this.addToPrintQueue({
|
||||
taskName: 'REFUND_ORDER',
|
||||
data: JSON.stringify({
|
||||
printerIp: printer.address,
|
||||
orderData: printData
|
||||
}));
|
||||
})
|
||||
})
|
||||
} else {
|
||||
refundPrint(printData);
|
||||
}
|
||||
@@ -377,11 +590,15 @@ export const usePrint = defineStore("print", {
|
||||
},
|
||||
|
||||
// 退菜小票打印
|
||||
printRefundDish(data) {
|
||||
RETURN_ORDER(data) {
|
||||
// 厨房退菜单
|
||||
this.REFUND_KITCHEN(data)
|
||||
|
||||
// 筛选条件:状态启用 + 小票类型 + 打印机可用 + 打印服务正常
|
||||
const validPrinters = this.deviceNoteList.filter(p => {
|
||||
return p.status
|
||||
&& p.subType === "cash"
|
||||
&& p.printType === "cash"
|
||||
&& _.includes(p.printContentType.split(','), 'RETURN_ORDER')
|
||||
&& this.checkPrinterAvailable(p)
|
||||
&& this.isPrintService;
|
||||
});
|
||||
@@ -397,7 +614,7 @@ export const usePrint = defineStore("print", {
|
||||
const printData = {
|
||||
...data,
|
||||
deviceId: printer.id,
|
||||
deviceName: printer.address,
|
||||
deviceName: printer.name,
|
||||
printerName: printer.name,
|
||||
connectionType: printer.connectionType,
|
||||
shop_name: store.shopInfo.shopName,
|
||||
@@ -408,10 +625,17 @@ export const usePrint = defineStore("print", {
|
||||
try {
|
||||
// 区分局域网和USB打印机
|
||||
if (printer.connectionType === "局域网") {
|
||||
ipcRenderer.send('printRefundDish', JSON.stringify({
|
||||
|
||||
const data = JSON.stringify({
|
||||
printerIp: printer.address,
|
||||
orderData: printData
|
||||
}));
|
||||
})
|
||||
|
||||
// 用户退菜单
|
||||
this.addToPrintQueue({
|
||||
taskName: 'RETURN_ORDER',
|
||||
data: data
|
||||
})
|
||||
} else {
|
||||
refundPrint(printData);
|
||||
}
|
||||
@@ -420,6 +644,441 @@ export const usePrint = defineStore("print", {
|
||||
console.error("❌ 退菜小票打印失败:", printer.address, error);
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
// 后厨-退菜单
|
||||
REFUND_KITCHEN(data) {
|
||||
// 筛选条件:状态启用 + 小票类型 + 打印机可用 + 打印服务正常
|
||||
const validPrinters = this.deviceNoteList.filter(p => {
|
||||
return p.status
|
||||
&& p.printType === "cash"
|
||||
&& _.includes(p.printContentType.split(','), 'REFUND_KITCHEN')
|
||||
&& this.checkPrinterAvailable(p)
|
||||
&& this.isPrintService;
|
||||
});
|
||||
|
||||
if (validPrinters.length === 0) {
|
||||
console.log("后厨-退菜单:无符合条件的可用打印机");
|
||||
return;
|
||||
}
|
||||
|
||||
const store = useUser();
|
||||
// 遍历符合条件的打印机打印
|
||||
validPrinters.forEach(printer => {
|
||||
const printData = {
|
||||
...data,
|
||||
deviceId: printer.id,
|
||||
deviceName: printer.name,
|
||||
printerName: printer.name,
|
||||
connectionType: printer.connectionType,
|
||||
shop_name: store.shopInfo.shopName,
|
||||
loginAccount: store.userInfo.name,
|
||||
printTime: dayjs().format("YYYY-MM-DD HH:mm:ss"),
|
||||
};
|
||||
|
||||
try {
|
||||
// 区分局域网和USB打印机
|
||||
if (printer.connectionType === "局域网") {
|
||||
|
||||
const data = JSON.stringify({
|
||||
printerIp: printer.address,
|
||||
orderData: printData
|
||||
})
|
||||
|
||||
// 厨房退菜单
|
||||
this.addToPrintQueue({
|
||||
taskName: 'REFUND_KITCHEN',
|
||||
data: data
|
||||
})
|
||||
} else {
|
||||
refundPrint(printData);
|
||||
}
|
||||
console.log("✅ 后厨-退菜单打印成功:", printer.address);
|
||||
} catch (error) {
|
||||
console.error("❌ 后厨-退菜单打印失败:", printer.address, error);
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
// 商品销售数据
|
||||
PRODUCT_REPORT(data) {
|
||||
// 筛选条件:状态启用 + 小票类型 + 打印机可用 + 打印服务正常
|
||||
const validPrinters = this.deviceNoteList.filter(p => {
|
||||
return p.status
|
||||
&& p.printType === "cash"
|
||||
&& _.includes(p.printContentType.split(','), 'PRODUCT_REPORT')
|
||||
&& this.checkPrinterAvailable(p)
|
||||
&& this.isPrintService;
|
||||
});
|
||||
|
||||
if (validPrinters.length === 0) {
|
||||
console.log("商品销售数据:无符合条件的可用打印机");
|
||||
return;
|
||||
}
|
||||
|
||||
const store = useUser();
|
||||
// 遍历符合条件的打印机打印
|
||||
validPrinters.forEach(printer => {
|
||||
const printData = {
|
||||
deviceId: printer.id,
|
||||
deviceName: printer.name,
|
||||
printerName: printer.name,
|
||||
connectionType: printer.connectionType,
|
||||
shop_name: store.shopInfo.shopName,
|
||||
loginAccount: store.userInfo.name,
|
||||
printTime: dayjs().format("YYYY-MM-DD HH:mm:ss"),
|
||||
};
|
||||
|
||||
try {
|
||||
// 区分局域网和USB打印机
|
||||
if (printer.connectionType === "局域网") {
|
||||
data.forEach(element => {
|
||||
this.addToPrintQueue({
|
||||
taskName: 'PRODUCT_REPORT',
|
||||
data: JSON.stringify({
|
||||
printerIp: printer.address,
|
||||
orderData: {
|
||||
...printData,
|
||||
...element
|
||||
}
|
||||
})
|
||||
});
|
||||
});
|
||||
}
|
||||
// else {
|
||||
// refundPrint(printData);
|
||||
// }
|
||||
console.log("✅ 商品销售数据打印成功:", printer.address);
|
||||
} catch (error) {
|
||||
console.error("❌ 商品销售数据打印失败:", printer.address, error);
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
// 经营日报
|
||||
DAY_REPORT(data) {
|
||||
console.log('print.DAY_REPORT', data);
|
||||
|
||||
// 筛选条件:状态启用 + 小票类型 + 打印机可用 + 打印服务正常
|
||||
const validPrinters = this.deviceNoteList.filter(p => {
|
||||
return p.status
|
||||
&& p.printType === "cash"
|
||||
&& _.includes(p.printContentType.split(','), 'DAY_REPORT')
|
||||
&& this.checkPrinterAvailable(p)
|
||||
&& this.isPrintService;
|
||||
});
|
||||
|
||||
if (validPrinters.length === 0) {
|
||||
console.log("经营日报:无符合条件的可用打印机");
|
||||
return;
|
||||
}
|
||||
|
||||
const store = useUser();
|
||||
// 遍历符合条件的打印机打印
|
||||
validPrinters.forEach(printer => {
|
||||
const printData = {
|
||||
deviceId: printer.id,
|
||||
deviceName: printer.name,
|
||||
printerName: printer.name,
|
||||
connectionType: printer.connectionType,
|
||||
shop_name: store.shopInfo.shopName,
|
||||
loginAccount: store.userInfo.name,
|
||||
printTime: dayjs().format("YYYY-MM-DD HH:mm:ss"),
|
||||
};
|
||||
|
||||
try {
|
||||
// 区分局域网和USB打印机
|
||||
if (printer.connectionType === "局域网") {
|
||||
data.forEach(element => {
|
||||
this.addToPrintQueue({
|
||||
taskName: 'DAY_REPORT',
|
||||
data: JSON.stringify({
|
||||
printerIp: printer.address,
|
||||
orderData: {
|
||||
...printData,
|
||||
...element
|
||||
}
|
||||
})
|
||||
});
|
||||
});
|
||||
}
|
||||
// else {
|
||||
// refundPrint(printData);
|
||||
// }
|
||||
console.log("✅ 经营日报打印成功:", printer.address);
|
||||
} catch (error) {
|
||||
console.error("❌ 经营日报打印失败:", printer.address, error);
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
// 日结单
|
||||
DAY_ORDER(data) {
|
||||
// 筛选条件:状态启用 + 小票类型 + 打印机可用 + 打印服务正常
|
||||
const validPrinters = this.deviceNoteList.filter(p => {
|
||||
return p.status
|
||||
&& p.printType === "cash"
|
||||
&& _.includes(p.printContentType.split(','), 'DAY_ORDER')
|
||||
&& this.checkPrinterAvailable(p)
|
||||
&& this.isPrintService;
|
||||
});
|
||||
|
||||
if (validPrinters.length === 0) {
|
||||
console.log("日结单:无符合条件的可用打印机");
|
||||
return;
|
||||
}
|
||||
|
||||
const store = useUser();
|
||||
// 遍历符合条件的打印机打印
|
||||
validPrinters.forEach(printer => {
|
||||
const printData = {
|
||||
deviceId: printer.id,
|
||||
deviceName: printer.name,
|
||||
printerName: printer.name,
|
||||
connectionType: printer.connectionType,
|
||||
shop_name: store.shopInfo.shopName,
|
||||
loginAccount: store.userInfo.name,
|
||||
printTime: dayjs().format("YYYY-MM-DD HH:mm:ss"),
|
||||
};
|
||||
|
||||
try {
|
||||
// 区分局域网和USB打印机
|
||||
if (printer.connectionType === "局域网") {
|
||||
data.forEach(element => {
|
||||
this.addToPrintQueue({
|
||||
taskName: 'DAY_ORDER',
|
||||
data: JSON.stringify({
|
||||
printerIp: printer.address,
|
||||
orderData: {
|
||||
...printData,
|
||||
...element
|
||||
}
|
||||
})
|
||||
});
|
||||
});
|
||||
}
|
||||
// else {
|
||||
// refundPrint(printData);
|
||||
// }
|
||||
console.log("✅ 日结单打印成功:", printer.address);
|
||||
} catch (error) {
|
||||
console.error("❌ 日结单打印失败:", printer.address, error);
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
// 储值单
|
||||
RECHARGE(data) {
|
||||
// 筛选条件:状态启用 + 小票类型 + 打印机可用 + 打印服务正常
|
||||
const validPrinters = this.deviceNoteList.filter(p => {
|
||||
return p.status
|
||||
&& p.printType === "cash"
|
||||
&& _.includes(p.printContentType.split(','), 'RECHARGE')
|
||||
&& this.checkPrinterAvailable(p)
|
||||
&& this.isPrintService;
|
||||
});
|
||||
|
||||
if (validPrinters.length === 0) {
|
||||
console.log("储值单:无符合条件的可用打印机");
|
||||
return;
|
||||
}
|
||||
|
||||
const store = useUser();
|
||||
// 遍历符合条件的打印机打印
|
||||
validPrinters.forEach(printer => {
|
||||
const printData = {
|
||||
...data,
|
||||
deviceId: printer.id,
|
||||
deviceName: printer.name,
|
||||
printerName: printer.name,
|
||||
connectionType: printer.connectionType,
|
||||
shop_name: store.shopInfo.shopName,
|
||||
loginAccount: store.userInfo.name,
|
||||
printTime: dayjs().format("YYYY-MM-DD HH:mm:ss"),
|
||||
};
|
||||
|
||||
try {
|
||||
// 区分局域网和USB打印机
|
||||
if (printer.connectionType === "局域网") {
|
||||
this.addToPrintQueue({
|
||||
taskName: 'RECHARGE',
|
||||
data: JSON.stringify({
|
||||
printerIp: printer.address,
|
||||
orderData: printData
|
||||
})
|
||||
});
|
||||
} else {
|
||||
refundPrint(printData);
|
||||
}
|
||||
console.log("✅ 储值单打印成功:", printer.address);
|
||||
} catch (error) {
|
||||
console.error("❌ 储值单打印失败:", printer.address, error);
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
|
||||
// 出入库单
|
||||
STOCK(data) {
|
||||
// 筛选条件:状态启用 + 小票类型 + 打印机可用 + 打印服务正常
|
||||
const validPrinters = this.deviceNoteList.filter(p => {
|
||||
return p.status
|
||||
&& p.printType === "cash"
|
||||
&& _.includes(p.printContentType.split(','), 'STOCK')
|
||||
&& this.checkPrinterAvailable(p)
|
||||
&& this.isPrintService;
|
||||
});
|
||||
|
||||
if (validPrinters.length === 0) {
|
||||
console.log("储值单:无符合条件的可用打印机");
|
||||
return;
|
||||
}
|
||||
|
||||
const store = useUser();
|
||||
// 遍历符合条件的打印机打印
|
||||
validPrinters.forEach(printer => {
|
||||
const printData = {
|
||||
...data,
|
||||
deviceId: printer.id,
|
||||
deviceName: printer.name,
|
||||
printerName: printer.name,
|
||||
connectionType: printer.connectionType,
|
||||
shop_name: store.shopInfo.shopName,
|
||||
loginAccount: store.userInfo.name,
|
||||
printTime: dayjs().format("YYYY-MM-DD HH:mm:ss"),
|
||||
};
|
||||
|
||||
try {
|
||||
// 区分局域网和USB打印机
|
||||
if (printer.connectionType === "局域网") {
|
||||
// ipcRenderer.send('STOCK', JSON.stringify({
|
||||
// printerIp: printer.address,
|
||||
// orderData: printData
|
||||
// }));
|
||||
this.addToPrintQueue({
|
||||
taskName: 'STOCK',
|
||||
data: JSON.stringify({
|
||||
printerIp: printer.address,
|
||||
orderData: printData
|
||||
})
|
||||
});
|
||||
} else {
|
||||
refundPrint(printData);
|
||||
}
|
||||
console.log("✅ 出入库单打印成功:", printer.address);
|
||||
} catch (error) {
|
||||
console.error("❌ 出入库单打印失败:", printer.address, error);
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
|
||||
// 盘点单
|
||||
STOCK_CHECK(data) {
|
||||
// 筛选条件:状态启用 + 小票类型 + 打印机可用 + 打印服务正常
|
||||
const validPrinters = this.deviceNoteList.filter(p => {
|
||||
return p.status
|
||||
&& p.printType === "cash"
|
||||
&& _.includes(p.printContentType.split(','), 'STOCK_CHECK')
|
||||
&& this.checkPrinterAvailable(p)
|
||||
&& this.isPrintService;
|
||||
});
|
||||
|
||||
if (validPrinters.length === 0) {
|
||||
console.log("盘点单:无符合条件的可用打印机");
|
||||
return;
|
||||
}
|
||||
|
||||
const store = useUser();
|
||||
// 遍历符合条件的打印机打印
|
||||
validPrinters.forEach(printer => {
|
||||
const printData = {
|
||||
...data,
|
||||
deviceId: printer.id,
|
||||
deviceName: printer.name,
|
||||
printerName: printer.name,
|
||||
connectionType: printer.connectionType,
|
||||
shop_name: store.shopInfo.shopName,
|
||||
loginAccount: store.userInfo.name,
|
||||
printTime: dayjs().format("YYYY-MM-DD HH:mm:ss"),
|
||||
};
|
||||
|
||||
try {
|
||||
// 区分局域网和USB打印机
|
||||
if (printer.connectionType === "局域网") {
|
||||
// ipcRenderer.send('STOCK_CHECK', JSON.stringify({
|
||||
// printerIp: printer.address,
|
||||
// orderData: printData
|
||||
// }));
|
||||
this.addToPrintQueue({
|
||||
taskName: 'STOCK_CHECK',
|
||||
data: JSON.stringify({
|
||||
printerIp: printer.address,
|
||||
orderData: printData
|
||||
})
|
||||
});
|
||||
} else {
|
||||
refundPrint(printData);
|
||||
}
|
||||
console.log("✅ 盘点单打印成功:", printer.address);
|
||||
} catch (error) {
|
||||
console.error("❌ 盘点单打印失败:", printer.address, error);
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
// 排队取号
|
||||
CALL(data) {
|
||||
// 筛选条件:状态启用 + 小票类型 + 打印机可用 + 打印服务正常
|
||||
const validPrinters = this.deviceNoteList.filter(p => {
|
||||
return p.status
|
||||
&& p.printType === "cash"
|
||||
&& _.includes(p.printContentType.split(','), 'CALL')
|
||||
&& this.checkPrinterAvailable(p)
|
||||
&& this.isPrintService;
|
||||
});
|
||||
|
||||
if (validPrinters.length === 0) {
|
||||
console.log("排队取号:无符合条件的可用打印机");
|
||||
return;
|
||||
}
|
||||
|
||||
const store = useUser();
|
||||
// 遍历符合条件的打印机打印
|
||||
validPrinters.forEach(printer => {
|
||||
const printData = {
|
||||
...data,
|
||||
deviceId: printer.id,
|
||||
deviceName: printer.name,
|
||||
printerName: printer.name,
|
||||
connectionType: printer.connectionType,
|
||||
shop_name: store.shopInfo.shopName,
|
||||
loginAccount: store.userInfo.name,
|
||||
printTime: dayjs().format("YYYY-MM-DD HH:mm:ss"),
|
||||
};
|
||||
|
||||
try {
|
||||
// 区分局域网和USB打印机
|
||||
if (printer.connectionType === "局域网") {
|
||||
// ipcRenderer.send('CALL', JSON.stringify({
|
||||
// printerIp: printer.address,
|
||||
// orderData: printData
|
||||
// }));
|
||||
this.addToPrintQueue({
|
||||
taskName: 'CALL',
|
||||
data: JSON.stringify({
|
||||
printerIp: printer.address,
|
||||
orderData: printData
|
||||
})
|
||||
});
|
||||
} else {
|
||||
refundPrint(printData);
|
||||
}
|
||||
console.log("✅ 排队取号打印成功:", printer.address);
|
||||
} catch (error) {
|
||||
console.error("❌ 排队取号打印失败:", printer.address, error);
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
});
|
||||
@@ -7,6 +7,7 @@ import ReconnectingWebSocket from "reconnecting-websocket";
|
||||
import { useGoods } from "@/store/goods.js";
|
||||
import { ElMessage } from "element-plus";
|
||||
import { getOrderByIdAjax, commOrderPrintData } from "@/utils/index.js";
|
||||
import { printData } from '@/api/print.js'
|
||||
|
||||
export const useSocket = defineStore("socket", {
|
||||
state: () => ({
|
||||
@@ -17,8 +18,236 @@ export const useSocket = defineStore("socket", {
|
||||
orderListTimer: null,
|
||||
log: false,
|
||||
isPrinting: false,
|
||||
// 新增:其他打印任务队列与状态锁
|
||||
printQueue: [],
|
||||
isProcessing: false
|
||||
}),
|
||||
actions: {
|
||||
// 计算订单中所有菜品的总价总和
|
||||
calcAllCartsTotalSum(cartObj) {
|
||||
// 初始化总和为0
|
||||
let totalSum = 0;
|
||||
// 遍历原始对象的所有键(0、1、2...)
|
||||
Object.keys(cartObj).forEach(key => {
|
||||
const carts = cartObj[key] || [];
|
||||
// 累加当前分类下的菜品总价(num × unitPrice)
|
||||
carts.forEach(item => {
|
||||
const num = Number(item.num) - Number(item.returnNum) || 0; // 防错:非数字转0
|
||||
const unitPrice = Number(item.unitPrice) || 0;
|
||||
totalSum += num * unitPrice;
|
||||
});
|
||||
});
|
||||
return totalSum; // 返回所有菜品的总价总和
|
||||
},
|
||||
// 1. 添加任务到队列
|
||||
addToPrintQueue(task) {
|
||||
this.printQueue.push(task);
|
||||
if (this.log) console.log('任务已加入打印队列,当前队列长度:', this.printQueue.length);
|
||||
this.processPrintQueue(); // 尝试启动处理
|
||||
},
|
||||
// 2. 处理队列(递归执行)
|
||||
async processPrintQueue() {
|
||||
const printStore = usePrint();
|
||||
|
||||
// 如果正在处理或队列为空,直接返回
|
||||
if (this.isProcessing || this.printQueue.length === 0) return;
|
||||
|
||||
this.isProcessing = true;
|
||||
const currentTask = this.printQueue[0]; // 取出第一个任务
|
||||
|
||||
try {
|
||||
if (this.log) console.log('开始执行打印任务:', currentTask);
|
||||
|
||||
const isOrderPrint = ['GUEST_ORDER', 'PRE_ORDER', 'ORDER', 'RETURN_ORDER', 'REFUND_ORDER', 'ALL_KITCHEN', 'ONLY_KITCHEN', 'REFUND_KITCHEN',]
|
||||
|
||||
console.log('currentTask===', currentTask);
|
||||
|
||||
if (_.includes(isOrderPrint, currentTask.printType)) {
|
||||
// 订单相关打印,调用对应接口获取数据
|
||||
const data = await getOrderByIdAjax(currentTask.orderId);
|
||||
|
||||
console.log('订单相关打印,调用对应接口获取数据===', data);
|
||||
|
||||
switch (currentTask.printType) {
|
||||
case 'ORDER':
|
||||
// 打印订单小票
|
||||
printStore.ORDER(commOrderPrintData(data));
|
||||
// 打印标签小票
|
||||
printStore.labelPrint(commOrderPrintData(data));
|
||||
break;
|
||||
case 'PRE_ORDER':
|
||||
// 打印预订单小票
|
||||
data.originAmount = this.calcAllCartsTotalSum(data.detailMap)
|
||||
|
||||
if (data.seatAmount > 0 && data.dineMode == 'dine-in') {
|
||||
data.originAmount += data.seatAmount
|
||||
}
|
||||
let packFee = 0
|
||||
|
||||
data.cartList.forEach(item => {
|
||||
if (item.packNumber > 0 && (item.num - item.returnNum) >= item.packNumber) {
|
||||
packFee += (item.num - item.returnNum) * item.packAmount
|
||||
}
|
||||
})
|
||||
|
||||
if (packFee > 0) {
|
||||
data.originAmount += packFee
|
||||
data.packFee = packFee
|
||||
}
|
||||
|
||||
printStore.PRE_ORDER(commOrderPrintData({ ...data, isBefore: true }));
|
||||
break;
|
||||
case 'GUEST_ORDER':
|
||||
// 打印客看单
|
||||
data.detailMap = _.at(data.detailMap, data.placeNum);
|
||||
|
||||
let amout = 0
|
||||
data.detailMap.flat().forEach(item => {
|
||||
amout += item.num * item.unitPrice
|
||||
});
|
||||
|
||||
data.originAmount = amout
|
||||
|
||||
if (data.placeNum == 1 && data.dineMode == 'dine-in') {
|
||||
data.originAmount += data.seatAmount
|
||||
}
|
||||
|
||||
if (data.packFee > 0) {
|
||||
data.originAmount += data.packFee
|
||||
}
|
||||
|
||||
printStore.GUEST_ORDER(commOrderPrintData({ ...data, isGuest: true, isBefore: false }));
|
||||
break;
|
||||
case 'ALL_KITCHEN':
|
||||
// 打印整单厨房票
|
||||
if (data.payMode == 'after-pay') {
|
||||
// 后付费订单,只打印当前下单商品的整单厨房票
|
||||
data.detailMap = _.at(data.detailMap, data.placeNum);
|
||||
printStore.ALL_KITCHEN(commOrderPrintData({ ...data, isGuest: true, isNotPrint: true }));
|
||||
} else {
|
||||
printStore.ALL_KITCHEN(commOrderPrintData({ ...data, isNotPrint: true }));
|
||||
}
|
||||
// console.log('打印整单厨房票.data', data);
|
||||
break;
|
||||
case 'ONLY_KITCHEN':
|
||||
// 打印一菜一品厨房票
|
||||
if (data.payMode == 'after-pay') {
|
||||
// 后付费订单,只打印当前下单的一菜一品厨房票
|
||||
data.detailMap = _.at(data.detailMap, data.placeNum);
|
||||
const orderInfo = commOrderPrintData({ ...data, isGuest: true, isNotPrint: true });
|
||||
orderInfo.carts.forEach(item => {
|
||||
const ONLY_KITCHEN_DATA = {
|
||||
...orderInfo,
|
||||
carts: [item]
|
||||
}
|
||||
printStore.ONLY_KITCHEN(ONLY_KITCHEN_DATA);
|
||||
})
|
||||
} else {
|
||||
data.cartList.forEach(item => {
|
||||
const ONLY_KITCHEN_DATA = {
|
||||
...data.orderData,
|
||||
cartList: [item],
|
||||
isNotPrint: true
|
||||
}
|
||||
printStore.ONLY_KITCHEN(commOrderPrintData(ONLY_KITCHEN_DATA));
|
||||
})
|
||||
}
|
||||
break;
|
||||
case 'RETURN_ORDER':
|
||||
// 打印退菜小票
|
||||
const socketData = JSON.parse(currentTask.data);
|
||||
// console.log('打印退菜小票.socketData', socketData);
|
||||
|
||||
let cartList = _.compact(
|
||||
_.map(data.cartList, (cartItem) => {
|
||||
// 找到对应项
|
||||
const taskItem = _.find(socketData, (t) => cartItem.id == t.id);
|
||||
|
||||
// 找到就返回带 num 的对象
|
||||
if (taskItem) {
|
||||
return {
|
||||
...cartItem,
|
||||
num: taskItem.num,
|
||||
returnNum: 0,
|
||||
payAmount: taskItem.num * cartItem.price
|
||||
};
|
||||
}
|
||||
|
||||
// 没找到返回 undefined,会被 _.compact 过滤掉
|
||||
return null;
|
||||
})
|
||||
);
|
||||
|
||||
data.cartList = cartList;
|
||||
|
||||
// console.log('打印退菜小票.data', data);
|
||||
|
||||
printStore.RETURN_ORDER(commOrderPrintData({ ...data, isRefundDish: true }));
|
||||
break;
|
||||
case 'REFUND_ORDER':
|
||||
// 打印退单小票
|
||||
{
|
||||
const socketData = JSON.parse(currentTask.data);
|
||||
// console.log('打印退菜小票.socketData', socketData);
|
||||
|
||||
let cartList = _.compact(
|
||||
_.map(data.cartList, (cartItem) => {
|
||||
// 找到对应项
|
||||
const taskItem = _.find(socketData, (t) => cartItem.id == t.id);
|
||||
|
||||
// 找到就返回带 num 的对象
|
||||
if (taskItem) {
|
||||
return {
|
||||
...cartItem,
|
||||
num: taskItem.num,
|
||||
returnNum: 0,
|
||||
payAmount: taskItem.num * cartItem.price
|
||||
};
|
||||
}
|
||||
|
||||
// 没找到返回 undefined,会被 _.compact 过滤掉
|
||||
return null;
|
||||
})
|
||||
);
|
||||
|
||||
data.cartList = cartList;
|
||||
data.payAmount = currentTask.amount;
|
||||
// console.log('打印退单小票.data', data);
|
||||
|
||||
printStore.REFUND_ORDER(commOrderPrintData({ ...data, isRefundDish: true }));
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
// 执行打印逻辑(参考你注释中的代码)
|
||||
const res = await printData({
|
||||
shopId: currentTask.shopId,
|
||||
dataId: currentTask.dataId,
|
||||
type: currentTask.printType
|
||||
});
|
||||
|
||||
console.log('printData.res===', res);
|
||||
|
||||
if (printStore[currentTask.printType]) {
|
||||
printStore[currentTask.printType](JSON.parse(res.data));
|
||||
}
|
||||
}
|
||||
if (this.log) console.log('任务执行成功');
|
||||
} catch (error) {
|
||||
console.error('打印任务执行失败:', error);
|
||||
// 失败时不移除任务,或者根据业务决定是否重试/丢弃
|
||||
} finally {
|
||||
// 无论成功失败,移除当前任务
|
||||
this.printQueue.shift();
|
||||
if (this.log) console.log('任务移除,剩余队列:', this.printQueue.length);
|
||||
|
||||
// 标记为空闲,尝试处理下一个
|
||||
this.isProcessing = false;
|
||||
this.processPrintQueue();
|
||||
}
|
||||
},
|
||||
// 关闭ws
|
||||
close() {
|
||||
if (this.log) console.log("关闭ws");
|
||||
@@ -219,10 +448,14 @@ export const useSocket = defineStore("socket", {
|
||||
}
|
||||
}
|
||||
} else if (data.data_type == "order") {
|
||||
this.addToPrintQueue(JSON.parse(data.data));
|
||||
return;
|
||||
|
||||
goodsStore.successClearCart();
|
||||
goodsStore.historyOrderAjax(data.data.table_code);
|
||||
this.cartInit();
|
||||
|
||||
this.addToPrintQueue(data.data);
|
||||
|
||||
// 收到订单消息,打印订单小票
|
||||
let orderInfo = data.data.split("_");
|
||||
@@ -277,6 +510,12 @@ export const useSocket = defineStore("socket", {
|
||||
} else if (data.data_type == "product_update") {
|
||||
// 商品更新
|
||||
this.updateGoods();
|
||||
} else if (data.data_type == 'other_print') {
|
||||
// 其他打印集合 data.data = {"shopId":148,"dataId":27,"printType":"STOCK"}
|
||||
// 用const res = printData({ shopId: shopId, dataId: dataId, type: printType })
|
||||
// 获取到数据后调用goodsStore[data.data.printType](JSON.parse(res.data))
|
||||
console.log('other_print===', data.data);
|
||||
this.addToPrintQueue(data.data);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -195,12 +195,13 @@ export function commOrderPrintData(orderInfo) {
|
||||
categoryId: item.categoryId,
|
||||
name: item.isGift === 1 ? `[赠]${item.productName}` : item.productName,
|
||||
number: item.num - item.returnNum,
|
||||
skuName: item.skuName,
|
||||
skuName: item.skuName || '',
|
||||
salePrice: formatDecimal(+price),
|
||||
totalAmount: formatDecimal(+item.payAmount),
|
||||
proGroupInfo: item.proGroupInfo
|
||||
? item.proGroupInfo.map((item) => item.goods).flat()
|
||||
: "",
|
||||
remark: item.remark
|
||||
});
|
||||
});
|
||||
} else {
|
||||
@@ -215,18 +216,19 @@ export function commOrderPrintData(orderInfo) {
|
||||
categoryId: item.categoryId,
|
||||
name: item.isGift === 1 ? `[赠]${item.productName}` : item.productName,
|
||||
number: item.num - item.returnNum,
|
||||
skuName: item.skuName,
|
||||
skuName: item.skuName || '',
|
||||
salePrice: formatDecimal(+price),
|
||||
totalAmount: formatDecimal((item.num - item.returnNum) * price),
|
||||
proGroupInfo: item.proGroupInfo
|
||||
? item.proGroupInfo.map((item) => item.goods).flat()
|
||||
: "",
|
||||
remark: item.remark || ''
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
if (orderInfo.dineMode == 'dine-in') {
|
||||
if (orderInfo.seatAmount > 0 && orderInfo.isGuest && orderInfo.placeNum == 1 && !orderInfo.isRefundDish) {
|
||||
if (orderInfo.seatAmount > 0 && orderInfo.isGuest && orderInfo.placeNum == 1 && !orderInfo.isRefundDish && !orderInfo.isNotPrint) {
|
||||
data.carts.push({
|
||||
categoryId: '',
|
||||
name: '餐位费',
|
||||
@@ -235,10 +237,11 @@ export function commOrderPrintData(orderInfo) {
|
||||
salePrice: formatDecimal(orderInfo.seatAmount / orderInfo.seatNum),
|
||||
totalAmount: orderInfo.seatAmount,
|
||||
proGroupInfo: "",
|
||||
remark: ''
|
||||
})
|
||||
}
|
||||
|
||||
if (orderInfo.seatAmount > 0 && !orderInfo.isGuest && !orderInfo.isRefundDish) {
|
||||
if (orderInfo.seatAmount > 0 && !orderInfo.isGuest && !orderInfo.isRefundDish && !orderInfo.isNotPrint) {
|
||||
data.carts.push({
|
||||
categoryId: '',
|
||||
name: '餐位费',
|
||||
@@ -247,11 +250,12 @@ export function commOrderPrintData(orderInfo) {
|
||||
salePrice: formatDecimal(orderInfo.seatAmount / orderInfo.seatNum),
|
||||
totalAmount: orderInfo.seatAmount,
|
||||
proGroupInfo: "",
|
||||
remark: ''
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
if (orderInfo.packFee > 0 && !orderInfo.isRefundDish) {
|
||||
if (orderInfo.packFee > 0 && !orderInfo.isRefundDish && !orderInfo.isNotPrint) {
|
||||
let packNum = 0;
|
||||
orderInfo.cartList.forEach(item => {
|
||||
packNum += item.packNumber
|
||||
@@ -264,10 +268,11 @@ export function commOrderPrintData(orderInfo) {
|
||||
salePrice: '',
|
||||
totalAmount: formatDecimal(orderInfo.packFee),
|
||||
proGroupInfo: "",
|
||||
remark: ''
|
||||
})
|
||||
}
|
||||
|
||||
console.log('最终组合打印数据===', data);
|
||||
// console.log('最终组合打印数据===', data);
|
||||
return data;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,3 +0,0 @@
|
||||
<template>
|
||||
收银
|
||||
</template>
|
||||
@@ -8,12 +8,12 @@
|
||||
</div>
|
||||
<div class="d_content">
|
||||
<div class="d_list">
|
||||
<el-form :model="form" label-position="left" label-width="60%">
|
||||
<el-form-item label="设备名称">
|
||||
<el-form ref="formRef" :model="form" :rules="rules" label-position="left" label-width="60%">
|
||||
<el-form-item label="设备名称" prop="name">
|
||||
<el-input v-model="form.name" placeholder="请输入设备名称"></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item label="设备类型">
|
||||
<el-radio-group v-model="form.connectionType">
|
||||
<el-radio-group v-model="form.connectionType" @change="connectionTypeChange">
|
||||
<el-radio-button label="USB" value="USB"></el-radio-button>
|
||||
<el-radio-button label="局域网" value="局域网"></el-radio-button>
|
||||
</el-radio-group>
|
||||
@@ -23,33 +23,43 @@
|
||||
</el-form-item> -->
|
||||
<el-form-item label="设备尺寸">
|
||||
<el-select v-model="form.receiptSize">
|
||||
<el-option label="58mm" value="58mm"></el-option>
|
||||
<el-option label="80mm" value="80mm"></el-option>
|
||||
<el-option label="58mm" value="58mm" v-if="form.connectionType === 'USB'"></el-option>
|
||||
<el-option label="80mm" value="80mm" v-if="form.connectionType === '局域网'"></el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="选择设备" v-if="form.connectionType === 'USB'">
|
||||
<el-form-item label="选择设备" prop="address" v-if="form.connectionType === 'USB'">
|
||||
<el-select v-model="form.address">
|
||||
<el-option :label="item.name" :value="item.name" v-for="item in printList" :key="item.name"></el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="设备IP" v-if="form.connectionType === '局域网'">
|
||||
<el-form-item label="设备IP" prop="address" v-if="form.connectionType === '局域网'">
|
||||
<el-input v-model="form.address" placeholder="请输入设备IP地址"></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item label="商品分类">
|
||||
<div style="cursor: pointer" @click="classifyRef.show()">
|
||||
<el-form-item label="商品分类" prop="classifyPrint" v-if="form.connectionType === '局域网'">
|
||||
<div class="column">
|
||||
<el-radio-group v-model="form.classifyPrint" @change="form.categoryList = []; form.categoryIds = ''">
|
||||
<el-radio-button label="全部" value="0"></el-radio-button>
|
||||
<el-radio-button label="部分(仅后厨)" value="1"
|
||||
:disabled="printTypeList[1].values.length == 0"></el-radio-button>
|
||||
</el-radio-group>
|
||||
<div style="cursor: pointer" @click="classifyRef.show()" v-if="form.classifyPrint == '1'">
|
||||
<span style="color: #409eff" v-if="form.categoryList.length">
|
||||
{{form.categoryList.map(item => item.name).join(',')}}
|
||||
</span>
|
||||
<span style="color: #e65d6e" v-else>
|
||||
请选择分类
|
||||
</span>
|
||||
<el-button type="primary" v-else style="margin-top: 10px;">选择商品分类</el-button>
|
||||
</div>
|
||||
</div>
|
||||
</el-form-item>
|
||||
<el-form-item label="是否打印交班小票">
|
||||
<el-radio-group v-model="form.handoverSwitch">
|
||||
<el-radio-button label="否" :value="0"></el-radio-button>
|
||||
<el-radio-button label="是" :value="1"></el-radio-button>
|
||||
</el-radio-group>
|
||||
<el-form-item label="打印类型" v-if="form.connectionType === '局域网'">
|
||||
<div class="row" v-for="(item, index) in printTypeList" :key="index">
|
||||
<div class="title">{{ item.label }}</div>
|
||||
<div class="cont">
|
||||
<el-checkbox-group v-model="item.values" @change="printTypeChange($event, index)">
|
||||
<el-checkbox :label="item.label" :value="item.value" v-for="item in item.list"
|
||||
:key="item.value"></el-checkbox>
|
||||
</el-checkbox-group>
|
||||
</div>
|
||||
</div>
|
||||
</el-form-item>
|
||||
<!-- <el-form-item label="打印份数">
|
||||
<el-select v-model="form.printQty">
|
||||
@@ -95,12 +105,15 @@
|
||||
<div class="row">收银员:{{ printData.loginAccount }}</div>
|
||||
<div class="line"></div>
|
||||
<table class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
<td>品名</td>
|
||||
<td>单价</td>
|
||||
<td>数量</td>
|
||||
<td>小计</td>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr v-for="(item, index) in printData.carts" :key="index">
|
||||
<td>
|
||||
<div>{{ item.name }}</div>
|
||||
@@ -110,6 +123,7 @@
|
||||
<td>{{ item.number }}</td>
|
||||
<td>{{ item.totalAmount }}</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<div class="line"></div>
|
||||
<div class="row between">
|
||||
@@ -144,10 +158,11 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<classify ref="classifyRef" @success="(e) => (form.categoryList = e)" />
|
||||
<classify ref="classifyRef" @success="classifyChange" />
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import _ from 'lodash'
|
||||
import dayjs from "dayjs";
|
||||
import { ipcRenderer } from "electron";
|
||||
import { onMounted, reactive, ref } from "vue";
|
||||
@@ -158,6 +173,7 @@ import { usePrint } from "@/store/print.js";
|
||||
import { printerAdd, printerDetail } from "@/api/account.js";
|
||||
import classify from "@/components/classify/index.vue";
|
||||
import { useGoods } from '@/store/goods.js'
|
||||
import receiptPrint from "@/components/lodop/receiptPrint.js";
|
||||
const goodsStore = useGoods()
|
||||
|
||||
const classifyRef = ref(null);
|
||||
@@ -172,26 +188,122 @@ const printList = ref([]);
|
||||
const feets = ref([0, 1, 2, 3, 4, 5, 8]);
|
||||
const loading = ref(false);
|
||||
const requestLoading = ref(false);
|
||||
const printTypeList = ref([
|
||||
{
|
||||
label: '前台',
|
||||
values: [],
|
||||
list: [
|
||||
{ label: '客看单', value: 'GUEST_ORDER' },
|
||||
{ label: '预结算单', value: 'PRE_ORDER' },
|
||||
{ label: '结算单', value: 'ORDER' },
|
||||
{ label: '退菜单', value: 'RETURN_ORDER' },
|
||||
{ label: '退款单', value: 'REFUND_ORDER' },
|
||||
]
|
||||
},
|
||||
{
|
||||
label: '后厨',
|
||||
values: [],
|
||||
list: [
|
||||
{ label: '后厨-整单', value: 'ALL_KITCHEN' },
|
||||
{ label: '后厨-分单', value: 'ONLY_KITCHEN' },
|
||||
{ label: '后厨-退菜单', value: 'REFUND_KITCHEN' },
|
||||
]
|
||||
},
|
||||
{
|
||||
label: '其它',
|
||||
values: [],
|
||||
list: [
|
||||
{ label: '交班单', value: 'HANDOVER' },
|
||||
{ label: '排队取号', value: 'CALL' },
|
||||
{ label: '储值单', value: 'RECHARGE' },
|
||||
{ label: '出入库单', value: 'STOCK' },
|
||||
{ label: '盘点单', value: 'STOCK_CHECK' },
|
||||
{ label: '商品报表', value: 'PRODUCT_REPORT' },
|
||||
{ label: '经营日报', value: 'DAY_REPORT' },
|
||||
{ label: '日结单', value: 'DAY_ORDER' },
|
||||
]
|
||||
}
|
||||
])
|
||||
|
||||
// 切换打印机类型
|
||||
function connectionTypeChange(e) {
|
||||
form.value.address = ''
|
||||
form.value.receiptSize = ''
|
||||
form.value.classifyPrint = '0'
|
||||
if (e == 'USB') {
|
||||
form.value.receiptSize = '58mm'
|
||||
} else {
|
||||
form.value.printContentType = ''
|
||||
form.value.receiptSize = '80mm'
|
||||
form.value.printContentType = ''
|
||||
printTypeList.value.forEach(el => {
|
||||
el.values = []
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
const categoryIdsType = ref('all') // all=全部 custom=部分
|
||||
|
||||
const form = ref({
|
||||
id: "",
|
||||
name: '', // 设备名称
|
||||
connectionType: 'USB', // 现在打印机支持USB 和 网络、蓝牙、局域网
|
||||
address: '', // 打印机名称
|
||||
port: '', // 端口
|
||||
subType: 'cash', // 打印类型(分类)label标签cash小票kitchen出品
|
||||
printType: 'cash', // 打印类型(分类)label标签cash小票kitchen出品
|
||||
contentType: '', // 打印机品牌
|
||||
categoryIds: [], // 打印分类Id
|
||||
categoryIds: '', // 打印分类Id
|
||||
categoryList: [], // 分类
|
||||
sort: '',
|
||||
receiptSize: '58mm', // 小票尺寸 58mm 80mm
|
||||
classifyPrint: 1, // 分类打印 0-所有 1-部分分类 2-部分商品
|
||||
printQty: '', // 打印数量 c1m1^2 = 顾客+商家[2张] m1^1 = 商家[1张] c1^1顾客[1张] c2m1^3顾客2+商家1[3张]
|
||||
printMethod: 'all', // 打印方式 all-全部打印 normal-仅打印结账单「前台」one-仅打印制作单「厨房」queue-仅打印排队取号
|
||||
printType: [], // 打印类型,JSON数组 refund-确认退款单 handover-交班单 queue-排队取号
|
||||
receiptSize: '', // 小票尺寸 58mm 80mm
|
||||
classifyPrint: '0', // 分类打印 0-所有 1-部分分类 2-部分商品
|
||||
printNum: '', // 打印数量 c1m1^2 = 顾客+商家[2张] m1^1 = 商家[1张] c1^1顾客[1张] c2m1^3顾客2+商家1[3张]
|
||||
kitchenPrintMode: 'all', // 打印方式 all-全部打印 normal-仅打印结账单「前台」one-仅打印制作单「厨房」queue-仅打印排队取号
|
||||
printContentType: '',
|
||||
status: 1,
|
||||
handoverSwitch: 0, // 交班单开关 0-关闭 1-开启
|
||||
});
|
||||
|
||||
const rules = ref({
|
||||
name: [
|
||||
{
|
||||
required: true,
|
||||
message: '请输入设备名称',
|
||||
trigger: 'blur'
|
||||
}
|
||||
],
|
||||
address: [
|
||||
{
|
||||
required: true,
|
||||
validator: (rule, value, callback) => {
|
||||
if (form.value.connectionType == 'USB') {
|
||||
if (form.value.address == '') {
|
||||
callback(new Error('请选择设备'))
|
||||
}
|
||||
callback()
|
||||
} else {
|
||||
if (form.value.address == '') {
|
||||
callback(new Error('请输入设备IP'))
|
||||
}
|
||||
callback()
|
||||
}
|
||||
},
|
||||
trigger: 'change'
|
||||
}
|
||||
],
|
||||
classifyPrint: [
|
||||
{
|
||||
required: false,
|
||||
validator: (rule, value, callback) => {
|
||||
if (form.value.classifyPrint == '1' && form.value.categoryList.length == '0') {
|
||||
callback(new Error('请选择商品分类'))
|
||||
} else {
|
||||
callback()
|
||||
}
|
||||
},
|
||||
trigger: 'change'
|
||||
}
|
||||
]
|
||||
})
|
||||
const printDataLoading = ref(false);
|
||||
const printData = reactive({
|
||||
shop_name: '',
|
||||
@@ -235,26 +347,20 @@ function getPrintList() {
|
||||
}
|
||||
|
||||
// 测试打印
|
||||
function printHandle() {
|
||||
if (form.value.connectionType === 'USB' && !form.value.address) {
|
||||
ElMessage.error("请选择打印设备");
|
||||
return;
|
||||
}
|
||||
if (form.value.connectionType === '局域网' && !form.value.address) {
|
||||
ElMessage.error("请输入设备IP地址");
|
||||
return;
|
||||
}
|
||||
|
||||
const formRef = ref(null)
|
||||
async function printHandle() {
|
||||
try {
|
||||
await formRef.value.validateField(['address'])
|
||||
printDataLoading.value = true;
|
||||
printData.shop_name = store.shopInfo.shopName
|
||||
printData.loginAccount = store.userInfo.name
|
||||
printData.deviceName = form.value.address;
|
||||
printData.deviceName = form.value.name;
|
||||
printData.printTime = dayjs().format("YYYY-MM-DD HH:mm:ss");
|
||||
|
||||
if (form.value.connectionType === 'USB') {
|
||||
printStore.pushReceiptData(printData, false);
|
||||
receiptPrint(printData,)
|
||||
} else if (form.value.connectionType === '局域网') {
|
||||
ipcRenderer.send('networkPrint', JSON.stringify({
|
||||
ipcRenderer.send('ORDER', JSON.stringify({
|
||||
printerIp: form.value.address,
|
||||
orderData: printData
|
||||
}))
|
||||
@@ -262,33 +368,58 @@ function printHandle() {
|
||||
setTimeout(() => {
|
||||
printDataLoading.value = false;
|
||||
}, 2500);
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
}
|
||||
}
|
||||
|
||||
// 打印类型切换
|
||||
function printTypeChange(e, index) {
|
||||
if (index == 1 && printTypeList.value[index].values.length == 0) {
|
||||
form.value.categoryList = []
|
||||
form.value.classifyPrint = '0'
|
||||
formRef.value?.clearValidate('classifyPrint')
|
||||
}
|
||||
if (index == 1 && printTypeList.value[index].values.length > 0) {
|
||||
form.value.classifyPrint = '1'
|
||||
}
|
||||
}
|
||||
|
||||
// 选择分类以后的回调
|
||||
function classifyChange(e) {
|
||||
form.value.categoryList = e
|
||||
formRef.value.validateField(['classifyPrint'])
|
||||
}
|
||||
|
||||
// 提交打印机
|
||||
async function submitHandle() {
|
||||
function submitHandle() {
|
||||
formRef.value.validate(async valid => {
|
||||
try {
|
||||
if (!form.value.name) {
|
||||
ElMessage.error("请输入设备名称");
|
||||
return;
|
||||
}
|
||||
if (form.value.connectionType === 'USB' && !form.value.address) {
|
||||
ElMessage.error("请选择打印设备");
|
||||
return;
|
||||
}
|
||||
if (form.value.connectionType === '局域网' && !form.value.address) {
|
||||
ElMessage.error("请输入设备IP地址");
|
||||
return;
|
||||
}
|
||||
if (valid) {
|
||||
loading.value = true;
|
||||
form.value.categoryIds = form.value.categoryList.map(item => item.id)
|
||||
form.value.categoryIds = form.value.categoryList.map(item => item.id).join(',')
|
||||
|
||||
if (form.value.connectionType == 'USB') {
|
||||
form.value.receiptSize = '58mm'
|
||||
form.value.printContentType = 'GUEST_ORDER,PRE_ORDER,ORDER,REFUND_ORDER'
|
||||
} else {
|
||||
form.value.receiptSize = '80mm'
|
||||
let arr = []
|
||||
printTypeList.value.forEach(item => {
|
||||
arr.push(...item.values)
|
||||
})
|
||||
form.value.printContentType = arr.join(',')
|
||||
}
|
||||
await printerAdd(form.value, form.value.id ? "put" : "post");
|
||||
ElMessage.success(form.value.id ? "编辑成功" : "添加成功");
|
||||
printStore.init();
|
||||
router.back();
|
||||
}
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
}
|
||||
loading.value = false;
|
||||
})
|
||||
}
|
||||
|
||||
// 查询打印机详情
|
||||
@@ -298,9 +429,11 @@ async function tbPrintMachineDetailAjax(id) {
|
||||
const res = await printerDetail({ id: id });
|
||||
form.value = res;
|
||||
|
||||
// 做分类信息补全
|
||||
let arr = []
|
||||
let categoryIds = res.categoryIds.split(',')
|
||||
goodsStore.originCategoryList.map(item => {
|
||||
res.categoryList.map(val => {
|
||||
categoryIds.map(val => {
|
||||
if (item.id == val) {
|
||||
arr.push({
|
||||
id: item.id,
|
||||
@@ -310,6 +443,22 @@ async function tbPrintMachineDetailAjax(id) {
|
||||
})
|
||||
})
|
||||
form.value.categoryList = arr
|
||||
|
||||
// 补全已选中的打印类型
|
||||
const printContentTypes = res.printContentType.split(',')
|
||||
printTypeList.value.forEach(val => {
|
||||
val.values = _.map(
|
||||
_.filter(val.list, item => printContentTypes.includes(item.value)),
|
||||
'value'
|
||||
);
|
||||
})
|
||||
|
||||
console.log(form.value);
|
||||
|
||||
|
||||
// if (printTypeList.value[1].values.length > 0 && form.value.classifyPrint == 1) {
|
||||
// form.value.classifyPrint = 1
|
||||
// }
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
}
|
||||
@@ -354,6 +503,7 @@ onMounted(() => {
|
||||
border-radius: 10px;
|
||||
background-color: #fff;
|
||||
padding: 15px;
|
||||
overflow-y: auto;
|
||||
}
|
||||
|
||||
.menu_wrap {
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
<div class="item" v-for="item in list" :key="item.id">
|
||||
<div class="left">
|
||||
<div class="icon">
|
||||
<el-image :src="icons[item.subType]" style="width: 40px; height: 40px"></el-image>
|
||||
<el-image :src="icons[item.printType]" style="width: 40px; height: 40px"></el-image>
|
||||
</div>
|
||||
<div class="info">
|
||||
<div class="name">{{ item.name }}</div>
|
||||
@@ -28,7 +28,7 @@
|
||||
<div class="editor">
|
||||
<el-text type="primary" @click="
|
||||
router.push({
|
||||
name: deviceRoute[item.subType],
|
||||
name: deviceRoute[item.printType],
|
||||
query: { id: item.id },
|
||||
})
|
||||
">
|
||||
|
||||
@@ -59,8 +59,9 @@
|
||||
</template>
|
||||
</template>
|
||||
</div>
|
||||
<div class="remark_wrap" @click="showRemark(props.item)">
|
||||
备注:<span class="t">{{ props.item.remark }}</span><el-icon class="icon" v-if="props.type == 'cart'">
|
||||
<div class="remark_wrap" v-if="props.item.id">
|
||||
备注:<span class="t">{{ props.item.remark }}</span>
|
||||
<el-icon class="icon" v-if="props.type == 'cart'" @click="showRemark(props.item)">
|
||||
<EditPen />
|
||||
</el-icon>
|
||||
</div>
|
||||
|
||||
@@ -135,13 +135,19 @@
|
||||
</el-icon>
|
||||
<el-text class="t">免厨</el-text>
|
||||
</div>
|
||||
<div class="item"
|
||||
<!-- <div class="item"
|
||||
:class="{ disabled: goodsStore.cartOrderItem.returnNum >= goodsStore.cartOrderItem.number }"
|
||||
@click="returnOrderItemHandle">
|
||||
<el-icon class="icon">
|
||||
<Delete />
|
||||
</el-icon>
|
||||
<el-text class="t">退菜</el-text>
|
||||
</div> -->
|
||||
<div class="item" @click="returnOrderItemHandle">
|
||||
<el-icon class="icon">
|
||||
<Delete />
|
||||
</el-icon>
|
||||
<el-text class="t">退菜</el-text>
|
||||
</div>
|
||||
<div class="item" @click="pendingOrderHandle">
|
||||
<el-icon class="icon">
|
||||
@@ -227,6 +233,8 @@
|
||||
</el-dialog>
|
||||
<!-- 合并/转桌 -->
|
||||
<tableMerging ref="tableMergingRef" @success="" />
|
||||
<!-- 批量退菜 -->
|
||||
<cartOperationReturn ref="cartOperationReturnRef" />
|
||||
<!-- 退菜数量 -->
|
||||
<el-dialog
|
||||
:title="`退菜:${goodsStore.cartOrderItem.product_name} x ${goodsStore.cartOrderItem.number - goodsStore.cartOrderItem.returnNum}`"
|
||||
@@ -266,6 +274,7 @@ import { useSocket } from '@/store/socket.js'
|
||||
import { usePrint } from '@/store/print.js'
|
||||
import { useUser } from '@/store/user.js'
|
||||
import refundConsModal from '@/components/refundConsModal.vue'
|
||||
import cartOperationReturn from './cartOperationReturn.vue'
|
||||
|
||||
const refundConsModalRef = ref(null)
|
||||
|
||||
@@ -274,6 +283,7 @@ const socket = useSocket()
|
||||
const printStore = usePrint()
|
||||
const store = useUser()
|
||||
const tableMergingRef = ref(null)
|
||||
const cartOperationReturnRef = ref(null)
|
||||
|
||||
const props = defineProps({
|
||||
item: {
|
||||
@@ -307,12 +317,13 @@ function pendingOrderHandle() {
|
||||
|
||||
// 退菜
|
||||
async function returnOrderItemHandle() {
|
||||
if (goodsStore.cartOrderItem.returnNum >= goodsStore.cartOrderItem.number) return
|
||||
if (goodsStore.cartOrderItem.number == 1) {
|
||||
returnOrderItemAjax()
|
||||
} else {
|
||||
showReturnForm.value = true
|
||||
}
|
||||
cartOperationReturnRef.value.open()
|
||||
// if (goodsStore.cartOrderItem.returnNum >= goodsStore.cartOrderItem.number) return
|
||||
// if (goodsStore.cartOrderItem.number == 1) {
|
||||
// returnOrderItemAjax()
|
||||
// } else {
|
||||
// showReturnForm.value = true
|
||||
// }
|
||||
}
|
||||
|
||||
// 提交自定义数量退菜
|
||||
@@ -335,6 +346,7 @@ function refundConsModalSuccess(e) {
|
||||
refundNext()
|
||||
}
|
||||
|
||||
// 提交最终退款请求
|
||||
async function refundNext() {
|
||||
try {
|
||||
let data = {
|
||||
@@ -359,18 +371,19 @@ async function refundNext() {
|
||||
goodsStore.cartOrderItem.returnNum += refundNum.value
|
||||
goodsStore.calcCartInfo()
|
||||
|
||||
getOrderByIdAjax(goodsStore.orderListInfo.id).then(res => {
|
||||
let originOrderInfo = res
|
||||
let index = originOrderInfo.cartList.findIndex(item => item.id == goodsStore.cartOrderItem.id)
|
||||
originOrderInfo.cartList = _.at(originOrderInfo.cartList, index);
|
||||
originOrderInfo.cartList[0].num = refundNum.value
|
||||
originOrderInfo.cartList[0].returnNum = 0
|
||||
originOrderInfo.cartList[0].payAmount = refundNum.value * originOrderInfo.cartList[0].price
|
||||
// 打印退菜小票
|
||||
// getOrderByIdAjax(goodsStore.orderListInfo.id).then(res => {
|
||||
// let originOrderInfo = res
|
||||
// let index = originOrderInfo.cartList.findIndex(item => item.id == goodsStore.cartOrderItem.id)
|
||||
// originOrderInfo.cartList = _.at(originOrderInfo.cartList, index);
|
||||
// originOrderInfo.cartList[0].num = refundNum.value
|
||||
// originOrderInfo.cartList[0].returnNum = 0
|
||||
// originOrderInfo.cartList[0].payAmount = refundNum.value * originOrderInfo.cartList[0].price
|
||||
|
||||
printStore.printRefundDish(commOrderPrintData({ ...originOrderInfo, isRefundDish: true }));
|
||||
}).catch(err => {
|
||||
console.log(err);
|
||||
})
|
||||
// printStore.printRefundDish(commOrderPrintData({ ...originOrderInfo, isRefundDish: true }));
|
||||
// }).catch(err => {
|
||||
// console.log(err);
|
||||
// })
|
||||
// await goodsStore.historyOrderAjax('', data.orderId)
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
|
||||
257
src/views/home/components/cartOperationReturn.vue
Normal file
257
src/views/home/components/cartOperationReturn.vue
Normal file
@@ -0,0 +1,257 @@
|
||||
<!-- 退菜弹窗 -->
|
||||
<template>
|
||||
<div>
|
||||
<el-dialog title="批量退菜" v-model="visable" width="700px" top="3vh" @closed="resetDialog">
|
||||
<div class="return_container">
|
||||
<div class="title">退菜原因(统一设置)<el-text type="danger">*</el-text></div>
|
||||
<div class="remark_btns">
|
||||
<el-button plain :type="item.active ? 'primary' : 'default'" v-for="item in remarks"
|
||||
:key="item.label" @click="item.active = !item.active">
|
||||
{{ item.label }}
|
||||
</el-button>
|
||||
</div>
|
||||
<div class="remark_input">
|
||||
<el-input placeholder="请输入自定义备注(选填)" v-model="remarkValue" clearable />
|
||||
</div>
|
||||
<div class="title">请选择要退的菜品</div>
|
||||
<div class="table">
|
||||
<el-table ref="tableRef" row-key="id" :data="tableData" border stripe height="280"
|
||||
@selection-change="handleSelectionChange">
|
||||
<el-table-column type="selection"></el-table-column>
|
||||
<el-table-column prop="name" label="菜品信息">
|
||||
<template #default="{ row }">
|
||||
<div>{{ row.productName }}</div>
|
||||
<div class="tag_wrap" v-if="row.sku_name">
|
||||
<el-text type="info" size="small">规格:</el-text>
|
||||
<el-text type="info" size="small" v-for="item in row.sku_name.split(',')">
|
||||
{{ item }}
|
||||
</el-text>
|
||||
</div>
|
||||
<div class="tag_wrap" v-if="row.remark">
|
||||
<el-text type="info" size="small">备注:</el-text>
|
||||
<el-text type="info" size="small">{{ row.remark }}</el-text>
|
||||
</div>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="quantity" label="退菜数量">
|
||||
<template #default="{ row }">
|
||||
<el-input-number v-model="row.customReturnNum" :min="1"
|
||||
:max="row.number - row.returnNum" style="width: 180px" :step="1" step-strictly>
|
||||
</el-input-number>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
</div>
|
||||
<div class="footer_wrap">
|
||||
<div class="left">退菜数量:共{{ _.sumBy(selectData, 'customReturnNum') || 0 }}份</div>
|
||||
<div class="right">
|
||||
<el-button plain @click="visable = false">取 消</el-button>
|
||||
<el-button type="primary" :disabled="selectData.length == 0" :loading="loading"
|
||||
@click="confirmReturn">确
|
||||
定</el-button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</el-dialog>
|
||||
<!-- 退款推库存的操作弹窗 -->
|
||||
<refundConsModal ref="refundConsModalRef" :list="refundList" @success="refundConsModalSuccess" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import _ from 'lodash'
|
||||
import { ref } from 'vue'
|
||||
import { ElMessage } from 'element-plus'
|
||||
import { useUser } from '@/store/user.js'
|
||||
import { useGoods } from '@/store/goods.js'
|
||||
import { refundOrder } from '@/api/order.js'
|
||||
import refundConsModal from '@/components/refundConsModal.vue'
|
||||
|
||||
const goodsStore = useGoods()
|
||||
const remarks = ref([
|
||||
{
|
||||
label: '不想要了',
|
||||
active: false
|
||||
},
|
||||
{
|
||||
label: '食材不足',
|
||||
active: false
|
||||
},
|
||||
{
|
||||
label: '等待过长',
|
||||
active: false
|
||||
},
|
||||
{
|
||||
label: '点重复了',
|
||||
active: false
|
||||
},
|
||||
{
|
||||
label: '口味问题',
|
||||
active: false
|
||||
}
|
||||
])
|
||||
const remarkValue = ref('')
|
||||
const visable = ref(false)
|
||||
const tableData = ref([])
|
||||
const tableRef = ref(null)
|
||||
const refundConsModalRef = ref(null)
|
||||
const refundList = ref([])
|
||||
const refundStock = ref('')
|
||||
const store = useUser()
|
||||
const selectData = ref([])
|
||||
|
||||
function handleSelectionChange(val) {
|
||||
selectData.value = val
|
||||
console.log('selectData', selectData.value)
|
||||
}
|
||||
|
||||
function confirmReturn() {
|
||||
// 获取表格选中的数据
|
||||
const selectedData = tableRef.value.getSelectionRows()
|
||||
if (selectedData.length == 0) {
|
||||
ElMessage.warning('请至少选择一项菜品退菜')
|
||||
return
|
||||
}
|
||||
console.log('selectedData', selectedData)
|
||||
// 判断是否有需要推库存的菜品
|
||||
refundList.value = selectedData.filter(item => item.refundMode == 3)
|
||||
|
||||
console.log('选中的菜品', refundList.value)
|
||||
|
||||
if (refundList.value.length > 0) {
|
||||
// 打开退款推库存的操作弹窗
|
||||
refundConsModalRef.value.show()
|
||||
} else {
|
||||
// 直接提交退菜请求
|
||||
refundNext()
|
||||
}
|
||||
}
|
||||
|
||||
// 退款推库存的操作
|
||||
function refundConsModalSuccess(e) {
|
||||
refundStock.value = e
|
||||
refundNext()
|
||||
}
|
||||
|
||||
// 提交最终退款请求
|
||||
const loading = ref(false)
|
||||
async function refundNext() {
|
||||
try {
|
||||
const selectedData = tableRef.value.getSelectionRows()
|
||||
const selectRemarks = remarks.value.filter(item => item.active).map(item => item.label)
|
||||
|
||||
if (selectRemarks.length == 0) {
|
||||
ElMessage.warning('请选择退菜原因')
|
||||
return
|
||||
}
|
||||
|
||||
let data = {
|
||||
orderId: goodsStore.orderListInfo.id,
|
||||
refundAmount: 0,
|
||||
modify: 0,
|
||||
cash: false,
|
||||
refundReason: `${selectRemarks.join(',')},${remarkValue.value}`,
|
||||
refundDetails: selectedData.map(item => ({
|
||||
id: item.id,
|
||||
returnAmount: item.lowPrice,
|
||||
num: item.customReturnNum
|
||||
})),
|
||||
operator: store.userInfo.name || store.shopInfo.shopName,
|
||||
print: true,
|
||||
refundStock: refundStock.value, // 是否推库存 1退菜图库存 2仅退菜不退库存
|
||||
}
|
||||
loading.value = true
|
||||
await refundOrder(data)
|
||||
await goodsStore.historyOrderAjax(goodsStore.orderListInfo.tableCode)
|
||||
ElMessage.success('退菜成功')
|
||||
goodsStore.calcCartInfo()
|
||||
|
||||
// 关闭退菜弹窗
|
||||
setTimeout(() => {
|
||||
visable.value = false
|
||||
}, 300);
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
} finally {
|
||||
setTimeout(() => {
|
||||
loading.value = false
|
||||
}, 300);
|
||||
}
|
||||
}
|
||||
|
||||
// 重置弹窗数据
|
||||
function resetDialog() {
|
||||
remarkValue.value = ''
|
||||
selectData.value = []
|
||||
refundList.value = []
|
||||
refundStock.value = ''
|
||||
|
||||
remarks.value.forEach(item => {
|
||||
item.active = false
|
||||
})
|
||||
}
|
||||
|
||||
function open() {
|
||||
visable.value = true
|
||||
tableData.value = _.flatMap(goodsStore.orderList, 'goods').map(item => ({
|
||||
...item,
|
||||
customReturnNum: item.number - item.returnNum
|
||||
})).filter(item => item.number - item.returnNum > 0)
|
||||
|
||||
tableData.value.forEach(item => {
|
||||
goodsStore.originGoodsList.forEach(val => {
|
||||
if (item.productId == val.id) {
|
||||
if (store.shopInfo.refundMode == 1) {
|
||||
// 跟随分类退款模式
|
||||
goodsStore.categoryList.forEach(v => {
|
||||
if (val.categoryId == v.id) {
|
||||
item.refundMode = v.refundMode
|
||||
}
|
||||
})
|
||||
} else {
|
||||
// 跟随商品退款模式及
|
||||
item.refundMode = val.refundMode
|
||||
}
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
console.log('cartOperationReturn组件打开了', tableData.value)
|
||||
|
||||
setTimeout(() => {
|
||||
let row = tableData.value.find(item => item.id === goodsStore.cartOrderItem.id)
|
||||
if (row && row.id) {
|
||||
tableRef.value.toggleRowSelection(row, true)
|
||||
}
|
||||
}, 100);
|
||||
}
|
||||
|
||||
defineExpose({
|
||||
open
|
||||
})
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.return_container {
|
||||
.title {
|
||||
font-size: 16px;
|
||||
margin-bottom: 14px;
|
||||
}
|
||||
|
||||
.remark_btns,
|
||||
.remark_input {
|
||||
margin-bottom: 14px;
|
||||
}
|
||||
|
||||
.footer_wrap {
|
||||
padding-top: 25px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
|
||||
.left {
|
||||
font-size: 16px;
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -1061,7 +1061,7 @@ onMounted(() => {
|
||||
|
||||
.shop_list {
|
||||
// max-height: calc(100vh - 40px - 80px - 40px);
|
||||
height: calc(100vh - 40px - 80px - 28px);
|
||||
height: calc(100vh - 40px - 80px - 40px);
|
||||
// overflow-y: auto;
|
||||
// display: flex;
|
||||
// flex-wrap: wrap;
|
||||
|
||||
@@ -226,6 +226,13 @@ function calcAllCartsTotalSum(cartObj) {
|
||||
async function printOrderLable(isBefore = false) {
|
||||
try {
|
||||
let orderId = goodsStore.orderListInfo.id
|
||||
await orderPrint({
|
||||
type: isBefore ? 1 : 0,
|
||||
id: orderId,
|
||||
});
|
||||
printLoading.value = false
|
||||
return
|
||||
|
||||
let data = await getOrderByIdAjax(orderId);
|
||||
|
||||
console.log(`打印订单标签数据${isBefore}===`, data);
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<template>
|
||||
<div>
|
||||
<div class="content">
|
||||
<div class="cart_wrap card" v-loading="cartLoading">
|
||||
<div class="menu_top">
|
||||
@@ -197,8 +198,7 @@
|
||||
</el-drawer>
|
||||
<!-- <takeFoodCode ref="takeFoodCodeRef" title="修改取餐号" placeholder="请输入取餐号" @success="takeFoodCodeSuccess" /> -->
|
||||
<!-- 结算订单 -->
|
||||
<settleAccount ref="settleAccountRef" :cart="cartList" :amount="cartInfo.totalAmount" :remark="goodsStore.remark"
|
||||
:orderInfo="orderInfo" @success="" />
|
||||
<settleAccount ref="settleAccountRef" :amount="cartInfo.totalAmount" :remark="goodsStore.remark" @success="" />
|
||||
<!-- 快捷收银 -->
|
||||
<fastCashier ref="fastCashierRef" type="0" />
|
||||
<!-- 挂起订单 -->
|
||||
@@ -209,6 +209,7 @@
|
||||
<SelectVipUser ref="SelectVipUserRef" @success="selectUser" />
|
||||
<!-- 修改就餐人数 -->
|
||||
<takeFoodCode ref="takeFoodCodeRef" title="修改就餐人数" placeholder="请输入就餐人数" @success="updateSeatNum" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
@@ -684,7 +685,7 @@ function showTableMerging() {
|
||||
|
||||
.shop_list {
|
||||
flex: 1;
|
||||
height: calc(100vh - 40px - 60px - 90px);
|
||||
height: calc(100vh - 40px - 60px - 102px);
|
||||
overflow-y: auto;
|
||||
border-right: 1px solid #ececec;
|
||||
|
||||
|
||||
@@ -28,15 +28,20 @@
|
||||
</el-dialog> -->
|
||||
<!-- <el-input v-model="authCode" placeholder="请扫描支付码"></el-input>
|
||||
<el-button type="primary" @click="microPayAjax">反扫支付</el-button> -->
|
||||
<el-button type="primary" @click="printReceipt">调用本地网络打印机</el-button>
|
||||
<el-button type="primary" @click="printReceipt">打印盘点单</el-button>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import dayjs from 'dayjs';
|
||||
import { onMounted, ref } from 'vue'
|
||||
import { findVersion } from '@/api/user.js'
|
||||
import packageData from "../../../package.json";
|
||||
import { ipcRenderer } from 'electron'
|
||||
import { microPay } from '@/api/order.js'
|
||||
import { usePrint } from '@/store/print';
|
||||
import { printData } from '@/api/print.js'
|
||||
import { useUser } from '@/store/user.js'
|
||||
import { ALL_KITCHEN, ONLY_KITCHEN, REFUND_KITCHEN } from '../../../electron/printService'
|
||||
|
||||
const showDialog = ref(false)
|
||||
const updataInfo = ref({})
|
||||
@@ -45,27 +50,88 @@ const uploadPro = ref(0)
|
||||
const uploadSucess = ref(false)
|
||||
const uploadResponse = ref({})
|
||||
const tempFilePath = ref('')
|
||||
|
||||
const printStore = usePrint()
|
||||
const authCode = ref('')
|
||||
const user = useUser()
|
||||
|
||||
function printReceipt() {
|
||||
let data = {
|
||||
printerIp: '192.168.1.53',
|
||||
orderData: {
|
||||
orderNo: '20260327008',
|
||||
shopName: '川味小馆',
|
||||
createTime: new Date().toLocaleString(),
|
||||
products: [
|
||||
{ name: '回锅肉', price: '32.00', num: 1 },
|
||||
{ name: '米饭', price: '2.00', num: 2 },
|
||||
{ name: '紫菜蛋花汤', price: '8.00', num: 1 }
|
||||
// RECHARGE=22 STOCK=30 STOCK_CHECK=32 CALL=38
|
||||
async function printReceipt() {
|
||||
const order = {
|
||||
shop_name: '张三的店',
|
||||
loginAccount: '',
|
||||
isBefore: true,
|
||||
carts: [
|
||||
{
|
||||
id: 1,
|
||||
name: "菜品名称1",
|
||||
skuName: "多放香菜",
|
||||
salePrice: "1.0",
|
||||
number: "10",
|
||||
totalAmount: "10",
|
||||
remark: '多放点盐',
|
||||
proGroupInfo: [
|
||||
{
|
||||
proName: '西红柿',
|
||||
number: '2'
|
||||
}
|
||||
]
|
||||
},
|
||||
// {
|
||||
// id: 2,
|
||||
// name: "菜品名称2",
|
||||
// skuName: "500ml",
|
||||
// salePrice: "1.0",
|
||||
// number: "10",
|
||||
// totalAmount: "10",
|
||||
// remark: ''
|
||||
// },
|
||||
// {
|
||||
// id: 3,
|
||||
// name: "菜品名称3",
|
||||
// skuName: "",
|
||||
// salePrice: "1.0",
|
||||
// number: "10",
|
||||
// totalAmount: "10",
|
||||
// remark: ''
|
||||
// },
|
||||
],
|
||||
total: '42.00',
|
||||
payType: '支付宝',
|
||||
remark: '微辣'
|
||||
amount: "10.00",
|
||||
originAmount: '10.00',
|
||||
discountAmount: "0.00",
|
||||
discountAllAmount: 0,
|
||||
orderAmount: 10,
|
||||
discount: 0,
|
||||
remark: "给我多放点辣椒,谢谢老板",
|
||||
orderInfo: {
|
||||
masterId: "",
|
||||
orderNo: "202404021023542223445",
|
||||
orderNum: '12',
|
||||
discountAllAmount: 0,
|
||||
orderAmount: 10,
|
||||
tableName: '室内-A1',
|
||||
dineMode: 'dine-in'
|
||||
},
|
||||
loginAccount: '李四',
|
||||
printerName: '堂食打印机',
|
||||
deviceName: "",
|
||||
createdAt: "2024-04-02 10:15",
|
||||
printTime: dayjs().format("YYYY-MM-DD HH:mm:ss"),
|
||||
}
|
||||
}
|
||||
ipcRenderer.send('portPrint', JSON.stringify(data))
|
||||
// ALL_KITCHEN('192.168.1.53', order)
|
||||
|
||||
// ONLY_KITCHEN('192.168.1.53', order)
|
||||
|
||||
REFUND_KITCHEN('192.168.1.53', order)
|
||||
|
||||
// const res = await printData({
|
||||
// shopId: user.shopInfo.id,
|
||||
// dataId: 38,
|
||||
// type: 'CALL'
|
||||
// })
|
||||
|
||||
// console.log(JSON.parse(res.data));
|
||||
|
||||
// printStore.CALL(JSON.parse(res.data))
|
||||
}
|
||||
|
||||
// 检查版本更新
|
||||
|
||||
@@ -38,7 +38,7 @@
|
||||
@click="takeWineDialogVisible = true; maxTakeNum = row.num; takeWineForm.id = row.id;">
|
||||
<span v-if="isExpired(row.expTime) || row.status == 2">已过期</span>
|
||||
<span v-else-if="row.num <= 0">已取完</span>
|
||||
<span v-else>取酒</span>
|
||||
<span v-else>待取酒</span>
|
||||
</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
@@ -48,18 +48,18 @@
|
||||
</div>
|
||||
</el-drawer>
|
||||
<el-dialog v-model="dialogVisible" title="新增存酒" width="350px" :close-on-click-modal="false" destroy-on-close>
|
||||
<el-form :model="form" :rules="rules" label-width="100px" label-position="left">
|
||||
<el-form-item label="选择酒品">
|
||||
<el-form ref="formRef" :model="form" :rules="rules" label-width="100px" label-position="left">
|
||||
<el-form-item label="选择酒品" prop="shopStorageGoodId">
|
||||
<el-select v-model="form.shopStorageGoodId" placeholder="请选择存酒商品" style="width: 180px;">
|
||||
<el-option v-for="item in storageGoodList" :key="item.id" :label="item.name" :value="item.id">
|
||||
</el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="存酒数量">
|
||||
<el-input-number v-model="form.num" :min="1"></el-input-number>
|
||||
<el-input-number v-model="form.num" :min="1" :step="1" step-strictly></el-input-number>
|
||||
</el-form-item>
|
||||
<el-form-item label="存酒有效期">
|
||||
<el-input-number v-model="form.expDay" :min="1"></el-input-number>
|
||||
<el-input-number v-model="form.expDay" :min="1" :step="1" step-strictly></el-input-number>
|
||||
<span style="margin-left: 8px;">天</span>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
@@ -77,7 +77,8 @@
|
||||
<el-dialog v-model="takeWineDialogVisible" title="取酒" width="350px" :close-on-click-modal="false" destroy-on-close>
|
||||
<el-form :model="takeWineForm" :rules="takeWineRules" label-width="100px" label-position="left">
|
||||
<el-form-item label="取酒数量">
|
||||
<el-input-number v-model="takeWineForm.num" :min="1" :max="maxTakeNum"></el-input-number>
|
||||
<el-input-number v-model="takeWineForm.num" :min="1" :step="1" step-strictly
|
||||
:max="maxTakeNum"></el-input-number>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<div class="dialog-footer">
|
||||
@@ -131,6 +132,8 @@ async function shopStorageGetAjax() {
|
||||
}
|
||||
}
|
||||
|
||||
const formRef = ref(null)
|
||||
|
||||
const form = ref({
|
||||
userId: '',
|
||||
shopStorageGoodId: '', // 存酒商品ID
|
||||
@@ -146,19 +149,23 @@ const rules = {
|
||||
|
||||
// 确认存酒
|
||||
const confirmLoading = ref(false);
|
||||
async function confirmHandle() {
|
||||
function confirmHandle() {
|
||||
formRef.value.validate(async vaild => {
|
||||
try {
|
||||
if (vaild) {
|
||||
confirmLoading.value = true;
|
||||
form.value.userId = props.userInfo.userId;
|
||||
await shopStoragePost(form.value);
|
||||
ElMessage.success('存酒成功');
|
||||
dialogVisible.value = false;
|
||||
shopStorageGetAjax(); // 刷新存酒商品列表
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('存酒失败:', error);
|
||||
} finally {
|
||||
confirmLoading.value = false;
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
// 获取存酒商品列表
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<template>
|
||||
<el-drawer v-model="showDrawer" direction="rtl" size="300px">
|
||||
<el-drawer v-model="showDrawer" direction="rtl" size="500px">
|
||||
<template #header>
|
||||
<h4>订单打印</h4>
|
||||
</template>
|
||||
@@ -80,8 +80,13 @@
|
||||
</el-button>
|
||||
</div>
|
||||
<div class="btn">
|
||||
<el-button type="primary" style="width: 100%" :loading="printLoading" @click="printHandle('normal')">
|
||||
打印小票
|
||||
<el-button type="primary" style="width: 100%" :loading="printLoading" @click="printHandle('normal', 2)">
|
||||
打印前台票
|
||||
</el-button>
|
||||
</div>
|
||||
<div class="btn">
|
||||
<el-button type="warning" style="width: 100%" :loading="printLoading" @click="printHandle('normal', 3)">
|
||||
打印厨房票
|
||||
</el-button>
|
||||
</div>
|
||||
</div>
|
||||
@@ -111,21 +116,15 @@ const loading = ref(false);
|
||||
const printLoading = ref(false);
|
||||
|
||||
// 打印操作
|
||||
async function printHandle(type) {
|
||||
async function printHandle(type, t = null) {
|
||||
try {
|
||||
printLoading.value = true;
|
||||
switch (type) {
|
||||
case "normal":
|
||||
// 打印订单小票
|
||||
if (printStore.deviceNoteList.length) {
|
||||
printStore.pushReceiptData(commOrderPrintData(originOrderInfo.value));
|
||||
} else {
|
||||
await orderPrint({
|
||||
id: orderInfo.value.id,
|
||||
type: 0 // 0结算单 1预结算单 2退款单
|
||||
type: t // 1 预结算单 2结算单 3厨房单
|
||||
})
|
||||
ElMessage.success('云打印小票成功')
|
||||
}
|
||||
break;
|
||||
case "label":
|
||||
// 打印标签小票
|
||||
|
||||
@@ -251,7 +251,7 @@ async function refundNext() {
|
||||
|
||||
await refundOrder(data)
|
||||
ElMessage.success('退款成功')
|
||||
await printRefund(rows.value)
|
||||
// await printRefund(rows.value)
|
||||
isShow.value = false
|
||||
emits('success')
|
||||
} catch (error) {
|
||||
|
||||
@@ -29,7 +29,7 @@ const statusList = {
|
||||
text: '用户未订阅'
|
||||
},
|
||||
0: {
|
||||
type: 'danger',
|
||||
type: 'error',
|
||||
text: '失败'
|
||||
},
|
||||
1: {
|
||||
|
||||
55
src/views/store_wine/components/countPage.vue
Normal file
55
src/views/store_wine/components/countPage.vue
Normal file
@@ -0,0 +1,55 @@
|
||||
<template>
|
||||
<div class="wrap">
|
||||
<el-table :data="list" stripe border v-loading="loading" height="100%">
|
||||
<el-table-column label="商品信息">
|
||||
<template v-slot="scope">
|
||||
<div class="center">
|
||||
<el-avatar :size="40" shape="square" :src="scope.row.imgUrl" style="flex-shrink: 0;">
|
||||
{{ scope.row.name.charAt(0) }}
|
||||
</el-avatar>
|
||||
<el-text>{{ scope.row.name }}</el-text>
|
||||
</div>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="有效存酒" prop="savNum"></el-table-column>
|
||||
<el-table-column label="已过期存酒" prop="savNum"></el-table-column>
|
||||
</el-table>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref, onMounted } from 'vue'
|
||||
import { shopStorageCount } from '@/api/product_new'
|
||||
|
||||
const loading = ref(false)
|
||||
const list = ref([])
|
||||
|
||||
async function shopStorageCountAjax() {
|
||||
try {
|
||||
loading.value = true
|
||||
list.value = await shopStorageCount()
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
} finally {
|
||||
setTimeout(() => {
|
||||
loading.value = false
|
||||
}, 300);
|
||||
}
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
shopStorageCountAjax()
|
||||
})
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
.wrap {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
.center {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 10px;
|
||||
}
|
||||
</style>
|
||||
416
src/views/store_wine/components/managePage.vue
Normal file
416
src/views/store_wine/components/managePage.vue
Normal file
@@ -0,0 +1,416 @@
|
||||
<!-- 存酒记录 -->
|
||||
<template>
|
||||
<div class="wrap">
|
||||
<div class="top_wrap">
|
||||
<el-form :model="queryForm" inline>
|
||||
<el-form-item label="酒名">
|
||||
<el-input v-model="queryForm.name" placeholder="请输入酒名"></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button type="primary" icon="Search" :loading="tableData.loading"
|
||||
@click="storageGoodGetAjax">搜索</el-button>
|
||||
<el-button icon="Refresh" :loading="tableData.loading" @click="reset">重置</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<el-button type="primary" @click="addFormDialogShow = true">新增酒品</el-button>
|
||||
</div>
|
||||
<div class="tab">
|
||||
<div class="tab_wrap">
|
||||
<el-table :data="tableData.list" v-loading="tableData.loading" border stripe height="100%">
|
||||
<el-table-column label="酒品名">
|
||||
<template v-slot="scope">
|
||||
<div class="center">
|
||||
<el-avatar :size="40" shape="square" :src="scope.row.imgUrl" style="flex-shrink: 0;">
|
||||
{{ scope.row.name.charAt(0) }}
|
||||
</el-avatar>
|
||||
<el-text>{{ scope.row.name }}</el-text>
|
||||
</div>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="单位" prop="unit"></el-table-column>
|
||||
<el-table-column label="有效期(天)" prop="period"></el-table-column>
|
||||
<el-table-column label="来源" prop="source" width="100">
|
||||
<template v-slot="scope">
|
||||
<el-text v-if="scope.row.source === 1">商品</el-text>
|
||||
<el-text v-if="scope.row.source === 0">手动</el-text>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="操作" width="300">
|
||||
<template #default="{ row }">
|
||||
<el-button type="primary" @click="storeHandle(row)">存酒</el-button>
|
||||
<el-button @click="editorHandle(row)">编辑</el-button>
|
||||
<el-button type="danger" @click="deleteHandle(row)">删除</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
</div>
|
||||
</div>
|
||||
<div class="pagination">
|
||||
<el-pagination background v-model:current-page="tableData.page" v-model:page-size="tableData.size"
|
||||
:page-sizes="[10, 30, 50, 100]" layout="sizes, pager, jumper, total" :total="tableData.total"
|
||||
@size-change="storageGoodGetAjax" @current-change="storageGoodGetAjax"></el-pagination>
|
||||
</div>
|
||||
<!-- 添加/编辑存酒 -->
|
||||
<el-dialog :title="addForm.id ? '编辑酒品' : '添加酒品'" width="600px" v-model="addFormDialogShow"
|
||||
@close="addFormDialogClsoe">
|
||||
<el-form ref="addFormRef" :model="addForm" :rules="addFormRules" label-width="120" label-position="right">
|
||||
<el-form-item label="类型">
|
||||
<el-radio-group v-model="addForm.source">
|
||||
<el-radio-button label="手动添加" :value="0"></el-radio-button>
|
||||
<el-radio-button label="从商品添加" :value="1"></el-radio-button>
|
||||
</el-radio-group>
|
||||
</el-form-item>
|
||||
<div v-if="addForm.source === 0">
|
||||
<el-form-item label="酒品名" prop="name">
|
||||
<el-input placeholder="请输入酒品名称" v-model="addForm.name" style="width: 80%;"></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item label="酒品图片">
|
||||
<UploadImg ref="UploadImgRef" @success="e => addForm.imgUrl = e" />
|
||||
</el-form-item>
|
||||
<el-form-item label="单位">
|
||||
<el-input placeholder="请输入单位" v-model="addForm.unit" style="width: 50%;"></el-input>
|
||||
</el-form-item>
|
||||
</div>
|
||||
<div v-else>
|
||||
<el-form-item label="选择商品">
|
||||
<el-select v-model="addForm.prodId" style="width: 80%;">
|
||||
<el-option v-for="item in goodsStore.originGoodsList" :label="item.name" :value="item.id"
|
||||
:key="item.id" @click="selectGoods(item)"></el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="商品名称">
|
||||
<el-text v-if="addForm.name">{{ addForm.name }}</el-text>
|
||||
<el-text type="info" v-else>请选择商品</el-text>
|
||||
</el-form-item>
|
||||
<el-form-item label="商品图片">
|
||||
<el-image :src="addForm.imgUrl" style="width: 140px;height: 140px;"></el-image>
|
||||
</el-form-item>
|
||||
</div>
|
||||
<el-form-item label="有效期">
|
||||
<el-input-number v-model="addForm.period" :min="1" :step="1" step-strictly></el-input-number>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<div class="dialog-footer">
|
||||
<div class="btn">
|
||||
<el-button style="width: 100%;" @click="addFormDialogShow = false">
|
||||
取消
|
||||
</el-button>
|
||||
</div>
|
||||
<div class="btn">
|
||||
<el-button style="width: 100%;" type="primary" :loading="addFormConfirmLoading"
|
||||
@click="addFormConfirm">
|
||||
确定
|
||||
</el-button>
|
||||
</div>
|
||||
</div>
|
||||
</el-dialog>
|
||||
<!-- 存酒 -->
|
||||
<el-dialog v-model="dialogVisible" :title="`${form.name} - 新增存酒`" width="400px" :close-on-click-modal="false"
|
||||
destroy-on-close @close="storeInClose">
|
||||
<el-form ref="formRef" :model="form" :rules="rules" label-width="100px" label-position="left">
|
||||
<el-form-item label="选择用户" prop="userId">
|
||||
<el-select v-model="form.userId" placeholder="请选择用户(可搜索)" clearable filterable remote
|
||||
remote-show-suffix :remote-method="remoteMethod" :loading="userListLoading"
|
||||
@clear="getUserList">
|
||||
<el-option :label="`${item.nickName}/${item.phone}`" :value="item.userId"
|
||||
v-for="item in userList" :key="item.id"></el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<!-- <el-form-item label="选择酒品">
|
||||
<el-select v-model="form.shopStorageGoodId" placeholder="请选择存酒商品">
|
||||
<el-option v-for="item in storageGoodList" :key="item.id" :label="item.name" :value="item.id">
|
||||
</el-option>
|
||||
</el-select>
|
||||
</el-form-item> -->
|
||||
<el-form-item label="存酒数量">
|
||||
<el-input-number v-model="form.num" :min="1" :step="1" step-strictly></el-input-number>
|
||||
</el-form-item>
|
||||
<el-form-item label="存酒有效期">
|
||||
<el-input-number v-model="form.expDay" :min="1" :step="1" step-strictly></el-input-number>
|
||||
<span style="margin-left: 8px;">天</span>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<div class="dialog-footer">
|
||||
<div class="btn">
|
||||
<el-button style="width: 100%;" @click="dialogVisible = false">取 消</el-button>
|
||||
</div>
|
||||
<div class="btn">
|
||||
<el-button style="width: 100%;" type="primary" :loading="confirmLoading" @click="confirmHandle">确
|
||||
定</el-button>
|
||||
</div>
|
||||
</div>
|
||||
</el-dialog>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import _ from 'lodash'
|
||||
import { ref, onMounted, nextTick } from 'vue'
|
||||
import { ElMessage, ElMessageBox } from 'element-plus'
|
||||
import { shopStoragePost, storageGoodGet, storageGoodPost, storageGoodPut, storageGoodDelete } from '@/api/product_new'
|
||||
import { shopUserList } from '@/api/account.js'
|
||||
import UploadImg from '@/components/uploadImg.vue'
|
||||
import { useGoods } from '@/store/goods.js'
|
||||
|
||||
const goodsStore = useGoods()
|
||||
|
||||
const UploadImgRef = ref(null)
|
||||
|
||||
const queryForm = ref({
|
||||
name: ''
|
||||
})
|
||||
|
||||
const tableData = ref({
|
||||
loading: false,
|
||||
page: 1,
|
||||
size: 10,
|
||||
total: 0,
|
||||
list: []
|
||||
});
|
||||
|
||||
function isExpired(expTime) {
|
||||
if (!expTime) return false;
|
||||
const now = new Date();
|
||||
const expDate = new Date(expTime);
|
||||
return expDate < now;
|
||||
}
|
||||
|
||||
function reset() {
|
||||
queryForm.value.name = ''
|
||||
tableData.page = 1
|
||||
storageGoodGetAjax()
|
||||
}
|
||||
|
||||
const userList = ref([])
|
||||
// 获取用户列表
|
||||
const userListLoading = ref(false)
|
||||
|
||||
function remoteMethod(query) {
|
||||
if (query) {
|
||||
getUserList(query)
|
||||
}
|
||||
}
|
||||
|
||||
// 获取用户列表
|
||||
async function getUserList(name = '') {
|
||||
try {
|
||||
userListLoading.value = true
|
||||
const res = await shopUserList({ page: 1, key: name, size: 20 })
|
||||
userList.value = res.records
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
} finally {
|
||||
setTimeout(() => {
|
||||
userListLoading.value = false
|
||||
}, 100);
|
||||
}
|
||||
}
|
||||
|
||||
// 获取存酒商品列表
|
||||
const storageGoodList = ref([]);
|
||||
async function storageGoodGetAjax() {
|
||||
try {
|
||||
tableData.value.loading = true
|
||||
const res = await storageGoodGet({
|
||||
name: queryForm.value.name,
|
||||
page: tableData.value.page,
|
||||
size: tableData.value.size,
|
||||
});
|
||||
tableData.value.list = res.records || [];
|
||||
tableData.value.total = +res.totalRow || 0
|
||||
} catch (error) {
|
||||
console.error('获取存酒商品列表失败:', error);
|
||||
} finally {
|
||||
setTimeout(() => {
|
||||
tableData.value.loading = false
|
||||
}, 300);
|
||||
}
|
||||
}
|
||||
|
||||
const dialogVisible = ref(false);
|
||||
const formObj = {
|
||||
name: '',
|
||||
userId: '',
|
||||
shopStorageGoodId: '', // 存酒商品ID
|
||||
num: 1, // 存酒数量
|
||||
expDay: 1, // 存酒有效期,单位天默认1天
|
||||
}
|
||||
const formRef = ref(null)
|
||||
const form = ref(formObj)
|
||||
const rules = {
|
||||
userId: [{ required: true, message: '请选择用户', trigger: 'change' }],
|
||||
shopStorageGoodId: [{ required: true, message: '请选择存酒商品', trigger: 'change' }],
|
||||
num: [{ required: true, message: '请输入存酒数量', trigger: 'change' }],
|
||||
expDay: [{ required: true, message: '请输入存酒有效期', trigger: 'change' }],
|
||||
}
|
||||
|
||||
function storeInClose() {
|
||||
formRef.value.resetFields()
|
||||
form.value = _.cloneDeep(formObj)
|
||||
}
|
||||
|
||||
// 确认存酒
|
||||
const confirmLoading = ref(false);
|
||||
function confirmHandle() {
|
||||
formRef.value.validate(async vaild => {
|
||||
try {
|
||||
if (vaild) {
|
||||
confirmLoading.value = true;
|
||||
await shopStoragePost(form.value);
|
||||
ElMessage.success('存酒成功');
|
||||
dialogVisible.value = false;
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('存酒失败:', error);
|
||||
} finally {
|
||||
confirmLoading.value = false;
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
// 添加酒品
|
||||
const addFormDialogShow = ref(false)
|
||||
const addFormRef = ref(null)
|
||||
const addFormObj = {
|
||||
id: '',
|
||||
name: '', // 酒品名称
|
||||
imgUrl: '', // 商品图片
|
||||
unit: '瓶', // 单位
|
||||
period: 365, // 过期时间
|
||||
prodId: '', // 商品id
|
||||
source: 0, // 0手动 1商品
|
||||
}
|
||||
const addForm = ref(_.cloneDeep(addFormObj))
|
||||
|
||||
const addFormRules = ref({
|
||||
name: [
|
||||
{
|
||||
required: true,
|
||||
message: '请输入酒品名称',
|
||||
trigger: 'blur'
|
||||
}
|
||||
]
|
||||
})
|
||||
|
||||
// 显示存酒
|
||||
async function storeHandle(row) {
|
||||
form.value.name = row.name
|
||||
form.value.shopStorageGoodId = row.id
|
||||
await nextTick()
|
||||
dialogVisible.value = true
|
||||
}
|
||||
|
||||
// 编辑
|
||||
async function editorHandle(row) {
|
||||
addForm.value = _.cloneDeep(row)
|
||||
addFormDialogShow.value = true
|
||||
if (row.source == 0) {
|
||||
await nextTick()
|
||||
UploadImgRef.value.init([{ url: row.imgUrl }])
|
||||
}
|
||||
}
|
||||
|
||||
// 删除
|
||||
function deleteHandle(row) {
|
||||
ElMessageBox.confirm(`确认要删除酒品「${row.name}」吗?`).then(async () => {
|
||||
try {
|
||||
tableData.value.loading = true
|
||||
await storageGoodDelete(row.id)
|
||||
reset()
|
||||
} catch (error) {
|
||||
tableData.value.loading = false
|
||||
}
|
||||
}).catch(() => { })
|
||||
}
|
||||
|
||||
// 选择商品
|
||||
function selectGoods(item) {
|
||||
addForm.value.name = item.name
|
||||
addForm.value.imgUrl = item.coverImg
|
||||
}
|
||||
|
||||
function addFormDialogClsoe() {
|
||||
addFormRef.value.resetFields()
|
||||
addForm.value = _.cloneDeep(addFormObj)
|
||||
if (form.value.source == 0) {
|
||||
UploadImgRef.value.init([])
|
||||
}
|
||||
}
|
||||
|
||||
const addFormConfirmLoading = ref(false)
|
||||
function addFormConfirm() {
|
||||
addFormRef.value.validate(async vaild => {
|
||||
try {
|
||||
if (vaild) {
|
||||
addFormConfirmLoading.value = true
|
||||
if (addForm.value.id) {
|
||||
await storageGoodPut(addForm.value)
|
||||
} else {
|
||||
await storageGoodPost(addForm.value)
|
||||
}
|
||||
ElMessage.success(addForm.value.id ? '编辑成功' : '添加成功')
|
||||
addFormDialogShow.value = false
|
||||
reset()
|
||||
}
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
} finally {
|
||||
setTimeout(() => {
|
||||
addFormConfirmLoading.value = false
|
||||
}, 300);
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
storageGoodGetAjax()
|
||||
getUserList()
|
||||
})
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
.wrap {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.tab {
|
||||
flex: 1;
|
||||
position: relative;
|
||||
|
||||
.tab_wrap {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
}
|
||||
}
|
||||
|
||||
.center {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 10px;
|
||||
}
|
||||
|
||||
.top_wrap {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
}
|
||||
|
||||
.pagination {
|
||||
padding-top: var(--el-font-size-base);
|
||||
}
|
||||
|
||||
.dialog-footer {
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
gap: var(--el-font-size-base);
|
||||
|
||||
.btn {
|
||||
flex: 1;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
393
src/views/store_wine/components/record.vue
Normal file
393
src/views/store_wine/components/record.vue
Normal file
@@ -0,0 +1,393 @@
|
||||
<!-- 存酒记录 -->
|
||||
<template>
|
||||
<div class="wrap">
|
||||
<div class="top_wrap">
|
||||
<el-form :model="queryForm" inline>
|
||||
<el-form-item label="酒名/用户昵称">
|
||||
<el-input v-model="queryForm.key" placeholder="请输入酒名/用户昵称"></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item label="状态">
|
||||
<el-select v-model="queryForm.status" placeholder="请选择状态" clearable style="width: 150px;">
|
||||
<el-option label="全部" value="" />
|
||||
<el-option label="已取完" value="0" />
|
||||
<el-option label="储存中" value="1" />
|
||||
<el-option label="已过期" value="2" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button type="primary" icon="Search" :loading="tableData.loading"
|
||||
@click="shopStorageGetAjax">搜索</el-button>
|
||||
<el-button icon="Refresh" :loading="tableData.loading" @click="reset">重置</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<el-button type="primary" @click="dialogVisible = true">新增存酒</el-button>
|
||||
</div>
|
||||
<div class="tab">
|
||||
<div class="tab_wrap">
|
||||
<el-table :data="tableData.list" v-loading="tableData.loading" border stripe height="100%">
|
||||
<el-table-column label="用户">
|
||||
<template v-slot="scope">
|
||||
<div class="center">
|
||||
<el-avatar :size="40" :src="scope.row.headImg" style="flex-shrink: 0;">
|
||||
{{ scope.row.nickName.charAt(0) }}
|
||||
</el-avatar>
|
||||
<el-text>{{ scope.row.nickName }}</el-text>
|
||||
</div>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="酒品名">
|
||||
<template v-slot="scope">
|
||||
<div class="center">
|
||||
<el-avatar :size="40" shape="square" :src="scope.row.imgUrl" style="flex-shrink: 0;">
|
||||
{{ scope.row.name.charAt(0) }}
|
||||
</el-avatar>
|
||||
<el-text>{{ scope.row.name }}</el-text>
|
||||
</div>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="数量" prop="num" width="80">
|
||||
<template v-slot="scope">
|
||||
<el-text>{{ scope.row.num }}{{ scope.row.unit }}</el-text>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="存酒时间" prop="savTime"></el-table-column>
|
||||
<el-table-column label="到期时间" prop="expTime"></el-table-column>
|
||||
<el-table-column label="状态" prop="status" width="100">
|
||||
<template v-slot="scope">
|
||||
<el-tag disable-transitions type="info"
|
||||
v-if="isExpired(scope.row.expTime) || scope.row.status == 2">已过期</el-tag>
|
||||
<el-tag disable-transitions type="info" v-else-if="scope.row.num <= 0">已取完</el-tag>
|
||||
<el-tag disable-transitions type="primary" v-else>未取完</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="操作" width="240">
|
||||
<template #default="{ row }">
|
||||
<el-button type="primary" @click="viewRecord(row)">查看记录</el-button>
|
||||
<el-button type="danger" :disabled="isExpired(row.expTime) || row.num <= 0"
|
||||
@click="takeWineDialogVisible = true; maxTakeNum = row.num; takeWineForm.id = row.id;">
|
||||
<span v-if="isExpired(row.expTime) || row.status == 2">已过期</span>
|
||||
<span v-else-if="row.num <= 0">已取完</span>
|
||||
<span v-else>待取酒</span>
|
||||
</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
</div>
|
||||
</div>
|
||||
<div class="pagination">
|
||||
<el-pagination background v-model:current-page="tableData.page" v-model:page-size="tableData.size"
|
||||
:page-sizes="[10, 30, 50, 100]" layout="sizes, pager, jumper, total" :total="tableData.total"
|
||||
@size-change="shopStorageGetAjax" @current-change="shopStorageGetAjax"></el-pagination>
|
||||
</div>
|
||||
<!-- 存酒 -->
|
||||
<el-dialog v-model="dialogVisible" title="新增存酒" width="400px" :close-on-click-modal="false" destroy-on-close
|
||||
@open="storeInOpen">
|
||||
<el-form ref="formRef" :model="form" :rules="rules" label-width="100px" label-position="left">
|
||||
<el-form-item label="选择用户" prop="userId">
|
||||
<el-select v-model="form.userId" placeholder="请选择用户(可搜索)" clearable filterable remote
|
||||
remote-show-suffix :remote-method="remoteMethod" :loading="userListLoading"
|
||||
@clear="getUserList">
|
||||
<el-option :label="`${item.nickName}/${item.phone}`" :value="item.userId"
|
||||
v-for="item in userList" :key="item.id"></el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="选择酒品" prop="shopStorageGoodId">
|
||||
<el-select v-model="form.shopStorageGoodId" placeholder="请选择存酒商品">
|
||||
<el-option v-for="item in storageGoodList" :key="item.id" :label="item.name" :value="item.id">
|
||||
</el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="存酒数量">
|
||||
<el-input-number v-model="form.num" :min="1" :step="1" step-strictly></el-input-number>
|
||||
</el-form-item>
|
||||
<el-form-item label="存酒有效期">
|
||||
<el-input-number v-model="form.expDay" :min="1" :step="1" step-strictly></el-input-number>
|
||||
<span style="margin-left: 8px;">天</span>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<div class="dialog-footer">
|
||||
<div class="btn">
|
||||
<el-button style="width: 100%;" @click="dialogVisible = false">取 消</el-button>
|
||||
</div>
|
||||
<div class="btn">
|
||||
<el-button style="width: 100%;" type="primary" :loading="confirmLoading" @click="confirmHandle">确
|
||||
定</el-button>
|
||||
</div>
|
||||
</div>
|
||||
</el-dialog>
|
||||
<!-- 存取酒记录弹窗 -->
|
||||
<el-dialog title="记录" width="600px" v-model="showRecordDialogVisible">
|
||||
<el-table :data="recordList" border stripe>
|
||||
<el-table-column label="记录" prop="content"></el-table-column>
|
||||
<el-table-column label="操作时间" prop="time"></el-table-column>
|
||||
</el-table>
|
||||
</el-dialog>
|
||||
<!-- 取酒对话框,只选择数量即可,不可超过存酒的数量 -->
|
||||
<el-dialog v-model="takeWineDialogVisible" title="取酒" width="350px" :close-on-click-modal="false"
|
||||
destroy-on-close>
|
||||
<el-form :model="takeWineForm" :rules="takeWineRules" label-width="100px" label-position="left">
|
||||
<el-form-item label="取酒数量">
|
||||
<el-input-number v-model="takeWineForm.num" :min="1" :step="1" step-strictly
|
||||
:max="maxTakeNum"></el-input-number>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<div class="dialog-footer">
|
||||
<div class="btn">
|
||||
<el-button style="width: 100%;" @click="takeWineDialogVisible = false">取 消</el-button>
|
||||
</div>
|
||||
<div class="btn">
|
||||
<el-button style="width: 100%;" type="primary" :loading="takeWineConfirmLoading"
|
||||
@click="confirmTakeWineHandle">确 定</el-button>
|
||||
</div>
|
||||
</div>
|
||||
</el-dialog>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref, onMounted } from 'vue'
|
||||
import { ElMessage } from 'element-plus'
|
||||
import { shopStoragePost, storageGoodGet, shopStorageGet, shopStoragePut, shopStorageRecord } from '@/api/product_new'
|
||||
import { shopUserList } from '@/api/account.js'
|
||||
|
||||
const queryForm = ref({
|
||||
key: '',
|
||||
status: ''
|
||||
})
|
||||
|
||||
const tableData = ref({
|
||||
loading: false,
|
||||
page: 1,
|
||||
size: 10,
|
||||
total: 0,
|
||||
list: []
|
||||
});
|
||||
|
||||
function isExpired(expTime) {
|
||||
if (!expTime) return false;
|
||||
const now = new Date();
|
||||
const expDate = new Date(expTime);
|
||||
return expDate < now;
|
||||
}
|
||||
|
||||
function reset() {
|
||||
queryForm.value.name = ''
|
||||
queryForm.value.status = ''
|
||||
tableData.page = 1
|
||||
shopStorageGetAjax()
|
||||
}
|
||||
|
||||
// 获取存酒记录
|
||||
async function shopStorageGetAjax() {
|
||||
try {
|
||||
tableData.value.loading = true
|
||||
const res = await shopStorageGet({
|
||||
key: queryForm.value.key,
|
||||
phone: '',
|
||||
status: queryForm.value.status,
|
||||
page: tableData.value.page,
|
||||
size: tableData.value.size,
|
||||
});
|
||||
tableData.value.list = res.records || [];
|
||||
tableData.value.total = +res.totalRow || 0
|
||||
} catch (error) {
|
||||
console.error('获取存酒列表失败:', error);
|
||||
} finally {
|
||||
setTimeout(() => {
|
||||
tableData.value.loading = false
|
||||
}, 300);
|
||||
}
|
||||
}
|
||||
|
||||
function storeInOpen() {
|
||||
init()
|
||||
getUserList()
|
||||
storageGoodGetAjax()
|
||||
}
|
||||
|
||||
|
||||
function init() {
|
||||
form.value = {
|
||||
userId: '',
|
||||
shopStorageGoodId: '',
|
||||
num: 1,
|
||||
expDay: 1,
|
||||
};
|
||||
}
|
||||
|
||||
const userList = ref([])
|
||||
// 获取用户列表
|
||||
const userListLoading = ref(false)
|
||||
|
||||
function remoteMethod(query) {
|
||||
if (query) {
|
||||
getUserList(query)
|
||||
}
|
||||
}
|
||||
|
||||
async function getUserList(name = '') {
|
||||
try {
|
||||
userListLoading.value = true
|
||||
const res = await shopUserList({ page: 1, key: name, size: 20 })
|
||||
userList.value = res.records
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
} finally {
|
||||
setTimeout(() => {
|
||||
userListLoading.value = false
|
||||
}, 100);
|
||||
}
|
||||
}
|
||||
|
||||
// 获取存酒商品列表
|
||||
const storageGoodList = ref([]);
|
||||
async function storageGoodGetAjax() {
|
||||
try {
|
||||
const res = await storageGoodGet({
|
||||
page: 1,
|
||||
size: 999,
|
||||
});
|
||||
storageGoodList.value = res.records || [];
|
||||
} catch (error) {
|
||||
console.error('获取存酒商品列表失败:', error);
|
||||
}
|
||||
}
|
||||
|
||||
const dialogVisible = ref(false);
|
||||
const formRef = ref(null)
|
||||
const form = ref({
|
||||
userId: '',
|
||||
shopStorageGoodId: '', // 存酒商品ID
|
||||
num: 1, // 存酒数量
|
||||
expDay: 1, // 存酒有效期,单位天默认1天
|
||||
})
|
||||
|
||||
const rules = {
|
||||
userId: [{ required: true, message: '请选择用户', trigger: 'change' }],
|
||||
shopStorageGoodId: [{ required: true, message: '请选择存酒商品', trigger: 'change' }],
|
||||
num: [{ required: true, message: '请输入存酒数量', trigger: 'change' }],
|
||||
expDay: [{ required: true, message: '请输入存酒有效期', trigger: 'change' }],
|
||||
}
|
||||
|
||||
// 确认存酒
|
||||
const confirmLoading = ref(false);
|
||||
function confirmHandle() {
|
||||
formRef.value.validate(async vaild => {
|
||||
try {
|
||||
if (vaild) {
|
||||
confirmLoading.value = true;
|
||||
await shopStoragePost(form.value);
|
||||
ElMessage.success('存酒成功');
|
||||
dialogVisible.value = false;
|
||||
shopStorageGetAjax(); // 刷新存酒商品列表
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('存酒失败:', error);
|
||||
} finally {
|
||||
confirmLoading.value = false;
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
// 查看记录
|
||||
const showRecordDialogVisible = ref(false);
|
||||
const recordList = ref([]);
|
||||
async function viewRecord(row) {
|
||||
try {
|
||||
showRecordDialogVisible.value = true;
|
||||
const res = await shopStorageRecord({
|
||||
id: row.id,
|
||||
page: 1,
|
||||
size: 999,
|
||||
});
|
||||
recordList.value = res || [];
|
||||
} catch (error) {
|
||||
console.error('获取存取酒记录失败:', error);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
const takeWineDialogVisible = ref(false);
|
||||
const takeWineForm = ref({
|
||||
id: '', // 存酒记录ID
|
||||
num: 1,
|
||||
})
|
||||
const takeWineRules = {
|
||||
num: [{ required: true, message: '请输入取酒数量', trigger: 'change' }],
|
||||
}
|
||||
const maxTakeNum = ref(1);
|
||||
const takeWineConfirmLoading = ref(false);
|
||||
|
||||
function confirmTakeWineHandle() {
|
||||
shopStoragePutAjax();
|
||||
}
|
||||
|
||||
// 存酒取酒 num 必需 正数为存酒反之为取酒
|
||||
async function shopStoragePutAjax() {
|
||||
try {
|
||||
takeWineConfirmLoading.value = true;
|
||||
await shopStoragePut({
|
||||
id: takeWineForm.value.id,
|
||||
num: -takeWineForm.value.num, // 取酒数量为负数
|
||||
});
|
||||
ElMessage.success('取酒成功');
|
||||
takeWineDialogVisible.value = false;
|
||||
shopStorageGetAjax(); // 刷新存酒记录列表
|
||||
} catch (error) {
|
||||
console.error('取酒失败:', error);
|
||||
} finally {
|
||||
takeWineConfirmLoading.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
shopStorageGetAjax()
|
||||
})
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
.wrap {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.tab {
|
||||
flex: 1;
|
||||
position: relative;
|
||||
|
||||
.tab_wrap {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
}
|
||||
}
|
||||
|
||||
.center {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 10px;
|
||||
}
|
||||
|
||||
.top_wrap {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
}
|
||||
|
||||
.pagination {
|
||||
padding-top: var(--el-font-size-base);
|
||||
}
|
||||
|
||||
.dialog-footer {
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
gap: var(--el-font-size-base);
|
||||
|
||||
.btn {
|
||||
flex: 1;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
104
src/views/store_wine/index.vue
Normal file
104
src/views/store_wine/index.vue
Normal file
@@ -0,0 +1,104 @@
|
||||
<template>
|
||||
<div class="container">
|
||||
<div class="drawer_wrap">
|
||||
<div class="header">
|
||||
<div class="left">
|
||||
<div class="return" @click="router.back()">
|
||||
<el-icon size="26" color="#555">
|
||||
<Back />
|
||||
</el-icon>
|
||||
</div>
|
||||
<div class="menu_wrap">
|
||||
<el-radio-group v-model="pageType">
|
||||
<el-radio-button label="存酒记录" :value="1"></el-radio-button>
|
||||
<el-radio-button label="可存酒管理" :value="2"></el-radio-button>
|
||||
<el-radio-button label="存酒统计" :value="3"></el-radio-button>
|
||||
</el-radio-group>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="pay_wrap">
|
||||
<!-- 存酒记录 -->
|
||||
<record name="record" key="record" v-if="pageType == 1" />
|
||||
<!-- 存酒管理 -->
|
||||
<managePage name="managePage" key="managePage" v-if="pageType == 2" />
|
||||
<!-- 存酒统计 -->
|
||||
<countPage name="countPage" key="countPage" v-if="pageType == 3" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref, onMounted } from "vue";
|
||||
import { useRouter } from 'vue-router'
|
||||
import record from "./components/record.vue";
|
||||
import countPage from "./components/countPage.vue";
|
||||
import managePage from "./components/managePage.vue";
|
||||
|
||||
const router = useRouter()
|
||||
|
||||
const pageType = ref(1)
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
.container {
|
||||
width: 100vw;
|
||||
height: 100vh;
|
||||
padding: var(--el-font-size-base);
|
||||
background-color: #efefef;
|
||||
}
|
||||
|
||||
.drawer_wrap {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: var(--el-font-size-base);
|
||||
|
||||
.header {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
padding: 0 var(--el-font-size-base);
|
||||
background-color: #fff;
|
||||
padding: var(--el-font-size-base);
|
||||
border-radius: var(--el-font-size-base);
|
||||
|
||||
.left {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: var(--el-font-size-base);
|
||||
|
||||
.return {
|
||||
cursor: pointer;
|
||||
border-radius: 4px;
|
||||
transition: background-color 0.3s;
|
||||
padding: 10px 8px 4px;
|
||||
|
||||
&:hover {
|
||||
background-color: rgba(0, 0, 0, 0.1);
|
||||
}
|
||||
}
|
||||
|
||||
.user_info {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: var(--el-font-size-base);
|
||||
}
|
||||
|
||||
.menu_wrap {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.pay_wrap {
|
||||
flex: 1;
|
||||
background: #fff;
|
||||
border-radius: var(--el-font-size-base);
|
||||
padding: var(--el-font-size-base);
|
||||
}
|
||||
}
|
||||
</style>
|
||||
Reference in New Issue
Block a user