Compare commits
18 Commits
33be9f2cef
...
test
| Author | SHA1 | Date | |
|---|---|---|---|
| da6b45e9e9 | |||
| 6aec434015 | |||
| cb8c9139fe | |||
| d5568c48d0 | |||
| fa67997c86 | |||
| 50a5aeb8e5 | |||
| 1985713f28 | |||
| 8655757dd6 | |||
| 78e88b8eb7 | |||
| 7e03547798 | |||
| c3a20ab2db | |||
| e0aba58651 | |||
| d19e1688a5 | |||
| 23b8db63b8 | |||
| c9cd3a80d9 | |||
| a5fdbd0c13 | |||
| 32d150fd15 | |||
| 5fab9a857a |
12729
dist-electron/main.js
12729
dist-electron/main.js
File diff suppressed because it is too large
Load Diff
181
electron/main.js
181
electron/main.js
@@ -5,6 +5,7 @@ import axios from "axios";
|
|||||||
import os from "os";
|
import os from "os";
|
||||||
import fs from "fs";
|
import fs from "fs";
|
||||||
import { exec } from "child_process";
|
import { exec } from "child_process";
|
||||||
|
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个文件)
|
// 固定的缓存文件路径(永远只存这1个文件)
|
||||||
@@ -106,6 +107,186 @@ app.whenReady().then(() => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// 打印结算小票
|
||||||
|
ipcMain.on('ORDER', async (event, arg) => {
|
||||||
|
try {
|
||||||
|
let _parmas = JSON.parse(arg);
|
||||||
|
// console.log(_parmas);
|
||||||
|
// console.log(_parmas.orderData.carts);
|
||||||
|
await ORDER(_parmas.printerIp, _parmas.orderData);
|
||||||
|
return { ok: true }
|
||||||
|
} catch (e) {
|
||||||
|
console.log(e);
|
||||||
|
return { ok: false, msg: e.message }
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
// 打印交班小票
|
||||||
|
ipcMain.on('printHandoverReceipt', async (event, arg) => {
|
||||||
|
try {
|
||||||
|
let _parmas = JSON.parse(arg);
|
||||||
|
console.log(_parmas);
|
||||||
|
await printHandoverReceipt(_parmas.printerIp, _parmas.handoverData);
|
||||||
|
return { ok: true }
|
||||||
|
} catch (e) {
|
||||||
|
console.log(e);
|
||||||
|
return { ok: false, msg: e.message }
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// 打印退款小票
|
||||||
|
ipcMain.on('REFUND_ORDER', async (event, arg) => {
|
||||||
|
try {
|
||||||
|
let _parmas = JSON.parse(arg);
|
||||||
|
// console.log(_parmas);
|
||||||
|
await REFUND_ORDER(_parmas.printerIp, _parmas.orderData);
|
||||||
|
return { ok: true }
|
||||||
|
} catch (e) {
|
||||||
|
console.log(e);
|
||||||
|
return { ok: false, msg: e.message }
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// 打印退菜单
|
||||||
|
ipcMain.on('RETURN_ORDER', async (event, arg) => {
|
||||||
|
try {
|
||||||
|
let _parmas = JSON.parse(arg);
|
||||||
|
// console.log(_parmas);
|
||||||
|
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);
|
||||||
|
return { ok: false, msg: e.message }
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
app.on("activate", () => {
|
app.on("activate", () => {
|
||||||
// 在 macOS 系统内, 如果没有已开启的应用窗口
|
// 在 macOS 系统内, 如果没有已开启的应用窗口
|
||||||
// 点击托盘图标时通常会重新创建一个新窗口
|
// 点击托盘图标时通常会重新创建一个新窗口
|
||||||
|
|||||||
1760
electron/printService.js
Normal file
1760
electron/printService.js
Normal file
File diff suppressed because it is too large
Load Diff
1161
package-lock.json
generated
1161
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "vite-electron",
|
"name": "vite-electron",
|
||||||
"private": true,
|
"private": true,
|
||||||
"version": "2.0.15",
|
"version": "2.0.27",
|
||||||
"main": "dist-electron/main.js",
|
"main": "dist-electron/main.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "chcp 65001 && vite",
|
"dev": "chcp 65001 && vite",
|
||||||
@@ -19,10 +19,12 @@
|
|||||||
"electron-pos-printer": "^1.3.6",
|
"electron-pos-printer": "^1.3.6",
|
||||||
"electron-pos-printer-vue": "^1.0.9",
|
"electron-pos-printer-vue": "^1.0.9",
|
||||||
"element-plus": "^2.4.3",
|
"element-plus": "^2.4.3",
|
||||||
|
"iconv-lite": "^0.7.2",
|
||||||
"js-md5": "^0.8.3",
|
"js-md5": "^0.8.3",
|
||||||
"lodash": "^4.17.21",
|
"lodash": "^4.17.21",
|
||||||
"pinia": "^2.1.7",
|
"pinia": "^2.1.7",
|
||||||
"pinia-plugin-persistedstate": "^3.2.1",
|
"pinia-plugin-persistedstate": "^3.2.1",
|
||||||
|
"qr-image": "^3.2.0",
|
||||||
"qrcode": "^1.5.3",
|
"qrcode": "^1.5.3",
|
||||||
"reconnecting-websocket": "^4.4.0",
|
"reconnecting-websocket": "^4.4.0",
|
||||||
"speak-tts": "^2.0.8",
|
"speak-tts": "^2.0.8",
|
||||||
@@ -30,13 +32,13 @@
|
|||||||
"uuid": "^10.0.0",
|
"uuid": "^10.0.0",
|
||||||
"vue": "^3.3.8",
|
"vue": "^3.3.8",
|
||||||
"vue-router": "^4.2.5",
|
"vue-router": "^4.2.5",
|
||||||
"ysk-utils": "^1.0.84"
|
"win32-api": "^26.1.2",
|
||||||
|
"ysk-utils": "^1.0.85"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@vitejs/plugin-vue": "^4.5.0",
|
"@vitejs/plugin-vue": "^4.5.0",
|
||||||
"electron": "^28.3.3",
|
"electron": "^28.3.3",
|
||||||
"electron-builder": "^24.13.3",
|
"electron-builder": "^24.13.3",
|
||||||
"electron-rebuild": "^3.2.9",
|
|
||||||
"path": "^0.12.7",
|
"path": "^0.12.7",
|
||||||
"sass": "^1.69.5",
|
"sass": "^1.69.5",
|
||||||
"sass-loader": "^13.3.2",
|
"sass-loader": "^13.3.2",
|
||||||
|
|||||||
BIN
printer.sdk.dll
Normal file
BIN
printer.sdk.dll
Normal file
Binary file not shown.
@@ -317,11 +317,11 @@ export function handoverNetworkPrint(id) {
|
|||||||
export function printerList(subType = "") {
|
export function printerList(subType = "") {
|
||||||
return request({
|
return request({
|
||||||
method: "get",
|
method: "get",
|
||||||
url: "/account/admin/printer",
|
url: "/account/admin/printer/getPrintLocal",
|
||||||
params: {
|
params: {
|
||||||
name: "",
|
name: "",
|
||||||
subType: subType,
|
subType: subType,
|
||||||
connectionType: "USB",
|
connectionType: "",
|
||||||
page: 1,
|
page: 1,
|
||||||
size: 100,
|
size: 100,
|
||||||
},
|
},
|
||||||
|
|||||||
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,
|
||||||
|
});
|
||||||
|
}
|
||||||
@@ -51,3 +51,83 @@ export function markIsSoldOut(data) {
|
|||||||
data,
|
data,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取存酒商品列表
|
||||||
|
* @param {*} params
|
||||||
|
* @returns
|
||||||
|
*/
|
||||||
|
export function storageGoodGet(params) {
|
||||||
|
return request({
|
||||||
|
method: "get",
|
||||||
|
url: "/product/admin/storageGood",
|
||||||
|
params,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 存酒记录添加
|
||||||
|
* @param {*} data
|
||||||
|
* @returns
|
||||||
|
*/
|
||||||
|
export function shopStoragePost(data) {
|
||||||
|
return request({
|
||||||
|
method: "post",
|
||||||
|
url: "/product/admin/shopStorage",
|
||||||
|
data,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 存酒记录
|
||||||
|
* @param {*} data
|
||||||
|
* @returns
|
||||||
|
*/
|
||||||
|
export function shopStorageGet(params) {
|
||||||
|
return request({
|
||||||
|
method: "get",
|
||||||
|
url: "/product/admin/shopStorage",
|
||||||
|
params,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 存酒取酒
|
||||||
|
* @param {*} data
|
||||||
|
* @returns
|
||||||
|
*/
|
||||||
|
export function shopStoragePut(data) {
|
||||||
|
return request({
|
||||||
|
method: "put",
|
||||||
|
url: "/product/admin/shopStorage",
|
||||||
|
data,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询存取酒记录
|
||||||
|
* @param {*} data
|
||||||
|
* @returns
|
||||||
|
*/
|
||||||
|
export function shopStorageRecord(params) {
|
||||||
|
return request({
|
||||||
|
method: "get",
|
||||||
|
url: "/product/admin/shopStorage/record",
|
||||||
|
params,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 耗材库存列表接口
|
||||||
|
* @param {*} data
|
||||||
|
* @returns
|
||||||
|
*/
|
||||||
|
export function consStock(params) {
|
||||||
|
return request({
|
||||||
|
method: "get",
|
||||||
|
url: "/product/admin/product/cons/consStock",
|
||||||
|
params,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import getLodop from "./LodopFuncs.js";
|
|||||||
* 打印交班小票
|
* 打印交班小票
|
||||||
*/
|
*/
|
||||||
export default (data) => {
|
export default (data) => {
|
||||||
console.log("data.deviceName===", data.deviceName);
|
console.log("USB.打印交班小票===", data);
|
||||||
let LODOP = getLodop();
|
let LODOP = getLodop();
|
||||||
LODOP.PRINT_INIT("打印小票");
|
LODOP.PRINT_INIT("打印小票");
|
||||||
// 设置打印纸大小D
|
// 设置打印纸大小D
|
||||||
@@ -19,31 +19,31 @@ export default (data) => {
|
|||||||
交班小票
|
交班小票
|
||||||
</div>
|
</div>
|
||||||
<div style="font-size: 12px;margin-top:50px;">
|
<div style="font-size: 12px;margin-top:50px;">
|
||||||
当班时间:${data.loginTime}
|
当班时间:${data.handoverTime }
|
||||||
</div>
|
</div>
|
||||||
<div style="font-size: 12px;">
|
<div style="font-size: 12px;">
|
||||||
交班时间:${data.handoverTime}
|
交班时间:${data.loginTime || ""} - ${data.handoverTime || ""}
|
||||||
</div>
|
</div>
|
||||||
<div style="font-size: 12px;">
|
<div style="font-size: 12px;">
|
||||||
收银员:${data.staffName}
|
收银员:${data.staffName || ""}
|
||||||
</div>
|
</div>
|
||||||
<div style="font-size: 12px;margin-top: 4px;">
|
<div style="font-size: 12px;margin-top: 4px;">
|
||||||
当班总收入:${data.handAmount}
|
当班总收入:${data.turnover || 0}
|
||||||
</div>
|
</div>
|
||||||
<div style="font-size: 12px;margin-top: 4px;">
|
<div style="font-size: 12px;margin-top: 4px;">
|
||||||
现金收入:${data.cashAmount}
|
现金收入:${data.cash || 0}
|
||||||
</div>
|
</div>
|
||||||
<div style="font-size: 12px;margin-top: 4px;">
|
<div style="font-size: 12px;margin-top: 4px;">
|
||||||
微信收入:${data.wechatAmount}
|
微信收入:${data.wechat || 0}
|
||||||
</div>
|
</div>
|
||||||
<div style="font-size: 12px;margin-top: 4px;">
|
<div style="font-size: 12px;margin-top: 4px;">
|
||||||
支付宝收入:${data.alipayAmount}
|
支付宝收入:${data.alipay || 0}
|
||||||
</div>
|
</div>
|
||||||
<div style="font-size: 12px;margin-top: 4px;">
|
<div style="font-size: 12px;margin-top: 4px;">
|
||||||
会员支付:${data.vipPay}
|
会员支付:${data.balance || 0}
|
||||||
</div>
|
</div>
|
||||||
<div style="font-size: 12px;margin-top: 4px;">
|
<div style="font-size: 12px;margin-top: 4px;">
|
||||||
会员充值:${data.vipRecharge}
|
会员充值:${data.recharge || 0}
|
||||||
</div>
|
</div>
|
||||||
`;
|
`;
|
||||||
|
|
||||||
@@ -86,72 +86,74 @@ export default (data) => {
|
|||||||
`;
|
`;
|
||||||
|
|
||||||
let productCategoriesTableBody = "";
|
let productCategoriesTableBody = "";
|
||||||
if (data.categoryDataList && data.categoryDataList.length) {
|
if (data.categoryList && data.categoryList.length) {
|
||||||
for (let item of data.categoryDataList) {
|
for (let item of data.categoryList) {
|
||||||
productCategoriesTableBody += `
|
productCategoriesTableBody += `
|
||||||
<tr>
|
<tr>
|
||||||
<td style="font-size: 12px;width:50%;">
|
<td style="font-size: 12px;width:50%;">
|
||||||
<div>${item.categoryName}</div>
|
<div>${item.categoryName}</div>
|
||||||
</td>
|
</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%;">
|
<td style="font-size: 12px;width:25%;">
|
||||||
${item.amount}
|
${item.amount || 0}
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let tabHead = `
|
// let tabHead = `
|
||||||
</table>
|
// </table>
|
||||||
<div style="font-size: 12px;margin-top: 4px;">商品数据</div>
|
// <div style="font-size: 12px;margin-top: 4px;">商品数据</div>
|
||||||
<table class="table" style="width: 100%;">
|
// <table class="table" style="width: 100%;">
|
||||||
<tr>
|
// <tr>
|
||||||
<td style="font-size: 12px;width:75%;">商品</td>
|
// <td style="font-size: 12px;width:75%;">商品</td>
|
||||||
<td style="font-size: 12px;width:25%;">数量</td>
|
// <td style="font-size: 12px;width:25%;">数量</td>
|
||||||
</tr>
|
// </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 = "";
|
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 = `
|
let str = `
|
||||||
</table>
|
</table>
|
||||||
<div style="font-size: 12px;margin-top: 4px;">
|
<div style="font-size: 12px;margin-top: 4px;">
|
||||||
<span>快捷收款金额:</span>
|
<span>快捷收款金额:</span>
|
||||||
<span>${data.quickInAmount}</span>
|
<span>${data.barScan || 0}</span>
|
||||||
</div>
|
</div>
|
||||||
<div style="font-size: 12px;">
|
<div style="font-size: 12px;">
|
||||||
<span>退款金额:</span>
|
<span>退款金额:</span>
|
||||||
<span>${data.refundAmount}</span>
|
<span>${data.refundAmount || 0}</span>
|
||||||
</div>
|
</div>
|
||||||
<div style="font-size: 12px;">
|
<div style="font-size: 12px;">
|
||||||
<span>总收入:</span>
|
<span>总收入:</span>
|
||||||
<span>${data.handAmount}</span>
|
<span>${data.turnover || 0}</span>
|
||||||
</div>
|
</div>
|
||||||
<div style="font-size: 12px;">
|
<div style="font-size: 12px;">
|
||||||
<span>挂账金额:</span>
|
<span>挂账金额:</span>
|
||||||
<span>${data.creditAmount}</span>
|
<span>${data.owed || 0}</span>
|
||||||
</div>
|
</div>
|
||||||
<div style="margin-top: 20px; font-size: 12px;">
|
<div style="margin-top: 20px; font-size: 12px;">
|
||||||
<span>总订单数:</span>
|
<span>总订单数:</span>
|
||||||
<span>${data.orderCount}</span>
|
<span>${data.orderCount || 0}</span>
|
||||||
</div>
|
</div>
|
||||||
<div style="font-size: 12px;">
|
<div style="font-size: 12px;">
|
||||||
打印时间:${data.printTime}
|
打印时间:${data.printTime}
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import { formatDecimal } from "@/utils/index.js";
|
|||||||
* 打印订单小票
|
* 打印订单小票
|
||||||
*/
|
*/
|
||||||
export default (data) => {
|
export default (data) => {
|
||||||
// console.log("需要打印的订单数据===", data);
|
console.log("需要打印的订单数据===", data);
|
||||||
// console.log("data.deviceName===", data.deviceName);
|
// console.log("data.deviceName===", data.deviceName);
|
||||||
let LODOP = getLodop();
|
let LODOP = getLodop();
|
||||||
LODOP.PRINT_INIT("打印小票");
|
LODOP.PRINT_INIT("打印小票");
|
||||||
|
|||||||
@@ -48,6 +48,7 @@
|
|||||||
<div class="input_wrap">
|
<div class="input_wrap">
|
||||||
<div class="input" style="flex: 1">付款:¥{{ formatDecimal(goodsStore.cartInfo.costSummary.finalPayAmount
|
<div class="input" style="flex: 1">付款:¥{{ formatDecimal(goodsStore.cartInfo.costSummary.finalPayAmount
|
||||||
|| 0) }}</div>
|
|| 0) }}</div>
|
||||||
|
<!-- <el-button type="warning" style="width: 80px;border-radius: 6px; height: 60px;" @click="applyRounding">抹零</el-button> -->
|
||||||
<el-button type="primary" style="width: 120px;border-radius: 6px; height: 60px;"
|
<el-button type="primary" style="width: 120px;border-radius: 6px; height: 60px;"
|
||||||
@click="showCouponHandle">添加优惠</el-button>
|
@click="showCouponHandle">添加优惠</el-button>
|
||||||
</div>
|
</div>
|
||||||
@@ -139,11 +140,25 @@
|
|||||||
<el-button type="danger" @click="clearCouponUser">清除</el-button>
|
<el-button type="danger" @click="clearCouponUser">清除</el-button>
|
||||||
</div>
|
</div>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="整单折扣">
|
<el-form-item label="优惠金额">
|
||||||
<el-input v-model="couponForm.discountRatio" placeholder="请输入折扣" style="width: 180px;"
|
<div class="column">
|
||||||
@input="discountInput">
|
<div>
|
||||||
|
<el-radio-group v-model="discountType" @change="clearDiscountChange">
|
||||||
|
<el-radio-button label="按金额优惠" :value="1"></el-radio-button>
|
||||||
|
<el-radio-button label="按折扣优惠" :value="2"></el-radio-button>
|
||||||
|
</el-radio-group>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<el-input v-model="couponForm.discountAmount" placeholder="请输入金额" style="width: 239px;"
|
||||||
|
@input="amountDiscountInput" v-if="discountType == 1">
|
||||||
|
<template #append>元</template>
|
||||||
|
</el-input>
|
||||||
|
<el-input v-model="couponForm.discountRatio" placeholder="请输入折扣" style="width: 239px;"
|
||||||
|
@input="discountInput" v-if="discountType == 2">
|
||||||
<template #append>折</template>
|
<template #append>折</template>
|
||||||
</el-input>
|
</el-input>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="优惠券">
|
<el-form-item label="优惠券">
|
||||||
<div style="width: 100%;">
|
<div style="width: 100%;">
|
||||||
@@ -258,6 +273,7 @@ import { staffPermission } from "@/api/user.js";
|
|||||||
import { cashPay, buyerPage, creditPay, vipPay } from "@/api/order.js";
|
import { cashPay, buyerPage, creditPay, vipPay } from "@/api/order.js";
|
||||||
import { calcUsablePoints } from '@/api/account.js'
|
import { calcUsablePoints } from '@/api/account.js'
|
||||||
import { useGoods } from "@/store/goods.js";
|
import { useGoods } from "@/store/goods.js";
|
||||||
|
import { createOrder } from '@/api/order.js';
|
||||||
|
|
||||||
const emit = defineEmits(["paySuccess", 'orderExpired', 'reset']);
|
const emit = defineEmits(["paySuccess", 'orderExpired', 'reset']);
|
||||||
|
|
||||||
@@ -470,13 +486,50 @@ function upadatePayData() {
|
|||||||
newCustomerDiscountId: goodsStore.newUserDiscount !== null ? goodsStore.newUserDiscount.id : goodsStore.newUserDiscount !== null ? goodsStore.newUserDiscount.id : '', // 新客立减Id
|
newCustomerDiscountId: goodsStore.newUserDiscount !== null ? goodsStore.newUserDiscount.id : goodsStore.newUserDiscount !== null ? goodsStore.newUserDiscount.id : '', // 新客立减Id
|
||||||
newCustomerDiscountAmount: goodsStore.newUserDiscount !== null ? goodsStore.newUserDiscount.amount : 0, // 新客立减金额
|
newCustomerDiscountAmount: goodsStore.newUserDiscount !== null ? goodsStore.newUserDiscount.amount : 0, // 新客立减金额
|
||||||
vipDiscountAmount: goodsStore.cartInfo.costSummary.vipDiscountAmount, // 超级会员折扣
|
vipDiscountAmount: goodsStore.cartInfo.costSummary.vipDiscountAmount, // 超级会员折扣
|
||||||
remark: '', // 现金支付备注
|
remark: goodsStore.remark, // 现金支付备注
|
||||||
|
dineMode: goodsStore.allSelected ? store.shopInfo.eatModel.split(',')[1] : store.shopInfo.eatModel.split(',')[0], // 用餐方式
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 结算支付
|
// 结算支付
|
||||||
async function confirmOrder() {
|
async function confirmOrder(t = 1) {
|
||||||
try {
|
try {
|
||||||
|
// if (goodsStore.cartList.length >= 0) {
|
||||||
|
// // 如果购物还存在商品,先下单后进行支付操作
|
||||||
|
// const data = {
|
||||||
|
// orderId: goodsStore.orderListInfo.id || '', // 订单id
|
||||||
|
// shopId: store.shopInfo.id, // 店铺id
|
||||||
|
// seatNum: goodsStore.tableInfo.num || 0, // 用餐人数
|
||||||
|
// packFee: goodsStore.cartInfo.packFee, // 打包费
|
||||||
|
// originAmount: goodsStore.cartInfo.costSummary.goodsOriginalAmount,
|
||||||
|
// tableCode: goodsStore.cartList[0].table_code, // 台桌号
|
||||||
|
// dineMode: goodsStore.allSelected ? store.shopInfo.eatModel.split(',')[1] : store.shopInfo.eatModel.split(',')[0], // 用餐方式
|
||||||
|
// remark: goodsStore.remark, // 备注
|
||||||
|
// placeNum: (goodsStore.orderListInfo.placeNum || 0) + 1, // 下单次数
|
||||||
|
// waitCall: 0, // 是否叫号
|
||||||
|
// userId: goodsStore.vipUserInfo.userId || '', // 会员用户id
|
||||||
|
// limitRate: goodsStore.limitDiscountRes
|
||||||
|
// }
|
||||||
|
|
||||||
|
// // goodsStore.calcCartInfo()
|
||||||
|
// const res = await createOrder(data)
|
||||||
|
// if (res.id) {
|
||||||
|
// // 设置订单信息
|
||||||
|
// // goodsStore.orderListInfo = res
|
||||||
|
// // if (t == 1) {
|
||||||
|
// // // 向其他端发送清空购物车消息
|
||||||
|
// // goodsStore.operateCart({ table_code: goodsStore.orderListInfo.tableCode }, "cleanup");
|
||||||
|
// // console.log('生成订单===', res);
|
||||||
|
// // } else {
|
||||||
|
// // goodsStore.clearCart()
|
||||||
|
// // }
|
||||||
|
// // 清除购物车,更新历史订单
|
||||||
|
// // goodsStore.updateOrderList()
|
||||||
|
// } else {
|
||||||
|
// ElMessage.error('订单成功失败,请重新下单')
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
// 判断订单是否锁定
|
// 判断订单是否锁定
|
||||||
await goodsStore.isOrderLock({
|
await goodsStore.isOrderLock({
|
||||||
table_code: goodsStore.orderListInfo.tableCode
|
table_code: goodsStore.orderListInfo.tableCode
|
||||||
@@ -486,7 +539,6 @@ async function confirmOrder() {
|
|||||||
|
|
||||||
upadatePayData()
|
upadatePayData()
|
||||||
|
|
||||||
|
|
||||||
payType.value = payList.value[payActive.value].payType
|
payType.value = payList.value[payActive.value].payType
|
||||||
if (payList.value[payActive.value].payType == "arrears") {
|
if (payList.value[payActive.value].payType == "arrears") {
|
||||||
showBuyerHandle();
|
showBuyerHandle();
|
||||||
@@ -508,9 +560,9 @@ async function confirmOrder() {
|
|||||||
ElMessageBox.prompt('确定现金支付?', '注意', {
|
ElMessageBox.prompt('确定现金支付?', '注意', {
|
||||||
confirmButtonText: '确定',
|
confirmButtonText: '确定',
|
||||||
cancelButtonText: '取消',
|
cancelButtonText: '取消',
|
||||||
inputPlaceholder: '请输入备注(选填)',
|
inputPlaceholder: goodsStore.remark ? goodsStore.remark : '请输入备注(选填)',
|
||||||
}).then(async ({ value }) => {
|
}).then(async ({ value }) => {
|
||||||
payData.value.checkOrderPay.remark = value;
|
payData.value.checkOrderPay.remark = value ? value : goodsStore.remark;
|
||||||
if (props.selecttype == 0) {
|
if (props.selecttype == 0) {
|
||||||
payLoading.loading = true
|
payLoading.loading = true
|
||||||
await cashPay(payData.value);
|
await cashPay(payData.value);
|
||||||
@@ -576,6 +628,20 @@ function amountInput(num) {
|
|||||||
payData.value.checkOrderPay.orderAmount = money.value;
|
payData.value.checkOrderPay.orderAmount = money.value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 应用抹零
|
||||||
|
function applyRounding() {
|
||||||
|
if (discountAmount.value !== null) {
|
||||||
|
money.value = formatDecimal(discountAmount.value)
|
||||||
|
roundAmount.value = 0
|
||||||
|
} else {
|
||||||
|
money.value = formatDecimal(props.amount)
|
||||||
|
roundAmount.value = 0
|
||||||
|
}
|
||||||
|
|
||||||
|
payData.value.checkOrderPay.roundAmount = roundAmount.value;
|
||||||
|
payData.value.checkOrderPay.orderAmount = money.value;
|
||||||
|
}
|
||||||
|
|
||||||
// 删除
|
// 删除
|
||||||
function delHandle() {
|
function delHandle() {
|
||||||
if (!money.value) return; money.value = money.value.substring(0, money.value.length - 1);
|
if (!money.value) return; money.value = money.value.substring(0, money.value.length - 1);
|
||||||
@@ -718,6 +784,32 @@ function clearCouponUser() {
|
|||||||
// resetCouponFormHandle()
|
// resetCouponFormHandle()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 按照金额优惠
|
||||||
|
const discountType = ref(1)
|
||||||
|
|
||||||
|
// 清除优惠方式变更时的优惠数据
|
||||||
|
function clearDiscountChange() {
|
||||||
|
couponForm.value.discountRatio = ''
|
||||||
|
couponForm.value.discountAmount = ''
|
||||||
|
discountRateNumber.value = 0
|
||||||
|
|
||||||
|
updateCartCalc()
|
||||||
|
}
|
||||||
|
|
||||||
|
const amountDiscountInput = _.debounce(function (e) {
|
||||||
|
couponForm.value.discountAmount = inputFilterFloat(e)
|
||||||
|
if (couponForm.value.discountAmount > goodsStore.cartInfo.costSummary.goodsRealAmount) {
|
||||||
|
couponForm.value.discountAmount = goodsStore.cartInfo.costSummary.goodsRealAmount
|
||||||
|
}
|
||||||
|
if (couponForm.value.discountAmount < 0) {
|
||||||
|
couponForm.value.discountAmount = 0
|
||||||
|
}
|
||||||
|
|
||||||
|
discountRateNumber.value = couponForm.value.discountAmount
|
||||||
|
|
||||||
|
updateCartCalc()
|
||||||
|
}, 500)
|
||||||
|
|
||||||
// 折扣格式化
|
// 折扣格式化
|
||||||
const discountRateNumber = ref(0)
|
const discountRateNumber = ref(0)
|
||||||
const discountInput = _.debounce(function (e) {
|
const discountInput = _.debounce(function (e) {
|
||||||
@@ -1251,6 +1343,12 @@ defineExpose({
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped lang="scss">
|
<style scoped lang="scss">
|
||||||
|
.column {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
.point_tips {
|
.point_tips {
|
||||||
&.err {
|
&.err {
|
||||||
color: var(--el-color-danger);
|
color: var(--el-color-danger);
|
||||||
|
|||||||
@@ -129,14 +129,11 @@ async function submitHandleAjax() {
|
|||||||
console.log('props.selecttype===', props.selecttype);
|
console.log('props.selecttype===', props.selecttype);
|
||||||
console.log('props.payType===', props.payType);
|
console.log('props.payType===', props.payType);
|
||||||
|
|
||||||
// return;
|
if (props.selecttype == 0) {
|
||||||
|
|
||||||
// 判断订单是否锁定
|
// 判断订单是否锁定
|
||||||
await goodsStore.isOrderLock({
|
await goodsStore.isOrderLock({
|
||||||
table_code: goodsStore.orderListInfo.tableCode
|
table_code: goodsStore.orderListInfo.tableCode
|
||||||
})
|
})
|
||||||
|
|
||||||
if (props.selecttype == 0) {
|
|
||||||
// 下单扫码支付
|
// 下单扫码支付
|
||||||
if (props.payType == 'scanCode') {
|
if (props.payType == 'scanCode') {
|
||||||
await microPay({
|
await microPay({
|
||||||
@@ -151,6 +148,7 @@ async function submitHandleAjax() {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
} else if (props.selecttype == 1) {
|
} else if (props.selecttype == 1) {
|
||||||
|
console.log('进入会员扫码充值');
|
||||||
// 会员扫码充值
|
// 会员扫码充值
|
||||||
await microPayVip({
|
await microPayVip({
|
||||||
shopId: store.shopInfo.id,
|
shopId: store.shopInfo.id,
|
||||||
|
|||||||
83
src/components/refundConsModal.vue
Normal file
83
src/components/refundConsModal.vue
Normal file
@@ -0,0 +1,83 @@
|
|||||||
|
<template>
|
||||||
|
<el-dialog title="提示" width="450px" v-model="visible">
|
||||||
|
<div class="refund_content">
|
||||||
|
<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>x{{ item.num }}</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="dialog_footer">
|
||||||
|
<div class="btn">
|
||||||
|
<el-button @click="handleCancel" style="width: 100%;">未上菜(退还库存)</el-button>
|
||||||
|
</div>
|
||||||
|
<div class="btn">
|
||||||
|
<el-button type="primary" @click="handleOk" style="width: 100%;">已上菜(不退库存)</el-button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</el-dialog>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup>
|
||||||
|
import { ref } from 'vue'
|
||||||
|
|
||||||
|
const visible = ref(false)
|
||||||
|
|
||||||
|
const props = defineProps({
|
||||||
|
list: {
|
||||||
|
type: Array,
|
||||||
|
default: () => []
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
const emits = defineEmits(['success'])
|
||||||
|
|
||||||
|
// 未上菜 1退菜图库存
|
||||||
|
function handleCancel() {
|
||||||
|
visible.value = false
|
||||||
|
emits('success', 1)
|
||||||
|
}
|
||||||
|
|
||||||
|
// 已上菜 2仅退菜不退库存
|
||||||
|
function handleOk() {
|
||||||
|
visible.value = false
|
||||||
|
emits('success', 2)
|
||||||
|
}
|
||||||
|
|
||||||
|
function show() {
|
||||||
|
visible.value = true
|
||||||
|
}
|
||||||
|
|
||||||
|
defineExpose({
|
||||||
|
show
|
||||||
|
})
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style scoped lang="scss">
|
||||||
|
.refund_content {
|
||||||
|
.title_wrap {
|
||||||
|
font-size: 16px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.list_wrap {
|
||||||
|
padding-top: 14px;
|
||||||
|
.item {
|
||||||
|
display: flex;
|
||||||
|
justify-content: space-between;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.dialog_footer {
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
gap: 20px;
|
||||||
|
padding-top: 20px;
|
||||||
|
|
||||||
|
.btn {
|
||||||
|
flex: 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@@ -18,7 +18,7 @@
|
|||||||
<span class="i">¥</span>
|
<span class="i">¥</span>
|
||||||
<span class="n">{{ formatDecimal(+goodsInfo.salePrice) }}</span>
|
<span class="n">{{ formatDecimal(+goodsInfo.salePrice) }}</span>
|
||||||
</div>
|
</div>
|
||||||
<span>库存:{{ stockNumber }}</span>
|
<span>库存:{{ stockNumber || 0 }}</span>
|
||||||
</div>
|
</div>
|
||||||
<div class="btn_wrap">
|
<div class="btn_wrap">
|
||||||
<div class="btn">
|
<div class="btn">
|
||||||
|
|||||||
@@ -119,46 +119,20 @@ export const useGlobal = defineStore("global", {
|
|||||||
},
|
},
|
||||||
],
|
],
|
||||||
bizCodes: [
|
bizCodes: [
|
||||||
{
|
{ type: "cashIn", label: "会员充值" },
|
||||||
type: "freeln",
|
{ type: "cashback", label: "消费返现" },
|
||||||
label: "霸王餐",
|
{ type: "cashback_refund", label: "消费返现扣减" },
|
||||||
},
|
{ type: "freeIn", label: "霸王餐充值" },
|
||||||
{
|
{ type: "awardIn", label: "充值奖励" },
|
||||||
type: "cashIn",
|
{ type: "wechatIn", label: "微信小程序充值" },
|
||||||
label: "现金充值",
|
{ type: "alipayIn", label: "支付宝小程序充值" },
|
||||||
},
|
{ type: "orderPay", label: "订单支付奖励" },
|
||||||
{
|
{ type: "orderRefund", label: "订单退款" },
|
||||||
type: "wechatIn",
|
{ type: "rechargeRefund", label: "充值退款" },
|
||||||
label: "微信小程序充值",
|
{ type: "rechargeCashRefund", label: "会员现金退款" },
|
||||||
},
|
{ type: "adminIn", label: "管理员手动增减余额" },
|
||||||
{
|
{ type: "adminOut", label: "管理员退款充值" },
|
||||||
type: "alipayIn",
|
{ type: "rechargeRedemption", label: "充值兑换码" }
|
||||||
label: "支付宝小程序充值",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
type: "awardIn",
|
|
||||||
label: "充值奖励",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
type: "rechargeRefund",
|
|
||||||
label: "充值退款",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
type: "orderPay",
|
|
||||||
label: "订单消费",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
type: "orderRefund",
|
|
||||||
label: "订单退款",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
type: "adminIn",
|
|
||||||
label: "管理员充值",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
type: "adminOut",
|
|
||||||
label: "管理员消费",
|
|
||||||
},
|
|
||||||
],
|
],
|
||||||
refundType: [
|
refundType: [
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import _ from "lodash";
|
|||||||
import dayjs from "dayjs";
|
import dayjs from "dayjs";
|
||||||
import { defineStore } from "pinia";
|
import { defineStore } from "pinia";
|
||||||
import { ref, computed, nextTick } from "vue";
|
import { ref, computed, nextTick } from "vue";
|
||||||
import { productPage, categoryList } from "@/api/product_new.js";
|
import { productPage, categoryList, consStock } from "@/api/product_new.js";
|
||||||
import { historyOrder, cancelOrder, rmPlaceOrder } from "@/api/order.js";
|
import { historyOrder, cancelOrder, rmPlaceOrder } from "@/api/order.js";
|
||||||
import { getLimitTimeDiscount, getDiscountActivity, getDiscountByUserId } from '@/api/market'
|
import { getLimitTimeDiscount, getDiscountActivity, getDiscountByUserId } from '@/api/market'
|
||||||
import { useUser } from "@/store/user.js";
|
import { useUser } from "@/store/user.js";
|
||||||
@@ -36,6 +36,7 @@ const initialCostSummary = {
|
|||||||
// 商品store + 购物车store
|
// 商品store + 购物车store
|
||||||
export const useGoods = defineStore("goods", {
|
export const useGoods = defineStore("goods", {
|
||||||
state: () => ({
|
state: () => ({
|
||||||
|
remark: "", // 订单备注
|
||||||
showVipPrice: 0,
|
showVipPrice: 0,
|
||||||
allSelected: 0, // 是否整单打包
|
allSelected: 0, // 是否整单打包
|
||||||
vipUserInfo: {}, // 会员信息
|
vipUserInfo: {}, // 会员信息
|
||||||
@@ -46,6 +47,7 @@ export const useGoods = defineStore("goods", {
|
|||||||
}, // 台桌信息
|
}, // 台桌信息
|
||||||
cartActiveIndex: 0, // 购物车激活索引,
|
cartActiveIndex: 0, // 购物车激活索引,
|
||||||
isCartInit: false,
|
isCartInit: false,
|
||||||
|
payType: "cart", // 结算类型,cart 购物车结算 table 桌台结算 order 订单结算,
|
||||||
cartList: [], // 购物车列表
|
cartList: [], // 购物车列表
|
||||||
// 购物车信息,
|
// 购物车信息,
|
||||||
cartInfo: {
|
cartInfo: {
|
||||||
@@ -60,6 +62,7 @@ export const useGoods = defineStore("goods", {
|
|||||||
goodsListLoading: false, // 商品列表加载状态
|
goodsListLoading: false, // 商品列表加载状态
|
||||||
goodsList: [], // 商品列表
|
goodsList: [], // 商品列表
|
||||||
originGoodsList: [], // 原始商品列表
|
originGoodsList: [], // 原始商品列表
|
||||||
|
consList: [], // 耗材列表
|
||||||
orderList: [], // 订单列表
|
orderList: [], // 订单列表
|
||||||
orderListInfo: "", // 历史订单信息
|
orderListInfo: "", // 历史订单信息
|
||||||
cartType: "cart", // cart order
|
cartType: "cart", // cart order
|
||||||
@@ -86,7 +89,6 @@ export const useGoods = defineStore("goods", {
|
|||||||
// 清除会员信息
|
// 清除会员信息
|
||||||
async clearVipUserInfo() {
|
async clearVipUserInfo() {
|
||||||
// console.log('清除会员信息');
|
// console.log('清除会员信息');
|
||||||
|
|
||||||
this.vipUserInfo = {};
|
this.vipUserInfo = {};
|
||||||
this.showVipPrice = 0;
|
this.showVipPrice = 0;
|
||||||
|
|
||||||
@@ -302,8 +304,18 @@ export const useGoods = defineStore("goods", {
|
|||||||
console.log(error);
|
console.log(error);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
// 耗材库存列表接口
|
||||||
|
async consStockAjax() {
|
||||||
|
try {
|
||||||
|
const store = useUser()
|
||||||
|
this.consList = await consStock({ shopId: store.shopInfo.id })
|
||||||
|
} catch (error) {
|
||||||
|
console.log(error);
|
||||||
|
}
|
||||||
|
},
|
||||||
// 初始化商品
|
// 初始化商品
|
||||||
async initGoods() {
|
async initGoods() {
|
||||||
|
await this.consStockAjax()
|
||||||
await this.getCategoryList();
|
await this.getCategoryList();
|
||||||
await this.getGoodsList();
|
await this.getGoodsList();
|
||||||
|
|
||||||
@@ -371,6 +383,50 @@ export const useGoods = defineStore("goods", {
|
|||||||
console.log(error);
|
console.log(error);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
/**
|
||||||
|
* 给商品列表批量添加 isSoldOut 售罄状态字段
|
||||||
|
* @param {Array} goodsList - 商品列表 [ { consList, isAutoSoldStock } ]
|
||||||
|
* @param {Array} consStockList - 真实耗材库存列表 [ { consId, stockNumber } ]
|
||||||
|
* @returns 带 isSoldOut 字段的新商品列表
|
||||||
|
*/
|
||||||
|
addGoodsSoldOutStatus(goodsList, consStockList) {
|
||||||
|
// console.log('addGoodsSoldOutStatus.goodsList', goodsList);
|
||||||
|
// console.log('addGoodsSoldOutStatus.consStockList', consStockList);
|
||||||
|
|
||||||
|
// 耗材ID映射真实库存(保留)
|
||||||
|
const consMap = _.keyBy(consStockList, item => String(item.consId));
|
||||||
|
|
||||||
|
return _.map(goodsList, goods => {
|
||||||
|
let isSoldOut = false;
|
||||||
|
|
||||||
|
// 开启自动售罄才判断
|
||||||
|
if (goods.isAutoSoldStock === 1 || goods.isAutoSoldStock === true) {
|
||||||
|
const goodsConsList = goods.consList || [];
|
||||||
|
|
||||||
|
// 无耗材 → 不售罄
|
||||||
|
if (goodsConsList.length === 0) {
|
||||||
|
isSoldOut = false;
|
||||||
|
} else {
|
||||||
|
// 核心:只要有一个耗材 真实库存 < 商品需要量 → 售罄
|
||||||
|
isSoldOut = _.some(goodsConsList, consItem => {
|
||||||
|
// 商品绑定的耗材ID(对应真实库存ID)
|
||||||
|
const consId = String(consItem.consInfoId);
|
||||||
|
// 商品需要消耗的数量(你的需求量)
|
||||||
|
const needStock = consItem.surplusStock || 0;
|
||||||
|
// 起售数量
|
||||||
|
const suitNum = goods.type == 'single' ? goods.skuList[0].suitNum : 1;
|
||||||
|
// 真实库存
|
||||||
|
const realStock = _.get(consMap, [consId, 'stockNumber'], 0);
|
||||||
|
|
||||||
|
// 真实库存 < 需要量 → 不足 → 售罄
|
||||||
|
return realStock < needStock * suitNum;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return { ...goods, isSoldOut };
|
||||||
|
});
|
||||||
|
},
|
||||||
// 获取商品列表/更新商品列表
|
// 获取商品列表/更新商品列表
|
||||||
async getGoodsList() {
|
async getGoodsList() {
|
||||||
try {
|
try {
|
||||||
@@ -386,7 +442,11 @@ export const useGoods = defineStore("goods", {
|
|||||||
name: this.goodsName,
|
name: this.goodsName,
|
||||||
});
|
});
|
||||||
|
|
||||||
this.originGoodsList = await productPage();
|
let ores = await productPage();
|
||||||
|
|
||||||
|
this.originGoodsList = this.addGoodsSoldOutStatus(ores, this.consList)
|
||||||
|
|
||||||
|
console.log('添加库存售罄的商品原始数据', this.originGoodsList);
|
||||||
|
|
||||||
// 获取限时折扣
|
// 获取限时折扣
|
||||||
this.limitDiscountRes = await getLimitTimeDiscount({ shopId: store.shopInfo.id })
|
this.limitDiscountRes = await getLimitTimeDiscount({ shopId: store.shopInfo.id })
|
||||||
@@ -441,18 +501,6 @@ export const useGoods = defineStore("goods", {
|
|||||||
|
|
||||||
this.goodsList.forEach(val => {
|
this.goodsList.forEach(val => {
|
||||||
val.forEach((item, index) => {
|
val.forEach((item, index) => {
|
||||||
// console.log('this.goodsList.index', index);
|
|
||||||
// console.log('this.goodsList.item', item);
|
|
||||||
// console.log('this.goodsList.limitDiscountRes', this.limitDiscountRes);
|
|
||||||
// console.log('this.goodsList.store.shopInfo', store.shopInfo);
|
|
||||||
// console.log('this.goodsList.this.vipUserInfo', this.vipUserInfo);
|
|
||||||
// console.log('this.goodsList.this.vipUserInfo', JSON.stringify(this.vipUserInfo));
|
|
||||||
// console.log('this.goodsList.this.canUseLimitTimeDiscount', limitUtils.canUseLimitTimeDiscount(item,
|
|
||||||
// this.limitDiscountRes,
|
|
||||||
// store.shopInfo,
|
|
||||||
// this.vipUserInfo, 'id'));
|
|
||||||
|
|
||||||
|
|
||||||
item.showMore = false;
|
item.showMore = false;
|
||||||
item.orderCount = 0;
|
item.orderCount = 0;
|
||||||
item.memberPrice = item.lowMemberPrice
|
item.memberPrice = item.lowMemberPrice
|
||||||
@@ -889,8 +937,12 @@ export const useGoods = defineStore("goods", {
|
|||||||
.map((item) => item.goods)
|
.map((item) => item.goods)
|
||||||
.flat()
|
.flat()
|
||||||
.map(this.comleteOrderInfo);
|
.map(this.comleteOrderInfo);
|
||||||
|
if (this.payType == 'table' || this.payType == 'order') {
|
||||||
|
return [...giftGoods, ...oldOrderGoods];
|
||||||
|
} else {
|
||||||
return [...currentGoods, ...giftGoods, ...oldOrderGoods];
|
return [...currentGoods, ...giftGoods, ...oldOrderGoods];
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// 合并所有商品列表
|
// 合并所有商品列表
|
||||||
const allGoods = ref(getAllGoodsList() || [])
|
const allGoods = ref(getAllGoodsList() || [])
|
||||||
|
|||||||
1136
src/store/print.js
1136
src/store/print.js
File diff suppressed because it is too large
Load Diff
270
src/store/print20260331.js
Normal file
270
src/store/print20260331.js
Normal file
@@ -0,0 +1,270 @@
|
|||||||
|
import { defineStore } from "pinia";
|
||||||
|
import { ipcRenderer } from "electron";
|
||||||
|
import { useUser } from "@/store/user.js";
|
||||||
|
import dayjs from "dayjs";
|
||||||
|
import receiptPrint from "@/components/lodop/receiptPrint.js";
|
||||||
|
import lodopPrintWork from "@/components/lodop/lodopPrintWork.js";
|
||||||
|
import invoicePrint from "@/components/lodop/invoicePrint.js";
|
||||||
|
import refundPrint from "@/components/lodop/refundPrint.js";
|
||||||
|
import { printerList } from "@/api/account.js";
|
||||||
|
import { useSocket } from './socket.js';
|
||||||
|
|
||||||
|
export const usePrint = defineStore("print", {
|
||||||
|
state: () => ({
|
||||||
|
isPrintService: false, // 打印服务是否启动
|
||||||
|
printServiceTimer: false, // 打印服务定时器
|
||||||
|
printServiceTimerCount: 0, // 打印服务定时器计数
|
||||||
|
printServiceTimerMaxCount: 10, // 打印服务定时器最大计数
|
||||||
|
showPrintNotService: false, // 是否显示重启软件,
|
||||||
|
localDevices: [], // 本地打印机列表
|
||||||
|
deviceNoteList: [], // 添加的打印机
|
||||||
|
deviceLableList: [], // 添加的打印机
|
||||||
|
labelList: [], // 要打印的队列数据
|
||||||
|
printTimer: null,
|
||||||
|
receiptList: [], // 小票队列数据
|
||||||
|
receiptTimer: null,
|
||||||
|
}),
|
||||||
|
actions: {
|
||||||
|
// 获取本地打印机和已添加的可以用打印机列表
|
||||||
|
async init() {
|
||||||
|
// 获取本地打印机
|
||||||
|
ipcRenderer.send("getPrintList");
|
||||||
|
ipcRenderer.on("printList", (event, arg) => {
|
||||||
|
this.localDevices = arg;
|
||||||
|
});
|
||||||
|
|
||||||
|
try {
|
||||||
|
// 获取已添加的打印机
|
||||||
|
const res = await printerList();
|
||||||
|
this.deviceNoteList = res.records.filter(
|
||||||
|
(item) => item.status && item.subType == "cash"
|
||||||
|
);
|
||||||
|
this.deviceLableList = res.records.filter(
|
||||||
|
(item) => item.status && item.subType == "label"
|
||||||
|
);
|
||||||
|
console.log("打印队列初始化成功", {
|
||||||
|
deviceNoteList: this.deviceNoteList,
|
||||||
|
deviceLableList: this.deviceLableList,
|
||||||
|
});
|
||||||
|
} catch (error) {
|
||||||
|
console.error("获取已添加的打印机列表失败", error);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 检测打印服务是否启动
|
||||||
|
this.checkPrintService();
|
||||||
|
},
|
||||||
|
// 检测打印组件服务是否启动
|
||||||
|
checkPrintService() {
|
||||||
|
this.printServiceTimer = setInterval(() => {
|
||||||
|
if (
|
||||||
|
typeof LODOP !== "undefined" &&
|
||||||
|
LODOP.webskt &&
|
||||||
|
LODOP.webskt.readyState == 1
|
||||||
|
) {
|
||||||
|
// 准备好
|
||||||
|
this.isPrintService = true;
|
||||||
|
clearInterval(this.printServiceTimer);
|
||||||
|
this.printServiceTimer = null;
|
||||||
|
} else {
|
||||||
|
this.printServiceTimerCount++;
|
||||||
|
console.log("打印服务未启动", this.printServiceTimerCount);
|
||||||
|
|
||||||
|
if (this.printServiceTimerCount >= this.printServiceTimerMaxCount) {
|
||||||
|
// 超过最大次数
|
||||||
|
this.isPrintService = false;
|
||||||
|
this.showPrintNotService = true;
|
||||||
|
clearInterval(this.printServiceTimer);
|
||||||
|
this.printServiceTimer = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
console.log("打印服务是否启动:", this.isPrintService);
|
||||||
|
}, 1000);
|
||||||
|
},
|
||||||
|
// 检查本地打印机是否能正常使用
|
||||||
|
checkLocalPrint(address) {
|
||||||
|
let print = "";
|
||||||
|
for (let item of this.localDevices) {
|
||||||
|
if (item.name == address) {
|
||||||
|
print = item;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!print.name) {
|
||||||
|
return false;
|
||||||
|
} else {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
// 打印标签小票
|
||||||
|
labelPrint(props) {
|
||||||
|
const store = useUser();
|
||||||
|
|
||||||
|
if (
|
||||||
|
this.deviceLableList.length &&
|
||||||
|
this.checkLocalPrint(this.deviceLableList[0].address)
|
||||||
|
) {
|
||||||
|
let pids = this.deviceLableList[0].categoryList;
|
||||||
|
let count = 0;
|
||||||
|
let sum = 0;
|
||||||
|
|
||||||
|
props.carts.map((item) => {
|
||||||
|
if (pids.some((el) => el == item.categoryId)) {
|
||||||
|
for (let i = 0; i < item.number; i++) {
|
||||||
|
sum++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
props.carts.map((item) => {
|
||||||
|
if (pids.some((el) => el == item.categoryId)) {
|
||||||
|
for (let i = 0; i < item.number; i++) {
|
||||||
|
count++;
|
||||||
|
this.labelList.push({
|
||||||
|
outNumber: props.outNumber,
|
||||||
|
name: item.name,
|
||||||
|
skuName: item.skuName,
|
||||||
|
masterId: props.orderInfo.tableName,
|
||||||
|
deviceName: this.deviceLableList[0].address,
|
||||||
|
createdAt: dayjs(props.createdAt).format("YYYY-MM-DD HH:mm:ss"),
|
||||||
|
isPrint: false,
|
||||||
|
count: `${count}/${sum}`,
|
||||||
|
ticketLogo: store.shopInfo.ticketLogo,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
console.log("this.labelList===", this.labelList);
|
||||||
|
// return;
|
||||||
|
|
||||||
|
// 执行打印操作
|
||||||
|
this.startLabelPrint();
|
||||||
|
} else {
|
||||||
|
console.log("标签打印:未在本机查询到打印机");
|
||||||
|
}
|
||||||
|
},
|
||||||
|
// 开始打印标签数据
|
||||||
|
startLabelPrint() {
|
||||||
|
if (this.printTimer != null) return;
|
||||||
|
this.printTimer = setInterval(() => {
|
||||||
|
let item = "";
|
||||||
|
if (!this.labelList.length) {
|
||||||
|
clearInterval(this.printTimer);
|
||||||
|
this.printTimer = null;
|
||||||
|
} else {
|
||||||
|
item = this.labelList[0];
|
||||||
|
if (!item.isPrint) {
|
||||||
|
ipcRenderer.send("printerTagSync", JSON.stringify(item));
|
||||||
|
this.labelList[0].isPrint = true;
|
||||||
|
this.labelList.splice(0, 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, 2000);
|
||||||
|
},
|
||||||
|
// 添加小票打印队列数据
|
||||||
|
pushReceiptData(props, isDevice = true) {
|
||||||
|
// console.log("pushReceiptData===", props);
|
||||||
|
if (!isDevice) {
|
||||||
|
// 测试打印,无需校验本地打印机
|
||||||
|
this.receiptList.push(props);
|
||||||
|
this.startReceiptPrint();
|
||||||
|
} else {
|
||||||
|
if (
|
||||||
|
this.deviceNoteList.length &&
|
||||||
|
this.checkLocalPrint(this.deviceNoteList[0].address) &&
|
||||||
|
this.isPrintService
|
||||||
|
) {
|
||||||
|
const store = useUser();
|
||||||
|
props.deviceId = this.deviceNoteList[0].id;
|
||||||
|
props.deviceName = this.deviceNoteList[0].address;
|
||||||
|
props.shop_name = store.shopInfo.shopName;
|
||||||
|
props.loginAccount = store.userInfo.name;
|
||||||
|
props.createdAt = dayjs(props.createdAt).format(
|
||||||
|
"YYYY-MM-DD HH:mm:ss"
|
||||||
|
);
|
||||||
|
props.printTime = dayjs().format("YYYY-MM-DD HH:mm:ss");
|
||||||
|
if (!props.orderInfo.masterId) {
|
||||||
|
props.orderInfo.masterId = props.orderInfo.tableName;
|
||||||
|
}
|
||||||
|
props.orderInfo.outNumber = props.outNumber;
|
||||||
|
if (!props.discountAmount) {
|
||||||
|
props.discountAmount = props.amount;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.receiptList.push(props);
|
||||||
|
this.startReceiptPrint();
|
||||||
|
} else {
|
||||||
|
console.log("订单小票:未在本机查询到打印机");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
// 开始打印小票
|
||||||
|
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;
|
||||||
|
} else {
|
||||||
|
receiptPrint(this.receiptList[0]);
|
||||||
|
// 在这里触发已打印操作标记
|
||||||
|
const data = {
|
||||||
|
type: "cashier",
|
||||||
|
operate_type: "order_print_status",
|
||||||
|
table_code: this.receiptList[0].orderInfo.tableCode,
|
||||||
|
account: userStore.shopInfo.account,
|
||||||
|
print_status: "1",
|
||||||
|
order_id: this.receiptList[0].orderInfo.id,
|
||||||
|
print_id: this.receiptList[0].deviceId,
|
||||||
|
shop_id: this.receiptList[0].orderInfo.shopId,
|
||||||
|
}
|
||||||
|
socketStore.ws.send(JSON.stringify(data));
|
||||||
|
this.receiptList.splice(0, 1);
|
||||||
|
}
|
||||||
|
}, 2000);
|
||||||
|
} catch (error) {
|
||||||
|
console.log(error);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
// 打印交班小票
|
||||||
|
printWork(data) {
|
||||||
|
if (
|
||||||
|
this.deviceNoteList.length &&
|
||||||
|
this.checkLocalPrint(this.deviceNoteList[0].address)
|
||||||
|
) {
|
||||||
|
data.deviceName = this.deviceNoteList[0].address;
|
||||||
|
lodopPrintWork(data);
|
||||||
|
} else {
|
||||||
|
console.log("交班小票:未在本机查询到打印机");
|
||||||
|
}
|
||||||
|
},
|
||||||
|
// 打印订单发票
|
||||||
|
printInvoice(data) {
|
||||||
|
if (
|
||||||
|
this.deviceNoteList.length &&
|
||||||
|
this.checkLocalPrint(this.deviceNoteList[0].address)
|
||||||
|
) {
|
||||||
|
data.deviceName = this.deviceNoteList[0].address;
|
||||||
|
invoicePrint(data);
|
||||||
|
} else {
|
||||||
|
console.log("订单发票:未在本机查询到打印机");
|
||||||
|
}
|
||||||
|
},
|
||||||
|
// 打印退单小票
|
||||||
|
printRefund(data) {
|
||||||
|
if (
|
||||||
|
this.deviceNoteList.length &&
|
||||||
|
this.checkLocalPrint(this.deviceNoteList[0].address)
|
||||||
|
) {
|
||||||
|
data.deviceName = this.deviceNoteList[0].address;
|
||||||
|
refundPrint(data);
|
||||||
|
} else {
|
||||||
|
console.log("退单小票:未在本机查询到打印机");
|
||||||
|
}
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
@@ -7,6 +7,7 @@ import ReconnectingWebSocket from "reconnecting-websocket";
|
|||||||
import { useGoods } from "@/store/goods.js";
|
import { useGoods } from "@/store/goods.js";
|
||||||
import { ElMessage } from "element-plus";
|
import { ElMessage } from "element-plus";
|
||||||
import { getOrderByIdAjax, commOrderPrintData } from "@/utils/index.js";
|
import { getOrderByIdAjax, commOrderPrintData } from "@/utils/index.js";
|
||||||
|
import { printData } from '@/api/print.js'
|
||||||
|
|
||||||
export const useSocket = defineStore("socket", {
|
export const useSocket = defineStore("socket", {
|
||||||
state: () => ({
|
state: () => ({
|
||||||
@@ -17,8 +18,236 @@ export const useSocket = defineStore("socket", {
|
|||||||
orderListTimer: null,
|
orderListTimer: null,
|
||||||
log: false,
|
log: false,
|
||||||
isPrinting: false,
|
isPrinting: false,
|
||||||
|
// 新增:其他打印任务队列与状态锁
|
||||||
|
printQueue: [],
|
||||||
|
isProcessing: false
|
||||||
}),
|
}),
|
||||||
actions: {
|
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
|
// 关闭ws
|
||||||
close() {
|
close() {
|
||||||
if (this.log) console.log("关闭ws");
|
if (this.log) console.log("关闭ws");
|
||||||
@@ -112,11 +341,61 @@ export const useSocket = defineStore("socket", {
|
|||||||
switch (data.operate_type) {
|
switch (data.operate_type) {
|
||||||
case "add":
|
case "add":
|
||||||
// 添加购物车商品
|
// 添加购物车商品
|
||||||
|
{
|
||||||
|
// console.log('socket终极操作数据.add===', data.data);
|
||||||
|
const cartItem = goodsStore.cartList.find(item => item.id == data.data.id) || { number: 0 }
|
||||||
|
// console.log('socket终极操作数据.cartItem===', cartItem);
|
||||||
|
let arr = []
|
||||||
|
goodsStore.orderList.forEach(item => {
|
||||||
|
arr.push(...item.goods)
|
||||||
|
})
|
||||||
|
const isExist = _.some(arr, item => Number(item.productId) === data.data.product_id)
|
||||||
|
|
||||||
|
if (data.data.number == 1 && data.data.number > cartItem.number) {
|
||||||
|
if (isExist) {
|
||||||
|
ElMessage({
|
||||||
|
type: 'warning',
|
||||||
|
message: '该商品已下单过,请确认是否重复',
|
||||||
|
duration: 4000
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
goodsStore.successAddCart(data.data);
|
goodsStore.successAddCart(data.data);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case "edit":
|
case "edit":
|
||||||
|
{
|
||||||
// 编辑购物车商品
|
// 编辑购物车商品
|
||||||
|
// console.log('socket终极操作数据.edit===', data.data);
|
||||||
|
|
||||||
|
const cartItem = goodsStore.cartList.find(item => item.id == data.data.id)
|
||||||
|
|
||||||
|
// console.log('socket终极操作数据.cartItem===', cartItem);
|
||||||
|
|
||||||
|
let arr = []
|
||||||
|
goodsStore.orderList.forEach(item => {
|
||||||
|
arr.push(...item.goods)
|
||||||
|
})
|
||||||
|
const isExist = _.some(arr, item => Number(item.productId) === data.data.product_id)
|
||||||
|
|
||||||
|
if (data.data.number == 2 && data.data.number > cartItem.number) {
|
||||||
|
if (isExist) {
|
||||||
|
ElMessage({
|
||||||
|
type: 'warning',
|
||||||
|
message: '该商品已下单过,请确认是否重复',
|
||||||
|
duration: 4000
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
ElMessage({
|
||||||
|
type: 'warning',
|
||||||
|
message: '购物车已有该商品,请确认是否重复',
|
||||||
|
duration: 4000
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
goodsStore.successEditCart(data.data);
|
goodsStore.successEditCart(data.data);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case "del":
|
case "del":
|
||||||
// 删除购物车商品
|
// 删除购物车商品
|
||||||
@@ -169,11 +448,21 @@ export const useSocket = defineStore("socket", {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (data.data_type == "order") {
|
} 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("_");
|
let orderInfo = data.data.split("_");
|
||||||
let orderId = orderInfo[0]; // 订单ID
|
let orderId = orderInfo[0]; // 订单ID
|
||||||
let orderModel = orderInfo[1]; // 订单类型
|
let orderModel = orderInfo[1]; // 订单类型
|
||||||
let orderStatus = orderInfo[2]; // 订单状态
|
let orderStatus = orderInfo[2]; // 订单ID_先付后付(1先付0后付)_订单状态 0未完成 1完成_第几次下单
|
||||||
|
let placeNum = orderInfo[3]; // 下单次数
|
||||||
|
|
||||||
let printList = useStorage.get("printList") || [];
|
let printList = useStorage.get("printList") || [];
|
||||||
|
|
||||||
@@ -189,9 +478,44 @@ export const useSocket = defineStore("socket", {
|
|||||||
this.orderList.push(orderId);
|
this.orderList.push(orderId);
|
||||||
this.startPrintInterval();
|
this.startPrintInterval();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 防止重复打印客看单
|
||||||
|
if (orderStatus == 0) {
|
||||||
|
getOrderByIdAjax(orderId).then(res => {
|
||||||
|
let originOrderInfo = res
|
||||||
|
originOrderInfo.detailMap = _.at(originOrderInfo.detailMap, placeNum);
|
||||||
|
|
||||||
|
console.log('originOrderInfo', originOrderInfo);
|
||||||
|
|
||||||
|
let amout = 0
|
||||||
|
originOrderInfo.detailMap.flat().forEach(item => {
|
||||||
|
amout += item.num * item.unitPrice
|
||||||
|
});
|
||||||
|
|
||||||
|
originOrderInfo.originAmount = amout
|
||||||
|
|
||||||
|
if (originOrderInfo.placeNum == 1 && originOrderInfo.dineMode == 'dine-in') {
|
||||||
|
originOrderInfo.originAmount += originOrderInfo.seatAmount
|
||||||
|
}
|
||||||
|
|
||||||
|
if (originOrderInfo.packFee > 0) {
|
||||||
|
originOrderInfo.originAmount += originOrderInfo.packFee
|
||||||
|
}
|
||||||
|
|
||||||
|
printStore.pushReceiptData(commOrderPrintData({ ...originOrderInfo, isGuest: true, isBefore: false }));
|
||||||
|
}).catch(err => {
|
||||||
|
console.log(err);
|
||||||
|
})
|
||||||
|
}
|
||||||
} else if (data.data_type == "product_update") {
|
} else if (data.data_type == "product_update") {
|
||||||
// 商品更新
|
// 商品更新
|
||||||
this.updateGoods();
|
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);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -159,7 +159,9 @@ export async function getOrderByIdAjax(orderId) {
|
|||||||
export function commOrderPrintData(orderInfo) {
|
export function commOrderPrintData(orderInfo) {
|
||||||
const userStore = useUser();
|
const userStore = useUser();
|
||||||
let data = {
|
let data = {
|
||||||
|
title: orderInfo.title,
|
||||||
isBefore: orderInfo.isBefore || false,
|
isBefore: orderInfo.isBefore || false,
|
||||||
|
isGuest: orderInfo.isGuest || false,
|
||||||
shop_name: userStore.shopInfo.shopName,
|
shop_name: userStore.shopInfo.shopName,
|
||||||
loginAccount: userStore.userInfo.name,
|
loginAccount: userStore.userInfo.name,
|
||||||
carts: [],
|
carts: [],
|
||||||
@@ -179,23 +181,54 @@ export function commOrderPrintData(orderInfo) {
|
|||||||
printTime: dayjs().format("YYYY-MM-DD HH:mm:ss"),
|
printTime: dayjs().format("YYYY-MM-DD HH:mm:ss"),
|
||||||
};
|
};
|
||||||
|
|
||||||
orderInfo.cartList.map((item) => {
|
if (orderInfo.isGuest) {
|
||||||
|
// 如果是客看单,只展示当前下单的菜品
|
||||||
|
orderInfo.detailMap[0].map((item) => {
|
||||||
|
let price = 0
|
||||||
|
if (item.discountSaleAmount > 0) {
|
||||||
|
price = item.discountSaleAmount
|
||||||
|
} else {
|
||||||
|
price = item.price
|
||||||
|
}
|
||||||
|
|
||||||
data.carts.push({
|
data.carts.push({
|
||||||
categoryId: item.categoryId,
|
categoryId: item.categoryId,
|
||||||
name: item.productName,
|
name: item.isGift === 1 ? `[赠]${item.productName}` : item.productName,
|
||||||
number: item.num,
|
number: item.num - item.returnNum,
|
||||||
skuName: item.skuName,
|
skuName: item.skuName || '',
|
||||||
salePrice: formatDecimal(+item.price),
|
salePrice: formatDecimal(+price),
|
||||||
totalAmount: formatDecimal(+item.payAmount),
|
totalAmount: formatDecimal(+item.payAmount),
|
||||||
proGroupInfo: item.proGroupInfo
|
proGroupInfo: item.proGroupInfo
|
||||||
? item.proGroupInfo.map((item) => item.goods).flat()
|
? item.proGroupInfo.map((item) => item.goods).flat()
|
||||||
: "",
|
: "",
|
||||||
|
remark: item.remark
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
} else {
|
||||||
|
orderInfo.cartList.map((item) => {
|
||||||
|
let price = 0
|
||||||
|
if (item.discountSaleAmount > 0) {
|
||||||
|
price = item.discountSaleAmount
|
||||||
|
} else {
|
||||||
|
price = item.price
|
||||||
|
}
|
||||||
|
data.carts.push({
|
||||||
|
categoryId: item.categoryId,
|
||||||
|
name: item.isGift === 1 ? `[赠]${item.productName}` : item.productName,
|
||||||
|
number: item.num - item.returnNum,
|
||||||
|
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.seatAmount > 0) {
|
if (orderInfo.dineMode == 'dine-in') {
|
||||||
console.log('有餐位费', orderInfo.seatAmount);
|
if (orderInfo.seatAmount > 0 && orderInfo.isGuest && orderInfo.placeNum == 1 && !orderInfo.isRefundDish && !orderInfo.isNotPrint) {
|
||||||
|
|
||||||
data.carts.push({
|
data.carts.push({
|
||||||
categoryId: '',
|
categoryId: '',
|
||||||
name: '餐位费',
|
name: '餐位费',
|
||||||
@@ -204,21 +237,42 @@ export function commOrderPrintData(orderInfo) {
|
|||||||
salePrice: formatDecimal(orderInfo.seatAmount / orderInfo.seatNum),
|
salePrice: formatDecimal(orderInfo.seatAmount / orderInfo.seatNum),
|
||||||
totalAmount: orderInfo.seatAmount,
|
totalAmount: orderInfo.seatAmount,
|
||||||
proGroupInfo: "",
|
proGroupInfo: "",
|
||||||
|
remark: ''
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
if (orderInfo.packFee > 0) {
|
if (orderInfo.seatAmount > 0 && !orderInfo.isGuest && !orderInfo.isRefundDish && !orderInfo.isNotPrint) {
|
||||||
|
data.carts.push({
|
||||||
|
categoryId: '',
|
||||||
|
name: '餐位费',
|
||||||
|
number: orderInfo.seatNum,
|
||||||
|
skuName: '',
|
||||||
|
salePrice: formatDecimal(orderInfo.seatAmount / orderInfo.seatNum),
|
||||||
|
totalAmount: orderInfo.seatAmount,
|
||||||
|
proGroupInfo: "",
|
||||||
|
remark: ''
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (orderInfo.packFee > 0 && !orderInfo.isRefundDish && !orderInfo.isNotPrint) {
|
||||||
|
let packNum = 0;
|
||||||
|
orderInfo.cartList.forEach(item => {
|
||||||
|
packNum += item.packNumber
|
||||||
|
})
|
||||||
data.carts.push({
|
data.carts.push({
|
||||||
categoryId: '',
|
categoryId: '',
|
||||||
name: '打包费',
|
name: '打包费',
|
||||||
number: '',
|
number: packNum,
|
||||||
skuName: '',
|
skuName: '',
|
||||||
salePrice: '',
|
salePrice: '',
|
||||||
totalAmount: formatDecimal(orderInfo.packFee),
|
totalAmount: formatDecimal(orderInfo.packFee),
|
||||||
proGroupInfo: "",
|
proGroupInfo: "",
|
||||||
|
remark: ''
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// console.log('最终组合打印数据===', data);
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -12,6 +12,12 @@
|
|||||||
<el-form-item label="设备名称">
|
<el-form-item label="设备名称">
|
||||||
<el-input v-model="form.name" placeholder="请输入设备名称"></el-input>
|
<el-input v-model="form.name" placeholder="请输入设备名称"></el-input>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
|
<el-form-item label="设备类型">
|
||||||
|
<el-radio-group v-model="form.connectionType" @change="form.address = ''">
|
||||||
|
<el-radio-button label="USB" value="USB"></el-radio-button>
|
||||||
|
<el-radio-button label="局域网" value="局域网"></el-radio-button>
|
||||||
|
</el-radio-group>
|
||||||
|
</el-form-item>
|
||||||
<!-- <el-form-item label="打印机品牌">
|
<!-- <el-form-item label="打印机品牌">
|
||||||
<el-input v-model="form.contentType" placeholder="请输入打印机品牌"></el-input>
|
<el-input v-model="form.contentType" placeholder="请输入打印机品牌"></el-input>
|
||||||
</el-form-item> -->
|
</el-form-item> -->
|
||||||
@@ -21,17 +27,41 @@
|
|||||||
<el-option label="80mm" value="80mm"></el-option>
|
<el-option label="80mm" value="80mm"></el-option>
|
||||||
</el-select>
|
</el-select>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="设备类型">
|
<el-form-item label="选择设备" v-if="form.connectionType === 'USB'">
|
||||||
<el-select v-model="form.connectionType">
|
|
||||||
<el-option label="USB" value="USB"></el-option>
|
|
||||||
<!-- <el-option label="网络" value="network"></el-option> -->
|
|
||||||
</el-select>
|
|
||||||
</el-form-item>
|
|
||||||
<el-form-item label="选择设备">
|
|
||||||
<el-select v-model="form.address">
|
<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-option :label="item.name" :value="item.name" v-for="item in printList" :key="item.name"></el-option>
|
||||||
</el-select>
|
</el-select>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
|
<el-form-item label="设备IP" v-if="form.connectionType === '局域网'">
|
||||||
|
<el-input v-model="form.address" placeholder="请输入设备IP地址"></el-input>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="商品分类">
|
||||||
|
<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" v-show="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>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="打印类型">
|
||||||
|
<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-form-item label="打印份数">
|
||||||
<el-select v-model="form.printQty">
|
<el-select v-model="form.printQty">
|
||||||
<el-option :label="item" :value="item" v-for="item in 4" :key="item"></el-option>
|
<el-option :label="item" :value="item" v-for="item in 4" :key="item"></el-option>
|
||||||
@@ -76,12 +106,15 @@
|
|||||||
<div class="row">收银员:{{ printData.loginAccount }}</div>
|
<div class="row">收银员:{{ printData.loginAccount }}</div>
|
||||||
<div class="line"></div>
|
<div class="line"></div>
|
||||||
<table class="table">
|
<table class="table">
|
||||||
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<td>品名</td>
|
<td>品名</td>
|
||||||
<td>单价</td>
|
<td>单价</td>
|
||||||
<td>数量</td>
|
<td>数量</td>
|
||||||
<td>小计</td>
|
<td>小计</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
<tr v-for="(item, index) in printData.carts" :key="index">
|
<tr v-for="(item, index) in printData.carts" :key="index">
|
||||||
<td>
|
<td>
|
||||||
<div>{{ item.name }}</div>
|
<div>{{ item.name }}</div>
|
||||||
@@ -91,6 +124,7 @@
|
|||||||
<td>{{ item.number }}</td>
|
<td>{{ item.number }}</td>
|
||||||
<td>{{ item.totalAmount }}</td>
|
<td>{{ item.totalAmount }}</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
<div class="line"></div>
|
<div class="line"></div>
|
||||||
<div class="row between">
|
<div class="row between">
|
||||||
@@ -125,9 +159,11 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<classify ref="classifyRef" @success="(e) => (form.categoryList = e)" />
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
|
import _ from 'lodash'
|
||||||
import dayjs from "dayjs";
|
import dayjs from "dayjs";
|
||||||
import { ipcRenderer } from "electron";
|
import { ipcRenderer } from "electron";
|
||||||
import { onMounted, reactive, ref } from "vue";
|
import { onMounted, reactive, ref } from "vue";
|
||||||
@@ -136,6 +172,12 @@ import { ElMessage } from "element-plus";
|
|||||||
import { useUser } from "@/store/user.js";
|
import { useUser } from "@/store/user.js";
|
||||||
import { usePrint } from "@/store/print.js";
|
import { usePrint } from "@/store/print.js";
|
||||||
import { printerAdd, printerDetail } from "@/api/account.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);
|
||||||
|
|
||||||
const printStore = usePrint();
|
const printStore = usePrint();
|
||||||
const store = useUser();
|
const store = useUser();
|
||||||
@@ -147,23 +189,63 @@ const printList = ref([]);
|
|||||||
const feets = ref([0, 1, 2, 3, 4, 5, 8]);
|
const feets = ref([0, 1, 2, 3, 4, 5, 8]);
|
||||||
const loading = ref(false);
|
const loading = ref(false);
|
||||||
const requestLoading = 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' },
|
||||||
|
]
|
||||||
|
}
|
||||||
|
])
|
||||||
|
|
||||||
|
const categoryIdsType = ref('all') // all=全部 custom=部分
|
||||||
|
|
||||||
const form = ref({
|
const form = ref({
|
||||||
id: "",
|
id: "",
|
||||||
name: '', // 设备名称
|
name: '', // 设备名称
|
||||||
connectionType: 'USB', // 现在打印机支持USB 和 网络、蓝牙
|
connectionType: 'USB', // 现在打印机支持USB 和 网络、蓝牙、局域网
|
||||||
address: '', // 打印机名称
|
address: '', // 打印机名称
|
||||||
port: '', // 端口
|
port: '', // 端口
|
||||||
subType: 'cash', // 打印类型(分类)label标签cash小票kitchen出品
|
printType: 'cash', // 打印类型(分类)label标签cash小票kitchen出品
|
||||||
contentType: '', // 打印机品牌
|
contentType: '', // 打印机品牌
|
||||||
categoryIds: [], // 打印分类Id
|
categoryIds: '', // 打印分类Id
|
||||||
categoryList: [], // 分类
|
categoryList: [], // 分类
|
||||||
sort: '',
|
sort: '',
|
||||||
receiptSize: '58mm', // 小票尺寸 58mm 80mm
|
receiptSize: '58mm', // 小票尺寸 58mm 80mm
|
||||||
classifyPrint: 1, // 分类打印 0-所有 1-部分分类 2-部分商品
|
classifyPrint: '0', // 分类打印 0-所有 1-部分分类 2-部分商品
|
||||||
printQty: '', // 打印数量 c1m1^2 = 顾客+商家[2张] m1^1 = 商家[1张] c1^1顾客[1张] c2m1^3顾客2+商家1[3张]
|
printNum: '', // 打印数量 c1m1^2 = 顾客+商家[2张] m1^1 = 商家[1张] c1^1顾客[1张] c2m1^3顾客2+商家1[3张]
|
||||||
printMethod: 'all', // 打印方式 all-全部打印 normal-仅打印结账单「前台」one-仅打印制作单「厨房」queue-仅打印排队取号
|
kitchenPrintMode: 'all', // 打印方式 all-全部打印 normal-仅打印结账单「前台」one-仅打印制作单「厨房」queue-仅打印排队取号
|
||||||
printType: [], // 打印类型,JSON数组 refund-确认退款单 handover-交班单 queue-排队取号
|
printContentType: [],
|
||||||
status: 1
|
status: 1,
|
||||||
|
handoverSwitch: 0, // 交班单开关 0-关闭 1-开启
|
||||||
});
|
});
|
||||||
|
|
||||||
const printDataLoading = ref(false);
|
const printDataLoading = ref(false);
|
||||||
@@ -210,21 +292,44 @@ function getPrintList() {
|
|||||||
|
|
||||||
// 测试打印
|
// 测试打印
|
||||||
function printHandle() {
|
function printHandle() {
|
||||||
if (!form.value.address) {
|
if (form.value.connectionType === 'USB' && !form.value.address) {
|
||||||
ElMessage.error("请选择打印设备");
|
ElMessage.error("请选择打印设备");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (form.value.connectionType === '局域网' && !form.value.address) {
|
||||||
|
ElMessage.error("请输入设备IP地址");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
printDataLoading.value = true;
|
printDataLoading.value = true;
|
||||||
printData.shop_name = store.shopInfo.shopName
|
printData.shop_name = store.shopInfo.shopName
|
||||||
printData.loginAccount = store.userInfo.name
|
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");
|
printData.printTime = dayjs().format("YYYY-MM-DD HH:mm:ss");
|
||||||
printStore.pushReceiptData(printData, false);
|
|
||||||
|
if (form.value.connectionType === 'USB') {
|
||||||
|
receiptPrint(printData,)
|
||||||
|
} else if (form.value.connectionType === '局域网') {
|
||||||
|
ipcRenderer.send('ORDER', JSON.stringify({
|
||||||
|
printerIp: form.value.address,
|
||||||
|
orderData: printData
|
||||||
|
}))
|
||||||
|
}
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
printDataLoading.value = false;
|
printDataLoading.value = false;
|
||||||
}, 2500);
|
}, 2500);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 打印类型切换
|
||||||
|
function printTypeChange(e, index) {
|
||||||
|
if (index == 1 && printTypeList.value[index].values.length == 0) {
|
||||||
|
form.value.categoryList = []
|
||||||
|
form.value.classifyPrint = '0'
|
||||||
|
} else {
|
||||||
|
form.value.classifyPrint = '1'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// 提交打印机
|
// 提交打印机
|
||||||
async function submitHandle() {
|
async function submitHandle() {
|
||||||
try {
|
try {
|
||||||
@@ -232,11 +337,29 @@ async function submitHandle() {
|
|||||||
ElMessage.error("请输入设备名称");
|
ElMessage.error("请输入设备名称");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!form.value.address) {
|
if (form.value.connectionType === 'USB' && !form.value.address) {
|
||||||
ElMessage.error("请选择打印设备");
|
ElMessage.error("请选择打印设备");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (form.value.connectionType === '局域网' && !form.value.address) {
|
||||||
|
ElMessage.error("请输入设备IP地址");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (form.value.classifyPrint == '1' && !form.value.categoryList.length) {
|
||||||
|
ElMessage.error("请选择商品分类");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
loading.value = true;
|
loading.value = true;
|
||||||
|
form.value.categoryIds = form.value.categoryList.map(item => item.id).join(',')
|
||||||
|
|
||||||
|
let arr = []
|
||||||
|
printTypeList.value.forEach(item => {
|
||||||
|
arr.push(...item.values)
|
||||||
|
})
|
||||||
|
|
||||||
|
form.value.printContentType = arr.join(',')
|
||||||
await printerAdd(form.value, form.value.id ? "put" : "post");
|
await printerAdd(form.value, form.value.id ? "put" : "post");
|
||||||
ElMessage.success(form.value.id ? "编辑成功" : "添加成功");
|
ElMessage.success(form.value.id ? "编辑成功" : "添加成功");
|
||||||
printStore.init();
|
printStore.init();
|
||||||
@@ -253,6 +376,37 @@ async function tbPrintMachineDetailAjax(id) {
|
|||||||
requestLoading.value = true;
|
requestLoading.value = true;
|
||||||
const res = await printerDetail({ id: id });
|
const res = await printerDetail({ id: id });
|
||||||
form.value = res;
|
form.value = res;
|
||||||
|
|
||||||
|
// 做分类信息补全
|
||||||
|
let arr = []
|
||||||
|
let categoryIds = res.categoryIds.split(',')
|
||||||
|
goodsStore.originCategoryList.map(item => {
|
||||||
|
categoryIds.map(val => {
|
||||||
|
if (item.id == val) {
|
||||||
|
arr.push({
|
||||||
|
id: item.id,
|
||||||
|
name: item.name
|
||||||
|
})
|
||||||
|
}
|
||||||
|
})
|
||||||
|
})
|
||||||
|
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) {
|
} catch (error) {
|
||||||
console.log(error);
|
console.log(error);
|
||||||
}
|
}
|
||||||
@@ -297,6 +451,7 @@ onMounted(() => {
|
|||||||
border-radius: 10px;
|
border-radius: 10px;
|
||||||
background-color: #fff;
|
background-color: #fff;
|
||||||
padding: 15px;
|
padding: 15px;
|
||||||
|
overflow-y: auto;
|
||||||
}
|
}
|
||||||
|
|
||||||
.menu_wrap {
|
.menu_wrap {
|
||||||
|
|||||||
@@ -13,7 +13,7 @@
|
|||||||
<div class="item" v-for="item in list" :key="item.id">
|
<div class="item" v-for="item in list" :key="item.id">
|
||||||
<div class="left">
|
<div class="left">
|
||||||
<div class="icon">
|
<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>
|
||||||
<div class="info">
|
<div class="info">
|
||||||
<div class="name">{{ item.name }}</div>
|
<div class="name">{{ item.name }}</div>
|
||||||
@@ -28,7 +28,7 @@
|
|||||||
<div class="editor">
|
<div class="editor">
|
||||||
<el-text type="primary" @click="
|
<el-text type="primary" @click="
|
||||||
router.push({
|
router.push({
|
||||||
name: deviceRoute[item.subType],
|
name: deviceRoute[item.printType],
|
||||||
query: { id: item.id },
|
query: { id: item.id },
|
||||||
})
|
})
|
||||||
">
|
">
|
||||||
|
|||||||
@@ -248,22 +248,31 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</el-dialog>
|
</el-dialog>
|
||||||
|
<!-- 退款推库存的操作弹窗 -->
|
||||||
|
<refundConsModal ref="refundConsModalRef" :list="refundList" @success="refundConsModalSuccess" />
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
|
import _ from 'lodash'
|
||||||
import { ref } from 'vue'
|
import { ref } from 'vue'
|
||||||
import { ElMessage } from 'element-plus'
|
import { ElMessage } from 'element-plus'
|
||||||
import takeFoodCode from '@/components/takeFoodCode.vue'
|
import takeFoodCode from '@/components/takeFoodCode.vue'
|
||||||
import TableMerging from './tableMerging.vue'
|
import TableMerging from './tableMerging.vue'
|
||||||
import skuModal from '@/components/skuModal.vue'
|
import skuModal from '@/components/skuModal.vue'
|
||||||
import { useGoods } from '@/store/goods.js'
|
import { useGoods } from '@/store/goods.js'
|
||||||
import { inputFilterFloat, formatDecimal } from '@/utils/index.js'
|
import { inputFilterFloat, formatDecimal, getOrderByIdAjax, commOrderPrintData } from '@/utils/index.js'
|
||||||
import { refundOrder } from '@/api/order.js'
|
import { refundOrder } from '@/api/order.js'
|
||||||
import { useSocket } from '@/store/socket.js'
|
import { useSocket } from '@/store/socket.js'
|
||||||
|
import { usePrint } from '@/store/print.js'
|
||||||
|
import { useUser } from '@/store/user.js'
|
||||||
|
import refundConsModal from '@/components/refundConsModal.vue'
|
||||||
|
|
||||||
|
const refundConsModalRef = ref(null)
|
||||||
|
|
||||||
const goodsStore = useGoods()
|
const goodsStore = useGoods()
|
||||||
const socket = useSocket()
|
const socket = useSocket()
|
||||||
|
const printStore = usePrint()
|
||||||
|
const store = useUser()
|
||||||
const tableMergingRef = ref(null)
|
const tableMergingRef = ref(null)
|
||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
@@ -312,15 +321,21 @@ async function returnFormSubmit() {
|
|||||||
returnFormLoading.value = true
|
returnFormLoading.value = true
|
||||||
await returnOrderItemAjax(returnForm.value.num)
|
await returnOrderItemAjax(returnForm.value.num)
|
||||||
showReturnForm.value = false
|
showReturnForm.value = false
|
||||||
ElMessage.success('退菜成功')
|
// ElMessage.success('退菜成功')
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log('退菜失败了');
|
console.log('退菜失败了');
|
||||||
}
|
}
|
||||||
returnFormLoading.value = false
|
returnFormLoading.value = false
|
||||||
}
|
}
|
||||||
|
|
||||||
// 提交退菜
|
const refundStock = ref('')
|
||||||
async function returnOrderItemAjax(num = 1) {
|
// 退款推库存的操作
|
||||||
|
function refundConsModalSuccess(e) {
|
||||||
|
refundStock.value = e
|
||||||
|
refundNext()
|
||||||
|
}
|
||||||
|
|
||||||
|
async function refundNext() {
|
||||||
try {
|
try {
|
||||||
let data = {
|
let data = {
|
||||||
orderId: goodsStore.orderListInfo.id,
|
orderId: goodsStore.orderListInfo.id,
|
||||||
@@ -332,19 +347,82 @@ async function returnOrderItemAjax(num = 1) {
|
|||||||
{
|
{
|
||||||
id: goodsStore.cartOrderItem.id,
|
id: goodsStore.cartOrderItem.id,
|
||||||
returnAmount: goodsStore.cartOrderItem.lowPrice,
|
returnAmount: goodsStore.cartOrderItem.lowPrice,
|
||||||
num: num
|
num: refundNum.value
|
||||||
}
|
}
|
||||||
]
|
],
|
||||||
|
operator: store.userInfo.name || store.shopInfo.shopName,
|
||||||
|
print: printStore.deviceNoteList.length ? false : true,
|
||||||
|
refundStock: refundStock.value, // 是否推库存 1退菜图库存 2仅退菜不退库存
|
||||||
}
|
}
|
||||||
await refundOrder(data)
|
await refundOrder(data)
|
||||||
goodsStore.cartOrderItem.returnNum += num
|
ElMessage.success('退菜成功')
|
||||||
|
goodsStore.cartOrderItem.returnNum += refundNum.value
|
||||||
goodsStore.calcCartInfo()
|
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
|
||||||
|
|
||||||
|
// printStore.printRefundDish(commOrderPrintData({ ...originOrderInfo, isRefundDish: true }));
|
||||||
|
// }).catch(err => {
|
||||||
|
// console.log(err);
|
||||||
|
// })
|
||||||
// await goodsStore.historyOrderAjax('', data.orderId)
|
// await goodsStore.historyOrderAjax('', data.orderId)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log(error);
|
console.log(error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 提交退菜
|
||||||
|
const refundNum = ref(1)
|
||||||
|
const refundList = ref([])
|
||||||
|
async function returnOrderItemAjax(num = 1) {
|
||||||
|
try {
|
||||||
|
refundNum.value = num
|
||||||
|
let item = goodsStore.cartOrderItem
|
||||||
|
|
||||||
|
console.log('returnOrderItemAjax===', item);
|
||||||
|
|
||||||
|
// 在这里给订单的商品补全库存信息 start
|
||||||
|
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('item===', item);
|
||||||
|
if (item.refundMode == 3) {
|
||||||
|
refundList.value = [
|
||||||
|
{
|
||||||
|
name: item.product_name,
|
||||||
|
num: refundNum.value
|
||||||
|
}
|
||||||
|
]
|
||||||
|
refundConsModalRef.value.show()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
refundNext()
|
||||||
|
// 在这里给订单的商品补全库存信息 end
|
||||||
|
} catch (error) {
|
||||||
|
console.log(error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// 显示打包
|
// 显示打包
|
||||||
function packHandle() {
|
function packHandle() {
|
||||||
let item = goodsStore.cartList[goodsStore.cartActiveIndex]
|
let item = goodsStore.cartList[goodsStore.cartActiveIndex]
|
||||||
|
|||||||
@@ -55,7 +55,13 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="shop_list" :class="{ img: shopListType == 'img' }" v-loading="loading">
|
<div class="shop_list" :class="{ img: shopListType == 'img' }" v-loading="loading">
|
||||||
<!-- <swiper class="swiper_box" direction="vertical" @slideChange="onSlideChange"> -->
|
<!-- <swiper class="swiper_box" direction="vertical" @slideChange="onSlideChange"> -->
|
||||||
<swiper ref="swiperRef" :loop="false" class="swiper_box" direction="vertical">
|
<swiper ref="swiperRef" :loop="false" class="swiper_box" direction="vertical" :modules="[Mousewheel]"
|
||||||
|
:simulate-touch="true" :allow-touch-move="true" :mousewheel="{
|
||||||
|
enabled: true,
|
||||||
|
forceToAxis: true,
|
||||||
|
releaseOnEdges: true,
|
||||||
|
invert: false,
|
||||||
|
}">
|
||||||
<swiper-slide class="slide_item" v-for="(goods, index) in goodsStore.goodsList" :key="index">
|
<swiper-slide class="slide_item" v-for="(goods, index) in goodsStore.goodsList" :key="index">
|
||||||
<div class="item_wrap" v-for="item in goods" :key="item.id" @click="showSkuHandle(item)">
|
<div class="item_wrap" v-for="item in goods" :key="item.id" @click="showSkuHandle(item)">
|
||||||
<div class="item">
|
<div class="item">
|
||||||
@@ -89,7 +95,7 @@
|
|||||||
<img class="sell_out_icon" src="@/assets/icon_goods_wks.svg">
|
<img class="sell_out_icon" src="@/assets/icon_goods_wks.svg">
|
||||||
</div>
|
</div>
|
||||||
<!-- 售罄 -->
|
<!-- 售罄 -->
|
||||||
<div class="sell_out" v-else-if="item.isSoldStock">
|
<div class="sell_out" v-else-if="item.isSoldStock || item.isSoldOut">
|
||||||
<img class="sell_out_icon" src="@/assets/icon_goods_sq.svg">
|
<img class="sell_out_icon" src="@/assets/icon_goods_sq.svg">
|
||||||
</div>
|
</div>
|
||||||
<!-- 库存不足 -->
|
<!-- 库存不足 -->
|
||||||
@@ -294,6 +300,8 @@ import { staffPermission } from '@/api/user.js'
|
|||||||
import { clearNoNum } from '@/utils/index.js'
|
import { clearNoNum } from '@/utils/index.js'
|
||||||
import { productOnOff, markIsSoldOut } from '@/api/product_new.js'
|
import { productOnOff, markIsSoldOut } from '@/api/product_new.js'
|
||||||
|
|
||||||
|
import { Mousewheel } from 'swiper/modules'
|
||||||
|
|
||||||
const swiperRef = ref(null)
|
const swiperRef = ref(null)
|
||||||
|
|
||||||
const store = useUser()
|
const store = useUser()
|
||||||
@@ -551,7 +559,7 @@ function showSkuHandle(item) {
|
|||||||
message: '不在可售时间内',
|
message: '不在可售时间内',
|
||||||
})
|
})
|
||||||
return
|
return
|
||||||
} else if (item.isSoldStock) {
|
} else if (item.isSoldStock || item.isSoldOut) {
|
||||||
ElMessage({
|
ElMessage({
|
||||||
type: 'error',
|
type: 'error',
|
||||||
message: '该商品已售罄',
|
message: '该商品已售罄',
|
||||||
|
|||||||
@@ -144,6 +144,10 @@ const props = defineProps({
|
|||||||
member: {
|
member: {
|
||||||
type: Object,
|
type: Object,
|
||||||
default: {}
|
default: {}
|
||||||
|
},
|
||||||
|
type: {
|
||||||
|
type: String,
|
||||||
|
default: 'cart' // cart 代客下单 table 桌台结算 order 订单结算
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -200,14 +204,64 @@ const printHandle = _.throttle(async function () {
|
|||||||
await printOrderLable(true)
|
await printOrderLable(true)
|
||||||
}, 1500, { leading: true, trailing: false })
|
}, 1500, { leading: true, trailing: false })
|
||||||
|
|
||||||
|
|
||||||
|
// 在 usePrint 的 actions 中添加(比如放在 pushReceiptData 方法下方)
|
||||||
|
function 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; // 返回所有菜品的总价总和
|
||||||
|
}
|
||||||
|
|
||||||
// 打印订单标签
|
// 打印订单标签
|
||||||
async function printOrderLable(isBefore = false) {
|
async function printOrderLable(isBefore = false) {
|
||||||
try {
|
try {
|
||||||
let orderId = goodsStore.orderListInfo.id
|
let orderId = goodsStore.orderListInfo.id
|
||||||
const data = await getOrderByIdAjax(orderId);
|
await orderPrint({
|
||||||
|
type: isBefore ? 1 : 0,
|
||||||
|
id: orderId,
|
||||||
|
});
|
||||||
|
printLoading.value = false
|
||||||
|
return
|
||||||
|
|
||||||
|
let data = await getOrderByIdAjax(orderId);
|
||||||
|
|
||||||
|
console.log(`打印订单标签数据${isBefore}===`, data);
|
||||||
|
|
||||||
|
if (isBefore) {
|
||||||
|
data.originAmount = calcAllCartsTotalSum(data.detailMap)
|
||||||
|
}
|
||||||
|
|
||||||
|
if (data.seatAmount > 0 && data.dineMode == 'dine-in' && isBefore) {
|
||||||
|
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 && isBefore) {
|
||||||
|
data.originAmount += packFee
|
||||||
|
data.packFee = packFee
|
||||||
|
}
|
||||||
|
|
||||||
let printList = useStorage.get("printList") || [];
|
let printList = useStorage.get("printList") || [];
|
||||||
|
|
||||||
|
console.log('printStore.deviceNoteList.length:', printStore.deviceNoteList.length);
|
||||||
|
|
||||||
// 防止重复打印
|
// 防止重复打印
|
||||||
if (!printList.some((el) => el == orderId)) {
|
if (!printList.some((el) => el == orderId)) {
|
||||||
if (!isBefore) {
|
if (!isBefore) {
|
||||||
@@ -221,17 +275,17 @@ async function printOrderLable(isBefore = false) {
|
|||||||
printStore.labelPrint(commOrderPrintData(data))
|
printStore.labelPrint(commOrderPrintData(data))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
console.log('printStore.deviceNoteList', printStore.deviceNoteList);
|
||||||
if (printStore.deviceNoteList.length) {
|
if (printStore.deviceNoteList.length) {
|
||||||
// 使用本地打印机打印
|
// 使用本地打印机打印
|
||||||
printStore.pushReceiptData(commOrderPrintData({ ...data, isBefore: isBefore }));
|
printStore.pushReceiptData(commOrderPrintData({ ...data, isBefore: isBefore }));
|
||||||
} else {
|
} else {
|
||||||
// 本地没有可用打印机使用云打印机
|
// 本地没有可用打印机使用云打印机
|
||||||
// await orderPrint({
|
await orderPrint({
|
||||||
// type: isBefore ? 1 : 0,
|
type: isBefore ? 1 : 0,
|
||||||
// id: orderId,
|
id: orderId,
|
||||||
// });
|
});
|
||||||
// ElMessage.success(`云打印${isBefore ? '预' : ''}结算单成功`);
|
ElMessage.success(`云打印${isBefore ? '预' : ''}结算单成功`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
@@ -258,9 +312,14 @@ function paySuccess() {
|
|||||||
|
|
||||||
const payCardRef = ref(null)
|
const payCardRef = ref(null)
|
||||||
function show(t) {
|
function show(t) {
|
||||||
|
goodsStore.payType = props.type
|
||||||
dialogVisible.value = true;
|
dialogVisible.value = true;
|
||||||
cartInfo.value = { ...goodsStore.cartInfo }
|
cartInfo.value = { ...goodsStore.cartInfo }
|
||||||
|
if (props.type === 'table' || props.type === 'order') {
|
||||||
|
orderList.value = goodsStore.orderList.map(item => item.goods).flat()
|
||||||
|
} else {
|
||||||
orderList.value = [...goodsStore.cartList, ...goodsStore.orderList.map(item => item.goods).flat()]
|
orderList.value = [...goodsStore.cartList, ...goodsStore.orderList.map(item => item.goods).flat()]
|
||||||
|
}
|
||||||
|
|
||||||
console.log('orderListInfo===================', { ...goodsStore.orderListInfo });
|
console.log('orderListInfo===================', { ...goodsStore.orderListInfo });
|
||||||
|
|
||||||
|
|||||||
@@ -204,7 +204,7 @@ function confirmHandle() {
|
|||||||
goodsStore.operateCart({
|
goodsStore.operateCart({
|
||||||
table_code: table_code,
|
table_code: table_code,
|
||||||
new_table_code: new_table_code,
|
new_table_code: new_table_code,
|
||||||
cart_ids: cart_ids
|
cart_id: cart_ids
|
||||||
}, 'rottable')
|
}, 'rottable')
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -70,7 +70,7 @@
|
|||||||
<div class="left">
|
<div class="left">
|
||||||
<span>台桌:{{ goodsStore.tableInfo.name }}</span>
|
<span>台桌:{{ goodsStore.tableInfo.name }}</span>
|
||||||
<div class="n" @click="takeFoodCodeRef.show()">
|
<div class="n" @click="takeFoodCodeRef.show()">
|
||||||
{{ goodsStore.tableInfo.num || 1 }}人
|
{{ goodsStore.tableInfo.num || 0 }}人
|
||||||
<el-icon>
|
<el-icon>
|
||||||
<EditPen />
|
<EditPen />
|
||||||
</el-icon>
|
</el-icon>
|
||||||
@@ -189,7 +189,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<!-- 备注 -->
|
<!-- 备注 -->
|
||||||
<remarkModal ref="remarkRef" @success="(e) => (remark = e)" />
|
<remarkModal ref="remarkRef" @success="(e) => (goodsStore.remark = e)" />
|
||||||
<!-- 修改取餐号 -->
|
<!-- 修改取餐号 -->
|
||||||
<takeFoodCode />
|
<takeFoodCode />
|
||||||
<el-drawer v-model="membershow" :with-header="true" size="90%" title="选择会员">
|
<el-drawer v-model="membershow" :with-header="true" size="90%" title="选择会员">
|
||||||
@@ -197,7 +197,7 @@
|
|||||||
</el-drawer>
|
</el-drawer>
|
||||||
<!-- <takeFoodCode ref="takeFoodCodeRef" title="修改取餐号" placeholder="请输入取餐号" @success="takeFoodCodeSuccess" /> -->
|
<!-- <takeFoodCode ref="takeFoodCodeRef" title="修改取餐号" placeholder="请输入取餐号" @success="takeFoodCodeSuccess" /> -->
|
||||||
<!-- 结算订单 -->
|
<!-- 结算订单 -->
|
||||||
<settleAccount ref="settleAccountRef" :cart="cartList" :amount="cartInfo.totalAmount" :remark="remark"
|
<settleAccount ref="settleAccountRef" :cart="cartList" :amount="cartInfo.totalAmount" :remark="goodsStore.remark"
|
||||||
:orderInfo="orderInfo" @success="" />
|
:orderInfo="orderInfo" @success="" />
|
||||||
<!-- 快捷收银 -->
|
<!-- 快捷收银 -->
|
||||||
<fastCashier ref="fastCashierRef" type="0" />
|
<fastCashier ref="fastCashierRef" type="0" />
|
||||||
@@ -212,6 +212,7 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
|
import _ from 'lodash'
|
||||||
import { ref } from "vue";
|
import { ref } from "vue";
|
||||||
import { useGlobal } from '@/store/global.js'
|
import { useGlobal } from '@/store/global.js'
|
||||||
import SelectVipUser from "@/components/selectVipUser.vue";
|
import SelectVipUser from "@/components/selectVipUser.vue";
|
||||||
@@ -224,7 +225,7 @@ import fastCashier from "@/views/home/components/fastCashier.vue";
|
|||||||
import pendingCartModal from "@/views/home/components/pendingCartModal.vue";
|
import pendingCartModal from "@/views/home/components/pendingCartModal.vue";
|
||||||
import tableMerging from '@/views/home/components/tableMerging.vue'
|
import tableMerging from '@/views/home/components/tableMerging.vue'
|
||||||
import CartItem from './components/cartItem.vue'
|
import CartItem from './components/cartItem.vue'
|
||||||
import { formatDecimal, formatPhoneNumber } from '@/utils/index.js'
|
import { formatDecimal, formatPhoneNumber, getOrderByIdAjax, commOrderPrintData } from '@/utils/index.js'
|
||||||
import { useGoods } from '@/store/goods.js'
|
import { useGoods } from '@/store/goods.js'
|
||||||
import { staffPermission } from '@/api/user.js'
|
import { staffPermission } from '@/api/user.js'
|
||||||
import { createOrder } from '@/api/order.js'
|
import { createOrder } from '@/api/order.js'
|
||||||
@@ -252,7 +253,6 @@ const pendingCartModalRef = ref(null);
|
|||||||
const settleAccountRef = ref(null);
|
const settleAccountRef = ref(null);
|
||||||
const fastCashierRef = ref(null);
|
const fastCashierRef = ref(null);
|
||||||
const tableMergingRef = ref(null)
|
const tableMergingRef = ref(null)
|
||||||
const remark = ref("");
|
|
||||||
const cartListActive = ref(0);
|
const cartListActive = ref(0);
|
||||||
const cartListActiveItem = ref({})
|
const cartListActiveItem = ref({})
|
||||||
const cartList = ref([]);
|
const cartList = ref([]);
|
||||||
@@ -299,6 +299,7 @@ async function quickCashHandle() {
|
|||||||
// 生成订单 t=0 先下单后结算 t=1直接结算
|
// 生成订单 t=0 先下单后结算 t=1直接结算
|
||||||
async function createOrderHandle(t = 0) {
|
async function createOrderHandle(t = 0) {
|
||||||
try {
|
try {
|
||||||
|
let placeNum = goodsStore.orderListInfo.placeNum || 0
|
||||||
if (goodsStore.cartList.length) {
|
if (goodsStore.cartList.length) {
|
||||||
const data = {
|
const data = {
|
||||||
orderId: goodsStore.orderListInfo.id || '', // 订单id
|
orderId: goodsStore.orderListInfo.id || '', // 订单id
|
||||||
@@ -308,8 +309,8 @@ async function createOrderHandle(t = 0) {
|
|||||||
originAmount: goodsStore.cartInfo.costSummary.goodsOriginalAmount,
|
originAmount: goodsStore.cartInfo.costSummary.goodsOriginalAmount,
|
||||||
tableCode: goodsStore.cartList[0].table_code, // 台桌号
|
tableCode: goodsStore.cartList[0].table_code, // 台桌号
|
||||||
dineMode: goodsStore.allSelected ? store.shopInfo.eatModel.split(',')[1] : store.shopInfo.eatModel.split(',')[0], // 用餐方式
|
dineMode: goodsStore.allSelected ? store.shopInfo.eatModel.split(',')[1] : store.shopInfo.eatModel.split(',')[0], // 用餐方式
|
||||||
remark: remark.value, // 备注
|
remark: goodsStore.remark, // 备注
|
||||||
placeNum: (goodsStore.orderListInfo.placeNum || 0) + 1, // 下单次数
|
placeNum: placeNum + 1, // 下单次数
|
||||||
waitCall: 0, // 是否叫号
|
waitCall: 0, // 是否叫号
|
||||||
userId: goodsStore.vipUserInfo.userId || '', // 会员用户id
|
userId: goodsStore.vipUserInfo.userId || '', // 会员用户id
|
||||||
limitRate: goodsStore.limitDiscountRes
|
limitRate: goodsStore.limitDiscountRes
|
||||||
@@ -328,6 +329,32 @@ async function createOrderHandle(t = 0) {
|
|||||||
settleAccountRef.value.show(t)
|
settleAccountRef.value.show(t)
|
||||||
} else {
|
} else {
|
||||||
goodsStore.clearCart()
|
goodsStore.clearCart()
|
||||||
|
// 开始打印客看单,可看单需要剔除其他历史下单
|
||||||
|
// getOrderByIdAjax(res.id).then(res => {
|
||||||
|
// let originOrderInfo = res
|
||||||
|
// originOrderInfo.detailMap = _.at(originOrderInfo.detailMap, placeNum + 1);
|
||||||
|
|
||||||
|
// console.log('originOrderInfo', originOrderInfo);
|
||||||
|
|
||||||
|
// let amout = 0
|
||||||
|
// originOrderInfo.detailMap.flat().forEach(item => {
|
||||||
|
// amout += item.num * item.unitPrice
|
||||||
|
// });
|
||||||
|
|
||||||
|
// originOrderInfo.originAmount = amout
|
||||||
|
|
||||||
|
// if (originOrderInfo.placeNum == 1 && originOrderInfo.dineMode == 'dine-in') {
|
||||||
|
// originOrderInfo.originAmount += originOrderInfo.seatAmount
|
||||||
|
// }
|
||||||
|
|
||||||
|
// if (originOrderInfo.packFee > 0) {
|
||||||
|
// originOrderInfo.originAmount += originOrderInfo.packFee
|
||||||
|
// }
|
||||||
|
|
||||||
|
// printStore.pushReceiptData(commOrderPrintData({ ...originOrderInfo, isGuest: true, isBefore: false }));
|
||||||
|
// }).catch(err => {
|
||||||
|
// console.log(err);
|
||||||
|
// })
|
||||||
}
|
}
|
||||||
// 清除购物车,更新历史订单
|
// 清除购物车,更新历史订单
|
||||||
goodsStore.updateOrderList()
|
goodsStore.updateOrderList()
|
||||||
|
|||||||
@@ -26,16 +26,22 @@
|
|||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
</el-dialog> -->
|
</el-dialog> -->
|
||||||
<el-input v-model="authCode" placeholder="请扫描支付码"></el-input>
|
<!-- <el-input v-model="authCode" placeholder="请扫描支付码"></el-input>
|
||||||
<el-button type="primary" @click="microPayAjax">反扫支付</el-button>
|
<el-button type="primary" @click="microPayAjax">反扫支付</el-button> -->
|
||||||
|
<el-button type="primary" @click="printReceipt">打印盘点单</el-button>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
|
import dayjs from 'dayjs';
|
||||||
import { onMounted, ref } from 'vue'
|
import { onMounted, ref } from 'vue'
|
||||||
import { findVersion } from '@/api/user.js'
|
import { findVersion } from '@/api/user.js'
|
||||||
import packageData from "../../../package.json";
|
import packageData from "../../../package.json";
|
||||||
import { ipcRenderer } from 'electron'
|
import { ipcRenderer } from 'electron'
|
||||||
import { microPay } from '@/api/order.js'
|
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 showDialog = ref(false)
|
||||||
const updataInfo = ref({})
|
const updataInfo = ref({})
|
||||||
@@ -44,8 +50,89 @@ const uploadPro = ref(0)
|
|||||||
const uploadSucess = ref(false)
|
const uploadSucess = ref(false)
|
||||||
const uploadResponse = ref({})
|
const uploadResponse = ref({})
|
||||||
const tempFilePath = ref('')
|
const tempFilePath = ref('')
|
||||||
|
const printStore = usePrint()
|
||||||
const authCode = ref('')
|
const authCode = ref('')
|
||||||
|
const user = useUser()
|
||||||
|
|
||||||
|
// 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: ''
|
||||||
|
// },
|
||||||
|
],
|
||||||
|
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"),
|
||||||
|
}
|
||||||
|
// 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))
|
||||||
|
}
|
||||||
|
|
||||||
// 检查版本更新
|
// 检查版本更新
|
||||||
async function findVersionAjax() {
|
async function findVersionAjax() {
|
||||||
|
|||||||
339
src/views/member/components/StoreWineManagement.vue
Normal file
339
src/views/member/components/StoreWineManagement.vue
Normal file
@@ -0,0 +1,339 @@
|
|||||||
|
<template>
|
||||||
|
<el-drawer v-model="drawerVisible" size="100%" :with-header="false" direction="btt">
|
||||||
|
<div class="drawer_wrap">
|
||||||
|
<div class="header">
|
||||||
|
<div class="left">
|
||||||
|
<div class="return" @click="drawerVisible = false">
|
||||||
|
<el-icon size="26" color="#555">
|
||||||
|
<Back />
|
||||||
|
</el-icon>
|
||||||
|
</div>
|
||||||
|
<div class="user_info">
|
||||||
|
<el-image :src="userInfo.headImg" fit="cover"
|
||||||
|
style="width: 40px; height: 40px; border-radius: 50%;background-color: #efefef;">
|
||||||
|
<template #error>
|
||||||
|
<el-icon style="font-size: 40px; color: #ccc;">
|
||||||
|
<user />
|
||||||
|
</el-icon>
|
||||||
|
</template>
|
||||||
|
</el-image>
|
||||||
|
<el-text>{{ userInfo.nickName }}/{{ userInfo.phone }}</el-text>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="right">
|
||||||
|
<!-- <el-button type="danger" @click="dialogVisible = true">取酒</el-button> -->
|
||||||
|
<el-button type="primary" @click="dialogVisible = true">新增存酒</el-button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="pay_wrap">
|
||||||
|
<div class="tab">
|
||||||
|
<el-table :data="list" height="100%" border stripe>
|
||||||
|
<el-table-column label="记录" prop="name"></el-table-column>
|
||||||
|
<el-table-column label="数量" prop="num"></el-table-column>
|
||||||
|
<el-table-column label="到期时间" prop="expTime"></el-table-column>
|
||||||
|
<el-table-column label="操作" width="250">
|
||||||
|
<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>
|
||||||
|
</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-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-form-item>
|
||||||
|
<el-form-item label="存酒有效期">
|
||||||
|
<el-input-number v-model="form.expDay" :min="1"></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 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-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>
|
||||||
|
<!-- 存取酒记录弹窗 -->
|
||||||
|
<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>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup>
|
||||||
|
import { ref, onMounted } from "vue";
|
||||||
|
import { ElMessage } from 'element-plus'
|
||||||
|
import { shopStoragePost, storageGoodGet, shopStorageGet, shopStoragePut, shopStorageRecord } from '@/api/product_new'
|
||||||
|
|
||||||
|
const props = defineProps({
|
||||||
|
userInfo: {
|
||||||
|
type: Object,
|
||||||
|
default: () => ({})
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
const drawerVisible = ref(false);
|
||||||
|
const dialogVisible = ref(false);
|
||||||
|
|
||||||
|
const list = ref([]);
|
||||||
|
|
||||||
|
// 获取存酒记录
|
||||||
|
async function shopStorageGetAjax() {
|
||||||
|
try {
|
||||||
|
const res = await shopStorageGet({
|
||||||
|
key: '',
|
||||||
|
phone: props.userInfo.phone,
|
||||||
|
page: 1,
|
||||||
|
size: 999,
|
||||||
|
});
|
||||||
|
list.value = res.records || [];
|
||||||
|
} catch (error) {
|
||||||
|
console.error('获取存酒列表失败:', error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const form = ref({
|
||||||
|
userId: '',
|
||||||
|
shopStorageGoodId: '', // 存酒商品ID
|
||||||
|
num: 1, // 存酒数量
|
||||||
|
expDay: 1, // 存酒有效期,单位天默认1天
|
||||||
|
})
|
||||||
|
|
||||||
|
const rules = {
|
||||||
|
shopStorageGoodId: [{ required: true, message: '请选择存酒商品', trigger: 'change' }],
|
||||||
|
num: [{ required: true, message: '请输入存酒数量', trigger: 'change' }],
|
||||||
|
expDay: [{ required: true, message: '请输入存酒有效期', trigger: 'change' }],
|
||||||
|
}
|
||||||
|
|
||||||
|
// 确认存酒
|
||||||
|
const confirmLoading = ref(false);
|
||||||
|
async function confirmHandle() {
|
||||||
|
try {
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 获取存酒商品列表
|
||||||
|
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 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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function init() {
|
||||||
|
drawerVisible.value = false;
|
||||||
|
dialogVisible.value = false;
|
||||||
|
takeWineDialogVisible.value = false;
|
||||||
|
form.value = {
|
||||||
|
userId: '',
|
||||||
|
shopStorageGoodId: '',
|
||||||
|
num: 1,
|
||||||
|
expDay: 1,
|
||||||
|
};
|
||||||
|
takeWineForm.value = {
|
||||||
|
id: '',
|
||||||
|
num: 1,
|
||||||
|
};
|
||||||
|
maxTakeNum.value = 1;
|
||||||
|
list.value = [];
|
||||||
|
}
|
||||||
|
|
||||||
|
function isExpired(expTime) {
|
||||||
|
if (!expTime) return false;
|
||||||
|
const now = new Date();
|
||||||
|
const expDate = new Date(expTime);
|
||||||
|
return expDate < now;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 查看记录
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function show() {
|
||||||
|
init();
|
||||||
|
drawerVisible.value = true;
|
||||||
|
// 刷新列表数据
|
||||||
|
storageGoodGetAjax();
|
||||||
|
shopStorageGetAjax();
|
||||||
|
}
|
||||||
|
|
||||||
|
defineExpose({
|
||||||
|
show,
|
||||||
|
init,
|
||||||
|
});
|
||||||
|
|
||||||
|
// 初始化
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
onMounted(() => {
|
||||||
|
storageGoodGetAjax();
|
||||||
|
shopStorageGetAjax();
|
||||||
|
})
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style scoped lang="scss">
|
||||||
|
.drawer_wrap {
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
display: flex;
|
||||||
|
padding: var(--el-font-size-base) 0;
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.pay_wrap {
|
||||||
|
flex: 1;
|
||||||
|
background: #fff;
|
||||||
|
border-radius: var(--el-font-size-base);
|
||||||
|
|
||||||
|
.tab {
|
||||||
|
height: 100%;
|
||||||
|
padding: var(--el-font-size-base);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.dialog-footer {
|
||||||
|
display: flex;
|
||||||
|
justify-content: flex-end;
|
||||||
|
gap: var(--el-font-size-base);
|
||||||
|
|
||||||
|
.btn {
|
||||||
|
flex: 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@@ -99,6 +99,9 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="btn_wrap">
|
<div class="btn_wrap">
|
||||||
|
<div class="btn">
|
||||||
|
<el-button type="success" style="width: 100%;" @click="StoreWineManagementRef.show()">存酒管理</el-button>
|
||||||
|
</div>
|
||||||
<div class="btn">
|
<div class="btn">
|
||||||
<el-button type="warning" style="width: 100%;" @click="UserChargeRef.show()">账户充值</el-button>
|
<el-button type="warning" style="width: 100%;" @click="UserChargeRef.show()">账户充值</el-button>
|
||||||
</div>
|
</div>
|
||||||
@@ -114,6 +117,8 @@
|
|||||||
<RecordDialog ref="RecordDialogRef" @refund="getUserList" />
|
<RecordDialog ref="RecordDialogRef" @refund="getUserList" />
|
||||||
<!-- 添加会员 -->
|
<!-- 添加会员 -->
|
||||||
<AddUserDrawer ref="AddUserDrawerRef" @success="queryHandle" />
|
<AddUserDrawer ref="AddUserDrawerRef" @success="queryHandle" />
|
||||||
|
<!-- 存酒管理 -->
|
||||||
|
<StoreWineManagement ref="StoreWineManagementRef" :user-info="currentRow" />
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
@@ -123,10 +128,12 @@ import { shopUserList } from '@/api/account.js'
|
|||||||
import UserCharge from './components/userCharge.vue'
|
import UserCharge from './components/userCharge.vue'
|
||||||
import RecordDialog from './components/recordDialog.vue'
|
import RecordDialog from './components/recordDialog.vue'
|
||||||
import AddUserDrawer from './components/addUserDrawer.vue'
|
import AddUserDrawer from './components/addUserDrawer.vue'
|
||||||
|
import StoreWineManagement from './components/storeWineManagement.vue'
|
||||||
|
|
||||||
const UserChargeRef = ref(null)
|
const UserChargeRef = ref(null)
|
||||||
const RecordDialogRef = ref(null)
|
const RecordDialogRef = ref(null)
|
||||||
const AddUserDrawerRef = ref(null)
|
const AddUserDrawerRef = ref(null)
|
||||||
|
const StoreWineManagementRef = ref(null)
|
||||||
|
|
||||||
const queryForm = ref({
|
const queryForm = ref({
|
||||||
key: '',
|
key: '',
|
||||||
|
|||||||
@@ -118,7 +118,7 @@ async function printHandle(type) {
|
|||||||
case "normal":
|
case "normal":
|
||||||
// 打印订单小票
|
// 打印订单小票
|
||||||
if (printStore.deviceNoteList.length) {
|
if (printStore.deviceNoteList.length) {
|
||||||
printStore.pushReceiptData(commOrderPrintData(originOrderInfo.value));
|
printStore.ORDER(commOrderPrintData(originOrderInfo.value));
|
||||||
} else {
|
} else {
|
||||||
await orderPrint({
|
await orderPrint({
|
||||||
id: orderInfo.value.id,
|
id: orderInfo.value.id,
|
||||||
|
|||||||
@@ -56,6 +56,14 @@
|
|||||||
¥{{ formatDecimal(+scope.row.payAmount) }}
|
¥{{ formatDecimal(+scope.row.payAmount) }}
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
|
<el-table-column label="已退数量">
|
||||||
|
<template v-slot="scope">
|
||||||
|
<div class="column">
|
||||||
|
<div class="row">退单数量:{{ scope.row.refundNum }}</div>
|
||||||
|
<div class="row">退菜数量:{{ scope.row.returnNum }}</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
<el-table-column label="退款数量" width="170">
|
<el-table-column label="退款数量" width="170">
|
||||||
<template v-slot="scope">
|
<template v-slot="scope">
|
||||||
<el-input-number v-model="scope.row.refund_number" :disabled="refundType != 2" :min="0"
|
<el-input-number v-model="scope.row.refund_number" :disabled="refundType != 2" :min="0"
|
||||||
@@ -66,7 +74,7 @@
|
|||||||
</el-table-column>
|
</el-table-column>
|
||||||
</el-table>
|
</el-table>
|
||||||
<template v-if="item.returnGoods.length">
|
<template v-if="item.returnGoods.length">
|
||||||
<div class="tips" style="margin-top: 20px;padding-bottom: 10px;">以下为已退部分退单/退菜</div>
|
<div class="tips" style="margin-top: 20px;padding-bottom: 10px;">以下已完成退菜/退款</div>
|
||||||
<el-table :data="item.returnGoods" brder stripe>
|
<el-table :data="item.returnGoods" brder stripe>
|
||||||
<el-table-column label="商品信息">
|
<el-table-column label="商品信息">
|
||||||
<template v-slot="scope">
|
<template v-slot="scope">
|
||||||
@@ -118,17 +126,19 @@
|
|||||||
<div class="drawer_footer">
|
<div class="drawer_footer">
|
||||||
<div class="btn">
|
<div class="btn">
|
||||||
<el-button type="danger" style="width: 100%;" :loading="loading"
|
<el-button type="danger" style="width: 100%;" :loading="loading"
|
||||||
@click="handleRefund">手动退款</el-button>
|
:disabled="item.onGoods && !item.onGoods.length" @click="handleRefund">手动退款</el-button>
|
||||||
</div>
|
</div>
|
||||||
<div class="btn">
|
<div class="btn">
|
||||||
<el-button type="primary" style="width: 100%;" :loading="loading"
|
<el-button type="primary" style="width: 100%;" :loading="loading"
|
||||||
@click="refundHandle()">原路退回</el-button>
|
:disabled="item.onGood && !item.onGoods.length" @click="refundHandle()">原路退回</el-button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
</el-drawer>
|
</el-drawer>
|
||||||
<takeFoodCode ref="takeFoodCodeRef" title="退款密码" :type="2" input-type="password" placeholder="请输入退款密码"
|
<takeFoodCode ref="takeFoodCodeRef" title="退款密码" :type="2" input-type="password" placeholder="请输入退款密码"
|
||||||
@success="passwordSuccess" />
|
@success="passwordSuccess" />
|
||||||
|
<!-- 退款退菜推库存的操作弹窗 -->
|
||||||
|
<refundConsModal ref="refundConsModalRef" :list="returnList" @success="refundConsModalSuccess" />
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
@@ -142,9 +152,13 @@ import { usePrint } from "@/store/print.js";
|
|||||||
import { useUser } from '@/store/user.js'
|
import { useUser } from '@/store/user.js'
|
||||||
import dayjs from 'dayjs'
|
import dayjs from 'dayjs'
|
||||||
import takeFoodCode from "@/components/takeFoodCode.vue";
|
import takeFoodCode from "@/components/takeFoodCode.vue";
|
||||||
|
import { useGoods } from '@/store/goods.js'
|
||||||
|
import refundConsModal from '@/components/refundConsModal.vue';
|
||||||
|
|
||||||
|
const refundConsModalRef = ref(null)
|
||||||
|
|
||||||
const emits = defineEmits(['success'])
|
const emits = defineEmits(['success'])
|
||||||
|
const goodsStore = useGoods()
|
||||||
const store = useUser()
|
const store = useUser()
|
||||||
const printStore = usePrint();
|
const printStore = usePrint();
|
||||||
const globalStore = useGlobal()
|
const globalStore = useGlobal()
|
||||||
@@ -168,41 +182,83 @@ const takeFoodCodeRef = ref(null)
|
|||||||
const cash = ref(false)
|
const cash = ref(false)
|
||||||
const amountInputRef = ref(null)
|
const amountInputRef = ref(null)
|
||||||
|
|
||||||
|
// 退款推库存的操作
|
||||||
|
function refundConsModalSuccess(e) {
|
||||||
|
refundStock.value = e
|
||||||
|
refundNext()
|
||||||
|
}
|
||||||
|
|
||||||
// 退款密码
|
// 退款密码
|
||||||
|
const returnList = ref([])
|
||||||
|
const refundDetails = ref([])
|
||||||
|
const pwd = ref('')
|
||||||
|
const refundStock = ref('')
|
||||||
|
const rows = ref([])
|
||||||
async function passwordSuccess(e = '') {
|
async function passwordSuccess(e = '') {
|
||||||
try {
|
pwd.value = e
|
||||||
loading.value = true
|
loading.value = true
|
||||||
let rows = tableRef.value.getSelectionRows()
|
rows.value = tableRef.value.getSelectionRows()
|
||||||
let refundDetails = []
|
// if (refundType.value != 1) {
|
||||||
if (refundType.value != 1) {
|
refundDetails.value = tableRef.value.getSelectionRows().map(val => {
|
||||||
refundDetails = tableRef.value.getSelectionRows().map(val => {
|
|
||||||
return {
|
return {
|
||||||
|
refundMode: val.refundMode,
|
||||||
|
name: val.productName,
|
||||||
id: val.id,
|
id: val.id,
|
||||||
returnAmount: val.payAmount,
|
returnAmount: val.payAmount,
|
||||||
num: val.refund_number
|
num: val.refund_number
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
// }
|
||||||
|
|
||||||
|
// 处理退菜退款的库存逻辑 判断有没有returnMode = 3,然后弹窗提示 start
|
||||||
|
console.log('refundDetails===', refundDetails.value);
|
||||||
|
refundDetails.value.forEach(item => {
|
||||||
|
if (item.refundMode == 3) {
|
||||||
|
returnList.value.push({
|
||||||
|
name: item.name,
|
||||||
|
num: item.num
|
||||||
|
})
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
console.log('returnList===', returnList.value);
|
||||||
|
|
||||||
|
// 显示退菜退款的弹窗
|
||||||
|
if (returnList.value.length > 0) {
|
||||||
|
refundConsModalRef.value.show()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
// 处理退菜退款的库存逻辑 判断有没有returnMode = 3,然后弹窗提示 end
|
||||||
|
|
||||||
|
refundNext()
|
||||||
|
}
|
||||||
|
|
||||||
|
// 最后的退款操作
|
||||||
|
async function refundNext() {
|
||||||
|
try {
|
||||||
let data = {
|
let data = {
|
||||||
orderId: item.value.id,
|
orderId: item.value.id,
|
||||||
refundAmount: formatDecimal(+refundAmount.value),
|
refundAmount: formatDecimal(+refundAmount.value),
|
||||||
modify: modify.value,
|
modify: modify.value,
|
||||||
cash: cash.value,
|
cash: cash.value,
|
||||||
refundReason: remark.value,
|
refundReason: remark.value,
|
||||||
refundDetails: refundDetails,
|
refundDetails: refundDetails.value,
|
||||||
pwd: e,
|
pwd: pwd.value,
|
||||||
|
operator: store.userInfo.name || store.shopInfo.shopName,
|
||||||
|
print: printStore.deviceNoteList.length ? false : true,
|
||||||
|
refundStock: refundStock.value, // 是否推库存 1退菜图库存 2仅退菜不退库存
|
||||||
};
|
};
|
||||||
|
|
||||||
await refundOrder(data)
|
await refundOrder(data)
|
||||||
ElMessage.success('退款成功')
|
ElMessage.success('退款成功')
|
||||||
await printRefund(rows)
|
// await printRefund(rows.value)
|
||||||
isShow.value = false
|
isShow.value = false
|
||||||
emits('success')
|
emits('success')
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log(error);
|
console.log(error);
|
||||||
}
|
} finally {
|
||||||
loading.value = false
|
loading.value = false
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 显示手动退款
|
// 显示手动退款
|
||||||
@@ -260,6 +316,7 @@ async function printRefund(rows) {
|
|||||||
if (printStore.deviceNoteList.length) {
|
if (printStore.deviceNoteList.length) {
|
||||||
// 本地打印
|
// 本地打印
|
||||||
const data = {
|
const data = {
|
||||||
|
title: '退款单',
|
||||||
shop_name: store.shopInfo.shopName,
|
shop_name: store.shopInfo.shopName,
|
||||||
loginAccount: store.userInfo.name,
|
loginAccount: store.userInfo.name,
|
||||||
carts: [],
|
carts: [],
|
||||||
@@ -268,6 +325,7 @@ async function printRefund(rows) {
|
|||||||
orderInfo: item.value,
|
orderInfo: item.value,
|
||||||
outNumber: item.value.id,
|
outNumber: item.value.id,
|
||||||
createdAt: item.value.createTime,
|
createdAt: item.value.createTime,
|
||||||
|
refundMethod: cash.value ? '线下退款' : '原路退回',
|
||||||
printTime: dayjs().format("YYYY-MM-DD HH:mm:ss"),
|
printTime: dayjs().format("YYYY-MM-DD HH:mm:ss"),
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -275,10 +333,10 @@ async function printRefund(rows) {
|
|||||||
data.carts.push(
|
data.carts.push(
|
||||||
{
|
{
|
||||||
name: item.productName,
|
name: item.productName,
|
||||||
number: item.num,
|
number: item.refund_number,
|
||||||
skuName: item.skuName,
|
skuName: item.skuName,
|
||||||
salePrice: formatDecimal(+item.unitPrice),
|
salePrice: formatDecimal(+item.unitPrice),
|
||||||
totalAmount: formatDecimal(+item.payAmount)
|
totalAmount: formatDecimal(+item.unitPrice * item.refund_number)
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
@@ -286,8 +344,8 @@ async function printRefund(rows) {
|
|||||||
printStore.printRefund(data);
|
printStore.printRefund(data);
|
||||||
} else {
|
} else {
|
||||||
// 云打印
|
// 云打印
|
||||||
await orderPrint({ id: item.value.id, type: 2 })
|
// await orderPrint({ id: item.value.id, type: 2 })
|
||||||
ElMessage.success('云打印退款单成功')
|
// ElMessage.success('云打印退款单成功')
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log(error);
|
console.log(error);
|
||||||
@@ -337,6 +395,29 @@ function show(row) {
|
|||||||
|
|
||||||
isShow.value = true
|
isShow.value = true
|
||||||
let newRow = { ...row }
|
let newRow = { ...row }
|
||||||
|
|
||||||
|
// 在这里给订单的商品补全库存信息 start
|
||||||
|
console.log('originGoodsList===', goodsStore.originGoodsList);
|
||||||
|
newRow.goods.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('newRow.goods===', newRow.goods);
|
||||||
|
// 在这里给订单的商品补全库存信息 end
|
||||||
|
|
||||||
remark.value = ''
|
remark.value = ''
|
||||||
|
|
||||||
let onGoods = []
|
let onGoods = []
|
||||||
@@ -345,14 +426,25 @@ function show(row) {
|
|||||||
// 可退的最大数量,下单数量 - 已退数量 - 退菜数量
|
// 可退的最大数量,下单数量 - 已退数量 - 退菜数量
|
||||||
let refundMaxNum = item.num - item.refundNum - item.returnNum
|
let refundMaxNum = item.num - item.refundNum - item.returnNum
|
||||||
|
|
||||||
if (refundMaxNum <= 0) {
|
// if (refundMaxNum <= 0) {
|
||||||
item.refund_number = item.num
|
// item.refund_number = item.num
|
||||||
// 已经退过,不在允许操作
|
// // 已经退过,不在允许操作
|
||||||
returnGoods.push(item)
|
// returnGoods.push(item)
|
||||||
} else {
|
// } else {
|
||||||
|
// // 可以操作的退款数量
|
||||||
|
// item.refund_number = item.num
|
||||||
|
// onGoods.push(item)
|
||||||
|
// }
|
||||||
|
item.refund_number = refundMaxNum
|
||||||
|
// if (item.refundNum > 0 || item.returnNum > 0) {
|
||||||
|
// // 已经退过,不在允许操作
|
||||||
|
// returnGoods.push(item)
|
||||||
|
// }
|
||||||
// 可以操作的退款数量
|
// 可以操作的退款数量
|
||||||
item.refund_number = item.num
|
if (refundMaxNum > 0) {
|
||||||
onGoods.push(item)
|
onGoods.push(item)
|
||||||
|
} else {
|
||||||
|
returnGoods.push(item)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -361,6 +453,8 @@ function show(row) {
|
|||||||
|
|
||||||
item.value = newRow
|
item.value = newRow
|
||||||
|
|
||||||
|
console.log('item.value===', item.value);
|
||||||
|
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
tableRef.value.clearSelection()
|
tableRef.value.clearSelection()
|
||||||
refundTypeChange(1)
|
refundTypeChange(1)
|
||||||
|
|||||||
@@ -168,7 +168,7 @@
|
|||||||
<!-- 打印操作 -->
|
<!-- 打印操作 -->
|
||||||
<PrintDrawer ref="PrintDrawerRef" />
|
<PrintDrawer ref="PrintDrawerRef" />
|
||||||
<!-- 结算订单 -->
|
<!-- 结算订单 -->
|
||||||
<SettleAccount ref="SettleAccountRef" @success="orderListAjax" />
|
<SettleAccount ref="SettleAccountRef" type="order" @success="orderListAjax" />
|
||||||
<!-- 全部商品 -->
|
<!-- 全部商品 -->
|
||||||
<allGoodsDialog ref="allGoodsDialogRef" />
|
<allGoodsDialog ref="allGoodsDialogRef" />
|
||||||
</template>
|
</template>
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
<!-- 空闲台桌 -->
|
<!-- 空闲台桌 -->
|
||||||
<template>
|
<template>
|
||||||
<div class="table_wrap">
|
<div class="table_wrap">
|
||||||
<div class="header">
|
<!-- <div class="header">
|
||||||
<span class="t">{{ props.tableInfo.name }}</span>
|
<span class="t">{{ props.tableInfo.name }}</span>
|
||||||
<div class="close" @click="close">
|
<div class="close" @click="close">
|
||||||
<el-icon class="icon">
|
<el-icon class="icon">
|
||||||
@@ -14,14 +14,29 @@
|
|||||||
<Clock />
|
<Clock />
|
||||||
</el-icon>
|
</el-icon>
|
||||||
<span class="t">{{tableStatusList.find(val => val.type == props.tableInfo.status).label}}</span>
|
<span class="t">{{tableStatusList.find(val => val.type == props.tableInfo.status).label}}</span>
|
||||||
</div>
|
</div> -->
|
||||||
<div class="cart" v-loading="payLoading" v-if="props.tableInfo.status == 'unsettled'">
|
<div class="cart" v-loading="payLoading" v-if="props.tableInfo.status == 'unsettled'">
|
||||||
<div class="cart_list">
|
<div class="cart_list">
|
||||||
<div class="item" v-for="item in cartList" :key="item.id">
|
<div class="item" v-for="item in cartList" :key="item.id">
|
||||||
<div class="top">
|
<div class="top">
|
||||||
<span class="name">{{ item.productName }}</span>
|
<span class="name">
|
||||||
<span class="n">x{{ item.num }}</span>
|
<span v-if="item.isTemporary" style="color: #999;">[临时菜]</span>
|
||||||
<span class="p">¥{{ item.price }}</span>
|
<span v-if="item.isGift" style="color: #999;">[赠]</span>
|
||||||
|
{{ item.productName }}
|
||||||
|
</span>
|
||||||
|
<span class="n">x{{ item.num - item.returnNum }}</span>
|
||||||
|
<span class="p">¥{{ item.unitPrice }}</span>
|
||||||
|
</div>
|
||||||
|
<div class="top" v-if="item.returnNum > 0" style="font-size: 12px;color: #999;">
|
||||||
|
<span class="name">[退菜]</span>
|
||||||
|
<span class="n">x{{ item.returnNum }}</span>
|
||||||
|
<span class="p">-¥{{ item.returnNum * item.price }}</span>
|
||||||
|
</div>
|
||||||
|
<div class="top" v-if="item.discountSaleAmount > 0 && item.isTemporary == 0"
|
||||||
|
style="font-size: 12px;color: #999;">
|
||||||
|
<span class="name">[改价优惠]</span>
|
||||||
|
<span class="n"></span>
|
||||||
|
<span class="p">-¥{{ item.price - item.unitPrice }}</span>
|
||||||
</div>
|
</div>
|
||||||
<div class="tag_wrap" v-if="item.skuName">
|
<div class="tag_wrap" v-if="item.skuName">
|
||||||
<div class="tag" v-for="item in item.skuName.split(',')">
|
<div class="tag" v-for="item in item.skuName.split(',')">
|
||||||
@@ -56,6 +71,9 @@
|
|||||||
<div class="btn_wrap" v-if="props.tableInfo.status == 'settled'">
|
<div class="btn_wrap" v-if="props.tableInfo.status == 'settled'">
|
||||||
<el-button type="primary" style="width: 100%;" @click="clearTableStatus">清理完成</el-button>
|
<el-button type="primary" style="width: 100%;" @click="clearTableStatus">清理完成</el-button>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="btn_wrap" v-if="props.tableInfo.status == 'unbound'">
|
||||||
|
<el-button type="default" disabled style="width: 100%;">{{ props.tableInfo.statusMsg }}</el-button>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<transition name="el-fade-in">
|
<transition name="el-fade-in">
|
||||||
<div class="people_num_wrap" v-show="showPeopleNum">
|
<div class="people_num_wrap" v-show="showPeopleNum">
|
||||||
@@ -77,7 +95,7 @@
|
|||||||
</transition>
|
</transition>
|
||||||
</div>
|
</div>
|
||||||
<!-- 结算订单 -->
|
<!-- 结算订单 -->
|
||||||
<SettleAccount ref="SettleAccountRef" @success="emits('success')" />
|
<SettleAccount ref="SettleAccountRef" type="table" @success="emits('success')" />
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@@ -182,9 +200,8 @@ async function getOrderDetail() {
|
|||||||
|
|
||||||
let total = 0
|
let total = 0
|
||||||
res.cartList.forEach(item => {
|
res.cartList.forEach(item => {
|
||||||
total += item.payAmount * item.num
|
total += +item.payAmount - (item.returnNum * item.price)
|
||||||
})
|
})
|
||||||
|
|
||||||
orderInfo.value.orderAmount = formatDecimal(total)
|
orderInfo.value.orderAmount = formatDecimal(total)
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
@@ -257,7 +274,8 @@ onMounted(() => {
|
|||||||
|
|
||||||
<style scoped lang="scss">
|
<style scoped lang="scss">
|
||||||
.table_wrap {
|
.table_wrap {
|
||||||
padding: 20px;
|
// padding: 20px;
|
||||||
|
padding-top: 14px;
|
||||||
|
|
||||||
.header {
|
.header {
|
||||||
display: flex;
|
display: flex;
|
||||||
@@ -299,14 +317,14 @@ onMounted(() => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.cart {
|
.cart {
|
||||||
height: calc(100vh - 160px);
|
height: calc(100vh - 75px);
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
|
|
||||||
.cart_list {
|
.cart_list {
|
||||||
flex: 1;
|
flex: 1;
|
||||||
border-radius: 6px;
|
border-radius: 6px;
|
||||||
background-color: #efefef;
|
background-color: #fff;
|
||||||
padding: 0 var(--el-font-size-base);
|
padding: 0 var(--el-font-size-base);
|
||||||
overflow-y: auto;
|
overflow-y: auto;
|
||||||
|
|
||||||
|
|||||||
@@ -5,42 +5,57 @@
|
|||||||
<div class="menus">
|
<div class="menus">
|
||||||
<div class="item" :class="{ active: tabActive == index }" v-for="(item, index) in tabAreas"
|
<div class="item" :class="{ active: tabActive == index }" v-for="(item, index) in tabAreas"
|
||||||
:key="item.id" @click="tabChange(item, index)">
|
:key="item.id" @click="tabChange(item, index)">
|
||||||
|
<div class="dot" :style="{ backgroundColor: item.color }" v-if="item.color"></div>
|
||||||
<el-text>{{ item.label }}</el-text>
|
<el-text>{{ item.label }}</el-text>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<!-- <div class="all">
|
<!-- <div class="all">
|
||||||
<el-button type="link" icon="Clock">预定管理</el-button>
|
<el-button type="link" icon="Clock">预定管理</el-button>
|
||||||
</div> -->
|
</div> -->
|
||||||
|
<div class="order_info">
|
||||||
|
<div class="title">
|
||||||
|
<el-icon>
|
||||||
|
<Tickets />
|
||||||
|
</el-icon>
|
||||||
|
<el-text>未结账:</el-text>
|
||||||
|
</div>
|
||||||
|
<el-text type="primary">
|
||||||
|
{{ orderInfo.num }}笔 | {{ orderInfo.personNum }}人 | ¥{{ formatDecimal(orderInfo.amount) }}
|
||||||
|
</el-text>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="tab_container">
|
<div class="tab_container">
|
||||||
<div class="tab_head">
|
<div class="tab_head" ref="tabHeadRef">
|
||||||
<el-radio-group v-model="area" @change="shopTableAjax">
|
<div class="item" :class="{ active: tabItemActive == -1 }" @click="tabItemChange('', -1)">全部</div>
|
||||||
<el-radio-button label="全部" value=""></el-radio-button>
|
<div class="item" :class="{ active: index == tabItemActive }" v-for="(item, index) in areaList"
|
||||||
<el-radio-button :label="item.name" :value="item.id" v-for="item in areaList"
|
:key="item.id" @click="tabItemChange(item, index)">
|
||||||
:key="item.id"></el-radio-button>
|
{{ item.name }}
|
||||||
</el-radio-group>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="overflow_y" v-loading="loading">
|
<div class="overflow_y" v-loading="loading">
|
||||||
<div class="tab_list">
|
<div class="tab_list">
|
||||||
<div class="item" :class="{ active: tableItemActive == index }"
|
<div class="item"
|
||||||
:style="{ '--color': tableStatusList.find(val => val.type == item.status).color }"
|
:style="{ '--color': tableStatusList.find(val => val.type == item.status).color }"
|
||||||
v-for="(item, index) in tableList" :key="item.id" @click="slectTableHandle(index, item)">
|
v-for="(item, index) in tableList" :key="item.id" @click="slectTableHandle(index, item)">
|
||||||
<div class="tab_title" :class="`${item.status}`">
|
<div class="tab_title" :class="`${item.status}`">
|
||||||
<span>{{ item.name }}</span>
|
<span>{{ item.areaName }} | {{ item.name }}</span>
|
||||||
<span>0/{{ item.maxCapacity }}</span>
|
<span>{{ item.personNum || 0 }}/{{ item.maxCapacity }}</span>
|
||||||
</div>
|
</div>
|
||||||
<div class="tab_cont">
|
<div class="tab_cont">
|
||||||
<el-icon class="icon" v-if="item.status != 'using'">
|
<div class="using"
|
||||||
<CircleClose />
|
v-if="item.status == 'unsettled' || item.status == 'unsettled' || item.status == 'paying' || item.status == 'settled' || item.status == 'unpaid'">
|
||||||
</el-icon>
|
<div class="t1">¥{{ formatDecimal(+item.orderAmount) }}</div>
|
||||||
<div class="using" v-else>
|
<div class="t2">
|
||||||
<div class="t1">开台中</div>
|
<el-icon color="#333">
|
||||||
<!-- <div class="t2">
|
|
||||||
<el-icon>
|
|
||||||
<Timer />
|
<Timer />
|
||||||
</el-icon>
|
</el-icon>
|
||||||
<span>{{ countTime(item.updatedAt) }}</span>
|
<span :key="refreshKey">{{ countTime(item.orderCreateTime) }}</span>
|
||||||
</div> -->
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="icon_wrap" v-else>
|
||||||
|
<el-icon class="icon">
|
||||||
|
<CircleClose />
|
||||||
|
</el-icon>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -49,19 +64,22 @@
|
|||||||
<el-empty description="空空如也~" />
|
<el-empty description="空空如也~" />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="pagination">
|
<!-- <div class="pagination">
|
||||||
<el-pagination background v-model:current-page="query.page" :pager-count="5"
|
<el-pagination background v-model:current-page="query.page" :pager-count="5"
|
||||||
layout=" pager, jumper, total" :total="query.total"
|
layout=" pager, jumper, total" :total="query.total"
|
||||||
@current-change="shopTableAjax"></el-pagination>
|
@current-change="shopTableAjax"></el-pagination>
|
||||||
|
</div> -->
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
<el-drawer v-model="drawerVisible"
|
||||||
<div class="right_card card">
|
:title="`${tableList[tableItemActive].areaName} | ${tableList[tableItemActive].name} (${tableList[tableItemActive].personNum || 0}/${tableList[tableItemActive].maxCapacity})`"
|
||||||
<!-- 台桌统计 -->
|
size="35%" v-if="tableList.length">
|
||||||
|
<tableInfo :tableInfo="tableList[tableItemActive]" @success="paySuccess" />
|
||||||
|
</el-drawer>
|
||||||
|
<!-- <div class="right_card card">
|
||||||
<countCard v-if="!slectTable.id" />
|
<countCard v-if="!slectTable.id" />
|
||||||
<!-- 台桌信息 -->
|
|
||||||
<tableInfo v-else :tableInfo="slectTable" @close="slectTableClose" @success="paySuccess" />
|
<tableInfo v-else :tableInfo="slectTable" @close="slectTableClose" @success="paySuccess" />
|
||||||
</div>
|
</div> -->
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@@ -69,9 +87,16 @@
|
|||||||
import { shopArea, shopTable } from "@/api/account.js";
|
import { shopArea, shopTable } from "@/api/account.js";
|
||||||
import countCard from '@/views/table/components/countCard.vue'
|
import countCard from '@/views/table/components/countCard.vue'
|
||||||
import tableInfo from '@/views/table/components/tableInfo.vue'
|
import tableInfo from '@/views/table/components/tableInfo.vue'
|
||||||
import { ref, onMounted } from 'vue'
|
import { ref, onMounted, onUnmounted, nextTick } from 'vue'
|
||||||
import { dayjs } from 'element-plus'
|
import { dayjs } from 'element-plus'
|
||||||
import tableStatusList from './statusList.js'
|
import tableStatusList from './statusList.js'
|
||||||
|
import { formatDecimal } from '@/utils/index.js'
|
||||||
|
|
||||||
|
const orderInfo = ref({
|
||||||
|
num: 0,
|
||||||
|
personNum: 0,
|
||||||
|
amount: 0
|
||||||
|
})
|
||||||
|
|
||||||
const tabActive = ref(0)
|
const tabActive = ref(0)
|
||||||
const tabAreas = ref([
|
const tabAreas = ref([
|
||||||
@@ -82,18 +107,22 @@ const tabAreas = ref([
|
|||||||
{
|
{
|
||||||
label: '空闲',
|
label: '空闲',
|
||||||
type: 'idle',
|
type: 'idle',
|
||||||
|
color: "#187CAA",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: '使用中',
|
label: '使用中',
|
||||||
type: 'unsettled'
|
type: 'unsettled',
|
||||||
|
color: "#DD3F41",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: '待清理',
|
label: '待清理',
|
||||||
type: 'settled',
|
type: 'settled',
|
||||||
|
color: "#FF9500",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: '已预订',
|
label: '已预订',
|
||||||
type: 'subscribe',
|
type: 'subscribe',
|
||||||
|
color: "#58B22C",
|
||||||
}
|
}
|
||||||
])
|
])
|
||||||
|
|
||||||
@@ -110,7 +139,7 @@ const tableList = ref([])
|
|||||||
// 所选区域
|
// 所选区域
|
||||||
const area = ref('')
|
const area = ref('')
|
||||||
// 选择台桌索引
|
// 选择台桌索引
|
||||||
const tableItemActive = ref(-1)
|
const tableItemActive = ref(0)
|
||||||
// 选择台桌信息
|
// 选择台桌信息
|
||||||
const slectTable = ref('')
|
const slectTable = ref('')
|
||||||
|
|
||||||
@@ -120,33 +149,89 @@ function tabChange(item, index) {
|
|||||||
shopTableAjax()
|
shopTableAjax()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const tabItemActive = ref(-1)
|
||||||
|
function tabItemChange(item, index) {
|
||||||
|
tabItemActive.value = index
|
||||||
|
if (index == -1) {
|
||||||
|
area.value = ''
|
||||||
|
} else {
|
||||||
|
area.value = item.id
|
||||||
|
}
|
||||||
|
shopTableAjax()
|
||||||
|
|
||||||
|
nextTick(() => {
|
||||||
|
scrollTabToCenter()
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// 自动居中滚动
|
||||||
|
const tabHeadRef = ref(null)
|
||||||
|
function scrollTabToCenter() {
|
||||||
|
const container = tabHeadRef.value
|
||||||
|
if (!container) return
|
||||||
|
|
||||||
|
// 获取当前激活的 item
|
||||||
|
const activeItem = container.querySelector('.item.active')
|
||||||
|
if (!activeItem) return
|
||||||
|
|
||||||
|
// 计算居中位置
|
||||||
|
const containerWidth = container.offsetWidth
|
||||||
|
const itemWidth = activeItem.offsetWidth
|
||||||
|
const itemLeft = activeItem.offsetLeft
|
||||||
|
|
||||||
|
// 滚动到中间(核心公式)
|
||||||
|
container.scrollTo({
|
||||||
|
left: itemLeft - containerWidth / 2 + itemWidth / 2,
|
||||||
|
behavior: 'smooth' // 丝滑滚动
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
// 计算当前的时间差
|
// 计算当前的时间差
|
||||||
function countTime(t) {
|
function countTime(t) {
|
||||||
let ctime = dayjs().valueOf()
|
if (!t) return '0小时1分'
|
||||||
return dayjs(ctime - t).format('H小时m分')
|
|
||||||
|
const now = dayjs().valueOf()
|
||||||
|
const createTime = dayjs(t).valueOf()
|
||||||
|
|
||||||
|
let diff = now - createTime
|
||||||
|
|
||||||
|
// 负数 或 小于1分钟,都强制显示 0小时1分
|
||||||
|
if (diff < 0 || diff < 60 * 1000) {
|
||||||
|
return '0小时1分'
|
||||||
|
}
|
||||||
|
|
||||||
|
const h = Math.floor(diff / 3600000)
|
||||||
|
const m = Math.floor((diff % 3600000) / 60000)
|
||||||
|
|
||||||
|
return `${h}小时${m}分`
|
||||||
}
|
}
|
||||||
|
|
||||||
// 支付成功,刷新状态
|
// 支付成功,刷新状态
|
||||||
async function paySuccess() {
|
async function paySuccess() {
|
||||||
|
drawerVisible.value = false
|
||||||
await shopTableAjax()
|
await shopTableAjax()
|
||||||
slectTableHandle(tableItemActive.value, tableList.value[tableItemActive.value])
|
// slectTableHandle(tableItemActive.value, tableList.value[tableItemActive.value])
|
||||||
}
|
}
|
||||||
|
|
||||||
// 选择台桌
|
// 选择台桌
|
||||||
|
const drawerVisible = ref(false)
|
||||||
function slectTableHandle(index, item) {
|
function slectTableHandle(index, item) {
|
||||||
if (tableItemActive.value == index) {
|
|
||||||
tableItemActive.value = -1
|
|
||||||
slectTable.value = ''
|
|
||||||
} else {
|
|
||||||
tableItemActive.value = index
|
tableItemActive.value = index
|
||||||
slectTable.value = item
|
drawerVisible.value = true
|
||||||
}
|
// if (tableItemActive.value == index) {
|
||||||
|
// tableItemActive.value = -1
|
||||||
|
// slectTable.value = ''
|
||||||
|
// } else {
|
||||||
|
// tableItemActive.value = index
|
||||||
|
// slectTable.value = item
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
// 关闭台桌
|
// 关闭台桌
|
||||||
function slectTableClose() {
|
function slectTableClose() {
|
||||||
tableItemActive.value = -1
|
tableItemActive.value = -1
|
||||||
slectTable.value = ''
|
slectTable.value = ''
|
||||||
|
drawerVisible.value = false
|
||||||
}
|
}
|
||||||
|
|
||||||
// 获取台桌区域
|
// 获取台桌区域
|
||||||
@@ -163,12 +248,21 @@ async function shopAreaAjax() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 获取台桌列表
|
// 获取台桌列表
|
||||||
async function shopTableAjax() {
|
async function shopTableAjax(isLoading = true) {
|
||||||
try {
|
try {
|
||||||
|
orderInfo.value = {
|
||||||
|
num: 0,
|
||||||
|
personNum: 0,
|
||||||
|
amount: 0
|
||||||
|
}
|
||||||
|
if (isLoading) {
|
||||||
loading.value = true
|
loading.value = true
|
||||||
|
}
|
||||||
const res = await shopTable({
|
const res = await shopTable({
|
||||||
page: query.value.page,
|
// page: query.value.page,
|
||||||
size: query.value.size,
|
// size: query.value.size,
|
||||||
|
page: 1,
|
||||||
|
size: 999,
|
||||||
areaId: area.value,
|
areaId: area.value,
|
||||||
tableCode: '',
|
tableCode: '',
|
||||||
name: '',
|
name: '',
|
||||||
@@ -176,19 +270,60 @@ async function shopTableAjax() {
|
|||||||
})
|
})
|
||||||
tableList.value = res.records
|
tableList.value = res.records
|
||||||
query.value.total = +res.totalRow
|
query.value.total = +res.totalRow
|
||||||
|
|
||||||
|
tableList.value.forEach(item => {
|
||||||
|
if (item.status == 'unsettled') {
|
||||||
|
orderInfo.value.num += 1
|
||||||
|
orderInfo.value.personNum += item.personNum || 0
|
||||||
|
orderInfo.value.amount += item.orderAmount || 0
|
||||||
|
}
|
||||||
|
})
|
||||||
|
if (isLoading) {
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
loading.value = false
|
loading.value = false
|
||||||
}, 500)
|
}, 500)
|
||||||
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
if (isLoading) {
|
||||||
loading.value = false
|
loading.value = false
|
||||||
|
}
|
||||||
console.log(error)
|
console.log(error)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const refreshKey = ref(0)
|
||||||
|
|
||||||
|
// 精准【每分钟 00 秒】自动刷新时间(和时钟完全同步)
|
||||||
|
let timeTimer = null
|
||||||
|
|
||||||
|
function syncMinuteRefresh() {
|
||||||
|
// 1. 计算当前时间距离下一个 00 秒还剩多少毫秒
|
||||||
|
const now = new Date()
|
||||||
|
const seconds = now.getSeconds()
|
||||||
|
const delay = (60 - seconds) * 1000 // 等到下一个整分钟
|
||||||
|
|
||||||
|
// 2. 等到整分钟时,执行一次刷新
|
||||||
|
setTimeout(() => {
|
||||||
|
refreshKey.value++ // 刷新时间
|
||||||
|
|
||||||
|
// 3. 之后每 60 秒执行一次(永远在 00 秒刷新)
|
||||||
|
timeTimer = setInterval(() => {
|
||||||
|
refreshKey.value++
|
||||||
|
}, 60000)
|
||||||
|
}, delay)
|
||||||
|
}
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
shopAreaAjax()
|
shopAreaAjax()
|
||||||
shopTableAjax()
|
shopTableAjax()
|
||||||
|
syncMinuteRefresh()
|
||||||
})
|
})
|
||||||
|
|
||||||
|
// 销毁清理
|
||||||
|
onUnmounted(() => {
|
||||||
|
clearInterval(timeTimer)
|
||||||
|
})
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped lang="scss">
|
<style scoped lang="scss">
|
||||||
@@ -219,7 +354,7 @@ onMounted(() => {
|
|||||||
padding: 0 10px;
|
padding: 0 10px;
|
||||||
|
|
||||||
.item {
|
.item {
|
||||||
padding: 0 10px;
|
padding: 0 20px;
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
position: relative;
|
position: relative;
|
||||||
@@ -228,6 +363,13 @@ onMounted(() => {
|
|||||||
font-size: var(--el-font-size-base);
|
font-size: var(--el-font-size-base);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.dot {
|
||||||
|
width: 8px;
|
||||||
|
height: 8px;
|
||||||
|
border-radius: 50%;
|
||||||
|
margin-right: 6px;
|
||||||
|
}
|
||||||
|
|
||||||
&.active {
|
&.active {
|
||||||
|
|
||||||
&::after {
|
&::after {
|
||||||
@@ -252,35 +394,82 @@ onMounted(() => {
|
|||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.order_info {
|
||||||
|
display: flex;
|
||||||
|
padding-right: 14px;
|
||||||
|
|
||||||
|
.title {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 4px;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.tab_container {
|
.tab_container {
|
||||||
padding: var(--el-font-size-base);
|
padding: var(--el-font-size-base);
|
||||||
|
|
||||||
.tab_head {
|
.tab_head {
|
||||||
|
width: calc(100vw - 125px);
|
||||||
padding-bottom: var(--el-font-size-base);
|
padding-bottom: var(--el-font-size-base);
|
||||||
|
overflow-x: auto;
|
||||||
|
white-space: nowrap;
|
||||||
|
|
||||||
|
/* 隐藏滚动条(通用) */
|
||||||
|
scrollbar-width: none;
|
||||||
|
-ms-overflow-style: none;
|
||||||
|
|
||||||
|
|
||||||
|
.item {
|
||||||
|
height: 42px;
|
||||||
|
display: inline-flex;
|
||||||
|
align-items: center;
|
||||||
|
padding: 4px 12px;
|
||||||
|
border-radius: 4px;
|
||||||
|
background-color: #f5f5f5;
|
||||||
|
margin-right: 10px;
|
||||||
|
|
||||||
|
&.active {
|
||||||
|
background-color: var(--primary-color);
|
||||||
|
color: #fff;
|
||||||
|
}
|
||||||
|
|
||||||
|
&:hover {
|
||||||
|
cursor: pointer;
|
||||||
|
background-color: var(--primary-color);
|
||||||
|
color: #fff;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 隐藏滚动条(Chrome / Electron / Edge) */
|
||||||
|
.tab_head::-webkit-scrollbar {
|
||||||
|
display: none !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
.overflow_y {
|
.overflow_y {
|
||||||
height: calc(100vh - 220px);
|
// height: calc(100vh - 220px);
|
||||||
|
height: calc(100vh - 162px);
|
||||||
overflow-y: auto;
|
overflow-y: auto;
|
||||||
}
|
}
|
||||||
|
|
||||||
.tab_list {
|
.tab_list {
|
||||||
display: grid;
|
display: grid;
|
||||||
grid-template-columns: 1fr 1fr 1fr 1fr;
|
grid-template-columns: 1fr 1fr 1fr 1fr 1fr;
|
||||||
grid-template-rows: auto;
|
grid-template-rows: auto;
|
||||||
gap: 10px;
|
gap: 10px;
|
||||||
|
|
||||||
.item {
|
.item {
|
||||||
border-radius: 6px;
|
border-radius: 6px;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
padding: 2px;
|
padding: 4px;
|
||||||
background-color: var(--color);
|
background-color: var(--color);
|
||||||
|
|
||||||
&.active {
|
&.active {
|
||||||
.tab_cont {
|
.tab_cont {
|
||||||
position: relative;
|
position: relative;
|
||||||
|
|
||||||
&::before {
|
&::before {
|
||||||
content: "";
|
content: "";
|
||||||
width: 100%;
|
width: 100%;
|
||||||
@@ -306,17 +495,37 @@ onMounted(() => {
|
|||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
padding: 0 10px;
|
padding: 0 10px;
|
||||||
color: #fff;
|
color: #fff;
|
||||||
|
gap: 4px;
|
||||||
|
|
||||||
|
span:nth-child(1) {
|
||||||
|
/* 核心:最多两行,超出... */
|
||||||
|
display: -webkit-box;
|
||||||
|
-webkit-line-clamp: 2;
|
||||||
|
/* 最多2行 */
|
||||||
|
-webkit-box-orient: vertical;
|
||||||
|
overflow: hidden;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
|
||||||
|
/* 保证换行正常 */
|
||||||
|
white-space: normal;
|
||||||
|
word-break: break-all;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.tab_cont {
|
.tab_cont {
|
||||||
height: 112px;
|
height: 108px;
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
|
||||||
justify-content: center;
|
|
||||||
background-color: #fff;
|
background-color: #fff;
|
||||||
border-radius: 4px;
|
border-radius: 4px;
|
||||||
position: relative;
|
position: relative;
|
||||||
|
|
||||||
|
.icon_wrap {
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
|
||||||
.icon {
|
.icon {
|
||||||
color: var(--color);
|
color: var(--color);
|
||||||
font-size: 30px;
|
font-size: 30px;
|
||||||
@@ -325,6 +534,29 @@ onMounted(() => {
|
|||||||
z-index: 2
|
z-index: 2
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.using {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
justify-content: center;
|
||||||
|
gap: 20px;
|
||||||
|
padding-left: 14px;
|
||||||
|
|
||||||
|
.t1 {
|
||||||
|
color: #333;
|
||||||
|
}
|
||||||
|
|
||||||
|
.t2 {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 4px;
|
||||||
|
|
||||||
|
span {
|
||||||
|
color: #555;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
331
src/views/table/index20260328.vue
Normal file
331
src/views/table/index20260328.vue
Normal file
@@ -0,0 +1,331 @@
|
|||||||
|
<template>
|
||||||
|
<div class="content">
|
||||||
|
<div class="cart_wrap card">
|
||||||
|
<div class="header">
|
||||||
|
<div class="menus">
|
||||||
|
<div class="item" :class="{ active: tabActive == index }" v-for="(item, index) in tabAreas"
|
||||||
|
:key="item.id" @click="tabChange(item, index)">
|
||||||
|
<el-text>{{ item.label }}</el-text>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<!-- <div class="all">
|
||||||
|
<el-button type="link" icon="Clock">预定管理</el-button>
|
||||||
|
</div> -->
|
||||||
|
</div>
|
||||||
|
<div class="tab_container">
|
||||||
|
<div class="tab_head">
|
||||||
|
<el-radio-group v-model="area" @change="shopTableAjax">
|
||||||
|
<el-radio-button label="全部" value=""></el-radio-button>
|
||||||
|
<el-radio-button :label="item.name" :value="item.id" v-for="item in areaList"
|
||||||
|
:key="item.id"></el-radio-button>
|
||||||
|
</el-radio-group>
|
||||||
|
</div>
|
||||||
|
<div class="overflow_y" v-loading="loading">
|
||||||
|
<div class="tab_list">
|
||||||
|
<div class="item" :class="{ active: tableItemActive == index }"
|
||||||
|
:style="{ '--color': tableStatusList.find(val => val.type == item.status).color }"
|
||||||
|
v-for="(item, index) in tableList" :key="item.id" @click="slectTableHandle(index, item)">
|
||||||
|
<div class="tab_title" :class="`${item.status}`">
|
||||||
|
<span>{{ item.name }}</span>
|
||||||
|
<span>0/{{ item.maxCapacity }}</span>
|
||||||
|
</div>
|
||||||
|
<div class="tab_cont">
|
||||||
|
<el-icon class="icon" v-if="item.status != 'using'">
|
||||||
|
<CircleClose />
|
||||||
|
</el-icon>
|
||||||
|
<div class="using" v-else>
|
||||||
|
<div class="t1">开台中</div>
|
||||||
|
<!-- <div class="t2">
|
||||||
|
<el-icon>
|
||||||
|
<Timer />
|
||||||
|
</el-icon>
|
||||||
|
<span>{{ countTime(item.updatedAt) }}</span>
|
||||||
|
</div> -->
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="empty" v-if="!tableList.length">
|
||||||
|
<el-empty description="空空如也~" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="pagination">
|
||||||
|
<el-pagination background v-model:current-page="query.page" :pager-count="5"
|
||||||
|
layout=" pager, jumper, total" :total="query.total"
|
||||||
|
@current-change="shopTableAjax"></el-pagination>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="right_card card">
|
||||||
|
<!-- 台桌统计 -->
|
||||||
|
<countCard v-if="!slectTable.id" />
|
||||||
|
<!-- 台桌信息 -->
|
||||||
|
<tableInfo v-else :tableInfo="slectTable" @close="slectTableClose" @success="paySuccess" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup>
|
||||||
|
import { shopArea, shopTable } from "@/api/account.js";
|
||||||
|
import countCard from '@/views/table/components/countCard.vue'
|
||||||
|
import tableInfo from '@/views/table/components/tableInfo.vue'
|
||||||
|
import { ref, onMounted } from 'vue'
|
||||||
|
import { dayjs } from 'element-plus'
|
||||||
|
import tableStatusList from './statusList.js'
|
||||||
|
|
||||||
|
const tabActive = ref(0)
|
||||||
|
const tabAreas = ref([
|
||||||
|
{
|
||||||
|
label: '全部',
|
||||||
|
type: '',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '空闲',
|
||||||
|
type: 'idle',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '使用中',
|
||||||
|
type: 'unsettled'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '待清理',
|
||||||
|
type: 'settled',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '已预订',
|
||||||
|
type: 'subscribe',
|
||||||
|
}
|
||||||
|
])
|
||||||
|
|
||||||
|
const query = ref({
|
||||||
|
page: 1,
|
||||||
|
size: 12,
|
||||||
|
total: 0
|
||||||
|
})
|
||||||
|
const loading = ref(false)
|
||||||
|
// 区域列表
|
||||||
|
const areaList = ref([])
|
||||||
|
// 台桌列表
|
||||||
|
const tableList = ref([])
|
||||||
|
// 所选区域
|
||||||
|
const area = ref('')
|
||||||
|
// 选择台桌索引
|
||||||
|
const tableItemActive = ref(-1)
|
||||||
|
// 选择台桌信息
|
||||||
|
const slectTable = ref('')
|
||||||
|
|
||||||
|
// 切换类型
|
||||||
|
function tabChange(item, index) {
|
||||||
|
tabActive.value = index
|
||||||
|
shopTableAjax()
|
||||||
|
}
|
||||||
|
|
||||||
|
// 计算当前的时间差
|
||||||
|
function countTime(t) {
|
||||||
|
let ctime = dayjs().valueOf()
|
||||||
|
return dayjs(ctime - t).format('H小时m分')
|
||||||
|
}
|
||||||
|
|
||||||
|
// 支付成功,刷新状态
|
||||||
|
async function paySuccess() {
|
||||||
|
await shopTableAjax()
|
||||||
|
slectTableHandle(tableItemActive.value, tableList.value[tableItemActive.value])
|
||||||
|
}
|
||||||
|
|
||||||
|
// 选择台桌
|
||||||
|
function slectTableHandle(index, item) {
|
||||||
|
if (tableItemActive.value == index) {
|
||||||
|
tableItemActive.value = -1
|
||||||
|
slectTable.value = ''
|
||||||
|
} else {
|
||||||
|
tableItemActive.value = index
|
||||||
|
slectTable.value = item
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 关闭台桌
|
||||||
|
function slectTableClose() {
|
||||||
|
tableItemActive.value = -1
|
||||||
|
slectTable.value = ''
|
||||||
|
}
|
||||||
|
|
||||||
|
// 获取台桌区域
|
||||||
|
async function shopAreaAjax() {
|
||||||
|
try {
|
||||||
|
const res = await shopArea({
|
||||||
|
page: 1,
|
||||||
|
size: 500
|
||||||
|
})
|
||||||
|
areaList.value = res.records
|
||||||
|
} catch (error) {
|
||||||
|
console.log(error)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 获取台桌列表
|
||||||
|
async function shopTableAjax() {
|
||||||
|
try {
|
||||||
|
loading.value = true
|
||||||
|
const res = await shopTable({
|
||||||
|
page: query.value.page,
|
||||||
|
size: query.value.size,
|
||||||
|
areaId: area.value,
|
||||||
|
tableCode: '',
|
||||||
|
name: '',
|
||||||
|
status: tabAreas.value[tabActive.value].type,
|
||||||
|
})
|
||||||
|
tableList.value = res.records
|
||||||
|
query.value.total = +res.totalRow
|
||||||
|
setTimeout(() => {
|
||||||
|
loading.value = false
|
||||||
|
}, 500)
|
||||||
|
} catch (error) {
|
||||||
|
loading.value = false
|
||||||
|
console.log(error)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
onMounted(() => {
|
||||||
|
shopAreaAjax()
|
||||||
|
shopTableAjax()
|
||||||
|
})
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style scoped lang="scss">
|
||||||
|
.pagination {
|
||||||
|
display: flex;
|
||||||
|
justify-content: flex-end;
|
||||||
|
padding-top: var(--el-font-size-base);
|
||||||
|
}
|
||||||
|
|
||||||
|
.cart_wrap {
|
||||||
|
flex: 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
.right_card {
|
||||||
|
flex: 1;
|
||||||
|
height: 100%;
|
||||||
|
margin-left: var(--el-font-size-base);
|
||||||
|
}
|
||||||
|
|
||||||
|
.header {
|
||||||
|
display: flex;
|
||||||
|
height: var(--el-component-size-large);
|
||||||
|
justify-content: space-between;
|
||||||
|
border-bottom: 1px solid #ececec;
|
||||||
|
|
||||||
|
.menus {
|
||||||
|
display: flex;
|
||||||
|
padding: 0 10px;
|
||||||
|
|
||||||
|
.item {
|
||||||
|
padding: 0 10px;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
position: relative;
|
||||||
|
|
||||||
|
span {
|
||||||
|
font-size: var(--el-font-size-base);
|
||||||
|
}
|
||||||
|
|
||||||
|
&.active {
|
||||||
|
|
||||||
|
&::after {
|
||||||
|
content: "";
|
||||||
|
width: 70%;
|
||||||
|
height: 4px;
|
||||||
|
border-radius: 4px;
|
||||||
|
position: absolute;
|
||||||
|
bottom: 0;
|
||||||
|
left: 15%;
|
||||||
|
background-color: var(--primary-color);
|
||||||
|
}
|
||||||
|
|
||||||
|
span {
|
||||||
|
color: var(--primary-color);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.all {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.tab_container {
|
||||||
|
padding: var(--el-font-size-base);
|
||||||
|
|
||||||
|
.tab_head {
|
||||||
|
padding-bottom: var(--el-font-size-base);
|
||||||
|
}
|
||||||
|
|
||||||
|
.overflow_y {
|
||||||
|
height: calc(100vh - 220px);
|
||||||
|
overflow-y: auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tab_list {
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: 1fr 1fr 1fr 1fr;
|
||||||
|
grid-template-rows: auto;
|
||||||
|
gap: 10px;
|
||||||
|
|
||||||
|
.item {
|
||||||
|
border-radius: 6px;
|
||||||
|
overflow: hidden;
|
||||||
|
padding: 2px;
|
||||||
|
background-color: var(--color);
|
||||||
|
|
||||||
|
&.active {
|
||||||
|
.tab_cont {
|
||||||
|
position: relative;
|
||||||
|
&::before {
|
||||||
|
content: "";
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
position: absolute;
|
||||||
|
top: 0;
|
||||||
|
left: 0;
|
||||||
|
background-color: var(--color);
|
||||||
|
opacity: .2;
|
||||||
|
z-index: 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
&:hover {
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tab_title {
|
||||||
|
height: var(--el-component-size-large);
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: space-between;
|
||||||
|
padding: 0 10px;
|
||||||
|
color: #fff;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tab_cont {
|
||||||
|
height: 112px;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
background-color: #fff;
|
||||||
|
border-radius: 4px;
|
||||||
|
position: relative;
|
||||||
|
|
||||||
|
.icon {
|
||||||
|
color: var(--color);
|
||||||
|
font-size: 30px;
|
||||||
|
transform: rotate(45deg);
|
||||||
|
position: relative;
|
||||||
|
z-index: 2
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@@ -26,7 +26,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="box_content_left_top_item_top">
|
<div class="box_content_left_top_item_top">
|
||||||
<div style="color:#ff5252; font-size: 30px;">
|
<div style="color:#ff5252; font-size: 30px;">
|
||||||
¥{{ formatDecimal(infoData.handAmount || 0) }}
|
¥{{ formatDecimal(infoData.orderTurnover || 0) }}
|
||||||
</div>
|
</div>
|
||||||
<div style="margin-top: 6px; color: #666;">
|
<div style="margin-top: 6px; color: #666;">
|
||||||
营业额
|
营业额
|
||||||
@@ -36,7 +36,7 @@
|
|||||||
<div class="box_content_left_top_item">
|
<div class="box_content_left_top_item">
|
||||||
<div class="box_content_left_top_item_botton">
|
<div class="box_content_left_top_item_botton">
|
||||||
<div style=" font-size: 20px;">
|
<div style=" font-size: 20px;">
|
||||||
¥{{ formatDecimal(infoData.cashAmount || 0) }}
|
¥{{ formatDecimal(infoData.cash || 0) }}
|
||||||
</div>
|
</div>
|
||||||
<div style="margin-top: 6px;">
|
<div style="margin-top: 6px;">
|
||||||
现金支付
|
现金支付
|
||||||
@@ -179,18 +179,19 @@ const exit = async () => {
|
|||||||
if (loading.value) return
|
if (loading.value) return
|
||||||
loading.value = true;
|
loading.value = true;
|
||||||
// await staffPermission('yun_xu_jiao_ban')
|
// await staffPermission('yun_xu_jiao_ban')
|
||||||
const res = await handover(isPrint.value)
|
await handover(printStore.deviceNoteList.length ? 0 : 1)
|
||||||
const data = await handoverData(res)
|
|
||||||
if (printStore.deviceNoteList.length) {
|
if (printStore.deviceNoteList.length) {
|
||||||
|
printStore.printWork(infoData.value)
|
||||||
// 使用本地打印机 打印交班数据
|
// 使用本地打印机 打印交班数据
|
||||||
data.printTime = dayjs().format('YYYY-MM-DD HH:mm:ss')
|
// data.printTime = dayjs().format('YYYY-MM-DD HH:mm:ss')
|
||||||
data.printShop = isPrint.value
|
// data.printShop = isPrint.value
|
||||||
printStore.printWork(data)
|
|
||||||
} else {
|
|
||||||
// 使用云打印机 打印交班数据
|
|
||||||
await handoverNetworkPrint(data.id)
|
|
||||||
}
|
}
|
||||||
|
// else {
|
||||||
|
// // 使用云打印机 打印交班数据
|
||||||
|
// await handoverNetworkPrint(data.id)
|
||||||
|
// }
|
||||||
logoutHandle()
|
logoutHandle()
|
||||||
|
loading.value = false;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
loading.value = false;
|
loading.value = false;
|
||||||
console.log(error);
|
console.log(error);
|
||||||
|
|||||||
Reference in New Issue
Block a user