fix(delivery-note): 无生产时间数据时整列不渲染
后端未下发 batch_production_dates 或整单没有日期 ⇒ 退回原 7 列 版式(列宽恢复 70/300/70/110/110/130/130);部分行有日期时 才出该列,无日期的行留空。
This commit is contained in:
@@ -9,6 +9,7 @@
|
||||
* · 不显示「收款记录」(2026-10-15 开发者裁决:库里只有结算单级收款,不编数字)
|
||||
* · 商品名取**下单原文** `item_name`(口径甲,2026-10-15 裁决)
|
||||
* · 生产时间取自出库流水的批次(2026-10-20):未出库就没有流水 ⇒ 该格留空,**不猜批次**
|
||||
* · **保险**:后端没下发该字段(或整单没有任何生产日期)⇒ **整列不渲染**、退回原 7 列版式
|
||||
*
|
||||
* 复用 `a4HistoryPrint` 的 canvas 取节点/导出套路(小程序原有先例)。
|
||||
* 设计:docs/design/20261015-小程序送货单图片(canvas出图分享).md
|
||||
@@ -26,9 +27,11 @@ const ROW_V_PAD = 14; // 多行格子的上下留白(行高 = 行数 * LINE_H
|
||||
const FONT = '22px sans-serif';
|
||||
const FONT_BOLD = 'bold 22px sans-serif';
|
||||
|
||||
/** 列宽:编号/产品/单位/总数量/单价/金额/生产时间/备注(合计 = W - 2*MARGIN = 920) */
|
||||
function columns() {
|
||||
const widths = [60, 220, 60, 90, 100, 110, 150, 130];
|
||||
/** 列宽:8 列(含生产时间)/ 7 列(保险:无生产时间数据时退回原版式),合计均为 W - 2*MARGIN = 920 */
|
||||
function columns(showProduction) {
|
||||
const widths = showProduction
|
||||
? [60, 220, 60, 90, 100, 110, 150, 130]
|
||||
: [70, 300, 70, 110, 110, 130, 130];
|
||||
let x = MARGIN;
|
||||
return widths.map((w) => {
|
||||
const col = { x, w };
|
||||
@@ -125,7 +128,10 @@ function drawDeliveryNote(canvas, note) {
|
||||
ctx.fillText('客户:' + String(note.customer_name || ''), MARGIN, 142);
|
||||
|
||||
// ── 表格 ──
|
||||
const cols = columns();
|
||||
// 保险(2026-10-20):后端没下发 `batch_production_dates`(老版服务端)或整单没有任何日期
|
||||
// ⇒ **不渲染生产时间列**,退回原 7 列版式(不让客户看到一整列空白)。
|
||||
const showProduction = items.some((item) => productionDateLines(item).length > 0);
|
||||
const cols = columns(showProduction);
|
||||
const tableRight = W - MARGIN;
|
||||
let y = 172;
|
||||
|
||||
@@ -171,33 +177,31 @@ function drawDeliveryNote(canvas, note) {
|
||||
y += rowH;
|
||||
};
|
||||
|
||||
drawRow(['编号', '产品', '单位', '总数量', '单价', '金额', '生产时间', '备注'], {
|
||||
bold: true,
|
||||
fill: '#f3f4f6',
|
||||
});
|
||||
const header = ['编号', '产品', '单位', '总数量', '单价', '金额'];
|
||||
if (showProduction) header.push('生产时间');
|
||||
header.push('备注');
|
||||
drawRow(header, { bold: true, fill: '#f3f4f6' });
|
||||
|
||||
items.forEach((item, index) => {
|
||||
drawRow(
|
||||
[
|
||||
index + 1,
|
||||
item.item_name,
|
||||
item.unit,
|
||||
qtyText(item.quantity),
|
||||
money(item.price),
|
||||
money(item.amount),
|
||||
productionDateLines(item),
|
||||
item.remark || '',
|
||||
],
|
||||
{ rowH: rowHeightFor(item) }
|
||||
);
|
||||
const cells = [
|
||||
index + 1,
|
||||
item.item_name,
|
||||
item.unit,
|
||||
qtyText(item.quantity),
|
||||
money(item.price),
|
||||
money(item.amount),
|
||||
];
|
||||
if (showProduction) cells.push(productionDateLines(item));
|
||||
cells.push(item.remark || '');
|
||||
drawRow(cells, { rowH: rowHeightFor(item) });
|
||||
});
|
||||
|
||||
const totalQty = sumBy(items, (item) => item.quantity);
|
||||
const totalAmount = sumBy(items, (item) => item.amount);
|
||||
drawRow(['', '合计', '', qtyText(totalQty), '', money(totalAmount), '', ''], {
|
||||
bold: true,
|
||||
fill: '#f3f4f6',
|
||||
});
|
||||
const totalCells = ['', '合计', '', qtyText(totalQty), '', money(totalAmount)];
|
||||
if (showProduction) totalCells.push('');
|
||||
totalCells.push('');
|
||||
drawRow(totalCells, { bold: true, fill: '#f3f4f6' });
|
||||
|
||||
// ── 汇总 + 金额大写 ──
|
||||
y += 34;
|
||||
|
||||
Reference in New Issue
Block a user