diff --git a/other-module/canteen-device/checkout-device/02-print-receipt.html b/other-module/canteen-device/checkout-device/02-print-receipt.html index 770bb46..5930bcd 100644 --- a/other-module/canteen-device/checkout-device/02-print-receipt.html +++ b/other-module/canteen-device/checkout-device/02-print-receipt.html @@ -217,6 +217,25 @@ } .receipt-stage::-webkit-scrollbar { display: none; } + /* 双版本对比容器 */ + .receipt-compare { + display: flex; + gap: 32px; + align-items: flex-start; + justify-content: center; + } + .receipt-compare__col { + display: flex; + flex-direction: column; + align-items: center; + gap: 12px; + } + .receipt-compare__label { + font-size: 12px; + color: rgba(255, 255, 255, 0.45); + letter-spacing: 0.5px; + } + /* 热敏小票纸 */ .receipt-paper { width: 300px; @@ -393,6 +412,9 @@ font-weight: 700; color: #1a1a2e; } + .receipt-score__value--text { + font-size: 12px; + } /* 双二维码并排 */ .receipt-qr--dual { @@ -576,7 +598,7 @@ id: 'CO-20260803-001', mealType: 'lunch', mealLabel: '午餐', - line: 'A 区 1 号餐线', + line: '一楼', cashier: '张三', time: '2026-08-03 12:15:30', payTime: '2026-08-03 12:15:35', @@ -596,7 +618,7 @@ id: 'CO-20260803-008', mealType: 'breakfast', mealLabel: '早餐', - line: 'A 区 1 号餐线', + line: '一楼', cashier: '张三', time: '2026-08-03 07:42:18', payTime: '2026-08-03 07:42:23', @@ -634,7 +656,7 @@ id: 'CO-20260803-022', mealType: 'dinner', mealLabel: '晚餐', - line: 'A 区 1 号餐线', + line: '一楼', cashier: '王五', time: '2026-08-03 18:15:20', payTime: '2026-08-03 18:15:25', @@ -688,8 +710,8 @@ /* 食堂抬头 */ var canteenInfo = { - name: 'CQ 能源公司员工食堂', - address: '重庆市渝北区星光大道 88 号', + name: '数味餐厅', + address: '陕西省西安市浐灞生态区欧亚大道3639号', phone: '023-7788-XXXX' }; @@ -745,109 +767,135 @@ return; } - /* 按分区分组渲染 */ + /* 按分区分组 */ var zoneOrder = ['营养秤', '档口秤']; var zones = {}; order.items.forEach(function(it) { if (!zones[it.zone]) zones[it.zone] = []; zones[it.zone].push(it); }); - var itemsHtml = ''; - zoneOrder.forEach(function(zoneName) { - var zoneItems = zones[zoneName]; - if (!zoneItems || zoneItems.length === 0) return; - itemsHtml += '【' + zoneName + '】'; - zoneItems.forEach(function(it) { - /* 小计 = 餐品克重 ÷ 100 × 单价(100g) */ - var subtotal = it.weight / 100 * it.price; - itemsHtml += '' - + '' + it.name + '(' + it.weight + 'g)' - + '' + it.price.toFixed(2) + '' - + '' + it.qty + '' - + '' + subtotal.toFixed(2) + '' - + ''; + + /* 构建商品行HTML - 版本一:价格不含¥,重量不含g; 版本二:价格含¥,重量含g */ + function buildItemsHtml(isV2) { + var html = ''; + zoneOrder.forEach(function(zoneName) { + var zoneItems = zones[zoneName]; + if (!zoneItems || zoneItems.length === 0) return; + /* 分区名称映射: 营养秤→餐线, 档口秤→档口 */ + var zoneLabel = zoneName === '营养秤' ? '餐线' : (zoneName === '档口秤' ? '档口' : zoneName); + html += '【' + zoneLabel + '】'; + zoneItems.forEach(function(it) { + /* 小计 = 餐品克重 ÷ 100 × 100克单价 */ + var subtotal = it.weight / 100 * it.price; + html += '' + + '' + it.name + '' + + '' + (isV2 ? '¥' : '') + it.price.toFixed(2) + '' + + '' + it.weight + (isV2 ? 'g' : '') + '' + + '' + (isV2 ? '¥' : '') + subtotal.toFixed(2) + '' + + ''; + }); }); - }); + return html; + } - var discountRow = order.discount > 0 - ? '
优惠-' + order.discount.toFixed(2) + '
' - : ''; + /* 构建完整小票纸张HTML */ + function buildReceiptPaper(isV2) { + var itemsHtml = buildItemsHtml(isV2); + var discountRow = order.discount > 0 + ? '
优惠-¥' + order.discount.toFixed(2) + '
' + : ''; + /* 营养得分: 82分统一显示为"继续努力" */ + var scoreText = order.nutrition.score === 82 ? '继续努力' : order.nutrition.score; + return '' + + '
' + /* 食堂抬头 */ + + '
' + + '
' + canteenInfo.name + '
' + + '
' + canteenInfo.address + '
' + + '
电话:' + canteenInfo.phone + '
' + + '
' + + '
' + /* 订单信息 */ + + '
' + + '
订单号' + order.id + '
' + + '
餐线' + order.line + '
' + + '
收银员' + order.cashier + '
' + + '
就餐时间' + order.time + '
' + + '
付款时间' + order.payTime + '
' + + '
' + + '
' + /* 消费明细表 */ + + '' + + '' + + '' + itemsHtml + '' + + '
餐品单价/100g' + (isV2 ? '' : '(元)') + '取用量(g)小计
' + + '
' + /* 金额汇总 */ + + '
' + + '
合计¥' + order.total.toFixed(2) + '
' + + discountRow + + '
应付¥' + order.payable.toFixed(2) + '
' + + '
实付¥' + order.paid.toFixed(2) + '
' + + '
' + + '
' + /* 支付信息 */ + + '
' + + '
支付类型' + order.payType + '
' + + '
支付方式' + order.payMethod + '
' + /* 仅会员支付订单展示餐卡余额 */ + + (order.payType === '会员支付' + ? '
餐卡余额¥' + order.balance.toFixed(2) + '
' + : '') + + '
' + + '
' + /* 营养摄入摘要 */ + + '
- - - ' + (isV2 ? '营养素摄入量 / 餐' : '营养摄入摘要') + ' - - -
' + + '
' + + '
热量
' + order.nutrition.calories + 'kcal
' + + '
蛋白质
' + order.nutrition.protein + 'g
' + + '
脂肪
' + order.nutrition.fat + 'g
' + + '
碳水
' + order.nutrition.carb + 'g
' + + '
' + + '
' + + '营养得分' + + '' + scoreText + '' + + '
' + + '
' + /* 二维码 */ + + '
' + + '
' + + getQRCodeEnterpriseSVG() + + '
扫码加入企业微信群
' + + '
获取营养知识与优惠活动
' + + '
' + + '
' + + getQRCodeMiniProgramSVG() + + '
扫码进入小程序
' + + '
查看详细营养分析报告
' + + '
' + + '
' + + '
' + /* 底部提示 */ + + '' + + '
'; + } + + /* 并排展示两个版本 */ var html = '' - + '
' - /* 食堂抬头 */ - + '
' - + '
' + canteenInfo.name + '
' - + '
' + canteenInfo.address + '
' - + '
电话:' + canteenInfo.phone + '
' - + '
' - + '
' - /* 订单信息 */ - + '
' - + '
订单号' + order.id + '
' - + '
餐线' + order.line + '
' - + '
收银员' + order.cashier + '
' - + '
就餐时间' + order.time + '
' - + '
付款时间' + order.payTime + '
' - + '
' - + '
' - /* 消费明细表 */ - + '' - + '' - + '' + itemsHtml + '' - + '
餐品单价(100g)份数小计
' - + '
' - /* 金额汇总 */ - + '
' - + '
合计' + order.total.toFixed(2) + '
' - + discountRow - + '
应付¥' + order.payable.toFixed(2) + '
' - + '
实付¥' + order.paid.toFixed(2) + '
' - + '
' - + '
' - /* 支付信息 */ - + '
' - + '
支付类型' + order.payType + '
' - + '
支付方式' + order.payMethod + '
' - /* 仅会员支付订单展示餐卡余额 */ - + (order.payType === '会员支付' - ? '
餐卡余额¥' + order.balance.toFixed(2) + '
' - : '') - + '
' - + '
' - /* 营养摄入摘要 */ - + '
- - - 营养摄入摘要 - - -
' - + '
' - + '
热量
' + order.nutrition.calories + 'kcal
' - + '
蛋白质
' + order.nutrition.protein + 'g
' - + '
脂肪
' + order.nutrition.fat + 'g
' - + '
碳水
' + order.nutrition.carb + 'g
' - + '
' - + '
' - + '营养得分' - + '' + order.nutrition.score + '' - + '
' - + '
' - /* 二维码 */ - + '
' - + '
' - + getQRCodeEnterpriseSVG() - + '
扫码加入企业微信群
' - + '
获取营养知识与优惠活动
' + + '
' + + '
' + + '
版本一(价格不含¥ · 重量不含g)
' + + buildReceiptPaper(false) + '
' - + '
' - + getQRCodeMiniProgramSVG() - + '
扫码进入小程序
' - + '
查看详细营养分析报告
' + + '
' + + '
版本二(价格含¥ · 重量含g)
' + + buildReceiptPaper(true) + '
' - + '
' - + '
' - /* 底部提示 */ - + '' - + '
'; + + '
'; document.getElementById('receiptStage').innerHTML = html; updatePrintBtn(); diff --git a/other-module/canteen-device/checkout-device/doc/CHANGELOG.md b/other-module/canteen-device/checkout-device/doc/CHANGELOG.md index 9a0dff2..792bbe6 100644 --- a/other-module/canteen-device/checkout-device/doc/CHANGELOG.md +++ b/other-module/canteen-device/checkout-device/doc/CHANGELOG.md @@ -1,5 +1,18 @@ # 结算设备 CHANGELOG +## 2026-08-05 | 小票双版本对比展示与格式优化 + +### 变更 +- `02-print-receipt.html` 小票预览改为双版本并排对比展示 + - **版本一**:价格不含 ¥,重量不含 g,表头显示"单价/100g(元)" + - **版本二**:价格含 ¥,重量含 g,小计含 ¥,表头显示"单价/100g" + - 分区名称映射:营养秤→餐线、档口秤→档口 + - 餐厅名称改为"数味餐厅",地址改为陕西省西安市浐灞生态区欧亚大道3639号 + - 餐线名称改为"一楼" + - 营养得分 82 分统一显示为"继续努力"(字号缩小至 12px) + - 合计/优惠金额全局加 ¥ 符号 + - 版本二营养标题改为"营养素摄入量 / 餐" + ## 2026-08-04 | 小票金额计算与支付信息优化 ### 变更