Compare commits
24 Commits
33be9f2cef
...
test
| Author | SHA1 | Date | |
|---|---|---|---|
| 75be7c0d53 | |||
| 97e0df4621 | |||
| 7f05d42d32 | |||
| 4e1484d4bb | |||
| 1ed8fa8c8e | |||
| 0b8fe251bf | |||
| da6b45e9e9 | |||
| 6aec434015 | |||
| cb8c9139fe | |||
| d5568c48d0 | |||
| fa67997c86 | |||
| 50a5aeb8e5 | |||
| 1985713f28 | |||
| 8655757dd6 | |||
| 78e88b8eb7 | |||
| 7e03547798 | |||
| c3a20ab2db | |||
| e0aba58651 | |||
| d19e1688a5 | |||
| 23b8db63b8 | |||
| c9cd3a80d9 | |||
| a5fdbd0c13 | |||
| 32d150fd15 | |||
| 5fab9a857a |
17423
dist-electron/main.js
17423
dist-electron/main.js
File diff suppressed because one or more lines are too long
181
electron/main.js
181
electron/main.js
@@ -5,6 +5,7 @@ import axios from "axios";
|
||||
import os from "os";
|
||||
import fs from "fs";
|
||||
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个文件)
|
||||
@@ -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", () => {
|
||||
// 在 macOS 系统内, 如果没有已开启的应用窗口
|
||||
// 点击托盘图标时通常会重新创建一个新窗口
|
||||
|
||||
1760
electron/printService.js
Normal file
1760
electron/printService.js
Normal file
File diff suppressed because it is too large
Load Diff
1168
package-lock.json
generated
1168
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "vite-electron",
|
||||
"private": true,
|
||||
"version": "2.0.15",
|
||||
"version": "2.0.31",
|
||||
"main": "dist-electron/main.js",
|
||||
"scripts": {
|
||||
"dev": "chcp 65001 && vite",
|
||||
@@ -19,10 +19,13 @@
|
||||
"electron-pos-printer": "^1.3.6",
|
||||
"electron-pos-printer-vue": "^1.0.9",
|
||||
"element-plus": "^2.4.3",
|
||||
"iconv-lite": "^0.7.2",
|
||||
"js-md5": "^0.8.3",
|
||||
"lodash": "^4.17.21",
|
||||
"pinia": "^2.1.7",
|
||||
"pinia-plugin-persistedstate": "^3.2.1",
|
||||
"pinyin-match": "^1.2.10",
|
||||
"qr-image": "^3.2.0",
|
||||
"qrcode": "^1.5.3",
|
||||
"reconnecting-websocket": "^4.4.0",
|
||||
"speak-tts": "^2.0.8",
|
||||
@@ -30,13 +33,13 @@
|
||||
"uuid": "^10.0.0",
|
||||
"vue": "^3.3.8",
|
||||
"vue-router": "^4.2.5",
|
||||
"ysk-utils": "^1.0.84"
|
||||
"win32-api": "^26.1.2",
|
||||
"ysk-utils": "^1.0.91"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@vitejs/plugin-vue": "^4.5.0",
|
||||
"electron": "^28.3.3",
|
||||
"electron-builder": "^24.13.3",
|
||||
"electron-rebuild": "^3.2.9",
|
||||
"path": "^0.12.7",
|
||||
"sass": "^1.69.5",
|
||||
"sass-loader": "^13.3.2",
|
||||
|
||||
BIN
printer.sdk.dll
Normal file
BIN
printer.sdk.dll
Normal file
Binary file not shown.
@@ -49,7 +49,7 @@ watch(route, (to) => {
|
||||
includeList.push(to.name);
|
||||
}
|
||||
// 需要全屏的路由
|
||||
let arr = ["/login", "/device_list", "/add_device", "/add_label", "/webview", '/workrecord'];
|
||||
let arr = ["/login", "/device_list", "/add_device", "/add_label", "/webview", '/workrecord', '/store_wine'];
|
||||
if (arr.includes(to.path)) {
|
||||
hideLeftMenu.value = true;
|
||||
} else {
|
||||
|
||||
@@ -317,11 +317,11 @@ export function handoverNetworkPrint(id) {
|
||||
export function printerList(subType = "") {
|
||||
return request({
|
||||
method: "get",
|
||||
url: "/account/admin/printer",
|
||||
url: "/account/admin/printer/getPrintLocal",
|
||||
params: {
|
||||
name: "",
|
||||
subType: subType,
|
||||
connectionType: "USB",
|
||||
connectionType: "",
|
||||
page: 1,
|
||||
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,133 @@ export function markIsSoldOut(data) {
|
||||
data,
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取存酒商品列表
|
||||
* @param {*} params
|
||||
* @returns
|
||||
*/
|
||||
export function storageGoodGet(params) {
|
||||
return request({
|
||||
method: "get",
|
||||
url: "/product/admin/storageGood",
|
||||
params,
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加酒品
|
||||
* @param {*} params
|
||||
* @returns
|
||||
*/
|
||||
export function storageGoodPost(data) {
|
||||
return request({
|
||||
method: "post",
|
||||
url: "/product/admin/storageGood",
|
||||
data,
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑酒品
|
||||
* @param {*} params
|
||||
* @returns
|
||||
*/
|
||||
export function storageGoodPut(data) {
|
||||
return request({
|
||||
method: "put",
|
||||
url: "/product/admin/storageGood/edit",
|
||||
data,
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除酒品
|
||||
* @param {*} params
|
||||
* @returns
|
||||
*/
|
||||
export function storageGoodDelete(id) {
|
||||
return request({
|
||||
method: "DELETE",
|
||||
url: `/product/admin/storageGood?id=${id}`,
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 存酒记录添加
|
||||
* @param {*} data
|
||||
* @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 shopStorageCount() {
|
||||
return request({
|
||||
method: "get",
|
||||
url: "/product/admin/shopStorage/count"
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 耗材库存列表接口
|
||||
* @param {*} data
|
||||
* @returns
|
||||
*/
|
||||
export function consStock(params) {
|
||||
return request({
|
||||
method: "get",
|
||||
url: "/product/admin/product/cons/consStock",
|
||||
params,
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -108,7 +108,8 @@ onMounted(() => {
|
||||
|
||||
<style scoped lang="scss">
|
||||
.list {
|
||||
min-height: 200px;
|
||||
height: 55vh;
|
||||
overflow-y: auto;
|
||||
|
||||
.row {
|
||||
padding-bottom: 20px;
|
||||
|
||||
@@ -3,7 +3,7 @@ import getLodop from "./LodopFuncs.js";
|
||||
* 打印交班小票
|
||||
*/
|
||||
export default (data) => {
|
||||
console.log("data.deviceName===", data.deviceName);
|
||||
console.log("USB.打印交班小票===", data);
|
||||
let LODOP = getLodop();
|
||||
LODOP.PRINT_INIT("打印小票");
|
||||
// 设置打印纸大小D
|
||||
@@ -19,31 +19,31 @@ export default (data) => {
|
||||
交班小票
|
||||
</div>
|
||||
<div style="font-size: 12px;margin-top:50px;">
|
||||
当班时间:${data.loginTime}
|
||||
当班时间:${data.handoverTime }
|
||||
</div>
|
||||
<div style="font-size: 12px;">
|
||||
交班时间:${data.handoverTime}
|
||||
交班时间:${data.loginTime || ""} - ${data.handoverTime || ""}
|
||||
</div>
|
||||
<div style="font-size: 12px;">
|
||||
收银员:${data.staffName}
|
||||
收银员:${data.staffName || ""}
|
||||
</div>
|
||||
<div style="font-size: 12px;margin-top: 4px;">
|
||||
当班总收入:${data.handAmount}
|
||||
当班总收入:${data.turnover || 0}
|
||||
</div>
|
||||
<div style="font-size: 12px;margin-top: 4px;">
|
||||
现金收入:${data.cashAmount}
|
||||
现金收入:${data.cash || 0}
|
||||
</div>
|
||||
<div style="font-size: 12px;margin-top: 4px;">
|
||||
微信收入:${data.wechatAmount}
|
||||
微信收入:${data.wechat || 0}
|
||||
</div>
|
||||
<div style="font-size: 12px;margin-top: 4px;">
|
||||
支付宝收入:${data.alipayAmount}
|
||||
支付宝收入:${data.alipay || 0}
|
||||
</div>
|
||||
<div style="font-size: 12px;margin-top: 4px;">
|
||||
会员支付:${data.vipPay}
|
||||
会员支付:${data.balance || 0}
|
||||
</div>
|
||||
<div style="font-size: 12px;margin-top: 4px;">
|
||||
会员充值:${data.vipRecharge}
|
||||
会员充值:${data.recharge || 0}
|
||||
</div>
|
||||
`;
|
||||
|
||||
@@ -86,72 +86,74 @@ export default (data) => {
|
||||
`;
|
||||
|
||||
let productCategoriesTableBody = "";
|
||||
if (data.categoryDataList && data.categoryDataList.length) {
|
||||
for (let item of data.categoryDataList) {
|
||||
if (data.categoryList && data.categoryList.length) {
|
||||
for (let item of data.categoryList) {
|
||||
productCategoriesTableBody += `
|
||||
<tr>
|
||||
<td style="font-size: 12px;width:50%;">
|
||||
<div>${item.categoryName}</div>
|
||||
</td>
|
||||
<td style="font-size: 12px;width:25%;">${item.num}</td>
|
||||
<td style="font-size: 12px;width:25%;">${item.num || 0}</td>
|
||||
<td style="font-size: 12px;width:25%;">
|
||||
${item.amount}
|
||||
${item.amount || 0}
|
||||
</td>
|
||||
</tr>
|
||||
`;
|
||||
}
|
||||
}
|
||||
|
||||
let tabHead = `
|
||||
</table>
|
||||
<div style="font-size: 12px;margin-top: 4px;">商品数据</div>
|
||||
<table class="table" style="width: 100%;">
|
||||
<tr>
|
||||
<td style="font-size: 12px;width:75%;">商品</td>
|
||||
<td style="font-size: 12px;width:25%;">数量</td>
|
||||
</tr>
|
||||
`;
|
||||
// let tabHead = `
|
||||
// </table>
|
||||
// <div style="font-size: 12px;margin-top: 4px;">商品数据</div>
|
||||
// <table class="table" style="width: 100%;">
|
||||
// <tr>
|
||||
// <td style="font-size: 12px;width:75%;">商品</td>
|
||||
// <td style="font-size: 12px;width:25%;">数量</td>
|
||||
// </tr>
|
||||
// `;
|
||||
|
||||
// let tableBody = "";
|
||||
// if (data.productDataList && data.productDataList.length) {
|
||||
// for (let item of data.productDataList) {
|
||||
// tableBody += `
|
||||
// <tr>
|
||||
// <td style="font-size: 12px;width:75%;">
|
||||
// <div>${item.productName}</div>
|
||||
// </td>
|
||||
// <td style="font-size: 12px;width:25%;">${item.num}</td>
|
||||
// </tr>
|
||||
// `;
|
||||
// }
|
||||
// }
|
||||
|
||||
// if (!data.printShop) {
|
||||
// tabHead = "";
|
||||
// tableBody = "";
|
||||
// }
|
||||
let tabHead = "";
|
||||
let tableBody = "";
|
||||
if (data.productDataList && data.productDataList.length) {
|
||||
for (let item of data.productDataList) {
|
||||
tableBody += `
|
||||
<tr>
|
||||
<td style="font-size: 12px;width:75%;">
|
||||
<div>${item.productName}</div>
|
||||
</td>
|
||||
<td style="font-size: 12px;width:25%;">${item.num}</td>
|
||||
</tr>
|
||||
`;
|
||||
}
|
||||
}
|
||||
|
||||
if (!data.printShop) {
|
||||
tabHead = "";
|
||||
tableBody = "";
|
||||
}
|
||||
|
||||
let str = `
|
||||
</table>
|
||||
<div style="font-size: 12px;margin-top: 4px;">
|
||||
<span>快捷收款金额:</span>
|
||||
<span>${data.quickInAmount}</span>
|
||||
<span>${data.barScan || 0}</span>
|
||||
</div>
|
||||
<div style="font-size: 12px;">
|
||||
<span>退款金额:</span>
|
||||
<span>${data.refundAmount}</span>
|
||||
<span>${data.refundAmount || 0}</span>
|
||||
</div>
|
||||
<div style="font-size: 12px;">
|
||||
<span>总收入:</span>
|
||||
<span>${data.handAmount}</span>
|
||||
<span>${data.turnover || 0}</span>
|
||||
</div>
|
||||
<div style="font-size: 12px;">
|
||||
<span>挂账金额:</span>
|
||||
<span>${data.creditAmount}</span>
|
||||
<span>${data.owed || 0}</span>
|
||||
</div>
|
||||
<div style="margin-top: 20px; font-size: 12px;">
|
||||
<span>总订单数:</span>
|
||||
<span>${data.orderCount}</span>
|
||||
<span>${data.orderCount || 0}</span>
|
||||
</div>
|
||||
<div style="font-size: 12px;">
|
||||
打印时间:${data.printTime}
|
||||
|
||||
@@ -5,7 +5,7 @@ import { formatDecimal } from "@/utils/index.js";
|
||||
* 打印订单小票
|
||||
*/
|
||||
export default (data) => {
|
||||
// console.log("需要打印的订单数据===", data);
|
||||
console.log("需要打印的订单数据===", data);
|
||||
// console.log("data.deviceName===", data.deviceName);
|
||||
let LODOP = getLodop();
|
||||
LODOP.PRINT_INIT("打印小票");
|
||||
|
||||
@@ -45,11 +45,19 @@
|
||||
<div class="drawerbox_bo_box_itembox" @click="router.push({ name: 'device_list' })">
|
||||
<div class="drawerbox_bo_box_icon">
|
||||
<el-icon size="40">
|
||||
<TurnOff />
|
||||
<Printer />
|
||||
</el-icon>
|
||||
</div>
|
||||
<div class="drawerbox_bo_box_icontext">设备管理</div>
|
||||
</div>
|
||||
<div class="drawerbox_bo_box_itembox" @click="router.push({ name: 'store_wine' })">
|
||||
<div class="drawerbox_bo_box_icon">
|
||||
<el-icon size="40">
|
||||
<Goblet />
|
||||
</el-icon>
|
||||
</div>
|
||||
<div class="drawerbox_bo_box_icontext">存酒管理</div>
|
||||
</div>
|
||||
<!-- <div class="drawerbox_bo_box_itembox" @click="openCallHandle">
|
||||
<div class="drawerbox_bo_box_icon">
|
||||
<el-icon size="40">
|
||||
|
||||
@@ -48,6 +48,7 @@
|
||||
<div class="input_wrap">
|
||||
<div class="input" style="flex: 1">付款:¥{{ formatDecimal(goodsStore.cartInfo.costSummary.finalPayAmount
|
||||
|| 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;"
|
||||
@click="showCouponHandle">添加优惠</el-button>
|
||||
</div>
|
||||
@@ -139,11 +140,25 @@
|
||||
<el-button type="danger" @click="clearCouponUser">清除</el-button>
|
||||
</div>
|
||||
</el-form-item>
|
||||
<el-form-item label="整单折扣">
|
||||
<el-input v-model="couponForm.discountRatio" placeholder="请输入折扣" style="width: 180px;"
|
||||
@input="discountInput">
|
||||
<template #append>折</template>
|
||||
</el-input>
|
||||
<el-form-item label="优惠金额">
|
||||
<div class="column">
|
||||
<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>
|
||||
</el-input>
|
||||
</div>
|
||||
</div>
|
||||
</el-form-item>
|
||||
<el-form-item label="优惠券">
|
||||
<div style="width: 100%;">
|
||||
@@ -258,6 +273,7 @@ import { staffPermission } from "@/api/user.js";
|
||||
import { cashPay, buyerPage, creditPay, vipPay } from "@/api/order.js";
|
||||
import { calcUsablePoints } from '@/api/account.js'
|
||||
import { useGoods } from "@/store/goods.js";
|
||||
import { createOrder } from '@/api/order.js';
|
||||
|
||||
const emit = defineEmits(["paySuccess", 'orderExpired', 'reset']);
|
||||
|
||||
@@ -432,7 +448,7 @@ async function payTypeChange(index, item) {
|
||||
SelectVipUserRef.value.show()
|
||||
}
|
||||
}
|
||||
if (item.payType == "arrears") {
|
||||
if (item.payType == "virtual") {
|
||||
// 挂账支付
|
||||
showBuyerHandle();
|
||||
}
|
||||
@@ -470,13 +486,50 @@ function upadatePayData() {
|
||||
newCustomerDiscountId: goodsStore.newUserDiscount !== null ? goodsStore.newUserDiscount.id : goodsStore.newUserDiscount !== null ? goodsStore.newUserDiscount.id : '', // 新客立减Id
|
||||
newCustomerDiscountAmount: goodsStore.newUserDiscount !== null ? goodsStore.newUserDiscount.amount : 0, // 新客立减金额
|
||||
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 {
|
||||
// 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({
|
||||
table_code: goodsStore.orderListInfo.tableCode
|
||||
@@ -486,9 +539,8 @@ async function confirmOrder() {
|
||||
|
||||
upadatePayData()
|
||||
|
||||
|
||||
payType.value = payList.value[payActive.value].payType
|
||||
if (payList.value[payActive.value].payType == "arrears") {
|
||||
if (payList.value[payActive.value].payType == "virtual") {
|
||||
showBuyerHandle();
|
||||
return
|
||||
} else if (payList.value[payActive.value].payType == "scanCode") {
|
||||
@@ -508,9 +560,9 @@ async function confirmOrder() {
|
||||
ElMessageBox.prompt('确定现金支付?', '注意', {
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
inputPlaceholder: '请输入备注(选填)',
|
||||
inputPlaceholder: goodsStore.remark ? goodsStore.remark : '请输入备注(选填)',
|
||||
}).then(async ({ value }) => {
|
||||
payData.value.checkOrderPay.remark = value;
|
||||
payData.value.checkOrderPay.remark = value ? value : goodsStore.remark;
|
||||
if (props.selecttype == 0) {
|
||||
payLoading.loading = true
|
||||
await cashPay(payData.value);
|
||||
@@ -576,6 +628,20 @@ function amountInput(num) {
|
||||
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() {
|
||||
if (!money.value) return; money.value = money.value.substring(0, money.value.length - 1);
|
||||
@@ -718,6 +784,32 @@ function clearCouponUser() {
|
||||
// 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 discountInput = _.debounce(function (e) {
|
||||
@@ -1251,6 +1343,12 @@ defineExpose({
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
.column {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 10px;
|
||||
}
|
||||
|
||||
.point_tips {
|
||||
&.err {
|
||||
color: var(--el-color-danger);
|
||||
|
||||
@@ -129,14 +129,11 @@ async function submitHandleAjax() {
|
||||
console.log('props.selecttype===', props.selecttype);
|
||||
console.log('props.payType===', props.payType);
|
||||
|
||||
// return;
|
||||
|
||||
// 判断订单是否锁定
|
||||
await goodsStore.isOrderLock({
|
||||
table_code: goodsStore.orderListInfo.tableCode
|
||||
})
|
||||
|
||||
if (props.selecttype == 0) {
|
||||
// 判断订单是否锁定
|
||||
await goodsStore.isOrderLock({
|
||||
table_code: goodsStore.orderListInfo.tableCode
|
||||
})
|
||||
// 下单扫码支付
|
||||
if (props.payType == 'scanCode') {
|
||||
await microPay({
|
||||
@@ -151,6 +148,7 @@ async function submitHandleAjax() {
|
||||
});
|
||||
}
|
||||
} else if (props.selecttype == 1) {
|
||||
console.log('进入会员扫码充值');
|
||||
// 会员扫码充值
|
||||
await microPayVip({
|
||||
shopId: store.shopInfo.id,
|
||||
|
||||
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="n">{{ formatDecimal(+goodsInfo.salePrice) }}</span>
|
||||
</div>
|
||||
<span>库存:{{ stockNumber }}</span>
|
||||
<span>库存:{{ stockNumber || 0 }}</span>
|
||||
</div>
|
||||
<div class="btn_wrap">
|
||||
<div class="btn">
|
||||
|
||||
@@ -17,7 +17,6 @@ import { ref } from 'vue';
|
||||
import userStore from '@/utils/useStorage.js'
|
||||
import { ElUpload, ElMessage } from 'element-plus';
|
||||
|
||||
|
||||
const fileList = ref([])
|
||||
|
||||
// 定义接收的外部属性
|
||||
|
||||
@@ -101,6 +101,11 @@ const routes = [
|
||||
name: "webview",
|
||||
component: () => import("@/views/webview/index.vue"),
|
||||
},
|
||||
{
|
||||
path: "/store_wine",
|
||||
name: "store_wine",
|
||||
component: () => import("@/views/store_wine/index.vue"),
|
||||
},
|
||||
];
|
||||
|
||||
const router = createRouter({
|
||||
|
||||
@@ -119,46 +119,20 @@ export const useGlobal = defineStore("global", {
|
||||
},
|
||||
],
|
||||
bizCodes: [
|
||||
{
|
||||
type: "freeln",
|
||||
label: "霸王餐",
|
||||
},
|
||||
{
|
||||
type: "cashIn",
|
||||
label: "现金充值",
|
||||
},
|
||||
{
|
||||
type: "wechatIn",
|
||||
label: "微信小程序充值",
|
||||
},
|
||||
{
|
||||
type: "alipayIn",
|
||||
label: "支付宝小程序充值",
|
||||
},
|
||||
{
|
||||
type: "awardIn",
|
||||
label: "充值奖励",
|
||||
},
|
||||
{
|
||||
type: "rechargeRefund",
|
||||
label: "充值退款",
|
||||
},
|
||||
{
|
||||
type: "orderPay",
|
||||
label: "订单消费",
|
||||
},
|
||||
{
|
||||
type: "orderRefund",
|
||||
label: "订单退款",
|
||||
},
|
||||
{
|
||||
type: "adminIn",
|
||||
label: "管理员充值",
|
||||
},
|
||||
{
|
||||
type: "adminOut",
|
||||
label: "管理员消费",
|
||||
},
|
||||
{ type: "cashIn", label: "会员充值" },
|
||||
{ type: "cashback", label: "消费返现" },
|
||||
{ type: "cashback_refund", label: "消费返现扣减" },
|
||||
{ type: "freeIn", label: "霸王餐充值" },
|
||||
{ type: "awardIn", label: "充值奖励" },
|
||||
{ type: "wechatIn", label: "微信小程序充值" },
|
||||
{ type: "alipayIn", label: "支付宝小程序充值" },
|
||||
{ type: "orderPay", label: "订单支付奖励" },
|
||||
{ type: "orderRefund", label: "订单退款" },
|
||||
{ type: "rechargeRefund", label: "充值退款" },
|
||||
{ type: "rechargeCashRefund", label: "会员现金退款" },
|
||||
{ type: "adminIn", label: "管理员手动增减余额" },
|
||||
{ type: "adminOut", label: "管理员退款充值" },
|
||||
{ type: "rechargeRedemption", label: "充值兑换码" }
|
||||
],
|
||||
refundType: [
|
||||
{
|
||||
|
||||
@@ -2,7 +2,7 @@ import _ from "lodash";
|
||||
import dayjs from "dayjs";
|
||||
import { defineStore } from "pinia";
|
||||
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 { getLimitTimeDiscount, getDiscountActivity, getDiscountByUserId } from '@/api/market'
|
||||
import { useUser } from "@/store/user.js";
|
||||
@@ -11,6 +11,7 @@ import useStorage from "@/utils/useStorage.js";
|
||||
import { formatDecimal } from "@/utils/index.js";
|
||||
import { shopUserDetail } from "@/api/account.js";
|
||||
import { ElMessage } from "element-plus";
|
||||
import PinyinMatch from 'pinyin-match';
|
||||
|
||||
import {
|
||||
OrderPriceCalculator, limitUtils,
|
||||
@@ -36,6 +37,7 @@ const initialCostSummary = {
|
||||
// 商品store + 购物车store
|
||||
export const useGoods = defineStore("goods", {
|
||||
state: () => ({
|
||||
remark: "", // 订单备注
|
||||
showVipPrice: 0,
|
||||
allSelected: 0, // 是否整单打包
|
||||
vipUserInfo: {}, // 会员信息
|
||||
@@ -46,6 +48,7 @@ export const useGoods = defineStore("goods", {
|
||||
}, // 台桌信息
|
||||
cartActiveIndex: 0, // 购物车激活索引,
|
||||
isCartInit: false,
|
||||
payType: "cart", // 结算类型,cart 购物车结算 table 桌台结算 order 订单结算,
|
||||
cartList: [], // 购物车列表
|
||||
// 购物车信息,
|
||||
cartInfo: {
|
||||
@@ -60,6 +63,7 @@ export const useGoods = defineStore("goods", {
|
||||
goodsListLoading: false, // 商品列表加载状态
|
||||
goodsList: [], // 商品列表
|
||||
originGoodsList: [], // 原始商品列表
|
||||
consList: [], // 耗材列表
|
||||
orderList: [], // 订单列表
|
||||
orderListInfo: "", // 历史订单信息
|
||||
cartType: "cart", // cart order
|
||||
@@ -86,7 +90,6 @@ export const useGoods = defineStore("goods", {
|
||||
// 清除会员信息
|
||||
async clearVipUserInfo() {
|
||||
// console.log('清除会员信息');
|
||||
|
||||
this.vipUserInfo = {};
|
||||
this.showVipPrice = 0;
|
||||
|
||||
@@ -302,8 +305,18 @@ export const useGoods = defineStore("goods", {
|
||||
console.log(error);
|
||||
}
|
||||
},
|
||||
// 耗材库存列表接口
|
||||
async consStockAjax() {
|
||||
try {
|
||||
const store = useUser()
|
||||
this.consList = await consStock({ shopId: store.shopInfo.id })
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
}
|
||||
},
|
||||
// 初始化商品
|
||||
async initGoods() {
|
||||
await this.consStockAjax()
|
||||
await this.getCategoryList();
|
||||
await this.getGoodsList();
|
||||
|
||||
@@ -347,10 +360,16 @@ export const useGoods = defineStore("goods", {
|
||||
// 根据商品名字模糊查询商品列表
|
||||
filterNameGoods(name) {
|
||||
this.goodsList = _.chunk(
|
||||
this.originGoodsList.filter((item) => item.name.includes(name)),
|
||||
this.originGoodsList.filter((item) => {
|
||||
// 原来的汉字模糊搜索
|
||||
const hasName = item.name.includes(name);
|
||||
// 新增:拼音/首字母模糊搜索(zs / zhangsan / 张三 都能搜)
|
||||
const hasPinyin = name && PinyinMatch.match(item.name, name);
|
||||
|
||||
return hasName || hasPinyin;
|
||||
}),
|
||||
12
|
||||
);
|
||||
|
||||
this.updateGoodsNumber();
|
||||
},
|
||||
// 获取商品分类列表
|
||||
@@ -371,6 +390,50 @@ export const useGoods = defineStore("goods", {
|
||||
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() {
|
||||
try {
|
||||
@@ -386,7 +449,11 @@ export const useGoods = defineStore("goods", {
|
||||
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 })
|
||||
@@ -441,18 +508,6 @@ export const useGoods = defineStore("goods", {
|
||||
|
||||
this.goodsList.forEach(val => {
|
||||
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.orderCount = 0;
|
||||
item.memberPrice = item.lowMemberPrice
|
||||
@@ -889,7 +944,11 @@ export const useGoods = defineStore("goods", {
|
||||
.map((item) => item.goods)
|
||||
.flat()
|
||||
.map(this.comleteOrderInfo);
|
||||
return [...currentGoods, ...giftGoods, ...oldOrderGoods];
|
||||
if (this.payType == 'table' || this.payType == 'order') {
|
||||
return [...giftGoods, ...oldOrderGoods];
|
||||
} else {
|
||||
return [...currentGoods, ...giftGoods, ...oldOrderGoods];
|
||||
}
|
||||
}
|
||||
|
||||
// 合并所有商品列表
|
||||
|
||||
1184
src/store/print.js
1184
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 { ElMessage } from "element-plus";
|
||||
import { getOrderByIdAjax, commOrderPrintData } from "@/utils/index.js";
|
||||
import { printData } from '@/api/print.js'
|
||||
|
||||
export const useSocket = defineStore("socket", {
|
||||
state: () => ({
|
||||
@@ -17,8 +18,236 @@ export const useSocket = defineStore("socket", {
|
||||
orderListTimer: null,
|
||||
log: false,
|
||||
isPrinting: false,
|
||||
// 新增:其他打印任务队列与状态锁
|
||||
printQueue: [],
|
||||
isProcessing: false
|
||||
}),
|
||||
actions: {
|
||||
// 计算订单中所有菜品的总价总和
|
||||
calcAllCartsTotalSum(cartObj) {
|
||||
// 初始化总和为0
|
||||
let totalSum = 0;
|
||||
// 遍历原始对象的所有键(0、1、2...)
|
||||
Object.keys(cartObj).forEach(key => {
|
||||
const carts = cartObj[key] || [];
|
||||
// 累加当前分类下的菜品总价(num × unitPrice)
|
||||
carts.forEach(item => {
|
||||
const num = Number(item.num) - Number(item.returnNum) || 0; // 防错:非数字转0
|
||||
const unitPrice = Number(item.unitPrice) || 0;
|
||||
totalSum += num * unitPrice;
|
||||
});
|
||||
});
|
||||
return totalSum; // 返回所有菜品的总价总和
|
||||
},
|
||||
// 1. 添加任务到队列
|
||||
addToPrintQueue(task) {
|
||||
this.printQueue.push(task);
|
||||
if (this.log) console.log('任务已加入打印队列,当前队列长度:', this.printQueue.length);
|
||||
this.processPrintQueue(); // 尝试启动处理
|
||||
},
|
||||
// 2. 处理队列(递归执行)
|
||||
async processPrintQueue() {
|
||||
const printStore = usePrint();
|
||||
|
||||
// 如果正在处理或队列为空,直接返回
|
||||
if (this.isProcessing || this.printQueue.length === 0) return;
|
||||
|
||||
this.isProcessing = true;
|
||||
const currentTask = this.printQueue[0]; // 取出第一个任务
|
||||
|
||||
try {
|
||||
if (this.log) console.log('开始执行打印任务:', currentTask);
|
||||
|
||||
const isOrderPrint = ['GUEST_ORDER', 'PRE_ORDER', 'ORDER', 'RETURN_ORDER', 'REFUND_ORDER', 'ALL_KITCHEN', 'ONLY_KITCHEN', 'REFUND_KITCHEN',]
|
||||
|
||||
console.log('currentTask===', currentTask);
|
||||
|
||||
if (_.includes(isOrderPrint, currentTask.printType)) {
|
||||
// 订单相关打印,调用对应接口获取数据
|
||||
const data = await getOrderByIdAjax(currentTask.orderId);
|
||||
|
||||
console.log('订单相关打印,调用对应接口获取数据===', data);
|
||||
|
||||
switch (currentTask.printType) {
|
||||
case 'ORDER':
|
||||
// 打印订单小票
|
||||
printStore.ORDER(commOrderPrintData(data));
|
||||
// 打印标签小票
|
||||
printStore.labelPrint(commOrderPrintData(data));
|
||||
break;
|
||||
case 'PRE_ORDER':
|
||||
// 打印预订单小票
|
||||
data.originAmount = this.calcAllCartsTotalSum(data.detailMap)
|
||||
|
||||
if (data.seatAmount > 0 && data.dineMode == 'dine-in') {
|
||||
data.originAmount += data.seatAmount
|
||||
}
|
||||
let packFee = 0
|
||||
|
||||
data.cartList.forEach(item => {
|
||||
if (item.packNumber > 0 && (item.num - item.returnNum) >= item.packNumber) {
|
||||
packFee += (item.num - item.returnNum) * item.packAmount
|
||||
}
|
||||
})
|
||||
|
||||
if (packFee > 0) {
|
||||
data.originAmount += packFee
|
||||
data.packFee = packFee
|
||||
}
|
||||
|
||||
printStore.PRE_ORDER(commOrderPrintData({ ...data, isBefore: true }));
|
||||
break;
|
||||
case 'GUEST_ORDER':
|
||||
// 打印客看单
|
||||
data.detailMap = _.at(data.detailMap, data.placeNum);
|
||||
|
||||
let amout = 0
|
||||
data.detailMap.flat().forEach(item => {
|
||||
amout += item.num * item.unitPrice
|
||||
});
|
||||
|
||||
data.originAmount = amout
|
||||
|
||||
if (data.placeNum == 1 && data.dineMode == 'dine-in') {
|
||||
data.originAmount += data.seatAmount
|
||||
}
|
||||
|
||||
if (data.packFee > 0) {
|
||||
data.originAmount += data.packFee
|
||||
}
|
||||
|
||||
printStore.GUEST_ORDER(commOrderPrintData({ ...data, isGuest: true, isBefore: false }));
|
||||
break;
|
||||
case 'ALL_KITCHEN':
|
||||
// 打印整单厨房票
|
||||
if (data.payMode == 'after-pay') {
|
||||
// 后付费订单,只打印当前下单商品的整单厨房票
|
||||
data.detailMap = _.at(data.detailMap, data.placeNum);
|
||||
printStore.ALL_KITCHEN(commOrderPrintData({ ...data, isGuest: true, isNotPrint: true }));
|
||||
} else {
|
||||
printStore.ALL_KITCHEN(commOrderPrintData({ ...data, isNotPrint: true }));
|
||||
}
|
||||
// console.log('打印整单厨房票.data', data);
|
||||
break;
|
||||
case 'ONLY_KITCHEN':
|
||||
// 打印一菜一品厨房票
|
||||
if (data.payMode == 'after-pay') {
|
||||
// 后付费订单,只打印当前下单的一菜一品厨房票
|
||||
data.detailMap = _.at(data.detailMap, data.placeNum);
|
||||
const orderInfo = commOrderPrintData({ ...data, isGuest: true, isNotPrint: true });
|
||||
orderInfo.carts.forEach(item => {
|
||||
const ONLY_KITCHEN_DATA = {
|
||||
...orderInfo,
|
||||
carts: [item]
|
||||
}
|
||||
printStore.ONLY_KITCHEN(ONLY_KITCHEN_DATA);
|
||||
})
|
||||
} else {
|
||||
data.cartList.forEach(item => {
|
||||
const ONLY_KITCHEN_DATA = {
|
||||
...data.orderData,
|
||||
cartList: [item],
|
||||
isNotPrint: true
|
||||
}
|
||||
printStore.ONLY_KITCHEN(commOrderPrintData(ONLY_KITCHEN_DATA));
|
||||
})
|
||||
}
|
||||
break;
|
||||
case 'RETURN_ORDER':
|
||||
// 打印退菜小票
|
||||
const socketData = JSON.parse(currentTask.data);
|
||||
// console.log('打印退菜小票.socketData', socketData);
|
||||
|
||||
let cartList = _.compact(
|
||||
_.map(data.cartList, (cartItem) => {
|
||||
// 找到对应项
|
||||
const taskItem = _.find(socketData, (t) => cartItem.id == t.id);
|
||||
|
||||
// 找到就返回带 num 的对象
|
||||
if (taskItem) {
|
||||
return {
|
||||
...cartItem,
|
||||
num: taskItem.num,
|
||||
returnNum: 0,
|
||||
payAmount: taskItem.num * cartItem.price
|
||||
};
|
||||
}
|
||||
|
||||
// 没找到返回 undefined,会被 _.compact 过滤掉
|
||||
return null;
|
||||
})
|
||||
);
|
||||
|
||||
data.cartList = cartList;
|
||||
|
||||
// console.log('打印退菜小票.data', data);
|
||||
|
||||
printStore.RETURN_ORDER(commOrderPrintData({ ...data, isRefundDish: true }));
|
||||
break;
|
||||
case 'REFUND_ORDER':
|
||||
// 打印退单小票
|
||||
{
|
||||
const socketData = JSON.parse(currentTask.data);
|
||||
// console.log('打印退菜小票.socketData', socketData);
|
||||
|
||||
let cartList = _.compact(
|
||||
_.map(data.cartList, (cartItem) => {
|
||||
// 找到对应项
|
||||
const taskItem = _.find(socketData, (t) => cartItem.id == t.id);
|
||||
|
||||
// 找到就返回带 num 的对象
|
||||
if (taskItem) {
|
||||
return {
|
||||
...cartItem,
|
||||
num: taskItem.num,
|
||||
returnNum: 0,
|
||||
payAmount: taskItem.num * cartItem.price
|
||||
};
|
||||
}
|
||||
|
||||
// 没找到返回 undefined,会被 _.compact 过滤掉
|
||||
return null;
|
||||
})
|
||||
);
|
||||
|
||||
data.cartList = cartList;
|
||||
data.payAmount = currentTask.amount;
|
||||
// console.log('打印退单小票.data', data);
|
||||
|
||||
printStore.REFUND_ORDER(commOrderPrintData({ ...data, isRefundDish: true }));
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
// 执行打印逻辑(参考你注释中的代码)
|
||||
const res = await printData({
|
||||
shopId: currentTask.shopId,
|
||||
dataId: currentTask.dataId,
|
||||
type: currentTask.printType
|
||||
});
|
||||
|
||||
console.log('printData.res===', res);
|
||||
|
||||
if (printStore[currentTask.printType]) {
|
||||
printStore[currentTask.printType](JSON.parse(res.data));
|
||||
}
|
||||
}
|
||||
if (this.log) console.log('任务执行成功');
|
||||
} catch (error) {
|
||||
console.error('打印任务执行失败:', error);
|
||||
// 失败时不移除任务,或者根据业务决定是否重试/丢弃
|
||||
} finally {
|
||||
// 无论成功失败,移除当前任务
|
||||
this.printQueue.shift();
|
||||
if (this.log) console.log('任务移除,剩余队列:', this.printQueue.length);
|
||||
|
||||
// 标记为空闲,尝试处理下一个
|
||||
this.isProcessing = false;
|
||||
this.processPrintQueue();
|
||||
}
|
||||
},
|
||||
// 关闭ws
|
||||
close() {
|
||||
if (this.log) console.log("关闭ws");
|
||||
@@ -112,11 +341,61 @@ export const useSocket = defineStore("socket", {
|
||||
switch (data.operate_type) {
|
||||
case "add":
|
||||
// 添加购物车商品
|
||||
goodsStore.successAddCart(data.data);
|
||||
{
|
||||
// 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);
|
||||
}
|
||||
break;
|
||||
case "edit":
|
||||
// 编辑购物车商品
|
||||
goodsStore.successEditCart(data.data);
|
||||
{
|
||||
// 编辑购物车商品
|
||||
// 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);
|
||||
}
|
||||
break;
|
||||
case "del":
|
||||
// 删除购物车商品
|
||||
@@ -169,11 +448,21 @@ export const useSocket = defineStore("socket", {
|
||||
}
|
||||
}
|
||||
} else if (data.data_type == "order") {
|
||||
this.addToPrintQueue(JSON.parse(data.data));
|
||||
return;
|
||||
|
||||
goodsStore.successClearCart();
|
||||
goodsStore.historyOrderAjax(data.data.table_code);
|
||||
this.cartInit();
|
||||
|
||||
this.addToPrintQueue(data.data);
|
||||
|
||||
// 收到订单消息,打印订单小票
|
||||
let orderInfo = data.data.split("_");
|
||||
let orderId = orderInfo[0]; // 订单ID
|
||||
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") || [];
|
||||
|
||||
@@ -189,9 +478,44 @@ export const useSocket = defineStore("socket", {
|
||||
this.orderList.push(orderId);
|
||||
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") {
|
||||
// 商品更新
|
||||
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) {
|
||||
const userStore = useUser();
|
||||
let data = {
|
||||
title: orderInfo.title,
|
||||
isBefore: orderInfo.isBefore || false,
|
||||
isGuest: orderInfo.isGuest || false,
|
||||
shop_name: userStore.shopInfo.shopName,
|
||||
loginAccount: userStore.userInfo.name,
|
||||
carts: [],
|
||||
@@ -179,46 +181,98 @@ export function commOrderPrintData(orderInfo) {
|
||||
printTime: dayjs().format("YYYY-MM-DD HH:mm:ss"),
|
||||
};
|
||||
|
||||
orderInfo.cartList.map((item) => {
|
||||
data.carts.push({
|
||||
categoryId: item.categoryId,
|
||||
name: item.productName,
|
||||
number: item.num,
|
||||
skuName: item.skuName,
|
||||
salePrice: formatDecimal(+item.price),
|
||||
totalAmount: formatDecimal(+item.payAmount),
|
||||
proGroupInfo: item.proGroupInfo
|
||||
? item.proGroupInfo.map((item) => item.goods).flat()
|
||||
: "",
|
||||
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({
|
||||
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.payAmount),
|
||||
proGroupInfo: item.proGroupInfo
|
||||
? 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) {
|
||||
console.log('有餐位费', orderInfo.seatAmount);
|
||||
|
||||
data.carts.push({
|
||||
categoryId: '',
|
||||
name: '餐位费',
|
||||
number: orderInfo.seatNum,
|
||||
skuName: '',
|
||||
salePrice: formatDecimal(orderInfo.seatAmount / orderInfo.seatNum),
|
||||
totalAmount: orderInfo.seatAmount,
|
||||
proGroupInfo: "",
|
||||
})
|
||||
}
|
||||
|
||||
if (orderInfo.packFee > 0) {
|
||||
if (orderInfo.dineMode == 'dine-in') {
|
||||
if (orderInfo.seatAmount > 0 && orderInfo.isGuest && orderInfo.placeNum == 1 && !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.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({
|
||||
categoryId: '',
|
||||
name: '打包费',
|
||||
number: '',
|
||||
number: packNum,
|
||||
skuName: '',
|
||||
salePrice: '',
|
||||
totalAmount: formatDecimal(orderInfo.packFee),
|
||||
proGroupInfo: "",
|
||||
remark: ''
|
||||
})
|
||||
}
|
||||
|
||||
// console.log('最终组合打印数据===', data);
|
||||
return data;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,3 +0,0 @@
|
||||
<template>
|
||||
收银
|
||||
</template>
|
||||
@@ -8,30 +8,59 @@
|
||||
</div>
|
||||
<div class="d_content">
|
||||
<div class="d_list">
|
||||
<el-form :model="form" label-position="left" label-width="60%">
|
||||
<el-form-item label="设备名称">
|
||||
<el-form ref="formRef" :model="form" :rules="rules" label-position="left" label-width="60%">
|
||||
<el-form-item label="设备名称" prop="name">
|
||||
<el-input v-model="form.name" placeholder="请输入设备名称"></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item label="设备类型">
|
||||
<el-radio-group v-model="form.connectionType" @change="connectionTypeChange">
|
||||
<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-input v-model="form.contentType" placeholder="请输入打印机品牌"></el-input>
|
||||
</el-form-item> -->
|
||||
<el-form-item label="设备尺寸">
|
||||
<el-select v-model="form.receiptSize">
|
||||
<el-option label="58mm" value="58mm"></el-option>
|
||||
<el-option label="80mm" value="80mm"></el-option>
|
||||
<el-option label="58mm" value="58mm" v-if="form.connectionType === 'USB'"></el-option>
|
||||
<el-option label="80mm" value="80mm" v-if="form.connectionType === '局域网'"></el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="设备类型">
|
||||
<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-form-item label="选择设备" prop="address" v-if="form.connectionType === 'USB'">
|
||||
<el-select v-model="form.address">
|
||||
<el-option :label="item.name" :value="item.name" v-for="item in printList" :key="item.name"></el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="设备IP" prop="address" v-if="form.connectionType === '局域网'">
|
||||
<el-input v-model="form.address" placeholder="请输入设备IP地址"></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item label="商品分类" prop="classifyPrint" v-if="form.connectionType === '局域网'">
|
||||
<div class="column">
|
||||
<el-radio-group v-model="form.classifyPrint" @change="form.categoryList = []; form.categoryIds = ''">
|
||||
<el-radio-button label="全部" value="0"></el-radio-button>
|
||||
<el-radio-button label="部分(仅后厨)" value="1"
|
||||
:disabled="printTypeList[1].values.length == 0"></el-radio-button>
|
||||
</el-radio-group>
|
||||
<div style="cursor: pointer" @click="classifyRef.show()" v-if="form.classifyPrint == '1'">
|
||||
<span style="color: #409eff" v-if="form.categoryList.length">
|
||||
{{form.categoryList.map(item => item.name).join(',')}}
|
||||
</span>
|
||||
<el-button type="primary" v-else style="margin-top: 10px;">选择商品分类</el-button>
|
||||
</div>
|
||||
</div>
|
||||
</el-form-item>
|
||||
<el-form-item label="打印类型" v-if="form.connectionType === '局域网'">
|
||||
<div class="row" v-for="(item, index) in printTypeList" :key="index">
|
||||
<div class="title">{{ item.label }}</div>
|
||||
<div class="cont">
|
||||
<el-checkbox-group v-model="item.values" @change="printTypeChange($event, index)">
|
||||
<el-checkbox :label="item.label" :value="item.value" v-for="item in item.list"
|
||||
:key="item.value"></el-checkbox>
|
||||
</el-checkbox-group>
|
||||
</div>
|
||||
</div>
|
||||
</el-form-item>
|
||||
<!-- <el-form-item label="打印份数">
|
||||
<el-select v-model="form.printQty">
|
||||
<el-option :label="item" :value="item" v-for="item in 4" :key="item"></el-option>
|
||||
@@ -76,21 +105,25 @@
|
||||
<div class="row">收银员:{{ printData.loginAccount }}</div>
|
||||
<div class="line"></div>
|
||||
<table class="table">
|
||||
<tr>
|
||||
<td>品名</td>
|
||||
<td>单价</td>
|
||||
<td>数量</td>
|
||||
<td>小计</td>
|
||||
</tr>
|
||||
<tr v-for="(item, index) in printData.carts" :key="index">
|
||||
<td>
|
||||
<div>{{ item.name }}</div>
|
||||
<div class="sku">{{ item.skuName }}</div>
|
||||
</td>
|
||||
<td>{{ item.salePrice }}</td>
|
||||
<td>{{ item.number }}</td>
|
||||
<td>{{ item.totalAmount }}</td>
|
||||
</tr>
|
||||
<thead>
|
||||
<tr>
|
||||
<td>品名</td>
|
||||
<td>单价</td>
|
||||
<td>数量</td>
|
||||
<td>小计</td>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr v-for="(item, index) in printData.carts" :key="index">
|
||||
<td>
|
||||
<div>{{ item.name }}</div>
|
||||
<div class="sku">{{ item.skuName }}</div>
|
||||
</td>
|
||||
<td>{{ item.salePrice }}</td>
|
||||
<td>{{ item.number }}</td>
|
||||
<td>{{ item.totalAmount }}</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<div class="line"></div>
|
||||
<div class="row between">
|
||||
@@ -125,9 +158,11 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<classify ref="classifyRef" @success="classifyChange" />
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import _ from 'lodash'
|
||||
import dayjs from "dayjs";
|
||||
import { ipcRenderer } from "electron";
|
||||
import { onMounted, reactive, ref } from "vue";
|
||||
@@ -136,6 +171,12 @@ import { ElMessage } from "element-plus";
|
||||
import { useUser } from "@/store/user.js";
|
||||
import { usePrint } from "@/store/print.js";
|
||||
import { printerAdd, printerDetail } from "@/api/account.js";
|
||||
import classify from "@/components/classify/index.vue";
|
||||
import { useGoods } from '@/store/goods.js'
|
||||
import receiptPrint from "@/components/lodop/receiptPrint.js";
|
||||
const goodsStore = useGoods()
|
||||
|
||||
const classifyRef = ref(null);
|
||||
|
||||
const printStore = usePrint();
|
||||
const store = useUser();
|
||||
@@ -147,25 +188,122 @@ const printList = ref([]);
|
||||
const feets = ref([0, 1, 2, 3, 4, 5, 8]);
|
||||
const loading = ref(false);
|
||||
const requestLoading = ref(false);
|
||||
const printTypeList = ref([
|
||||
{
|
||||
label: '前台',
|
||||
values: [],
|
||||
list: [
|
||||
{ label: '客看单', value: 'GUEST_ORDER' },
|
||||
{ label: '预结算单', value: 'PRE_ORDER' },
|
||||
{ label: '结算单', value: 'ORDER' },
|
||||
{ label: '退菜单', value: 'RETURN_ORDER' },
|
||||
{ label: '退款单', value: 'REFUND_ORDER' },
|
||||
]
|
||||
},
|
||||
{
|
||||
label: '后厨',
|
||||
values: [],
|
||||
list: [
|
||||
{ label: '后厨-整单', value: 'ALL_KITCHEN' },
|
||||
{ label: '后厨-分单', value: 'ONLY_KITCHEN' },
|
||||
{ label: '后厨-退菜单', value: 'REFUND_KITCHEN' },
|
||||
]
|
||||
},
|
||||
{
|
||||
label: '其它',
|
||||
values: [],
|
||||
list: [
|
||||
{ label: '交班单', value: 'HANDOVER' },
|
||||
{ label: '排队取号', value: 'CALL' },
|
||||
{ label: '储值单', value: 'RECHARGE' },
|
||||
{ label: '出入库单', value: 'STOCK' },
|
||||
{ label: '盘点单', value: 'STOCK_CHECK' },
|
||||
{ label: '商品报表', value: 'PRODUCT_REPORT' },
|
||||
{ label: '经营日报', value: 'DAY_REPORT' },
|
||||
{ label: '日结单', value: 'DAY_ORDER' },
|
||||
]
|
||||
}
|
||||
])
|
||||
|
||||
// 切换打印机类型
|
||||
function connectionTypeChange(e) {
|
||||
form.value.address = ''
|
||||
form.value.receiptSize = ''
|
||||
form.value.classifyPrint = '0'
|
||||
if (e == 'USB') {
|
||||
form.value.receiptSize = '58mm'
|
||||
} else {
|
||||
form.value.printContentType = ''
|
||||
form.value.receiptSize = '80mm'
|
||||
form.value.printContentType = ''
|
||||
printTypeList.value.forEach(el => {
|
||||
el.values = []
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
const categoryIdsType = ref('all') // all=全部 custom=部分
|
||||
|
||||
const form = ref({
|
||||
id: "",
|
||||
name: '', // 设备名称
|
||||
connectionType: 'USB', // 现在打印机支持USB 和 网络、蓝牙
|
||||
connectionType: 'USB', // 现在打印机支持USB 和 网络、蓝牙、局域网
|
||||
address: '', // 打印机名称
|
||||
port: '', // 端口
|
||||
subType: 'cash', // 打印类型(分类)label标签cash小票kitchen出品
|
||||
printType: 'cash', // 打印类型(分类)label标签cash小票kitchen出品
|
||||
contentType: '', // 打印机品牌
|
||||
categoryIds: [], // 打印分类Id
|
||||
categoryIds: '', // 打印分类Id
|
||||
categoryList: [], // 分类
|
||||
sort: '',
|
||||
receiptSize: '58mm', // 小票尺寸 58mm 80mm
|
||||
classifyPrint: 1, // 分类打印 0-所有 1-部分分类 2-部分商品
|
||||
printQty: '', // 打印数量 c1m1^2 = 顾客+商家[2张] m1^1 = 商家[1张] c1^1顾客[1张] c2m1^3顾客2+商家1[3张]
|
||||
printMethod: 'all', // 打印方式 all-全部打印 normal-仅打印结账单「前台」one-仅打印制作单「厨房」queue-仅打印排队取号
|
||||
printType: [], // 打印类型,JSON数组 refund-确认退款单 handover-交班单 queue-排队取号
|
||||
status: 1
|
||||
receiptSize: '', // 小票尺寸 58mm 80mm
|
||||
classifyPrint: '0', // 分类打印 0-所有 1-部分分类 2-部分商品
|
||||
printNum: '', // 打印数量 c1m1^2 = 顾客+商家[2张] m1^1 = 商家[1张] c1^1顾客[1张] c2m1^3顾客2+商家1[3张]
|
||||
kitchenPrintMode: 'all', // 打印方式 all-全部打印 normal-仅打印结账单「前台」one-仅打印制作单「厨房」queue-仅打印排队取号
|
||||
printContentType: '',
|
||||
status: 1,
|
||||
handoverSwitch: 0, // 交班单开关 0-关闭 1-开启
|
||||
});
|
||||
|
||||
const rules = ref({
|
||||
name: [
|
||||
{
|
||||
required: true,
|
||||
message: '请输入设备名称',
|
||||
trigger: 'blur'
|
||||
}
|
||||
],
|
||||
address: [
|
||||
{
|
||||
required: true,
|
||||
validator: (rule, value, callback) => {
|
||||
if (form.value.connectionType == 'USB') {
|
||||
if (form.value.address == '') {
|
||||
callback(new Error('请选择设备'))
|
||||
}
|
||||
callback()
|
||||
} else {
|
||||
if (form.value.address == '') {
|
||||
callback(new Error('请输入设备IP'))
|
||||
}
|
||||
callback()
|
||||
}
|
||||
},
|
||||
trigger: 'change'
|
||||
}
|
||||
],
|
||||
classifyPrint: [
|
||||
{
|
||||
required: false,
|
||||
validator: (rule, value, callback) => {
|
||||
if (form.value.classifyPrint == '1' && form.value.categoryList.length == '0') {
|
||||
callback(new Error('请选择商品分类'))
|
||||
} else {
|
||||
callback()
|
||||
}
|
||||
},
|
||||
trigger: 'change'
|
||||
}
|
||||
]
|
||||
})
|
||||
const printDataLoading = ref(false);
|
||||
const printData = reactive({
|
||||
shop_name: '',
|
||||
@@ -209,42 +347,79 @@ function getPrintList() {
|
||||
}
|
||||
|
||||
// 测试打印
|
||||
function printHandle() {
|
||||
if (!form.value.address) {
|
||||
ElMessage.error("请选择打印设备");
|
||||
return;
|
||||
}
|
||||
printDataLoading.value = true;
|
||||
printData.shop_name = store.shopInfo.shopName
|
||||
printData.loginAccount = store.userInfo.name
|
||||
printData.deviceName = form.value.address;
|
||||
printData.printTime = dayjs().format("YYYY-MM-DD HH:mm:ss");
|
||||
printStore.pushReceiptData(printData, false);
|
||||
setTimeout(() => {
|
||||
printDataLoading.value = false;
|
||||
}, 2500);
|
||||
}
|
||||
|
||||
// 提交打印机
|
||||
async function submitHandle() {
|
||||
const formRef = ref(null)
|
||||
async function printHandle() {
|
||||
try {
|
||||
if (!form.value.name) {
|
||||
ElMessage.error("请输入设备名称");
|
||||
return;
|
||||
await formRef.value.validateField(['address'])
|
||||
printDataLoading.value = true;
|
||||
printData.shop_name = store.shopInfo.shopName
|
||||
printData.loginAccount = store.userInfo.name
|
||||
printData.deviceName = form.value.name;
|
||||
printData.printTime = dayjs().format("YYYY-MM-DD HH:mm:ss");
|
||||
|
||||
if (form.value.connectionType === 'USB') {
|
||||
receiptPrint(printData,)
|
||||
} else if (form.value.connectionType === '局域网') {
|
||||
ipcRenderer.send('ORDER', JSON.stringify({
|
||||
printerIp: form.value.address,
|
||||
orderData: printData
|
||||
}))
|
||||
}
|
||||
if (!form.value.address) {
|
||||
ElMessage.error("请选择打印设备");
|
||||
return;
|
||||
}
|
||||
loading.value = true;
|
||||
await printerAdd(form.value, form.value.id ? "put" : "post");
|
||||
ElMessage.success(form.value.id ? "编辑成功" : "添加成功");
|
||||
printStore.init();
|
||||
router.back();
|
||||
setTimeout(() => {
|
||||
printDataLoading.value = false;
|
||||
}, 2500);
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
}
|
||||
loading.value = false;
|
||||
}
|
||||
|
||||
// 打印类型切换
|
||||
function printTypeChange(e, index) {
|
||||
if (index == 1 && printTypeList.value[index].values.length == 0) {
|
||||
form.value.categoryList = []
|
||||
form.value.classifyPrint = '0'
|
||||
formRef.value?.clearValidate('classifyPrint')
|
||||
}
|
||||
if (index == 1 && printTypeList.value[index].values.length > 0) {
|
||||
form.value.classifyPrint = '1'
|
||||
}
|
||||
}
|
||||
|
||||
// 选择分类以后的回调
|
||||
function classifyChange(e) {
|
||||
form.value.categoryList = e
|
||||
formRef.value.validateField(['classifyPrint'])
|
||||
}
|
||||
|
||||
// 提交打印机
|
||||
function submitHandle() {
|
||||
formRef.value.validate(async valid => {
|
||||
try {
|
||||
if (valid) {
|
||||
loading.value = true;
|
||||
form.value.categoryIds = form.value.categoryList.map(item => item.id).join(',')
|
||||
|
||||
if (form.value.connectionType == 'USB') {
|
||||
form.value.receiptSize = '58mm'
|
||||
form.value.printContentType = 'GUEST_ORDER,PRE_ORDER,ORDER,REFUND_ORDER'
|
||||
} else {
|
||||
form.value.receiptSize = '80mm'
|
||||
let arr = []
|
||||
printTypeList.value.forEach(item => {
|
||||
arr.push(...item.values)
|
||||
})
|
||||
form.value.printContentType = arr.join(',')
|
||||
}
|
||||
await printerAdd(form.value, form.value.id ? "put" : "post");
|
||||
ElMessage.success(form.value.id ? "编辑成功" : "添加成功");
|
||||
printStore.init();
|
||||
router.back();
|
||||
}
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
}
|
||||
loading.value = false;
|
||||
})
|
||||
}
|
||||
|
||||
// 查询打印机详情
|
||||
@@ -253,6 +428,37 @@ async function tbPrintMachineDetailAjax(id) {
|
||||
requestLoading.value = true;
|
||||
const res = await printerDetail({ id: id });
|
||||
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) {
|
||||
console.log(error);
|
||||
}
|
||||
@@ -297,6 +503,7 @@ onMounted(() => {
|
||||
border-radius: 10px;
|
||||
background-color: #fff;
|
||||
padding: 15px;
|
||||
overflow-y: auto;
|
||||
}
|
||||
|
||||
.menu_wrap {
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
<div class="item" v-for="item in list" :key="item.id">
|
||||
<div class="left">
|
||||
<div class="icon">
|
||||
<el-image :src="icons[item.subType]" style="width: 40px; height: 40px"></el-image>
|
||||
<el-image :src="icons[item.printType]" style="width: 40px; height: 40px"></el-image>
|
||||
</div>
|
||||
<div class="info">
|
||||
<div class="name">{{ item.name }}</div>
|
||||
@@ -28,7 +28,7 @@
|
||||
<div class="editor">
|
||||
<el-text type="primary" @click="
|
||||
router.push({
|
||||
name: deviceRoute[item.subType],
|
||||
name: deviceRoute[item.printType],
|
||||
query: { id: item.id },
|
||||
})
|
||||
">
|
||||
|
||||
@@ -248,22 +248,31 @@
|
||||
</div>
|
||||
</div>
|
||||
</el-dialog>
|
||||
<!-- 退款推库存的操作弹窗 -->
|
||||
<refundConsModal ref="refundConsModalRef" :list="refundList" @success="refundConsModalSuccess" />
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import _ from 'lodash'
|
||||
import { ref } from 'vue'
|
||||
import { ElMessage } from 'element-plus'
|
||||
import takeFoodCode from '@/components/takeFoodCode.vue'
|
||||
import TableMerging from './tableMerging.vue'
|
||||
import skuModal from '@/components/skuModal.vue'
|
||||
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 { 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 socket = useSocket()
|
||||
|
||||
const printStore = usePrint()
|
||||
const store = useUser()
|
||||
const tableMergingRef = ref(null)
|
||||
|
||||
const props = defineProps({
|
||||
@@ -312,15 +321,21 @@ async function returnFormSubmit() {
|
||||
returnFormLoading.value = true
|
||||
await returnOrderItemAjax(returnForm.value.num)
|
||||
showReturnForm.value = false
|
||||
ElMessage.success('退菜成功')
|
||||
// ElMessage.success('退菜成功')
|
||||
} catch (error) {
|
||||
console.log('退菜失败了');
|
||||
}
|
||||
returnFormLoading.value = false
|
||||
}
|
||||
|
||||
// 提交退菜
|
||||
async function returnOrderItemAjax(num = 1) {
|
||||
const refundStock = ref('')
|
||||
// 退款推库存的操作
|
||||
function refundConsModalSuccess(e) {
|
||||
refundStock.value = e
|
||||
refundNext()
|
||||
}
|
||||
|
||||
async function refundNext() {
|
||||
try {
|
||||
let data = {
|
||||
orderId: goodsStore.orderListInfo.id,
|
||||
@@ -332,19 +347,82 @@ async function returnOrderItemAjax(num = 1) {
|
||||
{
|
||||
id: goodsStore.cartOrderItem.id,
|
||||
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)
|
||||
goodsStore.cartOrderItem.returnNum += num
|
||||
ElMessage.success('退菜成功')
|
||||
goodsStore.cartOrderItem.returnNum += refundNum.value
|
||||
goodsStore.calcCartInfo()
|
||||
|
||||
// 打印退菜小票
|
||||
// getOrderByIdAjax(goodsStore.orderListInfo.id).then(res => {
|
||||
// let originOrderInfo = res
|
||||
// let index = originOrderInfo.cartList.findIndex(item => item.id == goodsStore.cartOrderItem.id)
|
||||
// originOrderInfo.cartList = _.at(originOrderInfo.cartList, index);
|
||||
// originOrderInfo.cartList[0].num = refundNum.value
|
||||
// originOrderInfo.cartList[0].returnNum = 0
|
||||
// originOrderInfo.cartList[0].payAmount = refundNum.value * originOrderInfo.cartList[0].price
|
||||
|
||||
// printStore.printRefundDish(commOrderPrintData({ ...originOrderInfo, isRefundDish: true }));
|
||||
// }).catch(err => {
|
||||
// console.log(err);
|
||||
// })
|
||||
// await goodsStore.historyOrderAjax('', data.orderId)
|
||||
} catch (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() {
|
||||
let item = goodsStore.cartList[goodsStore.cartActiveIndex]
|
||||
|
||||
@@ -55,7 +55,13 @@
|
||||
</div>
|
||||
<div class="shop_list" :class="{ img: shopListType == 'img' }" v-loading="loading">
|
||||
<!-- <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">
|
||||
<div class="item_wrap" v-for="item in goods" :key="item.id" @click="showSkuHandle(item)">
|
||||
<div class="item">
|
||||
@@ -89,7 +95,7 @@
|
||||
<img class="sell_out_icon" src="@/assets/icon_goods_wks.svg">
|
||||
</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">
|
||||
</div>
|
||||
<!-- 库存不足 -->
|
||||
@@ -294,6 +300,8 @@ import { staffPermission } from '@/api/user.js'
|
||||
import { clearNoNum } from '@/utils/index.js'
|
||||
import { productOnOff, markIsSoldOut } from '@/api/product_new.js'
|
||||
|
||||
import { Mousewheel } from 'swiper/modules'
|
||||
|
||||
const swiperRef = ref(null)
|
||||
|
||||
const store = useUser()
|
||||
@@ -551,7 +559,7 @@ function showSkuHandle(item) {
|
||||
message: '不在可售时间内',
|
||||
})
|
||||
return
|
||||
} else if (item.isSoldStock) {
|
||||
} else if (item.isSoldStock || item.isSoldOut) {
|
||||
ElMessage({
|
||||
type: 'error',
|
||||
message: '该商品已售罄',
|
||||
|
||||
@@ -144,6 +144,10 @@ const props = defineProps({
|
||||
member: {
|
||||
type: Object,
|
||||
default: {}
|
||||
},
|
||||
type: {
|
||||
type: String,
|
||||
default: 'cart' // cart 代客下单 table 桌台结算 order 订单结算
|
||||
}
|
||||
});
|
||||
|
||||
@@ -200,14 +204,64 @@ const printHandle = _.throttle(async function () {
|
||||
await printOrderLable(true)
|
||||
}, 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) {
|
||||
try {
|
||||
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") || [];
|
||||
|
||||
console.log('printStore.deviceNoteList.length:', printStore.deviceNoteList.length);
|
||||
|
||||
// 防止重复打印
|
||||
if (!printList.some((el) => el == orderId)) {
|
||||
if (!isBefore) {
|
||||
@@ -221,17 +275,17 @@ async function printOrderLable(isBefore = false) {
|
||||
printStore.labelPrint(commOrderPrintData(data))
|
||||
}
|
||||
}
|
||||
|
||||
console.log('printStore.deviceNoteList', printStore.deviceNoteList);
|
||||
if (printStore.deviceNoteList.length) {
|
||||
// 使用本地打印机打印
|
||||
printStore.pushReceiptData(commOrderPrintData({ ...data, isBefore: isBefore }));
|
||||
} else {
|
||||
// 本地没有可用打印机使用云打印机
|
||||
// await orderPrint({
|
||||
// type: isBefore ? 1 : 0,
|
||||
// id: orderId,
|
||||
// });
|
||||
// ElMessage.success(`云打印${isBefore ? '预' : ''}结算单成功`);
|
||||
await orderPrint({
|
||||
type: isBefore ? 1 : 0,
|
||||
id: orderId,
|
||||
});
|
||||
ElMessage.success(`云打印${isBefore ? '预' : ''}结算单成功`);
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
@@ -258,9 +312,14 @@ function paySuccess() {
|
||||
|
||||
const payCardRef = ref(null)
|
||||
function show(t) {
|
||||
goodsStore.payType = props.type
|
||||
dialogVisible.value = true;
|
||||
cartInfo.value = { ...goodsStore.cartInfo }
|
||||
orderList.value = [...goodsStore.cartList, ...goodsStore.orderList.map(item => item.goods).flat()]
|
||||
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()]
|
||||
}
|
||||
|
||||
console.log('orderListInfo===================', { ...goodsStore.orderListInfo });
|
||||
|
||||
|
||||
@@ -204,7 +204,7 @@ function confirmHandle() {
|
||||
goodsStore.operateCart({
|
||||
table_code: table_code,
|
||||
new_table_code: new_table_code,
|
||||
cart_ids: cart_ids
|
||||
cart_id: cart_ids
|
||||
}, 'rottable')
|
||||
}
|
||||
|
||||
|
||||
@@ -1,42 +1,43 @@
|
||||
<template>
|
||||
<div class="content">
|
||||
<div class="cart_wrap card" v-loading="cartLoading">
|
||||
<div class="menu_top">
|
||||
<div class="menu" @click="pendingCartModalRef.show()">
|
||||
<el-icon class="icon">
|
||||
<TakeawayBox />
|
||||
</el-icon>
|
||||
<el-text class="t">({{ goodsStore.pendingList.length }})</el-text>
|
||||
</div>
|
||||
<div class="number" @click="SelectVipUserRef.show()">
|
||||
<div class="left">
|
||||
<div>
|
||||
<div class="content">
|
||||
<div class="cart_wrap card" v-loading="cartLoading">
|
||||
<div class="menu_top">
|
||||
<div class="menu" @click="pendingCartModalRef.show()">
|
||||
<el-icon class="icon">
|
||||
<CirclePlus />
|
||||
<TakeawayBox />
|
||||
</el-icon>
|
||||
<template v-if="!goodsStore.vipUserInfo.id">
|
||||
<span class="t">选择用户</span>
|
||||
</template>
|
||||
<template v-else>
|
||||
<div class="user_info">
|
||||
<!-- <el-text class="n">{{ goodsStore.vipUserInfo.nickName }}</el-text> -->
|
||||
<el-text class="p">{{ formatPhoneNumber(goodsStore.vipUserInfo.phone) }}</el-text>
|
||||
<el-text class="t">({{ goodsStore.pendingList.length }})</el-text>
|
||||
</div>
|
||||
<div class="number" @click="SelectVipUserRef.show()">
|
||||
<div class="left">
|
||||
<el-icon class="icon">
|
||||
<CirclePlus />
|
||||
</el-icon>
|
||||
<template v-if="!goodsStore.vipUserInfo.id">
|
||||
<span class="t">选择用户</span>
|
||||
</template>
|
||||
<template v-else>
|
||||
<div class="user_info">
|
||||
<!-- <el-text class="n">{{ goodsStore.vipUserInfo.nickName }}</el-text> -->
|
||||
<el-text class="p">{{ formatPhoneNumber(goodsStore.vipUserInfo.phone) }}</el-text>
|
||||
</div>
|
||||
</template>
|
||||
</div>
|
||||
<div class="icon_wrap">
|
||||
<div class="u_icon" v-if="!goodsStore.vipUserInfo.id">
|
||||
<el-icon class="i">
|
||||
<ArrowRight />
|
||||
</el-icon>
|
||||
</div>
|
||||
<div class="u_icon" v-else @click.stop="goodsStore.clearVipUserInfo()">
|
||||
<el-icon class="i">
|
||||
<Close />
|
||||
</el-icon>
|
||||
</div>
|
||||
</template>
|
||||
</div>
|
||||
<div class="icon_wrap">
|
||||
<div class="u_icon" v-if="!goodsStore.vipUserInfo.id">
|
||||
<el-icon class="i">
|
||||
<ArrowRight />
|
||||
</el-icon>
|
||||
</div>
|
||||
<div class="u_icon" v-else @click.stop="goodsStore.clearVipUserInfo()">
|
||||
<el-icon class="i">
|
||||
<Close />
|
||||
</el-icon>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- <div class="select_user" @click="quickCashHandle">
|
||||
<!-- <div class="select_user" @click="quickCashHandle">
|
||||
<div class="left">
|
||||
<el-icon class="icon" style="color: var(--el-color-warning);">
|
||||
<WalletFilled />
|
||||
@@ -44,7 +45,7 @@
|
||||
<el-text class="t">快捷收银</el-text>
|
||||
</div>
|
||||
</div> -->
|
||||
<!-- <div class="select_user">
|
||||
<!-- <div class="select_user">
|
||||
<div class="left">
|
||||
<el-icon class="icon">
|
||||
<UserFilled />
|
||||
@@ -63,155 +64,156 @@
|
||||
<Close />
|
||||
</el-icon>
|
||||
</div> -->
|
||||
</div>
|
||||
<div class="shop_operation">
|
||||
<div class="shop_list">
|
||||
<div class="table_info" v-if="goodsStore.tableInfo.name">
|
||||
<div class="left">
|
||||
<span>台桌:{{ goodsStore.tableInfo.name }}</span>
|
||||
<div class="n" @click="takeFoodCodeRef.show()">
|
||||
{{ goodsStore.tableInfo.num || 1 }}人
|
||||
<el-icon>
|
||||
<EditPen />
|
||||
</el-icon>
|
||||
</div>
|
||||
</div>
|
||||
<div class="close" @click="goodsStore.selectTable()">
|
||||
<el-icon class="icon">
|
||||
<Close />
|
||||
</el-icon>
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<CartItem :item="item" :index="index" v-for="(item, index) in goodsStore.cartList" :key="item.id" />
|
||||
</div>
|
||||
<div class="empty" v-if="!goodsStore.cartList.length">
|
||||
<el-empty description="请选择商品" />
|
||||
</div>
|
||||
<div class="order_list_wrap">
|
||||
<div class="order_title" :class="{ border: !goodsStore.cartList.length }"
|
||||
v-if="goodsStore.orderList.length">
|
||||
<span class="l">历史下单</span>
|
||||
<div class="del" @click="goodsStore.clearHistoryOrder()">
|
||||
<el-icon class="icon">
|
||||
<Delete />
|
||||
</el-icon>
|
||||
<span>清空历史订单</span>
|
||||
</div>
|
||||
</div>
|
||||
<CartItem
|
||||
:item="{ product_name: '客座费', number: goodsStore.tableInfo.num, salePrice: store.shopInfo.tableFee, memberPrice: store.shopInfo.tableFee }"
|
||||
v-if="!store.shopInfo.isTableFee && goodsStore.tableInfo.name && !goodsStore.allSelected" />
|
||||
<div class="order_list_item" v-for="(arr, index) in goodsStore.orderList" :key="index">
|
||||
<div class="order_num">
|
||||
<span class="l">{{ `第${arr.orderNum}次下单` }}</span>
|
||||
<div class="del" @click="goodsStore.deleteHistoryOrder(arr.orderNum)">
|
||||
<span>删除</span>
|
||||
</div>
|
||||
</div>
|
||||
<CartItem type="order" :border="false" :item="item" :index="index" :i="i" :key="item.id"
|
||||
v-for="(item, i) in arr.goods" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- 购物车操作栏 -->
|
||||
<cartOperation :item="cartListActiveItem" @confirm="" @delete="delCartHandle" @pending="pendingCart"
|
||||
@merging="showTableMerging" @showPackage="e => goodsRef.showPackage(e)" />
|
||||
</div>
|
||||
<div class="footer">
|
||||
<div class="top">
|
||||
<div class="num-wrap">
|
||||
<div class="num_wrap_top">
|
||||
<div class="left" @click="allSelectedHandle"
|
||||
v-if="store.shopInfo && store.shopInfo.eatModel.includes('take-out')">
|
||||
<div class="selected">
|
||||
<div class="selected_round" v-if="!goodsStore.allSelected"></div>
|
||||
<el-icon class="icon" v-else>
|
||||
<CircleCheckFilled />
|
||||
<div class="shop_operation">
|
||||
<div class="shop_list">
|
||||
<div class="table_info" v-if="goodsStore.tableInfo.name">
|
||||
<div class="left">
|
||||
<span>台桌:{{ goodsStore.tableInfo.name }}</span>
|
||||
<div class="n" @click="takeFoodCodeRef.show()">
|
||||
{{ goodsStore.tableInfo.num || 0 }}人
|
||||
<el-icon>
|
||||
<EditPen />
|
||||
</el-icon>
|
||||
</div>
|
||||
<el-text class="t">外带</el-text>
|
||||
</div>
|
||||
<div class="left" v-else></div>
|
||||
<div class="right" v-if="goodsStore.cartInfo.costSummary">
|
||||
共<el-text>
|
||||
{{ formatDecimal(goodsStore.cartInfo.costSummary.goodsTotal || 0, 2, true) }}件
|
||||
</el-text>,¥{{ formatDecimal(goodsStore.cartInfo.costSummary.finalPayAmount || 0) }}
|
||||
<div class="close" @click="goodsStore.selectTable()">
|
||||
<el-icon class="icon">
|
||||
<Close />
|
||||
</el-icon>
|
||||
</div>
|
||||
</div>
|
||||
<div class="num_wrap_btm">
|
||||
{{ goodsStore.cartInfo.discountInfo }}
|
||||
<div>
|
||||
<CartItem :item="item" :index="index" v-for="(item, index) in goodsStore.cartList" :key="item.id" />
|
||||
</div>
|
||||
<div class="empty" v-if="!goodsStore.cartList.length">
|
||||
<el-empty description="请选择商品" />
|
||||
</div>
|
||||
<div class="order_list_wrap">
|
||||
<div class="order_title" :class="{ border: !goodsStore.cartList.length }"
|
||||
v-if="goodsStore.orderList.length">
|
||||
<span class="l">历史下单</span>
|
||||
<div class="del" @click="goodsStore.clearHistoryOrder()">
|
||||
<el-icon class="icon">
|
||||
<Delete />
|
||||
</el-icon>
|
||||
<span>清空历史订单</span>
|
||||
</div>
|
||||
</div>
|
||||
<CartItem
|
||||
:item="{ product_name: '客座费', number: goodsStore.tableInfo.num, salePrice: store.shopInfo.tableFee, memberPrice: store.shopInfo.tableFee }"
|
||||
v-if="!store.shopInfo.isTableFee && goodsStore.tableInfo.name && !goodsStore.allSelected" />
|
||||
<div class="order_list_item" v-for="(arr, index) in goodsStore.orderList" :key="index">
|
||||
<div class="order_num">
|
||||
<span class="l">{{ `第${arr.orderNum}次下单` }}</span>
|
||||
<div class="del" @click="goodsStore.deleteHistoryOrder(arr.orderNum)">
|
||||
<span>删除</span>
|
||||
</div>
|
||||
</div>
|
||||
<CartItem type="order" :border="false" :item="item" :index="index" :i="i" :key="item.id"
|
||||
v-for="(item, i) in arr.goods" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- 购物车操作栏 -->
|
||||
<cartOperation :item="cartListActiveItem" @confirm="" @delete="delCartHandle" @pending="pendingCart"
|
||||
@merging="showTableMerging" @showPackage="e => goodsRef.showPackage(e)" />
|
||||
</div>
|
||||
<div class="btm">
|
||||
<el-button icon="Edit" @click="remarkRef.show()"></el-button>
|
||||
<div class="button">
|
||||
<div class="btn" v-if="store.shopInfo.registerType == 'after'">
|
||||
<el-button type="primary" style="width: 100%;" :disabled="!goodsStore.cartList.length"
|
||||
v-loading="createOrderLoading" @click="createOrderHandle(0)">
|
||||
仅下单
|
||||
</el-button>
|
||||
<div class="footer">
|
||||
<div class="top">
|
||||
<div class="num-wrap">
|
||||
<div class="num_wrap_top">
|
||||
<div class="left" @click="allSelectedHandle"
|
||||
v-if="store.shopInfo && store.shopInfo.eatModel.includes('take-out')">
|
||||
<div class="selected">
|
||||
<div class="selected_round" v-if="!goodsStore.allSelected"></div>
|
||||
<el-icon class="icon" v-else>
|
||||
<CircleCheckFilled />
|
||||
</el-icon>
|
||||
</div>
|
||||
<el-text class="t">外带</el-text>
|
||||
</div>
|
||||
<div class="left" v-else></div>
|
||||
<div class="right" v-if="goodsStore.cartInfo.costSummary">
|
||||
共<el-text>
|
||||
{{ formatDecimal(goodsStore.cartInfo.costSummary.goodsTotal || 0, 2, true) }}件
|
||||
</el-text>,¥{{ formatDecimal(goodsStore.cartInfo.costSummary.finalPayAmount || 0) }}
|
||||
</div>
|
||||
</div>
|
||||
<div class="num_wrap_btm">
|
||||
{{ goodsStore.cartInfo.discountInfo }}
|
||||
</div>
|
||||
</div>
|
||||
<div class="btn">
|
||||
<el-button type="primary" style="width: 100%;"
|
||||
:disabled="!goodsStore.cartList.length && !goodsStore.orderList.length" v-loading="createOrderLoading"
|
||||
@click="createOrderHandle(1)">
|
||||
去结算
|
||||
</el-button>
|
||||
</div>
|
||||
<div class="btm">
|
||||
<el-button icon="Edit" @click="remarkRef.show()"></el-button>
|
||||
<div class="button">
|
||||
<div class="btn" v-if="store.shopInfo.registerType == 'after'">
|
||||
<el-button type="primary" style="width: 100%;" :disabled="!goodsStore.cartList.length"
|
||||
v-loading="createOrderLoading" @click="createOrderHandle(0)">
|
||||
仅下单
|
||||
</el-button>
|
||||
</div>
|
||||
<div class="btn">
|
||||
<el-button type="primary" style="width: 100%;"
|
||||
:disabled="!goodsStore.cartList.length && !goodsStore.orderList.length" v-loading="createOrderLoading"
|
||||
@click="createOrderHandle(1)">
|
||||
去结算
|
||||
</el-button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="shop_manage card">
|
||||
<!-- 分类/商品列表 -->
|
||||
<goods ref="goodsRef" @loading="cartLoading = true" />
|
||||
<!-- ©银收客 v{{ packageData.version }} -->
|
||||
</div>
|
||||
<!-- 无权限遮罩 -->
|
||||
<div class="no_permission" v-if="!store.menus.length || (store.menus.length && !store.menus[0].state)">
|
||||
无操作权限,请联系管理员(;´д`)ゞ
|
||||
</div>
|
||||
<!-- 打印插件是否加载好的提示 -->
|
||||
<div class="print_tip" v-if="!printStore.isPrintService"
|
||||
v-loading="!printStore.isPrintService && !printStore.showPrintNotService" element-loading-text="打印服务加载中...">
|
||||
<el-dialog title="注意" v-model="printStore.showPrintNotService" :modal="false" :close-on-click-modal="false"
|
||||
:close-on-press-escape="false" :show-close="false" top="30vh">
|
||||
<span class="print_tip_title">打印服务未启动,请重新加载程序或者退出后重新打开!</span>
|
||||
<template #footer>
|
||||
<div class="dialog-footer">
|
||||
<el-button @click="printReloadHandle">重新加载</el-button>
|
||||
<el-button type="primary" @click="quitAPPhandle">退出程序</el-button>
|
||||
</div>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</div>
|
||||
</div>
|
||||
<div class="shop_manage card">
|
||||
<!-- 分类/商品列表 -->
|
||||
<goods ref="goodsRef" @loading="cartLoading = true" />
|
||||
<!-- ©银收客 v{{ packageData.version }} -->
|
||||
</div>
|
||||
<!-- 无权限遮罩 -->
|
||||
<div class="no_permission" v-if="!store.menus.length || (store.menus.length && !store.menus[0].state)">
|
||||
无操作权限,请联系管理员(;´д`)ゞ
|
||||
</div>
|
||||
<!-- 打印插件是否加载好的提示 -->
|
||||
<div class="print_tip" v-if="!printStore.isPrintService"
|
||||
v-loading="!printStore.isPrintService && !printStore.showPrintNotService" element-loading-text="打印服务加载中...">
|
||||
<el-dialog title="注意" v-model="printStore.showPrintNotService" :modal="false" :close-on-click-modal="false"
|
||||
:close-on-press-escape="false" :show-close="false" top="30vh">
|
||||
<span class="print_tip_title">打印服务未启动,请重新加载程序或者退出后重新打开!</span>
|
||||
<template #footer>
|
||||
<div class="dialog-footer">
|
||||
<el-button @click="printReloadHandle">重新加载</el-button>
|
||||
<el-button type="primary" @click="quitAPPhandle">退出程序</el-button>
|
||||
</div>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</div>
|
||||
<!-- 备注 -->
|
||||
<remarkModal ref="remarkRef" @success="(e) => (goodsStore.remark = e)" />
|
||||
<!-- 修改取餐号 -->
|
||||
<takeFoodCode />
|
||||
<el-drawer v-model="membershow" :with-header="true" size="90%" title="选择会员">
|
||||
<member :membershow="'1'"></member>
|
||||
</el-drawer>
|
||||
<!-- <takeFoodCode ref="takeFoodCodeRef" title="修改取餐号" placeholder="请输入取餐号" @success="takeFoodCodeSuccess" /> -->
|
||||
<!-- 结算订单 -->
|
||||
<settleAccount ref="settleAccountRef" :amount="cartInfo.totalAmount" :remark="goodsStore.remark" @success="" />
|
||||
<!-- 快捷收银 -->
|
||||
<fastCashier ref="fastCashierRef" type="0" />
|
||||
<!-- 挂起订单 -->
|
||||
<pendingCartModal ref="pendingCartModalRef" />
|
||||
<!-- 检查版本升级 -->
|
||||
<updateDialog />
|
||||
<!-- 选择会员 -->
|
||||
<SelectVipUser ref="SelectVipUserRef" @success="selectUser" />
|
||||
<!-- 修改就餐人数 -->
|
||||
<takeFoodCode ref="takeFoodCodeRef" title="修改就餐人数" placeholder="请输入就餐人数" @success="updateSeatNum" />
|
||||
</div>
|
||||
<!-- 备注 -->
|
||||
<remarkModal ref="remarkRef" @success="(e) => (remark = e)" />
|
||||
<!-- 修改取餐号 -->
|
||||
<takeFoodCode />
|
||||
<el-drawer v-model="membershow" :with-header="true" size="90%" title="选择会员">
|
||||
<member :membershow="'1'"></member>
|
||||
</el-drawer>
|
||||
<!-- <takeFoodCode ref="takeFoodCodeRef" title="修改取餐号" placeholder="请输入取餐号" @success="takeFoodCodeSuccess" /> -->
|
||||
<!-- 结算订单 -->
|
||||
<settleAccount ref="settleAccountRef" :cart="cartList" :amount="cartInfo.totalAmount" :remark="remark"
|
||||
:orderInfo="orderInfo" @success="" />
|
||||
<!-- 快捷收银 -->
|
||||
<fastCashier ref="fastCashierRef" type="0" />
|
||||
<!-- 挂起订单 -->
|
||||
<pendingCartModal ref="pendingCartModalRef" />
|
||||
<!-- 检查版本升级 -->
|
||||
<updateDialog />
|
||||
<!-- 选择会员 -->
|
||||
<SelectVipUser ref="SelectVipUserRef" @success="selectUser" />
|
||||
<!-- 修改就餐人数 -->
|
||||
<takeFoodCode ref="takeFoodCodeRef" title="修改就餐人数" placeholder="请输入就餐人数" @success="updateSeatNum" />
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import _ from 'lodash'
|
||||
import { ref } from "vue";
|
||||
import { useGlobal } from '@/store/global.js'
|
||||
import SelectVipUser from "@/components/selectVipUser.vue";
|
||||
@@ -224,7 +226,7 @@ import fastCashier from "@/views/home/components/fastCashier.vue";
|
||||
import pendingCartModal from "@/views/home/components/pendingCartModal.vue";
|
||||
import tableMerging from '@/views/home/components/tableMerging.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 { staffPermission } from '@/api/user.js'
|
||||
import { createOrder } from '@/api/order.js'
|
||||
@@ -252,7 +254,6 @@ const pendingCartModalRef = ref(null);
|
||||
const settleAccountRef = ref(null);
|
||||
const fastCashierRef = ref(null);
|
||||
const tableMergingRef = ref(null)
|
||||
const remark = ref("");
|
||||
const cartListActive = ref(0);
|
||||
const cartListActiveItem = ref({})
|
||||
const cartList = ref([]);
|
||||
@@ -299,6 +300,7 @@ async function quickCashHandle() {
|
||||
// 生成订单 t=0 先下单后结算 t=1直接结算
|
||||
async function createOrderHandle(t = 0) {
|
||||
try {
|
||||
let placeNum = goodsStore.orderListInfo.placeNum || 0
|
||||
if (goodsStore.cartList.length) {
|
||||
const data = {
|
||||
orderId: goodsStore.orderListInfo.id || '', // 订单id
|
||||
@@ -308,8 +310,8 @@ async function createOrderHandle(t = 0) {
|
||||
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: remark.value, // 备注
|
||||
placeNum: (goodsStore.orderListInfo.placeNum || 0) + 1, // 下单次数
|
||||
remark: goodsStore.remark, // 备注
|
||||
placeNum: placeNum + 1, // 下单次数
|
||||
waitCall: 0, // 是否叫号
|
||||
userId: goodsStore.vipUserInfo.userId || '', // 会员用户id
|
||||
limitRate: goodsStore.limitDiscountRes
|
||||
@@ -328,6 +330,32 @@ async function createOrderHandle(t = 0) {
|
||||
settleAccountRef.value.show(t)
|
||||
} else {
|
||||
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()
|
||||
|
||||
@@ -26,16 +26,22 @@
|
||||
</div>
|
||||
</template>
|
||||
</el-dialog> -->
|
||||
<el-input v-model="authCode" placeholder="请扫描支付码"></el-input>
|
||||
<el-button type="primary" @click="microPayAjax">反扫支付</el-button>
|
||||
<!-- <el-input v-model="authCode" placeholder="请扫描支付码"></el-input>
|
||||
<el-button type="primary" @click="microPayAjax">反扫支付</el-button> -->
|
||||
<el-button type="primary" @click="printReceipt">打印盘点单</el-button>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import dayjs from 'dayjs';
|
||||
import { onMounted, ref } from 'vue'
|
||||
import { findVersion } from '@/api/user.js'
|
||||
import packageData from "../../../package.json";
|
||||
import { ipcRenderer } from 'electron'
|
||||
import { microPay } from '@/api/order.js'
|
||||
import { usePrint } from '@/store/print';
|
||||
import { printData } from '@/api/print.js'
|
||||
import { useUser } from '@/store/user.js'
|
||||
import { ALL_KITCHEN, ONLY_KITCHEN, REFUND_KITCHEN } from '../../../electron/printService'
|
||||
|
||||
const showDialog = ref(false)
|
||||
const updataInfo = ref({})
|
||||
@@ -44,8 +50,89 @@ const uploadPro = ref(0)
|
||||
const uploadSucess = ref(false)
|
||||
const uploadResponse = ref({})
|
||||
const tempFilePath = ref('')
|
||||
|
||||
const printStore = usePrint()
|
||||
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() {
|
||||
|
||||
346
src/views/member/components/StoreWineManagement.vue
Normal file
346
src/views/member/components/StoreWineManagement.vue
Normal file
@@ -0,0 +1,346 @@
|
||||
<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 ref="formRef" :model="form" :rules="rules" label-width="100px" label-position="left">
|
||||
<el-form-item label="选择酒品" prop="shopStorageGoodId">
|
||||
<el-select v-model="form.shopStorageGoodId" placeholder="请选择存酒商品" style="width: 180px;">
|
||||
<el-option v-for="item in storageGoodList" :key="item.id" :label="item.name" :value="item.id">
|
||||
</el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="存酒数量">
|
||||
<el-input-number v-model="form.num" :min="1" :step="1" step-strictly></el-input-number>
|
||||
</el-form-item>
|
||||
<el-form-item label="存酒有效期">
|
||||
<el-input-number v-model="form.expDay" :min="1" :step="1" step-strictly></el-input-number>
|
||||
<span style="margin-left: 8px;">天</span>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<div class="dialog-footer">
|
||||
<div class="btn">
|
||||
<el-button style="width: 100%;" @click="dialogVisible = false">取 消</el-button>
|
||||
</div>
|
||||
<div class="btn">
|
||||
<el-button style="width: 100%;" type="primary" :loading="confirmLoading" @click="confirmHandle">确
|
||||
定</el-button>
|
||||
</div>
|
||||
</div>
|
||||
</el-dialog>
|
||||
<!-- 取酒对话框,只选择数量即可,不可超过存酒的数量 -->
|
||||
<el-dialog v-model="takeWineDialogVisible" title="取酒" width="350px" :close-on-click-modal="false" destroy-on-close>
|
||||
<el-form :model="takeWineForm" :rules="takeWineRules" label-width="100px" label-position="left">
|
||||
<el-form-item label="取酒数量">
|
||||
<el-input-number v-model="takeWineForm.num" :min="1" :step="1" step-strictly
|
||||
:max="maxTakeNum"></el-input-number>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<div class="dialog-footer">
|
||||
<div class="btn">
|
||||
<el-button style="width: 100%;" @click="takeWineDialogVisible = false">取 消</el-button>
|
||||
</div>
|
||||
<div class="btn">
|
||||
<el-button style="width: 100%;" type="primary" :loading="takeWineConfirmLoading"
|
||||
@click="confirmTakeWineHandle">确 定</el-button>
|
||||
</div>
|
||||
</div>
|
||||
</el-dialog>
|
||||
<!-- 存取酒记录弹窗 -->
|
||||
<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 formRef = ref(null)
|
||||
|
||||
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);
|
||||
function confirmHandle() {
|
||||
formRef.value.validate(async vaild => {
|
||||
try {
|
||||
if (vaild) {
|
||||
confirmLoading.value = true;
|
||||
form.value.userId = props.userInfo.userId;
|
||||
await shopStoragePost(form.value);
|
||||
ElMessage.success('存酒成功');
|
||||
dialogVisible.value = false;
|
||||
shopStorageGetAjax(); // 刷新存酒商品列表
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('存酒失败:', error);
|
||||
} finally {
|
||||
confirmLoading.value = false;
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
// 获取存酒商品列表
|
||||
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 class="btn_wrap">
|
||||
<div class="btn">
|
||||
<el-button type="success" style="width: 100%;" @click="StoreWineManagementRef.show()">存酒管理</el-button>
|
||||
</div>
|
||||
<div class="btn">
|
||||
<el-button type="warning" style="width: 100%;" @click="UserChargeRef.show()">账户充值</el-button>
|
||||
</div>
|
||||
@@ -114,6 +117,8 @@
|
||||
<RecordDialog ref="RecordDialogRef" @refund="getUserList" />
|
||||
<!-- 添加会员 -->
|
||||
<AddUserDrawer ref="AddUserDrawerRef" @success="queryHandle" />
|
||||
<!-- 存酒管理 -->
|
||||
<StoreWineManagement ref="StoreWineManagementRef" :user-info="currentRow" />
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
@@ -123,10 +128,12 @@ import { shopUserList } from '@/api/account.js'
|
||||
import UserCharge from './components/userCharge.vue'
|
||||
import RecordDialog from './components/recordDialog.vue'
|
||||
import AddUserDrawer from './components/addUserDrawer.vue'
|
||||
import StoreWineManagement from './components/storeWineManagement.vue'
|
||||
|
||||
const UserChargeRef = ref(null)
|
||||
const RecordDialogRef = ref(null)
|
||||
const AddUserDrawerRef = ref(null)
|
||||
const StoreWineManagementRef = ref(null)
|
||||
|
||||
const queryForm = ref({
|
||||
key: '',
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<template>
|
||||
<el-drawer v-model="showDrawer" direction="rtl" size="300px">
|
||||
<el-drawer v-model="showDrawer" direction="rtl" size="500px">
|
||||
<template #header>
|
||||
<h4>订单打印</h4>
|
||||
</template>
|
||||
@@ -80,8 +80,13 @@
|
||||
</el-button>
|
||||
</div>
|
||||
<div class="btn">
|
||||
<el-button type="primary" style="width: 100%" :loading="printLoading" @click="printHandle('normal')">
|
||||
打印小票
|
||||
<el-button type="primary" style="width: 100%" :loading="printLoading" @click="printHandle('normal', 2)">
|
||||
打印前台票
|
||||
</el-button>
|
||||
</div>
|
||||
<div class="btn">
|
||||
<el-button type="warning" style="width: 100%" :loading="printLoading" @click="printHandle('normal', 3)">
|
||||
打印厨房票
|
||||
</el-button>
|
||||
</div>
|
||||
</div>
|
||||
@@ -111,21 +116,15 @@ const loading = ref(false);
|
||||
const printLoading = ref(false);
|
||||
|
||||
// 打印操作
|
||||
async function printHandle(type) {
|
||||
async function printHandle(type, t = null) {
|
||||
try {
|
||||
printLoading.value = true;
|
||||
switch (type) {
|
||||
case "normal":
|
||||
// 打印订单小票
|
||||
if (printStore.deviceNoteList.length) {
|
||||
printStore.pushReceiptData(commOrderPrintData(originOrderInfo.value));
|
||||
} else {
|
||||
await orderPrint({
|
||||
id: orderInfo.value.id,
|
||||
type: 0 // 0结算单 1预结算单 2退款单
|
||||
})
|
||||
ElMessage.success('云打印小票成功')
|
||||
}
|
||||
await orderPrint({
|
||||
id: orderInfo.value.id,
|
||||
type: t // 1 预结算单 2结算单 3厨房单
|
||||
})
|
||||
break;
|
||||
case "label":
|
||||
// 打印标签小票
|
||||
|
||||
@@ -56,6 +56,14 @@
|
||||
¥{{ formatDecimal(+scope.row.payAmount) }}
|
||||
</template>
|
||||
</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">
|
||||
<template v-slot="scope">
|
||||
<el-input-number v-model="scope.row.refund_number" :disabled="refundType != 2" :min="0"
|
||||
@@ -66,7 +74,7 @@
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
<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-column label="商品信息">
|
||||
<template v-slot="scope">
|
||||
@@ -118,17 +126,19 @@
|
||||
<div class="drawer_footer">
|
||||
<div class="btn">
|
||||
<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 class="btn">
|
||||
<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>
|
||||
</template>
|
||||
</el-drawer>
|
||||
<takeFoodCode ref="takeFoodCodeRef" title="退款密码" :type="2" input-type="password" placeholder="请输入退款密码"
|
||||
@success="passwordSuccess" />
|
||||
<!-- 退款退菜推库存的操作弹窗 -->
|
||||
<refundConsModal ref="refundConsModalRef" :list="returnList" @success="refundConsModalSuccess" />
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
@@ -142,9 +152,13 @@ import { usePrint } from "@/store/print.js";
|
||||
import { useUser } from '@/store/user.js'
|
||||
import dayjs from 'dayjs'
|
||||
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 goodsStore = useGoods()
|
||||
const store = useUser()
|
||||
const printStore = usePrint();
|
||||
const globalStore = useGlobal()
|
||||
@@ -168,41 +182,83 @@ const takeFoodCodeRef = ref(null)
|
||||
const cash = ref(false)
|
||||
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 = '') {
|
||||
try {
|
||||
loading.value = true
|
||||
let rows = tableRef.value.getSelectionRows()
|
||||
let refundDetails = []
|
||||
if (refundType.value != 1) {
|
||||
refundDetails = tableRef.value.getSelectionRows().map(val => {
|
||||
return {
|
||||
id: val.id,
|
||||
returnAmount: val.payAmount,
|
||||
num: val.refund_number
|
||||
}
|
||||
pwd.value = e
|
||||
loading.value = true
|
||||
rows.value = tableRef.value.getSelectionRows()
|
||||
// if (refundType.value != 1) {
|
||||
refundDetails.value = tableRef.value.getSelectionRows().map(val => {
|
||||
return {
|
||||
refundMode: val.refundMode,
|
||||
name: val.productName,
|
||||
id: val.id,
|
||||
returnAmount: val.payAmount,
|
||||
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 = {
|
||||
orderId: item.value.id,
|
||||
refundAmount: formatDecimal(+refundAmount.value),
|
||||
modify: modify.value,
|
||||
cash: cash.value,
|
||||
refundReason: remark.value,
|
||||
refundDetails: refundDetails,
|
||||
pwd: e,
|
||||
refundDetails: refundDetails.value,
|
||||
pwd: pwd.value,
|
||||
operator: store.userInfo.name || store.shopInfo.shopName,
|
||||
print: printStore.deviceNoteList.length ? false : true,
|
||||
refundStock: refundStock.value, // 是否推库存 1退菜图库存 2仅退菜不退库存
|
||||
};
|
||||
|
||||
await refundOrder(data)
|
||||
ElMessage.success('退款成功')
|
||||
await printRefund(rows)
|
||||
// await printRefund(rows.value)
|
||||
isShow.value = false
|
||||
emits('success')
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
loading.value = false
|
||||
}
|
||||
|
||||
// 显示手动退款
|
||||
@@ -260,6 +316,7 @@ async function printRefund(rows) {
|
||||
if (printStore.deviceNoteList.length) {
|
||||
// 本地打印
|
||||
const data = {
|
||||
title: '退款单',
|
||||
shop_name: store.shopInfo.shopName,
|
||||
loginAccount: store.userInfo.name,
|
||||
carts: [],
|
||||
@@ -268,6 +325,7 @@ async function printRefund(rows) {
|
||||
orderInfo: item.value,
|
||||
outNumber: item.value.id,
|
||||
createdAt: item.value.createTime,
|
||||
refundMethod: cash.value ? '线下退款' : '原路退回',
|
||||
printTime: dayjs().format("YYYY-MM-DD HH:mm:ss"),
|
||||
}
|
||||
|
||||
@@ -275,10 +333,10 @@ async function printRefund(rows) {
|
||||
data.carts.push(
|
||||
{
|
||||
name: item.productName,
|
||||
number: item.num,
|
||||
number: item.refund_number,
|
||||
skuName: item.skuName,
|
||||
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);
|
||||
} else {
|
||||
// 云打印
|
||||
await orderPrint({ id: item.value.id, type: 2 })
|
||||
ElMessage.success('云打印退款单成功')
|
||||
// await orderPrint({ id: item.value.id, type: 2 })
|
||||
// ElMessage.success('云打印退款单成功')
|
||||
}
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
@@ -337,6 +395,29 @@ function show(row) {
|
||||
|
||||
isShow.value = true
|
||||
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 = ''
|
||||
|
||||
let onGoods = []
|
||||
@@ -345,14 +426,25 @@ function show(row) {
|
||||
// 可退的最大数量,下单数量 - 已退数量 - 退菜数量
|
||||
let refundMaxNum = item.num - item.refundNum - item.returnNum
|
||||
|
||||
if (refundMaxNum <= 0) {
|
||||
item.refund_number = item.num
|
||||
// 已经退过,不在允许操作
|
||||
returnGoods.push(item)
|
||||
} else {
|
||||
// 可以操作的退款数量
|
||||
item.refund_number = item.num
|
||||
// if (refundMaxNum <= 0) {
|
||||
// item.refund_number = item.num
|
||||
// // 已经退过,不在允许操作
|
||||
// returnGoods.push(item)
|
||||
// } else {
|
||||
// // 可以操作的退款数量
|
||||
// item.refund_number = item.num
|
||||
// onGoods.push(item)
|
||||
// }
|
||||
item.refund_number = refundMaxNum
|
||||
// if (item.refundNum > 0 || item.returnNum > 0) {
|
||||
// // 已经退过,不在允许操作
|
||||
// returnGoods.push(item)
|
||||
// }
|
||||
// 可以操作的退款数量
|
||||
if (refundMaxNum > 0) {
|
||||
onGoods.push(item)
|
||||
} else {
|
||||
returnGoods.push(item)
|
||||
}
|
||||
})
|
||||
|
||||
@@ -361,6 +453,8 @@ function show(row) {
|
||||
|
||||
item.value = newRow
|
||||
|
||||
console.log('item.value===', item.value);
|
||||
|
||||
setTimeout(() => {
|
||||
tableRef.value.clearSelection()
|
||||
refundTypeChange(1)
|
||||
|
||||
@@ -168,7 +168,7 @@
|
||||
<!-- 打印操作 -->
|
||||
<PrintDrawer ref="PrintDrawerRef" />
|
||||
<!-- 结算订单 -->
|
||||
<SettleAccount ref="SettleAccountRef" @success="orderListAjax" />
|
||||
<SettleAccount ref="SettleAccountRef" type="order" @success="orderListAjax" />
|
||||
<!-- 全部商品 -->
|
||||
<allGoodsDialog ref="allGoodsDialogRef" />
|
||||
</template>
|
||||
|
||||
@@ -29,7 +29,7 @@ const statusList = {
|
||||
text: '用户未订阅'
|
||||
},
|
||||
0: {
|
||||
type: 'danger',
|
||||
type: 'error',
|
||||
text: '失败'
|
||||
},
|
||||
1: {
|
||||
|
||||
55
src/views/store_wine/components/countPage.vue
Normal file
55
src/views/store_wine/components/countPage.vue
Normal file
@@ -0,0 +1,55 @@
|
||||
<template>
|
||||
<div class="wrap">
|
||||
<el-table :data="list" stripe border v-loading="loading" height="100%">
|
||||
<el-table-column label="商品信息">
|
||||
<template v-slot="scope">
|
||||
<div class="center">
|
||||
<el-avatar :size="40" shape="square" :src="scope.row.imgUrl" style="flex-shrink: 0;">
|
||||
{{ scope.row.name.charAt(0) }}
|
||||
</el-avatar>
|
||||
<el-text>{{ scope.row.name }}</el-text>
|
||||
</div>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="有效存酒" prop="savNum"></el-table-column>
|
||||
<el-table-column label="已过期存酒" prop="savNum"></el-table-column>
|
||||
</el-table>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref, onMounted } from 'vue'
|
||||
import { shopStorageCount } from '@/api/product_new'
|
||||
|
||||
const loading = ref(false)
|
||||
const list = ref([])
|
||||
|
||||
async function shopStorageCountAjax() {
|
||||
try {
|
||||
loading.value = true
|
||||
list.value = await shopStorageCount()
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
} finally {
|
||||
setTimeout(() => {
|
||||
loading.value = false
|
||||
}, 300);
|
||||
}
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
shopStorageCountAjax()
|
||||
})
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
.wrap {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
.center {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 10px;
|
||||
}
|
||||
</style>
|
||||
416
src/views/store_wine/components/managePage.vue
Normal file
416
src/views/store_wine/components/managePage.vue
Normal file
@@ -0,0 +1,416 @@
|
||||
<!-- 存酒记录 -->
|
||||
<template>
|
||||
<div class="wrap">
|
||||
<div class="top_wrap">
|
||||
<el-form :model="queryForm" inline>
|
||||
<el-form-item label="酒名">
|
||||
<el-input v-model="queryForm.name" placeholder="请输入酒名"></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button type="primary" icon="Search" :loading="tableData.loading"
|
||||
@click="storageGoodGetAjax">搜索</el-button>
|
||||
<el-button icon="Refresh" :loading="tableData.loading" @click="reset">重置</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<el-button type="primary" @click="addFormDialogShow = true">新增酒品</el-button>
|
||||
</div>
|
||||
<div class="tab">
|
||||
<div class="tab_wrap">
|
||||
<el-table :data="tableData.list" v-loading="tableData.loading" border stripe height="100%">
|
||||
<el-table-column label="酒品名">
|
||||
<template v-slot="scope">
|
||||
<div class="center">
|
||||
<el-avatar :size="40" shape="square" :src="scope.row.imgUrl" style="flex-shrink: 0;">
|
||||
{{ scope.row.name.charAt(0) }}
|
||||
</el-avatar>
|
||||
<el-text>{{ scope.row.name }}</el-text>
|
||||
</div>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="单位" prop="unit"></el-table-column>
|
||||
<el-table-column label="有效期(天)" prop="period"></el-table-column>
|
||||
<el-table-column label="来源" prop="source" width="100">
|
||||
<template v-slot="scope">
|
||||
<el-text v-if="scope.row.source === 1">商品</el-text>
|
||||
<el-text v-if="scope.row.source === 0">手动</el-text>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="操作" width="300">
|
||||
<template #default="{ row }">
|
||||
<el-button type="primary" @click="storeHandle(row)">存酒</el-button>
|
||||
<el-button @click="editorHandle(row)">编辑</el-button>
|
||||
<el-button type="danger" @click="deleteHandle(row)">删除</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
</div>
|
||||
</div>
|
||||
<div class="pagination">
|
||||
<el-pagination background v-model:current-page="tableData.page" v-model:page-size="tableData.size"
|
||||
:page-sizes="[10, 30, 50, 100]" layout="sizes, pager, jumper, total" :total="tableData.total"
|
||||
@size-change="storageGoodGetAjax" @current-change="storageGoodGetAjax"></el-pagination>
|
||||
</div>
|
||||
<!-- 添加/编辑存酒 -->
|
||||
<el-dialog :title="addForm.id ? '编辑酒品' : '添加酒品'" width="600px" v-model="addFormDialogShow"
|
||||
@close="addFormDialogClsoe">
|
||||
<el-form ref="addFormRef" :model="addForm" :rules="addFormRules" label-width="120" label-position="right">
|
||||
<el-form-item label="类型">
|
||||
<el-radio-group v-model="addForm.source">
|
||||
<el-radio-button label="手动添加" :value="0"></el-radio-button>
|
||||
<el-radio-button label="从商品添加" :value="1"></el-radio-button>
|
||||
</el-radio-group>
|
||||
</el-form-item>
|
||||
<div v-if="addForm.source === 0">
|
||||
<el-form-item label="酒品名" prop="name">
|
||||
<el-input placeholder="请输入酒品名称" v-model="addForm.name" style="width: 80%;"></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item label="酒品图片">
|
||||
<UploadImg ref="UploadImgRef" @success="e => addForm.imgUrl = e" />
|
||||
</el-form-item>
|
||||
<el-form-item label="单位">
|
||||
<el-input placeholder="请输入单位" v-model="addForm.unit" style="width: 50%;"></el-input>
|
||||
</el-form-item>
|
||||
</div>
|
||||
<div v-else>
|
||||
<el-form-item label="选择商品">
|
||||
<el-select v-model="addForm.prodId" style="width: 80%;">
|
||||
<el-option v-for="item in goodsStore.originGoodsList" :label="item.name" :value="item.id"
|
||||
:key="item.id" @click="selectGoods(item)"></el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="商品名称">
|
||||
<el-text v-if="addForm.name">{{ addForm.name }}</el-text>
|
||||
<el-text type="info" v-else>请选择商品</el-text>
|
||||
</el-form-item>
|
||||
<el-form-item label="商品图片">
|
||||
<el-image :src="addForm.imgUrl" style="width: 140px;height: 140px;"></el-image>
|
||||
</el-form-item>
|
||||
</div>
|
||||
<el-form-item label="有效期">
|
||||
<el-input-number v-model="addForm.period" :min="1" :step="1" step-strictly></el-input-number>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<div class="dialog-footer">
|
||||
<div class="btn">
|
||||
<el-button style="width: 100%;" @click="addFormDialogShow = false">
|
||||
取消
|
||||
</el-button>
|
||||
</div>
|
||||
<div class="btn">
|
||||
<el-button style="width: 100%;" type="primary" :loading="addFormConfirmLoading"
|
||||
@click="addFormConfirm">
|
||||
确定
|
||||
</el-button>
|
||||
</div>
|
||||
</div>
|
||||
</el-dialog>
|
||||
<!-- 存酒 -->
|
||||
<el-dialog v-model="dialogVisible" :title="`${form.name} - 新增存酒`" width="400px" :close-on-click-modal="false"
|
||||
destroy-on-close @close="storeInClose">
|
||||
<el-form ref="formRef" :model="form" :rules="rules" label-width="100px" label-position="left">
|
||||
<el-form-item label="选择用户" prop="userId">
|
||||
<el-select v-model="form.userId" placeholder="请选择用户(可搜索)" clearable filterable remote
|
||||
remote-show-suffix :remote-method="remoteMethod" :loading="userListLoading"
|
||||
@clear="getUserList">
|
||||
<el-option :label="`${item.nickName}/${item.phone}`" :value="item.userId"
|
||||
v-for="item in userList" :key="item.id"></el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<!-- <el-form-item label="选择酒品">
|
||||
<el-select v-model="form.shopStorageGoodId" placeholder="请选择存酒商品">
|
||||
<el-option v-for="item in storageGoodList" :key="item.id" :label="item.name" :value="item.id">
|
||||
</el-option>
|
||||
</el-select>
|
||||
</el-form-item> -->
|
||||
<el-form-item label="存酒数量">
|
||||
<el-input-number v-model="form.num" :min="1" :step="1" step-strictly></el-input-number>
|
||||
</el-form-item>
|
||||
<el-form-item label="存酒有效期">
|
||||
<el-input-number v-model="form.expDay" :min="1" :step="1" step-strictly></el-input-number>
|
||||
<span style="margin-left: 8px;">天</span>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<div class="dialog-footer">
|
||||
<div class="btn">
|
||||
<el-button style="width: 100%;" @click="dialogVisible = false">取 消</el-button>
|
||||
</div>
|
||||
<div class="btn">
|
||||
<el-button style="width: 100%;" type="primary" :loading="confirmLoading" @click="confirmHandle">确
|
||||
定</el-button>
|
||||
</div>
|
||||
</div>
|
||||
</el-dialog>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import _ from 'lodash'
|
||||
import { ref, onMounted, nextTick } from 'vue'
|
||||
import { ElMessage, ElMessageBox } from 'element-plus'
|
||||
import { shopStoragePost, storageGoodGet, storageGoodPost, storageGoodPut, storageGoodDelete } from '@/api/product_new'
|
||||
import { shopUserList } from '@/api/account.js'
|
||||
import UploadImg from '@/components/uploadImg.vue'
|
||||
import { useGoods } from '@/store/goods.js'
|
||||
|
||||
const goodsStore = useGoods()
|
||||
|
||||
const UploadImgRef = ref(null)
|
||||
|
||||
const queryForm = ref({
|
||||
name: ''
|
||||
})
|
||||
|
||||
const tableData = ref({
|
||||
loading: false,
|
||||
page: 1,
|
||||
size: 10,
|
||||
total: 0,
|
||||
list: []
|
||||
});
|
||||
|
||||
function isExpired(expTime) {
|
||||
if (!expTime) return false;
|
||||
const now = new Date();
|
||||
const expDate = new Date(expTime);
|
||||
return expDate < now;
|
||||
}
|
||||
|
||||
function reset() {
|
||||
queryForm.value.name = ''
|
||||
tableData.page = 1
|
||||
storageGoodGetAjax()
|
||||
}
|
||||
|
||||
const userList = ref([])
|
||||
// 获取用户列表
|
||||
const userListLoading = ref(false)
|
||||
|
||||
function remoteMethod(query) {
|
||||
if (query) {
|
||||
getUserList(query)
|
||||
}
|
||||
}
|
||||
|
||||
// 获取用户列表
|
||||
async function getUserList(name = '') {
|
||||
try {
|
||||
userListLoading.value = true
|
||||
const res = await shopUserList({ page: 1, key: name, size: 20 })
|
||||
userList.value = res.records
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
} finally {
|
||||
setTimeout(() => {
|
||||
userListLoading.value = false
|
||||
}, 100);
|
||||
}
|
||||
}
|
||||
|
||||
// 获取存酒商品列表
|
||||
const storageGoodList = ref([]);
|
||||
async function storageGoodGetAjax() {
|
||||
try {
|
||||
tableData.value.loading = true
|
||||
const res = await storageGoodGet({
|
||||
name: queryForm.value.name,
|
||||
page: tableData.value.page,
|
||||
size: tableData.value.size,
|
||||
});
|
||||
tableData.value.list = res.records || [];
|
||||
tableData.value.total = +res.totalRow || 0
|
||||
} catch (error) {
|
||||
console.error('获取存酒商品列表失败:', error);
|
||||
} finally {
|
||||
setTimeout(() => {
|
||||
tableData.value.loading = false
|
||||
}, 300);
|
||||
}
|
||||
}
|
||||
|
||||
const dialogVisible = ref(false);
|
||||
const formObj = {
|
||||
name: '',
|
||||
userId: '',
|
||||
shopStorageGoodId: '', // 存酒商品ID
|
||||
num: 1, // 存酒数量
|
||||
expDay: 1, // 存酒有效期,单位天默认1天
|
||||
}
|
||||
const formRef = ref(null)
|
||||
const form = ref(formObj)
|
||||
const rules = {
|
||||
userId: [{ required: true, message: '请选择用户', trigger: 'change' }],
|
||||
shopStorageGoodId: [{ required: true, message: '请选择存酒商品', trigger: 'change' }],
|
||||
num: [{ required: true, message: '请输入存酒数量', trigger: 'change' }],
|
||||
expDay: [{ required: true, message: '请输入存酒有效期', trigger: 'change' }],
|
||||
}
|
||||
|
||||
function storeInClose() {
|
||||
formRef.value.resetFields()
|
||||
form.value = _.cloneDeep(formObj)
|
||||
}
|
||||
|
||||
// 确认存酒
|
||||
const confirmLoading = ref(false);
|
||||
function confirmHandle() {
|
||||
formRef.value.validate(async vaild => {
|
||||
try {
|
||||
if (vaild) {
|
||||
confirmLoading.value = true;
|
||||
await shopStoragePost(form.value);
|
||||
ElMessage.success('存酒成功');
|
||||
dialogVisible.value = false;
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('存酒失败:', error);
|
||||
} finally {
|
||||
confirmLoading.value = false;
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
// 添加酒品
|
||||
const addFormDialogShow = ref(false)
|
||||
const addFormRef = ref(null)
|
||||
const addFormObj = {
|
||||
id: '',
|
||||
name: '', // 酒品名称
|
||||
imgUrl: '', // 商品图片
|
||||
unit: '瓶', // 单位
|
||||
period: 365, // 过期时间
|
||||
prodId: '', // 商品id
|
||||
source: 0, // 0手动 1商品
|
||||
}
|
||||
const addForm = ref(_.cloneDeep(addFormObj))
|
||||
|
||||
const addFormRules = ref({
|
||||
name: [
|
||||
{
|
||||
required: true,
|
||||
message: '请输入酒品名称',
|
||||
trigger: 'blur'
|
||||
}
|
||||
]
|
||||
})
|
||||
|
||||
// 显示存酒
|
||||
async function storeHandle(row) {
|
||||
form.value.name = row.name
|
||||
form.value.shopStorageGoodId = row.id
|
||||
await nextTick()
|
||||
dialogVisible.value = true
|
||||
}
|
||||
|
||||
// 编辑
|
||||
async function editorHandle(row) {
|
||||
addForm.value = _.cloneDeep(row)
|
||||
addFormDialogShow.value = true
|
||||
if (row.source == 0) {
|
||||
await nextTick()
|
||||
UploadImgRef.value.init([{ url: row.imgUrl }])
|
||||
}
|
||||
}
|
||||
|
||||
// 删除
|
||||
function deleteHandle(row) {
|
||||
ElMessageBox.confirm(`确认要删除酒品「${row.name}」吗?`).then(async () => {
|
||||
try {
|
||||
tableData.value.loading = true
|
||||
await storageGoodDelete(row.id)
|
||||
reset()
|
||||
} catch (error) {
|
||||
tableData.value.loading = false
|
||||
}
|
||||
}).catch(() => { })
|
||||
}
|
||||
|
||||
// 选择商品
|
||||
function selectGoods(item) {
|
||||
addForm.value.name = item.name
|
||||
addForm.value.imgUrl = item.coverImg
|
||||
}
|
||||
|
||||
function addFormDialogClsoe() {
|
||||
addFormRef.value.resetFields()
|
||||
addForm.value = _.cloneDeep(addFormObj)
|
||||
if (form.value.source == 0) {
|
||||
UploadImgRef.value.init([])
|
||||
}
|
||||
}
|
||||
|
||||
const addFormConfirmLoading = ref(false)
|
||||
function addFormConfirm() {
|
||||
addFormRef.value.validate(async vaild => {
|
||||
try {
|
||||
if (vaild) {
|
||||
addFormConfirmLoading.value = true
|
||||
if (addForm.value.id) {
|
||||
await storageGoodPut(addForm.value)
|
||||
} else {
|
||||
await storageGoodPost(addForm.value)
|
||||
}
|
||||
ElMessage.success(addForm.value.id ? '编辑成功' : '添加成功')
|
||||
addFormDialogShow.value = false
|
||||
reset()
|
||||
}
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
} finally {
|
||||
setTimeout(() => {
|
||||
addFormConfirmLoading.value = false
|
||||
}, 300);
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
storageGoodGetAjax()
|
||||
getUserList()
|
||||
})
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
.wrap {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.tab {
|
||||
flex: 1;
|
||||
position: relative;
|
||||
|
||||
.tab_wrap {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
}
|
||||
}
|
||||
|
||||
.center {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 10px;
|
||||
}
|
||||
|
||||
.top_wrap {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
}
|
||||
|
||||
.pagination {
|
||||
padding-top: var(--el-font-size-base);
|
||||
}
|
||||
|
||||
.dialog-footer {
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
gap: var(--el-font-size-base);
|
||||
|
||||
.btn {
|
||||
flex: 1;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
393
src/views/store_wine/components/record.vue
Normal file
393
src/views/store_wine/components/record.vue
Normal file
@@ -0,0 +1,393 @@
|
||||
<!-- 存酒记录 -->
|
||||
<template>
|
||||
<div class="wrap">
|
||||
<div class="top_wrap">
|
||||
<el-form :model="queryForm" inline>
|
||||
<el-form-item label="酒名/用户昵称">
|
||||
<el-input v-model="queryForm.key" placeholder="请输入酒名/用户昵称"></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item label="状态">
|
||||
<el-select v-model="queryForm.status" placeholder="请选择状态" clearable style="width: 150px;">
|
||||
<el-option label="全部" value="" />
|
||||
<el-option label="已取完" value="0" />
|
||||
<el-option label="储存中" value="1" />
|
||||
<el-option label="已过期" value="2" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button type="primary" icon="Search" :loading="tableData.loading"
|
||||
@click="shopStorageGetAjax">搜索</el-button>
|
||||
<el-button icon="Refresh" :loading="tableData.loading" @click="reset">重置</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<el-button type="primary" @click="dialogVisible = true">新增存酒</el-button>
|
||||
</div>
|
||||
<div class="tab">
|
||||
<div class="tab_wrap">
|
||||
<el-table :data="tableData.list" v-loading="tableData.loading" border stripe height="100%">
|
||||
<el-table-column label="用户">
|
||||
<template v-slot="scope">
|
||||
<div class="center">
|
||||
<el-avatar :size="40" :src="scope.row.headImg" style="flex-shrink: 0;">
|
||||
{{ scope.row.nickName.charAt(0) }}
|
||||
</el-avatar>
|
||||
<el-text>{{ scope.row.nickName }}</el-text>
|
||||
</div>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="酒品名">
|
||||
<template v-slot="scope">
|
||||
<div class="center">
|
||||
<el-avatar :size="40" shape="square" :src="scope.row.imgUrl" style="flex-shrink: 0;">
|
||||
{{ scope.row.name.charAt(0) }}
|
||||
</el-avatar>
|
||||
<el-text>{{ scope.row.name }}</el-text>
|
||||
</div>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="数量" prop="num" width="80">
|
||||
<template v-slot="scope">
|
||||
<el-text>{{ scope.row.num }}{{ scope.row.unit }}</el-text>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="存酒时间" prop="savTime"></el-table-column>
|
||||
<el-table-column label="到期时间" prop="expTime"></el-table-column>
|
||||
<el-table-column label="状态" prop="status" width="100">
|
||||
<template v-slot="scope">
|
||||
<el-tag disable-transitions type="info"
|
||||
v-if="isExpired(scope.row.expTime) || scope.row.status == 2">已过期</el-tag>
|
||||
<el-tag disable-transitions type="info" v-else-if="scope.row.num <= 0">已取完</el-tag>
|
||||
<el-tag disable-transitions type="primary" v-else>未取完</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="操作" width="240">
|
||||
<template #default="{ row }">
|
||||
<el-button type="primary" @click="viewRecord(row)">查看记录</el-button>
|
||||
<el-button type="danger" :disabled="isExpired(row.expTime) || row.num <= 0"
|
||||
@click="takeWineDialogVisible = true; maxTakeNum = row.num; takeWineForm.id = row.id;">
|
||||
<span v-if="isExpired(row.expTime) || row.status == 2">已过期</span>
|
||||
<span v-else-if="row.num <= 0">已取完</span>
|
||||
<span v-else>待取酒</span>
|
||||
</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
</div>
|
||||
</div>
|
||||
<div class="pagination">
|
||||
<el-pagination background v-model:current-page="tableData.page" v-model:page-size="tableData.size"
|
||||
:page-sizes="[10, 30, 50, 100]" layout="sizes, pager, jumper, total" :total="tableData.total"
|
||||
@size-change="shopStorageGetAjax" @current-change="shopStorageGetAjax"></el-pagination>
|
||||
</div>
|
||||
<!-- 存酒 -->
|
||||
<el-dialog v-model="dialogVisible" title="新增存酒" width="400px" :close-on-click-modal="false" destroy-on-close
|
||||
@open="storeInOpen">
|
||||
<el-form ref="formRef" :model="form" :rules="rules" label-width="100px" label-position="left">
|
||||
<el-form-item label="选择用户" prop="userId">
|
||||
<el-select v-model="form.userId" placeholder="请选择用户(可搜索)" clearable filterable remote
|
||||
remote-show-suffix :remote-method="remoteMethod" :loading="userListLoading"
|
||||
@clear="getUserList">
|
||||
<el-option :label="`${item.nickName}/${item.phone}`" :value="item.userId"
|
||||
v-for="item in userList" :key="item.id"></el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="选择酒品" prop="shopStorageGoodId">
|
||||
<el-select v-model="form.shopStorageGoodId" placeholder="请选择存酒商品">
|
||||
<el-option v-for="item in storageGoodList" :key="item.id" :label="item.name" :value="item.id">
|
||||
</el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="存酒数量">
|
||||
<el-input-number v-model="form.num" :min="1" :step="1" step-strictly></el-input-number>
|
||||
</el-form-item>
|
||||
<el-form-item label="存酒有效期">
|
||||
<el-input-number v-model="form.expDay" :min="1" :step="1" step-strictly></el-input-number>
|
||||
<span style="margin-left: 8px;">天</span>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<div class="dialog-footer">
|
||||
<div class="btn">
|
||||
<el-button style="width: 100%;" @click="dialogVisible = false">取 消</el-button>
|
||||
</div>
|
||||
<div class="btn">
|
||||
<el-button style="width: 100%;" type="primary" :loading="confirmLoading" @click="confirmHandle">确
|
||||
定</el-button>
|
||||
</div>
|
||||
</div>
|
||||
</el-dialog>
|
||||
<!-- 存取酒记录弹窗 -->
|
||||
<el-dialog title="记录" width="600px" v-model="showRecordDialogVisible">
|
||||
<el-table :data="recordList" border stripe>
|
||||
<el-table-column label="记录" prop="content"></el-table-column>
|
||||
<el-table-column label="操作时间" prop="time"></el-table-column>
|
||||
</el-table>
|
||||
</el-dialog>
|
||||
<!-- 取酒对话框,只选择数量即可,不可超过存酒的数量 -->
|
||||
<el-dialog v-model="takeWineDialogVisible" title="取酒" width="350px" :close-on-click-modal="false"
|
||||
destroy-on-close>
|
||||
<el-form :model="takeWineForm" :rules="takeWineRules" label-width="100px" label-position="left">
|
||||
<el-form-item label="取酒数量">
|
||||
<el-input-number v-model="takeWineForm.num" :min="1" :step="1" step-strictly
|
||||
:max="maxTakeNum"></el-input-number>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<div class="dialog-footer">
|
||||
<div class="btn">
|
||||
<el-button style="width: 100%;" @click="takeWineDialogVisible = false">取 消</el-button>
|
||||
</div>
|
||||
<div class="btn">
|
||||
<el-button style="width: 100%;" type="primary" :loading="takeWineConfirmLoading"
|
||||
@click="confirmTakeWineHandle">确 定</el-button>
|
||||
</div>
|
||||
</div>
|
||||
</el-dialog>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref, onMounted } from 'vue'
|
||||
import { ElMessage } from 'element-plus'
|
||||
import { shopStoragePost, storageGoodGet, shopStorageGet, shopStoragePut, shopStorageRecord } from '@/api/product_new'
|
||||
import { shopUserList } from '@/api/account.js'
|
||||
|
||||
const queryForm = ref({
|
||||
key: '',
|
||||
status: ''
|
||||
})
|
||||
|
||||
const tableData = ref({
|
||||
loading: false,
|
||||
page: 1,
|
||||
size: 10,
|
||||
total: 0,
|
||||
list: []
|
||||
});
|
||||
|
||||
function isExpired(expTime) {
|
||||
if (!expTime) return false;
|
||||
const now = new Date();
|
||||
const expDate = new Date(expTime);
|
||||
return expDate < now;
|
||||
}
|
||||
|
||||
function reset() {
|
||||
queryForm.value.name = ''
|
||||
queryForm.value.status = ''
|
||||
tableData.page = 1
|
||||
shopStorageGetAjax()
|
||||
}
|
||||
|
||||
// 获取存酒记录
|
||||
async function shopStorageGetAjax() {
|
||||
try {
|
||||
tableData.value.loading = true
|
||||
const res = await shopStorageGet({
|
||||
key: queryForm.value.key,
|
||||
phone: '',
|
||||
status: queryForm.value.status,
|
||||
page: tableData.value.page,
|
||||
size: tableData.value.size,
|
||||
});
|
||||
tableData.value.list = res.records || [];
|
||||
tableData.value.total = +res.totalRow || 0
|
||||
} catch (error) {
|
||||
console.error('获取存酒列表失败:', error);
|
||||
} finally {
|
||||
setTimeout(() => {
|
||||
tableData.value.loading = false
|
||||
}, 300);
|
||||
}
|
||||
}
|
||||
|
||||
function storeInOpen() {
|
||||
init()
|
||||
getUserList()
|
||||
storageGoodGetAjax()
|
||||
}
|
||||
|
||||
|
||||
function init() {
|
||||
form.value = {
|
||||
userId: '',
|
||||
shopStorageGoodId: '',
|
||||
num: 1,
|
||||
expDay: 1,
|
||||
};
|
||||
}
|
||||
|
||||
const userList = ref([])
|
||||
// 获取用户列表
|
||||
const userListLoading = ref(false)
|
||||
|
||||
function remoteMethod(query) {
|
||||
if (query) {
|
||||
getUserList(query)
|
||||
}
|
||||
}
|
||||
|
||||
async function getUserList(name = '') {
|
||||
try {
|
||||
userListLoading.value = true
|
||||
const res = await shopUserList({ page: 1, key: name, size: 20 })
|
||||
userList.value = res.records
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
} finally {
|
||||
setTimeout(() => {
|
||||
userListLoading.value = false
|
||||
}, 100);
|
||||
}
|
||||
}
|
||||
|
||||
// 获取存酒商品列表
|
||||
const storageGoodList = ref([]);
|
||||
async function storageGoodGetAjax() {
|
||||
try {
|
||||
const res = await storageGoodGet({
|
||||
page: 1,
|
||||
size: 999,
|
||||
});
|
||||
storageGoodList.value = res.records || [];
|
||||
} catch (error) {
|
||||
console.error('获取存酒商品列表失败:', error);
|
||||
}
|
||||
}
|
||||
|
||||
const dialogVisible = ref(false);
|
||||
const formRef = ref(null)
|
||||
const form = ref({
|
||||
userId: '',
|
||||
shopStorageGoodId: '', // 存酒商品ID
|
||||
num: 1, // 存酒数量
|
||||
expDay: 1, // 存酒有效期,单位天默认1天
|
||||
})
|
||||
|
||||
const rules = {
|
||||
userId: [{ required: true, message: '请选择用户', trigger: 'change' }],
|
||||
shopStorageGoodId: [{ required: true, message: '请选择存酒商品', trigger: 'change' }],
|
||||
num: [{ required: true, message: '请输入存酒数量', trigger: 'change' }],
|
||||
expDay: [{ required: true, message: '请输入存酒有效期', trigger: 'change' }],
|
||||
}
|
||||
|
||||
// 确认存酒
|
||||
const confirmLoading = ref(false);
|
||||
function confirmHandle() {
|
||||
formRef.value.validate(async vaild => {
|
||||
try {
|
||||
if (vaild) {
|
||||
confirmLoading.value = true;
|
||||
await shopStoragePost(form.value);
|
||||
ElMessage.success('存酒成功');
|
||||
dialogVisible.value = false;
|
||||
shopStorageGetAjax(); // 刷新存酒商品列表
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('存酒失败:', error);
|
||||
} finally {
|
||||
confirmLoading.value = false;
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
// 查看记录
|
||||
const showRecordDialogVisible = ref(false);
|
||||
const recordList = ref([]);
|
||||
async function viewRecord(row) {
|
||||
try {
|
||||
showRecordDialogVisible.value = true;
|
||||
const res = await shopStorageRecord({
|
||||
id: row.id,
|
||||
page: 1,
|
||||
size: 999,
|
||||
});
|
||||
recordList.value = res || [];
|
||||
} catch (error) {
|
||||
console.error('获取存取酒记录失败:', error);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
const takeWineDialogVisible = ref(false);
|
||||
const takeWineForm = ref({
|
||||
id: '', // 存酒记录ID
|
||||
num: 1,
|
||||
})
|
||||
const takeWineRules = {
|
||||
num: [{ required: true, message: '请输入取酒数量', trigger: 'change' }],
|
||||
}
|
||||
const maxTakeNum = ref(1);
|
||||
const takeWineConfirmLoading = ref(false);
|
||||
|
||||
function confirmTakeWineHandle() {
|
||||
shopStoragePutAjax();
|
||||
}
|
||||
|
||||
// 存酒取酒 num 必需 正数为存酒反之为取酒
|
||||
async function shopStoragePutAjax() {
|
||||
try {
|
||||
takeWineConfirmLoading.value = true;
|
||||
await shopStoragePut({
|
||||
id: takeWineForm.value.id,
|
||||
num: -takeWineForm.value.num, // 取酒数量为负数
|
||||
});
|
||||
ElMessage.success('取酒成功');
|
||||
takeWineDialogVisible.value = false;
|
||||
shopStorageGetAjax(); // 刷新存酒记录列表
|
||||
} catch (error) {
|
||||
console.error('取酒失败:', error);
|
||||
} finally {
|
||||
takeWineConfirmLoading.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
shopStorageGetAjax()
|
||||
})
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
.wrap {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.tab {
|
||||
flex: 1;
|
||||
position: relative;
|
||||
|
||||
.tab_wrap {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
}
|
||||
}
|
||||
|
||||
.center {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 10px;
|
||||
}
|
||||
|
||||
.top_wrap {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
}
|
||||
|
||||
.pagination {
|
||||
padding-top: var(--el-font-size-base);
|
||||
}
|
||||
|
||||
.dialog-footer {
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
gap: var(--el-font-size-base);
|
||||
|
||||
.btn {
|
||||
flex: 1;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
104
src/views/store_wine/index.vue
Normal file
104
src/views/store_wine/index.vue
Normal file
@@ -0,0 +1,104 @@
|
||||
<template>
|
||||
<div class="container">
|
||||
<div class="drawer_wrap">
|
||||
<div class="header">
|
||||
<div class="left">
|
||||
<div class="return" @click="router.back()">
|
||||
<el-icon size="26" color="#555">
|
||||
<Back />
|
||||
</el-icon>
|
||||
</div>
|
||||
<div class="menu_wrap">
|
||||
<el-radio-group v-model="pageType">
|
||||
<el-radio-button label="存酒记录" :value="1"></el-radio-button>
|
||||
<el-radio-button label="可存酒管理" :value="2"></el-radio-button>
|
||||
<el-radio-button label="存酒统计" :value="3"></el-radio-button>
|
||||
</el-radio-group>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="pay_wrap">
|
||||
<!-- 存酒记录 -->
|
||||
<record name="record" key="record" v-if="pageType == 1" />
|
||||
<!-- 存酒管理 -->
|
||||
<managePage name="managePage" key="managePage" v-if="pageType == 2" />
|
||||
<!-- 存酒统计 -->
|
||||
<countPage name="countPage" key="countPage" v-if="pageType == 3" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref, onMounted } from "vue";
|
||||
import { useRouter } from 'vue-router'
|
||||
import record from "./components/record.vue";
|
||||
import countPage from "./components/countPage.vue";
|
||||
import managePage from "./components/managePage.vue";
|
||||
|
||||
const router = useRouter()
|
||||
|
||||
const pageType = ref(1)
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
.container {
|
||||
width: 100vw;
|
||||
height: 100vh;
|
||||
padding: var(--el-font-size-base);
|
||||
background-color: #efefef;
|
||||
}
|
||||
|
||||
.drawer_wrap {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: var(--el-font-size-base);
|
||||
|
||||
.header {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
padding: 0 var(--el-font-size-base);
|
||||
background-color: #fff;
|
||||
padding: var(--el-font-size-base);
|
||||
border-radius: var(--el-font-size-base);
|
||||
|
||||
.left {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: var(--el-font-size-base);
|
||||
|
||||
.return {
|
||||
cursor: pointer;
|
||||
border-radius: 4px;
|
||||
transition: background-color 0.3s;
|
||||
padding: 10px 8px 4px;
|
||||
|
||||
&:hover {
|
||||
background-color: rgba(0, 0, 0, 0.1);
|
||||
}
|
||||
}
|
||||
|
||||
.user_info {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: var(--el-font-size-base);
|
||||
}
|
||||
|
||||
.menu_wrap {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.pay_wrap {
|
||||
flex: 1;
|
||||
background: #fff;
|
||||
border-radius: var(--el-font-size-base);
|
||||
padding: var(--el-font-size-base);
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -1,7 +1,7 @@
|
||||
<!-- 空闲台桌 -->
|
||||
<template>
|
||||
<div class="table_wrap">
|
||||
<div class="header">
|
||||
<!-- <div class="header">
|
||||
<span class="t">{{ props.tableInfo.name }}</span>
|
||||
<div class="close" @click="close">
|
||||
<el-icon class="icon">
|
||||
@@ -14,14 +14,29 @@
|
||||
<Clock />
|
||||
</el-icon>
|
||||
<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_list">
|
||||
<div class="item" v-for="item in cartList" :key="item.id">
|
||||
<div class="top">
|
||||
<span class="name">{{ item.productName }}</span>
|
||||
<span class="n">x{{ item.num }}</span>
|
||||
<span class="p">¥{{ item.price }}</span>
|
||||
<span class="name">
|
||||
<span v-if="item.isTemporary" style="color: #999;">[临时菜]</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 class="tag_wrap" v-if="item.skuName">
|
||||
<div class="tag" v-for="item in item.skuName.split(',')">
|
||||
@@ -56,6 +71,9 @@
|
||||
<div class="btn_wrap" v-if="props.tableInfo.status == 'settled'">
|
||||
<el-button type="primary" style="width: 100%;" @click="clearTableStatus">清理完成</el-button>
|
||||
</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>
|
||||
<transition name="el-fade-in">
|
||||
<div class="people_num_wrap" v-show="showPeopleNum">
|
||||
@@ -77,7 +95,7 @@
|
||||
</transition>
|
||||
</div>
|
||||
<!-- 结算订单 -->
|
||||
<SettleAccount ref="SettleAccountRef" @success="emits('success')" />
|
||||
<SettleAccount ref="SettleAccountRef" type="table" @success="emits('success')" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@@ -182,9 +200,8 @@ async function getOrderDetail() {
|
||||
|
||||
let total = 0
|
||||
res.cartList.forEach(item => {
|
||||
total += item.payAmount * item.num
|
||||
total += +item.payAmount - (item.returnNum * item.price)
|
||||
})
|
||||
|
||||
orderInfo.value.orderAmount = formatDecimal(total)
|
||||
}
|
||||
} catch (error) {
|
||||
@@ -257,7 +274,8 @@ onMounted(() => {
|
||||
|
||||
<style scoped lang="scss">
|
||||
.table_wrap {
|
||||
padding: 20px;
|
||||
// padding: 20px;
|
||||
padding-top: 14px;
|
||||
|
||||
.header {
|
||||
display: flex;
|
||||
@@ -299,14 +317,14 @@ onMounted(() => {
|
||||
}
|
||||
|
||||
.cart {
|
||||
height: calc(100vh - 160px);
|
||||
height: calc(100vh - 75px);
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
|
||||
.cart_list {
|
||||
flex: 1;
|
||||
border-radius: 6px;
|
||||
background-color: #efefef;
|
||||
background-color: #fff;
|
||||
padding: 0 var(--el-font-size-base);
|
||||
overflow-y: auto;
|
||||
|
||||
|
||||
@@ -5,42 +5,57 @@
|
||||
<div class="menus">
|
||||
<div class="item" :class="{ active: tabActive == index }" v-for="(item, index) in tabAreas"
|
||||
: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>
|
||||
</div>
|
||||
</div>
|
||||
<!-- <div class="all">
|
||||
<el-button type="link" icon="Clock">预定管理</el-button>
|
||||
</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 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 class="tab_head" ref="tabHeadRef">
|
||||
<div class="item" :class="{ active: tabItemActive == -1 }" @click="tabItemChange('', -1)">全部</div>
|
||||
<div class="item" :class="{ active: index == tabItemActive }" v-for="(item, index) in areaList"
|
||||
:key="item.id" @click="tabItemChange(item, index)">
|
||||
{{ item.name }}
|
||||
</div>
|
||||
</div>
|
||||
<div class="overflow_y" v-loading="loading">
|
||||
<div class="tab_list">
|
||||
<div class="item" :class="{ active: tableItemActive == index }"
|
||||
<div class="item"
|
||||
: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>
|
||||
<span>{{ item.areaName }} | {{ item.name }}</span>
|
||||
<span>{{ item.personNum || 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>
|
||||
<div class="using"
|
||||
v-if="item.status == 'unsettled' || item.status == 'unsettled' || item.status == 'paying' || item.status == 'settled' || item.status == 'unpaid'">
|
||||
<div class="t1">¥{{ formatDecimal(+item.orderAmount) }}</div>
|
||||
<div class="t2">
|
||||
<el-icon color="#333">
|
||||
<Timer />
|
||||
</el-icon>
|
||||
<span>{{ countTime(item.updatedAt) }}</span>
|
||||
</div> -->
|
||||
<span :key="refreshKey">{{ countTime(item.orderCreateTime) }}</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="icon_wrap" v-else>
|
||||
<el-icon class="icon">
|
||||
<CircleClose />
|
||||
</el-icon>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -49,19 +64,22 @@
|
||||
<el-empty description="空空如也~" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="pagination">
|
||||
<!-- <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>
|
||||
<div class="right_card card">
|
||||
<!-- 台桌统计 -->
|
||||
<el-drawer v-model="drawerVisible"
|
||||
: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" />
|
||||
<!-- 台桌信息 -->
|
||||
<tableInfo v-else :tableInfo="slectTable" @close="slectTableClose" @success="paySuccess" />
|
||||
</div>
|
||||
</div> -->
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@@ -69,9 +87,16 @@
|
||||
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 { ref, onMounted, onUnmounted, nextTick } from 'vue'
|
||||
import { dayjs } from 'element-plus'
|
||||
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 tabAreas = ref([
|
||||
@@ -82,18 +107,22 @@ const tabAreas = ref([
|
||||
{
|
||||
label: '空闲',
|
||||
type: 'idle',
|
||||
color: "#187CAA",
|
||||
},
|
||||
{
|
||||
label: '使用中',
|
||||
type: 'unsettled'
|
||||
type: 'unsettled',
|
||||
color: "#DD3F41",
|
||||
},
|
||||
{
|
||||
label: '待清理',
|
||||
type: 'settled',
|
||||
color: "#FF9500",
|
||||
},
|
||||
{
|
||||
label: '已预订',
|
||||
type: 'subscribe',
|
||||
color: "#58B22C",
|
||||
}
|
||||
])
|
||||
|
||||
@@ -110,7 +139,7 @@ const tableList = ref([])
|
||||
// 所选区域
|
||||
const area = ref('')
|
||||
// 选择台桌索引
|
||||
const tableItemActive = ref(-1)
|
||||
const tableItemActive = ref(0)
|
||||
// 选择台桌信息
|
||||
const slectTable = ref('')
|
||||
|
||||
@@ -120,33 +149,89 @@ function tabChange(item, index) {
|
||||
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) {
|
||||
let ctime = dayjs().valueOf()
|
||||
return dayjs(ctime - t).format('H小时m分')
|
||||
if (!t) return '0小时1分'
|
||||
|
||||
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() {
|
||||
drawerVisible.value = false
|
||||
await shopTableAjax()
|
||||
slectTableHandle(tableItemActive.value, tableList.value[tableItemActive.value])
|
||||
// slectTableHandle(tableItemActive.value, tableList.value[tableItemActive.value])
|
||||
}
|
||||
|
||||
// 选择台桌
|
||||
const drawerVisible = ref(false)
|
||||
function slectTableHandle(index, item) {
|
||||
if (tableItemActive.value == index) {
|
||||
tableItemActive.value = -1
|
||||
slectTable.value = ''
|
||||
} else {
|
||||
tableItemActive.value = index
|
||||
slectTable.value = item
|
||||
}
|
||||
tableItemActive.value = index
|
||||
drawerVisible.value = true
|
||||
// if (tableItemActive.value == index) {
|
||||
// tableItemActive.value = -1
|
||||
// slectTable.value = ''
|
||||
// } else {
|
||||
// tableItemActive.value = index
|
||||
// slectTable.value = item
|
||||
// }
|
||||
}
|
||||
|
||||
// 关闭台桌
|
||||
function slectTableClose() {
|
||||
tableItemActive.value = -1
|
||||
slectTable.value = ''
|
||||
drawerVisible.value = false
|
||||
}
|
||||
|
||||
// 获取台桌区域
|
||||
@@ -163,12 +248,21 @@ async function shopAreaAjax() {
|
||||
}
|
||||
|
||||
// 获取台桌列表
|
||||
async function shopTableAjax() {
|
||||
async function shopTableAjax(isLoading = true) {
|
||||
try {
|
||||
loading.value = true
|
||||
orderInfo.value = {
|
||||
num: 0,
|
||||
personNum: 0,
|
||||
amount: 0
|
||||
}
|
||||
if (isLoading) {
|
||||
loading.value = true
|
||||
}
|
||||
const res = await shopTable({
|
||||
page: query.value.page,
|
||||
size: query.value.size,
|
||||
// page: query.value.page,
|
||||
// size: query.value.size,
|
||||
page: 1,
|
||||
size: 999,
|
||||
areaId: area.value,
|
||||
tableCode: '',
|
||||
name: '',
|
||||
@@ -176,19 +270,60 @@ async function shopTableAjax() {
|
||||
})
|
||||
tableList.value = res.records
|
||||
query.value.total = +res.totalRow
|
||||
setTimeout(() => {
|
||||
loading.value = false
|
||||
}, 500)
|
||||
|
||||
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(() => {
|
||||
loading.value = false
|
||||
}, 500)
|
||||
}
|
||||
} catch (error) {
|
||||
loading.value = false
|
||||
if (isLoading) {
|
||||
loading.value = false
|
||||
}
|
||||
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(() => {
|
||||
shopAreaAjax()
|
||||
shopTableAjax()
|
||||
syncMinuteRefresh()
|
||||
})
|
||||
|
||||
// 销毁清理
|
||||
onUnmounted(() => {
|
||||
clearInterval(timeTimer)
|
||||
})
|
||||
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
@@ -219,7 +354,7 @@ onMounted(() => {
|
||||
padding: 0 10px;
|
||||
|
||||
.item {
|
||||
padding: 0 10px;
|
||||
padding: 0 20px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
position: relative;
|
||||
@@ -228,6 +363,13 @@ onMounted(() => {
|
||||
font-size: var(--el-font-size-base);
|
||||
}
|
||||
|
||||
.dot {
|
||||
width: 8px;
|
||||
height: 8px;
|
||||
border-radius: 50%;
|
||||
margin-right: 6px;
|
||||
}
|
||||
|
||||
&.active {
|
||||
|
||||
&::after {
|
||||
@@ -252,35 +394,82 @@ onMounted(() => {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.order_info {
|
||||
display: flex;
|
||||
padding-right: 14px;
|
||||
|
||||
.title {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 4px;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.tab_container {
|
||||
padding: var(--el-font-size-base);
|
||||
|
||||
.tab_head {
|
||||
width: calc(100vw - 125px);
|
||||
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 {
|
||||
height: calc(100vh - 220px);
|
||||
// height: calc(100vh - 220px);
|
||||
height: calc(100vh - 162px);
|
||||
overflow-y: auto;
|
||||
}
|
||||
|
||||
.tab_list {
|
||||
display: grid;
|
||||
grid-template-columns: 1fr 1fr 1fr 1fr;
|
||||
grid-template-columns: 1fr 1fr 1fr 1fr 1fr;
|
||||
grid-template-rows: auto;
|
||||
gap: 10px;
|
||||
|
||||
.item {
|
||||
border-radius: 6px;
|
||||
overflow: hidden;
|
||||
padding: 2px;
|
||||
padding: 4px;
|
||||
background-color: var(--color);
|
||||
|
||||
&.active {
|
||||
.tab_cont {
|
||||
position: relative;
|
||||
|
||||
&::before {
|
||||
content: "";
|
||||
width: 100%;
|
||||
@@ -306,23 +495,66 @@ onMounted(() => {
|
||||
justify-content: space-between;
|
||||
padding: 0 10px;
|
||||
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 {
|
||||
height: 112px;
|
||||
height: 108px;
|
||||
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
|
||||
.icon_wrap {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
|
||||
.icon {
|
||||
color: var(--color);
|
||||
font-size: 30px;
|
||||
transform: rotate(45deg);
|
||||
position: relative;
|
||||
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 class="box_content_left_top_item_top">
|
||||
<div style="color:#ff5252; font-size: 30px;">
|
||||
¥{{ formatDecimal(infoData.handAmount || 0) }}
|
||||
¥{{ formatDecimal(infoData.orderTurnover || 0) }}
|
||||
</div>
|
||||
<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_botton">
|
||||
<div style=" font-size: 20px;">
|
||||
¥{{ formatDecimal(infoData.cashAmount || 0) }}
|
||||
¥{{ formatDecimal(infoData.cash || 0) }}
|
||||
</div>
|
||||
<div style="margin-top: 6px;">
|
||||
现金支付
|
||||
@@ -179,18 +179,19 @@ const exit = async () => {
|
||||
if (loading.value) return
|
||||
loading.value = true;
|
||||
// await staffPermission('yun_xu_jiao_ban')
|
||||
const res = await handover(isPrint.value)
|
||||
const data = await handoverData(res)
|
||||
await handover(printStore.deviceNoteList.length ? 0 : 1)
|
||||
if (printStore.deviceNoteList.length) {
|
||||
printStore.printWork(infoData.value)
|
||||
// 使用本地打印机 打印交班数据
|
||||
data.printTime = dayjs().format('YYYY-MM-DD HH:mm:ss')
|
||||
data.printShop = isPrint.value
|
||||
printStore.printWork(data)
|
||||
} else {
|
||||
// 使用云打印机 打印交班数据
|
||||
await handoverNetworkPrint(data.id)
|
||||
// data.printTime = dayjs().format('YYYY-MM-DD HH:mm:ss')
|
||||
// data.printShop = isPrint.value
|
||||
}
|
||||
// else {
|
||||
// // 使用云打印机 打印交班数据
|
||||
// await handoverNetworkPrint(data.id)
|
||||
// }
|
||||
logoutHandle()
|
||||
loading.value = false;
|
||||
} catch (error) {
|
||||
loading.value = false;
|
||||
console.log(error);
|
||||
|
||||
Reference in New Issue
Block a user