# 拣货单模板(148mm × 210mm)设计与实施 > 使用场景:`/order/waveOrder` —— **团购波次**、**散单波次** 页面的「批量打印拣货单」。 > 涉及代码:`GroupWaveBatchListPanel.vue` / `SandanWaveBatchListPanel.vue`(`business-type="PICKING"`) > → `components/BatchReceivingPrintDialog.vue` → `utils/printPaginate.ts` ## 一、数据来源与可选字段 `openBatchPrintDialog` 组装出的打印数据(`wavePrintDataMap[wave_id]`): ``` form = { ...首个订单(normalizePrintOrder 后), // 含 address / express_code / waybill_code / create_at ... wave_no, details: [全部订单(normalizePrintOrder 后)] } ``` `normalizePrintOrder` 会补:`address`(省市区镇+详细地址拼接)、`express_code`(多来源回退)、 `waybill_code`(= express_code)、`create_at`、`order_create_time`、`print_time`。 | 位置 | 可用字段 | | --- | --- | | 单据头(顶层) | `wave_no`、`sys_platform_name`、`sys_logistics_name`、`create_at`、`print_time`(自动)、`remark`、`delivery_order_code` 等订单字段(取首单) | | 明细表(`details` 每行) | `delivery_order_code`、`express_code`/`waybill_code`、`name`(收件人)、`mobile`、`province`、`city`、`area`、`items_total`、`items_weight`、`remark` | ⚠️ 限制: - 表格**没有行号变量**,不要设计「序号」列(会整列为空)。 - 波次打印的 `details` 是**订单维度**,不是商品维度 —— 无法在模板里输出商品明细。 - 表格单元格固定 `text-align: center`(渲染代码写死),`textAlign` 只对普通 text 生效。 - 分隔线/签字线必须是 `type: "shape"` + `shapeType: "line"`;旧模板的 `type: "line"` 不渲染。 - 分页截止线 = 表格下方**最近的 text 元素 top**(本模板 = 备注行 179mm,表格 top 61、表头 6mm)→ 每页约 18 行。 ## 二、生产环境原始数据备份(改动前) `wms.wms.gztbyc.com` · `wms_print_template` · **id = 16** ```json { "id": 16, "template_name": "拣货单", "platform": "default", "template_type": "CUSTOM", "template_url": "NONE", "template_content": [], "page_width": 76, "page_height": 130, "warehouse_id": null, "is_default": false, "status": "ACTIVE", "create_at": "2026-05-11T14:23:06.000Z", "update_at": "2026-05-11T14:23:06.000Z", "business_type": "PICKING", "delete_at": null, "editable": false, "deletable": false, "isGeneral": true } ``` > 回滚:`page_width=76, page_height=130, template_content=[]` > 说明:`warehouse_id=null` + `isGeneral=true` → 后端返回 `editable:false`,页面「编辑」按钮隐藏,只能改库/接口。 ## 三、版式设计(A5 纵向 148×210,页边距 10mm,内容宽 128mm) | # | 元素 | top | left | 宽 | 高 | 内容/字段 | | --- | --- | --- | --- | --- | --- | --- | | 1 | 标题 18pt 粗 居中 | 6 | 0 | 148 | 10 | 拣 货 单 | | 2 | 横线 | 17.5 | 10 | 128 | 1 | | | 3 | 波次号: 10pt | 21 | 10 | 20 | 7 | 静态文字 | | 4 | 波次号值 13pt 粗 | 21 | 30 | 60 | 7 | `wave_no` | | 5 | 平台: 10pt | 21 | 92 | 12 | 7 | 静态文字 | | 6 | 平台值 10pt | 21 | 104 | 34 | 7 | `sys_platform_name` | | 7 | 物流公司: 10pt | 30 | 10 | 24 | 7 | 静态文字 | | 8 | 物流公司值 10pt | 30 | 34 | 56 | 7 | `sys_logistics_name` | | 9 | 创建时间: 10pt | 39 | 10 | 24 | 7 | 静态文字 | | 10 | 创建时间值 10pt | 39 | 34 | 56 | 7 | `create_at` | | 11 | 波次号条码(44×10,靠右) | 29 | 94 | 44 | 10 | `wave_no`(Code128) | | 12 | 横线 | 48 | 10 | 128 | 1 | | | 13 | 「订单明细」12pt 粗 | 51 | 10 | 60 | 8 | | | 14 | 表格(订单明细) | 61 | 10 | 128 | 110 | 行高/表头 6mm,9pt | | 15 | 横线 | 176 | 10 | 128 | 1 | | | 16 | 备注: 9pt | 179 | 10 | 14 | 6 | 静态文字 | | 17 | 备注值 9pt 自动换行 | 179 | 24 | 114 | 10 | `remark` | | 18 | 打印时间: 9pt | 191 | 10 | 24 | 6 | 静态文字 | | 19 | 打印时间值 9pt | 191 | 34 | 46 | 6 | `print_time`(弹窗自动填) | | 20 | 拣货人: 9pt | 199 | 10 | 20 | 6 | 静态文字 | | 21 | 拣货人签字线 | 205 | 10 | 38 | 1 | | | 22 | 复核人: 9pt | 199 | 68 | 20 | 6 | 静态文字 | | 23 | 复核人签字线 | 205 | 68 | 34 | 1 | | 表格列(合计 128mm): | 列 | 宽 | 字段 | | --- | --- | --- | | 订单号 | 38 | `delivery_order_code` | | 物流单号 | 44 | `express_code` | | 收件人 | 20 | `name` | | 件数 | 12 | `items_total` | | 省份 | 14 | `province` | > 条码元素内容 = `wave_no`(Code128),仅用于手持枪快速定位波次;若仓库不需要扫码,可在编辑器里直接删掉该元素,或改小到 30×8mm。 > > 若不想打印条码,也可换成二维码(`type: "qrcode"`,同样取 `wave_no`)。 ## 四、模板内容 JSON 见同目录 `拣货单模板-148x210.json`。 ## 五、写回方式与实测结论 ### 5.1 接口不可用(生产环境实测 2026-11-19) | 试探 | 结果 | | --- | --- | | `setting.printTemplate.save` 写 id=16(148×210 + 新内容) | `code:500 保存打印模板失败` | | `setting.printTemplate.save` 写 id=16(76×130 + `[]`,完全无变化) | `code:500 保存打印模板失败` | | `setting.printTemplate.save` 写 id=17(原样回存) | `code:200 模板更新成功` | | `setting.printTemplate.update` / `.get` | `code:500 接口错误: 方法 update/get 不存在` | 结论:**不是内容校验问题**,而是 `warehouse_id IS NULL` 的「通用预设」被后端保护 (`isGeneral:true` → `editable:false` / `deletable:false`),接口层面无法写入。 生产环境只能走**直接改库**。 > 若希望生产也能在页面上编辑:把该模板 `warehouse_id` 绑到具体仓库(语义会从「全仓通用」变为「某仓专用」),或另建一条自定义模板。 ### 5.2 开发库已写入 `192.168.11.56:3307` / `wms` / `wms_print_template` id=16: ```sql UPDATE wms_print_template SET page_width = 148, page_height = 210, template_content = '' WHERE id = 16 AND business_type = 'PICKING' AND JSON_VALID(template_content); ``` 结果:`affectedRows=1`,回读 `page_width=148`、`page_height=210`、`JSON_VALID=1`、`JSON_LENGTH=23`。 ### 5.3 生产库待执行(需有库权限) ```sql -- 备份 SELECT id, template_name, page_width, page_height, warehouse_id, template_content FROM wms_print_template WHERE id = 16; -- 写入(template_content 取 docs/拣货单模板-148x210.json 的单行 JSON) UPDATE wms_print_template SET page_width = 148, page_height = 210, template_content = '' WHERE id = 16 AND business_type = 'PICKING' AND warehouse_id IS NULL; -- 校验 SELECT id, template_name, page_width, page_height, JSON_VALID(template_content) AS valid, JSON_LENGTH(template_content) AS el_cnt FROM wms_print_template WHERE id = 16; ``` 回滚: ```sql UPDATE wms_print_template SET page_width = 76, page_height = 130, template_content = '[]' WHERE id = 16; ``` ### 5.4 生产环境遗留问题(与本模板无关,建议一并处理) 生产 id=17「拣货单模板」(148×210,warehouse 1000028)里当前是**备货单版式**(上次迁移时写入), 名称与内容不一致;需要确认是改名成「备货单」还是清空/重写。