Compare commits
11 Commits
78e88b8eb7
...
prod
| Author | SHA1 | Date | |
|---|---|---|---|
| fa67997c86 | |||
| 50a5aeb8e5 | |||
| 1985713f28 | |||
| 8655757dd6 | |||
| 7e03547798 | |||
| e0aba58651 | |||
| d19e1688a5 | |||
| 23b8db63b8 | |||
| c9cd3a80d9 | |||
| a5fdbd0c13 | |||
| 32d150fd15 |
File diff suppressed because one or more lines are too long
@@ -5,7 +5,7 @@ import axios from "axios";
|
||||
import os from "os";
|
||||
import fs from "fs";
|
||||
import { exec } from "child_process";
|
||||
import { printReceipt, printHandoverReceipt, printRefund } from "./printService";
|
||||
import { printReceipt, printHandoverReceipt, printRefund,printRefundDish } from "./printService";
|
||||
|
||||
// ===== 核心配置:单文件缓存 =====
|
||||
// 固定的缓存文件路径(永远只存这1个文件)
|
||||
@@ -134,7 +134,7 @@ app.whenReady().then(() => {
|
||||
}
|
||||
});
|
||||
|
||||
// 打印退菜单/退款小票
|
||||
// 打印退款小票
|
||||
ipcMain.on('printRefund', async (event, arg) => {
|
||||
try {
|
||||
let _parmas = JSON.parse(arg);
|
||||
@@ -147,6 +147,19 @@ app.whenReady().then(() => {
|
||||
}
|
||||
});
|
||||
|
||||
// 打印退菜单
|
||||
ipcMain.on('printRefundDish', async (event, arg) => {
|
||||
try {
|
||||
let _parmas = JSON.parse(arg);
|
||||
// console.log(_parmas);
|
||||
await printRefundDish(_parmas.printerIp, _parmas.orderData);
|
||||
return { ok: true }
|
||||
} catch (e) {
|
||||
console.log(e);
|
||||
return { ok: false, msg: e.message }
|
||||
}
|
||||
});
|
||||
|
||||
app.on("activate", () => {
|
||||
// 在 macOS 系统内, 如果没有已开启的应用窗口
|
||||
// 点击托盘图标时通常会重新创建一个新窗口
|
||||
|
||||
@@ -82,8 +82,27 @@ const dineModeFilter = t => {
|
||||
return t
|
||||
}
|
||||
|
||||
// 支付类型 主扫 main_scan
|
||||
// 被扫 back_scan
|
||||
// 微信小程序 wechat_mini
|
||||
// 支付宝小程序 alipay_mini
|
||||
// 会员支付 vip_pay
|
||||
// 现金支付 cash_pay
|
||||
// 挂账支付 credit_pay
|
||||
const payTypeFilter = t => {
|
||||
if (t === 'main_scan') return '主扫'
|
||||
if (t === 'back_scan') return '被扫'
|
||||
if (t === 'wechat_mini') return '微信小程序'
|
||||
if (t === 'alipay_mini') return '支付宝小程序'
|
||||
if (t === 'vip_pay') return '余额支付'
|
||||
if (t === 'cash_pay') return '现金支付'
|
||||
if (t === 'credit_pay') return '挂账支付'
|
||||
return t
|
||||
}
|
||||
|
||||
// ======================== 打印结算小票 ========================
|
||||
export function printReceipt(printerIp, order) {
|
||||
// console.log('Printing receipt...', JSON.stringify(order));
|
||||
return new Promise((resolve) => {
|
||||
const socket = new net.Socket()
|
||||
const lineWidth = 48
|
||||
@@ -98,10 +117,10 @@ export function printReceipt(printerIp, order) {
|
||||
// ======================== 标题区域(彻底修复居中问题!) ========================
|
||||
const title1 = order.shop_name || '';
|
||||
let title2 = `结算单 #${order.orderInfo.orderNum}`
|
||||
if (order.isBefore && !order.isGuest) {
|
||||
if (order.isBefore) {
|
||||
title2 = `${order.isBefore ? '预' : ''}结算单 #${order.orderInfo.orderNum}`;
|
||||
}
|
||||
if (order.isGuest && order.isBefore) {
|
||||
if (order.isGuest) {
|
||||
title2 = `客看单 #${order.orderInfo.orderNum}`;
|
||||
}
|
||||
|
||||
@@ -145,8 +164,8 @@ export function printReceipt(printerIp, order) {
|
||||
const rightPart = padRightAlign(`${seatNumText}人`, 28) // 加标签更清晰,也可只显示数字
|
||||
|
||||
orderInfo += leftPart + rightPart + '\n'
|
||||
if (!order.isBefore) {
|
||||
orderInfo += padLeftAlign('结账时间:', 10) + padLeftAlign(order.createdAt || '-', 38) + '\n'
|
||||
if (!order.isBefore && !order.isGuest) {
|
||||
orderInfo += padLeftAlign('结账时间:', 10) + padLeftAlign(order.orderInfo.paidTime || '-', 38) + '\n'
|
||||
}
|
||||
orderInfo += createDivider(lineWidth, 'thin') + '\n'
|
||||
|
||||
@@ -157,15 +176,54 @@ export function printReceipt(printerIp, order) {
|
||||
orderInfo += padRightAlign('小计', 16) + '\n'
|
||||
orderInfo += createDivider(lineWidth, 'thin') + '\n'
|
||||
|
||||
// 处理商品列表(套餐主项显示金额,子项不显示金额 + 规格换行)
|
||||
order.carts.forEach(item => {
|
||||
const name = truncateByPrintWidth(item.name || '未知商品', 18)
|
||||
const price = formatAmount(item.salePrice)
|
||||
const num = item.number || 1
|
||||
const total = formatAmount(item.totalAmount)
|
||||
orderInfo += padLeftAlign(name, 18)
|
||||
orderInfo += padLeftAlign(price, 8)
|
||||
orderInfo += padLeftAlign(num, 6)
|
||||
orderInfo += padRightAlign(total, 16) + '\n'
|
||||
if (item.number > 0) {
|
||||
// 套餐商品逻辑
|
||||
if (item.proGroupInfo) {
|
||||
// 套餐主项:正常显示 名称、单价、数量、小计
|
||||
const packageName = truncateByPrintWidth(item.name || '未知套餐', 18)
|
||||
orderInfo += padLeftAlign(packageName, 18)
|
||||
orderInfo += padLeftAlign(formatAmount(item.salePrice), 8)
|
||||
orderInfo += padLeftAlign(item.number || 1, 6)
|
||||
orderInfo += padRightAlign(formatAmount(item.totalAmount), 16) + '\n'
|
||||
|
||||
// 套餐子项:只显示名称+规格,单价、小计全部为空
|
||||
const proGroupInfo = item.proGroupInfo || []
|
||||
proGroupInfo.forEach(subItem => {
|
||||
const subName = truncateByPrintWidth(`>${subItem.proName || '未知商品'}`, 18)
|
||||
orderInfo += padLeftAlign(subName, 18)
|
||||
orderInfo += padLeftAlign('', 8) // 子项单价空
|
||||
orderInfo += padLeftAlign(subItem.number || 1, 6)
|
||||
orderInfo += padRightAlign('', 16) + '\n' // 子项小计空
|
||||
|
||||
// 子项规格换行显示
|
||||
if (subItem.skuName) {
|
||||
const skuText = truncateByPrintWidth(` 规格:${subItem.skuName}`, 18)
|
||||
orderInfo += padLeftAlign(skuText, 18)
|
||||
orderInfo += padLeftAlign('', 8)
|
||||
orderInfo += padLeftAlign('', 6)
|
||||
orderInfo += padRightAlign('', 16) + '\n'
|
||||
}
|
||||
})
|
||||
} else {
|
||||
// 普通商品:正常显示 + 规格换行
|
||||
let productName = truncateByPrintWidth(item.name || '未知商品', 18)
|
||||
orderInfo += padLeftAlign(productName, 18)
|
||||
orderInfo += padLeftAlign(item.salePrice ? formatAmount(item.salePrice) : '', 8)
|
||||
orderInfo += padLeftAlign(item.number || 1, 6)
|
||||
orderInfo += padRightAlign(formatAmount(item.totalAmount), 16) + '\n'
|
||||
|
||||
// 规格单独换行
|
||||
if (item.skuName) {
|
||||
const skuLine = truncateByPrintWidth(` 规格:${item.skuName}`, 18)
|
||||
orderInfo += padLeftAlign(skuLine, 18)
|
||||
orderInfo += padLeftAlign('', 8)
|
||||
orderInfo += padLeftAlign('', 6)
|
||||
orderInfo += padRightAlign('', 16) + '\n'
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
orderInfo += createDivider(lineWidth, 'thin') + '\n'
|
||||
@@ -176,6 +234,7 @@ export function printReceipt(printerIp, order) {
|
||||
socket.write(iconv.encode(orderInfo, 'gbk'))
|
||||
|
||||
// ======================== 付款信息 ========================
|
||||
if (order.isBefore) {
|
||||
const payableLine = padLeftAlign('应付', 10) + padRightAlign(formatAmount(order.originAmount), 51) + '\n'
|
||||
socket.write(Buffer.from([0x1B, 0x21, 0x11])); // 放大字号
|
||||
socket.write(Buffer.from([0x1B, 0x45, 0x01])); // 加粗
|
||||
@@ -183,7 +242,16 @@ export function printReceipt(printerIp, order) {
|
||||
socket.write(Buffer.from([0x1B, 0x21, 0x00])); // 恢复默认字号
|
||||
socket.write(Buffer.from([0x1B, 0x45, 0x00])); // 取消加粗
|
||||
socket.write(iconv.encode(createDivider(lineWidth, 'thin') + '\n', 'gbk'));
|
||||
if (!order.isBefore) {
|
||||
}
|
||||
|
||||
if (!order.isBefore && !order.isGuest) {
|
||||
const payableLine = padLeftAlign('应付', 10) + padRightAlign(formatAmount(order.orderInfo.payAmount), 51) + '\n'
|
||||
socket.write(Buffer.from([0x1B, 0x21, 0x11])); // 放大字号
|
||||
socket.write(Buffer.from([0x1B, 0x45, 0x01])); // 加粗
|
||||
socket.write(iconv.encode(payableLine, 'gbk'));
|
||||
socket.write(Buffer.from([0x1B, 0x21, 0x00])); // 恢复默认字号
|
||||
socket.write(Buffer.from([0x1B, 0x45, 0x00])); // 取消加粗
|
||||
socket.write(iconv.encode(createDivider(lineWidth, 'thin') + '\n', 'gbk'));
|
||||
const paidLine = padLeftAlign('已付', 10) + padRightAlign(formatAmount(order.orderInfo.payAmount), 51) + '\n'
|
||||
socket.write(Buffer.from([0x1B, 0x21, 0x11]));
|
||||
socket.write(Buffer.from([0x1B, 0x45, 0x01]));
|
||||
@@ -195,6 +263,9 @@ export function printReceipt(printerIp, order) {
|
||||
|
||||
// ======================== 底部 ========================
|
||||
let bottom = ''
|
||||
if (!order.isBefore && !order.isGuest) {
|
||||
bottom += padLeftAlign('支付方式:', 8) + padLeftAlign(payTypeFilter(order.orderInfo.payType) || '无', 38) + '\n'
|
||||
}
|
||||
bottom += padLeftAlign('操作员:', 8) + padLeftAlign(order.loginAccount || '无', 38) + '\n'
|
||||
bottom += padLeftAlign('打印时间:', 10) + padLeftAlign(new Date().toLocaleString(), 38) + '\n'
|
||||
bottom += padLeftAlign('订单号:', 8) + padLeftAlign(order.orderInfo.orderNo || '-', 38) + '\n'
|
||||
@@ -222,8 +293,7 @@ export function printReceipt(printerIp, order) {
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
// ======================== 打印退菜单/退款小票 ========================
|
||||
// ======================== 退款小票 ========================
|
||||
export function printRefund(printerIp, order) {
|
||||
console.log(JSON.stringify(order));
|
||||
|
||||
@@ -240,7 +310,7 @@ export function printRefund(printerIp, order) {
|
||||
|
||||
// ======================== 标题区域(彻底修复居中问题!) ========================
|
||||
const title1 = order.shop_name || '';
|
||||
let title2 = order.title || '退款单'
|
||||
let title2 = '退款单';
|
||||
|
||||
// 核心修复:先写入空行清空打印机缓冲区,避免残留字符干扰居中起始位置
|
||||
socket.write(iconv.encode('\n', 'gbk'));
|
||||
@@ -308,6 +378,7 @@ export function printRefund(printerIp, order) {
|
||||
}
|
||||
|
||||
// ======================== 付款信息 ========================
|
||||
|
||||
let payableLine = ''
|
||||
payableLine += padLeftAlign('退款总计', 10) + padRightAlign(formatAmount(order.amount), 51) + '\n'
|
||||
socket.write(Buffer.from([0x1B, 0x21, 0x11])); // 放大字号
|
||||
@@ -315,6 +386,7 @@ export function printRefund(printerIp, order) {
|
||||
socket.write(iconv.encode(payableLine, 'gbk'));
|
||||
socket.write(Buffer.from([0x1B, 0x21, 0x00])); // 恢复默认字号
|
||||
socket.write(Buffer.from([0x1B, 0x45, 0x00])); // 取消加粗
|
||||
|
||||
let refundInfo = ''
|
||||
refundInfo += padLeftAlign('退款方式:', 10) + padLeftAlign(order.refundMethod || '无', 38) + '\n'
|
||||
refundInfo += padLeftAlign('退款原因:', 10) + padLeftAlign(order.remark || '无', 38) + '\n'
|
||||
@@ -350,6 +422,135 @@ export function printRefund(printerIp, order) {
|
||||
})
|
||||
}
|
||||
|
||||
// ======================== 打印退菜单 ========================
|
||||
export function printRefundDish(printerIp, order) {
|
||||
console.log(JSON.stringify(order));
|
||||
|
||||
return new Promise((resolve) => {
|
||||
const socket = new net.Socket()
|
||||
const lineWidth = 48
|
||||
socket.setTimeout(8000)
|
||||
|
||||
const formatAmount = (amount) => Number(amount || 0).toFixed(2)
|
||||
|
||||
socket.connect(9100, printerIp, () => {
|
||||
try {
|
||||
setupPrinter(socket)
|
||||
|
||||
// ======================== 标题区域(彻底修复居中问题!) ========================
|
||||
const title1 = order.shop_name || '';
|
||||
let title2 = '退菜单'
|
||||
|
||||
// 核心修复:先写入空行清空打印机缓冲区,避免残留字符干扰居中起始位置
|
||||
socket.write(iconv.encode('\n', 'gbk'));
|
||||
|
||||
// 步骤1:重置打印机格式(避免残留格式影响)
|
||||
socket.write(Buffer.from([0x1B, 0x40]));
|
||||
// 步骤2:居中对齐标题
|
||||
socket.write(Buffer.from([0x1B, 0x61, 0x01])); // 1 = center
|
||||
// 步骤3:设置标题1的格式(加粗+大号字体)
|
||||
socket.write(Buffer.from([0x1B, 0x21, 0x11])); // 字号放大(0x11 是常用放大值)
|
||||
socket.write(Buffer.from([0x1B, 0x45, 0x01])); // 加粗
|
||||
socket.write(iconv.encode(title1 + '\n', 'gbk'));
|
||||
|
||||
// 步骤4:恢复格式,打印标题2(常规字体)
|
||||
socket.write(Buffer.from([0x1B, 0x21, 0x00])); // 恢复默认字号
|
||||
socket.write(Buffer.from([0x1B, 0x45, 0x00])); // 取消加粗
|
||||
socket.write(iconv.encode(title2 + '\n\n', 'gbk'));
|
||||
socket.write(Buffer.from([0x1B, 0x61, 0x00])); // 0 = left
|
||||
|
||||
// ======================== 订单信息(修复显示+换行问题) ========================
|
||||
const tableLine = padLeftAlign('桌台号:', 8) + padLeftAlign(order.orderInfo.tableName || '无', 14) + '\n'
|
||||
socket.write(Buffer.from([0x1B, 0x21, 0x00])); // 正常字号
|
||||
socket.write(Buffer.from([0x1B, 0x45, 0x01])); // 加粗
|
||||
socket.write(iconv.encode(tableLine, 'gbk'));
|
||||
socket.write(Buffer.from([0x1B, 0x45, 0x00])); // 取消加粗
|
||||
|
||||
let orderInfo = ''
|
||||
|
||||
// 修复:打印机-用餐模式 + 就餐人数 展示逻辑
|
||||
const dineModeText = dineModeFilter(order.orderInfo.dineMode)
|
||||
// 1. 拼接打印机+用餐模式文本,空值兜底
|
||||
const printerDineText = `${order.printerName || '未知打印机'}-${dineModeText || '未知模式'}`
|
||||
// 2. 截断超长文本(左侧分配20宽度,保证不超限)
|
||||
const truncatedPrinterDine = truncateByPrintWidth(printerDineText, 20)
|
||||
// 3. 左侧左对齐填充20宽度(保证占满分配空间,不浪费空白)
|
||||
const leftPart = padLeftAlign(truncatedPrinterDine, 20)
|
||||
// 4. 右侧就餐人数:空值兜底为“无”,右对齐填充28宽度(20+28=48,刚好行宽)
|
||||
const seatNumText = order.orderInfo.seatNum || '0'
|
||||
const rightPart = padRightAlign(`${seatNumText}人`, 28) // 加标签更清晰,也可只显示数字
|
||||
|
||||
if (order.carts.length > 0) {
|
||||
orderInfo += leftPart + rightPart + '\n'
|
||||
orderInfo += createDivider(lineWidth, 'thin') + '\n'
|
||||
|
||||
// ======================== 商品表格 ========================
|
||||
orderInfo += padLeftAlign('品名', 18)
|
||||
orderInfo += padLeftAlign('单价', 8)
|
||||
orderInfo += padLeftAlign('数量', 6)
|
||||
orderInfo += padRightAlign('小计', 16) + '\n'
|
||||
orderInfo += createDivider(lineWidth, 'thin') + '\n'
|
||||
|
||||
order.carts.forEach(item => {
|
||||
const name = truncateByPrintWidth(item.name || '未知商品', 18)
|
||||
const price = formatAmount(item.salePrice)
|
||||
const num = item.number || 1
|
||||
const total = formatAmount(item.totalAmount)
|
||||
orderInfo += padLeftAlign(name, 18)
|
||||
orderInfo += padLeftAlign(price, 8)
|
||||
orderInfo += padLeftAlign(num, 6)
|
||||
orderInfo += padRightAlign(total, 16) + '\n'
|
||||
})
|
||||
|
||||
orderInfo += createDivider(lineWidth, 'thin') + '\n'
|
||||
socket.write(iconv.encode(orderInfo, 'gbk'))
|
||||
}
|
||||
|
||||
// ======================== 付款信息 ========================
|
||||
// if (order.isGuest) {
|
||||
// let payableLine = ''
|
||||
// payableLine += padLeftAlign('退款总计', 10) + padRightAlign(formatAmount(order.amount), 51) + '\n'
|
||||
// socket.write(Buffer.from([0x1B, 0x21, 0x11])); // 放大字号
|
||||
// socket.write(Buffer.from([0x1B, 0x45, 0x01])); // 加粗
|
||||
// socket.write(iconv.encode(payableLine, 'gbk'));
|
||||
// socket.write(Buffer.from([0x1B, 0x21, 0x00])); // 恢复默认字号
|
||||
// socket.write(Buffer.from([0x1B, 0x45, 0x00])); // 取消加粗
|
||||
// }
|
||||
// let refundInfo = ''
|
||||
// refundInfo += padLeftAlign('退款方式:', 10) + padLeftAlign(order.refundMethod || '无', 38) + '\n'
|
||||
// refundInfo += padLeftAlign('退款原因:', 10) + padLeftAlign(order.remark || '无', 38) + '\n'
|
||||
// socket.write(iconv.encode(refundInfo, 'gbk'));
|
||||
// socket.write(iconv.encode(createDivider(lineWidth, 'thin') + '\n', 'gbk'));
|
||||
|
||||
// ======================== 底部 ========================
|
||||
let bottom = ''
|
||||
bottom += padLeftAlign('操作员:', 8) + padLeftAlign(order.loginAccount || '无', 38) + '\n'
|
||||
bottom += padLeftAlign('打印时间:', 10) + padLeftAlign(new Date().toLocaleString(), 38) + '\n'
|
||||
bottom += padLeftAlign('原订单号:', 10) + padLeftAlign(order.orderInfo.orderNo || '-', 38) + '\n'
|
||||
bottom += createDivider(lineWidth, 'full') + '\n'
|
||||
bottom += '\n\n'
|
||||
bottom += '\n\n'
|
||||
|
||||
socket.write(iconv.encode(bottom, 'gbk'))
|
||||
socket.write(Buffer.from([0x1D, 0x56, 0x00]))
|
||||
|
||||
setTimeout(() => {
|
||||
socket.end()
|
||||
resolve('success')
|
||||
}, 400)
|
||||
} catch (err) {
|
||||
console.error(err)
|
||||
socket.destroy()
|
||||
resolve('error')
|
||||
}
|
||||
})
|
||||
|
||||
socket.on('error', () => resolve('error'))
|
||||
socket.on('timeout', () => resolve('timeout'))
|
||||
socket.on('close', () => { })
|
||||
})
|
||||
}
|
||||
|
||||
// ======================== 打印交班小票(完整版 · 补齐分类/商品数据) ========================
|
||||
export function printHandoverReceipt(printerIp, data) {
|
||||
return new Promise((resolve) => {
|
||||
@@ -390,22 +591,23 @@ export function printHandoverReceipt(printerIp, data) {
|
||||
let basicInfo = ''
|
||||
// 优化:拆分当班时间和交班时间,空值兜底
|
||||
basicInfo += padLeftAlign('交班时间:', 10) + padLeftAlign(data.handoverTime || '-', 36) + '\n'
|
||||
basicInfo += padLeftAlign('收银员:', 8) + padLeftAlign(data.staffName || '-', 36) + '\n'
|
||||
basicInfo += padLeftAlign('交班周期:', 10) + padLeftAlign(`${data.loginTime}-${data.handoverTime}` || '-', 36) + '\n\n'
|
||||
basicInfo += padLeftAlign('交班人:', 8) + padLeftAlign(data.staffName || '-', 36) + '\n'
|
||||
basicInfo += padLeftAlign('交班:', 6) + padLeftAlign(`${data.loginTime} - ${data.handoverTime}` || '-', 36) + '\n\n'
|
||||
|
||||
// basicInfo += createDivider(lineWidth, 'thin') + '\n'
|
||||
|
||||
// 收入明细 - 补充会员支付/充值字段
|
||||
basicInfo += padLeftAlign('当班营业总额:', 10) + padLeftAlign(formatAmount(data.handAmount), 36) + '\n'
|
||||
basicInfo += padLeftAlign('当班营业总额:', 10) + padLeftAlign(formatAmount(data.turnover), 36) + '\n'
|
||||
basicInfo += padLeftAlign('实际收款的支付方式', 10) + '\n'
|
||||
basicInfo += padLeftAlign('现金', 10) + padRightAlign(formatAmount(data.cashAmount), 36) + '\n'
|
||||
basicInfo += padLeftAlign('微信', 10) + padRightAlign(formatAmount(data.wechatAmount), 36) + '\n'
|
||||
basicInfo += padLeftAlign('支付宝', 10) + padRightAlign(formatAmount(data.alipayAmount), 36) + '\n'
|
||||
basicInfo += padLeftAlign('二维码收款', 10) + padRightAlign(formatAmount(data.vipPay), 36) + '\n'
|
||||
basicInfo += padLeftAlign('扫码收款', 10) + padRightAlign(formatAmount(data.vipRecharge), 36) + '\n\n'
|
||||
basicInfo += padLeftAlign('现金', 10) + padRightAlign(formatAmount(data.cash), 36) + '\n'
|
||||
basicInfo += padLeftAlign('微信', 10) + padRightAlign(formatAmount(data.wechat), 36) + '\n'
|
||||
basicInfo += padLeftAlign('支付宝', 10) + padRightAlign(formatAmount(data.alipay), 36) + '\n'
|
||||
basicInfo += padLeftAlign('二维码收款', 10) + padRightAlign(formatAmount(data.selfScan), 36) + '\n'
|
||||
basicInfo += padLeftAlign('扫码收款', 10) + padRightAlign(formatAmount(data.barScan), 36) + '\n'
|
||||
basicInfo += padLeftAlign('充值', 10) + padRightAlign(formatAmount(data.recharge), 36) + '\n\n'
|
||||
basicInfo += padLeftAlign('非实际收款的支付方式', 10) + '\n'
|
||||
basicInfo += padLeftAlign('挂账', 10) + padRightAlign(formatAmount(data.creditAmount), 36) + '\n'
|
||||
basicInfo += padLeftAlign('余额', 10) + padRightAlign(formatAmount(data.vipPay), 36) + '\n'
|
||||
basicInfo += padLeftAlign('挂账', 10) + padRightAlign(formatAmount(data.owed), 36) + '\n'
|
||||
basicInfo += padLeftAlign('余额', 10) + padRightAlign(formatAmount(data.balance), 36) + '\n'
|
||||
basicInfo += createDivider(lineWidth, 'thin') + '\n'
|
||||
|
||||
socket.write(Buffer.from([0x1B, 0x21, 0x00])); // 正常字号
|
||||
@@ -414,27 +616,27 @@ export function printHandoverReceipt(printerIp, data) {
|
||||
let refundInfo = ''
|
||||
refundInfo += padLeftAlign('退款/退菜', 10) + '\n'
|
||||
refundInfo += padLeftAlign('退款金额', 10) + padRightAlign(formatAmount(data.refundAmount), 36) + '\n'
|
||||
refundInfo += padLeftAlign('退菜数量', 10) + padRightAlign(formatAmount(data.refundAmount), 36) + '\n'
|
||||
refundInfo += padLeftAlign('退菜数量', 10) + padRightAlign(formatAmount(data.returnDishCount), 36) + '\n'
|
||||
refundInfo += createDivider(lineWidth, 'thin') + '\n'
|
||||
socket.write(iconv.encode(refundInfo, 'gbk'))
|
||||
|
||||
let orderInfo = ''
|
||||
const orderLabel = '订单(数量/订单总额)'
|
||||
const orderValue = `${data.orderCount}/${formatAmount(data.orderAmount)}`
|
||||
const orderValue = `${data.orderCount}/${formatAmount(data.orderTurnover)}`
|
||||
const orderLabelWidth = lineWidth - getPrintWidth(orderValue)
|
||||
orderInfo += padLeftAlign(orderLabel, orderLabelWidth) + orderValue + '\n\n'
|
||||
socket.write(iconv.encode(orderInfo, 'gbk'))
|
||||
|
||||
// ======================== 分类数据区域 ========================
|
||||
let categoryInfo = ''
|
||||
if (data.categoryDataList && data.categoryDataList.length) {
|
||||
if (data.categoryList && data.categoryList.length) {
|
||||
categoryInfo += centerAlign('销售数据', lineWidth) + '\n'
|
||||
categoryInfo += createDivider(lineWidth, 'thin') + '\n'
|
||||
// 分类表头
|
||||
categoryInfo += padLeftAlign('名称', 24) + padLeftAlign('数量', 12) + padRightAlign('总计', 12) + '\n'
|
||||
categoryInfo += padLeftAlign('商品分类', 24) + padLeftAlign('数量', 12) + padRightAlign('总计', 12) + '\n'
|
||||
// categoryInfo += createDivider(lineWidth, 'thin') + '\n'
|
||||
// 分类数据行
|
||||
data.categoryDataList.forEach(item => {
|
||||
data.categoryList.forEach(item => {
|
||||
const catName = truncateByPrintWidth(item.categoryName || '未知分类', 24)
|
||||
const num = item.num || 0
|
||||
const amount = formatAmount(item.amount)
|
||||
@@ -445,54 +647,22 @@ export function printHandoverReceipt(printerIp, data) {
|
||||
socket.write(iconv.encode(categoryInfo, 'gbk'))
|
||||
|
||||
// ======================== 商品数据区域 ========================
|
||||
let productInfo = ''
|
||||
if (data.printShop && data.productDataList && data.productDataList.length) {
|
||||
productInfo += centerAlign('商品数据', lineWidth) + '\n'
|
||||
productInfo += createDivider(lineWidth, 'thin') + '\n'
|
||||
// 商品表头
|
||||
productInfo += padLeftAlign('商品', 36) + padRightAlign('数量', 12) + '\n'
|
||||
// let productInfo = ''
|
||||
// if (data.detailList && data.detailList.length) {
|
||||
// productInfo += centerAlign('商品数据', lineWidth) + '\n'
|
||||
// productInfo += createDivider(lineWidth, 'thin') + '\n'
|
||||
// 商品数据行
|
||||
data.productDataList.forEach(item => {
|
||||
const prodName = truncateByPrintWidth(item.productName || '未知商品', 36)
|
||||
const num = item.num || 0
|
||||
productInfo += padLeftAlign(prodName, 36) + padRightAlign(num, 12) + '\n'
|
||||
})
|
||||
productInfo += createDivider(lineWidth, 'thin') + '\n'
|
||||
}
|
||||
socket.write(iconv.encode(productInfo, 'gbk'))
|
||||
|
||||
// ======================== 收入明细区域(优化对齐和格式) ========================
|
||||
// let incomeInfo = ''
|
||||
// incomeInfo += centerAlign('【收支汇总】', lineWidth) + '\n'
|
||||
// incomeInfo += createDivider(lineWidth, 'thin') + '\n'
|
||||
|
||||
// // 收支汇总项(补充挂账金额)
|
||||
// const incomeItems = [
|
||||
// { label: '快捷收款金额:', val: data.quickInAmount },
|
||||
// { label: '退款金额:', val: data.refundAmount },
|
||||
// { label: '总收入:', val: data.handAmount },
|
||||
// { label: '挂账金额:', val: data.creditAmount },
|
||||
// { label: '总订单数:', val: data.orderCount || 0 }
|
||||
// ]
|
||||
|
||||
// incomeItems.forEach((item, index) => {
|
||||
// const labelPart = padLeftAlign(item.label, 16)
|
||||
// let valPart = ''
|
||||
// // 总收入/总订单数加粗显示
|
||||
// if (index === 2 || index === 4) {
|
||||
// socket.write(Buffer.from([0x1B, 0x45, 0x01])); // 加粗
|
||||
// valPart = padRightAlign(index === 4 ? item.val : formatAmount(item.val), 32)
|
||||
// incomeInfo += labelPart + valPart + '\n'
|
||||
// socket.write(Buffer.from([0x1B, 0x45, 0x00])); // 取消加粗
|
||||
// } else {
|
||||
// valPart = padRightAlign(formatAmount(item.val), 32)
|
||||
// incomeInfo += labelPart + valPart + '\n'
|
||||
// }
|
||||
// // 商品表头
|
||||
// productInfo += padLeftAlign('商品', 36) + padRightAlign('数量', 12) + '\n'
|
||||
// // productInfo += createDivider(lineWidth, 'thin') + '\n'
|
||||
// // 商品数据行
|
||||
// data.detailList.forEach(item => {
|
||||
// const prodName = truncateByPrintWidth(item.productName || '未知商品', 36)
|
||||
// const num = item.num || 0
|
||||
// productInfo += padLeftAlign(prodName, 36) + padRightAlign(num, 12) + '\n'
|
||||
// })
|
||||
|
||||
// incomeInfo += createDivider(lineWidth, 'full') + '\n'
|
||||
// socket.write(iconv.encode(incomeInfo, 'gbk'))
|
||||
// productInfo += createDivider(lineWidth, 'thin') + '\n'
|
||||
// }
|
||||
// socket.write(iconv.encode(productInfo, 'gbk'))
|
||||
|
||||
// ======================== 底部区域(统一结算小票风格) ========================
|
||||
let bottomInfo = ''
|
||||
|
||||
13
package-lock.json
generated
13
package-lock.json
generated
@@ -1,12 +1,12 @@
|
||||
{
|
||||
"name": "vite-electron",
|
||||
"version": "2.0.15",
|
||||
"version": "2.0.21",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "vite-electron",
|
||||
"version": "2.0.15",
|
||||
"version": "2.0.21",
|
||||
"hasInstallScript": true,
|
||||
"dependencies": {
|
||||
"@element-plus/icons-vue": "^2.3.1",
|
||||
@@ -29,7 +29,7 @@
|
||||
"vue": "^3.3.8",
|
||||
"vue-router": "^4.2.5",
|
||||
"win32-api": "^26.1.2",
|
||||
"ysk-utils": "^1.0.84"
|
||||
"ysk-utils": "^1.0.85"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@vitejs/plugin-vue": "^4.5.0",
|
||||
@@ -6723,9 +6723,10 @@
|
||||
}
|
||||
},
|
||||
"node_modules/ysk-utils": {
|
||||
"version": "1.0.84",
|
||||
"resolved": "https://registry.npmmirror.com/ysk-utils/-/ysk-utils-1.0.84.tgz",
|
||||
"integrity": "sha512-UAMM1FfQGWJ4QPdI2EbGyJy4zv29yPXzi+Eyv/MDT0AFutdMnvbq0Q941BHn2egie2DOiw5mtDaj4yOWaSuUgA==",
|
||||
"version": "1.0.85",
|
||||
"resolved": "https://registry.npmmirror.com/ysk-utils/-/ysk-utils-1.0.85.tgz",
|
||||
"integrity": "sha512-HkbV4Jidi3G6DAuGAN972tClUYtC2zVoxo4crrxexfn0rZa8HjXatUfEbawHOeEzyl6G1CdC+160I2bKfxEBlA==",
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"bignumber.js": "^9.3.1",
|
||||
"loadsh": "^0.0.4",
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "vite-electron",
|
||||
"private": true,
|
||||
"version": "2.0.15",
|
||||
"version": "2.0.25",
|
||||
"main": "dist-electron/main.js",
|
||||
"scripts": {
|
||||
"dev": "chcp 65001 && vite",
|
||||
@@ -32,7 +32,7 @@
|
||||
"vue": "^3.3.8",
|
||||
"vue-router": "^4.2.5",
|
||||
"win32-api": "^26.1.2",
|
||||
"ysk-utils": "^1.0.84"
|
||||
"ysk-utils": "^1.0.85"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@vitejs/plugin-vue": "^4.5.0",
|
||||
|
||||
@@ -317,7 +317,7 @@ 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,
|
||||
|
||||
@@ -104,3 +104,30 @@ export function shopStoragePut(data) {
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询存取酒记录
|
||||
* @param {*} data
|
||||
* @returns
|
||||
*/
|
||||
export function shopStorageRecord(params) {
|
||||
return request({
|
||||
method: "get",
|
||||
url: "/product/admin/shopStorage/record",
|
||||
params,
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 耗材库存列表接口
|
||||
* @param {*} data
|
||||
* @returns
|
||||
*/
|
||||
export function consStock(params) {
|
||||
return request({
|
||||
method: "get",
|
||||
url: "/product/admin/product/cons/consStock",
|
||||
params,
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -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("打印小票");
|
||||
|
||||
@@ -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">
|
||||
<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']);
|
||||
|
||||
@@ -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,7 +539,6 @@ async function confirmOrder() {
|
||||
|
||||
upadatePayData()
|
||||
|
||||
|
||||
payType.value = payList.value[payActive.value].payType
|
||||
if (payList.value[payActive.value].payType == "arrears") {
|
||||
showBuyerHandle();
|
||||
@@ -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);
|
||||
|
||||
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">
|
||||
|
||||
@@ -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";
|
||||
@@ -36,6 +36,7 @@ const initialCostSummary = {
|
||||
// 商品store + 购物车store
|
||||
export const useGoods = defineStore("goods", {
|
||||
state: () => ({
|
||||
remark: "", // 订单备注
|
||||
showVipPrice: 0,
|
||||
allSelected: 0, // 是否整单打包
|
||||
vipUserInfo: {}, // 会员信息
|
||||
@@ -46,6 +47,7 @@ export const useGoods = defineStore("goods", {
|
||||
}, // 台桌信息
|
||||
cartActiveIndex: 0, // 购物车激活索引,
|
||||
isCartInit: false,
|
||||
payType: "cart", // 结算类型,cart 购物车结算 table 桌台结算 order 订单结算,
|
||||
cartList: [], // 购物车列表
|
||||
// 购物车信息,
|
||||
cartInfo: {
|
||||
@@ -60,6 +62,7 @@ export const useGoods = defineStore("goods", {
|
||||
goodsListLoading: false, // 商品列表加载状态
|
||||
goodsList: [], // 商品列表
|
||||
originGoodsList: [], // 原始商品列表
|
||||
consList: [], // 耗材列表
|
||||
orderList: [], // 订单列表
|
||||
orderListInfo: "", // 历史订单信息
|
||||
cartType: "cart", // cart order
|
||||
@@ -86,7 +89,6 @@ export const useGoods = defineStore("goods", {
|
||||
// 清除会员信息
|
||||
async clearVipUserInfo() {
|
||||
// console.log('清除会员信息');
|
||||
|
||||
this.vipUserInfo = {};
|
||||
this.showVipPrice = 0;
|
||||
|
||||
@@ -302,8 +304,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();
|
||||
|
||||
@@ -371,6 +383,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 +442,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 +501,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,8 +937,12 @@ export const useGoods = defineStore("goods", {
|
||||
.map((item) => item.goods)
|
||||
.flat()
|
||||
.map(this.comleteOrderInfo);
|
||||
if (this.payType == 'table' || this.payType == 'order') {
|
||||
return [...giftGoods, ...oldOrderGoods];
|
||||
} else {
|
||||
return [...currentGoods, ...giftGoods, ...oldOrderGoods];
|
||||
}
|
||||
}
|
||||
|
||||
// 合并所有商品列表
|
||||
const allGoods = ref(getAllGoodsList() || [])
|
||||
|
||||
@@ -75,14 +75,22 @@ export const usePrint = defineStore("print", {
|
||||
return ipReg.test(printer.address);
|
||||
}
|
||||
|
||||
if (printer.connectionType === "usb") {
|
||||
if (printer.connectionType === "USB") {
|
||||
return this.localDevices.some(item => item.name === printer.address);
|
||||
}
|
||||
return false;
|
||||
},
|
||||
|
||||
// 辅助方法:判断是否为特殊费用项(餐位费/打包费)
|
||||
isSpecialFeeItem(item) {
|
||||
// 可根据实际业务调整判断条件,比如通过名称/标识判断
|
||||
const specialNames = ["餐位费", "打包费"];
|
||||
// 条件:1. 无categoryId 2. 名称包含特殊费用关键词 或 标记了特殊标识
|
||||
return !item.categoryId && (item.isSpecialFee || specialNames.some(name => item.name?.includes(name)));
|
||||
},
|
||||
|
||||
// ==============================
|
||||
// 最终完美版 → 空数组打印全部
|
||||
// 优化:保留无categoryId的特殊费用项,兼容原有分类过滤逻辑
|
||||
// ==============================
|
||||
pushReceiptData(props, isDevice = true) {
|
||||
if (!isDevice) {
|
||||
@@ -105,15 +113,15 @@ export const usePrint = defineStore("print", {
|
||||
validPrinters.forEach(printer => {
|
||||
let filterCarts = [];
|
||||
|
||||
// ======================================
|
||||
// ✅ 核心:分类为空数组 → 打印全部菜品
|
||||
// ======================================
|
||||
// 核心过滤逻辑:
|
||||
// 1. 分类为空 → 打印全部(包含特殊费用项)
|
||||
// 2. 分类非空 → 打印「匹配分类的商品」+「无categoryId的特殊费用项」
|
||||
if (!printer.categoryList || printer.categoryList.length === 0) {
|
||||
filterCarts = props.carts || [];
|
||||
} else {
|
||||
// 有分类 → 只打印对应分类
|
||||
filterCarts = (props.carts || []).filter(item => {
|
||||
return printer.categoryList.includes(item.categoryId);
|
||||
// 保留:特殊费用项(无categoryId) + 匹配分类的商品(有categoryId)
|
||||
return this.isSpecialFeeItem(item) || printer.categoryList.includes(item.categoryId);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -199,90 +207,82 @@ export const usePrint = defineStore("print", {
|
||||
},
|
||||
|
||||
// ————————————————————————————————
|
||||
// 以下原有代码完全不动(除了printWork方法)
|
||||
// 以下原有代码完全保留,仅优化格式和可读性
|
||||
// ————————————————————————————————
|
||||
checkLocalPrint(address) {
|
||||
let print = "";
|
||||
for (let item of this.localDevices) {
|
||||
if (item.name == address) {
|
||||
print = item;
|
||||
}
|
||||
}
|
||||
if (!print.name) {
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
const targetPrinter = this.localDevices.find(item => item.name === address);
|
||||
return !!targetPrinter?.name;
|
||||
},
|
||||
|
||||
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++;
|
||||
const validLabelPrinter = this.deviceLableList[0];
|
||||
|
||||
if (!validLabelPrinter || !this.checkLocalPrint(validLabelPrinter.address)) {
|
||||
console.log("标签打印:未在本机查询到打印机");
|
||||
return;
|
||||
}
|
||||
|
||||
const pids = validLabelPrinter.categoryList;
|
||||
let totalCount = 0;
|
||||
let currentCount = 0;
|
||||
|
||||
// 先计算总打印数量
|
||||
props.carts.forEach(item => {
|
||||
if (pids.some(el => el === item.categoryId)) {
|
||||
totalCount += item.number;
|
||||
}
|
||||
});
|
||||
props.carts.map((item) => {
|
||||
if (pids.some((el) => el == item.categoryId)) {
|
||||
|
||||
// 构建标签打印列表
|
||||
props.carts.forEach(item => {
|
||||
if (pids.some(el => el === item.categoryId)) {
|
||||
for (let i = 0; i < item.number; i++) {
|
||||
count++;
|
||||
currentCount++;
|
||||
this.labelList.push({
|
||||
outNumber: props.outNumber,
|
||||
name: item.name,
|
||||
skuName: item.skuName,
|
||||
masterId: props.orderInfo.tableName,
|
||||
deviceName: this.deviceLableList[0].address,
|
||||
deviceName: validLabelPrinter.address,
|
||||
createdAt: dayjs(props.createdAt).format("YYYY-MM-DD HH:mm:ss"),
|
||||
isPrint: false,
|
||||
count: `${count}/${sum}`,
|
||||
count: `${currentCount}/${totalCount}`,
|
||||
ticketLogo: store.shopInfo.ticketLogo,
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
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];
|
||||
return;
|
||||
}
|
||||
|
||||
const item = this.labelList[0];
|
||||
if (!item.isPrint) {
|
||||
ipcRenderer.send("printerTagSync", JSON.stringify(item));
|
||||
this.labelList[0].isPrint = true;
|
||||
this.labelList.splice(0, 1);
|
||||
}
|
||||
}
|
||||
}, 2000);
|
||||
},
|
||||
|
||||
// 打印交班小票(优化:1. 新增handoverSwitch=1才打印 2. 兼容局域网打印机)
|
||||
printWork(data) {
|
||||
// 筛选条件:
|
||||
// 1. 状态启用 + 小票类型 + handoverSwitch=1
|
||||
// 2. 打印机可用
|
||||
// 3. 打印服务正常
|
||||
// 筛选条件:状态启用 + 小票类型 + handoverSwitch=1 + 打印机可用 + 打印服务正常
|
||||
const validPrinters = this.deviceNoteList.filter(p => {
|
||||
return p.status
|
||||
&& p.subType === "cash"
|
||||
&& p.handoverSwitch === 1 // 新增:只有handoverSwitch为1的打印机才打印交班小票
|
||||
&& p.handoverSwitch === 1
|
||||
&& this.checkPrinterAvailable(p)
|
||||
&& this.isPrintService;
|
||||
});
|
||||
@@ -305,13 +305,11 @@ export const usePrint = defineStore("print", {
|
||||
try {
|
||||
// 区分局域网和USB打印机
|
||||
if (printer.connectionType === "局域网") {
|
||||
// 局域网打印机:使用networkPrint指令
|
||||
ipcRenderer.send('printHandoverReceipt', JSON.stringify({
|
||||
printerIp: printer.address,
|
||||
handoverData: printData
|
||||
}));
|
||||
} else {
|
||||
// USB打印机:使用原有LODOP方式
|
||||
lodopPrintWork(printData);
|
||||
}
|
||||
console.log("✅ 交班小票打印成功:", printer.address);
|
||||
@@ -322,22 +320,19 @@ export const usePrint = defineStore("print", {
|
||||
},
|
||||
|
||||
printInvoice(data) {
|
||||
if (
|
||||
this.deviceNoteList.length &&
|
||||
this.checkLocalPrint(this.deviceNoteList[0].address)
|
||||
) {
|
||||
data.deviceName = this.deviceNoteList[0].address;
|
||||
invoicePrint(data);
|
||||
} else {
|
||||
const validPrinter = this.deviceNoteList[0];
|
||||
if (!validPrinter || !this.checkLocalPrint(validPrinter.address)) {
|
||||
console.log("订单发票:未在本机查询到打印机");
|
||||
return;
|
||||
}
|
||||
|
||||
data.deviceName = validPrinter.address;
|
||||
invoicePrint(data);
|
||||
},
|
||||
// 退菜/退款
|
||||
|
||||
// 退款小票打印
|
||||
printRefund(data) {
|
||||
// 筛选条件:
|
||||
// 1. 状态启用 + 小票类型
|
||||
// 2. 打印机可用
|
||||
// 3. 打印服务正常
|
||||
// 筛选条件:状态启用 + 小票类型 + 打印机可用 + 打印服务正常
|
||||
const validPrinters = this.deviceNoteList.filter(p => {
|
||||
return p.status
|
||||
&& p.subType === "cash"
|
||||
@@ -367,13 +362,11 @@ export const usePrint = defineStore("print", {
|
||||
try {
|
||||
// 区分局域网和USB打印机
|
||||
if (printer.connectionType === "局域网") {
|
||||
// 局域网打印机:使用networkPrint指令
|
||||
ipcRenderer.send('printRefund', JSON.stringify({
|
||||
printerIp: printer.address,
|
||||
orderData: printData
|
||||
}));
|
||||
} else {
|
||||
// USB打印机:使用原有LODOP方式
|
||||
refundPrint(printData);
|
||||
}
|
||||
console.log("✅ 退单小票打印成功:", printer.address);
|
||||
@@ -381,6 +374,52 @@ export const usePrint = defineStore("print", {
|
||||
console.error("❌ 退单小票打印失败:", printer.address, error);
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
// 退菜小票打印
|
||||
printRefundDish(data) {
|
||||
// 筛选条件:状态启用 + 小票类型 + 打印机可用 + 打印服务正常
|
||||
const validPrinters = this.deviceNoteList.filter(p => {
|
||||
return p.status
|
||||
&& p.subType === "cash"
|
||||
&& this.checkPrinterAvailable(p)
|
||||
&& this.isPrintService;
|
||||
});
|
||||
|
||||
if (validPrinters.length === 0) {
|
||||
console.log("退菜:无符合条件的可用打印机");
|
||||
return;
|
||||
}
|
||||
|
||||
const store = useUser();
|
||||
// 遍历符合条件的打印机打印
|
||||
validPrinters.forEach(printer => {
|
||||
const printData = {
|
||||
...data,
|
||||
deviceId: printer.id,
|
||||
deviceName: printer.address,
|
||||
printerName: printer.name,
|
||||
connectionType: printer.connectionType,
|
||||
shop_name: store.shopInfo.shopName,
|
||||
loginAccount: store.userInfo.name,
|
||||
printTime: dayjs().format("YYYY-MM-DD HH:mm:ss"),
|
||||
};
|
||||
|
||||
try {
|
||||
// 区分局域网和USB打印机
|
||||
if (printer.connectionType === "局域网") {
|
||||
ipcRenderer.send('printRefundDish', JSON.stringify({
|
||||
printerIp: printer.address,
|
||||
orderData: printData
|
||||
}));
|
||||
} else {
|
||||
refundPrint(printData);
|
||||
}
|
||||
console.log("✅ 退菜小票打印成功:", printer.address);
|
||||
} catch (error) {
|
||||
console.error("❌ 退菜小票打印失败:", printer.address, error);
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
});
|
||||
@@ -112,11 +112,61 @@ export const useSocket = defineStore("socket", {
|
||||
switch (data.operate_type) {
|
||||
case "add":
|
||||
// 添加购物车商品
|
||||
{
|
||||
// console.log('socket终极操作数据.add===', data.data);
|
||||
const cartItem = goodsStore.cartList.find(item => item.id == data.data.id) || { number: 0 }
|
||||
// console.log('socket终极操作数据.cartItem===', cartItem);
|
||||
let arr = []
|
||||
goodsStore.orderList.forEach(item => {
|
||||
arr.push(...item.goods)
|
||||
})
|
||||
const isExist = _.some(arr, item => Number(item.productId) === data.data.product_id)
|
||||
|
||||
if (data.data.number == 1 && data.data.number > cartItem.number) {
|
||||
if (isExist) {
|
||||
ElMessage({
|
||||
type: 'warning',
|
||||
message: '该商品已下单过,请确认是否重复',
|
||||
duration: 4000
|
||||
})
|
||||
}
|
||||
}
|
||||
goodsStore.successAddCart(data.data);
|
||||
}
|
||||
break;
|
||||
case "edit":
|
||||
{
|
||||
// 编辑购物车商品
|
||||
// console.log('socket终极操作数据.edit===', data.data);
|
||||
|
||||
const cartItem = goodsStore.cartList.find(item => item.id == data.data.id)
|
||||
|
||||
// console.log('socket终极操作数据.cartItem===', cartItem);
|
||||
|
||||
let arr = []
|
||||
goodsStore.orderList.forEach(item => {
|
||||
arr.push(...item.goods)
|
||||
})
|
||||
const isExist = _.some(arr, item => Number(item.productId) === data.data.product_id)
|
||||
|
||||
if (data.data.number == 2 && data.data.number > cartItem.number) {
|
||||
if (isExist) {
|
||||
ElMessage({
|
||||
type: 'warning',
|
||||
message: '该商品已下单过,请确认是否重复',
|
||||
duration: 4000
|
||||
})
|
||||
} else {
|
||||
ElMessage({
|
||||
type: 'warning',
|
||||
message: '购物车已有该商品,请确认是否重复',
|
||||
duration: 4000
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
goodsStore.successEditCart(data.data);
|
||||
}
|
||||
break;
|
||||
case "del":
|
||||
// 删除购物车商品
|
||||
@@ -169,11 +219,17 @@ export const useSocket = defineStore("socket", {
|
||||
}
|
||||
}
|
||||
} else if (data.data_type == "order") {
|
||||
goodsStore.successClearCart();
|
||||
goodsStore.historyOrderAjax(data.data.table_code);
|
||||
this.cartInit();
|
||||
|
||||
|
||||
// 收到订单消息,打印订单小票
|
||||
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,6 +245,35 @@ 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();
|
||||
|
||||
@@ -184,12 +184,19 @@ export function commOrderPrintData(orderInfo) {
|
||||
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.productName,
|
||||
number: item.num,
|
||||
name: item.isGift === 1 ? `[赠]${item.productName}` : item.productName,
|
||||
number: item.num - item.returnNum,
|
||||
skuName: item.skuName,
|
||||
salePrice: formatDecimal(+item.price),
|
||||
salePrice: formatDecimal(+price),
|
||||
totalAmount: formatDecimal(+item.payAmount),
|
||||
proGroupInfo: item.proGroupInfo
|
||||
? item.proGroupInfo.map((item) => item.goods).flat()
|
||||
@@ -198,13 +205,19 @@ export function commOrderPrintData(orderInfo) {
|
||||
});
|
||||
} 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.productName,
|
||||
number: item.num,
|
||||
name: item.isGift === 1 ? `[赠]${item.productName}` : item.productName,
|
||||
number: item.num - item.returnNum,
|
||||
skuName: item.skuName,
|
||||
salePrice: formatDecimal(+item.price),
|
||||
totalAmount: formatDecimal(+item.payAmount),
|
||||
salePrice: formatDecimal(+price),
|
||||
totalAmount: formatDecimal((item.num - item.returnNum) * price),
|
||||
proGroupInfo: item.proGroupInfo
|
||||
? item.proGroupInfo.map((item) => item.goods).flat()
|
||||
: "",
|
||||
@@ -212,7 +225,8 @@ export function commOrderPrintData(orderInfo) {
|
||||
});
|
||||
}
|
||||
|
||||
if (orderInfo.seatAmount > 0) {
|
||||
if (orderInfo.dineMode == 'dine-in') {
|
||||
if (orderInfo.seatAmount > 0 && orderInfo.isGuest && orderInfo.placeNum == 1 && !orderInfo.isRefundDish) {
|
||||
data.carts.push({
|
||||
categoryId: '',
|
||||
name: '餐位费',
|
||||
@@ -224,11 +238,28 @@ export function commOrderPrintData(orderInfo) {
|
||||
})
|
||||
}
|
||||
|
||||
if (orderInfo.packFee > 0) {
|
||||
if (orderInfo.seatAmount > 0 && !orderInfo.isGuest && !orderInfo.isRefundDish) {
|
||||
data.carts.push({
|
||||
categoryId: '',
|
||||
name: '餐位费',
|
||||
number: orderInfo.seatNum,
|
||||
skuName: '',
|
||||
salePrice: formatDecimal(orderInfo.seatAmount / orderInfo.seatNum),
|
||||
totalAmount: orderInfo.seatAmount,
|
||||
proGroupInfo: "",
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
if (orderInfo.packFee > 0 && !orderInfo.isRefundDish) {
|
||||
let packNum = 0;
|
||||
orderInfo.cartList.forEach(item => {
|
||||
packNum += item.packNumber
|
||||
})
|
||||
data.carts.push({
|
||||
categoryId: '',
|
||||
name: '打包费',
|
||||
number: '',
|
||||
number: packNum,
|
||||
skuName: '',
|
||||
salePrice: '',
|
||||
totalAmount: formatDecimal(orderInfo.packFee),
|
||||
@@ -236,6 +267,7 @@ export function commOrderPrintData(orderInfo) {
|
||||
})
|
||||
}
|
||||
|
||||
console.log('最终组合打印数据===', data);
|
||||
return data;
|
||||
}
|
||||
|
||||
|
||||
@@ -248,6 +248,8 @@
|
||||
</div>
|
||||
</div>
|
||||
</el-dialog>
|
||||
<!-- 退款推库存的操作弹窗 -->
|
||||
<refundConsModal ref="refundConsModalRef" :list="refundList" @success="refundConsModalSuccess" />
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
@@ -262,11 +264,15 @@ import { inputFilterFloat, formatDecimal, getOrderByIdAjax, commOrderPrintData }
|
||||
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({
|
||||
@@ -315,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,
|
||||
@@ -335,29 +347,27 @@ 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
|
||||
console.log('originOrderInfo1===', originOrderInfo);
|
||||
|
||||
console.log('goodsStore.cartOrderItem.id', goodsStore.cartOrderItem.id);
|
||||
|
||||
let index = originOrderInfo.cartList.findIndex(item => item.id == goodsStore.cartOrderItem.id)
|
||||
|
||||
console.log('index===', index);
|
||||
|
||||
originOrderInfo.cartList = _.at(originOrderInfo.cartList, index);
|
||||
console.log('originOrderInfo2===', originOrderInfo);
|
||||
// return
|
||||
originOrderInfo.cartList[0].num = refundNum.value
|
||||
originOrderInfo.cartList[0].returnNum = 0
|
||||
originOrderInfo.cartList[0].payAmount = refundNum.value * originOrderInfo.cartList[0].price
|
||||
|
||||
printStore.printRefund(commOrderPrintData({ ...originOrderInfo, isGuest: false, isBefore: false, title: '退菜单' }));
|
||||
printStore.printRefundDish(commOrderPrintData({ ...originOrderInfo, isRefundDish: true }));
|
||||
}).catch(err => {
|
||||
console.log(err);
|
||||
})
|
||||
@@ -367,6 +377,51 @@ async function returnOrderItemAjax(num = 1) {
|
||||
}
|
||||
}
|
||||
|
||||
// 提交退菜
|
||||
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,57 @@ 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);
|
||||
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 +268,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 +305,14 @@ function paySuccess() {
|
||||
|
||||
const payCardRef = ref(null)
|
||||
function show(t) {
|
||||
goodsStore.payType = props.type
|
||||
dialogVisible.value = true;
|
||||
cartInfo.value = { ...goodsStore.cartInfo }
|
||||
if (props.type === 'table' || props.type === 'order') {
|
||||
orderList.value = goodsStore.orderList.map(item => item.goods).flat()
|
||||
} else {
|
||||
orderList.value = [...goodsStore.cartList, ...goodsStore.orderList.map(item => item.goods).flat()]
|
||||
}
|
||||
|
||||
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')
|
||||
}
|
||||
|
||||
|
||||
@@ -70,7 +70,7 @@
|
||||
<div class="left">
|
||||
<span>台桌:{{ goodsStore.tableInfo.name }}</span>
|
||||
<div class="n" @click="takeFoodCodeRef.show()">
|
||||
{{ goodsStore.tableInfo.num || 1 }}人
|
||||
{{ goodsStore.tableInfo.num || 0 }}人
|
||||
<el-icon>
|
||||
<EditPen />
|
||||
</el-icon>
|
||||
@@ -189,7 +189,7 @@
|
||||
</div>
|
||||
</div>
|
||||
<!-- 备注 -->
|
||||
<remarkModal ref="remarkRef" @success="(e) => (remark = e)" />
|
||||
<remarkModal ref="remarkRef" @success="(e) => (goodsStore.remark = e)" />
|
||||
<!-- 修改取餐号 -->
|
||||
<takeFoodCode />
|
||||
<el-drawer v-model="membershow" :with-header="true" size="90%" title="选择会员">
|
||||
@@ -197,7 +197,7 @@
|
||||
</el-drawer>
|
||||
<!-- <takeFoodCode ref="takeFoodCodeRef" title="修改取餐号" placeholder="请输入取餐号" @success="takeFoodCodeSuccess" /> -->
|
||||
<!-- 结算订单 -->
|
||||
<settleAccount ref="settleAccountRef" :cart="cartList" :amount="cartInfo.totalAmount" :remark="remark"
|
||||
<settleAccount ref="settleAccountRef" :cart="cartList" :amount="cartInfo.totalAmount" :remark="goodsStore.remark"
|
||||
:orderInfo="orderInfo" @success="" />
|
||||
<!-- 快捷收银 -->
|
||||
<fastCashier ref="fastCashierRef" type="0" />
|
||||
@@ -253,7 +253,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([]);
|
||||
@@ -310,7 +309,7 @@ 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, // 备注
|
||||
remark: goodsStore.remark, // 备注
|
||||
placeNum: placeNum + 1, // 下单次数
|
||||
waitCall: 0, // 是否叫号
|
||||
userId: goodsStore.vipUserInfo.userId || '', // 会员用户id
|
||||
@@ -331,16 +330,31 @@ async function createOrderHandle(t = 0) {
|
||||
} else {
|
||||
goodsStore.clearCart()
|
||||
// 开始打印客看单,可看单需要剔除其他历史下单
|
||||
getOrderByIdAjax(res.id).then(res => {
|
||||
let originOrderInfo = res
|
||||
originOrderInfo.detailMap = _.at(originOrderInfo.detailMap, placeNum + 1);
|
||||
// getOrderByIdAjax(res.id).then(res => {
|
||||
// let originOrderInfo = res
|
||||
// originOrderInfo.detailMap = _.at(originOrderInfo.detailMap, placeNum + 1);
|
||||
|
||||
console.log('originOrderInfo', originOrderInfo);
|
||||
// console.log('originOrderInfo', originOrderInfo);
|
||||
|
||||
printStore.pushReceiptData(commOrderPrintData({ ...originOrderInfo, isGuest: true, isBefore: true }));
|
||||
}).catch(err => {
|
||||
console.log(err);
|
||||
})
|
||||
// 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()
|
||||
|
||||
@@ -30,11 +30,16 @@
|
||||
<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="150">
|
||||
<el-table-column label="到期时间" prop="expTime"></el-table-column>
|
||||
<el-table-column label="操作" width="250">
|
||||
<template #default="{ row }">
|
||||
<el-button type="danger" :disabled="row.num <= 0"
|
||||
@click="takeWineDialogVisible = true; maxTakeNum = row.num; takeWineForm.id = row.id;">取酒</el-button>
|
||||
<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>
|
||||
@@ -85,12 +90,19 @@
|
||||
</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 } from '@/api/product_new'
|
||||
import { shopStoragePost, storageGoodGet, shopStorageGet, shopStoragePut, shopStorageRecord } from '@/api/product_new'
|
||||
|
||||
const props = defineProps({
|
||||
userInfo: {
|
||||
@@ -214,6 +226,30 @@ function init() {
|
||||
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;
|
||||
|
||||
@@ -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,42 +182,84 @@ 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 {
|
||||
pwd.value = e
|
||||
loading.value = true
|
||||
let rows = tableRef.value.getSelectionRows()
|
||||
let refundDetails = []
|
||||
if (refundType.value != 1) {
|
||||
refundDetails = tableRef.value.getSelectionRows().map(val => {
|
||||
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
|
||||
}
|
||||
}
|
||||
|
||||
// 显示手动退款
|
||||
function handleRefund() {
|
||||
@@ -269,7 +325,7 @@ async function printRefund(rows) {
|
||||
orderInfo: item.value,
|
||||
outNumber: item.value.id,
|
||||
createdAt: item.value.createTime,
|
||||
refundMethod: cash.value ? '现金' : '原路退回',
|
||||
refundMethod: cash.value ? '线下退款' : '原路退回',
|
||||
printTime: dayjs().format("YYYY-MM-DD HH:mm:ss"),
|
||||
}
|
||||
|
||||
@@ -277,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)
|
||||
}
|
||||
)
|
||||
})
|
||||
@@ -288,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);
|
||||
@@ -339,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 = []
|
||||
@@ -347,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 {
|
||||
// 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)
|
||||
// }
|
||||
// 可以操作的退款数量
|
||||
item.refund_number = item.num
|
||||
if (refundMaxNum > 0) {
|
||||
onGoods.push(item)
|
||||
} else {
|
||||
returnGoods.push(item)
|
||||
}
|
||||
})
|
||||
|
||||
@@ -363,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>
|
||||
|
||||
@@ -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
|
||||
}
|
||||
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 {
|
||||
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
|
||||
|
||||
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) {
|
||||
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,17 +495,37 @@ 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_wrap {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
|
||||
.icon {
|
||||
color: var(--color);
|
||||
font-size: 30px;
|
||||
@@ -325,6 +534,29 @@ onMounted(() => {
|
||||
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,26 +179,18 @@ 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)
|
||||
|
||||
const res = '136'
|
||||
const data = { "accountType": "merchant", "alipayAmount": 0, "cashAmount": 38.5, "categoryDataList": [{ "amount": 8.7, "categoryId": "614", "categoryName": "主食", "num": 3, "quantity": 1 }, { "amount": 29.8, "categoryId": "615", "categoryName": "炒菜", "num": 5, "quantity": 4 }], "creditAmount": 0, "handAmount": 38.5, "handoverTime": "2026-04-02 18:19:45", "id": "136", "loginTime": "2026-04-02 18:17:57", "orderCount": 1, "productDataList": [{ "amount": 8.7, "num": 3, "productId": "4037", "productName": "金镶白玉板", "skuId": "6727", "skuName": "" }, { "amount": 8.8, "num": 1, "productId": "4039", "productName": "雪底红梅", "skuId": "6729", "skuName": "" }, { "amount": 1.2, "num": 1, "productId": "4045", "productName": "清蒸鲈鱼", "skuId": "6738", "skuName": "微辣,中度酸" }, { "amount": 2, "num": 1, "productId": "4046", "productName": "四喜丸子", "skuId": "6741", "skuName": "" }, { "amount": 17.8, "num": 2, "productId": "4295", "productName": "小烤串", "skuId": "6990", "skuName": "" }], "quickInAmount": 0, "refundAmount": 0, "shopId": "151", "shopName": "高歌的小店", "staffId": "151", "staffName": "高歌的小店", "vipPay": 0, "vipRecharge": 0, "wechatAmount": 0 }
|
||||
|
||||
// console.log('res===', JSON.stringify(res));
|
||||
// console.log('data===', JSON.stringify(data));
|
||||
|
||||
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
|
||||
}
|
||||
// logoutHandle()
|
||||
// else {
|
||||
// // 使用云打印机 打印交班数据
|
||||
// await handoverNetworkPrint(data.id)
|
||||
// }
|
||||
logoutHandle()
|
||||
loading.value = false;
|
||||
} catch (error) {
|
||||
loading.value = false;
|
||||
|
||||
Reference in New Issue
Block a user