diff --git a/docs/oms系统设计-050801.md b/docs/oms系统设计-050801.md index c604368..69cabb4 100644 --- a/docs/oms系统设计-050801.md +++ b/docs/oms系统设计-050801.md @@ -208,15 +208,37 @@ OMS 业务表中的 **`CustomerId`** 指向 **`t_customer.Id`**(客户业务 #### 3.1.2 必备字段(所有表) +> **强制**:凡继承 `OmsAuditedAggregateRoot` / Fake `AggregateRoot` 的 OMS 实体表,建表与增量迁移 **必须**包含下表全部字段。漏列会导致 SqlSugar 生成 SQL 时报错,例如:`Unknown column 'ConcurrencyStamp' in 'field list'`。 + | 字段名 | 字段类型 | 说明 | | --- | --- | --- | -| Id | BIGINT | 主键,自增,步长 1 | +| Id | INT / BIGINT | 主键,自增(实现侧多为 `INT` IDENTITY) | | IsDeleted | TINYINT | 软删除:0-否,1-是,默认 0 | +| **ConcurrencyStamp** | **CHAR(36)** | **并发戳(乐观锁版本)**;来自 Fake `AggregateRoot`,ORM 读写自动带上;更新时校验/轮换,防止并发覆盖写。业务代码一般无需手写。库表默认值用**固定 GUID**(见下),**禁止**迁移脚本写 `DEFAULT (UUID())` | | CreateUserId | INT | 创建人 | | CreateTime | DATETIME | 创建时间 | -| UpdateUserId | INT | 更新人 | -| UpdateTime | DATETIME | 更新时间 | +| UpdateUserId | INT | 更新人(可空) | +| UpdateTime | DATETIME | 更新时间(可空) | +**建表 / 迁移检查清单** + +1. 新建表:`CREATE TABLE` 必须含 `ConcurrencyStamp CHAR(36) NOT NULL DEFAULT '00000000-0000-0000-0000-000000000000'`(建议放在 `IsDeleted` 之后)。 +2. 增量脚本:若实体已有该属性而库表没有,须 `ALTER TABLE ... ADD COLUMN ConcurrencyStamp ...`(可参考 `sql/fix_concurrency_stamp_missing.sql`)。 +3. **复制安全(Error/Note 1674)**:`DEFAULT (UUID())` / `UPDATE ... SET x = UUID()` 在 STATEMENT/MIXED binlog 下会被判为 unsafe(主从可能得到不同值)。迁移 DDL **一律用常量默认值**;真实 UUID 由应用插入/更新时写入。若必须用 `UUID()` 回填历史行,会话临时 `SET SESSION binlog_format='ROW'`(需权限)或接受仅在 ROW 复制拓扑执行。 +4. 评审:新迁移 PR 对照本节必备字段,禁止再出现「实体有列、库表无列」。 +5. 典型报错定位:接口返回 `Unknown column 'ConcurrencyStamp'` → 查 SQL 中的表名 → 对该表补列后重试。 + +**DDL 示例片段** + +```sql +`IsDeleted` TINYINT NOT NULL DEFAULT 0 COMMENT '软删除:0-否,1-是', +-- 禁止:DEFAULT (UUID()) → 复制环境 1674 +`ConcurrencyStamp` CHAR(36) NOT NULL DEFAULT '00000000-0000-0000-0000-000000000000' COMMENT '并发戳', +`CreateUserId` INT NOT NULL DEFAULT 0 COMMENT '创建人', +`CreateTime` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', +`UpdateUserId` INT NULL COMMENT '更新人', +`UpdateTime` DATETIME NULL COMMENT '更新时间', +``` #### 3.1.3 字段命名规范 | 规范 | 说明 | 示例 | @@ -617,6 +639,67 @@ JWT → mapId(user.userid INT) | idx_csa_customer | KEY | CustomerId, IsDeleted, Id | 客户列表 | | idx_csa_customer_default | KEY | CustomerId, IsDefault | 默认地址查询 | +#### 4.2.11 物流单仓储绑定表 `t_order_stock_bind` + +> **用途**:客户在「我的订单」对**已创建成功**的物流单(`t_order`)绑定仓储 **包裹行** 或 **库存 SKU**,用于代发出库占用。 +> **与店铺 `match-inventory` 区别**:店铺链路是「店铺订单 → 扣库存 → **创建**物流单」;本表是「物流单已存在 → **挂载**包裹/库存」。 +> **数量**:绑定数量**不要求**与 `t_order_declaration` 申报件数对齐。 +> **冻结**:绑定保存时冻结(`C_inventory` / `C_parcel_item` 的 `FrozenQty`↑、`AvailableQty`↓);确认出库/预报钩子再扣实物 `Qty`/`Quantity` 并释放冻结。 +> **迁移脚本**:`sql/migrate_t_order_stock_bind.sql`。 + +| 字段名 | 字段类型 | 长度 | 主键/外键 | 非空 | 说明 | +| --- | --- | --- | --- | --- | --- | +| Id | INT | - | 主键 | 是 | 自增 | +| OrderId | INT | - | 外键 → `t_order.Id` | 是 | 物流单 | +| CustomerId | INT | - | 外键 → `t_customer.Id` | 是 | 归属客户(隔离键) | +| WarehouseId | INT | - | - | 是 | 仓库;须与订单 `WarehouseId` 一致(订单无仓库时以本字段写入为准) | +| BindType | VARCHAR | 20 | - | 是 | `inventory` / `parcelItem` | +| SkuId | INT | - | - | 否 | 库存必填;包裹行可空(未上架) | +| InventoryId | INT | - | → `C_inventory.Id` | 否 | 指定库位行;空则按 SKU 自动分摊冻结 | +| BinLocationId | INT | - | - | 否 | 库位快照 | +| ParcelId | INT | - | → `C_parcel.Id` | 否 | `BindType=parcelItem` 时必填 | +| ParcelItemId | INT | - | → `C_parcel_item.Id` | 否 | `BindType=parcelItem` 时必填 | +| BindQty | INT | - | - | 是 | 绑定数量,>0 | +| Status | VARCHAR | 20 | - | 是 | `bound` 已冻结 / `deducted` 已扣实物 / `released` 已释放 | +| SkuCode | VARCHAR | 64 | - | 否 | 展示快照 | +| SkuName | VARCHAR | 128 | - | 否 | 展示快照 | +| TrackingNo | VARCHAR | 64 | - | 否 | 包裹运单号快照 | +| ProductName | VARCHAR | 256 | - | 否 | 包裹品名快照 | +| ImageUrl | VARCHAR | 512 | - | 否 | 图片快照 | +| AttributeText | VARCHAR | 256 | - | 否 | 规格快照 | +| Remark | VARCHAR | 512 | - | 否 | 备注 | +| IsDeleted | TINYINT | - | - | 是 | 软删,默认 0 | +| ConcurrencyStamp | CHAR | 36 | - | 是 | 并发戳;见 **§3.1.2**,默认 UUID | +| CreateUserId | INT | - | - | 是 | 创建人 | +| CreateTime | DATETIME | - | - | 是 | 创建时间 | +| UpdateUserId | INT | - | - | 否 | 更新人 | +| UpdateTime | DATETIME | - | - | 否 | 更新时间 | + +**索引** + +| 索引名 | 类型 | 字段 | 说明 | +| --- | --- | --- | --- | +| idx_osb_order | KEY | OrderId, IsDeleted, Status | 订单绑定明细 | +| idx_osb_parcel_item | KEY | ParcelItemId, Status, IsDeleted | 包裹行占用汇总 | +| idx_osb_sku | KEY | CustomerId, WarehouseId, SkuId, Status | 库存占用查询 | + +**仓储表字段增量(同迁移脚本)** + +| 表 | 新增字段 | 说明 | +| --- | --- | --- | +| `C_inventory` | `FrozenQty` INT NOT NULL DEFAULT 0 | 已绑定未出库冻结量 | +| `C_inventory` | `AvailableQty` INT NOT NULL DEFAULT 0 | 可用 = `Qty - FrozenQty`(应用层维护) | +| `C_parcel_item` | `FrozenQty` INT NOT NULL DEFAULT 0 | 已被物流单占用数量 | +| `C_parcel_item` | `AvailableQty` INT NOT NULL DEFAULT 0 | 可用 = `Quantity - FrozenQty`(应用层维护) | + +**不变量** + +1. `AvailableQty = Qty(或 Quantity) - FrozenQty`,且三者均 ≥ 0。 +2. 绑定保存:校验 `BindQty ≤ AvailableQty`(对本单原占用先释放再算)。 +3. 包裹 Tab **允许全部生命周期**(`inTransit` / `arrived` / `stored`)。 +4. 已上架包裹行(有 `SkuId`)绑定包裹时**同时**冻结对应库存,避免重复售卖。 +5. 保存采用**全量覆盖**:提交 `items[]` 为最终态。 + ### 4.3 下单计费与版本策略(配置 → 运行时 → 下单) > 本节约定**销售产品**维度的规则/卖价如何进入线上算价链路,以及与 `t_order` 版本字段的对应关系;与渠道模块中「运营发布 → 生成版本」接口衔接。 @@ -2563,6 +2646,141 @@ t_order(OrderSource=pickup, PickupTime, CustomerSenderAddressId) | 权限 | `Order.SenderAddress.Query` / `.Create` / `.Update` / `.Delete` | | 联动 | 揽收创建页下拉刷新本列表;删除已占用地址 **允许**(订单已快照) | +#### 4.4.6 物流单绑定包裹/库存(我的订单) + +> **入口**:我的订单 → 选中一单 →「绑定包裹/库存」弹窗(左:包裹/库存 Tab;右:已选明细,可调数量)。 +> **权限**:`Order.MyOrders.StockBind`。 +> **实现状态**:设计落地中(oms0414-back `OrderService.StockBind` + 前端 `StockBindModal`)。 + +##### 4.4.6.1 接口清单 + +| 接口名称 | 请求方式 | 请求路径 | 说明 | +| --- | --- | --- | --- | +| 当前绑定 | GET | /order/stock-bind/detail | `orderId`;右侧已选 | +| 库存候选 | POST | /order/stock-bind/inventory-candidates | 左侧库存 Tab | +| 包裹候选 | POST | /order/stock-bind/parcel-candidates | 左侧包裹 Tab(**全部生命周期**) | +| 保存绑定 | POST | /order/stock-bind/save | 全量覆盖;冻结 | +| 清空绑定 | POST | /order/stock-bind/clear | 释放全部 `bound` | +| 确认扣减 | POST | /order/stock-bind/confirm-deduct | 扣实物并 `deducted`;可由预报/出库钩子调用 | + +##### 4.4.6.2 当前绑定(GET /order/stock-bind/detail) + +**请求**:`orderId`(必填)。 + +**响应** + +```json +{ + "orderId": 1001, + "warehouseId": 3, + "warehouseName": "华南仓", + "bindStatus": "bound", + "items": [ + { + "id": 11, + "bindType": "inventory", + "skuId": 88, + "skuCode": "SKU-A", + "skuName": "T恤", + "inventoryId": null, + "binLocationId": 5, + "binCode": "A-01", + "bindQty": 2, + "availableQty": 10, + "imageUrl": null, + "status": "bound" + }, + { + "id": 12, + "bindType": "parcelItem", + "parcelId": 50, + "parcelItemId": 501, + "trackingNo": "YT123", + "productName": "配件", + "attributeText": "红/L", + "skuId": 88, + "skuCode": "SKU-A", + "bindQty": 1, + "availableQty": 3, + "imageUrl": "", + "status": "bound" + } + ] +} +``` + +`bindStatus`:`none` / `bound` / `deducted`(存在任意 `deducted` 优先;否则有 `bound` 为 `bound`)。 + +##### 4.4.6.3 库存候选(POST /order/stock-bind/inventory-candidates) + +```json +{ + "orderId": 1001, + "warehouseId": 3, + "keyword": "", + "page": 1, + "pageSize": 30 +} +``` + +- 默认仓库:入参 `warehouseId` 优先,否则取订单 `WarehouseId`。 +- 仅返回 `AvailableQty > 0` 的 SKU 汇总。 +- 响应:`total` + `items[]`:`skuId`, `skuCode`, `skuName`, `skuImageUrl`, `warehouseId`, `totalQty`, `frozenQty`, `availableQty`, `binCount`。 + +##### 4.4.6.4 包裹候选(POST /order/stock-bind/parcel-candidates) + +```json +{ + "orderId": 1001, + "warehouseId": 3, + "lifecycleStatus": "", + "keyword": "", + "page": 1, + "pageSize": 20 +} +``` + +- `lifecycleStatus` 空或 `all`:全部生命周期均可。 +- 包裹下行:`parcelItemId`, `productName`, `attributeText`, `imageUrl`, `skuId`, `skuCode`, `quantity`, `frozenQty`, `availableQty`。 +- 仅下行 `availableQty > 0` 的包裹进入列表(包裹头仍可展示)。 + +##### 4.4.6.5 保存绑定(POST /order/stock-bind/save) + +```json +{ + "orderId": 1001, + "items": [ + { "bindType": "inventory", "skuId": 88, "bindQty": 2, "inventoryId": null }, + { "bindType": "parcelItem", "parcelId": 50, "parcelItemId": 501, "bindQty": 1 } + ] +} +``` + +**服务端步骤** + +1. 校验订单归属;`OrderStatus` 为已删除/已取消则拒绝;若已有 `deducted` 明细则拒绝改绑(须先业务回滚,本期不做回滚接口)。 +2. 解析仓库;无仓库且候选依赖仓库时拒绝。 +3. 读取现有 `Status=bound` 明细 → 全部释放冻结 → 软删/标 `released`。 +4. 按 `items[]` 重新冻结并插入 `bound` 明细(空数组等价清空)。 +5. `inventory`:按 `inventoryId` 或 SKU 多库位分摊冻结 `C_inventory`。 +6. `parcelItem`:冻结 `C_parcel_item`;若行上已有 `SkuId`,同步按 SKU 冻结库存。 +7. **不**校验申报明细数量。 +8. 事务提交;响应同 detail。 + +##### 4.4.6.6 清空 / 确认扣减 + +- `POST /order/stock-bind/clear`:`{ "orderId" }`,仅释放 `bound`。 +- `POST /order/stock-bind/confirm-deduct`:对 `bound` 行:`Qty`/`Quantity` 与 `FrozenQty` 同减 `BindQty`,`AvailableQty` 重算,明细改 `deducted`。 + +##### 4.4.6.7 前端(itfx-front) + +| 项 | 说明 | +| --- | --- | +| 入口 | `/order/myOrders` 工具栏/更多:「绑定包裹/库存」 | +| 组件 | `StockBindModal.vue`:左右两卡片;左 Tab 包裹/库存;右已选 + 数量步进 | +| 权限 | `Order.MyOrders.StockBind` | +| 规范 | `docs/前端页面设计规范.md`;主色 `var(--app-primary-color)` | + ## 5 渠道模块 ### 5.1 核心需求说明 diff --git a/docs/面单标签模板与PDF生成方案.md b/docs/面单标签模板与PDF生成方案.md new file mode 100644 index 0000000..34c9213 --- /dev/null +++ b/docs/面单标签模板与PDF生成方案.md @@ -0,0 +1,626 @@ +# OMS 面单标签模板设计与 PDF 生成方案 + +> **版本**:v0.4(开工核对版) +> **日期**:2026-07-18 +> **基线文档**:`docs/oms系统设计-050801.md`(§5.1 标签设计 / §5.2.20 `t_label_template` / §6 操作打印 / §9~10 订单 `labelUrl`) + +### 已确认决策 + +| 项 | 结论 | +| --- | --- | +| 出 PDF 时机 | **异步**(Pending → Ready / Failed) | +| 产品「客户面单」 | **下拉选具体模板**(`LabelTemplateId`),去掉写死「系统面单/客户面单」枚举作为出单依据 | +| 渲染引擎 | **纯 .NET**:`HiprintJson → QuestPDF`;vg-print **只做设计** | +| 默认模板 | 产品未选时回落 **全局默认模板 Id**(配置项) | +| 模板归属(一期) | **仅运营/管理员**设计与维护(客户自助 → 二期) | +| 默认纸张(一期) | **100×150 mm**(模板可改;未填时用此默认) | + +### 落地进度(相对本文) + +| 模块 | 状态 | 说明 | +| --- | --- | --- | +| 标签设计列表 + 新建弹窗 + 懒加载设计器 | **已做** | `labelDesign`:list/get/save/delete;新建弹窗填名称/类型再进设计 | +| 模板 CRUD API | **已做** | `GET list` / `GET {id}` / `POST save` / `POST delete` | +| Hiprint→QuestPDF 渲染器 | **已做** | Parser/IR/QuestPDF + 样本单测 | +| 异步出 PDF + 订单状态字段 | **已做** | Pending/Ready/Failed;创单投递 `generate-label-pdf` | +| 替换 HTML stub / 批量&仓内打 PDF | **已做** | print / batch / 仓内返回 PDF `printUrl`;无模板时回落 HTML | +| `IsEnabled` / 纸张字段 / enable API | **一期可砍** | 用「有无模板」即可;纸张从 JSON panel 读 | +| 独立 `labelTemplate` 列表页 | **取消** | 已并入 `labelDesign`,勿再建 | +| 设计器字段字典注入 | **已做** | `field-dictionary` + 设计器左侧字段 | +| 销售产品绑 `LabelTemplateId` | **已做** | 下拉接模板列表 | + +--- + +## 0. 一期开工范围(核对无遗漏后按此做) + +### 0.1 必须做(闭环) + +1. **导出真实 TemplateJson 样本** + 单位校准单测(pt/mm)。 +2. **`ILabelPdfRenderer`**:Parser → IR → QuestPDF;一期元素:text / barcode / qrcode / longText / hline / vline / rect / image。 +3. **`LabelPrintDataBuilder`**:订单 → PrintData(附录 B 字段)。 +4. **订单字段**:`LabelUrl`(复用/确认)、`LabelTemplateId`、`LabelGenerateStatus`、`LabelGenerateError`;SQL 迁移。 +5. **异步任务** `generateLabelPdf`(复用现有批量队列机制)。 +6. **创单投递任务**;`POST /order/print`、`batch/print` 返回 PDF `printUrl`;Pending/Failed 前端提示。 +7. **销售产品**:`LabelTemplateId` + 下拉接 `label-template/list`;废弃枚举出单逻辑。 +8. **全局默认模板配置**(配置表或 appsettings 键均可,先简单)。 +9. **设计器字段字典**:`GET field-dictionary` + vg-print 左侧可拖字段(至少单号/收件/重量常用组)。 +10. **仓内 print-label**:返回 `printUrl`;模板下拉改真实列表(可选覆盖)。 + +### 0.2 一期明确不做(避免范围膨胀) + +- Playwright / 浏览器渲染 +- table / html 元素、页眉页脚高级规则 +- 模板启停 API、预览图、客户自助设计 +- PDF 合并下载、地址变更自动 stale(二期) +- 平台店铺 ShippingLabelUrl + +### 0.3 建议实施顺序 + +```text +① JSON 样本 + Renderer 单测 +② PrintDataBuilder + preview-pdf(管理端验收版式) +③ 订单字段迁移 + 异步 generateLabelPdf + 创单挂钩 +④ 销售产品 LabelTemplateId 下拉 +⑤ 设计器字段字典 +⑥ order/print + batch/print + 仓内 printUrl +``` + +--- + +## 1. 背景与目标 + +### 1.1 要解决的问题 + +1. **标签样式不可配置**:订单创建后的「面单」目前是固定 HTML stub,无法按客户/产品定制版式。 +2. **设计器与打印链路断开**:`vg-print` 已能设计并保存 `TemplateJson`,但创建订单、单票打印、批量打印均未消费该模板。 +3. **批量打印需要稳定文件**:仓内/客服批量出单希望拿到 **PDF**(可下载、可静默打印、可归档),而不是临时拼 HTML。 +4. **产品「客户面单」未绑模板**:字段名虽叫客户面单,下拉却是写死的「系统面单/客户面单」,与 `t_label_template` 无关。 + +### 1.2 目标(一期) + +| 目标 | 说明 | +| --- | --- | +| 可设计 | vg-print 设计,拖拽绑定订单字段,保存 `TemplateJson` | +| 可保存 | 模板 CRUD(名称、类型;列表浏览/删除)— **已有** | +| 可绑定 | 销售产品「客户面单」改为 **模板下拉**(`LabelTemplateId`) | +| 可出 PDF | 纯 .NET 解析 `TemplateJson` + PrintData → 异步生成 PDF | +| 可批量 | 按 `labelUrl` 批量静默打 / 下载 | + +### 1.3 非目标(一期不做) + +- 平台店铺面单(Shopee 等)仍走平台 URL。 +- 不在服务端跑 Playwright/Chromium。 +- 不保证 hiprint 全部高级特性 100% 还原(见 §3.3 支持矩阵);一期覆盖面单常用元素。 +- 不做模板审批流 / 模板市场 / 客户自助设计。 + +--- + +## 2. 现状结论(Gap) + +```mermaid +flowchart LR + A[vg-print 设计器] -->|保存 TemplateJson| B[(t_label_template)] + C[销售产品 CustomerWaybill] -.->|仅枚举字符串| X[未关联模板] + D[创建订单 / 打单] -->|CreateOrderPrintFileAsync| E[极简 HTML] + F[仓内 print-label] -->|只写记录| G[(t_label_print_record)] + H[批量 print] --> E + B -.->|未消费| D +``` + +| 能力 | 现状 | 缺口 | +| --- | --- | --- | +| 设计器 | 列表+懒加载设计器 **已有**;新建弹窗 **已有** | 字段字典未注入 | +| 模板存储 | `t_label_template` CRUD **已有** | 纸张可读 panel;启停可砍 | +| 产品绑定 | `CustomerWaybill` 写死两枚举 | → `LabelTemplateId` | +| 渲染 | HTML stub | HiprintJson→PDF | +| 仓内打印 | 记日志 | 返回/打开 PDF | +| 批量 | 有框架 | 依赖真实 `labelUrl`(PDF) | + +--- + +## 3. 总体方案 + +### 3.1 核心思路 + +把链路拆成四段,职责清晰: + +| 阶段 | 做什么 | 产物 | +| --- | --- | --- | +| **① 设计** | vg-print 配置版式,左侧拖订单字段占位符 | `TemplateJson` | +| **② 绑定** | 销售产品「客户面单」下拉选模板 | `SalesProduct.LabelTemplateId` | +| **③ 灌数出 PDF** | 异步:.NET 解析 TemplateJson + PrintData → PDF | `Order.LabelUrl` | +| **④ 打印** | 单票 / 批量 / 仓内,统一打 `labelUrl` | 打印机 / 下载 | + +### 3.2 架构(纯 .NET 渲染 + 客户端静默打) + +```mermaid +sequenceDiagram + participant Designer as vg-print 设计器 + participant API as OMS API (.NET) + participant DB as DB + participant Worker as 异步 Worker + participant FE as 订单/仓内前端 + participant Hiprint as 本地 hiprint 客户端 + + Designer->>API: 保存 TemplateJson + API->>DB: t_label_template + Note over API,DB: 产品「客户面单」下拉存 LabelTemplateId + + FE->>API: 创建订单 + API->>DB: 落单 + Pending + 投递 generateLabelPdf + Worker->>DB: 读模板 JSON + 组 PrintData + Worker->>Worker: HiprintJsonRenderer → QuestPDF + Worker->>DB: 写 PDF + Ready/labelUrl + + FE->>API: 打印(Ready) + API-->>FE: printUrl (PDF) + FE->>Hiprint: 静默打印 PDF +``` + +- **设计**:继续 vg-print(前端)。 +- **出文件**:纯 .NET,**不**起浏览器。 +- **送打印机**:前端 hiprint 客户端打已生成的 PDF(与现网批量打印一致)。 + +### 3.3 纯 .NET 如何「转化使用」vg-print 保存的 JSON(已确认) + +#### 3.3.1 思路 + +vg-print / hiprint 的 `TemplateJson` 本质是 **声明式版式**:纸张尺寸 + 绝对定位元素列表(文本/条码/线/图/表…)。 +我们不在服务端执行 JS,而是: + +1. **反序列化** JSON → C# 模型(`HiprintTemplate` / `HiprintPanel` / `HiprintElement`) +2. **灌数**:按 `options.field` 从 `PrintData` 取值(无 field 则用 `title` 静态文案) +3. **绘制**:用 **QuestPDF**(或 PdfSharp)按 left/top/width/height 绝对定位画到页面 +4. **条码/二维码**:`options.textType = barcode | qrcode` 时用 **ZXing.Net** 生成图片再嵌入 + +```text +TemplateJson (hiprint) + │ + ▼ + HiprintTemplateParser ← 只认我们支持的元素子集 + │ + ▼ + Intermediate IR ← 统一:PageSize + List + │ + ▼ + QuestPdfEmitter ← 输出 PDF bytes +``` + +中间 IR 的好处:以后若换 PdfSharp,只换 Emitter;Parser 不动。 + +#### 3.3.2 JSON 结构(需解析的关键部分) + +典型形态(示意): + +```json +{ + "panels": [ + { + "index": 0, + "width": 100, + "height": 150, + "printElements": [ + { + "printElementType": { "type": "text" }, + "options": { + "left": 20, "top": 30, "width": 120, "height": 20, + "field": "serviceNo", + "title": "运单号", + "fontSize": 12, + "fontWeight": "bold", + "textAlign": "left", + "textType": "text" + } + }, + { + "printElementType": { "type": "text" }, + "options": { + "left": 20, "top": 60, "width": 160, "height": 40, + "field": "serviceNo", + "textType": "barcode" + } + } + ] + } + ] +} +``` + +坐标约定(实现时用真实样本校准一次): + +| 项 | hiprint 常见单位 | .NET 处理 | +| --- | --- | --- | +| 纸张 width/height | **mm** | QuestPDF `PageSizes` / 自定义 mm | +| 元素 left/top/width/height | **pt**(1 inch = 72 pt) | 换算:`pt → mm = pt * 25.4 / 72` | +| fontSize | pt | 直接用 | + +> 落地第一步:从设计器导出 1~2 份真实 JSON 做单元测试,校准单位(不同 vg-print 版本偶有差异)。 + +#### 3.3.3 元素支持矩阵(一期 / 二期) + +| 元素 type / textType | 一期 | 实现要点 | +| --- | --- | --- | +| text(普通文本) | ✅ | 灌 field;字体/对齐/颜色/粗体 | +| text + barcode | ✅ | ZXing Code128(可配置) | +| text + qrcode | ✅ | ZXing QR | +| longText | ✅ | 多行换行、超出裁剪或缩小 | +| hline / vline | ✅ | 线宽、颜色 | +| rect | ✅ | 边框/填充(简化) | +| image | ✅ | 静态图 URL/相对路径;或 field 指向图片地址 | +| table | 二期 | 按 columns + items[] 画表;一期可用「多行 text」凑合 | +| html | ❌ 一期跳过 | 设计规范禁止用自定义 HTML 做面单关键信息 | +| 页眉页脚/页码高级规则 | 二期 | 面单多为单页,一期可忽略 | + +**设计规范(避免踩坑)**:面单模板只用支持矩阵内的控件;保存模板时可做服务端校验,遇到不支持类型给出警告。 + +#### 3.3.4 关键代码落点(建议) + +| 组件 | 位置(建议) | +| --- | --- | +| `HiprintTemplateDocument` 等模型 | `Oms.Application/Labeling/Hiprint/` | +| `HiprintTemplateParser` | 同上 | +| `ILabelPdfRenderer` / `QuestPdfLabelRenderer` | 同上 | +| `LabelPrintDataBuilder` | 订单 → PrintData 字典 | +| `GenerateLabelPdfJobHandler` | 异步队列 Worker | +| NuGet | `QuestPDF`、`ZXing.Net`(及 ImageSharp 如需) | + +接口形态: + +```csharp +public interface ILabelPdfRenderer +{ + Task RenderAsync(string templateJson, IReadOnlyDictionary printData, CancellationToken ct = default); +} +``` + +#### 3.3.5 与「设计预览」的对齐策略 + +| 手段 | 说明 | +| --- | --- | +| 设计器预览 | 仍用 vg-print 前端预览(设计时) | +| 服务端预览 API | `POST .../preview-pdf` 走同一套 `ILabelPdfRenderer`,给产品配置/验收用 | +| 回归用例 | 固定 TemplateJson + PrintData → 对比 PDF 哈希或关键区域截图 | + +预期:**常用面单元素**视觉接近;像素级与浏览器 hiprint 不完全一致(字体 hinting 等),以「可扫码、信息齐全、布局不错位」为验收标准。 + +#### 3.3.6 为何仍划算(相对 Playwright) + +- 无 Chromium 运维,部署与现有 API 一致。 +- 异步高峰更可控(线程池而非浏览器池)。 +- 设计器继续复用,**不是**推倒重做;成本在「解析器 + 支持矩阵」,可控且可测。 + +### 3.4 异步出 PDF(已确认) + +创单:落单 → 解析产品 `LabelTemplateId`(空则全局默认)→ `LabelGenerateStatus=Pending` → 投递 `generateLabelPdf` → 立即返回。 + +Worker:`PrintData` → `ILabelPdfRenderer` → 落盘 → `Ready` / `Failed`。 + +打印:Ready 用 `labelUrl`;Pending 提示生成中或短等补生成;Failed 可「重新生成」。 + +### 3.5 产品「客户面单」字段改造(已确认) + +**现状**:`customerWaybillOptions` 写死: + +```ts +{ label: '系统面单', value: '系统面单' }, +{ label: '客户面单', value: '客户面单' }, +``` + +与模板库无关,不能表达「用哪张版式」。 + +**改造**: + +| 项 | 做法 | +| --- | --- | +| UI | 「客户面单」下拉改为拉 `GET /channel/label-template/list`(启用中的模板),展示 `Name` | +| 存储 | 新增/使用 `LabelTemplateId`(long,可空) | +| 旧字段 `CustomerWaybill` | 迁移期可废弃写入,或仅作展示兼容;**出 PDF 只认 LabelTemplateId** | +| 未选模板 | 使用系统配置的 **全局默认模板 Id**;若默认也没有 → 异步任务 Failed,并提示去配置 | + +仓内打印页的模板下拉同理:不要写死 `lastMile/customer/...` 类型枚举当「模板」,应拉真实模板列表(类型可作筛选)。 + +平台店铺面单 URL 仍独立,不进该下拉。 + +## 4. 领域模型 + +### 4.1 模板 `t_label_template` + +| 字段 | 一期 | 说明 | +| --- | --- | --- | +| Id / Name / TemplateType / TemplateJson | ✅ 已有 | CRUD 已通 | +| PaperWidthMm / PaperHeightMm | 可选 | **优先从 TemplateJson.panels[0] 读**;缺省 100×150 | +| IsEnabled / PreviewImageUrl / Remark | 二期 | 一期不做启停 | + +### 4.2 销售产品绑定 + +| 字段 | 说明 | +| --- | --- | +| LabelTemplateId | **主字段**:客户面单下拉选中的模板 Id | +| CustomerWaybill | 旧枚举;迁移后停止作为出单依据(可留列不清) | + +解析:`产品.LabelTemplateId` → 否则 → `全局默认模板Id` → 否则 Failed。 + +### 4.3 订单侧产物 + +| 字段 | 说明 | +| --- | --- | +| `LabelUrl` | PDF 路径(替换 HTML stub) | +| `LabelTemplateId` | 实际模板 Id | +| `LabelGenerateStatus` | `Pending` / `Ready` / `Failed` | +| `LabelGenerateError` | 失败原因 | +| PrintData 快照 | 建议一期就落 json 列或扩展表,便于重打 | + +### 4.4 仓内打印记录 + +- `print-label/print` 返回 `printUrl`;可选写 `PrintFileUrl` 到记录表。 + +### 设计页交互(已落地) + +- 默认列表;新建弹窗(名称+类型)→ 懒加载设计器;返回卸载。 +- API:list / get / save / delete。 +- **待补**:字段字典注入。 + +--- + +## 5. 字段字典(设计器左侧可拖字段) + +设计器不应让业务人员手写字段名。一期提供 **标准 PrintData Schema**,前端注入 vg-print 的元素/字段面板。 + +### 5.1 命名约定 + +- 全部 **camelCase**,与前端/hiprint `print(data)` 一致。 +- 地址类同时提供分行字段与 `recipientAddressFull`。 + +### 5.2 字段分组(初稿) + +#### A. 单号 + +| 字段 | 说明 | +| --- | --- | +| serviceNo | 运单号 / 服务商单号 | +| clientNo | 客户单号 | +| trackNo | 跟踪号 | +| otherNo | 其他单号(若有) | +| requestId | 请求号 | + +#### B. 产品 / 渠道 / 仓库 + +| 字段 | 说明 | +| --- | --- | +| productCode | 销售产品编码 | +| salesProductName | 销售产品名称 | +| channelCode | 渠道编码 | +| channelName | 渠道名称 | +| warehouseName | 仓库名称 | +| customerCode / customerName | 客户(管理端场景) | + +#### C. 收件人 + +| 字段 | 说明 | +| --- | --- | +| recipientName | 姓名 | +| recipientCompany | 公司 | +| recipientPhone | 电话 | +| recipientEmail | 邮箱 | +| recipientZip | 邮编 | +| recipientCountry / recipientCountryName | 国家 | +| recipientProvince / City / Street1/2/3 | 省市区街道 | +| recipientAddressFull | 拼接地址 | +| recipientTaxNo / vatNo / eori | 税号类 | + +#### D. 发件人 + +对称字段:`senderName`、`senderCompany`、`senderPhone`、`senderAddressFull` … + +#### E. 重量尺寸 + +| 字段 | 说明 | +| --- | --- | +| actualWeight | 实重 | +| volumetricWeight | 体积重 | +| chargeableWeight | 计费重 | +| length / width / height | 长宽高 | +| weightUnit | 默认 KG | +| dimUnit | 默认 CM | + +#### F. 货品明细(表格 — 二期) + +```json +"items": [ + { "skuCode": "", "skuName": "", "qty": 1, "weight": 0.1, "declareNameEn": "", "declareValue": 0 } +] +``` + +一期可用多个 text 字段代替。 + +#### G. 系统 + +| 字段 | 说明 | +| --- | --- | +| printTime | 出 PDF 时间 | +| operatorName | 操作人(仓内打印时) | + +### 5.3 设计器待补 + +1. `GET /channel/label-template/field-dictionary` +2. 注入 vg-print provider / 可拖字段分组 +3. 预览可用 Mock PrintData + +(列表/新建弹窗/保存/删除已完成,勿重复建设独立列表页。) + +--- + +## 6. 关键业务流程 + +### 6.1 设计与发布 + +1. 运营「标签设计」→ 新建弹窗 / 设计 → 拖字段 → 预览 → 保存。 +2. 销售产品「客户面单」下拉选模板(`LabelTemplateId`)。 +3. 配置全局默认模板(产品未选时回落)。 + +### 6.2 创建订单 → 生成 PDF + +| 触发 | 建议 | +| --- | --- | +| 订单创建成功 | **主路径**:异步 `generateLabelPdf` | +| 预报/生成包裹 | 地址重量补全后可 **重生** | +| 地址变更 | 二期:`labelStale` | + +``` +resolveTemplate(product) → buildPrintData(order) → renderPdf +→ /uploads/prints/orders/xxx.pdf → labelUrl + Ready +``` + +### 6.3 单票 / 批量打印 + +- 单票 / 批量:返回 PDF `printUrl`;Pending 提示生成中;Failed 可重生。 +- 合并下载 → 二期。 + +### 6.4 仓内「打印标签」 + +1. lookup(已有)→ 确认打印。 +2. 优先订单 `labelUrl`;无则现场生成。 +3. 返回 `printUrl`;模板下拉接真实列表。 + +--- + +## 7. API 设计(增量) + +### 7.1 模板 + +| 方法 | 路径 | 一期 | +| --- | --- | --- | +| POST save | `/channel/label-template/save` | ✅ | +| GET list | `/channel/label-template/list` | ✅ | +| GET detail | `/channel/label-template/{id}` | ✅ | +| POST delete | `/channel/label-template/delete` | ✅ | +| GET field-dictionary | `/channel/label-template/field-dictionary` | 待做 | +| POST preview-pdf | `/channel/label-template/preview-pdf` | 待做 | +| POST enable | `/channel/label-template/enable` | 砍掉(二期) | + +### 7.2 销售产品 + +- Save/Detail 增加 `labelTemplateId`;下拉接 list。 + +### 7.3 订单 / 打印 + +| 方法 | 说明 | +| --- | --- | +| 创单内部 | 投递 `generateLabelPdf`(非同步堵接口) | +| `POST /order/print` | PDF `printUrl` | +| `POST /order/batch/print` | 每单 PDF url | +| `POST /order/label/regenerate` | 强制重生 | + +### 7.4 仓内 + +| 方法 | 说明 | +| --- | --- | +| `POST /operation/print-label/print` | 返回 `printUrl` | + +### 7.5 渲染(进程内) + +```csharp +Task RenderAsync(string templateJson, IReadOnlyDictionary printData, CancellationToken ct = default); +``` + +--- + +## 8. 前端改造清单 + +| 页面/模块 | 状态 | +| --- | --- | +| `channel/labelDesign` | ✅ 列表+弹窗+懒加载;⏳ 字段字典 | +| `channel/labelTemplate` 独立页 | ❌ 取消 | +| `channel/salesProducts` | ⏳ 模板下拉 | +| `OrderPrintModal` / 我的订单批量 | ⏳ PDF + Pending 提示 | +| `operation/printLabel` | ⏳ printUrl + 真实模板下拉 | +| 权限文案 | 随菜单既有资源即可 | + +--- + +## 9. 分阶段落地 + +### 一期(按 §0.3 顺序) + +见文首 **§0**。 + +### 二期 + +1. table 元素、启停、预览图。 +2. 地址变更 stale / 重生;PDF 合并。 +3. 客户自助设计;保存时不支持元素强校验。 + +### 三期(可选) + +- 仅当 QuestPDF 还原成本过高时再评估 Playwright 兜底。 + +--- + +## 10. 风险与对策 + +| 风险 | 对策 | +| --- | --- | +| JSON 与 PDF 视觉偏差 | 支持矩阵;preview-pdf;pt/mm 单测 | +| 中文字体 | 服务端嵌入 Noto Sans SC / 雅黑 | +| 创单后立刻打印 | Pending 短等或提示稍后 | +| 旧枚举数据 | 出单只认 LabelTemplateId | +| 批量高峰 | 异步队列限流 | + +--- + +## 11. 验收标准(一期) + +1. 设计器模板(文本+条码+线框)经 .NET 出可扫码 PDF。 +2. 销售产品下拉为真实模板,存 `LabelTemplateId`。 +3. 创单异步后 Ready + `labelUrl` 可打开。 +4. 单票/批量/仓内能打该 PDF;Pending 有提示。 +5. 无产品模板且无全局默认 → Failed + 明确提示。 + +--- + +## 12. 决策状态 + +| # | 项 | 状态 | +| --- | --- | --- | +| 1 | 渲染:纯 .NET + Hiprint JSON | **已确认** | +| 2 | 出 PDF:异步 | **已确认** | +| 3 | 产品:模板下拉 | **已确认** | +| 4 | 模板归属 | **一期:仅运营**(已拍板默认) | +| 5 | 默认纸张 | **一期:100×150 mm**(已拍板默认) | + +**结论:方案可开工。** 无阻塞性遗漏;下一刀从 §0.3 ①「真实 JSON 样本 + Renderer」开始。 + +--- + +## 附录 A. 与现有文档章节映射 + +| 本方案 | 设计总册 | +| --- | --- | +| 设计器 / TemplateJson | §5.1、§5.2.20、§5.3.12 | +| 仓内打印记录 | §6.1、§6.2.3、§6.3.3 | +| 订单 labelUrl / batch print | §4.4.1.8、§9.6.3、§10 | +| 批量异步 | `订单批量处理与异步队列方案0707.md` | + +## 附录 B. PrintData 示例(节选) + +```json +{ + "serviceNo": "S202607180001", + "clientNo": "C-10086", + "trackNo": "YT1234567890", + "salesProductName": "专线-普货", + "warehouseName": "SZ-01", + "recipientName": "John Lee", + "recipientPhone": "+1-xxx", + "recipientCountryName": "United States", + "recipientAddressFull": "xxx Street, City, CA 90001", + "actualWeight": 1.25, + "length": 30, + "width": 20, + "height": 10, + "items": [ + { "skuCode": "SKU001", "skuName": "T-Shirt", "qty": 2 } + ], + "printTime": "2026-07-18 14:00:00" +} +``` diff --git a/nginx-default.conf b/nginx-default.conf index e5733d0..416f5b2 100644 --- a/nginx-default.conf +++ b/nginx-default.conf @@ -116,6 +116,9 @@ server { location ^~ /order/myOrders { try_files /index.html =200; } + location ^~ /order/waybillManage { + try_files /index.html =200; + } location ^~ /order/pickupOrder { try_files /index.html =200; } diff --git a/nginx-docker.conf b/nginx-docker.conf index 4658fe6..416f7b0 100644 --- a/nginx-docker.conf +++ b/nginx-docker.conf @@ -45,6 +45,7 @@ server { location ^~ /order/priceCheck { try_files /index.html =200; } location ^~ /order/placeOrder { try_files /index.html =200; } location ^~ /order/myOrders { try_files /index.html =200; } + location ^~ /order/waybillManage { try_files /index.html =200; } location ^~ /order/pickupOrder { try_files /index.html =200; } location ^~ /order/batchJobs { try_files /index.html =200; } location ^~ /order/templateMapping { try_files /index.html =200; } diff --git a/src/api/channel/labelTemplate.ts b/src/api/channel/labelTemplate.ts index c2ff020..54e99f5 100644 --- a/src/api/channel/labelTemplate.ts +++ b/src/api/channel/labelTemplate.ts @@ -1,6 +1,78 @@ import { axiosInstance } from '@/api/rbac' import { assertBusinessOk, omsUrl, unwrapData } from '@/api/oms/common' +export type LabelTemplateListItem = { + id: number + name: string + templateType?: string + createTime?: string + updateTime?: string +} + +export type LabelTemplateDetail = LabelTemplateListItem & { + templateJson?: unknown +} + +export type LabelFieldItem = { field: string; title: string } +export type LabelFieldGroup = { code: string; title: string; fields: LabelFieldItem[] } + +export async function getLabelTemplateList(params?: { + keyword?: string + templateType?: string +}) { + const res = await axiosInstance.get(omsUrl('/channel/label-template/list'), { params }) + assertBusinessOk(res.data) + const data = unwrapData(res.data) + const items = (data?.items ?? data?.Items ?? []) as any[] + return items.map((row) => ({ + id: Number(row.id ?? row.Id), + name: String(row.name ?? row.Name ?? ''), + templateType: row.templateType ?? row.TemplateType, + createTime: row.createTime ?? row.CreateTime, + updateTime: row.updateTime ?? row.UpdateTime, + })) as LabelTemplateListItem[] +} + +export async function getLabelTemplate(id: number) { + const res = await axiosInstance.get(omsUrl(`/channel/label-template/${id}`)) + assertBusinessOk(res.data) + const row = unwrapData(res.data) || {} + return { + id: Number(row.id ?? row.Id), + name: String(row.name ?? row.Name ?? ''), + templateType: row.templateType ?? row.TemplateType, + templateJson: row.templateJson ?? row.TemplateJson, + createTime: row.createTime ?? row.CreateTime, + updateTime: row.updateTime ?? row.UpdateTime, + } as LabelTemplateDetail +} + +export async function getLabelFieldDictionary() { + const res = await axiosInstance.get(omsUrl('/channel/label-template/field-dictionary')) + assertBusinessOk(res.data) + const data = unwrapData(res.data) + const items = (data?.items ?? data?.Items ?? []) as any[] + return items.map((g) => ({ + code: String(g.code ?? g.Code ?? ''), + title: String(g.title ?? g.Title ?? ''), + fields: ((g.fields ?? g.Fields ?? []) as any[]).map((f) => ({ + field: String(f.field ?? f.Field ?? ''), + title: String(f.title ?? f.Title ?? ''), + })), + })) as LabelFieldGroup[] +} + +export async function previewLabelTemplatePdf(body: { + templateId?: number + templateJson?: unknown + printData?: Record +}) { + const res = await axiosInstance.post(omsUrl('/channel/label-template/preview-pdf'), body, { + responseType: 'blob', + }) + return res.data as Blob +} + export async function saveLabelTemplate(body: { id?: number name: string @@ -11,3 +83,8 @@ export async function saveLabelTemplate(body: { assertBusinessOk(res.data) return unwrapData(res.data) } + +export async function deleteLabelTemplate(id: number) { + const res = await axiosInstance.post(omsUrl('/channel/label-template/delete'), { id }) + assertBusinessOk(res.data) +} diff --git a/src/api/operation/index.ts b/src/api/operation/index.ts index ed886f5..ff30238 100644 --- a/src/api/operation/index.ts +++ b/src/api/operation/index.ts @@ -80,6 +80,58 @@ export async function outboundRecentList(params?: { limit?: number; warehouseId? return parseListPayload(res.data) } +export async function printLabelLookup(params: { number: string; numberType?: string }) { + const res = await axiosInstance.get(omsUrl('/operation/print-label/lookup'), { params }) + assertBusinessOk(res.data) + return unwrapData(res.data) as PrintLabelLookupResult +} + +export type PrintLabelBindItem = { + bindType?: string + skuCode?: string + skuName?: string + trackingNo?: string + productName?: string + attributeText?: string + imageUrl?: string + binCode?: string + bindQty?: number + status?: string +} + +export type PrintLabelLookupCandidate = { + orderId: number + serviceNo?: string + clientNo?: string + trackNo?: string + orderStatusName?: string + bindQtyTotal?: number + matchedHint?: string +} + +export type PrintLabelLookupResult = { + matched?: boolean + matchedNumberType?: string + warnings?: string[] + orderId?: number + serviceNo?: string + clientNo?: string + trackNo?: string + productCode?: string + salesProductName?: string + destinationCountry?: string + destinationCountryName?: string + orderStatus?: string + orderStatusName?: string + warehouseId?: number + warehouseName?: string + bindStatus?: string + bindQtyTotal?: number + bindLineCount?: number + bindItems?: PrintLabelBindItem[] + candidates?: PrintLabelLookupCandidate[] +} + export async function printLabelPrint(body: { number: string numberType: string diff --git a/src/api/order/index.ts b/src/api/order/index.ts index 7ddeb9e..f2d7542 100644 --- a/src/api/order/index.ts +++ b/src/api/order/index.ts @@ -1280,3 +1280,101 @@ export async function postOrderFeeAdd(body: OrderFeeAddRequest): Promise { assertBusinessOk(res.data) return res.data?.data ?? res.data?.Data ?? res.data } + +export interface OrderStockBindItem { + id?: number + bindType: 'inventory' | 'parcelItem' | string + skuId?: number + skuCode?: string + skuName?: string + inventoryId?: number + binLocationId?: number + binCode?: string + parcelId?: number + parcelItemId?: number + trackingNo?: string + productName?: string + attributeText?: string + imageUrl?: string + bindQty: number + availableQty?: number + status?: string +} + +export interface OrderStockBindDetail { + orderId: number + warehouseId?: number + warehouseName?: string + bindStatus: string + items: OrderStockBindItem[] +} + +function unwrapData(body: any): T { + return (body?.data ?? body?.Data ?? body) as T +} + +/** GET /order/stock-bind/detail */ +export async function getOrderStockBindDetail(orderId: number): Promise { + const res = await axiosInstance.get(orderUrl('/order/stock-bind/detail'), { params: { orderId } }) + assertBusinessOk(res.data) + return unwrapData(res.data) +} + +/** POST /order/stock-bind/inventory-candidates */ +export async function postOrderStockBindInventoryCandidates(body: { + orderId: number + warehouseId?: number + keyword?: string + page?: number + pageSize?: number +}): Promise<{ items: any[]; total: number }> { + const res = await axiosInstance.post(orderUrl('/order/stock-bind/inventory-candidates'), body) + assertBusinessOk(res.data) + const data = unwrapData(res.data) + return { + items: data?.items ?? data?.Items ?? [], + total: data?.total ?? data?.Total ?? 0, + } +} + +/** POST /order/stock-bind/parcel-candidates */ +export async function postOrderStockBindParcelCandidates(body: { + orderId: number + warehouseId?: number + lifecycleStatus?: string + keyword?: string + page?: number + pageSize?: number +}): Promise<{ items: any[]; total: number }> { + const res = await axiosInstance.post(orderUrl('/order/stock-bind/parcel-candidates'), body) + assertBusinessOk(res.data) + const data = unwrapData(res.data) + return { + items: data?.items ?? data?.Items ?? [], + total: data?.total ?? data?.Total ?? 0, + } +} + +/** POST /order/stock-bind/save */ +export async function postOrderStockBindSave(body: { + orderId: number + items: Array<{ + bindType: string + skuId?: number + inventoryId?: number + parcelId?: number + parcelItemId?: number + bindQty: number + }> +}): Promise { + const res = await axiosInstance.post(orderUrl('/order/stock-bind/save'), body) + assertBusinessOk(res.data) + return unwrapData(res.data) +} + +/** POST /order/stock-bind/clear */ +export async function postOrderStockBindClear(orderId: number): Promise { + const res = await axiosInstance.post(orderUrl('/order/stock-bind/clear'), { orderId }) + assertBusinessOk(res.data) + return unwrapData(res.data) +} diff --git a/src/api/warehouse/index.ts b/src/api/warehouse/index.ts index 2ed7645..ab8e470 100644 --- a/src/api/warehouse/index.ts +++ b/src/api/warehouse/index.ts @@ -87,3 +87,5 @@ export const getWarehouseInventoryBinDetail = (skuId: number, warehouseId: numbe getData('/warehouse/inventory/bin-detail', { skuId, warehouseId, customerId }) export const relocateWarehouseInventory = (body: Record) => postOk('/warehouse/inventory/relocate', body) +export const getWarehouseInventoryHistory = (body: Record) => + postList('/warehouse/inventory/history', body) diff --git a/src/components/top-nav/index.vue b/src/components/top-nav/index.vue index 8537629..130528c 100644 --- a/src/components/top-nav/index.vue +++ b/src/components/top-nav/index.vue @@ -17,7 +17,7 @@ position="bl" :popup-offset="0" :mouse-enter-delay="80" - :mouse-leave-delay="400" + :mouse-leave-delay="120" unmount-on-close > = { MarkClaimed: '创建理赔件', MarkProcessed: '标记已处理', EditOrder: '修改订单', + StockBind: '绑定包裹/库存', AddMapping: '添加映射', AddInterface: '新增接口', RefreshList: '刷新列表', @@ -487,6 +488,7 @@ const CORE_GROUPS: PageButtonGroup[] = [ { code: 'MarkClaimed', name: '创建理赔件' }, { code: 'MarkProcessed', name: '标记已处理' }, { code: 'EditOrder', name: '修改订单' }, + { code: 'StockBind', name: '绑定包裹/库存' }, { code: 'View', name: '查看详情' }, { code: 'More', name: '更多' }, { code: 'DownstreamForecastResult', name: '下游预报结果' }, diff --git a/src/locale/en-US.ts b/src/locale/en-US.ts index a6c0fa5..a3ad090 100644 --- a/src/locale/en-US.ts +++ b/src/locale/en-US.ts @@ -90,6 +90,8 @@ export default { 'warehouse.common.detail': 'Detail', 'warehouse.common.warehouse': 'Warehouse', 'warehouse.common.customer': 'Customer', + 'warehouse.common.customerName': 'Customer Name', + 'warehouse.common.customerCode': 'Customer Code', 'warehouse.common.selectCustomer': 'All customers', 'warehouse.common.selectCustomerRequired': 'Select a customer before create/update', 'warehouse.common.yes': 'Yes', @@ -102,6 +104,7 @@ export default { 'warehouse.sku.table.weightG': 'Weight(g)', 'warehouse.sku.table.remark': 'Remark', 'warehouse.sku.search.keyword': 'Code / Name', + 'warehouse.sku.tip': 'Manage warehouse SKUs. Stock qty is aggregated across warehouses — check Available on My Inventory before shipping.', 'warehouse.sku.form.skuCode': 'SKU Code', 'warehouse.sku.form.skuName': 'SKU Name', 'warehouse.sku.form.weightG': 'Weight(g)', @@ -141,13 +144,28 @@ export default { 'warehouse.inventory.table.skuName': 'SKU Name', 'warehouse.inventory.table.warehouseId': 'Warehouse', 'warehouse.inventory.table.totalQty': 'Total Qty', + 'warehouse.inventory.table.availableQty': 'Available', + 'warehouse.inventory.table.frozenQty': 'Frozen', 'warehouse.inventory.table.binCount': 'Bins', 'warehouse.inventory.table.binCode': 'Bin', 'warehouse.inventory.table.qty': 'Qty', 'warehouse.inventory.search.keyword': 'Code / Name', 'warehouse.inventory.actions.binDetail': 'Bin Detail', + 'warehouse.inventory.actions.history': 'History', 'warehouse.inventory.actions.relocate': 'Relocate', 'warehouse.inventory.drawer.binDetail': 'Bin Detail', + 'warehouse.inventory.drawer.history': 'Stock history', + 'warehouse.inventory.history.all': 'All', + 'warehouse.inventory.history.inbound': 'Inbound', + 'warehouse.inventory.history.deduct': 'Deduct', + 'warehouse.inventory.history.type': 'Type', + 'warehouse.inventory.history.qty': 'Qty', + 'warehouse.inventory.history.refNo': 'Ref No.', + 'warehouse.inventory.history.remark': 'Remark', + 'warehouse.inventory.history.time': 'Time', + 'warehouse.inventory.history.empty': 'No history yet', + 'warehouse.inventory.history.loadFailed': 'Failed to load history', + 'warehouse.inventory.tip': 'Available = ready to ship; Frozen = reserved by orders. Use History for inbound & deductions.', 'warehouse.inventory.modal.relocate': 'Relocate', 'warehouse.inventory.form.sourceBin': 'Source Bin', 'warehouse.inventory.form.targetBin': 'Target Bin', @@ -196,11 +214,16 @@ export default { 'warehouse.parcel.table.image': 'Image', 'warehouse.parcel.table.imagePreviewTip': 'Click to enlarge', 'warehouse.parcel.table.attribute': 'Attributes', - 'warehouse.parcel.table.quantity': 'Qty', + 'warehouse.parcel.table.quantity': 'Total', + 'warehouse.parcel.table.availableQty': 'Available', + 'warehouse.parcel.table.frozenQty': 'Frozen', 'warehouse.parcel.badge.multiTip': 'Multi-item parcel. Click Items / Attributes / Qty for details.', 'warehouse.parcel.drawer.itemsTitle': 'Item details', 'warehouse.parcel.drawer.totalQty': 'Total qty', + 'warehouse.parcel.drawer.availableQty': 'Available', + 'warehouse.parcel.drawer.frozenQty': 'Frozen', 'warehouse.parcel.drawer.itemCount': '{n} line(s)', + 'warehouse.parcel.tip': 'Available = ready to bind; Frozen = reserved by orders. Use status tabs to filter.', 'warehouse.parcel.drawer.edit': 'Edit parcel', 'warehouse.parcel.drawer.empty': 'No items', 'warehouse.parcel.table.arrivalTime': 'Arrival Time', @@ -237,6 +260,11 @@ export default { 'warehouse.parcel.message.imageTooLarge': 'Image must be under 5MB', 'warehouse.parcelArrival.form.trackingNo': 'Domestic tracking No.', 'warehouse.parcelArrival.form.placeholder.scanOrInput': 'Scan or enter domestic tracking number', + 'warehouse.parcelArrival.scan.title': 'Scan arrival', + 'warehouse.parcelArrival.tip': 'Scan domestic tracking to confirm arrival. Check the current warehouse first.', + 'warehouse.parcelArrival.preview.title': 'Confirm arrival', + 'warehouse.parcelArrival.preview.empty': 'Verify warehouse and tracking, then press Enter or Confirm arrival.', + 'warehouse.parcelArrival.recent.title': 'Arrival records', 'warehouse.parcelArrival.search.trackingNo': 'Domestic tracking No.', 'warehouse.parcelArrival.table.trackingNo': 'Domestic tracking No.', 'warehouse.parcelArrival.table.warehouse': 'Warehouse', @@ -266,6 +294,7 @@ export default { 'warehouse.inbound.table.plannedQty': 'Planned Qty', 'warehouse.inbound.table.createTime': 'Created', 'warehouse.inbound.search.keyword': 'Notice / Mark', + 'warehouse.inbound.tip': 'Forecast inbound goods. Stock increases after receive & putaway. Status: Forecasted → Received → Completed.', 'warehouse.inbound.form.markReference': 'Mark Ref', 'warehouse.inbound.form.markBoxNo': 'Box No', 'warehouse.inbound.form.sku': 'SKU', @@ -968,6 +997,47 @@ export default { 'order.myOrders.batch.partialSuccess': '{success} succeeded, {fail} failed. {detail}', 'order.myOrders.actions.more': 'More', 'order.myOrders.actions.viewTrack': 'Track', + 'order.myOrders.actions.stockBind': 'Bind parcel / inventory', + 'order.myOrders.stockBind.title': 'Bind parcel / inventory', + 'order.myOrders.stockBind.tabInventory': 'Warehouse stock', + 'order.myOrders.stockBind.tabParcel': 'My parcels', + 'order.myOrders.stockBind.searchPlaceholder': 'Search SKU / tracking no.', + 'order.myOrders.stockBind.searchSku': 'Search SKU code or name', + 'order.myOrders.stockBind.searchParcel': 'Search tracking no.', + 'order.myOrders.stockBind.warehouse': 'Warehouse', + 'order.myOrders.stockBind.forOrder': 'Order', + 'order.myOrders.stockBind.tipFreeze': 'Pick stock or parcels on the left. Saving only freezes qty; it does not deduct yet.', + 'order.myOrders.stockBind.tipDeducted': 'This order is already deducted. Binding is read-only.', + 'order.myOrders.stockBind.pickTitle': 'Available to pick', + 'order.myOrders.stockBind.cartTitle': 'Will use for this order', + 'order.myOrders.stockBind.cartSummary': '{lines} line(s) · {qty} pcs', + 'order.myOrders.stockBind.emptyInventory': 'No available stock in this warehouse', + 'order.myOrders.stockBind.emptyParcel': 'No available parcel items', + 'order.myOrders.stockBind.available': 'Available', + 'order.myOrders.stockBind.total': 'Total', + 'order.myOrders.stockBind.selected': 'Selected', + 'order.myOrders.stockBind.clear': 'Clear all', + 'order.myOrders.stockBind.save': 'Confirm binding', + 'order.myOrders.stockBind.emptySelected': 'Tap items on the left to add', + 'order.myOrders.stockBind.maxAvailable': 'Max available', + 'order.myOrders.stockBind.qtyExceed': 'Exceeds available quantity', + 'order.myOrders.stockBind.singleOnly': 'Select exactly one order to bind', + 'order.myOrders.stockBind.loadFailed': 'Failed to load binding data', + 'order.myOrders.stockBind.saveSuccess': 'Binding saved', + 'order.myOrders.stockBind.saveFailed': 'Failed to save binding', + 'order.myOrders.stockBind.clearSuccess': 'Binding cleared', + 'order.myOrders.stockBind.clearFailed': 'Failed to clear binding', + 'order.myOrders.stockBind.alreadyDeducted': 'Already deducted; cannot rebind', + 'order.myOrders.stockBind.viewEmpty': 'No bound parcels or inventory', + 'order.myOrders.stockBind.bindQty': 'Bound qty', + 'order.myOrders.stockBind.bindCount': '{count} item(s)', + 'order.myOrders.stockBind.bin': 'Bin', + 'order.myOrders.stockBind.status.none': 'None', + 'order.myOrders.stockBind.status.bound': 'Bound', + 'order.myOrders.stockBind.status.deducted': 'Deducted', + 'order.myOrders.stockBind.status.released': 'Released', + 'common.cancel': 'Cancel', + 'common.loading': 'Loading...', 'order.myOrders.latestTrack.loading': 'Loading track…', 'order.myOrders.latestTrack.empty': 'No tracking yet', @@ -1032,6 +1102,7 @@ export default { 'order.myOrders.drawer.tabs.weight': 'Weight/Dimensions', 'order.myOrders.drawer.tabs.fee': 'Receivables/Payables', 'order.myOrders.drawer.tabs.track': 'Tracking', + 'order.myOrders.drawer.tabs.stockBind': 'Bound stock', 'order.myOrders.drawer.orderBasic': 'Basic Info', 'order.myOrders.drawer.basic.viewAll': 'All', 'order.myOrders.drawer.basic.group.identity': 'Order IDs', @@ -2232,11 +2303,15 @@ export default { // Operation Module - Inbound Scan 'operation.inbound.pageTitle': 'Waybill Information', 'operation.inbound.broadcastSettings': 'Broadcast Settings', + 'operation.inbound.scan.title': 'Scan inbound', + 'operation.inbound.tip': 'Scan to verify product and country, then enter received weight and dimensions before inbound.', + 'operation.inbound.preview.title': 'Verify', + 'operation.inbound.preview.empty': 'Scan a number to show order info and enter weight / dimensions', 'operation.inbound.form.scanNumber': 'Scan Number:', - 'operation.inbound.form.receivedWeight': 'Received Weight:', - 'operation.inbound.form.dimensions': 'Length × Width × Height:', - 'operation.inbound.form.salesProduct': 'Sales Product:', - 'operation.inbound.form.destinationCountry': 'Destination Country:', + 'operation.inbound.form.receivedWeight': 'Received Weight', + 'operation.inbound.form.dimensions': 'L × W × H', + 'operation.inbound.form.salesProduct': 'Sales Product', + 'operation.inbound.form.destinationCountry': 'Destination Country', 'operation.inbound.form.remarks': 'Remarks:', 'operation.inbound.form.placeholder.scanOrInput': 'Scan or enter number', 'operation.inbound.form.placeholder.input': 'Please enter', @@ -2247,10 +2322,11 @@ export default { 'operation.inbound.form.placeholder.scanFirst': 'Auto-filled after scanning', 'operation.inbound.form.hint.supportedTypes': 'Supported: Waybill number, Service provider number, Channel transfer number, Platform order number', 'operation.inbound.actions.reset': 'Reset', + 'operation.inbound.actions.lookup': 'Lookup', 'operation.inbound.actions.inbound': 'Inbound', - 'operation.inbound.recentOrders.title': 'Recent Orders', + 'operation.inbound.recentOrders.title': 'Recent inbound', 'operation.inbound.recentOrders.subtitle': 'Maximum 50 recent orders displayed here', - 'operation.inbound.recentOrders.empty': 'No data', + 'operation.inbound.recentOrders.empty': 'No records', 'operation.inbound.table.index': 'Index', 'operation.inbound.table.waybillNumber': 'Waybill Number', 'operation.inbound.table.weight': 'Weight', @@ -2269,12 +2345,16 @@ export default { // Operation Module - Outbound Scan 'operation.outbound.pageTitle': 'Waybill Information', 'operation.outbound.broadcastSettings': 'Broadcast Settings', + 'operation.outbound.scan.title': 'Scan outbound', + 'operation.outbound.tip': 'Scan waybill to verify product, country and channel. Weight and dimensions are optional.', + 'operation.outbound.preview.title': 'Verify', + 'operation.outbound.preview.empty': 'Scan a number to show order info; weight / dimensions are optional', 'operation.outbound.form.scanNumber': 'Scan Number:', - 'operation.outbound.form.shipWeight': 'Shipped weight:', - 'operation.outbound.form.dimensions': 'L × W × H:', - 'operation.outbound.form.salesProduct': 'Sales product:', - 'operation.outbound.form.destinationCountry': 'Destination country:', - 'operation.outbound.form.serviceChannel': 'Service channel:', + 'operation.outbound.form.shipWeight': 'Shipped weight', + 'operation.outbound.form.dimensions': 'L × W × H', + 'operation.outbound.form.salesProduct': 'Sales product', + 'operation.outbound.form.destinationCountry': 'Destination country', + 'operation.outbound.form.serviceChannel': 'Service channel', 'operation.outbound.form.placeholder.scanOrInput': 'Scan or enter number', 'operation.outbound.form.placeholder.input': 'Enter', 'operation.outbound.form.placeholder.length': 'L / CM', @@ -2284,10 +2364,11 @@ export default { 'operation.outbound.form.placeholder.scanFirst': 'Auto-filled after scan', 'operation.outbound.form.hint.supportedTypes': 'Supported: Waybill number only', 'operation.outbound.actions.reset': 'Reset', + 'operation.outbound.actions.lookup': 'Lookup', 'operation.outbound.actions.outbound': 'Outbound', - 'operation.outbound.recentOrders.title': 'Recent orders', + 'operation.outbound.recentOrders.title': 'Recent outbound', 'operation.outbound.recentOrders.subtitle': 'Maximum 50 recent orders displayed here', - 'operation.outbound.recentOrders.empty': 'No data', + 'operation.outbound.recentOrders.empty': 'No records', 'operation.outbound.table.index': 'Index', 'operation.outbound.table.waybillNumber': 'Waybill Number', 'operation.outbound.table.weight': 'Weight', @@ -2306,24 +2387,46 @@ export default { // Operation Module - Print Label 'operation.printLabel.pageTitle': 'Print Label', 'operation.printLabel.broadcastSettings': 'Broadcast Settings', - 'operation.printLabel.form.scanNumber': 'Number:', - 'operation.printLabel.form.placeholder.scanOrInput': 'Scan or enter number', - 'operation.printLabel.form.placeholder.numberType': 'Select number type', + 'operation.printLabel.tip': 'Scan any number to load the order and bound goods. Verify qty before printing to avoid wrong/missing shipments.', + 'operation.printLabel.scan.title': 'Scan & print', + 'operation.printLabel.form.scanNumber': 'Scan number', + 'operation.printLabel.form.placeholder.scanOrInput': 'Waybill / Client / Track / Parcel / SKU', + 'operation.printLabel.form.placeholder.numberType': 'Number type', 'operation.printLabel.form.placeholder.labelTemplate': 'Select label template', - 'operation.printLabel.form.hint.supportedTypes': 'Supported: Waybill, Customer order, Tracking, Other', + 'operation.printLabel.form.hint.supportedTypes': 'Supports: Waybill, Client order, Tracking, Other, Parcel tracking, SKU', 'operation.printLabel.actions.reset': 'Reset', - 'operation.printLabel.actions.print': 'Print', + 'operation.printLabel.actions.lookup': 'Lookup', + 'operation.printLabel.actions.print': 'Confirm print', 'operation.printLabel.recentOrders.subtitle': 'Maximum 50 recent records displayed here', - 'operation.printLabel.recentOrders.empty': 'No data', + 'operation.printLabel.recentOrders.title': 'Recent prints', + 'operation.printLabel.recentOrders.empty': 'No records', + 'operation.printLabel.numberType.auto': 'Auto detect', 'operation.printLabel.numberType.waybill': 'Waybill Number', 'operation.printLabel.numberType.customerOrder': 'Customer Order Number', 'operation.printLabel.numberType.tracking': 'Tracking Number', 'operation.printLabel.numberType.other': 'Other Number', + 'operation.printLabel.numberType.parcel': 'Parcel tracking', + 'operation.printLabel.numberType.sku': 'SKU code', 'operation.printLabel.labelTemplate.lastMile': 'Last Mile Label', 'operation.printLabel.labelTemplate.customer': 'Customer Label', 'operation.printLabel.labelTemplate.inbound': 'Inbound Label', 'operation.printLabel.labelTemplate.outbound': 'Outbound Label', 'operation.printLabel.labelTemplate.sku': 'SKU Label', + 'operation.printLabel.preview.title': 'Verify before print', + 'operation.printLabel.preview.empty': 'Scan a number to show order and bound goods', + 'operation.printLabel.preview.order': 'Order', + 'operation.printLabel.preview.bindSummary': '{lines} line(s) · {qty} pcs', + 'operation.printLabel.preview.lines': 'Lines', + 'operation.printLabel.preview.noneBind': 'No parcel/inventory bound — verify physical goods carefully', + 'operation.printLabel.preview.multiMatch': 'Multiple orders matched — pick one to continue', + 'operation.printLabel.preview.bindInventory': 'Stock', + 'operation.printLabel.preview.bindParcel': 'Parcel', + 'operation.printLabel.preview.bindQty': 'Ship qty', + 'operation.printLabel.preview.bin': 'Bin', + 'operation.printLabel.preview.sku': 'SKU', + 'operation.printLabel.preview.tracking': 'Tracking', + 'operation.printLabel.preview.attr': 'Spec', + 'operation.printLabel.preview.selectCandidate': 'Select', 'operation.printLabel.table.index': 'Index', 'operation.printLabel.table.waybillNumber': 'Waybill Number', 'operation.printLabel.table.customerOrderNumber': 'Customer Order Number', @@ -2335,6 +2438,8 @@ export default { 'operation.printLabel.table.operateTime': 'Operate Time', 'operation.printLabel.table.operator': 'Operator', 'operation.printLabel.message.waybillNumberRequired': 'Please enter or scan number', + 'operation.printLabel.message.lookupSuccess': 'Order found — verify bound goods', + 'operation.printLabel.message.lookupFirst': 'Lookup and verify the order first', 'operation.printLabel.message.printSuccess': 'Print successful', 'operation.printLabel.printSuccess.yes': 'Yes', 'operation.printLabel.printSuccess.no': 'No', @@ -3088,6 +3193,34 @@ export default { 'channel.labelDesign.noContent': 'No content', 'channel.labelDesign.applySuccess': 'Config applied', 'channel.labelDesign.resetSuccess': 'Config reset', + 'channel.labelDesign.searchPlaceholder': 'Search by name', + 'channel.labelDesign.typePlaceholder': 'Template type', + 'channel.labelDesign.namePlaceholder': 'Template name', + 'channel.labelDesign.loadingDesigner': 'Loading designer…', + 'channel.labelDesign.total': '{n} total', + 'channel.labelDesign.table.name': 'Name', + 'channel.labelDesign.table.type': 'Type', + 'channel.labelDesign.table.updateTime': 'Updated', + 'channel.labelDesign.table.actions': 'Actions', + 'channel.labelDesign.actions.search': 'Search', + 'channel.labelDesign.actions.create': 'New template', + 'channel.labelDesign.actions.edit': 'Design', + 'channel.labelDesign.actions.delete': 'Delete', + 'channel.labelDesign.actions.back': 'Back', + 'channel.labelDesign.actions.preview': 'Preview', + 'channel.labelDesign.actions.print': 'Print', + 'channel.labelDesign.actions.save': 'Save', + 'channel.labelDesign.actions.startDesign': 'Start design', + 'channel.labelDesign.actions.cancel': 'Cancel', + 'channel.labelDesign.message.loadFailed': 'Failed to load templates', + 'channel.labelDesign.message.saveSuccess': 'Template saved', + 'channel.labelDesign.message.saveFailed': 'Save failed', + 'channel.labelDesign.message.deleteSuccess': 'Deleted', + 'channel.labelDesign.message.nameRequired': 'Template name is required', + 'channel.labelDesign.fieldDictionary': 'Order fields', + 'channel.labelDesign.message.fieldCopied': 'Copied field: {field}', + 'channel.labelDesign.message.previewEmpty': 'Nothing to preview', + 'channel.labelDesign.message.previewFailed': 'PDF preview failed', // Channel - Sales Products 'channel.salesProducts.search.placeholder': 'Enter product name', @@ -3152,6 +3285,7 @@ export default { 'channel.salesProducts.form.group': 'Group', 'channel.salesProducts.form.efficiency': 'Transit time', 'channel.salesProducts.form.customerWaybill': 'Customer waybill', + 'channel.salesProducts.form.placeholder.labelTemplate': 'Select label template (global default if empty)', 'channel.salesProducts.form.blacklistArea': 'Blacklist area', 'channel.salesProducts.form.remoteAreaDivision': 'Remote area division', 'channel.salesProducts.form.priceArea': 'Price area', diff --git a/src/locale/zh-CN.ts b/src/locale/zh-CN.ts index 1b2f32a..3f3b801 100644 --- a/src/locale/zh-CN.ts +++ b/src/locale/zh-CN.ts @@ -90,6 +90,8 @@ export default { 'warehouse.common.detail': '详情', 'warehouse.common.warehouse': '仓库', 'warehouse.common.customer': '客户', + 'warehouse.common.customerName': '客户名称', + 'warehouse.common.customerCode': '客户编码', 'warehouse.common.selectCustomer': '全部客户', 'warehouse.common.selectCustomerRequired': '新增/修改请先选择客户', 'warehouse.common.yes': '是', @@ -102,6 +104,7 @@ export default { 'warehouse.sku.table.weightG': '重量(g)', 'warehouse.sku.table.remark': '备注', 'warehouse.sku.search.keyword': '编码/名称', + 'warehouse.sku.tip': '维护库内 SKU 主数据;库存数量来自各仓库汇总,下单发货前请先在「我的库存」确认可用量。', 'warehouse.sku.form.skuCode': 'SKU 编码', 'warehouse.sku.form.skuName': 'SKU 名称', 'warehouse.sku.form.weightG': '重量(g)', @@ -140,14 +143,29 @@ export default { 'warehouse.inventory.table.skuCode': 'SKU 编码', 'warehouse.inventory.table.skuName': 'SKU 名称', 'warehouse.inventory.table.warehouseId': '仓库', - 'warehouse.inventory.table.totalQty': '总数量', + 'warehouse.inventory.table.totalQty': '总量', + 'warehouse.inventory.table.availableQty': '可用', + 'warehouse.inventory.table.frozenQty': '冻结', 'warehouse.inventory.table.binCount': '库位数', 'warehouse.inventory.table.binCode': '库位', 'warehouse.inventory.table.qty': '数量', 'warehouse.inventory.search.keyword': '编码/名称', 'warehouse.inventory.actions.binDetail': '库位明细', + 'warehouse.inventory.actions.history': '出入库记录', 'warehouse.inventory.actions.relocate': '换库位', 'warehouse.inventory.drawer.binDetail': '库位明细', + 'warehouse.inventory.drawer.history': '出入库记录', + 'warehouse.inventory.history.all': '全部', + 'warehouse.inventory.history.inbound': '入库', + 'warehouse.inventory.history.deduct': '扣减', + 'warehouse.inventory.history.type': '类型', + 'warehouse.inventory.history.qty': '数量', + 'warehouse.inventory.history.refNo': '关联单号', + 'warehouse.inventory.history.remark': '说明', + 'warehouse.inventory.history.time': '时间', + 'warehouse.inventory.history.empty': '暂无出入库记录', + 'warehouse.inventory.history.loadFailed': '加载出入库记录失败', + 'warehouse.inventory.tip': '可用=可发货;冻结=已被订单占用;点「出入库记录」可查看历史入库与扣减。', 'warehouse.inventory.modal.relocate': '换库位', 'warehouse.inventory.form.sourceBin': '源库位', 'warehouse.inventory.form.targetBin': '目标库位', @@ -196,11 +214,16 @@ export default { 'warehouse.parcel.table.image': '图片', 'warehouse.parcel.table.imagePreviewTip': '点击放大', 'warehouse.parcel.table.attribute': '属性', - 'warehouse.parcel.table.quantity': '数量', + 'warehouse.parcel.table.quantity': '总量', + 'warehouse.parcel.table.availableQty': '可用', + 'warehouse.parcel.table.frozenQty': '冻结', 'warehouse.parcel.badge.multiTip': '多商品包裹,点击商品/属性/数量可查看明细', 'warehouse.parcel.drawer.itemsTitle': '商品明细', 'warehouse.parcel.drawer.totalQty': '合计数量', + 'warehouse.parcel.drawer.availableQty': '可用', + 'warehouse.parcel.drawer.frozenQty': '冻结', 'warehouse.parcel.drawer.itemCount': '共 {n} 项', + 'warehouse.parcel.tip': '可用=可绑定发货;冻结=已被订单占用。点状态 Tab 快速筛选在途/到仓/已上架。', 'warehouse.parcel.drawer.edit': '编辑包裹', 'warehouse.parcel.drawer.empty': '暂无商品明细', 'warehouse.parcel.table.arrivalTime': '到仓时间', @@ -237,6 +260,11 @@ export default { 'warehouse.parcel.message.imageTooLarge': '图片不能超过 5MB', 'warehouse.parcelArrival.form.trackingNo': '国内快递单号', 'warehouse.parcelArrival.form.placeholder.scanOrInput': '扫描或输入国内快递单号', + 'warehouse.parcelArrival.scan.title': '扫码到仓', + 'warehouse.parcelArrival.tip': '扫描国内快递单号确认到仓;请确认当前仓库正确后再操作。', + 'warehouse.parcelArrival.preview.title': '到仓确认', + 'warehouse.parcelArrival.preview.empty': '确认仓库与单号无误后,回车或点击确认到仓。', + 'warehouse.parcelArrival.recent.title': '到仓记录', 'warehouse.parcelArrival.search.trackingNo': '国内快递单号', 'warehouse.parcelArrival.table.trackingNo': '国内快递单号', 'warehouse.parcelArrival.table.warehouse': '仓库', @@ -266,6 +294,7 @@ export default { 'warehouse.inbound.table.plannedQty': '计划数量', 'warehouse.inbound.table.createTime': '创建时间', 'warehouse.inbound.search.keyword': '单号/唛头', + 'warehouse.inbound.tip': '预报到仓货物;收货上架后库存会增加。关注状态:预报 → 待入库 → 已完成。', 'warehouse.inbound.form.markReference': '唛头', 'warehouse.inbound.form.markBoxNo': '箱号', 'warehouse.inbound.form.sku': 'SKU', @@ -719,6 +748,47 @@ export default { 'order.myOrders.actions.markProcessed': '标记已处理', 'order.myOrders.actions.more': '更多', 'order.myOrders.actions.viewTrack': '轨迹', + 'order.myOrders.actions.stockBind': '绑定包裹/库存', + 'order.myOrders.stockBind.title': '绑定包裹/库存', + 'order.myOrders.stockBind.tabInventory': '仓库库存', + 'order.myOrders.stockBind.tabParcel': '我的包裹', + 'order.myOrders.stockBind.searchPlaceholder': '搜索 SKU / 运单号', + 'order.myOrders.stockBind.searchSku': '搜索 SKU 编码或名称', + 'order.myOrders.stockBind.searchParcel': '搜索快递单号', + 'order.myOrders.stockBind.warehouse': '发货仓', + 'order.myOrders.stockBind.forOrder': '当前订单', + 'order.myOrders.stockBind.tipFreeze': '点选左侧可用库存或包裹加入右侧;保存后仅冻结数量,不会立刻扣减出库。', + 'order.myOrders.stockBind.tipDeducted': '该订单已确认扣减,绑定明细只读,无法再修改。', + 'order.myOrders.stockBind.pickTitle': '可选资源', + 'order.myOrders.stockBind.cartTitle': '本单将使用', + 'order.myOrders.stockBind.cartSummary': '{lines} 种 · 共 {qty} 件', + 'order.myOrders.stockBind.emptyInventory': '当前仓库暂无可用库存', + 'order.myOrders.stockBind.emptyParcel': '暂无可用包裹明细', + 'order.myOrders.stockBind.available': '可用', + 'order.myOrders.stockBind.total': '总量', + 'order.myOrders.stockBind.selected': '已选明细', + 'order.myOrders.stockBind.clear': '清空全部', + 'order.myOrders.stockBind.save': '确认绑定', + 'order.myOrders.stockBind.emptySelected': '从左侧点选要发的库存或包裹', + 'order.myOrders.stockBind.maxAvailable': '最多可用', + 'order.myOrders.stockBind.qtyExceed': '超出可用数量', + 'order.myOrders.stockBind.singleOnly': '请只选择一笔订单进行绑定', + 'order.myOrders.stockBind.loadFailed': '加载绑定数据失败', + 'order.myOrders.stockBind.saveSuccess': '绑定已保存', + 'order.myOrders.stockBind.saveFailed': '保存绑定失败', + 'order.myOrders.stockBind.clearSuccess': '已清空绑定', + 'order.myOrders.stockBind.clearFailed': '清空绑定失败', + 'order.myOrders.stockBind.alreadyDeducted': '已确认扣减,不能再改绑', + 'order.myOrders.stockBind.viewEmpty': '暂无绑定的包裹或库存', + 'order.myOrders.stockBind.bindQty': '绑定数量', + 'order.myOrders.stockBind.bindCount': '共 {count} 条', + 'order.myOrders.stockBind.bin': '库位', + 'order.myOrders.stockBind.status.none': '未绑定', + 'order.myOrders.stockBind.status.bound': '已绑定', + 'order.myOrders.stockBind.status.deducted': '已扣减', + 'order.myOrders.stockBind.status.released': '已释放', + 'common.cancel': '取消', + 'common.loading': '加载中...', 'order.myOrders.latestTrack.loading': '轨迹加载中…', 'order.myOrders.latestTrack.empty': '暂无轨迹', @@ -919,6 +989,7 @@ export default { 'order.myOrders.drawer.tabs.weight': '件重尺', 'order.myOrders.drawer.tabs.fee': '应收应付', 'order.myOrders.drawer.tabs.track': '轨迹', + 'order.myOrders.drawer.tabs.stockBind': '绑定包裹/库存', 'order.myOrders.drawer.orderBasic': '基本信息', 'order.myOrders.drawer.basic.viewAll': '全部', 'order.myOrders.drawer.basic.group.identity': '单号信息', @@ -2251,11 +2322,15 @@ export default { // 操作模块 - 入库扫描 'operation.inbound.pageTitle': '运单信息', 'operation.inbound.broadcastSettings': '播报设置', + 'operation.inbound.scan.title': '扫码入库', + 'operation.inbound.tip': '扫描单号核对产品与国家后,填写收货实重与尺寸再入库,避免录错。', + 'operation.inbound.preview.title': '核对信息', + 'operation.inbound.preview.empty': '扫描单号后显示订单信息,并填写收货实重与尺寸', 'operation.inbound.form.scanNumber': '扫描单号:', - 'operation.inbound.form.receivedWeight': '收货实重:', - 'operation.inbound.form.dimensions': '长*宽*高:', - 'operation.inbound.form.salesProduct': '销售产品:', - 'operation.inbound.form.destinationCountry': '目的国家:', + 'operation.inbound.form.receivedWeight': '收货实重', + 'operation.inbound.form.dimensions': '长*宽*高', + 'operation.inbound.form.salesProduct': '销售产品', + 'operation.inbound.form.destinationCountry': '目的国家', 'operation.inbound.form.remarks': '备注:', 'operation.inbound.form.placeholder.scanOrInput': '请扫描或输入单号', 'operation.inbound.form.placeholder.input': '请输入', @@ -2266,10 +2341,11 @@ export default { 'operation.inbound.form.placeholder.scanFirst': '扫描单号后自动带出', 'operation.inbound.form.hint.supportedTypes': '支持:运单号,服务商单号,渠道转单号,平台订单号', 'operation.inbound.actions.reset': '重置', + 'operation.inbound.actions.lookup': '查询核对', 'operation.inbound.actions.inbound': '入库', - 'operation.inbound.recentOrders.title': '最近操作的订单', + 'operation.inbound.recentOrders.title': '最近入库', 'operation.inbound.recentOrders.subtitle': '此处最多显示最近操作的50张订单', - 'operation.inbound.recentOrders.empty': '暂无数据', + 'operation.inbound.recentOrders.empty': '暂无记录', 'operation.inbound.table.index': '序号', 'operation.inbound.table.waybillNumber': '运单号', 'operation.inbound.table.weight': '重量', @@ -2288,12 +2364,16 @@ export default { // 操作模块 - 出库扫描 'operation.outbound.pageTitle': '运单信息', 'operation.outbound.broadcastSettings': '播报设置', + 'operation.outbound.scan.title': '扫码出库', + 'operation.outbound.tip': '扫描运单号核对产品、国家与渠道后,可按需补录发货实重尺寸再出库。', + 'operation.outbound.preview.title': '核对信息', + 'operation.outbound.preview.empty': '扫描单号后显示订单信息,可填写发货实重与尺寸', 'operation.outbound.form.scanNumber': '扫描单号:', - 'operation.outbound.form.shipWeight': '发货实重:', - 'operation.outbound.form.dimensions': '长*宽*高:', - 'operation.outbound.form.salesProduct': '销售产品:', - 'operation.outbound.form.destinationCountry': '目的国家:', - 'operation.outbound.form.serviceChannel': '服务渠道:', + 'operation.outbound.form.shipWeight': '发货实重', + 'operation.outbound.form.dimensions': '长*宽*高', + 'operation.outbound.form.salesProduct': '销售产品', + 'operation.outbound.form.destinationCountry': '目的国家', + 'operation.outbound.form.serviceChannel': '服务渠道', 'operation.outbound.form.placeholder.scanOrInput': '请扫描或输入单号', 'operation.outbound.form.placeholder.input': '请输入', 'operation.outbound.form.placeholder.length': '长/CM', @@ -2303,10 +2383,11 @@ export default { 'operation.outbound.form.placeholder.scanFirst': '扫描单号后自动带出', 'operation.outbound.form.hint.supportedTypes': '支持:仅支持运单号', 'operation.outbound.actions.reset': '重置', + 'operation.outbound.actions.lookup': '查询核对', 'operation.outbound.actions.outbound': '出库', - 'operation.outbound.recentOrders.title': '最近操作的订单', + 'operation.outbound.recentOrders.title': '最近出库', 'operation.outbound.recentOrders.subtitle': '此处最多显示最近操作的50张订单', - 'operation.outbound.recentOrders.empty': '暂无数据', + 'operation.outbound.recentOrders.empty': '暂无记录', 'operation.outbound.table.index': '序号', 'operation.outbound.table.waybillNumber': '运单号', 'operation.outbound.table.weight': '重量', @@ -2322,27 +2403,48 @@ export default { 'operation.outbound.message.outboundFailed': '出库失败', 'operation.outbound.message.loadRecentFailed': '加载最近出库记录失败', - // 操作模块 - 打印标签 'operation.printLabel.pageTitle': '打印标签', 'operation.printLabel.broadcastSettings': '播报设置', - 'operation.printLabel.form.scanNumber': '单号:', - 'operation.printLabel.form.placeholder.scanOrInput': '请扫描或输入单号', - 'operation.printLabel.form.placeholder.numberType': '请选择单号类型', + 'operation.printLabel.tip': '扫描任一号码拉出订单与绑定货品,核对数量无误后再打印面单,避免发错、发漏。', + 'operation.printLabel.scan.title': '扫码打印', + 'operation.printLabel.form.scanNumber': '扫描号码', + 'operation.printLabel.form.placeholder.scanOrInput': '运单号 / 客户单号 / 跟踪号 / 包裹单号 / SKU', + 'operation.printLabel.form.placeholder.numberType': '号码类型', 'operation.printLabel.form.placeholder.labelTemplate': '请选择标签模板', - 'operation.printLabel.form.hint.supportedTypes': '支持: 运单号、客户单号、跟踪号、其他单号', + 'operation.printLabel.form.hint.supportedTypes': '支持: 运单号、客户单号、跟踪号、其他单号、包裹快递单号、SKU', 'operation.printLabel.actions.reset': '重置', - 'operation.printLabel.actions.print': '打印', + 'operation.printLabel.actions.lookup': '查询核对', + 'operation.printLabel.actions.print': '确认打印', 'operation.printLabel.recentOrders.subtitle': '此处最多显示最近操作的50条记录', - 'operation.printLabel.recentOrders.empty': '暂无数据', + 'operation.printLabel.recentOrders.title': '最近打印', + 'operation.printLabel.recentOrders.empty': '暂无记录', + 'operation.printLabel.numberType.auto': '智能识别', 'operation.printLabel.numberType.waybill': '运单号', 'operation.printLabel.numberType.customerOrder': '客户单号', 'operation.printLabel.numberType.tracking': '跟踪号', 'operation.printLabel.numberType.other': '其他单号', + 'operation.printLabel.numberType.parcel': '包裹快递单号', + 'operation.printLabel.numberType.sku': 'SKU 编码', 'operation.printLabel.labelTemplate.lastMile': '尾程标签', 'operation.printLabel.labelTemplate.customer': '客户标签', 'operation.printLabel.labelTemplate.inbound': '入库标签', 'operation.printLabel.labelTemplate.outbound': '出库标签', 'operation.printLabel.labelTemplate.sku': 'sku标签', + 'operation.printLabel.preview.title': '核对信息', + 'operation.printLabel.preview.empty': '扫描号码后显示订单与绑定货品', + 'operation.printLabel.preview.order': '订单', + 'operation.printLabel.preview.bindSummary': '{lines} 种货 · 共 {qty} 件', + 'operation.printLabel.preview.lines': '货品种类', + 'operation.printLabel.preview.noneBind': '未绑定包裹/库存,请与实物仔细核对后再打印', + 'operation.printLabel.preview.multiMatch': '命中多笔订单,请点选一笔再核对', + 'operation.printLabel.preview.bindInventory': '库存', + 'operation.printLabel.preview.bindParcel': '包裹', + 'operation.printLabel.preview.bindQty': '应发', + 'operation.printLabel.preview.bin': '库位', + 'operation.printLabel.preview.sku': 'SKU', + 'operation.printLabel.preview.tracking': '快递单号', + 'operation.printLabel.preview.attr': '规格', + 'operation.printLabel.preview.selectCandidate': '选择此单', 'operation.printLabel.table.index': '序号', 'operation.printLabel.table.waybillNumber': '运单号', 'operation.printLabel.table.customerOrderNumber': '客户单号', @@ -2354,6 +2456,8 @@ export default { 'operation.printLabel.table.operateTime': '操作时间', 'operation.printLabel.table.operator': '操作人', 'operation.printLabel.message.waybillNumberRequired': '请输入或扫描单号', + 'operation.printLabel.message.lookupSuccess': '已找到订单,请核对绑定货品', + 'operation.printLabel.message.lookupFirst': '请先查询并核对订单信息', 'operation.printLabel.message.printSuccess': '打印成功', 'operation.printLabel.printSuccess.yes': '是', 'operation.printLabel.printSuccess.no': '否', @@ -3109,6 +3213,34 @@ export default { 'channel.labelDesign.noContent': '无内容', 'channel.labelDesign.applySuccess': '配置已应用', 'channel.labelDesign.resetSuccess': '配置已重置', + 'channel.labelDesign.searchPlaceholder': '搜索模板名称', + 'channel.labelDesign.typePlaceholder': '模板类型', + 'channel.labelDesign.namePlaceholder': '模板名称', + 'channel.labelDesign.loadingDesigner': '正在加载设计器…', + 'channel.labelDesign.total': '共 {n} 条', + 'channel.labelDesign.table.name': '名称', + 'channel.labelDesign.table.type': '类型', + 'channel.labelDesign.table.updateTime': '更新时间', + 'channel.labelDesign.table.actions': '操作', + 'channel.labelDesign.actions.search': '查询', + 'channel.labelDesign.actions.create': '新建模板', + 'channel.labelDesign.actions.edit': '设计', + 'channel.labelDesign.actions.delete': '删除', + 'channel.labelDesign.actions.back': '返回列表', + 'channel.labelDesign.actions.preview': '预览', + 'channel.labelDesign.actions.print': '打印', + 'channel.labelDesign.actions.save': '保存', + 'channel.labelDesign.actions.startDesign': '开始设计', + 'channel.labelDesign.actions.cancel': '取消', + 'channel.labelDesign.message.loadFailed': '加载模板失败', + 'channel.labelDesign.message.saveSuccess': '模板已保存', + 'channel.labelDesign.message.saveFailed': '保存失败', + 'channel.labelDesign.message.deleteSuccess': '已删除', + 'channel.labelDesign.message.nameRequired': '请填写模板名称', + 'channel.labelDesign.fieldDictionary': '订单字段', + 'channel.labelDesign.message.fieldCopied': '已复制字段:{field}', + 'channel.labelDesign.message.previewEmpty': '暂无可预览的模板', + 'channel.labelDesign.message.previewFailed': '预览 PDF 失败', // 渠道 - 销售产品 'channel.salesProducts.search.placeholder': '请输入产品名称', @@ -3179,6 +3311,7 @@ export default { 'channel.salesProducts.form.weightRounding': '计重进位', 'channel.salesProducts.form.productDescription': '产品说明', 'channel.salesProducts.form.preStorageScript': '落库前执行脚本', + 'channel.salesProducts.form.placeholder.labelTemplate': '请选择标签模板(未选则用全局默认)', 'channel.salesProducts.form.placeholder.input': '请输入', 'channel.salesProducts.form.placeholder.min': '最小值', 'channel.salesProducts.form.placeholder.max': '最大值', diff --git a/src/router/routes/newModules/operation.ts b/src/router/routes/newModules/operation.ts index 797bb6b..046d9bf 100644 --- a/src/router/routes/newModules/operation.ts +++ b/src/router/routes/newModules/operation.ts @@ -41,7 +41,7 @@ const OPERATION: AppRouteRecordRaw = { meta: { locale: 'menu.operation.printLabel', requiresAuth: true, - permission: 'Operation.PrintLabel.Query', + permission: 'Operation.PrintLabel', order: 3, }, }, diff --git a/src/store/modules/rbac-user.ts b/src/store/modules/rbac-user.ts index 3312749..9f97ec5 100644 --- a/src/store/modules/rbac-user.ts +++ b/src/store/modules/rbac-user.ts @@ -310,9 +310,19 @@ export const useRbacUserStore = defineStore('rbacUser', () => { initAuth() - // 检查权限 + // 检查权限(与 @/utils/rbac-permission 规则一致:资源码 ↔ Query 互通) function hasPermission(permission: string): boolean { - return permissions.value.includes(permission) + if (!permission?.trim()) return true + const code = permission.trim() + const granted = permissions.value + if (granted.includes(code)) return true + if (/\.Query$/i.test(code)) { + const resource = code.replace(/\.Query$/i, '') + if (resource && granted.includes(resource)) return true + } else if (granted.includes(`${code}.Query`)) { + return true + } + return false } // 检查角色 diff --git a/src/styles/warehouse-list-page.less b/src/styles/warehouse-list-page.less index d674cb2..aa24997 100644 --- a/src/styles/warehouse-list-page.less +++ b/src/styles/warehouse-list-page.less @@ -23,6 +23,18 @@ overflow: hidden; } +.warehouse-list-page-card .wh-page-tip { + margin: 16px 16px 0; + padding: 10px 12px; + border-radius: 6px; + background: color-mix(in srgb, var(--app-primary-color) 8%, #fff); + border: 1px solid color-mix(in srgb, var(--app-primary-color) 22%, #e5e6eb); + color: #4e5969; + font-size: 13px; + line-height: 1.5; + flex-shrink: 0; +} + .warehouse-list-page-card .status-tabs { padding: 16px 16px 0; flex-shrink: 0; @@ -98,7 +110,9 @@ .warehouse-list-page-card .list-wrap :deep(.wh-action-btn--relocate:hover), .warehouse-list-page-card .list-wrap :deep(.wh-action-btn--receive:hover), .warehouse-list-page-card .list-wrap :deep(.wh-action-btn--star:hover), -.warehouse-list-page-card .list-wrap :deep(.wh-action-btn--pay:hover) { +.warehouse-list-page-card .list-wrap :deep(.wh-action-btn--pay:hover), +.warehouse-list-page-card .list-wrap :deep(.wh-action-btn--history:hover), +.warehouse-list-page-card .list-wrap :deep(.wh-action-btn--track:hover) { color: var(--app-primary-color); background: var(--app-primary-color-light, #e6f7f7); } diff --git a/src/utils/rbac-permission.ts b/src/utils/rbac-permission.ts index fd42d39..4ba8f4d 100644 --- a/src/utils/rbac-permission.ts +++ b/src/utils/rbac-permission.ts @@ -1,12 +1,29 @@ import { useRbacUserStore } from '@/store/modules/rbac-user' +import { normalizeResourcePermissionCode } from '@/constants/pageButtonCatalog' /** * 检查是否有权限(三级按钮 / 路由 meta.permission) + * + * 兼容菜单同步后的编码差异: + * - 二级菜单可能是资源码 `Operation.PrintLabel` + * - 路由 meta 可能是 `Operation.PrintLabel.Query` + * 二者互相视为可访问页面。 */ export function hasPermission(permission: string): boolean { const userStore = useRbacUserStore() if (!permission?.trim()) return true - return userStore.permissions.includes(permission) + const code = permission.trim() + const granted = userStore.permissions + if (granted.includes(code)) return true + + if (/\.Query$/i.test(code)) { + const resource = normalizeResourcePermissionCode(code) + if (resource && granted.includes(resource)) return true + } else if (granted.includes(`${code}.Query`)) { + return true + } + + return false } /** diff --git a/src/utils/syncMenuLevel3Buttons.ts b/src/utils/syncMenuLevel3Buttons.ts index 023102a..394db0e 100644 --- a/src/utils/syncMenuLevel3Buttons.ts +++ b/src/utils/syncMenuLevel3Buttons.ts @@ -182,10 +182,15 @@ async function ensurePageMenu( ): Promise<{ menu: MenuTreeDto; created: boolean }> { const existing = findPageChildMenu(parentMenu, pageDef.route, pageDef.permissionCode); if (existing?.id) { - // 已有二级菜单但未配 permissionCode 时,用路由目录补齐,便于同步三级按钮 + // 已有二级菜单:补齐或纠正 permissionCode(Xxx.Query → Xxx),便于同步「查询」等三级按钮 const existingCode = existing.permissionCode?.trim() || ''; const nextCode = pageDef.permissionCode?.trim() || ''; - if (!existingCode && nextCode) { + const shouldPatchCode = + !!nextCode && + (!existingCode || + existingCode === nextCode || + normalizeResourcePermissionCode(existingCode) === nextCode); + if (shouldPatchCode && existingCode !== nextCode) { try { await MenuService.putRbacMenuUpdate(existing.id, { name: existing.name || pageDef.name, @@ -248,7 +253,7 @@ export async function syncMenuLevel3Buttons( menu: MenuTreeDto, options?: SyncLevel3Options, ): Promise { - const parentPermissionCode = menu.permissionCode?.trim() || ''; + let parentPermissionCode = menu.permissionCode?.trim() || ''; if (!parentPermissionCode) { throw new Error('当前菜单未配置权限编码,无法同步三级按钮'); } @@ -259,6 +264,28 @@ export async function syncMenuLevel3Buttons( throw new Error('仅支持对页面菜单同步三级按钮'); } + // 二级菜单若误存为 Xxx.Query,纠正为资源码,使「查询」可作为三级按钮同步 + const resourceCode = normalizeResourcePermissionCode(parentPermissionCode); + if (resourceCode && resourceCode !== parentPermissionCode) { + try { + await MenuService.putRbacMenuUpdate(menu.id, { + name: menu.name, + permissionCode: resourceCode, + icon: menu.icon, + route: menu.route, + component: menu.component, + order: menu.order ?? 0, + isHidden: menu.isHidden ?? false, + isCached: menu.isCached ?? false, + description: menu.description || `同步二级菜单权限码: ${resourceCode}`, + }); + parentPermissionCode = resourceCode; + menu = { ...menu, permissionCode: resourceCode }; + } catch { + // 纠正失败时仍按原编码尝试同步(查询按钮可能被过滤) + } + } + const catalogButtons = getCatalogButtons(parentPermissionCode); let permissionTreeButtons: PageButtonDef[] = []; try { diff --git a/src/utils/syncMenuRouteCatalog.ts b/src/utils/syncMenuRouteCatalog.ts index 902d61c..b90203d 100644 --- a/src/utils/syncMenuRouteCatalog.ts +++ b/src/utils/syncMenuRouteCatalog.ts @@ -2,6 +2,7 @@ import i18n from '@/locale'; import { appRoutes } from '@/router/routes'; import type { AppRouteRecordRaw } from '@/router/routes/types'; import type { MenuTreeDto } from '@/api/rbac'; +import { normalizeResourcePermissionCode } from '@/constants/pageButtonCatalog'; export interface RoutePageMenuDef { name: string; @@ -88,11 +89,15 @@ export function getPageRoutesFromModule(moduleRoute: AppRouteRecordRaw): RoutePa if (!child.meta || child.meta.hideInMenu) return; const routePath = joinRoutePath(parentPath, child.path); + // 二级菜单存资源码(Operation.PrintLabel),查询等动作作为三级按钮同步 + const rawPermission = (child.meta.permission as string | undefined)?.trim() || undefined; pages.push({ name: resolveRouteMenuTitle(child), route: routePath, component: extractComponentPath(child.component), - permissionCode: (child.meta.permission as string | undefined)?.trim() || undefined, + permissionCode: rawPermission + ? normalizeResourcePermissionCode(rawPermission) || rawPermission + : undefined, icon: (child.meta.icon as string | undefined)?.trim() || undefined, order: (child.meta.order as number | undefined) ?? 0, isHidden: false, diff --git a/src/utils/warehouseActionRenderer.ts b/src/utils/warehouseActionRenderer.ts index f4f9e1c..9360fe3 100644 --- a/src/utils/warehouseActionRenderer.ts +++ b/src/utils/warehouseActionRenderer.ts @@ -11,6 +11,7 @@ export const warehouseActionIcons = { star: ``, pay: ``, track: ``, + history: ``, } as const export type WarehouseActionVariant = keyof typeof warehouseActionIcons diff --git a/src/utils/warehouseListMapper.ts b/src/utils/warehouseListMapper.ts index c5d9fe1..967f487 100644 --- a/src/utils/warehouseListMapper.ts +++ b/src/utils/warehouseListMapper.ts @@ -75,6 +75,8 @@ export type ParcelItemLine = { attributeText: string imageUrl: string quantity: number + availableQty: number + frozenQty: number remark: string } @@ -96,11 +98,20 @@ export function normalizeParcelItemLines(items: unknown): ParcelItemLine[] { return list.map((item) => { const row = item as Row const q = Number(pickField(row, 'quantity', 'Quantity') ?? 1) + const qty = q > 0 ? q : 1 + const frozen = Math.max(0, Number(pickField(row, 'frozenQty', 'FrozenQty') ?? 0)) + const availableRaw = pickField(row, 'availableQty', 'AvailableQty') + const available = + availableRaw != null && availableRaw !== '' + ? Number(availableRaw) + : Math.max(0, qty - frozen) return { productName: String(pickField(row, 'productName', 'ProductName') ?? '').trim() || '-', attributeText: String(pickField(row, 'attributeText', 'AttributeText') ?? '').trim() || '-', imageUrl: String(pickField(row, 'imageUrl', 'ImageUrl', 'image', 'Image') ?? '').trim(), - quantity: q > 0 ? q : 1, + quantity: qty, + availableQty: Number.isFinite(available) ? available : 0, + frozenQty: frozen, remark: String(pickField(row, 'remark', 'Remark') ?? '').trim() || '-', } }) diff --git a/src/views/api/upstreamInterface/index.vue b/src/views/api/upstreamInterface/index.vue index dc56b46..350f320 100644 --- a/src/views/api/upstreamInterface/index.vue +++ b/src/views/api/upstreamInterface/index.vue @@ -1330,6 +1330,7 @@ import { IconClose, IconEdit, IconPlus, IconSearch, IconMore, IconMinus, IconRef diff --git a/src/views/channel/labelDesign/index.vue b/src/views/channel/labelDesign/index.vue index 4d54fad..f16e3f7 100644 --- a/src/views/channel/labelDesign/index.vue +++ b/src/views/channel/labelDesign/index.vue @@ -1,103 +1,324 @@ - diff --git a/src/views/channel/salesProducts/index.vue b/src/views/channel/salesProducts/index.vue index 9d6f53e..7d3c3c5 100644 --- a/src/views/channel/salesProducts/index.vue +++ b/src/views/channel/salesProducts/index.vue @@ -18,6 +18,7 @@ updateSalesProduct, updateSalesProductPrice, } from '@/api/channel/salesProduct'; + import { getLabelTemplateList } from '@/api/channel/labelTemplate'; import { postForewarningServiceKpiAreaGetKpiAreas } from '@/api/channel/kpiArea'; import { getWarehouseList } from '@/api/system/warehouse'; import { postWeightRuleList } from '@/api/channel/weightRule'; @@ -109,6 +110,7 @@ minTimeliness: '', maxTimeliness: '', customerWaybill: '系统面单', + labelTemplateId: undefined as number | undefined, blacklistArea: '', remoteAreaDivision: '', priceArea: '', @@ -166,11 +168,20 @@ } } - // 客户面单选项 - const customerWaybillOptions = ref([ - { label: '系统面单', value: '系统面单' }, - { label: '客户面单', value: '客户面单' }, - ]); + // 客户面单:真实标签模板下拉 + const labelTemplateOptions = ref<{ label: string; value: number }[]>([]); + + async function loadLabelTemplateOptions() { + try { + const items = await getLabelTemplateList(); + labelTemplateOptions.value = (items || []).map((it) => ({ + label: it.name, + value: it.id, + })); + } catch { + labelTemplateOptions.value = []; + } + } const weightFactorOptions: IdSelectOption[] = Array.from({ length: 20 }, (_, index) => { const v = ((index + 1) * 0.5).toFixed(1).replace(/\.0$/, ''); @@ -637,6 +648,7 @@ minTimeliness: '', maxTimeliness: '', customerWaybill: '系统面单', + labelTemplateId: undefined as number | undefined, blacklistArea: '', remoteAreaDivision: '', priceArea: '', @@ -656,8 +668,10 @@ minTimeliness: '', maxTimeliness: '', customerWaybill: '系统面单', + labelTemplateId: undefined, blacklistArea: '', remoteAreaDivision: '', + priceArea: '', weightCalculationRule: '', weightRounding: '', productDescription: '', @@ -684,6 +698,7 @@ minTimeliness: Number(addProductFormData.minTimeliness) || 0, maxTimeliness: Number(addProductFormData.maxTimeliness) || 0, customerWaybill: addProductFormData.customerWaybill || '系统面单', + labelTemplateId: addProductFormData.labelTemplateId || undefined, productDescription: addProductFormData.productDescription || '', preStorageScript: addProductFormData.preStorageScript || '', isActive: 1, @@ -961,6 +976,11 @@ minTimeliness: numStr(p.minTimeliness ?? p.MinTimeliness), maxTimeliness: numStr(p.maxTimeliness ?? p.MaxTimeliness), customerWaybill: p.customerWaybill ?? p.CustomerWaybill ?? '系统面单', + labelTemplateId: (() => { + const raw = p.labelTemplateId ?? p.LabelTemplateId; + const n = Number(raw); + return Number.isFinite(n) && n > 0 ? n : undefined; + })(), blacklistArea: numStr(p.blacklistAreaId ?? p.BlacklistAreaId), remoteAreaDivision: numStr(p.remoteAreaId ?? p.RemoteAreaId), priceArea: numStr(p.priceAreaId ?? p.PriceAreaId), @@ -982,6 +1002,7 @@ void loadKpiAreaSelectOptions(); void loadWeightSelectOptions(); void loadBillingFactorSelectOptions(); + void loadLabelTemplateOptions(); loadProductList(); }); @@ -1159,6 +1180,7 @@ minTimeliness: Number(formData.minTimeliness) || 0, maxTimeliness: Number(formData.maxTimeliness) || 0, customerWaybill: formData.customerWaybill, + labelTemplateId: formData.labelTemplateId || undefined, blacklistAreaId: blAreaId ?? null, remoteAreaId: rmAreaId ?? null, priceAreaId: paAreaId ?? null, @@ -3068,11 +3090,14 @@
@@ -3623,11 +3648,14 @@
diff --git a/src/views/operation/inboundScan/index.vue b/src/views/operation/inboundScan/index.vue index 3e36719..ec4b8ec 100644 --- a/src/views/operation/inboundScan/index.vue +++ b/src/views/operation/inboundScan/index.vue @@ -1,152 +1,168 @@ diff --git a/src/views/operation/outboundScan/index.vue b/src/views/operation/outboundScan/index.vue index 7024954..a581017 100644 --- a/src/views/operation/outboundScan/index.vue +++ b/src/views/operation/outboundScan/index.vue @@ -1,161 +1,166 @@ diff --git a/src/views/operation/printLabel/index.vue b/src/views/operation/printLabel/index.vue index 1e8f9b4..9b4c5dc 100644 --- a/src/views/operation/printLabel/index.vue +++ b/src/views/operation/printLabel/index.vue @@ -1,488 +1,1138 @@ diff --git a/src/views/operation/styles/ops-scan-page.less b/src/views/operation/styles/ops-scan-page.less new file mode 100644 index 0000000..a1325dd --- /dev/null +++ b/src/views/operation/styles/ops-scan-page.less @@ -0,0 +1,509 @@ +.ops-page { + display: flex; + flex-direction: row; + align-items: stretch; + gap: 12px; + padding: 16px; + background: #f0f3f4; + flex: 1; + min-height: 0; + overflow: hidden; +} + +.ops-col--main { + flex: 1 1 0; + min-width: 0; + min-height: 0; + display: flex; + flex-direction: column; + gap: 12px; +} + +.ops-card { + display: flex; + flex-direction: column; + background: #fff; + border-radius: 8px; + box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06); + overflow: hidden; +} + +.ops-card__head { + display: flex; + align-items: center; + gap: 10px; + padding: 12px 16px; + font-size: 14px; + font-weight: 600; + color: #1d2129; + border-bottom: 1px solid #f2f3f5; + flex-shrink: 0; + background: #fafbfc; +} + +.ops-card__body { + min-height: 0; +} + +.ops-card--scan { + flex: 0 0 auto; +} + +.ops-card--verify { + flex: 1 1 0; + min-height: 0; + + .ops-card__body { + flex: 1; + overflow: auto; + } +} + +.ops-card--recent { + flex: 0 0 380px; + width: 380px; + max-width: 40%; + + .ops-card__body { + flex: 1; + display: flex; + flex-direction: column; + } +} + +.ops-card--recent-wide { + flex: 1.2 1 0; + min-width: 0; + width: auto; + max-width: none; + + .ops-card__body { + flex: 1; + display: flex; + flex-direction: column; + min-height: 0; + } +} + +.ops-feedback { + margin: 0 0 0 auto; + max-width: 60%; + font-size: 13px; + font-weight: 600; + line-height: 1.4; + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; + + &.is-error { + color: #f53f3f; + } + + &.is-success { + color: #00b42a; + } + + &.is-warning { + color: #d46b08; + } +} + +.ops-scan { + display: flex; + flex-direction: column; + gap: 10px; + padding: 14px 16px 12px; +} + +.ops-scan__row { + display: flex; + align-items: center; + gap: 10px; + width: 100%; +} + +.ops-scan__row--tools { + justify-content: space-between; + flex-wrap: wrap; +} + +.ops-scan-input { + width: 100%; + + :deep(.arco-input-wrapper) { + height: 44px; + border-radius: 6px; + background: #fff; + border-color: #e5e6eb; + transition: border-color 0.2s, box-shadow 0.2s; + + &:hover, + &.arco-input-focus { + border-color: var(--app-primary-color); + } + + &.arco-input-focus { + box-shadow: 0 0 0 2px color-mix(in srgb, var(--app-primary-color) 18%, transparent); + } + } + + :deep(.arco-input) { + height: 42px; + font-size: 18px; + font-weight: 560; + letter-spacing: 0.02em; + } +} + +.ops-scan-hint { + margin: 0; + font-size: 12px; + color: #86909c; + line-height: 1.4; +} + +.ops-scan__opts { + display: flex; + flex-wrap: wrap; + align-items: center; + gap: 12px; + min-width: 0; +} + +.ops-opt { + white-space: nowrap; + color: #4e5969; +} + +.ops-scan__actions { + display: flex; + align-items: center; + gap: 8px; + margin-left: auto; +} + +.ops-btn { + height: 36px !important; + border-radius: 4px !important; + padding: 0 16px !important; + font-size: 14px; + + &--ghost { + color: #4e5969; + border-color: #e5e6eb; + background: #fff; + + &:hover { + color: var(--app-primary-color); + border-color: var(--app-primary-color); + background: color-mix(in srgb, var(--app-primary-color) 6%, #fff); + } + } + + &--primary { + min-width: 112px; + font-weight: 600; + background: var(--app-primary-color) !important; + border-color: var(--app-primary-color) !important; + + &:hover { + filter: brightness(1.05); + } + } +} + +.ops-verify { + padding: 16px; +} + +.ops-verify-spin { + width: 100%; + min-height: 200px; +} + +.ops-hero { + padding: 16px 18px; + border-radius: 10px; + background: color-mix(in srgb, var(--app-primary-color) 8%, #fff); + border: 1px solid color-mix(in srgb, var(--app-primary-color) 20%, #e5e6eb); +} + +.ops-hero__waybill { + font-size: 26px; + font-weight: 700; + letter-spacing: 0.02em; + color: #1d2129; + line-height: 1.2; + word-break: break-all; +} + +.ops-hero__meta { + margin-top: 10px; + display: flex; + flex-wrap: wrap; + gap: 10px 20px; + font-size: 13px; + color: #4e5969; +} + +.ops-metrics { + margin-top: 16px; + display: grid; + grid-template-columns: minmax(140px, 200px) 1fr; + gap: 16px; +} + +.ops-metric__label { + display: block; + margin-bottom: 8px; + font-size: 13px; + font-weight: 500; + color: #4e5969; +} + +.ops-metric__weight { + display: flex; + align-items: center; + gap: 8px; +} + +.ops-unit { + font-size: 13px; + color: #86909c; + flex-shrink: 0; +} + +.ops-dims { + display: flex; + align-items: center; + gap: 6px; + flex-wrap: wrap; +} + +.ops-dims__x { + color: #86909c; + font-size: 13px; +} + +.ops-field { + :deep(.arco-input-wrapper) { + height: 36px; + border-radius: 4px; + } + + &--dim { + width: 96px; + } +} + +.ops-select { + width: 100%; + max-width: 320px; + + :deep(.arco-select-view-single) { + height: 36px; + border-radius: 4px; + } +} + +.ops-readonly { + :deep(.arco-input-wrapper) { + height: 36px; + background: #f7f8fa; + } + + :deep(.arco-input) { + color: #4e5969; + cursor: default; + } +} + +.ops-empty { + display: flex; + flex-direction: column; + align-items: center; + justify-content: center; + min-height: 200px; + text-align: center; + color: #86909c; +} + +.ops-empty__title { + margin: 0; + font-size: 16px; + color: #4e5969; +} + +.ops-empty__tip { + margin: 8px 0 0; + max-width: 420px; + font-size: 13px; + line-height: 1.5; +} + +.ops-status-grid { + display: grid; + grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); + gap: 12px; +} + +.ops-status-item { + padding: 14px 16px; + border-radius: 8px; + background: #f7f8fa; + border: 1px solid #f0f0f0; + + span { + display: block; + font-size: 12px; + color: #86909c; + margin-bottom: 6px; + } + + strong { + font-size: 15px; + font-weight: 600; + color: #1d2129; + word-break: break-all; + } +} + +.ops-recent__count { + min-width: 20px; + height: 20px; + padding: 0 7px; + border-radius: 10px; + background: color-mix(in srgb, var(--app-primary-color) 12%, #fff); + color: var(--app-primary-color); + font-size: 12px; + font-weight: 600; + line-height: 20px; + text-align: center; +} + +.ops-recent__list { + flex: 1; + min-height: 0; + overflow: auto; + padding: 10px; +} + +.ops-recent__empty { + padding: 40px 12px; + text-align: center; + font-size: 13px; + color: #c9cdd4; +} + +.ops-recent__row { + padding: 12px; + border-radius: 8px; + font-size: 13px; + color: #4e5969; + border: 1px solid #f0f0f0; + background: #fff; + + & + & { + margin-top: 8px; + } + + &:hover { + background: #f7f8fa; + border-color: #e5e6eb; + } +} + +.ops-recent__top, +.ops-recent__mid, +.ops-recent__bottom { + display: flex; + align-items: center; + justify-content: space-between; + gap: 8px; +} + +.ops-recent__mid, +.ops-recent__bottom { + margin-top: 6px; + font-size: 12px; + color: #86909c; +} + +.ops-recent__no { + font-weight: 600; + font-size: 13px; + color: #1d2129; + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; +} + +.ops-recent__weight { + flex-shrink: 0; + font-weight: 600; + color: var(--app-primary-color); + font-size: 12px; +} + +.ops-recent__time { + flex-shrink: 0; +} + +.ops-list-toolbar { + display: flex; + justify-content: space-between; + align-items: center; + gap: 12px; + padding: 12px 16px 0; + flex-shrink: 0; + flex-wrap: wrap; +} + +.ops-list-wrap { + width: 100%; + flex: 1; + min-height: 0; + padding: 12px 16px 16px; + box-sizing: border-box; + display: flex; + flex-direction: column; + overflow: hidden; +} + +@media (max-width: 1100px) { + .ops-page { + flex-direction: column; + overflow: auto; + } + + .ops-card--recent, + .ops-card--recent-wide { + flex: 0 0 auto; + width: 100%; + max-width: none; + max-height: 320px; + } + + .ops-metrics { + grid-template-columns: 1fr; + } + + .ops-scan__row--tools { + flex-direction: column; + align-items: stretch; + } + + .ops-scan__actions { + margin-left: 0; + width: 100%; + + .ops-btn { + flex: 1; + } + } + + .ops-feedback { + max-width: 100%; + margin-left: 0; + } +} diff --git a/src/views/order/myOrders/columnConfig.ts b/src/views/order/myOrders/columnConfig.ts index 5ad8b66..126cce0 100644 --- a/src/views/order/myOrders/columnConfig.ts +++ b/src/views/order/myOrders/columnConfig.ts @@ -31,7 +31,6 @@ export const MY_ORDERS_COLUMN_CATALOG: OrderListColumnDef[] = [ { key: 'customerOrderNo', labelKey: 'order.myOrders.table.customerOrderNo', width: 150 }, { key: 'trackingNo', labelKey: 'order.myOrders.table.trackingNo', width: 160 }, { key: 'orderStatus', labelKey: 'order.myOrders.table.orderStatus', width: 130 }, - { key: 'latestTrack', labelKey: 'order.myOrders.table.latestTrack', width: 280 }, { key: 'shippingMethod', labelKey: 'order.myOrders.table.shippingMethod', width: 120 }, { key: 'serviceChannel', labelKey: 'order.myOrders.table.serviceChannel', width: 120 }, { key: 'isPaid', labelKey: 'order.myOrders.table.isPaid', width: 80 }, @@ -64,7 +63,6 @@ export const MY_ORDERS_DEFAULT_KEYS: string[] = [ 'customerOrderNo', 'trackingNo', 'orderStatus', - 'latestTrack', 'consigneeCountry', 'shippingMethod', 'chargeableWeight', @@ -191,7 +189,6 @@ export function mergeDiscoveredColumns( 'items', 'weightList', 'feeList', - 'latestTrackRaw', ...(options?.skipKeys || []), ]); const map = new Map(catalog.map((c) => [c.key, c])); diff --git a/src/views/order/myOrders/components/OrderDetailDrawer.vue b/src/views/order/myOrders/components/OrderDetailDrawer.vue index 72efcb4..45e317b 100644 --- a/src/views/order/myOrders/components/OrderDetailDrawer.vue +++ b/src/views/order/myOrders/components/OrderDetailDrawer.vue @@ -18,36 +18,6 @@ {{ $t('order.myOrders.drawer.actions.edit') }} - -
@@ -361,228 +331,6 @@
- -
-
- -
- -
- - {{ $t('order.myOrders.drawer.weight.viewAll') }} - - {{ $t(section.labelKey) }} - - -
- - - - -
- - -
-
- - -
- {{ $t('order.myOrders.drawer.fee.grossProfit') }} - {{ formatGrossProfitTotals(feeGrossProfitTotals) }} - {{ grossProfitMarginText }} -
-
- -
- {{ $t('order.myOrders.drawer.fee.grossProfitFormula') }} - - {{ formatFeeTotals(receivableTotals) }} - − - {{ formatFeeTotals(payableTotals) }} - = - - {{ formatGrossProfitTotals(feeGrossProfitTotals) }} - - -
- -
- - {{ $t('order.myOrders.drawer.fee.viewAll') }} - {{ $t('finance.receivablePayable.feeType.receivable') }} - {{ $t('finance.receivablePayable.feeType.payable') }} - -
- - -
-
@@ -663,6 +411,14 @@ />
+ + +
+ +
@@ -692,6 +448,7 @@ import { getDictListAll, type DictDto } from '@/api/system/dict'; import { getOrderStatusMeta, resolveOrderStatusCode } from '@/constants/orderStatus'; import { useRbacUserStore } from '@/store/modules/rbac-user'; import AddOrderFeeModal from './AddOrderFeeModal.vue'; +import OrderStockBindTab from './OrderStockBindTab.vue'; const { t } = useI18n(); const rbacUserStore = useRbacUserStore(); @@ -984,22 +741,15 @@ function resetEditState() { const [register, { openDrawer: innerOpenDrawer, setDrawerProps, closeDrawer }] = useDrawer(); const activeTab = ref('basic'); -const tabList = computed(() => { - const tabs = [ - { key: 'basic', label: t('order.myOrders.drawer.tabs.basic') }, - { key: 'weight', label: t('order.myOrders.drawer.tabs.weight') }, - { key: 'fee', label: t('order.myOrders.drawer.tabs.fee') }, - { key: 'track', label: t('order.myOrders.drawer.tabs.track') }, - ]; - if (isCustomerPortal.value) { - return tabs.filter((tab) => tab.key === 'basic' || tab.key === 'track'); - } - return tabs; -}); +const tabList = computed(() => [ + { key: 'basic', label: t('order.myOrders.drawer.tabs.basic') }, + { key: 'track', label: t('order.myOrders.drawer.tabs.track') }, + { key: 'stockBind', label: t('order.myOrders.drawer.tabs.stockBind') }, +]); function resolveDrawerTab(tab?: string) { const next = tab || 'basic'; - if (isCustomerPortal.value && (next === 'weight' || next === 'fee')) { + if (next === 'weight' || next === 'fee') { return 'basic'; } return next; @@ -1864,13 +1614,6 @@ function handleTabChange(tabKey: string) { if (next === 'basic') { basicViewMode.value = 'all'; } - if (next === 'weight') { - weightViewMode.value = 'all'; - } - if (next === 'fee') { - feeViewMode.value = 'all'; - void ensureFeeItemDictLoaded(); - } if (next === 'track') { loadTrackTimeline(); } @@ -1886,11 +1629,11 @@ watch( (newOrder) => { detail.value = newOrder ? { ...newOrder } : null; resetEditState(); + if (activeTab.value === 'weight' || activeTab.value === 'fee') { + activeTab.value = 'basic'; + } if (newOrder) { loadDetailData(); - if (activeTab.value === 'fee') { - void ensureFeeItemDictLoaded(); - } if (activeTab.value === 'track') { loadTrackTimeline(); } @@ -1899,20 +1642,11 @@ watch( { immediate: true, deep: true } ); -watch(isCustomerPortal, (customer) => { - if (customer && (activeTab.value === 'weight' || activeTab.value === 'fee')) { - activeTab.value = 'basic'; - resetEditState(); - } -}); - defineExpose({ - openDrawer: (opts?: { tab?: 'basic' | 'weight' | 'fee' | 'track' }) => { + openDrawer: (opts?: { tab?: 'basic' | 'weight' | 'fee' | 'track' | 'stockBind' }) => { const tab = resolveDrawerTab(opts?.tab); activeTab.value = tab; basicViewMode.value = 'all'; - feeViewMode.value = 'all'; - weightViewMode.value = 'all'; resetEditState(); setDrawerProps({ content: '', @@ -1923,8 +1657,6 @@ defineExpose({ innerOpenDrawer(); if (tab === 'track') { void loadTrackTimeline(); - } else if (tab === 'fee' && !isCustomerPortal.value) { - void ensureFeeItemDictLoaded(); } }, startBasicEdit, diff --git a/src/views/order/myOrders/components/OrderStockBindTab.vue b/src/views/order/myOrders/components/OrderStockBindTab.vue new file mode 100644 index 0000000..496d032 --- /dev/null +++ b/src/views/order/myOrders/components/OrderStockBindTab.vue @@ -0,0 +1,272 @@ + + + + + diff --git a/src/views/order/myOrders/components/StockBindModal.vue b/src/views/order/myOrders/components/StockBindModal.vue new file mode 100644 index 0000000..e997051 --- /dev/null +++ b/src/views/order/myOrders/components/StockBindModal.vue @@ -0,0 +1,1003 @@ + + + + + diff --git a/src/views/order/myOrders/index.vue b/src/views/order/myOrders/index.vue index 1844f49..cd63aef 100644 --- a/src/views/order/myOrders/index.vue +++ b/src/views/order/myOrders/index.vue @@ -30,11 +30,11 @@ type OrderDownstreamForwardResult, } from '@/api/order'; import { notifyCustomerBalanceChanged } from '@/api/customer/accountFlow'; - import { postGetDetailTimeline } from '@/api/TrackOrder/trackOrder'; import OrderDetailDrawer from './components/OrderDetailDrawer.vue'; import OrderPayConfirmModal from './components/OrderPayConfirmModal.vue'; import MarkProblematicModal from './components/MarkProblematicModal.vue'; import MarkClaimedModal from './components/MarkClaimedModal.vue'; + import StockBindModal from './components/StockBindModal.vue'; import ColumnConfigModal from '../components/ColumnConfigModal.vue'; import { MY_ORDERS_COLUMN_CATALOG, @@ -147,7 +147,7 @@ async function openDetailWithOptionalFetch( row: any, - opts?: { editBasic?: boolean; tab?: 'basic' | 'weight' | 'fee' | 'track' }, + opts?: { editBasic?: boolean; tab?: 'basic' | 'track' }, ) { let nextRow = row; const id = row?.id; @@ -255,6 +255,9 @@ const problematicModalVisible = ref(false); const claimedModalVisible = ref(false); + const stockBindModalVisible = ref(false); + const stockBindOrderId = ref(null); + const stockBindOrderLabel = ref(''); const exceptionOrderIds = ref([]); const payConfirmVisible = ref(false); const payConfirmOrders = ref>([]); @@ -340,8 +343,6 @@ const orderList = ref([]); const listLoading = ref(false); let listRequestSeq = 0; - /** 最新轨迹缓存:orderNumber -> 文案 */ - const latestTrackCache = new Map(); function escapeHtml(text: string) { return String(text) @@ -351,89 +352,6 @@ .replace(/"/g, '"'); } - function formatTrackTimeShort(ts: unknown) { - if (ts == null || ts === '') return ''; - const n = typeof ts === 'number' ? ts : Number(ts); - if (!Number.isFinite(n) || n <= 0) return String(ts); - const ms = n < 1e12 ? n * 1000 : n; - try { - return new Date(ms).toLocaleString('zh-CN', { - month: '2-digit', - day: '2-digit', - hour: '2-digit', - minute: '2-digit', - hour12: false, - }); - } catch { - return ''; - } - } - - function pickLatestTrackText(list: any[]): string { - if (!Array.isArray(list) || !list.length) return ''; - const highlighted = list.find((item) => item?.isHighlight); - const latest = highlighted || list[list.length - 1]; - if (!latest) return ''; - const content = String(latest.content || latest.enContent || '').trim(); - const place = [latest.trackPlace, latest.trackPlaceCity, latest.trackPlaceProvince] - .map((p) => (p == null ? '' : String(p).trim())) - .filter(Boolean) - .join(' '); - const time = formatTrackTimeShort(latest.trackTime); - return [content, place, time].filter(Boolean).join(' · '); - } - - function getOrderTrackNumber(row: any) { - return String(row?.trackingNo || row?.waybillNo || row?.customerOrderNo || '').trim(); - } - - async function enrichLatestTracks(rows: any[], requestSeq: number) { - const targets = rows.filter((row) => { - const status = resolveOrderStatusCode(row); - if (status === 'draft' || status === 'deleted') return false; - return !!getOrderTrackNumber(row); - }); - if (!targets.length) return; - - const concurrency = 5; - for (let i = 0; i < targets.length; i += concurrency) { - if (requestSeq !== listRequestSeq) return; - const batch = targets.slice(i, i + concurrency); - await Promise.all( - batch.map(async (row) => { - const orderNumber = getOrderTrackNumber(row); - if (!orderNumber) return; - - let text = latestTrackCache.get(orderNumber); - if (text === undefined) { - try { - const res: any = await postGetDetailTimeline({ orderNumber }); - const list = res?.data || res || []; - text = pickLatestTrackText(list) || ''; - } catch { - text = ''; - } - latestTrackCache.set(orderNumber, text); - } - - if (requestSeq !== listRequestSeq) return; - const idx = orderList.value.findIndex((it) => Number(it.id) === Number(row.id)); - if (idx < 0) return; - const display = - text || - (row.trackingNo - ? t('order.myOrders.latestTrack.emptyWithNo') - : t('order.myOrders.latestTrack.empty')); - orderList.value[idx] = { - ...orderList.value[idx], - latestTrack: display, - latestTrackRaw: text, - }; - }), - ); - } - } - const selectedRowCount = ref(0); /** 表格选中行(用于批量操作) */ const selectedOrderRows = ref([]); @@ -694,22 +612,9 @@ if (requestSeq !== listRequestSeq) { return; } - const mapped = (items || []).map((row) => normalizeOrderRow(row)).map((row) => { - const status = resolveOrderStatusCode(row); - const skipTrack = - status === 'draft' || status === 'deleted' || !getOrderTrackNumber(row); - return { - ...row, - latestTrack: skipTrack - ? t('order.myOrders.latestTrack.empty') - : t('order.myOrders.latestTrack.loading'), - latestTrackRaw: '', - }; - }); - orderList.value = mapped; + orderList.value = (items || []).map((row) => normalizeOrderRow(row)); totalCount.value = total; tabCounts.value[status] = total; - void enrichLatestTracks(mapped, requestSeq); } catch (e: any) { if (requestSeq !== listRequestSeq) { return; @@ -1057,6 +962,21 @@ await openDetailWithOptionalFetch(rows[0], { editBasic: true }); }; + const openStockBindModal = () => { + const rows = requireSelectedRows(); + if (!rows.length) return; + if (rows.length > 1) { + Message.warning(t('order.myOrders.stockBind.singleOnly')); + return; + } + const row = rows[0]; + stockBindOrderId.value = Number(getOrderRowId(row)!); + stockBindOrderLabel.value = String( + row?.waybillNo || row?.serviceNo || row?.customerOrderNo || row?.clientNo || '', + ).trim(); + stockBindModalVisible.value = true; + }; + const openProblematicModal = () => { const rows = requireSelectedRows(); if (!rows.length) return; @@ -1123,6 +1043,7 @@ }; const onMoreActionClick = (key: string) => { + if (key === 'stockBind') return openStockBindModal(); if (key === 'createProblematic') return openProblematicModal(); if (key === 'createClaimed') return openClaimedModal(); if (key === 'createTrackOrder') return handleCreateTrackOrder(); @@ -1234,14 +1155,6 @@ : ''; return `${statusText}${handleTagHtml}`; } - if (colKey === 'latestTrack') { - const text = String(rowData?.latestTrack || value || '').trim(); - if (!text) return '--'; - const escaped = escapeHtml(text); - const isLoading = text === t('order.myOrders.latestTrack.loading'); - const color = isLoading ? '#86909c' : '#4e5969'; - return `${escaped}`; - } if (colKey === 'predeclareFailReason') { const reason = rowData?.predeclareFailReason || value || ''; if (!reason) return null; @@ -1397,6 +1310,10 @@