From b0512d33087a9493c299821db5d76b98785e35ef Mon Sep 17 00:00:00 2001 From: yin <3313488199@qq.com> Date: Thu, 27 Aug 2026 18:11:02 +0800 Subject: [PATCH] 1 --- docs/出库单批量打印-商品明细分页设计.md | 191 ++++++++++ out.txt | 1 + server.txt | 85 +---- src/api/order.index/orderindex.ts | 6 + src/api/order/order.ts | 10 +- src/api/storage.entry/entry.ts | 12 + src/api/storage.management/management.ts | 5 + src/components/BatchReceivingPrintDialog.vue | 253 ++++++++----- src/components/ScanBox/index.vue | 6 + src/components/UpperTable/index.vue | 2 +- src/composables/useOrderAsyncExport.ts | 3 + src/utils/printPaginate.ts | 197 +++++++++++ .../order/orderManagement/archiveOrder.vue | 20 +- .../component/OrderExportColumnsDialog.vue | 332 ++++++++++++++++++ .../config/order-common-config.ts | 132 ++++++- .../orderManagement/deliveryException.vue | 20 +- .../order/orderManagement/deliveryOrder.vue | 20 +- .../orderManagement/entrustWarehouse.vue | 20 +- .../order/orderManagement/exceptionOrder.vue | 20 +- .../order/orderManagement/outboundOrder.vue | 20 +- .../order/orderManagement/pendingOrder.vue | 20 +- .../order/orderManagement/reviewOrder.vue | 20 +- .../utils/order-index-helpers.ts | 22 +- .../utils/order-page-export.ts | 83 ++++- .../orderManagement/utils/toolbar-actions.ts | 14 +- .../order/waveOrder/config/wave-config.ts | 16 +- .../component/BindReceivingToEntryDialog.vue | 168 ++++++--- src/views/storage/entry/entry-config.ts | 5 +- .../management/replenishmentDemand/index.vue | 115 +++++- .../replenishment-demand-config.ts | 16 + src/views/storage/stockout/index.vue | 39 +- src/views/storage/stockout/stockout-config.ts | 6 +- src/views/store/stores/index.vue | 8 +- 33 files changed, 1612 insertions(+), 275 deletions(-) create mode 100644 docs/出库单批量打印-商品明细分页设计.md create mode 100644 out.txt create mode 100644 src/utils/printPaginate.ts create mode 100644 src/views/order/orderManagement/component/OrderExportColumnsDialog.vue diff --git a/docs/出库单批量打印-商品明细分页设计.md b/docs/出库单批量打印-商品明细分页设计.md new file mode 100644 index 00000000..f3f6a3bc --- /dev/null +++ b/docs/出库单批量打印-商品明细分页设计.md @@ -0,0 +1,191 @@ +# 出库单批量打印 —— 商品明细分页设计 + +> 状态:已实施(2026-08-27) +> 日期:2026-08-27 +> 相关页面:`storage/stockout` 批量打印出库单(`BatchReceivingPrintDialog.vue`) +> 相关模板:出库单A5模板(`template_18`,OUTBOUND,148mm × 210mm) + +## 1. 背景与目标 + +批量打印出库单时,商品明细可能很多,且商品名称长短不一导致行高不固定。当前模板对「商品明细」表格不做任何分页/裁剪处理,内容一多就会**向下压过「备注」「打印时间」等固定元素,甚至溢出页面**。 + +**目标**: +- 商品明细表格内容到达「备注」位置(截止线)后,将剩余明细**自动拆分到第 2、3…N 页**打印。 +- 分页数量**不按固定行数**,而是**按每行的实际渲染高度动态计算**。 +- 打印台(`print.send`)与浏览器打印**两条通道都要支持**,且都采用**前端逐页发任务**的方式。 +- 第 2 页起**重复单据头**,并通过单据头(出库单号)确认多页属于同一张出库单、同一批次。 + +## 2. 现状与问题定位 + +### 2.1 打印链路 + +```mermaid +flowchart LR + A[stockout/index.vue
选择多张已完成出库单] --> B[BatchReceivingPrintDialog.vue] + B --> C[fetchPrintData
获取单据头 + details 明细] + C --> D[预览 .preview-page 单页渲染] + C --> E[doPrint 打印台通道
print.send customize] + C --> F[browserPrint 浏览器通道
拷贝 preview-page 到新窗口] +``` + +- `doPrint()`:构造 `PrintSendCustomizeParams`(`type:'customize'` + `computerId` + `printer` + `template` + `data` + `count`),调用 `stationApi.sendPrint()`,由**打印台客户端**渲染。 +- `browserPrint()`:把当前 `.preview-page` 的 `outerHTML` 写入新窗口后 `print()`。 +- 两条通道目前都只能表达「一张单、一页」。 + +### 2.2 模板布局(出库单A5,148×210mm) + +| 区域 | 元素 | top(mm) | 说明 | +|---|---|---|---| +| 单据头 | 出库单号/波次号/创建时间/快递公司/运单号/收件人/地址… | 4 ~ 74 | 每页要重复的部分 | +| 商品明细 | `table`(type=table) | 77 | 表头高 `headerHeight`=6,行高 `rowHeight`=6 | +| 截止线 | 分割线 / **备注** | 154 / **158** | 表格不得越过此线 | +| 页脚 | 打印时间 | 166 | 仅最后一页显示 | + +表格列:商品编码 `item_code`(22) / 商品名称 `item_name`(40) / 数量 `plan_qty`(18) / 单价 `actual_price`(20) / 明细备注 `detail_remark`(28),合计 128mm。 + +### 2.3 问题根因 + +- `computePreviewItemStyle()` 对 `type==='table'` 设置 `width/height: auto`,表格高度完全由 `details` 行数 + 每行实际换行高度决定,**不裁剪、不分页**。 +- 表格 `top=77`、截止线 `158`,单页数据区可用高度固定 ≈ `158 − 77 − 6 = 75mm`。 +- 行高不固定:商品名称列宽 40mm、字号约 3mm(≈13 字/行),名称超长换行后该行高度 = `换行行数 × rowHeight`,所以**不能按固定行数拆页**。 + +## 3. 总体方案 + +**核心思路:前端按「实际渲染高度」动态切分明细 → 一张出库单生成多页 → 前端逐页发送(打印台逐次 sendPrint / 浏览器逐页渲染)→ 每页带完整单据头。** + +```mermaid +flowchart TD + A[打印队列中取一张出库单] --> B[准备: 定位 table 与截止线
tableTop=77 header=6 cutline=158] + B --> C[逐行计算实际高度 h_i
估算: ceil(text/colWidth) x rowHeight] + C --> D[累加, 达到截止线则切页] + D --> E[每页生成独立 template_content + data] + E --> F{打印通道} + F -->|打印台| G[逐页调用 print.send
type=customize count=1] + F -->|浏览器| H[逐页渲染 .preview-page
拼接 + 强制分页] + G --> I[全部页完成 → 队列下一张单] + H --> I +``` + +### 3.1 关键参数(出库单A5) + +``` +tableTop = table.top // 77 +headerH = table.headerHeight // 6 +cutlineTop = 158 // 备注 top(截止线,不遮挡备注) +usableH = cutlineTop - tableTop - headerH // = 75mm(第1页) +``` + +- **第 1 页**:单据头完整 + 表格(重复表头)+ 截止线下方的备注、打印时间。 +- **第 2…N 页**:**重复单据头**(`top < tableTop` 的模板元素)+ 表格(重复表头)+ 页码标识;备注、打印时间等页脚元素**仅最后一页**保留。 +- 第 2+ 页的 `usableH` 与第 1 页一致(因为重复单据头后,表格仍从 77 开始,截止线仍为 158)。 + +### 3.2 动态行高计算 + +**推荐:估算法(快、无 DOM 开销)** +``` +perLineH = rowHeight(6) +cols: 每列 { width, field } +行高 = max over 列 of ( ceil( 文本宽度 / 列宽 ) ) × perLineH +文本宽度 = 估算字符数 × 字宽(中文≈fontSize,ASCII≈0.5×fontSize) +``` + +**备选:测量法(更准)** +- 在隐藏 DOM 中按模板列宽/字号渲染该行,读取 `scrollHeight` 换算成 mm 累加。 +- 成本高,仅当估算误差影响分页正确性时启用。 + +### 3.3 页面模板内容生成 + +对每个拆出的页 `P`: + +```ts +// 第1页(多页时也加页码) +pageTemplateContent(P0) = [ + ...单头元素(top<77), + table元素(表头 + P0 的行), + ...页脚元素(备注 top=158 / 打印时间 top=166), + 页码 text 元素, // "第 1/N 页" +] + +// 第2..N页 +pageTemplateContent(Pk) = [ + ...单头元素(top<77), // 重复单据头 + table元素(表头 + Pk 的行), + 页码 text 元素, // 如 "第 2/3 页",可用自定义 text,无 field_code +] +``` + +> 页码仅在多页(N>1)时追加,第 1 页同样有;单页场景保持原模板不加页码。 +> 表格元素的 `rows`(表头列定义)保持不变,仅数据行 `details` 切片不同。 + +### 3.4 每页 data + +``` +pageData = { + ...formData, // 单据头字段完整(含 delivery_order_code 出库单号) + details: details.slice(页起始行, 页结束行), + pageNo: k, // 第几页 + pageTotal: N, // 共几页 +} +``` + +> 通过单据头字段(出库单号 + 收件人等)确认多页属于同一张单;批量队列中多张单按出库单号区分批次。 + +## 4. 打印台通道(doPrint) + +改造后逐页发送: + +```ts +for (const page of pages) { + const payload: PrintSendCustomizeParams = { + type: 'customize', + computerId: printSettings.station, + printer: printSettings.printer, + template: { ...template, template_content: page.templateContent }, + data: page.data, + timestamp: String(Date.now()), + count: 1, + } + await stationApi.sendPrint(payload) // 每页一次任务,顺序等待 +} +``` + +- 一张单的 N 页全部成功后再打印队列中的下一张单。 +- 进度提示:`打印队列 (M)` 按单据计数;当前页提示「出库单号 xxx (第 k/N 页)」。 +- 失败处理:单页失败记录该单据为 `error`,允许补打(沿用现有 `printStatusMap`)。 + +## 5. 浏览器通道(browserPrint) + +改造后逐页渲染: + +- 一张单生成 N 个 `.preview-page`(每页内容与打印台一致),拼接写入打印窗口。 +- 页与页之间强制分页:`@page { size: 148mm 210mm; margin: 0 }` + 每个 `.preview-page` 之间 `page-break-after: always`。 +- 图片(条码/二维码)加载完成后再 `print()`(沿用现有逻辑)。 + +## 6. 单据头与批次确认 + +- **每页都重复单据头**:出库单号(`delivery_order_code`)、收件人、地址、物流等 `top<77` 的元素。 +- 多页时每页右下角渲染页码(`第 k/N 页`,**含第 1 页**),便于纸质面单归档时确认页序与归属。 +- 批量队列 = 多张出库单 = 多个批次;同单多页通过「出库单号」归属同一批次。 + +## 7. 涉及改动点 + +| 文件 | 改动 | +|---|---| +| `src/components/BatchReceivingPrintDialog.vue` | ① 新增分页计算(定位 table/截止线、动态行高、切分 details)② `doPrint` 逐页发送 ③ `browserPrint` 逐页渲染 + 强制分页 ④ 页码/进度展示 | +| `src/utils/printPaginate.ts`(新增,建议) | 抽公共分页工具:`paginateDetails(template, details) → Page[]`,供打印台/浏览器复用 | +| `src/views/storage/stockout/index.vue` | `fetchPrintData` 补充单据头字段映射(`delivery_order_code`/`wave_no`/`logistics_name` 等模板字段与 `stockout_order_code` 数据的对齐),确保第 2+ 页单据头有值 | + +## 8. 实施前需核对 + +1. **字段映射**:模板出库单号 `field_code=delivery_order_code`,而 stockout 数据为 `stockout_order_code`,需确认打印取值是否已正确映射(`getPreviewValue` 按 `field_code` 直取)。 +2. **打印台渲染行为**:`print.send` 的 `template.template_content` 是否严格按 `top/left/width/height` 绝对定位渲染第 2+ 页模板(依赖打印台客户端,需联调验证)。 +3. **截止线取值**:目前取备注 `top=158`,若后续模板编辑改动布局,分页参数应改为**运行时从模板读取**(取 `table` 下方第一个非表格元素的 top),而不是硬编码。 +4. **留白策略**:第 1 页表格只到 158mm,页面下方(158~210)仍保留备注/打印时间,符合「不遮挡备注」要求;如需减少留白可后续再调截止线策略。 + +## 9. 验收标准 + +- 商品明细少(表格不越 158)时:仍为单页,行为与现状一致。 +- 商品明细多(越 158)时:自动拆分多页;第 2+ 页重复单据头与表头;每页均不遮挡备注。 +- 商品名称长短变化:每页行数随之动态变化,总页数正确。 +- 打印台与浏览器两条通道分页结果一致。 +- 批量多张单:逐张、逐页按序打印,出库单号可区分批次与页序。 diff --git a/out.txt b/out.txt new file mode 100644 index 00000000..e5e9b692 --- /dev/null +++ b/out.txt @@ -0,0 +1 @@ +[{"id": "text_1750000000001", "top": 6, "bold": true, "left": 0, "name": "出库单", "type": "text", "title": "出库单", "width": 148, "custom": true, "height": 10, "italic": false, "rotate": 0, "content": "出 库 单", "autoWrap": true, "fontSize": "18", "createdAt": "2026-06-14T00:00:00.000Z", "direction": "horizontal", "textAlign": "center", "underline": false, "updatedAt": "2026-06-14T00:00:00.000Z", "lineHeight": 10}, {"id": "line_1750000000002", "top": 18, "left": 10, "type": "line", "width": 128, "height": 0.5}, {"id": "text_1750000000003", "top": 21, "bold": false, "left": 10, "name": "发货单号", "type": "text", "title": "发货单号", "width": 26, "custom": true, "height": 7, "italic": false, "rotate": 0, "content": "发货单号:", "autoWrap": true, "fontSize": "10", "createdAt": "2026-06-14T00:00:00.000Z", "direction": "horizontal", "textAlign": "left", "underline": false, "updatedAt": "2026-06-14T00:00:00.000Z", "lineHeight": 6}, {"id": "144_1750000000004", "top": 21, "bold": false, "left": 36, "type": "text", "title": "出库单号", "width": 46, "height": 7, "italic": false, "rotate": 0, "content": "出库单号", "autoWrap": true, "fontSize": "10", "createdAt": "2026-06-14T00:00:00.000Z", "textAlign": "left", "underline": false, "updatedAt": "2026-06-14T00:00:00.000Z", "field_code": "delivery_order_code", "lineHeight": 6}, {"id": "text_1750000000005", "top": 21, "bold": false, "left": 84, "name": "波次号", "type": "text", "title": "波次号", "width": 20, "custom": true, "height": 7, "italic": false, "rotate": 0, "content": "波次号:", "autoWrap": true, "fontSize": "10", "createdAt": "2026-06-14T00:00:00.000Z", "direction": "horizontal", "textAlign": "left", "underline": false, "updatedAt": "2026-06-14T00:00:00.000Z", "lineHeight": 6}, {"id": "147_1750000000006", "top": 21, "bold": false, "left": 104, "type": "text", "title": "波次号", "width": 34, "height": 7, "italic": false, "rotate": 0, "content": "波次号", "autoWrap": true, "fontSize": "10", "createdAt": "2026-06-14T00:00:00.000Z", "textAlign": "left", "underline": false, "updatedAt": "2026-06-14T00:00:00.000Z", "field_code": "wave_no", "lineHeight": 6}, {"id": "text_1750000000007", "top": 29, "bold": false, "left": 10, "name": "创建时间", "type": "text", "title": "创建时间", "width": 26, "custom": true, "height": 7, "italic": false, "rotate": 0, "content": "创建时间:", "autoWrap": true, "fontSize": "10", "createdAt": "2026-06-14T00:00:00.000Z", "direction": "horizontal", "textAlign": "left", "underline": false, "updatedAt": "2026-06-14T00:00:00.000Z", "lineHeight": 6}, {"id": "157_1750000000008", "top": 29, "bold": false, "left": 36, "type": "text", "title": "创建时间", "width": 46, "height": 7, "italic": false, "rotate": 0, "content": "创建时间", "autoWrap": true, "fontSize": "10", "createdAt": "2026-06-14T00:00:00.000Z", "textAlign": "left", "underline": false, "updatedAt": "2026-06-14T00:00:00.000Z", "field_code": "create_at", "lineHeight": 6}, {"id": "text_1750000000009", "top": 29, "bold": false, "left": 84, "name": "快递公司", "type": "text", "title": "快递公司", "width": 26, "custom": true, "height": 7, "italic": false, "rotate": 0, "content": "快递公司:", "autoWrap": true, "fontSize": "10", "createdAt": "2026-06-14T00:00:00.000Z", "direction": "horizontal", "textAlign": "left", "underline": false, "updatedAt": "2026-06-14T00:00:00.000Z", "lineHeight": 6}, {"id": "154_1750000000010", "top": 29, "bold": false, "left": 110, "type": "text", "title": "物流公司", "width": 28, "height": 7, "italic": false, "rotate": 0, "content": "物流公司", "autoWrap": true, "fontSize": "10", "createdAt": "2026-06-14T00:00:00.000Z", "textAlign": "left", "underline": false, "updatedAt": "2026-06-14T00:00:00.000Z", "field_code": "logistics_name", "lineHeight": 6}, {"id": "text_1750000000011", "top": 37, "bold": false, "left": 10, "name": "运单号", "type": "text", "title": "运单号", "width": 20, "custom": true, "height": 7, "italic": false, "rotate": 0, "content": "运单号:", "autoWrap": true, "fontSize": "10", "createdAt": "2026-06-14T00:00:00.000Z", "direction": "horizontal", "textAlign": "left", "underline": false, "updatedAt": "2026-06-14T00:00:00.000Z", "lineHeight": 6}, {"id": "155_1750000000012", "top": 37, "bold": false, "left": 30, "type": "text", "title": "快递单号", "width": 78, "height": 7, "italic": false, "rotate": 0, "content": "快递单号", "autoWrap": true, "fontSize": "10", "createdAt": "2026-06-14T00:00:00.000Z", "textAlign": "left", "underline": false, "updatedAt": "2026-06-14T00:00:00.000Z", "field_code": "express_code", "lineHeight": 6}, {"id": "qrcode_1750000000013", "top": 4, "bold": false, "left": 120, "type": "qrcode", "title": "运单号", "width": 24, "height": 24, "italic": false, "rotate": 0, "content": "运单号", "autoWrap": true, "fontSize": "8", "createdAt": "2026-06-14T00:00:00.000Z", "textAlign": "center", "underline": false, "updatedAt": "2026-06-14T00:00:00.000Z", "field_code": "express_code", "lineHeight": 6}, {"id": "line_1750000000014", "top": 46, "left": 10, "type": "line", "width": 128, "height": 0.5}, {"id": "text_1750000000015", "top": 49, "bold": true, "left": 10, "name": "收件人信息", "type": "text", "title": "收件人信息", "width": 128, "custom": true, "height": 7, "italic": false, "rotate": 0, "content": "收件人信息", "autoWrap": true, "fontSize": "11", "createdAt": "2026-06-14T00:00:00.000Z", "direction": "horizontal", "textAlign": "left", "underline": false, "updatedAt": "2026-06-14T00:00:00.000Z", "lineHeight": 6}, {"id": "text_1750000000016", "top": 57, "bold": false, "left": 10, "name": "收件人", "type": "text", "title": "收件人", "width": 20, "custom": true, "height": 7, "italic": false, "rotate": 0, "content": "收件人:", "autoWrap": true, "fontSize": "10", "createdAt": "2026-06-14T00:00:00.000Z", "direction": "horizontal", "textAlign": "left", "underline": false, "updatedAt": "2026-06-14T00:00:00.000Z", "lineHeight": 6}, {"id": "148_1750000000017", "top": 57, "bold": false, "left": 30, "type": "text", "title": "收件人", "width": 38, "height": 7, "italic": false, "rotate": 0, "content": "收件人", "autoWrap": true, "fontSize": "10", "createdAt": "2026-06-14T00:00:00.000Z", "textAlign": "left", "underline": false, "updatedAt": "2026-06-14T00:00:00.000Z", "field_code": "name", "lineHeight": 6}, {"id": "text_1750000000018", "top": 57, "bold": false, "left": 70, "name": "电话", "type": "text", "title": "电话", "width": 14, "custom": true, "height": 7, "italic": false, "rotate": 0, "content": "电话:", "autoWrap": true, "fontSize": "10", "createdAt": "2026-06-14T00:00:00.000Z", "direction": "horizontal", "textAlign": "left", "underline": false, "updatedAt": "2026-06-14T00:00:00.000Z", "lineHeight": 6}, {"id": "149_1750000000019", "top": 57, "bold": false, "left": 84, "type": "text", "title": "手机号", "width": 54, "height": 7, "italic": false, "rotate": 0, "content": "手机号", "autoWrap": true, "fontSize": "10", "createdAt": "2026-06-14T00:00:00.000Z", "textAlign": "left", "underline": false, "updatedAt": "2026-06-14T00:00:00.000Z", "field_code": "mobile", "lineHeight": 6}, {"id": "text_1750000000020", "top": 65, "bold": false, "left": 10, "name": "地址", "type": "text", "title": "地址", "width": 14, "custom": true, "height": 7, "italic": false, "rotate": 0, "content": "地址:", "autoWrap": true, "fontSize": "10", "createdAt": "2026-06-14T00:00:00.000Z", "direction": "horizontal", "textAlign": "left", "underline": false, "updatedAt": "2026-06-14T00:00:00.000Z", "lineHeight": 6}, {"id": "150_1750000000021", "top": 65, "bold": false, "left": 24, "type": "text", "title": "省", "width": 18, "height": 7, "italic": false, "rotate": 0, "content": "省", "autoWrap": true, "fontSize": "10", "createdAt": "2026-06-14T00:00:00.000Z", "textAlign": "left", "underline": false, "updatedAt": "2026-06-14T00:00:00.000Z", "field_code": "province", "lineHeight": 6}, {"id": "151_1750000000022", "top": 65, "bold": false, "left": 42, "type": "text", "title": "市", "width": 18, "height": 7, "italic": false, "rotate": 0, "content": "市", "autoWrap": true, "fontSize": "10", "createdAt": "2026-06-14T00:00:00.000Z", "textAlign": "left", "underline": false, "updatedAt": "2026-06-14T00:00:00.000Z", "field_code": "city", "lineHeight": 6}, {"id": "152_1750000000023", "top": 65, "bold": false, "left": 60, "type": "text", "title": "区", "width": 18, "height": 7, "italic": false, "rotate": 0, "content": "区", "autoWrap": true, "fontSize": "10", "createdAt": "2026-06-14T00:00:00.000Z", "textAlign": "left", "underline": false, "updatedAt": "2026-06-14T00:00:00.000Z", "field_code": "area", "lineHeight": 6}, {"id": "153_1750000000024", "top": 65, "bold": false, "left": 78, "type": "text", "title": "详细地址", "width": 60, "height": 7, "italic": false, "rotate": 0, "content": "详细地址", "autoWrap": true, "fontSize": "10", "createdAt": "2026-06-14T00:00:00.000Z", "textAlign": "left", "underline": false, "updatedAt": "2026-06-14T00:00:00.000Z", "field_code": "detail_address", "lineHeight": 6}, {"id": "line_1750000000025", "top": 74, "left": 10, "type": "line", "width": 128, "height": 0.5}, {"id": "table_1750000000026", "top": 77, "left": 10, "name": "table", "rows": [{"id": "159_1750000000027", "bold": false, "type": "text", "title": "商品编码", "width": 22, "height": 6, "italic": false, "rotate": 0, "content": "商品编码", "autoWrap": true, "fontSize": "9", "textAlign": "left", "underline": false, "field_code": "item_code", "lineHeight": 6}, {"id": "160_1750000000028", "bold": false, "type": "text", "title": "商品名称", "width": 40, "height": 6, "italic": false, "rotate": 0, "content": "商品名称", "autoWrap": true, "fontSize": "9", "textAlign": "left", "underline": false, "field_code": "item_name", "lineHeight": 6}, {"id": "161_1750000000029", "bold": false, "type": "text", "title": "数量", "width": 18, "height": 6, "italic": false, "rotate": 0, "content": "数量", "autoWrap": true, "fontSize": "9", "textAlign": "left", "underline": false, "field_code": "plan_qty", "lineHeight": 6}, {"id": "162_1750000000030", "bold": false, "type": "text", "title": "单价", "width": 20, "height": 6, "italic": false, "rotate": 0, "content": "单价", "autoWrap": true, "fontSize": "9", "textAlign": "left", "underline": false, "field_code": "actual_price", "lineHeight": 6}, {"id": "163_1750000000031", "bold": false, "type": "text", "title": "备注", "width": 28, "height": 6, "italic": false, "rotate": 0, "content": "备注", "autoWrap": true, "fontSize": "9", "textAlign": "left", "underline": false, "field_code": "detail_remark", "lineHeight": 6}], "type": "table", "width": 128, "height": 75, "createdAt": "2026-06-14T00:00:00.000Z", "rowHeight": 6, "updatedAt": "2026-06-14T00:00:00.000Z", "headerHeight": 6}, {"id": "line_1750000000032", "top": 154, "left": 10, "type": "line", "width": 128, "height": 0.5}, {"id": "text_1750000000033", "top": 158, "bold": false, "left": 10, "name": "备注", "type": "text", "title": "备注", "width": 14, "custom": true, "height": 7, "italic": false, "rotate": 0, "content": "备注:", "autoWrap": true, "fontSize": "9", "createdAt": "2026-06-14T00:00:00.000Z", "direction": "horizontal", "textAlign": "left", "underline": false, "updatedAt": "2026-06-14T00:00:00.000Z", "lineHeight": 6}, {"id": "158_1750000000034", "top": 158, "bold": false, "left": 24, "type": "text", "title": "备注", "width": 114, "height": 7, "italic": false, "rotate": 0, "content": "备注", "autoWrap": true, "fontSize": "9", "createdAt": "2026-06-14T00:00:00.000Z", "textAlign": "left", "underline": false, "updatedAt": "2026-06-14T00:00:00.000Z", "field_code": "remark", "lineHeight": 6}, {"id": "text_printtime_label", "top": 166, "bold": false, "left": 10, "name": "打印时间", "type": "text", "title": "打印时间", "width": 26, "custom": true, "height": 7, "italic": false, "rotate": 0, "content": "打印时间:", "autoWrap": true, "fontSize": "9", "createdAt": "2026-06-14T00:00:00.000Z", "direction": "horizontal", "textAlign": "left", "underline": false, "updatedAt": "2026-06-14T00:00:00.000Z", "lineHeight": 6}, {"id": "164_printtime", "top": 166, "bold": false, "left": 36, "type": "text", "title": "打印时间", "width": 102, "height": 7, "italic": false, "rotate": 0, "content": "打印时间", "autoWrap": true, "fontSize": "9", "createdAt": "2026-06-14T00:00:00.000Z", "textAlign": "left", "underline": false, "updatedAt": "2026-06-14T00:00:00.000Z", "field_code": "print_time", "lineHeight": 6}] \ No newline at end of file diff --git a/server.txt b/server.txt index 30350c54..e5e9b692 100644 --- a/server.txt +++ b/server.txt @@ -1,84 +1 @@ -server -{ - listen 80; - listen 443 ssl; - listen 443 quic; - http2 on; - server_name wms.wms.gztbyc.com; - index index.html index.htm default.htm default.html; - root /www/wwwroot/web/current; - include /www/server/panel/vhost/nginx/extension/wms.wms.gztbyc.com/*.conf; - #CERT-APPLY-CHECK--START - # 用于SSL证书申请时的文件验证相关配置 -- 请勿删除并保持这段设置在优先级高的位置 - include /www/server/panel/vhost/nginx/well-known/wms.wms.gztbyc.com.conf; - #CERT-APPLY-CHECK--END - - #SSL-START SSL相关配置,请勿删除或修改下一行带注释的404规则 - #error_page 404/404.html; - #HTTP_TO_HTTPS_START - set $isRedcert 1; - if ($server_port != 443) { - set $isRedcert 2; - } - if ( $uri ~ /\.well-known/ ) { - set $isRedcert 1; - } - if ($isRedcert != 1) { - rewrite ^(/.*)$ https://$host$1 permanent; - } - #HTTP_TO_HTTPS_END - ssl_certificate /www/server/panel/vhost/cert/wms.wms.gztbyc.com/fullchain.pem; - ssl_certificate_key /www/server/panel/vhost/cert/wms.wms.gztbyc.com/privkey.pem; - ssl_protocols TLSv1.1 TLSv1.2 TLSv1.3; - ssl_ciphers EECDH+CHACHA20:EECDH+CHACHA20-draft:EECDH+AES128:RSA+AES128:EECDH+AES256:RSA+AES256:EECDH+3DES:RSA+3DES:!MD5; - ssl_prefer_server_ciphers on; - ssl_session_tickets on; - ssl_session_cache shared:SSL:10m; - ssl_session_timeout 10m; - add_header Strict-Transport-Security "max-age=31536000"; - add_header Alt-Svc 'quic=":443"; h3=":443"; h3-29=":443"; h3-27=":443";h3-25=":443"; h3-T050=":443"; h3-Q050=":443";h3-Q049=":443";h3-Q048=":443"; h3-Q046=":443"; h3-Q043=":443"'; - error_page 497 https://$host$request_uri; - - #SSL-END - - #ERROR-PAGE-START 错误页配置,可以注释、删除或修改 - #error_page 404 /404.html; - #error_page 502 /502.html; - #ERROR-PAGE-END - - #REWRITE-START URL重写规则引用,修改后将导致面板设置的伪静态规则失效 - include /www/server/panel/vhost/rewrite/html_wms.wms.gztbyc.com.conf; - #REWRITE-END - - #禁止访问的文件或目录 - location ~ ^/(\.user.ini|\.htaccess|\.git|\.env|\.svn|\.project|LICENSE|README.md) - { - return 404; - } - - #一键申请SSL证书验证目录相关设置 - location ~ \.well-known{ - allow all; - } - - #禁止在证书验证目录放入敏感文件 - if ( $uri ~ "^/\.well-known/.*\.(php|jsp|py|js|css|lua|ts|go|zip|tar\.gz|rar|7z|sql|bak)$" ) { - return 403; - } - - location ~ .*\\.(gif|jpg|jpeg|png|bmp|swf)$ - { - expires 30d; - error_log /dev/null; - access_log /dev/null; - } - - location ~ .*\\.(js|css)?$ - { - expires 12h; - error_log /dev/null; - access_log /dev/null; - } - access_log /www/wwwlogs/wms.wms.gztbyc.com.log; - error_log /www/wwwlogs/wms.wms.gztbyc.com.error.log; -} \ No newline at end of file +[{"id": "text_1750000000001", "top": 6, "bold": true, "left": 0, "name": "出库单", "type": "text", "title": "出库单", "width": 148, "custom": true, "height": 10, "italic": false, "rotate": 0, "content": "出 库 单", "autoWrap": true, "fontSize": "18", "createdAt": "2026-06-14T00:00:00.000Z", "direction": "horizontal", "textAlign": "center", "underline": false, "updatedAt": "2026-06-14T00:00:00.000Z", "lineHeight": 10}, {"id": "line_1750000000002", "top": 18, "left": 10, "type": "line", "width": 128, "height": 0.5}, {"id": "text_1750000000003", "top": 21, "bold": false, "left": 10, "name": "发货单号", "type": "text", "title": "发货单号", "width": 26, "custom": true, "height": 7, "italic": false, "rotate": 0, "content": "发货单号:", "autoWrap": true, "fontSize": "10", "createdAt": "2026-06-14T00:00:00.000Z", "direction": "horizontal", "textAlign": "left", "underline": false, "updatedAt": "2026-06-14T00:00:00.000Z", "lineHeight": 6}, {"id": "144_1750000000004", "top": 21, "bold": false, "left": 36, "type": "text", "title": "出库单号", "width": 46, "height": 7, "italic": false, "rotate": 0, "content": "出库单号", "autoWrap": true, "fontSize": "10", "createdAt": "2026-06-14T00:00:00.000Z", "textAlign": "left", "underline": false, "updatedAt": "2026-06-14T00:00:00.000Z", "field_code": "delivery_order_code", "lineHeight": 6}, {"id": "text_1750000000005", "top": 21, "bold": false, "left": 84, "name": "波次号", "type": "text", "title": "波次号", "width": 20, "custom": true, "height": 7, "italic": false, "rotate": 0, "content": "波次号:", "autoWrap": true, "fontSize": "10", "createdAt": "2026-06-14T00:00:00.000Z", "direction": "horizontal", "textAlign": "left", "underline": false, "updatedAt": "2026-06-14T00:00:00.000Z", "lineHeight": 6}, {"id": "147_1750000000006", "top": 21, "bold": false, "left": 104, "type": "text", "title": "波次号", "width": 34, "height": 7, "italic": false, "rotate": 0, "content": "波次号", "autoWrap": true, "fontSize": "10", "createdAt": "2026-06-14T00:00:00.000Z", "textAlign": "left", "underline": false, "updatedAt": "2026-06-14T00:00:00.000Z", "field_code": "wave_no", "lineHeight": 6}, {"id": "text_1750000000007", "top": 29, "bold": false, "left": 10, "name": "创建时间", "type": "text", "title": "创建时间", "width": 26, "custom": true, "height": 7, "italic": false, "rotate": 0, "content": "创建时间:", "autoWrap": true, "fontSize": "10", "createdAt": "2026-06-14T00:00:00.000Z", "direction": "horizontal", "textAlign": "left", "underline": false, "updatedAt": "2026-06-14T00:00:00.000Z", "lineHeight": 6}, {"id": "157_1750000000008", "top": 29, "bold": false, "left": 36, "type": "text", "title": "创建时间", "width": 46, "height": 7, "italic": false, "rotate": 0, "content": "创建时间", "autoWrap": true, "fontSize": "10", "createdAt": "2026-06-14T00:00:00.000Z", "textAlign": "left", "underline": false, "updatedAt": "2026-06-14T00:00:00.000Z", "field_code": "create_at", "lineHeight": 6}, {"id": "text_1750000000009", "top": 29, "bold": false, "left": 84, "name": "快递公司", "type": "text", "title": "快递公司", "width": 26, "custom": true, "height": 7, "italic": false, "rotate": 0, "content": "快递公司:", "autoWrap": true, "fontSize": "10", "createdAt": "2026-06-14T00:00:00.000Z", "direction": "horizontal", "textAlign": "left", "underline": false, "updatedAt": "2026-06-14T00:00:00.000Z", "lineHeight": 6}, {"id": "154_1750000000010", "top": 29, "bold": false, "left": 110, "type": "text", "title": "物流公司", "width": 28, "height": 7, "italic": false, "rotate": 0, "content": "物流公司", "autoWrap": true, "fontSize": "10", "createdAt": "2026-06-14T00:00:00.000Z", "textAlign": "left", "underline": false, "updatedAt": "2026-06-14T00:00:00.000Z", "field_code": "logistics_name", "lineHeight": 6}, {"id": "text_1750000000011", "top": 37, "bold": false, "left": 10, "name": "运单号", "type": "text", "title": "运单号", "width": 20, "custom": true, "height": 7, "italic": false, "rotate": 0, "content": "运单号:", "autoWrap": true, "fontSize": "10", "createdAt": "2026-06-14T00:00:00.000Z", "direction": "horizontal", "textAlign": "left", "underline": false, "updatedAt": "2026-06-14T00:00:00.000Z", "lineHeight": 6}, {"id": "155_1750000000012", "top": 37, "bold": false, "left": 30, "type": "text", "title": "快递单号", "width": 78, "height": 7, "italic": false, "rotate": 0, "content": "快递单号", "autoWrap": true, "fontSize": "10", "createdAt": "2026-06-14T00:00:00.000Z", "textAlign": "left", "underline": false, "updatedAt": "2026-06-14T00:00:00.000Z", "field_code": "express_code", "lineHeight": 6}, {"id": "qrcode_1750000000013", "top": 4, "bold": false, "left": 120, "type": "qrcode", "title": "运单号", "width": 24, "height": 24, "italic": false, "rotate": 0, "content": "运单号", "autoWrap": true, "fontSize": "8", "createdAt": "2026-06-14T00:00:00.000Z", "textAlign": "center", "underline": false, "updatedAt": "2026-06-14T00:00:00.000Z", "field_code": "express_code", "lineHeight": 6}, {"id": "line_1750000000014", "top": 46, "left": 10, "type": "line", "width": 128, "height": 0.5}, {"id": "text_1750000000015", "top": 49, "bold": true, "left": 10, "name": "收件人信息", "type": "text", "title": "收件人信息", "width": 128, "custom": true, "height": 7, "italic": false, "rotate": 0, "content": "收件人信息", "autoWrap": true, "fontSize": "11", "createdAt": "2026-06-14T00:00:00.000Z", "direction": "horizontal", "textAlign": "left", "underline": false, "updatedAt": "2026-06-14T00:00:00.000Z", "lineHeight": 6}, {"id": "text_1750000000016", "top": 57, "bold": false, "left": 10, "name": "收件人", "type": "text", "title": "收件人", "width": 20, "custom": true, "height": 7, "italic": false, "rotate": 0, "content": "收件人:", "autoWrap": true, "fontSize": "10", "createdAt": "2026-06-14T00:00:00.000Z", "direction": "horizontal", "textAlign": "left", "underline": false, "updatedAt": "2026-06-14T00:00:00.000Z", "lineHeight": 6}, {"id": "148_1750000000017", "top": 57, "bold": false, "left": 30, "type": "text", "title": "收件人", "width": 38, "height": 7, "italic": false, "rotate": 0, "content": "收件人", "autoWrap": true, "fontSize": "10", "createdAt": "2026-06-14T00:00:00.000Z", "textAlign": "left", "underline": false, "updatedAt": "2026-06-14T00:00:00.000Z", "field_code": "name", "lineHeight": 6}, {"id": "text_1750000000018", "top": 57, "bold": false, "left": 70, "name": "电话", "type": "text", "title": "电话", "width": 14, "custom": true, "height": 7, "italic": false, "rotate": 0, "content": "电话:", "autoWrap": true, "fontSize": "10", "createdAt": "2026-06-14T00:00:00.000Z", "direction": "horizontal", "textAlign": "left", "underline": false, "updatedAt": "2026-06-14T00:00:00.000Z", "lineHeight": 6}, {"id": "149_1750000000019", "top": 57, "bold": false, "left": 84, "type": "text", "title": "手机号", "width": 54, "height": 7, "italic": false, "rotate": 0, "content": "手机号", "autoWrap": true, "fontSize": "10", "createdAt": "2026-06-14T00:00:00.000Z", "textAlign": "left", "underline": false, "updatedAt": "2026-06-14T00:00:00.000Z", "field_code": "mobile", "lineHeight": 6}, {"id": "text_1750000000020", "top": 65, "bold": false, "left": 10, "name": "地址", "type": "text", "title": "地址", "width": 14, "custom": true, "height": 7, "italic": false, "rotate": 0, "content": "地址:", "autoWrap": true, "fontSize": "10", "createdAt": "2026-06-14T00:00:00.000Z", "direction": "horizontal", "textAlign": "left", "underline": false, "updatedAt": "2026-06-14T00:00:00.000Z", "lineHeight": 6}, {"id": "150_1750000000021", "top": 65, "bold": false, "left": 24, "type": "text", "title": "省", "width": 18, "height": 7, "italic": false, "rotate": 0, "content": "省", "autoWrap": true, "fontSize": "10", "createdAt": "2026-06-14T00:00:00.000Z", "textAlign": "left", "underline": false, "updatedAt": "2026-06-14T00:00:00.000Z", "field_code": "province", "lineHeight": 6}, {"id": "151_1750000000022", "top": 65, "bold": false, "left": 42, "type": "text", "title": "市", "width": 18, "height": 7, "italic": false, "rotate": 0, "content": "市", "autoWrap": true, "fontSize": "10", "createdAt": "2026-06-14T00:00:00.000Z", "textAlign": "left", "underline": false, "updatedAt": "2026-06-14T00:00:00.000Z", "field_code": "city", "lineHeight": 6}, {"id": "152_1750000000023", "top": 65, "bold": false, "left": 60, "type": "text", "title": "区", "width": 18, "height": 7, "italic": false, "rotate": 0, "content": "区", "autoWrap": true, "fontSize": "10", "createdAt": "2026-06-14T00:00:00.000Z", "textAlign": "left", "underline": false, "updatedAt": "2026-06-14T00:00:00.000Z", "field_code": "area", "lineHeight": 6}, {"id": "153_1750000000024", "top": 65, "bold": false, "left": 78, "type": "text", "title": "详细地址", "width": 60, "height": 7, "italic": false, "rotate": 0, "content": "详细地址", "autoWrap": true, "fontSize": "10", "createdAt": "2026-06-14T00:00:00.000Z", "textAlign": "left", "underline": false, "updatedAt": "2026-06-14T00:00:00.000Z", "field_code": "detail_address", "lineHeight": 6}, {"id": "line_1750000000025", "top": 74, "left": 10, "type": "line", "width": 128, "height": 0.5}, {"id": "table_1750000000026", "top": 77, "left": 10, "name": "table", "rows": [{"id": "159_1750000000027", "bold": false, "type": "text", "title": "商品编码", "width": 22, "height": 6, "italic": false, "rotate": 0, "content": "商品编码", "autoWrap": true, "fontSize": "9", "textAlign": "left", "underline": false, "field_code": "item_code", "lineHeight": 6}, {"id": "160_1750000000028", "bold": false, "type": "text", "title": "商品名称", "width": 40, "height": 6, "italic": false, "rotate": 0, "content": "商品名称", "autoWrap": true, "fontSize": "9", "textAlign": "left", "underline": false, "field_code": "item_name", "lineHeight": 6}, {"id": "161_1750000000029", "bold": false, "type": "text", "title": "数量", "width": 18, "height": 6, "italic": false, "rotate": 0, "content": "数量", "autoWrap": true, "fontSize": "9", "textAlign": "left", "underline": false, "field_code": "plan_qty", "lineHeight": 6}, {"id": "162_1750000000030", "bold": false, "type": "text", "title": "单价", "width": 20, "height": 6, "italic": false, "rotate": 0, "content": "单价", "autoWrap": true, "fontSize": "9", "textAlign": "left", "underline": false, "field_code": "actual_price", "lineHeight": 6}, {"id": "163_1750000000031", "bold": false, "type": "text", "title": "备注", "width": 28, "height": 6, "italic": false, "rotate": 0, "content": "备注", "autoWrap": true, "fontSize": "9", "textAlign": "left", "underline": false, "field_code": "detail_remark", "lineHeight": 6}], "type": "table", "width": 128, "height": 75, "createdAt": "2026-06-14T00:00:00.000Z", "rowHeight": 6, "updatedAt": "2026-06-14T00:00:00.000Z", "headerHeight": 6}, {"id": "line_1750000000032", "top": 154, "left": 10, "type": "line", "width": 128, "height": 0.5}, {"id": "text_1750000000033", "top": 158, "bold": false, "left": 10, "name": "备注", "type": "text", "title": "备注", "width": 14, "custom": true, "height": 7, "italic": false, "rotate": 0, "content": "备注:", "autoWrap": true, "fontSize": "9", "createdAt": "2026-06-14T00:00:00.000Z", "direction": "horizontal", "textAlign": "left", "underline": false, "updatedAt": "2026-06-14T00:00:00.000Z", "lineHeight": 6}, {"id": "158_1750000000034", "top": 158, "bold": false, "left": 24, "type": "text", "title": "备注", "width": 114, "height": 7, "italic": false, "rotate": 0, "content": "备注", "autoWrap": true, "fontSize": "9", "createdAt": "2026-06-14T00:00:00.000Z", "textAlign": "left", "underline": false, "updatedAt": "2026-06-14T00:00:00.000Z", "field_code": "remark", "lineHeight": 6}, {"id": "text_printtime_label", "top": 166, "bold": false, "left": 10, "name": "打印时间", "type": "text", "title": "打印时间", "width": 26, "custom": true, "height": 7, "italic": false, "rotate": 0, "content": "打印时间:", "autoWrap": true, "fontSize": "9", "createdAt": "2026-06-14T00:00:00.000Z", "direction": "horizontal", "textAlign": "left", "underline": false, "updatedAt": "2026-06-14T00:00:00.000Z", "lineHeight": 6}, {"id": "164_printtime", "top": 166, "bold": false, "left": 36, "type": "text", "title": "打印时间", "width": 102, "height": 7, "italic": false, "rotate": 0, "content": "打印时间", "autoWrap": true, "fontSize": "9", "createdAt": "2026-06-14T00:00:00.000Z", "textAlign": "left", "underline": false, "updatedAt": "2026-06-14T00:00:00.000Z", "field_code": "print_time", "lineHeight": 6}] \ No newline at end of file diff --git a/src/api/order.index/orderindex.ts b/src/api/order.index/orderindex.ts index 48750c3c..86d249fd 100644 --- a/src/api/order.index/orderindex.ts +++ b/src/api/order.index/orderindex.ts @@ -167,6 +167,12 @@ export type OrderExportParams = { /** 导出模式,默认 waybill */ export_mode?: OrderExportMode exportMode?: OrderExportMode + /** + * 导出表头字段白名单(中文表头字符串数组,如 ["系统订单号","外部订单号"]);不传或空数组时输出全部列。 + * 支持 export_columns 与 exportColumns 两种写法。 + */ + export_columns?: string[] + exportColumns?: string[] } export type OrderExportTaskProgressParams = { diff --git a/src/api/order/order.ts b/src/api/order/order.ts index 6c36dc49..fff747c7 100644 --- a/src/api/order/order.ts +++ b/src/api/order/order.ts @@ -5,8 +5,12 @@ const v = '1.0' /** order.wave.batchList 的 where 白名单(禁止 warehouse_id / warehouseId) */ export type WaveBatchListWhere = { wave_id?: number | string - /** 货主(店铺)ID 筛选 */ - store_id?: number | string + /** 货主(店铺)ID 筛选;支持单值/数组/{ operator, value } 结构 */ + store_id?: + | number + | string + | Array + | { operator?: string; value: number | string | Array } wave_no?: string wave_type?: number wave_status?: number @@ -67,6 +71,8 @@ export type WaveBatchListItem = Record & { source?: number review_assignment_status?: string unreviewed_order_count?: number + /** 货主信息:波次内所有订单均为同一货主时返回货主名称,否则返回“混合” */ + store_name?: string } export type WaveBatchListResponse = { diff --git a/src/api/storage.entry/entry.ts b/src/api/storage.entry/entry.ts index 88dc43f0..426e8f41 100644 --- a/src/api/storage.entry/entry.ts +++ b/src/api/storage.entry/entry.ts @@ -143,6 +143,10 @@ export type EntryDetailItem = { warehouse_item_name?: string warehouse_item_spec?: string count?: number + /** 计划数量(storage.entry.get items 实际返回字段) */ + planned?: number + /** 已完成数量(storage.entry.get items 实际返回字段) */ + completed?: number received_quantity?: number confirm_quantity?: number warehouse_quantity?: number | null @@ -187,6 +191,10 @@ export type EntryOrderDetail = { store_name?: string store_remask?: string order_status?: string + /** 商品类型总数 */ + total_order_lines?: number + /** 商品总数 */ + total_quantity?: number items?: EntryDetailItem[] receivingBindings?: EntryOrderReceivingBinding[] /** 入库单级导入/PDA 记录汇总(若后端返回) */ @@ -200,6 +208,10 @@ export type GetEntryDetailResponse = { entryOrder?: EntryOrderDetail data?: { entryOrder?: EntryOrderDetail + /** 商品总数(接口在 entryOrder 外层返回时读取此字段) */ + total_quantity?: number + /** 已收数量 */ + received_quantity?: number items?: EntryDetailItem[] receivingBindings?: EntryOrderReceivingBinding[] } diff --git a/src/api/storage.management/management.ts b/src/api/storage.management/management.ts index a2b8d30d..c1e4208a 100644 --- a/src/api/storage.management/management.ts +++ b/src/api/storage.management/management.ts @@ -11,6 +11,8 @@ export type ReplenishmentDemandSortField = | 'replenishment_needed' export interface ReplenishmentDemandBody { + /** 货主筛选:支持单值或数组(正整数),不传返回全部货主 */ + store_id?: number | string | Array pagination?: { page?: number pageSize?: number @@ -30,6 +32,9 @@ export function getReplenishmentDemand(data?: ReplenishmentDemandBody): Promise< const body: Record = { pagination: data?.pagination ?? { page: 1, pageSize: 20 }, } + if (data?.store_id !== undefined && data?.store_id !== null && data?.store_id !== '') { + body.store_id = data.store_id + } if (data?.sort) { body.sort = data.sort } diff --git a/src/components/BatchReceivingPrintDialog.vue b/src/components/BatchReceivingPrintDialog.vue index 68a8f33e..8134b116 100644 --- a/src/components/BatchReceivingPrintDialog.vue +++ b/src/components/BatchReceivingPrintDialog.vue @@ -43,58 +43,64 @@
+ {{ field.label }}
[10, 20, 50, 100, 200, 500, 1000], + default: () => [10, 20, 50, 100, 200, 500], }, // 分页布局 paginationLayout: { diff --git a/src/composables/useOrderAsyncExport.ts b/src/composables/useOrderAsyncExport.ts index 20b6000a..2ab635b5 100644 --- a/src/composables/useOrderAsyncExport.ts +++ b/src/composables/useOrderAsyncExport.ts @@ -17,6 +17,9 @@ export type OrderAsyncExportPayload = { sort?: Record export_mode?: OrderExportMode exportMode?: OrderExportMode + /** 导出表头字段白名单(中文表头字符串数组);不传或空数组时输出全部列 */ + export_columns?: string[] + exportColumns?: string[] } export function useOrderAsyncExport(storageKey?: string) { diff --git a/src/utils/printPaginate.ts b/src/utils/printPaginate.ts new file mode 100644 index 00000000..fc695e0d --- /dev/null +++ b/src/utils/printPaginate.ts @@ -0,0 +1,197 @@ +/** + * 打印模板分页工具 + * + * 用于把一张单据的「商品明细」按模板布局拆分为多页: + * - 定位模板中的 table(商品明细)与下方「截止线」(默认取表格之后最近的 text 元素 top,即备注位置) + * - 按每行实际渲染高度(商品名称换行会抬高行高)动态切分,而非固定行数 + * - 第 2+ 页重复单据头(top < tableTop 的元素)+ 重复表头 + 页码 + * + * 打印台通道(print.send)与浏览器打印共用此逻辑,保证两通道分页一致。 + */ + +export interface PrintPageItem { + /** 第几页(从 1 开始) */ + pageNo: number + /** 总页数 */ + pageTotal: number + /** 该页模板内容(第 1 页为原模板;第 2+ 页为单头 + 表格 + 页码) */ + templateContent: Record[] + /** 该页数据(单据头字段完整 + details 切片 + pageNo/pageTotal) */ + data: Record + /** 该页明细在原始 details 中的起始下标(含) */ + detailStart: number + /** 该页明细在原始 details 中的结束下标(不含) */ + detailEnd: number +} + +export interface PaginatePrintOptions { + /** 截止线(mm),默认自动取表格之后最近的 text 元素 top */ + cutlineTop?: number + /** 单元格字号(mm),用于估算文本换行,默认 3 */ + cellFontSizeMm?: number + /** 每行基准高度(mm),默认取 table.rowHeight || 6 */ + perLineHeight?: number + /** 是否给第 2+ 页追加页码元素,默认 true */ + appendPageLabel?: boolean +} + +/** 中日韩/全角字符按 1 个宽度单位,其余按 0.5 个单位(近似) */ +function displayUnits(text: string): number { + let units = 0 + for (const ch of String(text ?? '')) { + const code = ch.codePointAt(0) ?? 0 + if (code >= 0x2e80 || code === 0x3000) { + units += 1 + } else { + units += 0.5 + } + } + return units +} + +/** + * 估算单行实际高度: + * 对每一列,按「文本显示宽度 / 列宽」换行,取所有列的最大行数 × 基准行高。 + */ +function estimateRowHeight( + detail: Record, + table: Record, + cellFontSizeMm: number, + perLineHeight: number +): number { + const cols: any[] = Array.isArray(table.rows) ? table.rows : [] + let maxLines = 1 + for (const col of cols) { + const colWidth = Number(col.width) || 10 + const value = detail?.[col.field_code] + if (value === undefined || value === null || String(value).trim() === '') continue + // 每行可容纳的「中文宽度单位」数:列宽 / 字号 + const capacity = Math.max(1, colWidth / Math.max(0.1, cellFontSizeMm)) + const lines = Math.max(1, Math.ceil(displayUnits(String(value)) / capacity)) + maxLines = Math.max(maxLines, lines) + } + return maxLines * perLineHeight +} + +/** 第 2+ 页追加的页码元素(自定义 text,无 field_code,content 直接显示) */ +function buildPageLabel(template: Record, pageNo: number, pageTotal: number) { + const pageWidth = Number(template?.page_width) || 148 + const pageHeight = Number(template?.page_height) || 210 + return { + id: `page_label_${pageNo}`, + top: Math.max(0, pageHeight - 8), + left: Math.max(0, pageWidth - 46), + type: 'text', + width: 42, + height: 6, + fontSize: 8, + content: `第 ${pageNo}/${pageTotal} 页`, + textAlign: 'right', + lineHeight: 6 + } +} + +/** + * 按模板布局把单据分页。 + * - 模板中没有 table 或没有明细 → 返回单页原样,行为与现状一致。 + * - 有 table 且明细溢出 → 自动拆分多页。 + */ +export function paginatePrintTemplate( + template: Record, + formData: Record, + options: PaginatePrintOptions = {} +): PrintPageItem[] { + const content: any[] = Array.isArray(template?.template_content) ? template.template_content : [] + const table = content.find(el => el?.type === 'table') + const details: any[] = Array.isArray(formData?.details) ? formData.details : [] + + if (!table || details.length === 0) { + return [ + { + pageNo: 1, + pageTotal: 1, + templateContent: content, + data: { ...formData, details, pageNo: 1, pageTotal: 1 }, + detailStart: 0, + detailEnd: details.length + } + ] + } + + const tableTop = Number(table.top) ?? 0 + const headerH = Number(table.headerHeight ?? 4) + const perLineHeight = options.perLineHeight ?? Number(table.rowHeight ?? 6) + const cellFontSizeMm = options.cellFontSizeMm ?? 3 + + // 截止线:参数优先;否则取表格之后最近的 text 元素 top(如备注位置) + const optionCutline = options.cutlineTop + let cutlineTop: number + if (optionCutline === undefined || optionCutline === null) { + const afterTexts = content + .filter(el => el !== table && el?.type === 'text' && Number(el.top) > tableTop) + .map(el => Number(el.top)) + .filter(n => Number.isFinite(n)) + .sort((a, b) => a - b) + cutlineTop = afterTexts.length > 0 ? (afterTexts[0] as number) : tableTop + (Number(table.height) || 75) + } else { + cutlineTop = optionCutline + } + + const usableH = cutlineTop - tableTop - headerH + + // 第一遍:按实际行高动态切分(不按固定行数) + const pageRowSets: any[][] = [] + let curRows: any[] = [] + let curH = 0 + for (const detail of details) { + const rowH = estimateRowHeight(detail, table, cellFontSizeMm, perLineHeight) + if (curRows.length > 0 && curH + rowH > usableH) { + pageRowSets.push(curRows) + curRows = [] + curH = 0 + } + curRows.push(detail) + curH += rowH + } + if (curRows.length > 0 || pageRowSets.length === 0) { + pageRowSets.push(curRows) + } + + // 第二遍:生成每页模板内容与数据 + const total = pageRowSets.length + const result: PrintPageItem[] = [] + let idx = 0 + pageRowSets.forEach((rows, i) => { + const pageNo = i + 1 + const detailStart = idx + const detailEnd = idx + rows.length + idx = detailEnd + + let pageContent = content + if (pageNo > 1) { + // 第 2+ 页:重复单据头(top < tableTop)+ 表格(重复表头) + const head = content.filter(el => Number(el.top) < tableTop) + pageContent = [...head, table] + } + // 多页时每页右下角都追加页码(第 1 页同样加,便于确认页序与批次) + if (total > 1 && options.appendPageLabel !== false) { + pageContent = [...pageContent, buildPageLabel(template, pageNo, total)] + } + + result.push({ + pageNo, + pageTotal: total, + templateContent: pageContent, + data: { + ...formData, + details: rows, + pageNo, + pageTotal: total + }, + detailStart, + detailEnd + }) + }) + + return result +} diff --git a/src/views/order/orderManagement/archiveOrder.vue b/src/views/order/orderManagement/archiveOrder.vue index 7b4342ac..de0f3131 100644 --- a/src/views/order/orderManagement/archiveOrder.vue +++ b/src/views/order/orderManagement/archiveOrder.vue @@ -113,6 +113,14 @@
+ + + +
+
+ 勾选需要导出的字段,未勾选的字段将不出现在导出文件中。 +
+ + +
+ + + + + 全选 + + 反选 + 清空 + 已选 {{ selected.length }} / {{ totalColumnCount }} +
+ + +
+
+
+ {{ group.name }} + + 全选 + + {{ getGroupSelectedCount(group.name) }}/{{ group.fields.length }} +
+
+ + + {{ col }} + + +
+
+
未找到匹配的字段
+
+
+ + +
+ + + + + diff --git a/src/views/order/orderManagement/config/order-common-config.ts b/src/views/order/orderManagement/config/order-common-config.ts index cf1d4045..80841e6e 100644 --- a/src/views/order/orderManagement/config/order-common-config.ts +++ b/src/views/order/orderManagement/config/order-common-config.ts @@ -320,6 +320,116 @@ export interface PendingBatchAsyncTaskConfig { failText: string } +/** order.export 导出模式(waybill=不含明细,item=含明细) */ +export type OrderExportColumnMode = 'waybill' | 'item' + +/** 导出字段分组 */ +export type OrderExportColumnGroup = + | '订单信息' + | '收货信息' + | '商品明细' + | '物流信息' + | '包材信息' + | '流程状态' + | '时间信息' + | '留言备注' + +/** order.export 可导出字段(export_columns 中文表头白名单),modes 标注适用导出模式,group 标注展示分组 */ +export type OrderExportColumnOption = { + label: string + modes: OrderExportColumnMode[] + group: OrderExportColumnGroup +} + +/** + * order.export 全部可导出字段(共 51 个,对齐接口枚举): + * 仅 waybill 模式输出:系统订单号、外部订单号、平台单号、抓取波次号、商品明细; + * 仅 item 模式输出:订单ID、订单号、外部单号、波次号、仓库商品名称、商品条码、商品图片、数量; + * 其余为两种模式通用。 + */ +export const ORDER_EXPORT_ALL_COLUMNS: OrderExportColumnOption[] = [ + // ===== 订单信息 ===== + { label: '系统订单号', modes: ['waybill'], group: '订单信息' }, + { label: '外部订单号', modes: ['waybill'], group: '订单信息' }, + { label: '平台单号', modes: ['waybill'], group: '订单信息' }, + { label: '订单ID', modes: ['item'], group: '订单信息' }, + { label: '订单号', modes: ['item'], group: '订单信息' }, + { label: '外部单号', modes: ['item'], group: '订单信息' }, + { label: '订单状态', modes: ['waybill', 'item'], group: '订单信息' }, + { label: '抓取波次号', modes: ['waybill'], group: '订单信息' }, + { label: '波次号', modes: ['item'], group: '订单信息' }, + { label: '波次序号', modes: ['waybill', 'item'], group: '订单信息' }, + { label: '货主', modes: ['waybill', 'item'], group: '订单信息' }, + { label: '平台', modes: ['waybill', 'item'], group: '订单信息' }, + { label: '店铺昵称', modes: ['waybill', 'item'], group: '订单信息' }, + { label: '业务类型', modes: ['waybill', 'item'], group: '订单信息' }, + { label: '订单金额', modes: ['waybill', 'item'], group: '订单信息' }, + { label: '实收金额', modes: ['waybill', 'item'], group: '订单信息' }, + // ===== 收货信息 ===== + { label: '收件人', modes: ['waybill', 'item'], group: '收货信息' }, + { label: '收件人电话', modes: ['waybill', 'item'], group: '收货信息' }, + { label: '省', modes: ['waybill', 'item'], group: '收货信息' }, + { label: '市', modes: ['waybill', 'item'], group: '收货信息' }, + { label: '区', modes: ['waybill', 'item'], group: '收货信息' }, + { label: '镇', modes: ['waybill', 'item'], group: '收货信息' }, + { label: '详细地址', modes: ['waybill', 'item'], group: '收货信息' }, + // ===== 商品明细 ===== + { label: '商品明细', modes: ['waybill'], group: '商品明细' }, + { label: '仓库商品名称', modes: ['item'], group: '商品明细' }, + { label: '商品条码', modes: ['item'], group: '商品明细' }, + { label: '商品图片', modes: ['item'], group: '商品明细' }, + { label: '数量', modes: ['item'], group: '商品明细' }, + { label: '商品种数', modes: ['waybill', 'item'], group: '商品明细' }, + { label: '商品件数', modes: ['waybill', 'item'], group: '商品明细' }, + { label: '商品重量', modes: ['waybill', 'item'], group: '商品明细' }, + { label: '称重重量(g)', modes: ['waybill', 'item'], group: '商品明细' }, + // ===== 物流信息 ===== + { label: '物流公司', modes: ['waybill', 'item'], group: '物流信息' }, + { label: '运单号', modes: ['waybill', 'item'], group: '物流信息' }, + { label: '运单接口', modes: ['waybill', 'item'], group: '物流信息' }, + { label: '分配时间', modes: ['waybill', 'item'], group: '物流信息' }, + // ===== 包材信息 ===== + { label: '包材ID', modes: ['waybill', 'item'], group: '包材信息' }, + { label: '包材编码', modes: ['waybill', 'item'], group: '包材信息' }, + { label: '包材名称', modes: ['waybill', 'item'], group: '包材信息' }, + // ===== 流程状态 ===== + { label: '出库状态', modes: ['waybill', 'item'], group: '流程状态' }, + { label: '复核状态', modes: ['waybill', 'item'], group: '流程状态' }, + { label: '复核完成状态', modes: ['waybill', 'item'], group: '流程状态' }, + { label: '配货状态', modes: ['waybill', 'item'], group: '流程状态' }, + { label: '打包状态', modes: ['waybill', 'item'], group: '流程状态' }, + // ===== 时间信息 ===== + { label: '创建时间', modes: ['waybill', 'item'], group: '时间信息' }, + { label: '支付时间', modes: ['waybill', 'item'], group: '时间信息' }, + { label: '发货时间', modes: ['waybill', 'item'], group: '时间信息' }, + { label: '归档时间', modes: ['waybill', 'item'], group: '时间信息' }, + // ===== 留言备注 ===== + { label: '备注', modes: ['waybill', 'item'], group: '留言备注' }, + { label: '买家留言', modes: ['waybill', 'item'], group: '留言备注' }, + { label: '卖家留言', modes: ['waybill', 'item'], group: '留言备注' } +] + +/** 按导出模式获取可用导出字段(中文表头数组) */ +export function getOrderExportColumnsByMode(mode: OrderExportColumnMode): string[] { + return ORDER_EXPORT_ALL_COLUMNS.filter((col) => col.modes.includes(mode)).map((col) => col.label) +} + +/** 按导出模式获取分组字段(用于字段选择表单分组展示) */ +export function getOrderExportColumnGroupsByMode( + mode: OrderExportColumnMode +): Array<{ name: OrderExportColumnGroup; fields: string[] }> { + const groups: Array<{ name: OrderExportColumnGroup; fields: string[] }> = [] + ORDER_EXPORT_ALL_COLUMNS.filter((col) => col.modes.includes(mode)).forEach((col) => { + let group = groups.find((g) => g.name === col.group) + if (!group) { + group = { name: col.group, fields: [] } + groups.push(group) + } + group.fields.push(col.label) + }) + return groups +} + export const ORDER_TOOLBAR_BUTTONS: Record = { refresh: { key: 'refresh', label: '刷新', category: 'refresh', size: 'small', action: 'loadData' }, export: { @@ -332,18 +442,11 @@ export const ORDER_TOOLBAR_BUTTONS: Record = { buttonType: 'dropdown', dropdownOptions: [ { label: '不含明细', action: 'handleExportWaybill' }, - { label: '含明细', action: 'handleExportItem', divided: true } + { label: '含明细', action: 'handleExportItem', divided: true }, + { label: '导出选中(不含明细)', action: 'handleExportSelectionWaybill', divided: true }, + { label: '导出选中(含明细)', action: 'handleExportSelectionItem' } ] }, - exportSelection: { - key: 'exportSelection', - label: '导出选中', - category: 'setting', - size: 'small', - loadingKey: 'exportSelectionLoading', - disabledKey: 'hasNoSelection', - action: 'handleExportSelection' - }, deliveryExport: { key: 'deliveryExport', label: '导出', @@ -809,10 +912,12 @@ export const orderDetailFullSections: OrderDetailSectionConfig[] = [ { prop: 'warehouse_code', label: '仓库编码' }, { prop: 'create_channel', label: '来源' }, { prop: 'order_flag', label: '订单标记', span: 4, multiline: true }, - { prop: 'sys_platform_name', label: '平台编码' }, + { prop: 'sys_platform_name', label: '平台名称' }, + { prop: 'sys_platform_code', label: '平台编码', tag: true }, { prop: 'source_platform_name', label: '来源平台名' }, { prop: 'source_platform_code', label: '来源平台编码', tag: true }, { prop: 'source_order_codes', label: '平台交易单号' }, + { prop: 'oaid_order_source_code', label: 'OAID来源编码' }, { prop: 'shop_nick', label: '店铺名称' }, { prop: 'buyer_nick', label: '买家昵称' }, { prop: 'seller_nick', label: '卖家昵称' }, @@ -1027,6 +1132,7 @@ export const orderItemCompactColumns: OrderItemColumnConfig[] = [ export const orderItemFullColumns: OrderItemColumnConfig[] = [ { prop: 'images', label: '图片', width: 80, align: 'center', image: true }, { prop: 'id', label: '明细ID', width: 90, align: 'center' }, + { prop: 'order_item_id', label: '订单明细ID', width: 110, align: 'center' }, { prop: 'order_id', label: '订单ID', width: 90, align: 'center' }, { prop: 'order_line_no', label: '行号', width: 80, align: 'center' }, { prop: 'item_code', label: '商品编码', minWidth: 140, showOverflowTooltip: true }, @@ -1039,7 +1145,10 @@ export const orderItemFullColumns: OrderItemColumnConfig[] = [ { prop: 'stock_unit', label: '单位', width: 80, align: 'center' }, { prop: 'is_batch_mgmt', label: '批次管理', width: 100, align: 'center' }, { prop: 'is_shelf_life_mgmt', label: '效期管理', width: 100, align: 'center' }, + { prop: 'is_images', label: '有图', width: 80, align: 'center' }, + { prop: 'barcodes', label: '条码', minWidth: 140, showOverflowTooltip: true }, { prop: 'packing_requirements', label: '包装要求', minWidth: 120, showOverflowTooltip: true }, + { prop: 'picking_locations', label: '拣货位', minWidth: 140, showOverflowTooltip: true }, { prop: 'store_id', label: '货主ID', width: 100, align: 'center' }, ] @@ -1050,7 +1159,6 @@ export const orderItemFullColumns: OrderItemColumnConfig[] = [ export const simpleListToolbarButtonKeys = [ 'refresh', 'export', - 'exportSelection', 'columnConfig', 'toggleDetail' ] diff --git a/src/views/order/orderManagement/deliveryException.vue b/src/views/order/orderManagement/deliveryException.vue index 794f41fa..9e3390bd 100644 --- a/src/views/order/orderManagement/deliveryException.vue +++ b/src/views/order/orderManagement/deliveryException.vue @@ -109,6 +109,14 @@ + + + + + + + + + + + + + + { return nested && typeof nested === 'object' ? nested : res } +/** 商品明细行规范化:兼容图片字段(接口返回 image_url,面板按 images 渲染) */ +function normalizeOrderItemRow(row: any): any { + if (!row || typeof row !== 'object') return row + if (Array.isArray(row.images)) return row + const urls = Array.isArray(row.image_url) + ? row.image_url + : typeof row.image_url === 'string' && row.image_url + ? [row.image_url] + : [] + return urls.length ? { ...row, images: urls } : row +} + /** order.detail 商品明细:优先 orderItems,兼容 items 及嵌套字段 */ export function normalizeOrderDetailItems(data: Record): any[] { - if (Array.isArray(data.orderItems)) return data.orderItems - if (Array.isArray(data.items)) return data.items + const normalize = (rows: any[]) => (Array.isArray(rows) ? rows.map(normalizeOrderItemRow) : []) + + if (Array.isArray(data.orderItems)) return normalize(data.orderItems) + if (Array.isArray(data.items)) return normalize(data.items) const rawItems = data.order?.items || data.detail?.items - if (Array.isArray(rawItems)) return rawItems + if (Array.isArray(rawItems)) return normalize(rawItems) if (typeof rawItems === 'string') { try { const parsed = JSON.parse(rawItems) - return Array.isArray(parsed) ? parsed : [] + return Array.isArray(parsed) ? normalize(parsed) : [] } catch { return [] } diff --git a/src/views/order/orderManagement/utils/order-page-export.ts b/src/views/order/orderManagement/utils/order-page-export.ts index 9dbaf682..5aa716a4 100644 --- a/src/views/order/orderManagement/utils/order-page-export.ts +++ b/src/views/order/orderManagement/utils/order-page-export.ts @@ -2,10 +2,18 @@ import { ref, type Ref } from 'vue' import { ElMessage } from 'element-plus' import type { OrderExportMode } from '@/api/order.index/orderindex' import { useOrderAsyncExport } from '@/composables/useOrderAsyncExport' +import { useUserStore } from '@/stores/modules/user' import { ORDER_INDEX_EXPORT_SCOPES, sanitizeOrderListWhere } from './order-index-helpers' import { exportUpperTableRows } from './export' import { translateOrderField } from '../config/order-common-config' +/** 提取选中行的订单 id(过滤空值) */ +function extractSelectionIds(rows: any[]): Array { + return rows + .map((row: any) => row?.id) + .filter((id: any) => id !== undefined && id !== null && id !== '') +} + export function createOrderPageExport(options: { scopeKey: keyof typeof ORDER_INDEX_EXPORT_SCOPES buildWhere: () => Record @@ -18,6 +26,20 @@ export function createOrderPageExport(options: { const asyncExport = useOrderAsyncExport(options.storageKey) const exportSelectionLoading = ref(false) + /** 导出选中(含明细/不含明细)字段选择对话框状态 */ + const exportColumnsDialogVisible = ref(false) + const exportColumnsMode = ref('waybill') + const exportColumnsLoading = ref(false) + /** 导出选中字段配置持久化 key(按 用户/角色/页面/模式 独立保存;前缀区别于字段设置,避免被“故障修复”清除) */ + const exportColumnsStorageKey = ref('') + + function getExportColumnsStorageKey(mode: OrderExportMode): string { + const userStore = useUserStore() + const userId = userStore.user?.username || userStore.user?.id || 'unknown' + const roleId = userStore.roleId || 'default' + return `order_export_columns_${userId}_${roleId}_${options.scopeKey}_${mode}` + } + async function handleExport(exportMode: OrderExportMode = 'waybill') { const scope = ORDER_INDEX_EXPORT_SCOPES[options.scopeKey] if (!scope) { @@ -61,12 +83,71 @@ export function createOrderPageExport(options: { } } + /** 打开导出选中字段选择对话框(含明细/不含明细) */ + function openExportColumnsDialog(mode: OrderExportMode) { + if (!options.selectionRows.value.length) { + ElMessage.warning('请先勾选要导出的订单') + return + } + exportColumnsMode.value = mode + exportColumnsStorageKey.value = getExportColumnsStorageKey(mode) + exportColumnsDialogVisible.value = true + } + + async function handleExportSelectionWaybill() { + openExportColumnsDialog('waybill') + } + + async function handleExportSelectionItem() { + openExportColumnsDialog('item') + } + + /** 字段选择确认后,提交 order.export 异步导出选中订单 */ + async function confirmExportColumns(columns: string[]) { + const scope = ORDER_INDEX_EXPORT_SCOPES[options.scopeKey] + if (!scope) { + ElMessage.error('未配置导出范围') + return + } + const ids = extractSelectionIds(options.selectionRows.value) + if (!ids.length) { + ElMessage.warning('请先勾选要导出的订单') + return + } + if (exportColumnsLoading.value) return + exportColumnsLoading.value = true + try { + await asyncExport.submitExportTask({ + ...scope, + where: sanitizeOrderListWhere({ + ...options.buildWhere(), + id: { operator: 'in', value: ids } + }), + sort: options.buildSort?.(), + export_mode: exportColumnsMode.value, + export_columns: columns + }) + exportColumnsDialogVisible.value = false + } catch (error: any) { + ElMessage.error(error?.message || '导出任务提交失败') + } finally { + exportColumnsLoading.value = false + } + } + return { ...asyncExport, exportSelectionLoading, + exportColumnsDialogVisible, + exportColumnsMode, + exportColumnsLoading, + exportColumnsStorageKey, handleExport: handleExportWaybill, handleExportWaybill, handleExportItem, - handleExportSelection + handleExportSelection, + handleExportSelectionWaybill, + handleExportSelectionItem, + confirmExportColumns } } diff --git a/src/views/order/orderManagement/utils/toolbar-actions.ts b/src/views/order/orderManagement/utils/toolbar-actions.ts index 019504ba..01ffb23f 100644 --- a/src/views/order/orderManagement/utils/toolbar-actions.ts +++ b/src/views/order/orderManagement/utils/toolbar-actions.ts @@ -22,12 +22,18 @@ function bindExportToolbarActions(params: { handleExportWaybill?: () => Promise handleExportItem?: () => Promise handleExportSelection?: () => Promise + handleExportSelectionWaybill?: () => Promise + handleExportSelectionItem?: () => Promise }) { return { handleExport: params.handleExport, handleExportWaybill: params.handleExportWaybill || params.handleExport, handleExportItem: params.handleExportItem || params.handleExport, - ...(params.handleExportSelection ? { handleExportSelection: params.handleExportSelection } : {}) + ...(params.handleExportSelection ? { handleExportSelection: params.handleExportSelection } : {}), + ...(params.handleExportSelectionWaybill + ? { handleExportSelectionWaybill: params.handleExportSelectionWaybill } + : {}), + ...(params.handleExportSelectionItem ? { handleExportSelectionItem: params.handleExportSelectionItem } : {}) } } @@ -326,6 +332,8 @@ export function createReviewToolbarController(params: { handleExportWaybill?: () => Promise handleExportItem?: () => Promise handleExportSelection?: () => Promise + handleExportSelectionWaybill?: () => Promise + handleExportSelectionItem?: () => Promise openColumnConfigPanel: () => void toggleDetailVisible: () => void openCreateOrderDialog: () => void @@ -457,6 +465,8 @@ export function createPendingToolbarController(params: { handleExportWaybill?: () => Promise handleExportItem?: () => Promise handleExportSelection?: () => Promise + handleExportSelectionWaybill?: () => Promise + handleExportSelectionItem?: () => Promise openColumnConfigPanel: () => void toggleDetailVisible: () => void openCreateOrderDialog: () => void @@ -1535,6 +1545,8 @@ export function createSimpleListToolbarController(params: { handleExportWaybill?: () => Promise handleExportItem?: () => Promise handleExportSelection?: () => Promise + handleExportSelectionWaybill?: () => Promise + handleExportSelectionItem?: () => Promise openColumnConfigPanel: () => void toggleDetailVisible: () => void }) { diff --git a/src/views/order/waveOrder/config/wave-config.ts b/src/views/order/waveOrder/config/wave-config.ts index b23c8189..a4330ce8 100644 --- a/src/views/order/waveOrder/config/wave-config.ts +++ b/src/views/order/waveOrder/config/wave-config.ts @@ -137,8 +137,8 @@ export const waveAvailableFields = [ type: 'select', options: [ { label: '未分配', value: '未分配' }, + { label: '部分分配', value: '部分分配' }, { label: '已分配', value: '已分配' }, - { label: '部分分配', value: 'partial' }, ] }), group: WAVE_SCAN_PROCESS_STATUS_GROUP }, { ...scanWorkflowField({ @@ -147,6 +147,7 @@ export const waveAvailableFields = [ type: 'select', options: [ { label: '未分配', value: 'unassigned' }, + { label: '部分分配', value: 'partially_assigned' }, { label: '已分配', value: 'assigned' }, ] }), group: WAVE_SCAN_PROCESS_STATUS_GROUP }, @@ -156,25 +157,17 @@ export const waveAvailableFields = [ type: 'select', options: [ { label: '未打印', value: 'unprinted' }, + { label: '部分打印', value: 'partially_printed' }, { label: '已打印', value: 'printed' }, ] }), group: WAVE_SCAN_PROCESS_STATUS_GROUP }, - { ...scanWorkflowField({ - label: '拣货状态', - value: 'pick_assignment_status', - type: 'select', - options: [ - { label: '未拣货', value: '未拣货' }, - { label: '部分拣货', value: '部分拣货' }, - { label: '已拣货', value: '已拣货' }, - ] - }), group: WAVE_SCAN_PROCESS_STATUS_GROUP }, { ...scanWorkflowField({ label: '复核状态', value: 'review_assignment_status', type: 'select', options: [ { label: '未复核', value: 'unreviewed' }, + { label: '部分复核', value: 'partially_reviewed' }, { label: '已复核', value: 'reviewed' }, ] }), group: WAVE_SCAN_PROCESS_STATUS_GROUP }, @@ -404,7 +397,6 @@ export const waveWhereAllowedFieldList = [ 'storage_assignment_status', 'express_assignment_status', 'print_assignment_status', - 'pick_assignment_status', 'review_assignment_status', 'total_orders_min', 'total_orders_max', diff --git a/src/views/storage/entry/component/BindReceivingToEntryDialog.vue b/src/views/storage/entry/component/BindReceivingToEntryDialog.vue index 7b0c8645..048366a4 100644 --- a/src/views/storage/entry/component/BindReceivingToEntryDialog.vue +++ b/src/views/storage/entry/component/BindReceivingToEntryDialog.vue @@ -23,6 +23,14 @@ 订单状态 {{ entryOrderStatusLabel }} + + 商品类型数 + {{ entryTotalOrderLines }} + + + 商品总数 + {{ entryTotalQuantity }} + 运单号 {{ entryExpressCode }} @@ -194,6 +202,7 @@ import { receivingCompare, type BindReceivingResponse, type EntryDetailItem, + type EntryOrderDetail, type ReceivingCompareResponse, type ReceivingCompareItem, type ReceivingCompareRow, @@ -260,6 +269,8 @@ const receivingList = ref([]) const receivingListLoading = ref(false) const compareLoading = ref(false) const entryItems = ref([]) +const entryOrderInfo = ref(null) +const entryTotalQuantityRaw = ref(null) const selectedReceivingRows = ref([]) const compareRows = ref([]) const bindSubmitting = ref(false) @@ -325,6 +336,31 @@ const entryPurchaseOrderCode = computed(() => { return code !== null && code !== undefined && String(code).trim() ? String(code).trim() : '' }) +const entryTotalQuantity = computed(() => { + // 1) 优先:接口在 entryOrder 外层返回的 total_quantity + if (entryTotalQuantityRaw.value !== null && entryTotalQuantityRaw.value !== undefined) { + return String(entryTotalQuantityRaw.value) + } + // 2) entryOrder 内返回的 total_quantity + const v = entryOrderInfo.value?.total_quantity + if (v !== null && v !== undefined) return String(v) + // 3) 回退:按明细数量求和(兼容 planned / count / total_planned) + const sum = entryItems.value.reduce((acc, item) => { + const raw = item as Record + const qty = raw.planned ?? raw.count ?? raw.total_planned + return acc + (Number(qty) || 0) + }, 0) + return sum > 0 ? String(sum) : '' +}) + +const entryTotalOrderLines = computed(() => { + const v = entryOrderInfo.value?.total_order_lines + if (v !== null && v !== undefined) return String(v) + // 接口未返回时按明细条数统计 + const n = entryItems.value.length + return n > 0 ? String(n) : '' +}) + const isEntryFullyCovered = ref(false) const canSubmitBind = computed( @@ -446,6 +482,81 @@ function buildEntryOnlyCompareRows(): CompareDisplayRow[] { }) } +/** + * 收集对照记录(兼容两种返回结构): + * 1) 新结构:顶层合并后的 comparison + receiving_only + * 2) 旧结构:遍历各收货单 comparisons 下的 comparison + receiving_only + * 同时跟踪每个商品的最佳匹配状态(matched > entry_only)。 + */ +function collectCompareRecords(payload: ReceivingCompareResponse): { + records: ReceivingCompareRow[] + hasUnmatchedEntry: boolean +} { + const records: ReceivingCompareRow[] = [] + const seenKeys = new Set() + // 按 warehouse_item_code 跟踪最佳匹配状态:matched > entry_only + const itemMatchStatus = new Map() + + const pushRecords = (items: ReceivingCompareRow[]) => { + for (const record of items) { + const raw = record as Record + const ms = String(raw.match_status ?? '').toLowerCase() + // 收货侧可用量为 0 则不展示(无实际可绑定量) + if (!raw.warehouse_item_code && Number(raw.receiving_available) === 0) continue + const key = String(raw.warehouse_item_code ?? Math.random()) + + // 更新该商品的最佳匹配状态 + const prev = itemMatchStatus.get(key) + if (!prev || (prev === 'entry_only' && ms === 'matched')) { + itemMatchStatus.set(key, ms) + } + + if (!seenKeys.has(key)) { + seenKeys.add(key) + records.push(record) + } else if (ms === 'matched') { + // 已存在 entry_only 记录,现在遇到 matched,覆盖更新 + const idx = records.findIndex((r) => { + const rRaw = r as Record + return String(rRaw.warehouse_item_code ?? '') === key + }) + if (idx >= 0) { + records[idx] = record + } + } + } + } + + // 1) 新结构:顶层合并后的 comparison / receiving_only + if (Array.isArray(payload.comparison) || Array.isArray(payload.receiving_only)) { + pushRecords([ + ...(Array.isArray(payload.comparison) ? payload.comparison : []), + ...(Array.isArray(payload.receiving_only) ? payload.receiving_only : []), + ]) + } + + // 2) 旧结构回退:遍历各收货单 comparisons + if (!records.length && Array.isArray(payload.comparisons)) { + for (const item of payload.comparisons) { + pushRecords([ + ...(Array.isArray(item.comparison) ? item.comparison : []), + ...(Array.isArray(item.receiving_only) ? item.receiving_only : []), + ]) + } + } + + // 只要有一个 entry_only 的商品从未被任何收货单 matched,则不算完全覆盖 + let hasUnmatchedEntry = false + for (const [, status] of itemMatchStatus) { + if (status === 'entry_only') { + hasUnmatchedEntry = true + break + } + } + + return { records, hasUnmatchedEntry } +} + function syncTableHeight() { const el = tableHostRef.value if (!el) return @@ -471,6 +582,8 @@ function resetReceivingState() { selectedReceivingRows.value = [] compareRows.value = [] entryItems.value = [] + entryOrderInfo.value = null + entryTotalQuantityRaw.value = null isEntryFullyCovered.value = false pagination.currentPage = 1 pagination.pageSize = 10 @@ -498,6 +611,11 @@ async function loadEntryItems() { try { const res = await getEntryDetail({ id: entryOrderId.value }) const order = res.entryOrder ?? res.data?.entryOrder + entryOrderInfo.value = order ?? null + // total_quantity 可能在 entryOrder 外层返回(storage.entry.get 实际结构) + const payloadTotal = res.data && typeof res.data === 'object' ? res.data.total_quantity : undefined + entryTotalQuantityRaw.value = + payloadTotal !== undefined && payloadTotal !== null ? payloadTotal : (order?.total_quantity ?? null) entryItems.value = Array.isArray(order?.items) ? order.items : [] if (!selectedReceivingRows.value.length) { compareRows.value = buildEntryOnlyCompareRows() @@ -505,6 +623,8 @@ async function loadEntryItems() { } catch (error) { console.error('加载入库单明细失败:', error) entryItems.value = [] + entryOrderInfo.value = null + entryTotalQuantityRaw.value = null compareRows.value = [] ElMessage.error('加载入库单明细失败') } @@ -552,53 +672,7 @@ async function refreshCompareRows() { res.data && typeof res.data === 'object' ? { ...res, ...res.data } : res ) as ReceivingCompareResponse - const allRecords: ReceivingCompareRow[] = [] - const seenKeys = new Set() - // 按 warehouse_item_code 跟踪最佳匹配状态:matched > entry_only - const itemMatchStatus = new Map() - - for (const item of (payload.comparisons ?? [])) { - const records = [ - ...(Array.isArray(item.comparison) ? item.comparison : []), - ...(Array.isArray(item.receiving_only) ? item.receiving_only : []), - ] - for (const record of records) { - const raw = record as Record - const ms = String(raw.match_status ?? '').toLowerCase() - // 收货侧可用量为 0 则不展示(无实际可绑定量) - if (!raw.warehouse_item_code && Number(raw.receiving_available) === 0) continue - const key = String(raw.warehouse_item_code ?? Math.random()) - - // 更新该商品的最佳匹配状态 - const prev = itemMatchStatus.get(key) - if (!prev || (prev === 'entry_only' && ms === 'matched')) { - itemMatchStatus.set(key, ms) - } - - if (!seenKeys.has(key)) { - seenKeys.add(key) - allRecords.push(record) - } else if (ms === 'matched') { - // 已存在 entry_only 记录,现在遇到 matched,覆盖更新 - const idx = allRecords.findIndex((r) => { - const rRaw = r as Record - return String(rRaw.warehouse_item_code ?? '') === key - }) - if (idx >= 0) { - allRecords[idx] = record - } - } - } - } - - // 只要有一个 entry_only 的商品从未被任何收货单 matched,则不算完全覆盖 - let hasUnmatchedEntry = false - for (const [, status] of itemMatchStatus) { - if (status === 'entry_only') { - hasUnmatchedEntry = true - break - } - } + const { records: allRecords, hasUnmatchedEntry } = collectCompareRecords(payload) isEntryFullyCovered.value = !hasUnmatchedEntry if (allRecords.length) { diff --git a/src/views/storage/entry/entry-config.ts b/src/views/storage/entry/entry-config.ts index 1e1ed6e9..0b91c19e 100644 --- a/src/views/storage/entry/entry-config.ts +++ b/src/views/storage/entry/entry-config.ts @@ -302,15 +302,12 @@ export function isPendingEntryOrderStatus(status: unknown): boolean { return upper === 'PENDING' || upper === 'CREATED' || normalized === '待入库' || normalized === '已创建' } -/** 是否允许快捷直入(storage.entry.quickInbound,仅 CREATED 且未绑定收货单) */ +/** 是否允许快捷直入(storage.entry.quickInbound,仅 CREATED 状态;已绑定收货单的同样允许) */ export function canQuickInbound(status: unknown, hasReceiving?: unknown, receivingBindings?: unknown): boolean { if (status === null || status === undefined || status === '') return false const normalized = String(status).trim() const upper = normalized.toUpperCase() if (upper !== 'CREATED' && normalized !== '已创建') return false - // 已绑定收货单的排除虚拟直入 - if (hasReceiving === true) return false - if (Array.isArray(receivingBindings) && receivingBindings.length > 0) return false return true } diff --git a/src/views/storage/management/replenishmentDemand/index.vue b/src/views/storage/management/replenishmentDemand/index.vue index cdb45961..e7af52ed 100644 --- a/src/views/storage/management/replenishmentDemand/index.vue +++ b/src/views/storage/management/replenishmentDemand/index.vue @@ -26,6 +26,31 @@ +
+
+ 货主 + + + +
+
+
刷新 @@ -70,8 +95,28 @@
无可用补货库位(存货区与分拣区均无库存)
+ + + + + ([]) const selectedRows = ref([]) const summary = ref({}) +const storeOptions = ref>([]) +const storeLoading = ref(false) const queryForm = reactive(defaultQueryForm()) const pagination = reactive({ @@ -183,7 +235,7 @@ const defaultTableSort = computed(() => ({ })) function buildRequestBody() { - return { + const body: Record = { pagination: { page: pagination.page, pageSize: queryForm.pageSize, @@ -193,6 +245,16 @@ function buildRequestBody() { sortOrder: queryForm.sortOrder, }, } + const storeId = queryForm.store_id + const hasStoreFilter = + storeId !== undefined && + storeId !== null && + storeId !== '' && + !(Array.isArray(storeId) && storeId.length === 0) + if (hasStoreFilter) { + body.store_id = storeId + } + return body } async function fetchData() { @@ -230,6 +292,24 @@ function handleQuery() { void fetchData() } +async function loadStoreOptions() { + storeLoading.value = true + try { + const res: any = await loadStores() + const rawStores = extractStoreListFromResponse(res) + storeOptions.value = mapStoreListToSelectOptions(rawStores) + } catch { + storeOptions.value = [] + } finally { + storeLoading.value = false + } +} + +function handleStoreFilterChange() { + pagination.page = 1 + void fetchData() +} + function handleReset() { Object.assign(queryForm, defaultQueryForm()) pagination.page = 1 @@ -281,6 +361,7 @@ function statusTagType(status?: string) { } onMounted(() => { + void loadStoreOptions() void fetchData() }) @@ -369,6 +450,38 @@ onMounted(() => { } } +.query-bar { + display: flex; + align-items: center; + gap: 16px; + padding: 10px 16px; + background: #fff; + border-radius: 6px; + flex-shrink: 0; + + .query-item { + display: flex; + align-items: center; + gap: 8px; + + .query-label { + font-size: 13px; + color: #606266; + white-space: nowrap; + } + } +} + +.barcode-list { + display: flex; + flex-wrap: wrap; + gap: 4px; + + .barcode-tag { + max-width: 100%; + } +} + .toolbar { display: flex; justify-content: space-between; diff --git a/src/views/storage/management/replenishmentDemand/replenishment-demand-config.ts b/src/views/storage/management/replenishmentDemand/replenishment-demand-config.ts index b62e8bcc..ee13a82c 100644 --- a/src/views/storage/management/replenishmentDemand/replenishment-demand-config.ts +++ b/src/views/storage/management/replenishmentDemand/replenishment-demand-config.ts @@ -1,6 +1,8 @@ import type { ReplenishmentDemandSortField } from '@/api/storage.management/management' export interface ReplenishmentDemandQueryForm { + /** 货主筛选:支持单值或数组 */ + store_id?: number | string | Array pageSize: number sortField: ReplenishmentDemandSortField sortOrder: 'ASC' | 'DESC' @@ -10,6 +12,15 @@ export interface ReplenishmentDemandListItem { stock_id: number stock_code?: string stock_name?: string + /** 货主ID */ + store_id?: number + /** 货主名称 */ + store_name?: string + /** 条码列表 */ + barcodes?: Array<{ + id?: number + barcode?: string + }> pick_zone_quantity?: number storage_zone_quantity?: number total_demand?: number @@ -33,6 +44,7 @@ export interface ReplenishmentDemandSummary { } export const defaultQueryForm = (): ReplenishmentDemandQueryForm => ({ + store_id: undefined, pageSize: 20, sortField: 'shortage', sortOrder: 'DESC', @@ -96,6 +108,8 @@ export function exportReplenishmentDemandCsv(rows: ReplenishmentDemandListItem[] const headers = [ 'SKU编码', '商品名称', + '货主名称', + '条码', '分拣区库存', '存货区库存', '总需求量', @@ -107,6 +121,8 @@ export function exportReplenishmentDemandCsv(rows: ReplenishmentDemandListItem[] const lines = rows.map((row) => [ row.stock_code ?? '', row.stock_name ?? '', + row.store_name ?? '', + (row.barcodes ?? []).map((b) => b?.barcode ?? '').join('、'), row.pick_zone_quantity ?? '', row.storage_zone_quantity ?? '', row.total_demand ?? '', diff --git a/src/views/storage/stockout/index.vue b/src/views/storage/stockout/index.vue index 05c855c7..34be77bb 100644 --- a/src/views/storage/stockout/index.vue +++ b/src/views/storage/stockout/index.vue @@ -1047,7 +1047,27 @@ async function handleOpenPrintDialog() { } async function fetchPrintData(row: any, _index: number) { + // 打印时间:打开打印对话框时生成 + const now = new Date() + const pad = (n: number) => String(n).padStart(2, '0') + const nowStr = `${now.getFullYear()}-${pad(now.getMonth() + 1)}-${pad(now.getDate())} ${pad(now.getHours())}:${pad(now.getMinutes())}:${pad(now.getSeconds())}` + + // 单据头:优先对齐出库单A5模板字段名(field_code),兼容列表字段名与 order 字段名 const formData: any = { + // 模板字段(供 getPreviewValue 按 field_code 取用) + delivery_order_code: row.stockout_order_code || row.delivery_order_code || '', + name: row.receiver_name || row.name || '', + mobile: row.receiver_mobile || row.mobile || '', + province: row.receiver_province || row.province || '', + city: row.receiver_city || row.city || '', + area: row.receiver_area || row.area || '', + detail_address: row.receiver_detail_address ?? row.detail_address ?? row.detailAddress ?? '', + logistics_name: row.express_name || row.logistics_name || '', + wave_no: row.wave_no || '', + create_at: row.created_at || row.create_at || '', + print_time: nowStr, + remark: row.remark || '', + // 其余单据信息 stockout_order_code: row.stockout_order_code || '', express_code: row.express_code || '', express_codes: row.express_codes || '', @@ -1057,7 +1077,6 @@ async function fetchPrintData(row: any, _index: number) { sync_status: row.sync_status || '', store_name: row.store_name || row['store.remask'] || row['store.store_remask'] || '', total_order_lines: row.total_order_lines ?? '', - remark: row.remark || '', order_create_time: row.order_create_time || '', created_at: row.created_at || '', updated_at: row.updated_at || '', @@ -1075,7 +1094,25 @@ async function fetchPrintData(row: any, _index: number) { ? payload.items : [] formData.details = formatStockoutListItems(rows) + + // 从 order 中取值:优先模板字段名,兼容列表字段名;取不到保留列表行值 + const pick = (keys: string[], fallback: any) => { + for (const k of keys) { + if (order[k] !== undefined && order[k] !== null && String(order[k]).trim() !== '') return order[k] + } + return fallback + } Object.assign(formData, { + delivery_order_code: pick(['delivery_order_code', 'stockout_order_code'], formData.delivery_order_code), + name: pick(['name', 'receiver_name'], formData.name), + mobile: pick(['mobile', 'receiver_mobile'], formData.mobile), + province: pick(['province', 'receiver_province'], formData.province), + city: pick(['city', 'receiver_city'], formData.city), + area: pick(['area', 'receiver_area'], formData.area), + detail_address: pick(['detail_address', 'detailAddress', 'receiver_detail_address', 'receiver_detail'], formData.detail_address), + logistics_name: pick(['logistics_name', 'express_name'], formData.logistics_name), + wave_no: pick(['wave_no'], formData.wave_no), + create_at: pick(['create_at', 'created_at'], formData.create_at), stockout_order_code: order.stockout_order_code || formData.stockout_order_code, express_code: order.express_code ?? formData.express_code, express_codes: order.express_codes ?? formData.express_codes, diff --git a/src/views/storage/stockout/stockout-config.ts b/src/views/storage/stockout/stockout-config.ts index 98fb9493..ac2c03a5 100644 --- a/src/views/storage/stockout/stockout-config.ts +++ b/src/views/storage/stockout/stockout-config.ts @@ -331,7 +331,11 @@ export function formatStockoutListItems(list: any[] = []) { stock_unit: item.stock_unit ?? snap.stock_unit ?? '', actual_qty: item.actual_qty ?? item.actual_quantity ?? '', batch_no: item.batch_no ?? '', - remark: item.remark ?? '' + remark: item.remark ?? '', + // 打印模板(出库单A5)表格列所需字段 + plan_qty: item.plan_qty ?? item.plan_quantity ?? '', + actual_price: item.actual_price ?? item.price ?? '', + detail_remark: item.detail_remark ?? item.remark ?? '' } }) } diff --git a/src/views/store/stores/index.vue b/src/views/store/stores/index.vue index e53383aa..eba19dd6 100644 --- a/src/views/store/stores/index.vue +++ b/src/views/store/stores/index.vue @@ -2199,12 +2199,14 @@ async function submitCreateUser() { createUserDialog.visible = false if (created && password) { // 仅本次新建账号时返回初始明文密码 + const username = String(data?.username ?? createUserForm.username ?? '').trim() + const copyText = `地址:https://wms.wms.gztbyc.com/\n账号:${username}\n密码:${password}` ElMessageBox.alert( - `用户名:${data?.username ?? createUserForm.username}\n初始密码:${password}`, + copyText, '创建成功', - { confirmButtonText: '复制密码并关闭', type: 'success' } + { confirmButtonText: '复制并关闭', type: 'success' } ).then(() => { - navigator.clipboard?.writeText(password).catch(() => {}) + navigator.clipboard?.writeText(copyText).catch(() => {}) }).catch(() => {}) } else { ElMessage.success(created ? '创建成功' : '账号已存在,已为货主授权')