Compare commits
26
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2b5525ce49 | ||
|
|
2c98d121ca | ||
|
|
d1eeaab067 | ||
|
|
3ffa706b89 | ||
|
|
22baa5b5c0 | ||
|
|
9f47b1b276 | ||
|
|
7adb97d145 | ||
|
|
24439b15a3 | ||
|
|
7842791c10 | ||
|
|
78893f1144 | ||
|
|
20858dbe33 | ||
|
|
99922bbc34 | ||
|
|
c38a7384aa | ||
|
|
5594e8fa02 | ||
|
|
f851f5667d | ||
|
|
9b1dec75dd | ||
|
|
b52ad0c3e3 | ||
|
|
64697276ec | ||
|
|
1e26ddad4b | ||
|
|
8abc058a65 | ||
|
|
5036593195 | ||
|
|
de31c14695 | ||
|
|
15b51b6139 | ||
|
|
985cab06b0 | ||
|
|
8b0decbaca | ||
|
|
ffa2b82c73 |
@@ -39,25 +39,25 @@
|
|||||||
|
|
||||||
## 模块快速查询
|
## 模块快速查询
|
||||||
|
|
||||||
退货预报与签收结果:`src/modules/overseas-warehouse/views/ReturnOrdersView.vue`、`api/returnOrders.ts`;菜单仍名为“退货换标”。列表路由 `return-relabel`、独立新建路由 `return-relabel/create` 与详情路由均复用该页面,并分别由 `createPage/detailPage` 明确模式;新建页直接填写海外仓、联系人、客户参考号及 SKU 预报明细,取消或提交后返回列表,不再由 `WarehouseServiceView.vue` 或列表内弹框承载。客户退货库存/箱号共用 `views/ReturnInventoryView.vue`、`api/returnInventory.ts`,`return-cartons` 传 `cartonOnly=true`。Backend 为 Lastleg `returnreceipt/`,退货单签收完成不等于换标或退货出库完成;后续换标、出库须按各自业务状态核对。
|
本表只保留首个入口;完整 API、字段、状态与恢复规则见 [按需业务索引](docs/business-index.md)。从本应用根执行 `rg -n -F '任务词或文件名' docs/business-index.md` 读取命中条款;涉及业务行为变更时必须核对对应细则,纯定位不全文加载。保留所有适用的最近模块指引。
|
||||||
|
|
||||||
先从 `src/modules/registry.ts` 确认模块,再按目标模块的 `routes.ts → views/ → api/、store/、contracts.ts 或 public.ts` 查询。页面是否正式开放以 `routes.ts` 的 `release` 为准,不从任务或进度文档推断。
|
表中路径均相对本应用根目录。模块指引中的后端类名以服务名起算,如 `firstleg/service/X.java` 即 `baiyue-firstleg/firstleg/src/main/java/com/baiyue/firstleg/service/X.java`。
|
||||||
|
|
||||||
| 业务 | 模块入口 | 联查模块或服务端 |
|
| 业务 | 首个入口 |
|
||||||
|---|---|---|
|
|---|---|
|
||||||
| 登录、注册与会话 | `src/modules/auth/`、`src/api/session.ts`、`src/api/http.ts` | Backend `auth/`、`iam/`;正常轮换的统一 Access/Refresh Token 会话持久化,“记住账号”只记登录标识;访问令牌失效但刷新令牌仍在时先恢复会话,公开认证接口不得携带旧 Token |
|
| 登录、注册与会话 | `src/modules/auth/AGENTS.md`、`src/api/session.ts`、`src/api/http.ts` |
|
||||||
| 企业资料、成员与角色 | `src/modules/tenant-management/`、`src/modules/account/` | Backend `iam/`、`auth/`、`file/`;公司联系电话/邮箱是企业资料,不作为登录标识;成员登录手机号可选,修改时同步 Auth、撤销该账号会话并审计。审核必填资质仅营业执照与统一社会信用代码;法人身份证选填,可随营业执照提交,也可在已有营业执照后单独补传或替换。前端角色树到服务端权限的映射统一维护在 `contracts.ts` 的 `FRONTEND_TO_MERCHANT_PERMISSION_CODES`,海外入仓、采购、本土卡车和散板权限必须显式进入该映射 |
|
| 企业资料、成员与角色 | `src/modules/tenant-management/AGENTS.md`、`src/modules/account/AGENTS.md` |
|
||||||
| 工作台与系统入口 | `src/modules/dashboard/`、`src/modules/system/` | `src/navigation/clientNavigation.ts`、`src/router/index.ts` |
|
| 工作台与系统入口 | `src/modules/dashboard/AGENTS.md`、`src/modules/system/AGENTS.md` |
|
||||||
| 企业成员消息收件箱 | `src/modules/notifications/` | Backend `iam/src/main/java/com/baiyue/iam/notification/`;列表、详情、已读与未读数契约见 `iam/src/main/resources/openapi/notification-v1.yaml` |
|
| 企业成员消息收件箱 | `src/modules/notifications/AGENTS.md` |
|
||||||
| 头程下单、中文批量导入、入仓码关系、箱唛、履约进度与入库费用确认 | `src/modules/first-leg/`;列表与批量入口 `views/FirstLegOrdersView.vue`,模板/导入 API `api/firstLeg.ts`,入仓详情 `components/InboundCodeAssociationDialog.vue`、`api/inboundCodeAssociations.ts`,独立计费重弹框 `components/InboundBillingPanel.vue`、`api/inboundBilling.ts` | 中文 XLSX 模板按当前客户生成地址、全部有效仓库和渠道下拉,最多 50 行,只创建草稿并支持部分/原子导入;导入结果只显示 Excel 行号,不展示内部 `clientRowId`。所有订单行均可进入计费重弹框,尚未推送时展示明确空态;只有具备编辑权限且服务端返回当前 `SENT` 费用时才可二次确认并提交 `expectedFeeVersion` 与幂等键,成功后版本锁定、平台不得再修改。Backend `order/`、`firstleg/`、`warehouse/`,不得用内部 ID 补齐缺失业务编号 |
|
| 头程下单、中文批量导入、入仓码关系、箱唛、履约进度与入库费用确认 | `src/modules/first-leg/AGENTS.md` |
|
||||||
| 装柜完成后的退税报关资料 | `src/modules/first-leg/views/FirstLegOrdersView.vue` 的“报关资料”、`components/CustomsDocumentsDialog.vue`、`api/customs.ts` | 只显示登录客户在同柜的退税入仓码;报关开始前可上传、替换、调整同一资料覆盖的一个或多个入仓码及删除误传,全部写入携带幂等键和版本;开始后只读冻结资料,整柜完成后才能下载平台回传的一对一完成文件。Backend `firstleg/customs/container/`、`customs-v1.yaml`,二进制归 `file/` |
|
| 装柜完成后的退税报关资料 | `src/modules/first-leg/AGENTS.md`、`src/modules/first-leg/components/CustomsDocumentsDialog.vue` |
|
||||||
| 统一订单展示 | `src/modules/order-management/` | `src/modules/first-leg/` 与对应后端订单契约 |
|
| 统一订单展示 | `src/modules/order-management/AGENTS.md` |
|
||||||
| 客户财务账单、入仓码联查、收款、未收余额与客户确认 | `src/modules/finance/`;确认与明细入口 `views/FinanceBillsView.vue`、`api/finance.ts`,入仓码通过 `src/modules/first-leg/public.ts` 复用 `InboundCodeAssociationDialog` | Backend `finance/`;账单行只显示服务端 `inboundCode` 并按登录客户查询业务关系,缺失显示“—”,不得回退内部 ID。收款方式由服务端枚举映射中文。出账或已出账调整后为 `PENDING_CONFIRMATION`,客户确认提交登录成员、`expectedVersion` 和幂等键 |
|
| 客户财务账单、入仓码联查、收款、未收余额与客户确认 | `src/modules/finance/AGENTS.md` |
|
||||||
| 客户资金账户、授信与充值申请 | `src/modules/finance/views/FinanceAccountView.vue`、`api/account.ts` | 显示当前企业 CNY 实际余额、冻结金额、授信额度、授信有效期、已用授信、冻结授信、总可用余额和不可变流水;数据加载前显示“—”,不得先伪装为零。授信到期日当天仍有效,次日已用授信并入实际余额,负数实际余额会阻止提交新订单。充值只展示服务端启用的平台统一静态收款码,客户上传 JPG/PNG 付款截图后进入待审核。客户范围只取登录态,无收款码时禁止提交,不模拟支付成功 |
|
| 客户资金账户、授信与充值申请 | `src/modules/finance/AGENTS.md` |
|
||||||
| 海外采购 | `src/modules/cross-border/routes.ts`、`views/ProcurementView.vue`、`components/ProcurementDetailPanel.vue`、`api/procurement.ts` | 独立列表、新建及详情路由;客户范围只取 Token,创建的 `customerName` 只取认证会话企业名称。详情消费独立客户投影,展示履约、已确认箱明细、实际运单和费用结果,不开放内部文件或平台操作。Backend `lastleg-service/procurement/` |
|
| 海外采购 | `src/modules/cross-border/AGENTS.md` |
|
||||||
| 美国本土卡与美本土散板 | `src/modules/cross-border/routes.ts`、`components/BusinessOrdersView.vue`、`api/businessOrders.ts` | 两个运输业务共用列表/表单组件,客户范围只取 Token;不消费采购字段或状态。Backend `lastleg-service/` 的 `trucking/`、`looseboard/` 客户接口 |
|
| 美国本土卡与美本土散板 | `src/modules/cross-border/AGENTS.md` |
|
||||||
| 海外仓入库订单 | `src/modules/order-management/routes.ts`、`views/InboundOrdersView.vue`、`api/inboundPlans.ts` | `orders/inbound` 为只读列表/详情,权限 `merchant:warehouse:inbound:list`;不展示或提交内部 ID |
|
| 海外仓入库订单 | `src/modules/order-management/AGENTS.md` |
|
||||||
| 海外仓贴标、仓储转运、货物废弃 | `src/modules/overseas-warehouse/routes.ts`、`views/WarehouseServiceView.vue`、`api/warehouseServices.ts` | 三个路由均为 `active`;退货预报另见本节独立入口;贴标申请先选国外中转仓和有库存历史入仓单,换标类型为只换 SKU、只换箱唛、SKU+箱唛。涉及箱唛换标时,整张贴标申请只选择一个 FBA 目的仓,全部箱级明细统一提交该目的仓,模板和明细不再逐行选择目的仓。箱唛换标明细一行固定代表一箱,箱数不可编辑,提交也固定为 1。货物明细外层始终提供“SKU 关联”“箱号关联”“SKU 混箱换标”三套模板的下载、上传,不随换标类型切换;上传只进入待导入关系区,客户可勾选部分或全选后导入本次明细,只有进入明细的库存才随申请提交和冻结。明细也支持手动新增编辑,组合换标以仓库唛头连接旧/新 SKU 和新 FBA 箱唛关系。涉及箱唛换标时必须选择卡车、自提或快递;快递可选择打印面单并上传 PDF/图片。PDA 逐箱换标、上传照片并由仓库复核后,客户详情展示完工照片和“换标完成确认”;客户确认前不得继续出库,确认后卡车进入预排车,自提/快递进入换标出库待创建。历史库存位置不能解释成箱唛与具体托盘快照,客户页面不暴露托盘、库位和内部库存 ID |
|
| 海外仓贴标、仓储转运、货物废弃 | `src/modules/overseas-warehouse/AGENTS.md` |
|
||||||
|
|
||||||
## 租户、认证与数据安全
|
## 租户、认证与数据安全
|
||||||
|
|
||||||
@@ -97,8 +97,8 @@ pnpm typecheck
|
|||||||
pnpm build
|
pnpm build
|
||||||
```
|
```
|
||||||
|
|
||||||
- 日常变更至少运行 `pnpm typecheck`;交付前运行 `pnpm build`。
|
- 按 `../../docs/AI工程执行与协作约束.md` 的“验证范围选择”执行;命令表不是每轮清单。文案/纯展示核对差异,小逻辑跑定向测试;类型/签名变化加最小类型检查,公共能力覆盖实际消费者。不因源码修改或交付自动 typecheck、全量测试或构建;构建和全量测试分别说明触发原因,相同编译不重复跑。纯文档/索引只检查路径、链接及索引合同。
|
||||||
- 当前测试使用 Node.js 内置测试运行器,执行 `pnpm test`;项目仍未声明 lint 脚本,不得声称 lint 已通过。
|
- 当前测试使用 Node.js 内置测试运行器,局部改动指定受影响测试文件,`pnpm test` 是全量入口;项目未声明 lint 脚本,不得声称 lint 已通过。
|
||||||
- 不手工修改 `dist/` 或 `node_modules/`;依赖变更必须同步当前项目依赖清单和锁文件。
|
- 不手工修改 `dist/` 或 `node_modules/`;依赖变更必须同步当前项目依赖清单和锁文件。
|
||||||
|
|
||||||
## 全量验收脚本
|
## 全量验收脚本
|
||||||
@@ -110,11 +110,4 @@ pnpm build
|
|||||||
|
|
||||||
## Client 全量验收快速索引
|
## Client 全量验收快速索引
|
||||||
|
|
||||||
当前按客户侧全量业务闭环验收。业务域文档用于核对功能来源和验收证据,不限制本次验收的模块范围;按“模块 `routes.ts` → 页面/组件 → `api`、store、contracts”定位。本表只描述 Client 页面与客户可见契约,服务端实现详见后端模块指引。
|
全量验收的两类客户可见范围按需查 `docs/business-index.md` 同名节;平台/PDA 操作与内部证据不得因此暴露给客户。普通修改保持最小模块范围,不自动加载验收资料。
|
||||||
|
|
||||||
| 验收域 | Client 范围与代码入口 | 验收首读 |
|
|
||||||
|---|---|---|
|
|
||||||
| 客户基础与订单 | 登录/注册、企业资料与资质、成员/角色权限、工作台和订单 | `src/modules/auth/`、`tenant-management/`、`account/`、`system/`、`dashboard/`、`first-leg/`、`order-management/`;按客户可见契约核对权限、状态、幂等和错误处理 |
|
|
||||||
| 履约、海外仓与财务 | 入库计费、柜次进度、船期、海外仓贴标/转运/废弃/退货换标、消息和客户账单 | `src/modules/first-leg/`、`overseas-warehouse/`、`finance/`、`notifications/`;按服务端权限核对客户可见字段、客户隔离和只读/写入边界 |
|
|
||||||
|
|
||||||
客户侧边界:仍以服务端权限和客户可见字段为准;PDA、平台后台操作和内部证据不因全量验收自动暴露到 Client。财务按 `../../docs/财务管理/` 与 `src/modules/finance/routes.ts` 定位。
|
|
||||||
|
|||||||
@@ -0,0 +1,40 @@
|
|||||||
|
# Client业务详细索引
|
||||||
|
|
||||||
|
本文件保存当前页面/API 入口及业务规则,是[应用指引](../AGENTS.md)的按需补充。涉及字段、状态、权限、金额、资源或作业恢复时必须读取受影响条款,不作为普通定位任务的全文首读。
|
||||||
|
|
||||||
|
正文代码路径以工作区 `apps/client-web/` 应用根起算,源码包缩写与裸文件名沿对应条目的目录解释;明确标注“工作区”的路径从工作区根起算。Markdown 相对链接以本文件所在的 `docs/` 为起点。已知文件直接定位;行为变更同时核对最近模块指引及服务端合同。
|
||||||
|
|
||||||
|
原条款在本文件维护,主 AGENTS 仅保留短入口和通用边界;不要将新业务细节复制回主指引。
|
||||||
|
|
||||||
|
## 模块快速查询
|
||||||
|
|
||||||
|
退货预报与签收结果:`src/modules/overseas-warehouse/views/ReturnOrdersView.vue`、`api/returnOrders.ts`;菜单仍名为“退货换标”。列表路由 `return-relabel`、独立新建路由 `return-relabel/create` 与详情路由均复用该页面,并分别由 `createPage/detailPage` 明确模式;新建页直接填写海外仓、联系人、客户参考号及 SKU 预报明细,取消或提交后返回列表,不再由 `WarehouseServiceView.vue` 或列表内弹框承载。客户退货库存/箱号共用 `views/ReturnInventoryView.vue`、`api/returnInventory.ts`,`return-cartons` 传 `cartonOnly=true`。Backend 为 Lastleg `returnreceipt/`,退货单签收完成不等于换标或退货出库完成;后续换标、出库须按各自业务状态核对。
|
||||||
|
|
||||||
|
先从 `src/modules/registry.ts` 确认模块,再按目标模块的 `routes.ts → views/ → api/、store/、contracts.ts 或 public.ts` 查询。页面是否正式开放以 `routes.ts` 的 `release` 为准,不从任务或进度文档推断。
|
||||||
|
|
||||||
|
| 业务 | 模块入口 | 联查模块或服务端 |
|
||||||
|
|---|---|---|
|
||||||
|
| 登录、注册与会话 | `src/modules/auth/`、`src/api/session.ts`、`src/api/http.ts` | Backend `auth/`、`iam/`;正常轮换的统一 Access/Refresh Token 会话持久化,“记住账号”只记登录标识;访问令牌失效但刷新令牌仍在时先恢复会话,公开认证接口不得携带旧 Token |
|
||||||
|
| 企业资料、成员与角色 | `src/modules/tenant-management/`、`src/modules/account/` | Backend `iam/`、`auth/`、`file/`;公司联系电话/邮箱是企业资料,不作为登录标识;成员登录手机号可选,修改时同步 Auth、撤销该账号会话并审计。审核必填资质仅营业执照与统一社会信用代码;法人身份证选填,可随营业执照提交,也可在已有营业执照后单独补传或替换。前端角色树到服务端权限的映射统一维护在 `contracts.ts` 的 `FRONTEND_TO_MERCHANT_PERMISSION_CODES`,海外入仓、采购、本土卡车和散板权限必须显式进入该映射 |
|
||||||
|
| 工作台与系统入口 | `src/modules/dashboard/`、`src/modules/system/` | `src/navigation/clientNavigation.ts`、`src/router/index.ts` |
|
||||||
|
| 企业成员消息收件箱 | `src/modules/notifications/` | Backend `iam/src/main/java/com/baiyue/iam/notification/`;列表、详情、已读与未读数契约见 `iam/src/main/resources/openapi/notification-v1.yaml` |
|
||||||
|
| 头程下单、中文批量导入、入仓码关系、箱唛、履约进度与入库费用确认 | `src/modules/first-leg/`;列表与批量入口 `views/FirstLegOrdersView.vue`,模板/导入 API `api/firstLeg.ts`,入仓详情 `components/InboundCodeAssociationDialog.vue`、`api/inboundCodeAssociations.ts`,费用确认弹框 `components/InboundBillingPanel.vue`、`api/inboundBilling.ts` | 中文 XLSX 模板按当前客户生成地址、全部有效仓库和渠道下拉,最多 50 行,只创建草稿并支持部分/原子导入;导入结果只显示 Excel 行号,不展示内部 `clientRowId`。列表“确认计费重”仅在具备确认权限且服务端 `customerFeeConfirmationRequired=true` 时显示,已确认或未推送费用时隐藏;详情可查看费用;确认提交 `expectedFeeVersion` 与幂等键,成功后版本锁定、平台不得再修改。Backend `order/`、`firstleg/`、`warehouse/`,不得用内部 ID 补齐缺失业务编号 |
|
||||||
|
| 装柜完成后的退税报关资料 | `src/modules/first-leg/views/FirstLegOrdersView.vue` 的“报关资料”、`components/CustomsDocumentsDialog.vue`、`api/customs.ts` | 只显示登录客户在同柜的退税入仓码;报关开始前可上传、替换、调整同一资料覆盖的一个或多个入仓码及删除误传,全部写入携带幂等键和版本;开始后只读冻结资料,整柜完成后才能下载平台回传的一对一完成文件。Backend `firstleg/customs/container/`、`customs-v1.yaml`,二进制归 `file/` |
|
||||||
|
| 统一订单展示 | `src/modules/order-management/` | `src/modules/first-leg/` 与对应后端订单契约 |
|
||||||
|
| 客户财务账单、入仓码联查、收款、未收余额与客户确认 | `src/modules/finance/`;确认与明细入口 `views/FinanceBillsView.vue`、`api/finance.ts`,入仓码通过 `src/modules/first-leg/public.ts` 复用 `InboundCodeAssociationDialog` | Backend `finance/`;账单行只显示服务端 `inboundCode` 并按登录客户查询业务关系,缺失显示“—”,不得回退内部 ID。收款方式由服务端枚举映射中文。出账或已出账调整后为 `PENDING_CONFIRMATION`,客户确认提交登录成员、`expectedVersion` 和幂等键 |
|
||||||
|
| 客户资金账户、授信与充值申请 | `src/modules/finance/views/FinanceAccountView.vue`、`api/account.ts` | 显示当前企业 CNY 实际余额、冻结金额、授信额度、授信有效期、已用授信、冻结授信、总可用余额和不可变流水;数据加载前显示“—”,不得先伪装为零。授信到期日当天仍有效,次日已用授信并入实际余额,负数实际余额会阻止提交新订单。充值只展示服务端启用的平台统一静态收款码,客户上传 JPG/PNG 付款截图后进入待审核。客户范围只取登录态,无收款码时禁止提交,不模拟支付成功 |
|
||||||
|
| 海外采购 | `src/modules/cross-border/routes.ts`、`views/ProcurementView.vue`、`components/ProcurementDetailPanel.vue`、`api/procurement.ts` | 独立列表、新建及详情路由;客户范围只取 Token,创建的 `customerName` 只取认证会话企业名称。详情消费独立客户投影,展示履约、已确认箱明细、实际运单和费用结果,不开放内部文件或平台操作。Backend `lastleg-service/procurement/` |
|
||||||
|
| 美国本土卡与美本土散板 | `src/modules/cross-border/routes.ts`、`components/BusinessOrdersView.vue`、`api/businessOrders.ts` | 两个运输业务共用列表/表单组件,客户范围只取 Token;不消费采购字段或状态。Backend `lastleg-service/` 的 `trucking/`、`looseboard/` 客户接口 |
|
||||||
|
| 海外仓入库订单 | `src/modules/order-management/routes.ts`、`views/InboundOrdersView.vue`、`api/inboundPlans.ts` | `orders/inbound` 为只读列表/详情,权限 `merchant:warehouse:inbound:list`;不展示或提交内部 ID |
|
||||||
|
| 海外仓贴标、仓储转运、货物废弃 | `src/modules/overseas-warehouse/routes.ts`、`views/WarehouseServiceView.vue`、`api/warehouseServices.ts` | 三个路由均为 `active`;退货预报另见本节独立入口;贴标申请先选国外中转仓和有库存历史入仓单,换标类型为只换 SKU、只换箱唛、SKU+箱唛。涉及箱唛换标时,整张贴标申请只选择一个 FBA 目的仓,全部箱级明细统一提交该目的仓,模板和明细不再逐行选择目的仓。箱唛换标明细一行固定代表一箱,箱数不可编辑,提交也固定为 1。货物明细外层始终提供“SKU 关联”“箱号关联”“SKU 混箱换标”三套模板的下载、上传,不随换标类型切换;上传只进入待导入关系区,客户可勾选部分或全选后导入本次明细,只有进入明细的库存才随申请提交和冻结。明细也支持手动新增编辑,组合换标以仓库唛头连接旧/新 SKU 和新 FBA 箱唛关系。涉及箱唛换标时必须选择卡车、自提或快递;快递可选择打印面单并上传 PDF/图片。PDA 逐箱换标、上传照片并由仓库复核后,客户详情展示完工照片和“换标完成确认”;客户确认前不得继续出库,确认后卡车进入预排车,自提/快递进入换标出库待创建。历史库存位置不能解释成箱唛与具体托盘快照,客户页面不暴露托盘、库位和内部库存 ID |
|
||||||
|
|
||||||
|
## Client 全量验收快速索引
|
||||||
|
|
||||||
|
当前按客户侧全量业务闭环验收。业务域文档用于核对功能来源和验收证据,不限制本次验收的模块范围;按“模块 `routes.ts` → 页面/组件 → `api`、store、contracts”定位。本表只描述 Client 页面与客户可见契约,服务端实现详见后端模块指引。
|
||||||
|
|
||||||
|
| 验收域 | Client 范围与代码入口 | 验收首读 |
|
||||||
|
|---|---|---|
|
||||||
|
| 客户基础与订单 | 登录/注册、企业资料与资质、成员/角色权限、工作台和订单 | `src/modules/auth/`、`tenant-management/`、`account/`、`system/`、`dashboard/`、`first-leg/`、`order-management/`;按客户可见契约核对权限、状态、幂等和错误处理 |
|
||||||
|
| 履约、海外仓与财务 | 入库计费、柜次进度、船期、海外仓贴标/转运/废弃/退货换标、消息和客户账单 | `src/modules/first-leg/`、`overseas-warehouse/`、`finance/`、`notifications/`;按服务端权限核对客户可见字段、客户隔离和只读/写入边界 |
|
||||||
|
|
||||||
|
客户侧边界:仍以服务端权限和客户可见字段为准;PDA、平台后台操作和内部证据不因全量验收自动暴露到 Client。财务按 `../../docs/财务管理/` 与 `src/modules/finance/routes.ts` 定位。
|
||||||
@@ -0,0 +1,26 @@
|
|||||||
|
# Client 个人资料模块指引
|
||||||
|
|
||||||
|
## 路径基准与读取顺序
|
||||||
|
|
||||||
|
- 本文件适用于 `src/modules/account/`,代码路径相对本目录;应用公共规则见 `../../../AGENTS.md`。
|
||||||
|
- 只有 `views/AccountProfileView.vue`、`utils/accountProfile.ts`;路由 `account/profile`。
|
||||||
|
- 后端:个人资料归 `iam/`(`PersonalProfileService.java`),登录手机号变更经 `auth/` 同步并撤销会话。
|
||||||
|
|
||||||
|
## 页面与入口
|
||||||
|
|
||||||
|
| 目标 | 页面/路由 | API 与后端 |
|
||||||
|
|---|---|---|
|
||||||
|
| 个人资料查看与修改 | `views/AccountProfileView.vue`;`account/profile` | `../tenant-management/api/merchantIam.ts`;`iam/` |
|
||||||
|
| 表单校验与展示映射 | `utils/accountProfile.ts` | 服务端字段 |
|
||||||
|
|
||||||
|
## 关键边界
|
||||||
|
|
||||||
|
- 个人资料只改本人信息;企业资料(含 `contactPhone`)归 `../tenant-management/`,两处不互相回填。
|
||||||
|
- 登录手机号修改由 IAM/Auth 处理并撤销该账号现有会话,前端不自行清理 Token。
|
||||||
|
- 敏感字段(证件号、密码)不在页面持久化,也不写入日志或快照。
|
||||||
|
- 保存需要明确成功/失败反馈,失败保留已填内容。
|
||||||
|
|
||||||
|
## 验证
|
||||||
|
|
||||||
|
- 定向:`pnpm test src/modules/account/<目标测试>`。
|
||||||
|
- 本文件或索引变更后,从后端根运行 `./scripts/agents-index-contract.ps1`。
|
||||||
@@ -0,0 +1,30 @@
|
|||||||
|
# Client 登录与注册模块指引
|
||||||
|
|
||||||
|
## 路径基准与读取顺序
|
||||||
|
|
||||||
|
- 本文件适用于 `src/modules/auth/`,代码路径相对本目录;应用公共规则见 `../../../AGENTS.md`。
|
||||||
|
- 页面:`views/LoginView.vue`、`views/RegisterView.vue`、`views/LegalDocumentView.vue`(`/login`、`/register`、`/legal/*`);会话状态在 `store/auth.ts`,请求在 `api/auth.ts`。
|
||||||
|
- 后端:登录与 Token 归 `auth/`,注册与资质归 `iam/` + `file/`。
|
||||||
|
|
||||||
|
## 页面与入口
|
||||||
|
|
||||||
|
| 目标 | 页面/入口 | API 与后端 |
|
||||||
|
|---|---|---|
|
||||||
|
| 登录、记住账号 | `views/LoginView.vue` | `api/auth.ts`、`store/auth.ts`;`auth/` |
|
||||||
|
| 企业注册与资质上传 | `views/RegisterView.vue` | `api/auth.ts`;`iam/`、`file/` |
|
||||||
|
| 用户协议与隐私政策 | `views/LegalDocumentView.vue`、`legalDocuments.ts` | 静态文案 |
|
||||||
|
| 认证壳层与布局 | `components/AuthShell.vue` | — |
|
||||||
|
| 令牌解析与刷新 | `store/auth.ts`、`utils/jwt.ts` | `../../api/http.ts`、`../../api/session.ts` |
|
||||||
|
|
||||||
|
## 关键边界
|
||||||
|
|
||||||
|
- 页面不拼 `Authorization`、不自行持久化密码;Access/Refresh Token 只在 `store/auth.ts` 与 `src/api/session.ts` 编排。
|
||||||
|
- 注册时登录手机号同时初始化公司联系电话,注册完成后两者独立维护;企业资料只改 `contactPhone`。
|
||||||
|
- “记住账号”只保存登录 ID,不改变 Token 的持久化与续期策略。
|
||||||
|
- 注册必填资质仅营业执照与统一社会信用代码,法人身份证选填;上传成功不等于审核通过。
|
||||||
|
- 并发或跨标签页 401 共用一次刷新,每个原请求最多重放一次。
|
||||||
|
|
||||||
|
## 验证
|
||||||
|
|
||||||
|
- 定向:`pnpm test src/modules/auth/<目标测试>`;登录或注册字段变化同时核对 `auth/`、`iam/` 合同。
|
||||||
|
- 本文件或索引变更后,从后端根运行 `./scripts/agents-index-contract.ps1`。
|
||||||
@@ -0,0 +1,30 @@
|
|||||||
|
# Client 跨境业务模块指引
|
||||||
|
|
||||||
|
## 路径基准与读取顺序
|
||||||
|
|
||||||
|
- 本文件适用于 `src/modules/cross-border/`,代码路径相对本目录;应用公共规则见 `../../../AGENTS.md`,业务细则见 `../../../docs/business-index.md`。
|
||||||
|
- 三条业务线共用本模块:`procurement`(海外采购)、`domestic-trucking`(本土卡车)、`pallet-shipping`(美本土散板);每条都是独立列表 + 建单 + 详情路由。
|
||||||
|
- 后端只查 `lastleg-service/` 的 `procurement/`、`trucking/`、`looseboard/`;纯页面与文案不读后端。
|
||||||
|
|
||||||
|
## 页面与入口
|
||||||
|
|
||||||
|
| 目标 | 页面/路由 | API 与后端 |
|
||||||
|
|---|---|---|
|
||||||
|
| 海外采购列表、建单与详情 | `views/ProcurementView.vue`、`components/ProcurementDetailPanel.vue`;`cross-border/procurement`、`.../create`、`.../:orderNo/detail` | `api/procurement.ts`、`procurementSubmission.ts`、`procurementPresentation.ts`;`lastleg-service/procurement/` |
|
||||||
|
| 本土卡车列表、建单与详情 | `views/DomesticTruckingView.vue`、`components/TransportDemandForm.vue`;`cross-border/domestic-trucking`、`.../create`、`.../:orderNo/detail` | `api/businessOrders.ts`、`transportDemandForm.ts`;`lastleg-service/trucking/` |
|
||||||
|
| 美本土散板列表、建单与详情 | `views/PalletShippingView.vue`;`cross-border/pallet-shipping`、`.../create`、`.../:orderNo/detail` | `api/businessOrders.ts`;`lastleg-service/looseboard/` |
|
||||||
|
| 通用业务单展示与车次安排 | `components/BusinessOrdersView.vue`、`fleetArrangement.ts` | `api/businessOrders.ts`;`lastleg-service/fleet/trip/` |
|
||||||
|
| 柜型与规格换算 | `containerSpecifications.ts` | 本地换算,服务端复核 |
|
||||||
|
|
||||||
|
## 关键边界
|
||||||
|
|
||||||
|
- 三条线都是客户自助下单,提交后由平台审核;客户侧不提供审核、改价或内部作业动作。
|
||||||
|
- 客户与仓库范围只取服务端当前租户上下文,不从前端参数推断;跨客户查询一律拒绝。
|
||||||
|
- 提交需要幂等键、提交中状态与可恢复失败反馈;失败保留已填内容。
|
||||||
|
- 海外采购的购买、装箱、面单、交寄与国内核费是一条独立链路,改节点前先读 `docs/海外仓业务/采购订单样品履约流程变更需求.md`(工作区路径)。
|
||||||
|
- 页面承载方式按已确认原型:列表 + 独立建单/详情路由,不改为弹框或抽屉。
|
||||||
|
|
||||||
|
## 验证
|
||||||
|
|
||||||
|
- 定向:`pnpm test src/modules/cross-border/<目标测试>`;接口或类型变化同时运行 `pnpm typecheck`。
|
||||||
|
- 本文件或索引变更后,从后端根运行 `./scripts/agents-index-contract.ps1`。
|
||||||
@@ -274,7 +274,7 @@ onMounted(() => { if (props.detailPage) void loadDetail(); else if (!props.creat
|
|||||||
<header v-if="mode === 'create'" class="page-head" :class="{ 'looseboard-page-head': props.kind === 'looseboard' }">
|
<header v-if="mode === 'create'" class="page-head" :class="{ 'looseboard-page-head': props.kind === 'looseboard' }">
|
||||||
<div>
|
<div>
|
||||||
<h2>{{ configuration.title }}下单</h2>
|
<h2>{{ configuration.title }}下单</h2>
|
||||||
<p>请填写订单信息,带 * 项为必填项</p>
|
|
||||||
</div>
|
</div>
|
||||||
<el-button @click="returnToList">返回列表</el-button>
|
<el-button @click="returnToList">返回列表</el-button>
|
||||||
</header>
|
</header>
|
||||||
|
|||||||
@@ -60,7 +60,7 @@ const hasPending = computed(() => props.detail.fees.some(f => f.walletStatus?.en
|
|||||||
<el-table-column prop="trackingNo" label="运单号" min-width="230" />
|
<el-table-column prop="trackingNo" label="运单号" min-width="230" />
|
||||||
<el-table-column label="实际交寄时间" width="185"><template #default="{ row }">{{ dateTime(row.shippedAt) }}</template></el-table-column>
|
<el-table-column label="实际交寄时间" width="185"><template #default="{ row }">{{ dateTime(row.shippedAt) }}</template></el-table-column>
|
||||||
</el-table>
|
</el-table>
|
||||||
<p class="procurement-note">这里显示已实际交给承运方的记录;国内寄客户后,本单履约完成。</p>
|
|
||||||
</section>
|
</section>
|
||||||
<section class="procurement-section" aria-label="采购费用与资金结果">
|
<section class="procurement-section" aria-label="采购费用与资金结果">
|
||||||
<h3>费用与资金结果</h3>
|
<h3>费用与资金结果</h3>
|
||||||
|
|||||||
@@ -27,14 +27,14 @@ defineExpose({
|
|||||||
<h3>运输信息</h3>
|
<h3>运输信息</h3>
|
||||||
<div class="transport-demand-grid">
|
<div class="transport-demand-grid">
|
||||||
<el-form-item v-if="kind === 'truck'" class="transport-demand-wide" label="车辆类型" prop="vehicleType">
|
<el-form-item v-if="kind === 'truck'" class="transport-demand-wide" label="车辆类型" prop="vehicleType">
|
||||||
<el-select v-model="model.vehicleType" placeholder="请选择车辆类型"><el-option label="15拖" value="PALLET_15" /><el-option label="30拖" value="PALLET_30" /></el-select>
|
<el-select v-model="model.vehicleType" placeholder=""><el-option label="15拖" value="PALLET_15" /><el-option label="30拖" value="PALLET_30" /></el-select>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="起运地" prop="origin"><el-input v-model.trim="model.origin" maxlength="255" placeholder="城市 / 港口 / 州" /></el-form-item>
|
<el-form-item label="起运地" prop="origin"><el-input v-model.trim="model.origin" maxlength="255" placeholder="城市 / 港口 / 州" /></el-form-item>
|
||||||
<el-form-item label="目的地" prop="destination"><el-input v-model.trim="model.destination" maxlength="255" placeholder="城市 / 州" /></el-form-item>
|
<el-form-item label="目的地" prop="destination"><el-input v-model.trim="model.destination" maxlength="255" placeholder="城市 / 州" /></el-form-item>
|
||||||
<el-form-item label="起运地联系人" prop="originContactName"><el-input v-model.trim="model.originContactName" maxlength="128" placeholder="请输入起运地联系人" /></el-form-item>
|
<el-form-item label="起运地联系人" prop="originContactName"><el-input v-model.trim="model.originContactName" maxlength="128" placeholder="" /></el-form-item>
|
||||||
<el-form-item label="目的地联系人" prop="destinationContactName"><el-input v-model.trim="model.destinationContactName" maxlength="128" placeholder="请输入目的地联系人" /></el-form-item>
|
<el-form-item label="目的地联系人" prop="destinationContactName"><el-input v-model.trim="model.destinationContactName" maxlength="128" placeholder="" /></el-form-item>
|
||||||
<el-form-item label="起运地联系电话" prop="originContactPhone"><el-input v-model.trim="model.originContactPhone" type="tel" maxlength="128" placeholder="请输入起运地联系电话" /></el-form-item>
|
<el-form-item label="起运地联系电话" prop="originContactPhone"><el-input v-model.trim="model.originContactPhone" type="tel" maxlength="128" placeholder="" /></el-form-item>
|
||||||
<el-form-item label="目的地联系电话" prop="destinationContactPhone"><el-input v-model.trim="model.destinationContactPhone" type="tel" maxlength="128" placeholder="请输入目的地联系电话" /></el-form-item>
|
<el-form-item label="目的地联系电话" prop="destinationContactPhone"><el-input v-model.trim="model.destinationContactPhone" type="tel" maxlength="128" placeholder="" /></el-form-item>
|
||||||
<el-form-item label="起运详细地址"><el-input v-model.trim="model.originAddress" maxlength="500" placeholder="街道 / 门牌等补充信息(选填)" /></el-form-item>
|
<el-form-item label="起运详细地址"><el-input v-model.trim="model.originAddress" maxlength="500" placeholder="街道 / 门牌等补充信息(选填)" /></el-form-item>
|
||||||
<el-form-item label="目的详细地址"><el-input v-model.trim="model.destinationAddress" maxlength="500" placeholder="街道 / 门牌等补充信息(选填)" /></el-form-item>
|
<el-form-item label="目的详细地址"><el-input v-model.trim="model.destinationAddress" maxlength="500" placeholder="街道 / 门牌等补充信息(选填)" /></el-form-item>
|
||||||
</div>
|
</div>
|
||||||
@@ -42,25 +42,25 @@ defineExpose({
|
|||||||
<section class="transport-demand-section">
|
<section class="transport-demand-section">
|
||||||
<h3>货物信息</h3>
|
<h3>货物信息</h3>
|
||||||
<div class="transport-demand-grid" :class="kind === 'looseboard' ? 'transport-demand-cargo-four' : 'transport-demand-cargo-three'">
|
<div class="transport-demand-grid" :class="kind === 'looseboard' ? 'transport-demand-cargo-four' : 'transport-demand-cargo-three'">
|
||||||
<el-form-item v-if="kind === 'looseboard'" label="商品名称"><el-input v-model.trim="model.productName" maxlength="255" placeholder="请输入商品名称(选填)" /></el-form-item>
|
<el-form-item v-if="kind === 'looseboard'" label="商品名称"><el-input v-model.trim="model.productName" maxlength="255" placeholder="" /></el-form-item>
|
||||||
<el-form-item v-if="kind === 'looseboard'" label="预计托数" prop="estimatedPalletCount"><el-input-number v-model="model.estimatedPalletCount" :min="0" :precision="0" controls-position="right" placeholder="请输入预计托数" /></el-form-item>
|
<el-form-item v-if="kind === 'looseboard'" label="预计托数" prop="estimatedPalletCount"><el-input-number v-model="model.estimatedPalletCount" :min="0" :precision="0" controls-position="right" placeholder="" /></el-form-item>
|
||||||
<el-form-item v-if="kind === 'truck'" label="件数" prop="packageCount"><el-input-number v-model="model.packageCount" :min="0" :precision="0" controls-position="right" placeholder="请输入件数" /></el-form-item>
|
<el-form-item v-if="kind === 'truck'" label="件数" prop="packageCount"><el-input-number v-model="model.packageCount" :min="0" :precision="0" controls-position="right" placeholder="" /></el-form-item>
|
||||||
<el-form-item label="总重量 (kg)" prop="totalWeightKg"><el-input-number v-model="model.totalWeightKg" :min="0" :precision="3" controls-position="right" placeholder="请输入总重量" /></el-form-item>
|
<el-form-item label="总重量 (kg)" prop="totalWeightKg"><el-input-number v-model="model.totalWeightKg" :min="0" :precision="3" controls-position="right" placeholder="" /></el-form-item>
|
||||||
<el-form-item label="总体积 (m³)" prop="totalVolumeCbm"><el-input-number v-model="model.totalVolumeCbm" :min="0" :precision="6" controls-position="right" placeholder="请输入总体积" /></el-form-item>
|
<el-form-item label="总体积 (m³)" prop="totalVolumeCbm"><el-input-number v-model="model.totalVolumeCbm" :min="0" :precision="6" controls-position="right" placeholder="" /></el-form-item>
|
||||||
<el-form-item v-if="kind === 'looseboard'" label="件数" prop="packageCount"><el-input-number v-model="model.packageCount" :min="0" :precision="0" controls-position="right" placeholder="请输入件数" /></el-form-item>
|
<el-form-item v-if="kind === 'looseboard'" label="件数" prop="packageCount"><el-input-number v-model="model.packageCount" :min="0" :precision="0" controls-position="right" placeholder="" /></el-form-item>
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
<section class="transport-demand-section">
|
<section class="transport-demand-section">
|
||||||
<h3>费用与时效</h3>
|
<h3>费用与时效</h3>
|
||||||
<div class="transport-demand-grid">
|
<div class="transport-demand-grid">
|
||||||
<el-form-item label="预算总价" prop="budgetAmount"><div class="transport-demand-budget">
|
<el-form-item label="预算总价" prop="budgetAmount"><div class="transport-demand-budget">
|
||||||
<el-input-number v-model="model.budgetAmount" :min="0" :precision="2" controls-position="right" placeholder="请输入预算总价(选填)" />
|
<el-input-number v-model="model.budgetAmount" :min="0" :precision="2" controls-position="right" placeholder="" />
|
||||||
<el-select v-model="model.currency" aria-label="预算币种" placeholder="请选择预算币种"><el-option label="USD" value="USD" /><el-option label="CNY" value="CNY" /></el-select>
|
<el-select v-model="model.currency" aria-label="预算币种" placeholder=""><el-option label="USD" value="USD" /><el-option label="CNY" value="CNY" /></el-select>
|
||||||
</div></el-form-item>
|
</div></el-form-item>
|
||||||
<div />
|
<div />
|
||||||
<el-form-item label="取货时间" prop="pickupAt"><el-date-picker v-model="model.pickupAt" type="datetime" format="YYYY-MM-DD HH:mm" time-format="HH:mm" value-format="YYYY-MM-DDTHH:mm:ss" placeholder="请选择取货日期和时间" @change="formRef?.validateField('deliveryAt').catch(() => undefined)" /></el-form-item>
|
<el-form-item label="取货时间" prop="pickupAt"><el-date-picker v-model="model.pickupAt" type="datetime" format="YYYY-MM-DD HH:mm" time-format="HH:mm" value-format="YYYY-MM-DDTHH:mm:ss" placeholder="" @change="formRef?.validateField('deliveryAt').catch(() => undefined)" /></el-form-item>
|
||||||
<el-form-item label="送货时间" prop="deliveryAt"><el-date-picker v-model="model.deliveryAt" type="datetime" format="YYYY-MM-DD HH:mm" time-format="HH:mm" value-format="YYYY-MM-DDTHH:mm:ss" placeholder="请选择送货日期和时间" /></el-form-item>
|
<el-form-item label="送货时间" prop="deliveryAt"><el-date-picker v-model="model.deliveryAt" type="datetime" format="YYYY-MM-DD HH:mm" time-format="HH:mm" value-format="YYYY-MM-DDTHH:mm:ss" placeholder="" /></el-form-item>
|
||||||
<el-form-item class="transport-demand-wide" label="备注"><el-input v-model="model.remark" type="textarea" :rows="3" maxlength="1000" show-word-limit placeholder="请输入其他要求(选填)" /></el-form-item>
|
<el-form-item class="transport-demand-wide" label="备注"><el-input v-model="model.remark" type="textarea" :rows="3" maxlength="1000" show-word-limit placeholder="" /></el-form-item>
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
<footer class="transport-demand-actions">
|
<footer class="transport-demand-actions">
|
||||||
|
|||||||
@@ -54,16 +54,8 @@ test('successful net debit excludes the original estimate and counts only succes
|
|||||||
assert.equal(presentation.feeStatus(fee('DUTY', null, 100)), '待核定')
|
assert.equal(presentation.feeStatus(fee('DUTY', null, 100)), '待核定')
|
||||||
})
|
})
|
||||||
|
|
||||||
test('request recovery preserves content and identity while malformed recovery cannot create a replacement', () => {
|
test('new requests get unique keys without restoring stored submissions', () => {
|
||||||
const original = presentation.buildProcurementCreate(draft(), 'Company', 'fixed-key')
|
assert.notEqual(submission.procurementRequestKey(crypto), submission.procurementRequestKey(crypto))
|
||||||
assert.deepEqual(normalized(submission.restoreProcurementSubmission(JSON.stringify(original))), normalized(original))
|
|
||||||
assert.throws(() => submission.restoreProcurementSubmission('{}'))
|
|
||||||
assert.throws(() => submission.restoreProcurementSubmission(JSON.stringify({ ...original, currency: 'EUR' })))
|
|
||||||
assert.equal(submission.definitelyRejected({ code: 'TIMEOUT' }), false)
|
|
||||||
assert.equal(submission.definitelyRejected({ status: 500 }), false)
|
|
||||||
assert.equal(submission.definitelyRejected({ status: 409 }), false)
|
|
||||||
assert.equal(submission.definitelyRejected({ status: 400 }), true)
|
|
||||||
assert.equal(submission.procurementRequestKey({ getRandomValues: target => { target.set([1, 2, 3, 4]); return target } }), 'proc-00000001000000020000000300000004')
|
|
||||||
})
|
})
|
||||||
|
|
||||||
class ApiError extends Error { constructor(message, code, status) { super(message); this.code = code; this.status = status } }
|
class ApiError extends Error { constructor(message, code, status) { super(message); this.code = code; this.status = status } }
|
||||||
@@ -109,18 +101,16 @@ test('detail has one in-flight request and an older response cannot overwrite an
|
|||||||
} finally { harness.dispose() }
|
} finally { harness.dispose() }
|
||||||
})
|
})
|
||||||
|
|
||||||
test('timeout retries the exact original body after reload and does not accept changed form data', async () => {
|
test('timeout releases the form and another click submits the edited current values', async () => {
|
||||||
const storage = new Map(), calls = []
|
const calls = []
|
||||||
const first = viewHarness({ createPage: true, storage, api: { createProcurement: async payload => { calls.push(normalized(payload)); throw new ApiError('timeout', 'TIMEOUT') } } })
|
const harness = viewHarness({ createPage: true, api: { createProcurement: async payload => { calls.push(normalized(payload)); throw new ApiError('timeout', 'TIMEOUT') } } })
|
||||||
try {
|
try {
|
||||||
Object.assign(first.state.form, draft()); await first.state.submit(); assert.equal(calls.length, 1); assert.ok(first.state.pending.value)
|
Object.assign(harness.state.form, draft()); await harness.state.submit()
|
||||||
first.state.form.productName = 'changed'; await first.state.submit(); assert.deepEqual(calls[1], calls[0])
|
assert.equal(harness.state.submitting.value, false); assert.equal(harness.storage.size, 0)
|
||||||
} finally { first.dispose() }
|
harness.state.form.productName = 'changed'; await harness.state.submit()
|
||||||
const recovered = viewHarness({ createPage: true, storage, api: { createProcurement: async payload => { calls.push(normalized(payload)); return { order: { orderNo: 'PO-SAME' } } } } })
|
assert.equal(calls[1].productName, 'changed'); assert.notEqual(calls[0].idempotencyKey, calls[1].idempotencyKey)
|
||||||
try {
|
assert.equal(harness.state.submitting.value, false)
|
||||||
assert.equal(recovered.state.form.productName, 'Test product'); await recovered.state.submit(); assert.deepEqual(calls[2], calls[0])
|
} finally { harness.dispose() }
|
||||||
assert.equal(storage.size, 0); assert.equal(recovered.pushes[0].params.orderNo, 'PO-SAME')
|
|
||||||
} finally { recovered.dispose() }
|
|
||||||
})
|
})
|
||||||
|
|
||||||
test('submission double-click sends once and definitive validation rejection permits correction', async () => {
|
test('submission double-click sends once and definitive validation rejection permits correction', async () => {
|
||||||
@@ -129,7 +119,7 @@ test('submission double-click sends once and definitive validation rejection per
|
|||||||
try {
|
try {
|
||||||
Object.assign(harness.state.form, draft()); const first = harness.state.submit(); await harness.state.submit(); assert.equal(calls, 1)
|
Object.assign(harness.state.form, draft()); const first = harness.state.submit(); await harness.state.submit(); assert.equal(calls, 1)
|
||||||
reject(new ApiError('invalid', 'A0422')); await first
|
reject(new ApiError('invalid', 'A0422')); await first
|
||||||
assert.equal(harness.state.pending.value, null); assert.equal(harness.storage.size, 0)
|
assert.equal(harness.state.submitting.value, false); assert.equal(harness.storage.size, 0)
|
||||||
} finally { harness.dispose() }
|
} finally { harness.dispose() }
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -149,17 +139,18 @@ test('pagination batches one request and switching account clears old rows befor
|
|||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
test('replay rejection cannot discard an earlier unknown creation outcome', async () => {
|
test('consecutive timeout and permission failures never persist or freeze a submission', async () => {
|
||||||
const calls = []; let attempt = 0
|
let attempt = 0
|
||||||
const harness = viewHarness({ createPage: true, api: { createProcurement: async payload => {
|
const harness = viewHarness({ createPage: true, api: { createProcurement: async () => { throw new ApiError('failed', ++attempt === 1 ? 'TIMEOUT' : 'A0403') } } })
|
||||||
calls.push(normalized(payload)); attempt++
|
|
||||||
if (attempt === 1) throw new ApiError('timeout', 'TIMEOUT')
|
|
||||||
throw new ApiError('permission revoked', 'A0403')
|
|
||||||
} } })
|
|
||||||
try {
|
try {
|
||||||
Object.assign(harness.state.form, draft()); await harness.state.submit()
|
Object.assign(harness.state.form, draft()); await harness.state.submit(); await harness.state.submit()
|
||||||
const saved = [...harness.storage.values()][0]; await harness.state.submit()
|
assert.equal(attempt, 2); assert.equal(harness.state.submitting.value, false); assert.equal(harness.storage.size, 0)
|
||||||
assert.equal([...harness.storage.values()][0], saved); assert.ok(harness.state.pending.value)
|
harness.state.form.productName = 'editable'; assert.equal(harness.state.form.productName, 'editable')
|
||||||
assert.deepEqual(calls[1], calls[0])
|
|
||||||
} finally { harness.dispose() }
|
} finally { harness.dispose() }
|
||||||
})
|
})
|
||||||
|
|
||||||
|
test('purchase category is optional while its length remains bounded', () => {
|
||||||
|
const payload = presentation.buildProcurementCreate({ ...draft(), purchaseCategory: ' ' }, 'Company', 'key')
|
||||||
|
assert.equal(payload.purchaseCategory, '')
|
||||||
|
assert.throws(() => presentation.buildProcurementCreate({ ...draft(), purchaseCategory: 'x'.repeat(129) }, 'Company', 'key'), /品类/)
|
||||||
|
})
|
||||||
|
|||||||
@@ -101,11 +101,12 @@ export function draftBudgetTotal(draft: ProcurementDraft) {
|
|||||||
}
|
}
|
||||||
export function buildProcurementCreate(draft: ProcurementDraft, customerName: string, key: string): ProcurementCreate {
|
export function buildProcurementCreate(draft: ProcurementDraft, customerName: string, key: string): ProcurementCreate {
|
||||||
for (const [field, label, max] of [
|
for (const [field, label, max] of [
|
||||||
['purchaseCategory', '采购品类', 128], ['productName', '商品名称', 255], ['receivingAddress', '完整国内收货地址', 1000],
|
['productName', '商品名称', 255], ['receivingAddress', '完整国内收货地址', 1000],
|
||||||
['contactName', '最终收件人', 128], ['contactPhone', '联系电话', 64],
|
['contactName', '最终收件人', 128], ['contactPhone', '联系电话', 64],
|
||||||
] as const) {
|
] as const) {
|
||||||
if (!draft[field].trim() || draft[field].trim().length > max) throw new Error(`请填写有效的${label}`)
|
if (!draft[field].trim() || draft[field].trim().length > max) throw new Error(`请填写有效的${label}`)
|
||||||
}
|
}
|
||||||
|
if (draft.purchaseCategory.trim().length > 128) throw new Error('采购品类超过长度限制')
|
||||||
if (!customerName.trim()) throw new Error('当前企业信息尚未加载,请刷新登录信息后重试')
|
if (!customerName.trim()) throw new Error('当前企业信息尚未加载,请刷新登录信息后重试')
|
||||||
if (!/^\d+$/.test(draft.purchaseQuantity) || !Number.isSafeInteger(Number(draft.purchaseQuantity)) || Number(draft.purchaseQuantity) <= 0) throw new Error('采购数量必须为正整数')
|
if (!/^\d+$/.test(draft.purchaseQuantity) || !Number.isSafeInteger(Number(draft.purchaseQuantity)) || Number(draft.purchaseQuantity) <= 0) throw new Error('采购数量必须为正整数')
|
||||||
const price = cents(draft.budgetUnitPrice)
|
const price = cents(draft.budgetUnitPrice)
|
||||||
|
|||||||
@@ -1,23 +1,3 @@
|
|||||||
import type { ProcurementCreate } from './api/procurement'
|
|
||||||
import { buildProcurementCreate, emptyProcurementDraft } from './procurementPresentation'
|
|
||||||
|
|
||||||
/** Restore the exact request; an unknown result cannot become a new order. */
|
|
||||||
export function restoreProcurementSubmission(raw: string): ProcurementCreate {
|
|
||||||
const saved: unknown = JSON.parse(raw)
|
|
||||||
if (!saved || typeof saved !== 'object' || Array.isArray(saved)) throw new Error('提交记录格式错误')
|
|
||||||
const value = saved as Record<string, unknown>
|
|
||||||
for (const key of ['customerName', 'purchaseCategory', 'productName', 'currency', 'receivingAddress', 'contactName', 'contactPhone', 'idempotencyKey']) if (typeof value[key] !== 'string') throw new Error('提交记录不完整')
|
|
||||||
if (typeof value.purchaseQuantity !== 'number' || typeof value.budgetUnitPrice !== 'number' || !String(value.idempotencyKey).trim() || String(value.idempotencyKey).length > 255) throw new Error('提交记录不完整')
|
|
||||||
for (const key of ['productSpecification', 'productUrl', 'remark']) if (value[key] !== undefined && typeof value[key] !== 'string') throw new Error('提交记录不完整')
|
|
||||||
if (value.currency !== 'CNY' && value.currency !== 'USD') throw new Error('提交记录币种无效')
|
|
||||||
return buildProcurementCreate({ ...emptyProcurementDraft(), purchaseCategory: String(value.purchaseCategory), productName: String(value.productName),
|
|
||||||
productSpecification: String(value.productSpecification || ''), productUrl: String(value.productUrl || ''), purchaseQuantity: String(value.purchaseQuantity),
|
|
||||||
budgetUnitPrice: String(value.budgetUnitPrice), currency: value.currency, receivingAddress: String(value.receivingAddress), contactName: String(value.contactName),
|
|
||||||
contactPhone: String(value.contactPhone), remark: String(value.remark || '') }, String(value.customerName), String(value.idempotencyKey))
|
|
||||||
}
|
|
||||||
export function definitelyRejected(error: { code?: string; status?: number }) {
|
|
||||||
return ['A0400', 'A0401', 'A0403', 'A0422'].includes(error.code || '') || [400, 401, 403, 422].includes(error.status || 0)
|
|
||||||
}
|
|
||||||
export function procurementRequestKey(provider: Pick<Crypto, 'getRandomValues'> & Partial<Pick<Crypto, 'randomUUID'>> = globalThis.crypto) {
|
export function procurementRequestKey(provider: Pick<Crypto, 'getRandomValues'> & Partial<Pick<Crypto, 'randomUUID'>> = globalThis.crypto) {
|
||||||
if (provider.randomUUID) return provider.randomUUID()
|
if (provider.randomUUID) return provider.randomUUID()
|
||||||
return `proc-${Array.from(provider.getRandomValues(new Uint32Array(4)), value => value.toString(16).padStart(8, '0')).join('')}`
|
return `proc-${Array.from(provider.getRandomValues(new Uint32Array(4)), value => value.toString(16).padStart(8, '0')).join('')}`
|
||||||
|
|||||||
@@ -9,9 +9,9 @@ import DataTable, { type DataTableColumn } from '@/components/common/DataTable.v
|
|||||||
import QueryToolbar, { type QueryField, type QueryModel } from '@/components/common/QueryToolbar.vue'
|
import QueryToolbar, { type QueryField, type QueryModel } from '@/components/common/QueryToolbar.vue'
|
||||||
import type { TableAction } from '@/components/common/tableActions'
|
import type { TableAction } from '@/components/common/tableActions'
|
||||||
import ProcurementDetailPanel from '../components/ProcurementDetailPanel.vue'
|
import ProcurementDetailPanel from '../components/ProcurementDetailPanel.vue'
|
||||||
import { createProcurement, getProcurement, listProcurements, type ProcurementCreate, type ProcurementDetail, type ProcurementSummary } from '../api/procurement'
|
import { createProcurement, getProcurement, listProcurements, type ProcurementDetail, type ProcurementSummary } from '../api/procurement'
|
||||||
import { buildProcurementCreate, dateTime, draftBudgetTotal, emptyProcurementDraft, money, procurementStatuses, statusLabel, statusTone } from '../procurementPresentation'
|
import { buildProcurementCreate, dateTime, draftBudgetTotal, emptyProcurementDraft, money, procurementStatuses, statusLabel, statusTone } from '../procurementPresentation'
|
||||||
import { definitelyRejected, procurementRequestKey, restoreProcurementSubmission } from '../procurementSubmission'
|
import { procurementRequestKey } from '../procurementSubmission'
|
||||||
|
|
||||||
const props = withDefaults(defineProps<{ createPage?: boolean; detailPage?: boolean }>(), { createPage: false, detailPage: false })
|
const props = withDefaults(defineProps<{ createPage?: boolean; detailPage?: boolean }>(), { createPage: false, detailPage: false })
|
||||||
const auth = useAuthStore(), route = useRoute(), router = useRouter()
|
const auth = useAuthStore(), route = useRoute(), router = useRouter()
|
||||||
@@ -20,11 +20,9 @@ const orderNo = computed(() => typeof route.params.orderNo === 'string' ? route.
|
|||||||
const canCreate = computed(() => auth.hasPermission('merchant:cross-border:procurement:create'))
|
const canCreate = computed(() => auth.hasPermission('merchant:cross-border:procurement:create'))
|
||||||
const canList = computed(() => auth.hasPermission('merchant:cross-border:procurement:list'))
|
const canList = computed(() => auth.hasPermission('merchant:cross-border:procurement:list'))
|
||||||
const identity = computed(() => auth.token ? accessTokenIdentity(auth.token) : null)
|
const identity = computed(() => auth.token ? accessTokenIdentity(auth.token) : null)
|
||||||
const storageKey = computed(() => identity.value ? `cc-procurement-submit:${encodeURIComponent(identity.value)}` : null)
|
|
||||||
const companyName = computed(() => auth.profile.tenantName || (auth.user?.tenantName && !/^企业租户 \d+$/.test(auth.user.tenantName) ? auth.user.tenantName : ''))
|
const companyName = computed(() => auth.profile.tenantName || (auth.user?.tenantName && !/^企业租户 \d+$/.test(auth.user.tenantName) ? auth.user.tenantName : ''))
|
||||||
const form = reactive(emptyProcurementDraft())
|
const form = reactive(emptyProcurementDraft())
|
||||||
const pending = shallowRef<ProcurementCreate | null>(null)
|
const submitError = ref(''), submittedOrder = ref('')
|
||||||
const recoveryError = ref(''), submitError = ref(''), submittedOrder = ref('')
|
|
||||||
const submitting = ref(false), loading = ref(false), error = ref('')
|
const submitting = ref(false), loading = ref(false), error = ref('')
|
||||||
const detail = shallowRef<ProcurementDetail | null>(null)
|
const detail = shallowRef<ProcurementDetail | null>(null)
|
||||||
const rows = ref<ProcurementSummary[]>([]), total = ref(0)
|
const rows = ref<ProcurementSummary[]>([]), total = ref(0)
|
||||||
@@ -74,43 +72,22 @@ async function loadDetail() {
|
|||||||
}
|
}
|
||||||
function search() { if (query.page === 1) void loadList(); else query.page = 1 }
|
function search() { if (query.page === 1) void loadList(); else query.page = 1 }
|
||||||
function resetQuery() { const reload = query.page === 1; Object.assign(query, { page: 1, orderNo: '', purchaseCategory: '', productName: '', status: '' }); if (reload) void loadList() }
|
function resetQuery() { const reload = query.page === 1; Object.assign(query, { page: 1, orderNo: '', purchaseCategory: '', productName: '', status: '' }); if (reload) void loadList() }
|
||||||
function populate(payload: ProcurementCreate) {
|
function resetForm() { submitError.value = ''; submittedOrder.value = ''; Object.assign(form, emptyProcurementDraft()) }
|
||||||
Object.assign(form, { purchaseCategory: payload.purchaseCategory, productName: payload.productName, productSpecification: payload.productSpecification || '', productUrl: payload.productUrl || '',
|
|
||||||
purchaseQuantity: String(payload.purchaseQuantity), budgetUnitPrice: String(payload.budgetUnitPrice), currency: payload.currency, receivingAddress: payload.receivingAddress,
|
|
||||||
contactName: payload.contactName, contactPhone: payload.contactPhone, remark: payload.remark || '' })
|
|
||||||
}
|
|
||||||
function restorePending() {
|
|
||||||
pending.value = null; recoveryError.value = ''; submitError.value = ''; submittedOrder.value = ''; Object.assign(form, emptyProcurementDraft())
|
|
||||||
if (!storageKey.value) return
|
|
||||||
try { const saved = sessionStorage.getItem(storageKey.value); if (saved) { pending.value = Object.freeze(restoreProcurementSubmission(saved)); populate(pending.value) } }
|
|
||||||
catch { recoveryError.value = '上次提交记录暂无法恢复,请先在订单列表或通过客服核对提交结果,避免重复下单。' }
|
|
||||||
}
|
|
||||||
async function submit() {
|
async function submit() {
|
||||||
if (submitting.value || !canCreate.value || recoveryError.value || !storageKey.value) return
|
if (submitting.value || !canCreate.value || !identity.value || submittedOrder.value) return
|
||||||
submitError.value = ''; const owner = identity.value, key = storageKey.value; const resuming = Boolean(pending.value)
|
const owner = identity.value; submitting.value = true; submitError.value = ''
|
||||||
let started = false
|
|
||||||
try {
|
try {
|
||||||
if (!pending.value) {
|
const result = await createProcurement(buildProcurementCreate(form, companyName.value, procurementRequestKey()))
|
||||||
const payload = buildProcurementCreate(form, companyName.value, procurementRequestKey())
|
|
||||||
try { sessionStorage.setItem(key, JSON.stringify(payload)) } catch { throw new Error('浏览器暂无法保留提交信息,请允许会话存储后重试') }
|
|
||||||
pending.value = Object.freeze(payload)
|
|
||||||
}
|
|
||||||
submitting.value = true; started = true
|
|
||||||
const result = await createProcurement(pending.value)
|
|
||||||
sessionStorage.removeItem(key)
|
|
||||||
if (!active || owner !== identity.value) return
|
if (!active || owner !== identity.value) return
|
||||||
pending.value = null; submittedOrder.value = result.order.orderNo; ElMessage.success('采购订单已提交')
|
submittedOrder.value = result.order.orderNo; ElMessage.success('采购订单已提交')
|
||||||
if (canList.value) await router.push({ name: 'cross-border-procurement-detail', params: { orderNo: result.order.orderNo } })
|
if (canList.value) await router.push({ name: 'cross-border-procurement-detail', params: { orderNo: result.order.orderNo } })
|
||||||
} catch (cause) {
|
} catch (cause) { if (active && owner === identity.value) submitError.value = message(cause) }
|
||||||
if (!active || owner !== identity.value) return
|
finally { submitting.value = false }
|
||||||
if (!resuming && cause instanceof ApiError && definitelyRejected(cause)) { sessionStorage.removeItem(key); pending.value = null }
|
|
||||||
submitError.value = started && pending.value ? `${message(cause)}。提交结果尚未确认,请再次确认上次提交结果。` : message(cause)
|
|
||||||
} finally { submitting.value = false }
|
|
||||||
}
|
}
|
||||||
watch(() => [mode.value, orderNo.value, query.page, query.size, identity.value], (values, previous) => {
|
watch(() => [mode.value, orderNo.value, query.page, query.size, identity.value], (values, previous) => {
|
||||||
if (values[4] !== previous?.[4]) { rows.value = []; total.value = 0 }
|
if (values[4] !== previous?.[4]) { rows.value = []; total.value = 0 }
|
||||||
++requestSequence; inFlight = ''; loading.value = false; error.value = ''; detail.value = null
|
++requestSequence; inFlight = ''; loading.value = false; error.value = ''; detail.value = null
|
||||||
if (mode.value === 'create') restorePending()
|
if (mode.value === 'create') resetForm()
|
||||||
else if (mode.value === 'detail') void loadDetail()
|
else if (mode.value === 'detail') void loadDetail()
|
||||||
else void loadList()
|
else void loadList()
|
||||||
}, { immediate: true })
|
}, { immediate: true })
|
||||||
@@ -140,15 +117,13 @@ onBeforeUnmount(() => { active = false; ++requestSequence })
|
|||||||
<section v-else class="procurement-create" aria-label="采购下单">
|
<section v-else class="procurement-create" aria-label="采购下单">
|
||||||
<header class="procurement-heading"><div><h2>海外采购下单</h2><p>一单一个商品及规格;预算仅授权样品货款,运费及关税另行核定。</p></div><el-button v-if="canList" @click="returnToList">返回列表</el-button></header>
|
<header class="procurement-heading"><div><h2>海外采购下单</h2><p>一单一个商品及规格;预算仅授权样品货款,运费及关税另行核定。</p></div><el-button v-if="canList" @click="returnToList">返回列表</el-button></header>
|
||||||
<el-result v-if="!canCreate" icon="warning" title="没有采购下单权限" sub-title="请联系企业管理员配置权限" />
|
<el-result v-if="!canCreate" icon="warning" title="没有采购下单权限" sub-title="请联系企业管理员配置权限" />
|
||||||
<el-result v-else-if="submittedOrder" icon="success" title="采购订单已提交" :sub-title="submittedOrder"><template #extra><el-button @click="restorePending">新建另一单</el-button></template></el-result>
|
<el-result v-else-if="submittedOrder" icon="success" title="采购订单已提交" :sub-title="submittedOrder"><template #extra><el-button @click="resetForm">新建另一单</el-button></template></el-result>
|
||||||
<template v-else>
|
<template v-else>
|
||||||
<el-alert v-if="recoveryError" :title="recoveryError" type="error" :closable="false" />
|
|
||||||
<el-alert v-else-if="pending" title="已保留本次提交内容。请再次确认上次提交结果,确认前不修改订单信息。" type="warning" :closable="false" />
|
|
||||||
<el-alert v-if="submitError" class="submit-error" :title="submitError" type="error" :closable="false" />
|
<el-alert v-if="submitError" class="submit-error" :title="submitError" type="error" :closable="false" />
|
||||||
<el-form :model="form" label-position="top" :disabled="submitting || Boolean(pending) || Boolean(recoveryError)" @submit.prevent="submit">
|
<el-form :model="form" label-position="top" :disabled="submitting" @submit.prevent="submit">
|
||||||
<h3>商品与预算</h3><div class="procurement-form-grid">
|
<h3>商品与预算</h3><div class="procurement-form-grid">
|
||||||
<el-form-item label="采购品类" required><el-input v-model.trim="form.purchaseCategory" maxlength="128" placeholder="请输入采购品类" /></el-form-item>
|
<el-form-item label="采购品类"><el-input v-model.trim="form.purchaseCategory" maxlength="128" placeholder="" /></el-form-item>
|
||||||
<el-form-item label="商品名称" required><el-input v-model.trim="form.productName" maxlength="255" placeholder="请输入商品名称" /></el-form-item>
|
<el-form-item label="商品名称" required><el-input v-model.trim="form.productName" maxlength="255" placeholder="" /></el-form-item>
|
||||||
<el-form-item label="商品规格"><el-input v-model.trim="form.productSpecification" maxlength="500" placeholder="规格、型号" /></el-form-item>
|
<el-form-item label="商品规格"><el-input v-model.trim="form.productSpecification" maxlength="500" placeholder="规格、型号" /></el-form-item>
|
||||||
<el-form-item label="采购数量(件)" required><el-input v-model.trim="form.purchaseQuantity" inputmode="numeric" maxlength="18" placeholder="正整数" /></el-form-item>
|
<el-form-item label="采购数量(件)" required><el-input v-model.trim="form.purchaseQuantity" inputmode="numeric" maxlength="18" placeholder="正整数" /></el-form-item>
|
||||||
<el-form-item label="预算单价" required><el-input v-model.trim="form.budgetUnitPrice" inputmode="decimal" maxlength="20" placeholder="请明确填写;免费样品填 0" /></el-form-item>
|
<el-form-item label="预算单价" required><el-input v-model.trim="form.budgetUnitPrice" inputmode="decimal" maxlength="20" placeholder="请明确填写;免费样品填 0" /></el-form-item>
|
||||||
@@ -158,12 +133,11 @@ onBeforeUnmount(() => { active = false; ++requestSequence })
|
|||||||
<h3>最终国内收件资料</h3><div class="procurement-form-grid">
|
<h3>最终国内收件资料</h3><div class="procurement-form-grid">
|
||||||
<el-form-item label="收件人" required><el-input v-model.trim="form.contactName" maxlength="128" placeholder="实际收件人姓名" /></el-form-item>
|
<el-form-item label="收件人" required><el-input v-model.trim="form.contactName" maxlength="128" placeholder="实际收件人姓名" /></el-form-item>
|
||||||
<el-form-item label="联系电话" required><el-input v-model.trim="form.contactPhone" maxlength="64" type="tel" placeholder="快递可联系的电话" /></el-form-item>
|
<el-form-item label="联系电话" required><el-input v-model.trim="form.contactPhone" maxlength="64" type="tel" placeholder="快递可联系的电话" /></el-form-item>
|
||||||
<el-form-item label="下单企业"><el-input :model-value="companyName" disabled /></el-form-item>
|
|
||||||
<el-form-item class="full" label="完整国内地址" required><el-input v-model.trim="form.receivingAddress" maxlength="1000" placeholder="省、市、区县、街道及详细门牌" /></el-form-item>
|
<el-form-item class="full" label="完整国内地址" required><el-input v-model.trim="form.receivingAddress" maxlength="1000" placeholder="省、市、区县、街道及详细门牌" /></el-form-item>
|
||||||
<el-form-item class="full" label="采购要求"><el-input v-model="form.remark" type="textarea" :rows="3" maxlength="1000" show-word-limit placeholder="其他采购要求(选填)" /></el-form-item>
|
<el-form-item class="full" label="采购要求"><el-input v-model="form.remark" type="textarea" :rows="3" maxlength="1000" show-word-limit placeholder="" /></el-form-item>
|
||||||
</div>
|
</div>
|
||||||
</el-form>
|
</el-form>
|
||||||
<footer class="procurement-form-actions"><el-button v-if="canList" :disabled="submitting" @click="returnToList">返回列表</el-button><el-button type="primary" :loading="submitting" :disabled="Boolean(recoveryError) || (!pending && !companyName) || !identity" @click="submit">{{ pending ? '确认上次提交结果' : '提交采购订单' }}</el-button></footer>
|
<footer class="procurement-form-actions"><el-button type="primary" :loading="submitting" :disabled="!companyName || !identity" @click="submit">提交采购订单</el-button></footer>
|
||||||
</template>
|
</template>
|
||||||
</section>
|
</section>
|
||||||
</section>
|
</section>
|
||||||
|
|||||||
@@ -0,0 +1,26 @@
|
|||||||
|
# Client 工作台模块指引
|
||||||
|
|
||||||
|
## 路径基准与读取顺序
|
||||||
|
|
||||||
|
- 本文件适用于 `src/modules/dashboard/`,代码路径相对本目录;应用公共规则见 `../../../AGENTS.md`。
|
||||||
|
- 只有 `views/DashboardView.vue` 与 `overview.ts`;路由为空路径(登录后默认页)。
|
||||||
|
- 后端按卡片来源分别查 `order/`、`firstleg/`、`lastleg-service/`;本模块只做聚合展示。
|
||||||
|
|
||||||
|
## 页面与入口
|
||||||
|
|
||||||
|
| 目标 | 页面/入口 | API 与后端 |
|
||||||
|
|---|---|---|
|
||||||
|
| 业务总览卡片与快捷入口 | `views/DashboardView.vue` | `overview.ts`;按卡片对应的服务 |
|
||||||
|
| 卡片数据映射与跳转 | `overview.ts` | 各业务模块的公开 API |
|
||||||
|
|
||||||
|
## 关键边界
|
||||||
|
|
||||||
|
- 只展示服务端或既有模块返回的数据,不在首页二次统计或补算。
|
||||||
|
- 快捷入口跳转带明确业务筛选,不用标题文字反推状态。
|
||||||
|
- 首页不新增跨客户对比或内部经营指标;客户只能看到本企业数据。
|
||||||
|
- 卡片加载失败要单卡片降级,不阻塞整页。
|
||||||
|
|
||||||
|
## 验证
|
||||||
|
|
||||||
|
- 定向:`pnpm test src/modules/dashboard/<目标测试>`。
|
||||||
|
- 本文件或索引变更后,从后端根运行 `./scripts/agents-index-contract.ps1`。
|
||||||
@@ -13,8 +13,8 @@ const primaryActions = computed(() => [
|
|||||||
{ title: '美本土散板', description: '拼车拼载 · 打盘服务 · 灵活派送', icon: Forklift, route: '/cross-border/pallet-shipping/create', permission: 'merchant:cross-border:pallet-shipping:create', tone: 'cyan', featured: false },
|
{ title: '美本土散板', description: '拼车拼载 · 打盘服务 · 灵活派送', icon: Forklift, route: '/cross-border/pallet-shipping/create', permission: 'merchant:cross-border:pallet-shipping:create', tone: 'cyan', featured: false },
|
||||||
{ title: '海外采购', description: '采购代购 · 验货质检 · 集中发货', icon: ShoppingCart, route: '/cross-border/procurement/create', permission: 'merchant:cross-border:procurement:create', tone: 'orange', featured: false },
|
{ title: '海外采购', description: '采购代购 · 验货质检 · 集中发货', icon: ShoppingCart, route: '/cross-border/procurement/create', permission: 'merchant:cross-border:procurement:create', tone: 'orange', featured: false },
|
||||||
{ title: '贴标申请', description: '产品建档 · 标签上传 · 批量贴标', icon: Tags, route: '/overseas-warehouse/labeling/create', permission: 'merchant:overseas-warehouse:relabel:create', tone: 'rose', featured: false },
|
{ title: '贴标申请', description: '产品建档 · 标签上传 · 批量贴标', icon: Tags, route: '/overseas-warehouse/labeling/create', permission: 'merchant:overseas-warehouse:relabel:create', tone: 'rose', featured: false },
|
||||||
{ title: '仓储转运', description: '仓储管理 · 货物转运', icon: Warehouse, route: '/overseas-warehouse/storage-transfer', permission: 'merchant:overseas-warehouse:transfer:list', tone: 'teal', featured: false, actionLabel: '开始办理' },
|
{ title: '仓储转运', description: '仓储管理 · 货物转运', icon: Warehouse, route: '/overseas-warehouse/storage-transfer/create', permission: 'merchant:overseas-warehouse:transfer:create', tone: 'teal', featured: false, actionLabel: '开始办理' },
|
||||||
{ title: '货物废弃', description: '废弃申请 · 处理进度', icon: PackageOpen, route: '/overseas-warehouse/cargo-disposal', permission: 'merchant:overseas-warehouse:discard:list', tone: 'brown', featured: false, actionLabel: '开始办理' },
|
{ title: '货物废弃', description: '废弃申请 · 处理进度', icon: PackageOpen, route: '/overseas-warehouse/cargo-disposal/create', permission: 'merchant:overseas-warehouse:discard:create', tone: 'brown', featured: false, actionLabel: '开始办理' },
|
||||||
].filter((action) => auth.hasPermission(action.permission)))
|
].filter((action) => auth.hasPermission(action.permission)))
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
@@ -23,7 +23,7 @@ const primaryActions = computed(() => [
|
|||||||
<div class="client-dashboard">
|
<div class="client-dashboard">
|
||||||
<header class="business-intro">
|
<header class="business-intro">
|
||||||
<h1>选择业务,快速下单</h1>
|
<h1>选择业务,快速下单</h1>
|
||||||
<p>请选择您需要的业务类型,填写信息后提交订单,我们将尽快为您安排。</p>
|
|
||||||
</header>
|
</header>
|
||||||
|
|
||||||
<section class="quick-actions" aria-label="业务选择">
|
<section class="quick-actions" aria-label="业务选择">
|
||||||
|
|||||||
@@ -0,0 +1,29 @@
|
|||||||
|
# Client 财务模块指引
|
||||||
|
|
||||||
|
## 路径基准与读取顺序
|
||||||
|
|
||||||
|
- 本文件适用于 `src/modules/finance/`,代码路径相对本目录;应用公共规则见 `../../../AGENTS.md`,账单与资金细则见 `../../../docs/business-index.md`。
|
||||||
|
- 本模块只做客户可见的账单查询、客户确认与资金账户;费用来源、核销与账期归 `backend finance/`,不在前端重算。
|
||||||
|
- 后端只查 `finance/`(账单、收款、账户与授信);文件下载归 `file/`。
|
||||||
|
|
||||||
|
## 页面与入口
|
||||||
|
|
||||||
|
| 目标 | 页面/路由 | API 与后端 |
|
||||||
|
|---|---|---|
|
||||||
|
| 客户财务账单列表、筛选与未收余额 | `views/FinanceBillsView.vue`;`finance/bills` | `api/finance.ts`;`finance/` 账单 |
|
||||||
|
| 账单详情、入仓码联查与客户确认 | `views/FinanceBillDetailView.vue`;`finance/bills/:billNo/detail` | `api/finance.ts`、`adapters.ts`;`finance/` |
|
||||||
|
| 客户资金账户、授信与充值申请 | `views/FinanceAccountView.vue`;`finance/account` | `api/account.ts`;`finance/` 资金账户 |
|
||||||
|
| 跨页契约与稳定类型 | `contracts.ts` | 服务端 DTO |
|
||||||
|
|
||||||
|
## 关键边界
|
||||||
|
|
||||||
|
- 账单行只显示服务端返回的 `inboundCode`;缺失时显示“—”,不用内部 ID 或本地拼接回退。
|
||||||
|
- 实际、冻结、可用余额、授信与流水只消费 Finance 权威结果,前端不自行汇总或推算。
|
||||||
|
- 客户确认按服务端允许动作开放,提交金额与状态以服务端返回为准;已确认账单不得在前端改回。
|
||||||
|
- 充值申请与账户操作携带幂等键与提交中状态,失败保留原输入。
|
||||||
|
- 费用明细与柜级分摊只展示服务端结果;前端不参与分摊计算,也不把退税额或汇率写死。
|
||||||
|
|
||||||
|
## 验证
|
||||||
|
|
||||||
|
- 定向:`pnpm test src/modules/finance/<目标测试>`;接口或金额字段变化同时运行 `pnpm typecheck`。
|
||||||
|
- 本文件或索引变更后,从后端根运行 `./scripts/agents-index-contract.ps1`。
|
||||||
@@ -0,0 +1,35 @@
|
|||||||
|
# Client 头程模块指引
|
||||||
|
|
||||||
|
## 路径基准与读取顺序
|
||||||
|
|
||||||
|
- 本文件适用于 `src/modules/first-leg/`,代码路径相对本目录;应用公共规则见 `../../../AGENTS.md`,字段与接口细则见 `../../../docs/business-index.md`。
|
||||||
|
- 模块分层固定:`views/` 页面、`components/` 业务组件、`api/` 请求、`store/` 跨页状态、`types/`、`utils/`、`data/`;跨模块只能从本目录 `public.ts` 导入。
|
||||||
|
- 后端只查 `order/`(订单读写与批量导入)、`firstleg/`(履约进度、入库费用、报关资料)、`file/`(资质与附件);纯页面与文案不读后端。
|
||||||
|
|
||||||
|
## 页面与入口
|
||||||
|
|
||||||
|
| 目标 | 页面/路由 | API 与后端 |
|
||||||
|
|---|---|---|
|
||||||
|
| 头程订单列表、详情、草稿编辑 | `views/FirstLegOrdersView.vue`;`orders/first-leg`、`orders/first-leg/:orderId/detail`、`orders/first-leg/:draftId/edit` | `api/firstLeg.ts`;`store/firstLegOrders.ts`;`order/` |
|
||||||
|
| 创建订单入口(选业务类型) | `views/FirstLegOrderCreateHubView.vue`;`orders/first-leg/create` | `components/FirstLegOrderEditorShell.vue` |
|
||||||
|
| 快速下单(按渠道/目的仓/SKU 生成草稿) | `views/QuickOrderView.vue`;`first-leg/quick-order` | `api/firstLeg.ts`;只生成草稿,不提交、不审核 |
|
||||||
|
| 中文批量导入与逐行结果 | 订单列表导入入口 | `api/firstLeg.ts`;`order/` 批量导入;入仓码与失败原因逐行展示 |
|
||||||
|
| 履约进度与入仓码关系 | `components/OrderProgressPanel.vue`、`components/InboundCodeAssociationDialog.vue` | `api/inboundCodeAssociations.ts`、`utils/orderProgress.ts`;`firstleg/` |
|
||||||
|
| 运输事实与商品图片 | `components/TransportFactsTable.vue`(纯展示)、`utils/transportFacts.ts`、`utils/productImage.ts` | 行数据类型来自 `api/unifiedOrders.ts`;图片读取归 `file/` |
|
||||||
|
| 入库费用确认与计费重 | `components/InboundBillingPanel.vue` | `api/inboundBilling.ts`;`firstleg/service/MerchantInboundBillingService.java` |
|
||||||
|
| 装柜后的退税报关资料 | `views/CustomsDocumentsView.vue`、`components/CustomsDocumentsDialog.vue` | `api/customs.ts`、`store/customsPending.ts`、`utils/customsEligibility.ts`;`firstleg/customs/`、`file/` |
|
||||||
|
| 船期与参考价格 | `views/SailingPricesView.vue`;`first-leg/sailing-prices` | `api/firstLeg.ts`;`firstleg/` 船期价格 |
|
||||||
|
| 往来单位候选 | `data/firstLegParties.ts`、`api/partners.ts` | `warehouse/` 公共往来单位 |
|
||||||
|
|
||||||
|
## 关键边界
|
||||||
|
|
||||||
|
- 头程订单只用当前正式读写契约;不得扩展 `LEGACY_MANUAL`、旧系统入仓码、C02 不可用回退旧 API、历史部分响应兼容或其他新旧并跑逻辑。触及该链路时同步删除生产分支、类型、文案、Mock 和测试。
|
||||||
|
- 快速下单只创建草稿,不提交、不审核;逐行失败必须回填原因与入仓码,不用内部 ID 代替业务编号。
|
||||||
|
- 入库费用确认携带 `expectedFeeVersion` 与幂等键,金额与冻结状态只认服务端结果;列表“确认计费重”仅在具备确认权限且服务端 `customerFeeConfirmationRequired=true` 时显示,已确认或未推送费用的订单不显示;详情保留费用查看入口。
|
||||||
|
- 报关资料在开始后只读冻结资料,未装柜或无资格时不展示入口;`utils/customsEligibility.ts` 是唯一资格判断入口。
|
||||||
|
- 模块间协作只能从本模块 `public.ts` 导入,不穿透其他模块的 `views/` 或内部目录。
|
||||||
|
|
||||||
|
## 验证
|
||||||
|
|
||||||
|
- 定向:`pnpm test src/modules/first-leg/<目标测试>`;接口或类型变化同时运行 `pnpm typecheck`。
|
||||||
|
- 本文件或索引变更后,从后端根运行 `./scripts/agents-index-contract.ps1`。
|
||||||
@@ -2,6 +2,8 @@
|
|||||||
|
|
||||||
依据:当前对话 2026-10-19 用户确认“卡车自送排第一,我司提货排第二,快递自提排第三;快递自提增加非必填快递单号”。该确认优先于历史原型对应字段。
|
依据:当前对话 2026-10-19 用户确认“卡车自送排第一,我司提货排第二,快递自提排第三;快递自提增加非必填快递单号”。该确认优先于历史原型对应字段。
|
||||||
|
|
||||||
|
2026-10-20 补充确认:新建、重置头程订单默认选择“卡车自送”;快速下单生成的草稿同步使用该默认值,编辑已有草稿保留原取货方式。
|
||||||
|
|
||||||
| 页面 | 操作 | 承载方式 | 布局 | 当前实现 | 结论 |
|
| 页面 | 操作 | 承载方式 | 布局 | 当前实现 | 结论 |
|
||||||
|---|---|---|---|---|---|
|
|---|---|---|---|---|---|
|
||||||
| 头程下单 | 新增 | 现有独立页面 | 保持现有国内交货区布局 | 快递自送、我司提货、卡车自送;无快递单号输入 | 按确认顺序排列;第三项改为快递自提,下方条件显示选填快递单号 |
|
| 头程下单 | 新增 | 现有独立页面 | 保持现有国内交货区布局 | 快递自送、我司提货、卡车自送;无快递单号输入 | 按确认顺序排列;第三项改为快递自提,下方条件显示选填快递单号 |
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
import { computed, nextTick, onBeforeUnmount, ref, watch } from 'vue'
|
import { computed, nextTick, onBeforeUnmount, ref, watch } from 'vue'
|
||||||
import { ElMessage, ElMessageBox } from 'element-plus'
|
import { ElMessage, ElMessageBox } from 'element-plus'
|
||||||
import { Download, FileText, LockKeyhole, Pencil, Trash2, Upload } from '@lucide/vue'
|
import { Download, FileText, LockKeyhole, Pencil, Trash2, Upload } from '@lucide/vue'
|
||||||
|
import CustomsHelp from './CustomsHelp.vue'
|
||||||
import {
|
import {
|
||||||
MERCHANT_CUSTOMS_STATUS_LABELS,
|
MERCHANT_CUSTOMS_STATUS_LABELS,
|
||||||
deleteMerchantCustomsDocument,
|
deleteMerchantCustomsDocument,
|
||||||
@@ -329,7 +330,7 @@ function clearanceResultStatusLabel(value: MerchantClearanceResult) {
|
|||||||
<template>
|
<template>
|
||||||
<el-dialog
|
<el-dialog
|
||||||
:model-value="modelValue"
|
:model-value="modelValue"
|
||||||
class="customs-documents-dialog"
|
class="customs-documents-dialog client-ui"
|
||||||
title="退税报关资料"
|
title="退税报关资料"
|
||||||
width="920px"
|
width="920px"
|
||||||
append-to-body
|
append-to-body
|
||||||
@@ -367,7 +368,7 @@ function clearanceResultStatusLabel(value: MerchantClearanceResult) {
|
|||||||
|
|
||||||
<section class="customs-section">
|
<section class="customs-section">
|
||||||
<div class="customs-section-title">
|
<div class="customs-section-title">
|
||||||
<div><h3>上传资料</h3><p>支持任意格式,单个文件不超过 50MB;可关联同柜内当前企业的一票或多票退税入仓码。</p></div>
|
<div class="customs-help-heading"><h3>上传资料</h3><CustomsHelp title="报关资料上传说明"><p>支持任意格式,单个文件不超过 50MB;可关联同柜内当前企业的一票或多票退税入仓码。</p></CustomsHelp></div>
|
||||||
<el-button v-if="canEdit && !locked" type="primary" :loading="mutating" @click="chooseUpload"><Upload :size="16" />选择文件上传</el-button>
|
<el-button v-if="canEdit && !locked" type="primary" :loading="mutating" @click="chooseUpload"><Upload :size="16" />选择文件上传</el-button>
|
||||||
</div>
|
</div>
|
||||||
<el-checkbox-group v-model="selectedInboundIds" class="customs-inbound-options" :disabled="!canEdit || locked" aria-label="选择资料关联入仓码">
|
<el-checkbox-group v-model="selectedInboundIds" class="customs-inbound-options" :disabled="!canEdit || locked" aria-label="选择资料关联入仓码">
|
||||||
@@ -382,7 +383,7 @@ function clearanceResultStatusLabel(value: MerchantClearanceResult) {
|
|||||||
|
|
||||||
<section class="customs-section clearance-results-section">
|
<section class="customs-section clearance-results-section">
|
||||||
<div class="customs-section-title">
|
<div class="customs-section-title">
|
||||||
<div><h3>海关申报结果</h3><p>平台完成正式申报后,客户可查看与本订单相关的查验、补充资料和放行结果。</p></div>
|
<h3>海关申报结果</h3>
|
||||||
</div>
|
</div>
|
||||||
<div v-if="clearanceError" class="customs-error" role="alert">
|
<div v-if="clearanceError" class="customs-error" role="alert">
|
||||||
<strong>海关申报结果加载失败</strong>
|
<strong>海关申报结果加载失败</strong>
|
||||||
@@ -402,7 +403,7 @@ function clearanceResultStatusLabel(value: MerchantClearanceResult) {
|
|||||||
|
|
||||||
<section class="customs-section">
|
<section class="customs-section">
|
||||||
<div class="customs-section-title">
|
<div class="customs-section-title">
|
||||||
<div><h3>资料版本历史</h3><p>每份当前资料展示服务端版本、关联票和上传时间;覆盖及删除操作由服务端保留不可变历史。</p></div>
|
<h3>资料版本历史</h3>
|
||||||
</div>
|
</div>
|
||||||
<el-empty v-if="!detail.documents.length" description="尚未上传退税报关资料" :image-size="54" />
|
<el-empty v-if="!detail.documents.length" description="尚未上传退税报关资料" :image-size="54" />
|
||||||
<div v-else class="customs-document-list">
|
<div v-else class="customs-document-list">
|
||||||
@@ -447,42 +448,49 @@ function clearanceResultStatusLabel(value: MerchantClearanceResult) {
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<style scoped>
|
<style scoped>
|
||||||
:global(.customs-documents-dialog.el-dialog) { display: flex; max-height: 70vh; flex-direction: column; overflow: hidden; }
|
:global(.customs-documents-dialog.el-dialog) { display: flex; max-height: 70vh; flex-direction: column; overflow: hidden; padding: 0; border: 1px solid var(--client-border); border-radius: var(--client-radius); }
|
||||||
:global(.customs-documents-dialog .el-dialog__header), :global(.customs-documents-dialog .el-dialog__footer) { flex: 0 0 auto; }
|
:global(.customs-documents-dialog .el-dialog__header), :global(.customs-documents-dialog .el-dialog__footer) { flex: 0 0 auto; }
|
||||||
:global(.customs-documents-dialog .el-dialog__body) { min-height: 0; flex: 1 1 auto; overflow-y: auto; overscroll-behavior: contain; }
|
:global(.customs-documents-dialog .el-dialog__header) { margin: 0; padding: 18px 48px 18px 20px; border-bottom: 1px solid var(--client-border); }
|
||||||
|
:global(.customs-documents-dialog .el-dialog__title) { color: var(--client-text); font-size: 16px; font-weight: 600; line-height: 24px; }
|
||||||
|
:global(.customs-documents-dialog .el-dialog__headerbtn) { top: 8px; right: 8px; }
|
||||||
|
:global(.customs-documents-dialog .el-dialog__body) { min-height: 0; flex: 1 1 auto; overflow-y: auto; padding: 20px; color: var(--client-text); line-height: 1.6; overscroll-behavior: contain; }
|
||||||
|
:global(.customs-documents-dialog .el-dialog__footer) { padding: 14px 20px; border-top: 1px solid var(--client-border); background: var(--client-header-bg); }
|
||||||
.customs-error { display: grid; gap: 10px; justify-items: start; padding: 22px; border: 1px solid #f1b8b8; background: #fff7f7; color: #9f2d2d; }
|
.customs-error { display: grid; gap: 10px; justify-items: start; padding: 22px; border: 1px solid #f1b8b8; background: #fff7f7; color: #9f2d2d; }
|
||||||
.customs-error span { overflow-wrap: anywhere; font-size: 12px; }
|
.customs-error span { overflow-wrap: anywhere; font-size: 12px; }
|
||||||
.customs-summary { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)) auto; align-items: center; gap: 18px; padding: 16px 18px; border: 1px solid var(--border); background: #f8faf9; }
|
.customs-summary { display: grid; grid-template-columns: minmax(0, 1.6fr) repeat(2, minmax(0, 1fr)) auto; align-items: center; gap: 18px; padding: 16px; border: 1px solid var(--client-border); border-radius: var(--client-radius); background: var(--client-header-bg); }
|
||||||
.customs-summary div { min-width: 0; }
|
.customs-summary div { min-width: 0; }
|
||||||
.customs-summary span { display: block; color: var(--muted); font-size: 11px; }
|
.customs-summary > div > span { display: block; color: var(--muted); font-size: 11px; }
|
||||||
.customs-summary strong { display: block; margin-top: 5px; overflow-wrap: anywhere; color: var(--navy); font-size: 14px; }
|
.customs-summary strong { display: block; margin-top: 5px; overflow-wrap: anywhere; color: var(--navy); font-size: 14px; }
|
||||||
.customs-locked { display: flex; align-items: flex-start; gap: 10px; margin-top: 14px; padding: 13px 15px; border: 1px solid #d5dde1; background: #f5f7f8; color: var(--muted); }
|
.customs-locked { display: flex; align-items: flex-start; gap: 10px; margin-top: 14px; padding: 13px 15px; border: 1px solid #d5dde1; background: #f5f7f8; color: var(--muted); }
|
||||||
.customs-locked strong, .customs-locked span { display: block; }
|
.customs-locked strong, .customs-locked span { display: block; }
|
||||||
.customs-locked strong { color: var(--navy); font-size: 12px; }
|
.customs-locked strong { color: var(--navy); font-size: 12px; }
|
||||||
.customs-locked span { margin-top: 3px; font-size: 11px; }
|
.customs-locked span { margin-top: 3px; font-size: 11px; }
|
||||||
.customs-section { margin-top: 18px; }
|
.customs-section { margin-top: var(--client-section-gap); padding: 16px; border: 1px solid var(--client-border); border-radius: var(--client-radius); }
|
||||||
|
.customs-section :deep(.el-empty) { padding: 20px 0; }
|
||||||
.clearance-result-list { display:grid; gap:10px; }
|
.clearance-result-list { display:grid; gap:10px; }
|
||||||
.clearance-result-row { display:grid; grid-template-columns:minmax(0,1fr) auto; gap:6px 14px; padding:12px 14px; border:1px solid var(--border); background:#fbfcfe; }
|
.clearance-result-row { display:grid; grid-template-columns:minmax(0,1fr) auto; gap:6px 14px; padding:12px 14px; border:1px solid var(--border); background:#fbfcfe; }
|
||||||
.clearance-result-row strong,.clearance-result-row span { display:block; }
|
.clearance-result-row strong,.clearance-result-row span { display:block; }
|
||||||
.clearance-result-row span { margin-top:4px; color:var(--muted); font-size:11px; }
|
.clearance-result-row span { margin-top:4px; color:var(--muted); font-size:11px; }
|
||||||
.clearance-result-row p { grid-column:1 / -1; margin:0; color:var(--navy); font-size:12px; }
|
.clearance-result-row p { grid-column:1 / -1; margin:0; color:var(--navy); font-size:12px; }
|
||||||
.customs-section-title { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; margin-bottom: 12px; }
|
.customs-section-title { display: flex; align-items: center; justify-content: space-between; gap: 18px; margin-bottom: 14px; }
|
||||||
.customs-section-title h3 { margin: 0; color: var(--navy); font-size: 14px; }
|
.customs-section-title h3 { margin: 0; color: var(--navy); font-size: 14px; }
|
||||||
.customs-section-title p { margin: 5px 0 0; color: var(--muted); font-size: 11px; line-height: 1.55; }
|
.customs-help-heading { display: flex; align-items: center; gap: 4px; }
|
||||||
.customs-inbound-options { display: flex; flex-wrap: wrap; gap: 8px 18px; padding: 13px 15px; border: 1px solid var(--border); }
|
.customs-inbound-options { display: flex; flex-wrap: wrap; gap: 8px 18px; padding: 12px 14px; border: 1px solid var(--client-border); border-radius: var(--client-radius); background: var(--client-header-bg); }
|
||||||
.customs-inbound-options :deep(.el-checkbox) { margin-right: 0; }
|
.customs-inbound-options :deep(.el-checkbox) { margin-right: 0; }
|
||||||
|
.customs-inbound-options :deep(.el-checkbox__label) { white-space: normal; overflow-wrap: anywhere; }
|
||||||
.customs-inbound-code { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; }
|
.customs-inbound-code { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; }
|
||||||
.customs-inbound-options small { margin-left: 7px; color: var(--muted); }
|
.customs-inbound-options small { margin-left: 7px; color: var(--muted); }
|
||||||
.customs-hidden-input { display: none; }
|
.customs-hidden-input { display: none; }
|
||||||
.customs-document-list { display: grid; gap: 10px; }
|
.customs-document-list { display: grid; gap: 10px; }
|
||||||
.customs-document-card { padding: 14px 16px; border: 1px solid var(--border); }
|
.customs-document-card { padding: 14px 16px; border: 1px solid var(--client-border); border-radius: var(--client-radius); }
|
||||||
.customs-document-main { display: flex; align-items: flex-start; gap: 11px; min-width: 0; }
|
.customs-document-main { display: flex; align-items: flex-start; gap: 11px; min-width: 0; }
|
||||||
.customs-document-main > svg { flex: 0 0 20px; color: var(--primary); }
|
.customs-document-main > svg { flex: 0 0 20px; color: var(--primary); }
|
||||||
.customs-document-main > div { min-width: 0; }
|
.customs-document-main > div { min-width: 0; }
|
||||||
.customs-document-main strong, .customs-document-main span, .customs-document-main small { display: block; overflow-wrap: anywhere; }
|
.customs-document-main strong, .customs-document-main span, .customs-document-main small { display: block; overflow-wrap: anywhere; }
|
||||||
.customs-document-main strong { color: var(--navy); font-size: 13px; }
|
.customs-document-main strong { color: var(--navy); font-size: 13px; line-height: 1.6; }
|
||||||
.customs-document-main span, .customs-document-main small { margin-top: 4px; color: var(--muted); font-size: 11px; }
|
.customs-document-main span, .customs-document-main small { margin-top: 4px; color: var(--muted); font-size: 11px; }
|
||||||
.customs-document-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 2px; margin-top: 8px; }
|
.customs-document-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; align-items: center; gap: 6px 10px; margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--client-border); }
|
||||||
|
.customs-document-actions :deep(.el-button + .el-button) { margin-left: 0; }
|
||||||
.customs-scope-editor { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-top: 12px; padding-top: 12px; border-top: 1px dashed var(--border); }
|
.customs-scope-editor { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-top: 12px; padding-top: 12px; border-top: 1px dashed var(--border); }
|
||||||
.customs-scope-editor :deep(.el-checkbox) { margin-right: 16px; }
|
.customs-scope-editor :deep(.el-checkbox) { margin-right: 16px; }
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
@@ -0,0 +1,21 @@
|
|||||||
|
<script setup lang="ts">
|
||||||
|
import { Info } from '@lucide/vue'
|
||||||
|
|
||||||
|
defineProps<{ title: string }>()
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<el-tooltip :trigger="['hover', 'focus']" placement="top" effect="light" :show-after="150" :hide-after="100" :enterable="true">
|
||||||
|
<template #content><div class="customs-help-content"><strong>{{ title }}</strong><slot /></div></template>
|
||||||
|
<button type="button" class="customs-help" :aria-label="`查看${title}`"><Info :size="14" aria-hidden="true" /></button>
|
||||||
|
</el-tooltip>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
.customs-help { display: inline-flex; width: 24px; height: 24px; flex: 0 0 24px; align-items: center; justify-content: center; margin: 0; padding: 0; border: 0; background: transparent; color: var(--muted); cursor: help; vertical-align: middle; }
|
||||||
|
.customs-help:hover,.customs-help:focus-visible { color: var(--primary); }
|
||||||
|
.customs-help:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
|
||||||
|
.customs-help-content { max-width: 320px; color: var(--navy); font-size: 12px; font-weight: 400; line-height: 1.6; white-space: normal; }
|
||||||
|
.customs-help-content > strong { display: block; margin-bottom: 4px; }
|
||||||
|
.customs-help-content :deep(p) { margin: 0; }
|
||||||
|
</style>
|
||||||
@@ -20,7 +20,7 @@ test('supports a standalone dialog and keeps the unpushed billing-weight state v
|
|||||||
assert.match(source, /watch\(\(\) => props\.autoOpen/)
|
assert.match(source, /watch\(\(\) => props\.autoOpen/)
|
||||||
assert.match(source, /if \(autoOpen\) feeDialogOpen\.value = true/)
|
assert.match(source, /if \(autoOpen\) feeDialogOpen\.value = true/)
|
||||||
assert.match(source, /v-else-if="props\.unavailable \|\| !props\.data"/)
|
assert.match(source, /v-else-if="props\.unavailable \|\| !props\.data"/)
|
||||||
assert.match(source, /平台推送计费重后,可在这里核对并确认/)
|
assert.match(source, /平台推送费用后,可在这里核对并确认/)
|
||||||
assert.match(source, /@closed="emit\('closed'\)"/)
|
assert.match(source, /@closed="emit\('closed'\)"/)
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -30,7 +30,7 @@ test('shows the published merchant inbound, measurement details and customer con
|
|||||||
}
|
}
|
||||||
assert.match(source, /formatInboundMoney\(props\.data\.latestFee\.totalAmount/)
|
assert.match(source, /formatInboundMoney\(props\.data\.latestFee\.totalAmount/)
|
||||||
assert.match(source, /formatConversionPrecision\(/)
|
assert.match(source, /formatConversionPrecision\(/)
|
||||||
assert.match(source, /确认费用/)
|
assert.match(source, /title="确认计费重"/)
|
||||||
assert.match(source, /确认后当前费用版本将锁定/)
|
assert.match(source, /确认后当前费用版本将锁定/)
|
||||||
assert.match(source, /customerConfirmationStatus === 'CONFIRMED'/)
|
assert.match(source, /customerConfirmationStatus === 'CONFIRMED'/)
|
||||||
assert.match(source, /confirmMerchantInboundFee/)
|
assert.match(source, /confirmMerchantInboundFee/)
|
||||||
|
|||||||
@@ -77,7 +77,7 @@ async function confirmFee() {
|
|||||||
<el-tag :type="props.data.latestFee.customerConfirmationStatus === 'CONFIRMED' ? 'success' : 'warning'" effect="light">
|
<el-tag :type="props.data.latestFee.customerConfirmationStatus === 'CONFIRMED' ? 'success' : 'warning'" effect="light">
|
||||||
{{ props.data.latestFee.customerConfirmationStatus === 'CONFIRMED' ? '客户已确认 · 费用已锁定' : '费用已发布 · 待确认' }}
|
{{ props.data.latestFee.customerConfirmationStatus === 'CONFIRMED' ? '客户已确认 · 费用已锁定' : '费用已发布 · 待确认' }}
|
||||||
</el-tag>
|
</el-tag>
|
||||||
<el-button v-if="props.data.latestFee.customerConfirmationStatus !== 'CONFIRMED' && props.canConfirm" type="primary" @click="feeDialogOpen = true">确认费用</el-button>
|
<el-button v-if="props.data.latestFee.customerConfirmationStatus !== 'CONFIRMED' && props.canConfirm" type="primary" @click="feeDialogOpen = true">确认计费重</el-button>
|
||||||
<el-button v-else plain @click="feeDialogOpen = true">查看费用</el-button>
|
<el-button v-else plain @click="feeDialogOpen = true">查看费用</el-button>
|
||||||
</div>
|
</div>
|
||||||
</header>
|
</header>
|
||||||
@@ -198,19 +198,19 @@ async function confirmFee() {
|
|||||||
|
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
<el-dialog v-model="feeDialogOpen" class="billing-confirm-dialog" title="确认测量与计费数据" width="min(1180px, calc(100vw - 40px))" append-to-body @closed="emit('closed')">
|
<el-dialog v-model="feeDialogOpen" class="billing-confirm-dialog" title="确认计费重" width="min(1180px, calc(100vw - 40px))" append-to-body @closed="emit('closed')">
|
||||||
<div v-if="props.loading" class="inbound-billing-loading" aria-live="polite" aria-busy="true">
|
<div v-if="props.loading" class="inbound-billing-loading" aria-live="polite" aria-busy="true">
|
||||||
<el-skeleton :rows="4" animated />
|
<el-skeleton :rows="4" animated />
|
||||||
<span class="sr-only">正在加载计费重</span>
|
<span class="sr-only">正在加载费用</span>
|
||||||
</div>
|
</div>
|
||||||
<div v-else-if="props.error" class="inbound-billing-state is-error" role="alert">
|
<div v-else-if="props.error" class="inbound-billing-state is-error" role="alert">
|
||||||
<TriangleAlert :size="22" />
|
<TriangleAlert :size="22" />
|
||||||
<div><strong>计费重加载失败</strong><span>{{ props.error }}</span></div>
|
<div><strong>费用加载失败</strong><span>{{ props.error }}</span></div>
|
||||||
<el-button @click="$emit('retry')"><RefreshCw :size="15" />重新加载</el-button>
|
<el-button @click="$emit('retry')"><RefreshCw :size="15" />重新加载</el-button>
|
||||||
</div>
|
</div>
|
||||||
<div v-else-if="props.unavailable || !props.data" class="inbound-billing-state is-pending" role="status">
|
<div v-else-if="props.unavailable || !props.data" class="inbound-billing-state is-pending" role="status">
|
||||||
<Clock3 :size="22" />
|
<Clock3 :size="22" />
|
||||||
<div><strong>{{ props.unavailableMessage }}</strong><span>平台推送计费重后,可在这里核对并确认。</span></div>
|
<div><strong>{{ props.unavailableMessage }}</strong><span>平台推送费用后,可在这里核对并确认。</span></div>
|
||||||
</div>
|
</div>
|
||||||
<template v-else>
|
<template v-else>
|
||||||
<dl class="fee-dialog-summary" aria-label="计费汇总">
|
<dl class="fee-dialog-summary" aria-label="计费汇总">
|
||||||
|
|||||||
@@ -26,14 +26,14 @@ function stageState(index: number) {
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<p v-if="order.status === 'CANCELLED'" class="draft-progress-note">订单已取消,不再继续履约。</p>
|
<p v-if="order.status === 'CANCELLED'" class="draft-progress-note">订单已取消</p>
|
||||||
<ol v-else class="progress-stages" aria-label="订单主状态阶段">
|
<ol v-else class="progress-stages" aria-label="订单主状态阶段">
|
||||||
<li v-for="(stage, index) in FIRST_LEG_PROGRESS_STAGES" :key="stage.code" :class="stageState(index)" :aria-current="index === currentIndex ? 'step' : undefined">
|
<li v-for="(stage, index) in FIRST_LEG_PROGRESS_STAGES" :key="stage.code" :class="stageState(index)" :aria-current="index === currentIndex ? 'step' : undefined">
|
||||||
<span class="stage-marker" aria-hidden="true"><Check v-if="index < currentIndex" :size="13" /><CircleDot v-else :size="13" /></span>
|
<span class="stage-marker" aria-hidden="true"><Check v-if="index < currentIndex" :size="13" /><CircleDot v-else :size="13" /></span>
|
||||||
<span class="stage-label">{{ stage.label }}</span>
|
<span class="stage-label">{{ stage.label }}</span>
|
||||||
</li>
|
</li>
|
||||||
</ol>
|
</ol>
|
||||||
<p v-if="order.status === 'DRAFT'" class="draft-progress-note">订单提交后开始记录主状态进度。</p>
|
<p v-if="order.status === 'DRAFT'" class="draft-progress-note">待提交</p>
|
||||||
<div v-if="order.status !== 'CANCELLED'" class="progress-cabinet-detail"><slot name="cabinet" /></div>
|
<div v-if="order.status !== 'CANCELLED'" class="progress-cabinet-detail"><slot name="cabinet" /></div>
|
||||||
</section>
|
</section>
|
||||||
</template>
|
</template>
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ function time(value: string | null) { return value ? value.replace('T', ' ') : '
|
|||||||
<el-table-column prop="location" label="地点" min-width="130" />
|
<el-table-column prop="location" label="地点" min-width="130" />
|
||||||
<el-table-column prop="source" label="来源" width="105" />
|
<el-table-column prop="source" label="来源" width="105" />
|
||||||
</el-table>
|
</el-table>
|
||||||
<p v-else>暂无实际装载片段的运输节点。预计时间不表示实际发生。</p>
|
<p v-else>暂无运输节点</p>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
|||||||
@@ -128,41 +128,25 @@ test('cancelled detail summary has no pending overseas synchronization entries',
|
|||||||
assert.deepEqual(summary, [])
|
assert.deepEqual(summary, [])
|
||||||
})
|
})
|
||||||
|
|
||||||
test('edit freezes detail version rather than cached list version and replays same key/body after uncertain result', async t => {
|
test('edit preserves the detail version but generates a fresh command after failure', async t => {
|
||||||
const h = harness(t)
|
const h = harness(t), session = h.store.beginDraftEdit(await h.store.loadDraftDetail('one'))
|
||||||
const original = await h.store.loadDraftDetail('one')
|
h.store.orders = [{ id: 'one', version: 0 }]; h.behavior.failWrite = true
|
||||||
const session = h.store.beginDraftEdit(original)
|
await assert.rejects(h.store.saveDraft(h.draft, '客户', 'one', session), /响应丢失/)
|
||||||
h.store.orders = [{ ...original, version: 0 }]
|
h.behavior.failWrite = false; h.draft.customerRemark = '已修改'
|
||||||
h.behavior.failWrite = true
|
await h.store.saveDraft(h.draft, '客户', 'one', session)
|
||||||
await assert.rejects(h.store.saveDraft(h.draft, '测试企业', 'one', session), /响应丢失/)
|
|
||||||
const first = h.calls.find(call => call.method === 'PUT')
|
|
||||||
assert.equal(first.data.expectedVersion, 9)
|
|
||||||
assert.equal(first.data.draft.customerRemark, '原草稿')
|
|
||||||
assert.ok(first.headers['Idempotency-Key'])
|
|
||||||
assert.deepEqual(h.calls.map(call => call.method), ['GET', 'PUT'], 'no pre-save version refresh')
|
|
||||||
h.behavior.failWrite = false; h.behavior.version = 10
|
|
||||||
const result = await h.store.saveDraft(h.draft, '测试企业', 'one', session)
|
|
||||||
const writes = h.calls.filter(call => call.method === 'PUT')
|
const writes = h.calls.filter(call => call.method === 'PUT')
|
||||||
assert.deepEqual(writes[1], first)
|
assert.equal(writes[0].data.expectedVersion, 9); assert.equal(writes[1].data.draft.customerRemark, '已修改')
|
||||||
assert.deepEqual(h.calls.map(call => call.method), ['GET', 'PUT', 'GET', 'PUT', 'GET'])
|
assert.notEqual(writes[0].headers['Idempotency-Key'], writes[1].headers['Idempotency-Key'])
|
||||||
assert.equal(result.version, 10)
|
|
||||||
})
|
})
|
||||||
|
test('missing edit session is invalid while changed inputs after failure are accepted', async t => {
|
||||||
test('changed retry payload or missing edit session fails closed without issuing a new write', async t => {
|
const h = harness(t); await assert.rejects(h.store.saveDraft(h.draft, '客户', 'one'), /重新打开/)
|
||||||
const h = harness(t)
|
const session = h.store.beginDraftEdit(await h.store.loadDraftDetail('one')); h.behavior.failWrite = true
|
||||||
await assert.rejects(h.store.saveDraft(h.draft, '客户', 'one'), /重新打开/)
|
|
||||||
assert.equal(h.calls.length, 0)
|
|
||||||
const session = h.store.beginDraftEdit(await h.store.loadDraftDetail('one'))
|
|
||||||
h.behavior.failWrite = true
|
|
||||||
await assert.rejects(h.store.saveDraft(h.draft, '客户', 'one', session))
|
await assert.rejects(h.store.saveDraft(h.draft, '客户', 'one', session))
|
||||||
h.draft.customerRemark = '不同内容'
|
h.draft.customerRemark = '不同内容'; h.behavior.failWrite = false
|
||||||
await assert.rejects(h.store.saveDraft(h.draft, '客户', 'one', session), /重试原内容/)
|
await h.store.saveDraft(h.draft, '客户', 'one', session)
|
||||||
assert.equal(h.calls.filter(call => call.method === 'PUT').length, 1)
|
assert.equal(h.calls.filter(call => call.method === 'PUT').length, 2)
|
||||||
assert.equal(session.expectedVersion, 9)
|
|
||||||
assert.ok(Object.isFrozen(session))
|
|
||||||
})
|
})
|
||||||
|
test('read failure after edit does not retain a frozen request', async t => {
|
||||||
test('read failure after successful edit preserves the same command for retry', async t => {
|
|
||||||
const h = harness(t)
|
const h = harness(t)
|
||||||
const session = h.store.beginDraftEdit(await h.store.loadDraftDetail('one'))
|
const session = h.store.beginDraftEdit(await h.store.loadDraftDetail('one'))
|
||||||
h.behavior.failRead = true
|
h.behavior.failRead = true
|
||||||
@@ -170,28 +154,17 @@ test('read failure after successful edit preserves the same command for retry',
|
|||||||
h.behavior.failRead = false
|
h.behavior.failRead = false
|
||||||
await h.store.saveDraft(h.draft, '客户', 'one', session)
|
await h.store.saveDraft(h.draft, '客户', 'one', session)
|
||||||
const writes = h.calls.filter(call => call.method === 'PUT')
|
const writes = h.calls.filter(call => call.method === 'PUT')
|
||||||
assert.deepEqual(writes[0], writes[1])
|
assert.notEqual(writes[0].headers['Idempotency-Key'], writes[1].headers['Idempotency-Key'])
|
||||||
})
|
})
|
||||||
|
|
||||||
test('cancel forwards version and reason without rejecting submitted orders locally; retry keeps key and body', async t => {
|
test('cancel submits the current version and reason after a previous failure', async t => {
|
||||||
const h = harness(t)
|
const h = harness(t); h.behavior.status = 'SUBMITTED'; h.behavior.failWrite = true
|
||||||
h.behavior.status = 'SUBMITTED'
|
|
||||||
h.store.orders = [{ id: 'one', status: 'PENDING_REVIEW', version: 0 }]
|
|
||||||
h.behavior.failWrite = true
|
|
||||||
await assert.rejects(h.store.cancelOrder('one', 12, '客户要求取消'), /响应丢失/)
|
await assert.rejects(h.store.cancelOrder('one', 12, '客户要求取消'), /响应丢失/)
|
||||||
const first = h.calls[0]
|
h.behavior.failWrite = false; await h.store.cancelOrder('one', 13, '其他原因')
|
||||||
assert.equal(first.method, 'POST')
|
const writes = h.calls.filter(call => call.method === 'POST')
|
||||||
assert.equal(first.url, '/merchant/v1/orders/first-leg/one/cancel')
|
assert.equal(writes.length, 2); assert.deepEqual(writes[1].data, { expectedVersion: 13, reason: '其他原因' })
|
||||||
assert.deepEqual(first.data, { expectedVersion: 12, reason: '客户要求取消' })
|
assert.notEqual(writes[0].headers['Idempotency-Key'], writes[1].headers['Idempotency-Key'])
|
||||||
await assert.rejects(h.store.cancelOrder('one', 13, '其他原因'), /原版本和原因/)
|
|
||||||
assert.equal(h.calls.length, 1)
|
|
||||||
h.behavior.failWrite = false
|
|
||||||
await h.store.cancelOrder('one', 12, '客户要求取消')
|
|
||||||
assert.deepEqual(h.calls[2], first)
|
|
||||||
assert.equal(h.calls[1].method, 'GET')
|
|
||||||
assert.equal(h.store.orders.length, 0)
|
|
||||||
})
|
})
|
||||||
|
|
||||||
test('cancel requires a detail version and a nonempty reason', async t => {
|
test('cancel requires a detail version and a nonempty reason', async t => {
|
||||||
const h = harness(t)
|
const h = harness(t)
|
||||||
await assert.rejects(h.store.cancelOrder('one', undefined, '理由'))
|
await assert.rejects(h.store.cancelOrder('one', undefined, '理由'))
|
||||||
@@ -252,24 +225,13 @@ test('cancel UI uses mandatory-reason centered prompt and refreshes after succes
|
|||||||
assert.deepEqual(h.calls[1], ['cancel', 'one', 12, '客户申请取消'])
|
assert.deepEqual(h.calls[1], ['cancel', 'one', 12, '客户申请取消'])
|
||||||
})
|
})
|
||||||
|
|
||||||
test('cancel UI keeps an uncertain command for explicit retry, but conflict requires a fresh decision', async () => {
|
test('cancel UI releases failure and asks for a current cancellation decision on the next click', async () => {
|
||||||
const h = cancellationViewHarness()
|
const h = cancellationViewHarness(), order = { id: 'one', status: 'DRAFT' }
|
||||||
const order = { id: 'one', status: 'DRAFT' }
|
h.behavior.error = new Error('网络无响应'); await h.handler(order)
|
||||||
h.behavior.error = new Error('网络无响应')
|
h.behavior.error = null; await h.handler(order)
|
||||||
await h.handler(order)
|
assert.equal(h.prompts.length, 2); assert.equal(h.calls.filter(call => call[0] === 'prepare').length, 2)
|
||||||
assert.equal(h.pendingCancellation.value.expectedVersion, 12)
|
assert.equal(h.calls.filter(call => call[0] === 'cancel').length, 2)
|
||||||
h.behavior.error = null
|
|
||||||
await h.handler(order)
|
|
||||||
assert.equal(h.prompts.length, 1)
|
|
||||||
assert.equal(h.calls.filter(call => call[0] === 'prepare').length, 1)
|
|
||||||
assert.equal(h.calls.filter(call => call[0] === 'confirm').length, 1)
|
|
||||||
assert.deepEqual(h.calls.filter(call => call[0] === 'cancel')[0], h.calls.filter(call => call[0] === 'cancel')[1])
|
|
||||||
h.behavior.error = new h.ApiError()
|
|
||||||
await h.handler(order)
|
|
||||||
assert.equal(h.pendingCancellation.value, undefined)
|
|
||||||
assert.match(h.messages.at(-1), /刷新订单后重新确认/)
|
|
||||||
})
|
})
|
||||||
|
|
||||||
test('cancel UI blocks unavailable permission and irreversible visible stages before reads or writes', async () => {
|
test('cancel UI blocks unavailable permission and irreversible visible stages before reads or writes', async () => {
|
||||||
const h = cancellationViewHarness()
|
const h = cancellationViewHarness()
|
||||||
h.canCancelOrder.value = false
|
h.canCancelOrder.value = false
|
||||||
@@ -286,23 +248,14 @@ test('both editor entry points capture detail sessions and both save paths pass
|
|||||||
assert.equal((view.match(/store\.saveDraft(?:ForSubmission)?\(cloneDraft\(form\), tenantStore\.company\.companyName, editingId\.value, editingSession\.value\)/g) ?? []).length, 2)
|
assert.equal((view.match(/store\.saveDraft(?:ForSubmission)?\(cloneDraft\(form\), tenantStore\.company\.companyName, editingId\.value, editingSession\.value\)/g) ?? []).length, 2)
|
||||||
})
|
})
|
||||||
|
|
||||||
test('submit reads raw detail version rather than list zero and replays original key and version after timeout', async t => {
|
test('submit uses the current raw version and a fresh key after timeout', async t => {
|
||||||
const h = harness(t)
|
const h = harness(t); h.store.orders = [{id:'one',status:'DRAFT',version:0}]; h.behavior.failSubmit = true
|
||||||
h.store.orders = [{ id: 'one', status: 'DRAFT', version: 0 }]
|
|
||||||
h.behavior.failSubmit = true
|
|
||||||
await assert.rejects(h.store.submitSaved('one', 'ACTIVE'), /响应丢失/)
|
await assert.rejects(h.store.submitSaved('one', 'ACTIVE'), /响应丢失/)
|
||||||
const first = h.calls[1]
|
h.behavior.version = 10; h.behavior.failSubmit = false; await h.store.submitSaved('one', 'ACTIVE')
|
||||||
assert.equal(first.url, '/merchant/v1/orders/first-leg/one/submit')
|
const writes = h.calls.filter(call => call.url.endsWith('/submit'))
|
||||||
assert.deepEqual(first.data, { expectedVersion: 9 })
|
assert.deepEqual(writes.map(call => call.data.expectedVersion), [9,10]); assert.notEqual(writes[0].headers['Idempotency-Key'],writes[1].headers['Idempotency-Key'])
|
||||||
assert.ok(first.headers['Idempotency-Key'])
|
|
||||||
h.behavior.version = 10; h.behavior.status = 'SUBMITTED'; h.behavior.failSubmit = false
|
|
||||||
await h.store.submitSaved('one', 'ACTIVE')
|
|
||||||
assert.deepEqual(h.calls[3], first)
|
|
||||||
assert.deepEqual(h.calls.map(call => call.method), ['GET', 'POST', 'GET', 'POST', 'GET'])
|
|
||||||
assert.equal(h.store.hasPendingSubmission('one'), false)
|
|
||||||
})
|
})
|
||||||
|
test('submit validates current status and releases failure after readback', async t => {
|
||||||
test('submit refuses missing version or non-draft first decision and preserves command after failed readback', async t => {
|
|
||||||
const h = harness(t)
|
const h = harness(t)
|
||||||
for (const version of [undefined, -1, 1.5]) {
|
for (const version of [undefined, -1, 1.5]) {
|
||||||
h.behavior.version = version
|
h.behavior.version = version
|
||||||
@@ -313,49 +266,25 @@ test('submit refuses missing version or non-draft first decision and preserves c
|
|||||||
assert.ok(h.calls.every(call => call.method === 'GET'))
|
assert.ok(h.calls.every(call => call.method === 'GET'))
|
||||||
h.behavior.status = 'DRAFT'; h.behavior.failSubmitRead = true
|
h.behavior.status = 'DRAFT'; h.behavior.failSubmitRead = true
|
||||||
await assert.rejects(h.store.submitSaved('one'), /读取失败/)
|
await assert.rejects(h.store.submitSaved('one'), /读取失败/)
|
||||||
assert.equal(h.store.hasPendingSubmission('one'), true)
|
|
||||||
h.behavior.failRead = false; h.behavior.failSubmitRead = false
|
h.behavior.failRead = false; h.behavior.failSubmitRead = false
|
||||||
await h.store.submitSaved('one')
|
await h.store.submitSaved('one')
|
||||||
const posts = h.calls.filter(call => call.method === 'POST')
|
const posts = h.calls.filter(call => call.method === 'POST')
|
||||||
assert.deepEqual(posts[0], posts[1])
|
assert.notEqual(posts[0].headers['Idempotency-Key'], posts[1].headers['Idempotency-Key'])
|
||||||
assert.deepEqual(posts[0].data, { expectedVersion: 0 }, 'raw detail zero is valid')
|
assert.deepEqual(posts[0].data, { expectedVersion: 0 }, 'raw detail zero is valid')
|
||||||
})
|
})
|
||||||
|
|
||||||
test('save then submit retries without another save and changed form requires an explicit new decision', async t => {
|
test('failed submit leaves the draft editable for a fresh save and submission', async t => {
|
||||||
const h = harness(t)
|
const h = harness(t), session = h.store.beginDraftEdit(await h.store.loadDraftDetail('one'))
|
||||||
const session = h.store.beginDraftEdit(await h.store.loadDraftDetail('one'))
|
await h.store.saveDraft(h.draft, '客户', 'one', session); h.behavior.failSubmit = true
|
||||||
await h.store.saveDraftForSubmission(h.draft, '客户', 'one', session)
|
await assert.rejects(h.store.submitSaved('one')); h.draft.customerRemark = '新内容'
|
||||||
h.behavior.failSubmit = true
|
await h.store.saveDraft(h.draft, '客户', 'one', session); h.behavior.failSubmit = false
|
||||||
await assert.rejects(h.store.submitSaved('one'))
|
await h.store.submitSaved('one'); assert.equal(h.calls.filter(call => call.method === 'PUT').length, 2)
|
||||||
const first = h.calls.find(call => call.url.endsWith('/submit'))
|
|
||||||
await h.store.saveDraftForSubmission(h.draft, '客户', 'one', session)
|
|
||||||
assert.equal(h.calls.filter(call => call.method === 'PUT').length, 1)
|
|
||||||
h.draft.customerRemark = '新决定'
|
|
||||||
await assert.rejects(h.store.saveDraftForSubmission(h.draft, '客户', 'one', session), /重新编辑/)
|
|
||||||
h.behavior.status = 'SUBMITTED'
|
|
||||||
await assert.rejects(h.store.beginNewSubmissionEdit('one'), /不能重新编辑/)
|
|
||||||
assert.equal(h.store.hasPendingSubmission('one'), true)
|
|
||||||
h.behavior.status = 'DRAFT'; h.behavior.version = 12
|
|
||||||
const newSession = await h.store.beginNewSubmissionEdit('one')
|
|
||||||
assert.equal(newSession.expectedVersion, 12)
|
|
||||||
await h.store.saveDraftForSubmission(h.draft, '客户', 'one', newSession)
|
|
||||||
h.behavior.version = 13; h.behavior.failSubmit = false
|
|
||||||
await h.store.submitSaved('one')
|
|
||||||
const posts = h.calls.filter(call => call.url.endsWith('/submit'))
|
|
||||||
assert.notEqual(posts[1].headers['Idempotency-Key'], first.headers['Idempotency-Key'])
|
|
||||||
assert.deepEqual(posts[1].data, { expectedVersion: 13 })
|
|
||||||
})
|
})
|
||||||
|
test('failed initial submit read releases the submission guard for the next click', async t => {
|
||||||
test('failed initial submit read does not resave the prepared draft on retry', async t => {
|
const h = harness(t); h.behavior.failRead = true; await assert.rejects(h.store.submitSaved('one'))
|
||||||
const h = harness(t)
|
h.behavior.failRead = false; await h.store.submitSaved('one')
|
||||||
const session = h.store.beginDraftEdit(await h.store.loadDraftDetail('one'))
|
assert.equal(h.calls.filter(call => call.url.endsWith('/submit')).length, 1)
|
||||||
await h.store.saveDraftForSubmission(h.draft, '客户', 'one', session)
|
|
||||||
h.behavior.failRead = true
|
|
||||||
await assert.rejects(h.store.submitSaved('one'))
|
|
||||||
await h.store.saveDraftForSubmission(h.draft, '客户', 'one', session)
|
|
||||||
assert.equal(h.calls.filter(call => call.method === 'PUT').length, 1)
|
|
||||||
})
|
})
|
||||||
|
|
||||||
async function submissionViewHarness(t) {
|
async function submissionViewHarness(t) {
|
||||||
const h = harness(t)
|
const h = harness(t)
|
||||||
const source = readFileSync(new URL('../views/FirstLegOrdersView.vue', import.meta.url), 'utf8').match(/<script setup lang="ts">([\s\S]*?)<\/script>/)[1]
|
const source = readFileSync(new URL('../views/FirstLegOrdersView.vue', import.meta.url), 'utf8').match(/<script setup lang="ts">([\s\S]*?)<\/script>/)[1]
|
||||||
@@ -377,56 +306,29 @@ async function submissionViewHarness(t) {
|
|||||||
return { ...h, ...handlers, globals, messages, confirmations }
|
return { ...h, ...handlers, globals, messages, confirmations }
|
||||||
}
|
}
|
||||||
|
|
||||||
test('real editor submit handler retries original submission without PUT and requires confirmation for changed form', async t => {
|
test('real editor releases failure and saves current edited input on another click', async t => {
|
||||||
const h = await submissionViewHarness(t)
|
const h = await submissionViewHarness(t); h.behavior.failSubmit = true
|
||||||
h.behavior.failSubmit = true
|
await h.submitOrder(); assert.equal(h.globals.saving.value, false)
|
||||||
await h.submitOrder()
|
h.draft.customerRemark = '修改后的决定'; h.behavior.failSubmit = false; await h.submitOrder()
|
||||||
await h.submitOrder()
|
const writes = h.calls.filter(call => call.method === 'PUT'), posts = h.calls.filter(call => call.url.endsWith('/submit'))
|
||||||
assert.equal(h.calls.filter(call => call.method === 'PUT').length, 1)
|
assert.equal(writes.length, 2); assert.equal(writes[1].data.draft.customerRemark, '修改后的决定')
|
||||||
const posts = h.calls.filter(call => call.url.endsWith('/submit'))
|
assert.notEqual(posts[0].headers['Idempotency-Key'], posts[1].headers['Idempotency-Key']); assert.equal(h.globals.saving.value, false)
|
||||||
assert.deepEqual(posts[0], posts[1])
|
|
||||||
h.draft.customerRemark = '修改后的决定'
|
|
||||||
h.behavior.cancelConfirm = true
|
|
||||||
await h.submitOrder()
|
|
||||||
assert.equal(h.confirmations.length, 1)
|
|
||||||
assert.equal(h.calls.filter(call => call.method === 'PUT').length, 1)
|
|
||||||
h.behavior.cancelConfirm = false; h.behavior.failSubmit = false; h.behavior.version = 12
|
|
||||||
await h.submitOrder()
|
|
||||||
assert.equal(h.confirmations.length, 2)
|
|
||||||
assert.equal(h.calls.filter(call => call.method === 'PUT').length, 2)
|
|
||||||
const last = h.calls.filter(call => call.url.endsWith('/submit')).at(-1)
|
|
||||||
assert.deepEqual(last.data, { expectedVersion: 12 })
|
|
||||||
assert.notEqual(last.headers['Idempotency-Key'], posts[0].headers['Idempotency-Key'])
|
|
||||||
assert.equal(h.globals.saving.value, false)
|
|
||||||
})
|
})
|
||||||
|
test('real batch handler uses only current selection after a failed batch', async t => {
|
||||||
test('real batch handler retains uncertain IDs across list refresh and retries original commands even if now submitted', async t => {
|
const h = await submissionViewHarness(t); h.behavior.failSubmit = true
|
||||||
const h = await submissionViewHarness(t)
|
await h.submitSelectedDraftOrders(); assert.equal(h.globals.batchSubmitting.value, false)
|
||||||
h.behavior.failSubmit = true
|
h.behavior.failSubmit = false; await h.submitSelectedDraftOrders()
|
||||||
await h.submitSelectedDraftOrders()
|
assert.equal(h.calls.filter(call => call.url.endsWith('/submit')).length, 1)
|
||||||
assert.deepEqual(h.globals.pendingBatchSubmissionIds.value, ['one'])
|
h.globals.selectedDraftOrders.value = [{id:'one',version:9}]; await h.submitSelectedDraftOrders()
|
||||||
assert.deepEqual(h.globals.selectedDraftOrders.value, [])
|
|
||||||
h.behavior.failSubmit = false; h.behavior.status = 'SUBMITTED'; h.behavior.version = 10
|
|
||||||
await h.submitSelectedDraftOrders()
|
|
||||||
const posts = h.calls.filter(call => call.url.endsWith('/submit'))
|
const posts = h.calls.filter(call => call.url.endsWith('/submit'))
|
||||||
assert.equal(posts.length, 2)
|
assert.equal(posts.length, 2); assert.notEqual(posts[0].headers['Idempotency-Key'], posts[1].headers['Idempotency-Key'])
|
||||||
assert.deepEqual(posts[1], posts[0])
|
|
||||||
assert.deepEqual(posts[0].data, { expectedVersion: 9 })
|
|
||||||
assert.deepEqual(h.globals.pendingBatchSubmissionIds.value, [])
|
|
||||||
assert.equal(h.globals.batchSubmitting.value, false)
|
|
||||||
})
|
})
|
||||||
|
test('real new-order handler retains the created order and saves current edits after submit failure', async t => {
|
||||||
test('real new-order handler creates once and retries the saved order submission with the original version', async t => {
|
const h = await submissionViewHarness(t); h.globals.editingId.value = undefined; h.globals.editingSession.value = undefined
|
||||||
const h = await submissionViewHarness(t)
|
h.behavior.version = 0; h.behavior.failSubmit = true; await h.submitOrder()
|
||||||
h.globals.editingId.value = undefined; h.globals.editingSession.value = undefined
|
assert.equal(h.globals.editingId.value, 'one'); h.behavior.failSubmit = false; h.draft.customerRemark = '修改'
|
||||||
h.behavior.version = 0; h.behavior.failSubmit = true
|
|
||||||
await h.submitOrder()
|
|
||||||
assert.equal(h.globals.editingId.value, 'one')
|
|
||||||
h.behavior.version = 1; h.behavior.status = 'SUBMITTED'; h.behavior.failSubmit = false
|
|
||||||
await h.submitOrder()
|
await h.submitOrder()
|
||||||
assert.equal(h.calls.filter(call => call.method === 'POST' && call.url === '/merchant/v1/orders/first-leg').length, 1)
|
assert.equal(h.calls.filter(call => call.method === 'POST' && call.url === '/merchant/v1/orders/first-leg').length, 1)
|
||||||
assert.equal(h.calls.filter(call => call.method === 'PUT').length, 0)
|
assert.equal(h.calls.filter(call => call.method === 'PUT').length, 1)
|
||||||
const posts = h.calls.filter(call => call.url.endsWith('/submit'))
|
assert.equal(h.calls.filter(call => call.url.endsWith('/submit')).length, 2)
|
||||||
assert.deepEqual(posts[0], posts[1])
|
|
||||||
assert.deepEqual(posts[0].data, { expectedVersion: 0 })
|
|
||||||
})
|
})
|
||||||
@@ -220,7 +220,7 @@ test('only blocks submission when a known company audit status is not active', (
|
|||||||
})
|
})
|
||||||
|
|
||||||
test('uses the versioned merchant cancellation contract', () => {
|
test('uses the versioned merchant cancellation contract', () => {
|
||||||
assert.match(storeSource, /cancelMerchantFirstLegOrder\(id, pending\.payload, pending\.key\)/)
|
assert.match(storeSource, /cancelMerchantFirstLegOrder\(id, payload, createIdempotencyKey\(/)
|
||||||
assert.match(apiSource, /cancelMerchantFirstLegOrder\(id: number \| string, payload: \{ expectedVersion: number; reason: string \}, idempotencyKey: string\)/)
|
assert.match(apiSource, /cancelMerchantFirstLegOrder\(id: number \| string, payload: \{ expectedVersion: number; reason: string \}, idempotencyKey: string\)/)
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -231,8 +231,8 @@ test('sends an idempotency key for create and submit writes', () => {
|
|||||||
assert.match(apiSource, /createMerchantFirstLegOrderBatch\(items: MerchantBatchDraftItem\[\], idempotencyKey: string\)/)
|
assert.match(apiSource, /createMerchantFirstLegOrderBatch\(items: MerchantBatchDraftItem\[\], idempotencyKey: string\)/)
|
||||||
assert.match(apiSource, /headers: \{ 'Idempotency-Key': idempotencyKey \}/)
|
assert.match(apiSource, /headers: \{ 'Idempotency-Key': idempotencyKey \}/)
|
||||||
assert.match(storeSource, /createMerchantFirstLegOrderBatch\(items, idempotencyKey\)/)
|
assert.match(storeSource, /createMerchantFirstLegOrderBatch\(items, idempotencyKey\)/)
|
||||||
assert.match(storeSource, /pendingSubmissions\.get\(id\)/)
|
assert.doesNotMatch(storeSource, /pendingSubmissions|pendingEdits|pendingCancellation/)
|
||||||
assert.match(storeSource, /submitMerchantFirstLegOrder\(id, pending\.payload, pending\.key\)/)
|
assert.match(storeSource, /submitMerchantFirstLegOrder\(id, \{ expectedVersion: order\.version \}, createIdempotencyKey\(/)
|
||||||
})
|
})
|
||||||
|
|
||||||
test('does not expose the contradictory backend rejected state in the client model', () => {
|
test('does not expose the contradictory backend rejected state in the client model', () => {
|
||||||
|
|||||||
@@ -404,11 +404,7 @@ export const useFirstLegOrdersStore = defineStore('client-first-leg-orders', ()
|
|||||||
const orderProgress = ref<Record<string, MerchantOrderProgress>>({})
|
const orderProgress = ref<Record<string, MerchantOrderProgress>>({})
|
||||||
const queryChannelNames = ref<string[]>([])
|
const queryChannelNames = ref<string[]>([])
|
||||||
let listRequest = 0
|
let listRequest = 0
|
||||||
const pendingSubmissions = new Map<string, { key: string; payload: { expectedVersion: number } }>()
|
|
||||||
const submissionForms = new Map<string, { snapshot: string; order: FirstLegOrder }>()
|
|
||||||
const submittingIds = new Set<string>()
|
const submittingIds = new Set<string>()
|
||||||
const pendingEdits = new WeakMap<DraftEditSession, { key: string; payload: { expectedVersion: number; draft: FirstLegOrderSaveRequest } }>()
|
|
||||||
const pendingCancellations = new Map<string, { key: string; payload: { expectedVersion: number; reason: string } }>()
|
|
||||||
|
|
||||||
function beginDraftEdit(detail: FirstLegOrder): DraftEditSession {
|
function beginDraftEdit(detail: FirstLegOrder): DraftEditSession {
|
||||||
if (!canClientEditFirstLegOrder(detail.status) || !Number.isSafeInteger(detail.version) || detail.version < 0) throw new Error('请重新打开草稿详情后编辑')
|
if (!canClientEditFirstLegOrder(detail.status) || !Number.isSafeInteger(detail.version) || detail.version < 0) throw new Error('请重新打开草稿详情后编辑')
|
||||||
@@ -534,22 +530,12 @@ export const useFirstLegOrdersStore = defineStore('client-first-leg-orders', ()
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function saveDraft(draft: FirstLegOrderDraft, customerName: string, id?: string, editSession?: DraftEditSession) {
|
async function saveDraft(draft: FirstLegOrderDraft, customerName: string, id?: string, editSession?: DraftEditSession) {
|
||||||
if (hasPendingSubmission(id)) throw new Error('上次提交结果未确认,请重试原提交,或确认重新编辑后再保存')
|
|
||||||
const warehouse = prepareDraftForSave(draft, warehouses.value)
|
const warehouse = prepareDraftForSave(draft, warehouses.value)
|
||||||
if (id) {
|
if (id) {
|
||||||
if (!editSession || editSession.orderId !== id) throw new Error('请重新打开草稿详情后编辑')
|
if (!editSession || editSession.orderId !== id) throw new Error('请重新打开草稿详情后编辑')
|
||||||
const payload = { expectedVersion: editSession.expectedVersion, draft: savePayload(draft, warehouse, customerName) }
|
const payload = { expectedVersion: editSession.expectedVersion, draft: savePayload(draft, warehouse, customerName) }
|
||||||
let pending = pendingEdits.get(editSession)
|
await updateMerchantFirstLegOrder(id, payload, createIdempotencyKey(`first-leg-edit-${id}`))
|
||||||
if (pending && JSON.stringify(pending.payload) !== JSON.stringify(payload)) throw new Error('上次保存结果未确认,请重试原内容,或重新打开详情后编辑')
|
|
||||||
// Observe an uncertain previous outcome without replacing its frozen version.
|
|
||||||
if (pending) await getMerchantFirstLegOrder(id)
|
|
||||||
if (!pending) {
|
|
||||||
pending = { key: createIdempotencyKey(`first-leg-edit-${id}`), payload: JSON.parse(JSON.stringify(payload)) }
|
|
||||||
pendingEdits.set(editSession, pending)
|
|
||||||
}
|
|
||||||
await updateMerchantFirstLegOrder(id, pending.payload, pending.key)
|
|
||||||
const saved = await loadOrderAggregate(id)
|
const saved = await loadOrderAggregate(id)
|
||||||
pendingEdits.delete(editSession)
|
|
||||||
return saved
|
return saved
|
||||||
}
|
}
|
||||||
const createdId = await createMerchantFirstLegOrder(savePayload(draft, warehouse, customerName))
|
const createdId = await createMerchantFirstLegOrder(savePayload(draft, warehouse, customerName))
|
||||||
@@ -559,15 +545,7 @@ export const useFirstLegOrdersStore = defineStore('client-first-leg-orders', ()
|
|||||||
async function cancelOrder(id: string, expectedVersion: number, reason: string) {
|
async function cancelOrder(id: string, expectedVersion: number, reason: string) {
|
||||||
if (!Number.isSafeInteger(expectedVersion) || expectedVersion < 0 || !reason.trim() || reason.trim().length > 500) throw new Error('取消订单需要详情版本及 1–500 字取消原因')
|
if (!Number.isSafeInteger(expectedVersion) || expectedVersion < 0 || !reason.trim() || reason.trim().length > 500) throw new Error('取消订单需要详情版本及 1–500 字取消原因')
|
||||||
const payload = { expectedVersion, reason: reason.trim() }
|
const payload = { expectedVersion, reason: reason.trim() }
|
||||||
let pending = pendingCancellations.get(id)
|
await cancelMerchantFirstLegOrder(id, payload, createIdempotencyKey(`first-leg-cancel-${id}`))
|
||||||
if (pending && JSON.stringify(pending.payload) !== JSON.stringify(payload)) throw new Error('上次取消结果未确认,请使用原版本和原因重试')
|
|
||||||
if (pending) await getMerchantFirstLegOrder(id)
|
|
||||||
if (!pending) {
|
|
||||||
pending = { key: createIdempotencyKey(`first-leg-cancel-${id}`), payload }
|
|
||||||
pendingCancellations.set(id, pending)
|
|
||||||
}
|
|
||||||
await cancelMerchantFirstLegOrder(id, pending.payload, pending.key)
|
|
||||||
pendingCancellations.delete(id)
|
|
||||||
orders.value = orders.value.filter(order => order.id !== id)
|
orders.value = orders.value.filter(order => order.id !== id)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -576,7 +554,6 @@ export const useFirstLegOrdersStore = defineStore('client-first-leg-orders', ()
|
|||||||
const labels: Record<string, string> = { DRAFT: '草稿', SUBMITTED: '审核中', APPROVED: '已审核', ACCEPTED: '已接单', REJECTED: '已退回' }
|
const labels: Record<string, string> = { DRAFT: '草稿', SUBMITTED: '审核中', APPROVED: '已审核', ACCEPTED: '已接单', REJECTED: '已退回' }
|
||||||
if (!Object.hasOwn(labels, order.status)) throw new Error('当前订单状态不允许取消,请刷新订单查看最新进度')
|
if (!Object.hasOwn(labels, order.status)) throw new Error('当前订单状态不允许取消,请刷新订单查看最新进度')
|
||||||
if (!Number.isSafeInteger(order.version) || order.version < 0) throw new Error('订单版本缺失,请重新加载详情')
|
if (!Number.isSafeInteger(order.version) || order.version < 0) throw new Error('订单版本缺失,请重新加载详情')
|
||||||
pendingCancellations.delete(id)
|
|
||||||
return { id, expectedVersion: order.version, businessNo: order.orderNo || order.inboundCode || '—', statusLabel: labels[order.status] }
|
return { id, expectedVersion: order.version, businessNo: order.orderNo || order.inboundCode || '—', statusLabel: labels[order.status] }
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -597,55 +574,19 @@ export const useFirstLegOrdersStore = defineStore('client-first-leg-orders', ()
|
|||||||
if (submittingIds.has(id)) throw new Error('订单正在提交,请稍候')
|
if (submittingIds.has(id)) throw new Error('订单正在提交,请稍候')
|
||||||
submittingIds.add(id)
|
submittingIds.add(id)
|
||||||
try {
|
try {
|
||||||
let pending = pendingSubmissions.get(id)
|
|
||||||
// Always observe the raw detail; a retry must retain the original command.
|
|
||||||
const { order } = await getMerchantFirstLegOrder(id)
|
const { order } = await getMerchantFirstLegOrder(id)
|
||||||
if (!pending) {
|
|
||||||
if (order.status !== 'DRAFT') throw new Error('当前订单不是草稿,请刷新订单查看最新状态')
|
if (order.status !== 'DRAFT') throw new Error('当前订单不是草稿,请刷新订单查看最新状态')
|
||||||
if (!Number.isSafeInteger(order.version) || order.version < 0) throw new Error('订单版本缺失,请重新加载详情')
|
if (!Number.isSafeInteger(order.version) || order.version < 0) throw new Error('订单版本缺失,请重新加载详情')
|
||||||
pending = { key: createIdempotencyKey(`first-leg-submit-${id}`), payload: { expectedVersion: order.version } }
|
await submitMerchantFirstLegOrder(id, { expectedVersion: order.version }, createIdempotencyKey(`first-leg-submit-${id}`))
|
||||||
pendingSubmissions.set(id, pending)
|
return await loadOrderAggregate(id)
|
||||||
}
|
|
||||||
await submitMerchantFirstLegOrder(id, pending.payload, pending.key)
|
|
||||||
const submitted = await loadOrderAggregate(id)
|
|
||||||
pendingSubmissions.delete(id)
|
|
||||||
submissionForms.delete(id)
|
|
||||||
return submitted
|
|
||||||
} finally {
|
} finally {
|
||||||
submittingIds.delete(id)
|
submittingIds.delete(id)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function hasPendingSubmission(id?: string) { return !!id && (pendingSubmissions.has(id) || submissionForms.has(id)) }
|
|
||||||
|
|
||||||
function isSubmissionRetry(id: string | undefined, draft: FirstLegOrderDraft) {
|
|
||||||
return !!id && hasPendingSubmission(id) && submissionForms.get(id)?.snapshot === JSON.stringify(draft)
|
|
||||||
}
|
|
||||||
|
|
||||||
async function beginNewSubmissionEdit(id: string) {
|
|
||||||
if (submittingIds.has(id)) throw new Error('订单正在提交,请稍候')
|
|
||||||
const detail = await getMerchantFirstLegOrder(id)
|
|
||||||
if (detail.order.status !== 'DRAFT') throw new Error('订单已不在草稿状态,不能重新编辑,请刷新订单查看最新状态')
|
|
||||||
if (!Number.isSafeInteger(detail.order.version) || detail.order.version < 0) throw new Error('订单版本缺失,请重新加载详情')
|
|
||||||
const order = mapOrder(detail.order, warehouses.value, detail)
|
|
||||||
const session = beginDraftEdit(order)
|
|
||||||
pendingSubmissions.delete(id)
|
|
||||||
submissionForms.delete(id)
|
|
||||||
upsertOrder(order)
|
|
||||||
return session
|
|
||||||
}
|
|
||||||
|
|
||||||
async function saveDraftForSubmission(draft: FirstLegOrderDraft, customerName: string, id?: string, editSession?: DraftEditSession) {
|
|
||||||
if (id && isSubmissionRetry(id, draft)) return submissionForms.get(id)!.order
|
|
||||||
const snapshot = JSON.stringify(draft)
|
|
||||||
const order = await saveDraft(JSON.parse(snapshot), customerName, id, editSession)
|
|
||||||
submissionForms.set(order.id, { snapshot, order })
|
|
||||||
return order
|
|
||||||
}
|
|
||||||
|
|
||||||
async function loadDraftDetail(id: string) {
|
async function loadDraftDetail(id: string) {
|
||||||
return loadOrderAggregate(id)
|
return loadOrderAggregate(id)
|
||||||
}
|
}
|
||||||
|
|
||||||
return { orders, orderDetails, total, queueCounts, orderProgress, queryChannelNames, warehouses, loading, loadedFromApi, loadError, warehouseLoadError, getById, load, loadDetail, loadDraftDetail, loadWarehouseDetail, loadWarehouseType, beginDraftEdit, saveDraft, prepareCancellation, cancelOrder, saveDraftBatch, submitSaved, hasPendingSubmission, isSubmissionRetry, beginNewSubmissionEdit, saveDraftForSubmission }
|
return { orders, orderDetails, total, queueCounts, orderProgress, queryChannelNames, warehouses, loading, loadedFromApi, loadError, warehouseLoadError, getById, load, loadDetail, loadDraftDetail, loadWarehouseDetail, loadWarehouseType, beginDraftEdit, saveDraft, prepareCancellation, cancelOrder, saveDraftBatch, submitSaved }
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import type { TableAction } from '@/components/common/tableActions'
|
|||||||
import { MERCHANT_CUSTOMS_STATUS_LABELS, type MerchantCustomsContainer } from '../api/customs'
|
import { MERCHANT_CUSTOMS_STATUS_LABELS, type MerchantCustomsContainer } from '../api/customs'
|
||||||
import { readCustomsDocuments, type CustomsDocumentRow } from '../utils/customsDocumentsReader'
|
import { readCustomsDocuments, type CustomsDocumentRow } from '../utils/customsDocumentsReader'
|
||||||
import CustomsDocumentsDialog from '../components/CustomsDocumentsDialog.vue'
|
import CustomsDocumentsDialog from '../components/CustomsDocumentsDialog.vue'
|
||||||
|
import CustomsHelp from '../components/CustomsHelp.vue'
|
||||||
|
|
||||||
import { useCustomsPendingStore } from '../store/customsPending'
|
import { useCustomsPendingStore } from '../store/customsPending'
|
||||||
|
|
||||||
@@ -98,7 +99,7 @@ onMounted(() => { void load() })
|
|||||||
<QueryToolbar v-model="queryModel" layout="grid" ariaLabel="报关资料查询条件" :fields="queryFields" @search="search" />
|
<QueryToolbar v-model="queryModel" layout="grid" ariaLabel="报关资料查询条件" :fields="queryFields" @search="search" />
|
||||||
<section class="customs-card">
|
<section class="customs-card">
|
||||||
<DataTable v-model:page="page" v-model:page-size="pageSize" :data="pagedRecords" :columns="columns" :loading="loading" :total="filteredRecords.length" :page-sizes="[10, 20, 50, 100]" :row-actions="rowActions" row-key="order.id" :empty-text="emptyText">
|
<DataTable v-model:page="page" v-model:page-size="pageSize" :data="pagedRecords" :columns="columns" :loading="loading" :total="filteredRecords.length" :page-sizes="[10, 20, 50, 100]" :row-actions="rowActions" row-key="order.id" :empty-text="emptyText">
|
||||||
<template #toolbar><strong>资料列表</strong><span>统计为本客户同柜退税货物汇总,资料覆盖按入仓码计。</span></template>
|
<template #toolbar><strong class="customs-list-heading">资料列表<CustomsHelp title="资料统计口径"><p>统计为本客户同柜退税货物汇总,资料覆盖按入仓码计。</p></CustomsHelp></strong></template>
|
||||||
<template #toolbar-actions><el-button :loading="loading" @click="load"><RefreshCcw :size="16" />刷新</el-button></template>
|
<template #toolbar-actions><el-button :loading="loading" @click="load"><RefreshCcw :size="16" />刷新</el-button></template>
|
||||||
<template v-if="errorMessage" #error><div class="state-error" role="alert"><span>{{ errorMessage }}</span><el-button :loading="loading" @click="load">重新加载</el-button></div></template>
|
<template v-if="errorMessage" #error><div class="state-error" role="alert"><span>{{ errorMessage }}</span><el-button :loading="loading" @click="load">重新加载</el-button></div></template>
|
||||||
<template #orderNo="{ row }">{{ row.order.orderNo || '—' }}</template>
|
<template #orderNo="{ row }">{{ row.order.orderNo || '—' }}</template>
|
||||||
@@ -114,6 +115,7 @@ onMounted(() => { void load() })
|
|||||||
|
|
||||||
<style scoped>
|
<style scoped>
|
||||||
.customs-page { display: grid; gap: var(--client-section-gap); }
|
.customs-page { display: grid; gap: var(--client-section-gap); }
|
||||||
|
.customs-list-heading { display: flex; align-items: center; gap: 4px; }
|
||||||
.customs-card { overflow: hidden; border: 1px solid var(--client-border); border-radius: var(--client-radius); background: #fff; }
|
.customs-card { overflow: hidden; border: 1px solid var(--client-border); border-radius: var(--client-radius); background: #fff; }
|
||||||
.state-error { display: flex; min-height: 84px; align-items: center; justify-content: center; gap: 12px; padding: 14px; color: #b42318; }
|
.state-error { display: flex; min-height: 84px; align-items: center; justify-content: center; gap: 12px; padding: 14px; color: #b42318; }
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
@@ -235,7 +235,7 @@ test('shows one unified progress line and C02 business summaries without detail
|
|||||||
assert.match(source, /pickingStatusLabel: getFirstLegPickingStatusLabel\(summary\.loadingStatus\)/)
|
assert.match(source, /pickingStatusLabel: getFirstLegPickingStatusLabel\(summary\.loadingStatus\)/)
|
||||||
assert.match(source, /prop="pickingStatusLabel" label="拣货状态"/)
|
assert.match(source, /prop="pickingStatusLabel" label="拣货状态"/)
|
||||||
assert.doesNotMatch(source, /label="当前节点"/)
|
assert.doesNotMatch(source, /label="当前节点"/)
|
||||||
assert.match(source, /尚未分配柜次,后续柜次节点将在这里同步。/)
|
assert.match(source, /尚未分配柜次/)
|
||||||
assert.doesNotMatch(source, /暂无柜次分配信息/)
|
assert.doesNotMatch(source, /暂无柜次分配信息/)
|
||||||
assert.doesNotMatch(source, /summary\.sealNo \|\|/)
|
assert.doesNotMatch(source, /summary\.sealNo \|\|/)
|
||||||
assert.doesNotMatch(progressSource, /客户确认|差异处理中|派送中/)
|
assert.doesNotMatch(progressSource, /客户确认|差异处理中|派送中/)
|
||||||
@@ -397,7 +397,7 @@ test('distills order creation into the confirmed prototype sections with server
|
|||||||
assert.match(cargoToolbarSource, /isCreatePage && !routeDraftId && canCreateOrder/)
|
assert.match(cargoToolbarSource, /isCreatePage && !routeDraftId && canCreateOrder/)
|
||||||
assert.match(cargoToolbarSource, /downloadBatchTemplate[\s\S]*下载 Excel 模板/)
|
assert.match(cargoToolbarSource, /downloadBatchTemplate[\s\S]*下载 Excel 模板/)
|
||||||
assert.match(cargoToolbarSource, /openBatchImport[\s\S]*Excel 批量导入/)
|
assert.match(cargoToolbarSource, /openBatchImport[\s\S]*Excel 批量导入/)
|
||||||
assert.match(cargoToolbarSource, /Excel 导入用于一次创建多条订单草稿/)
|
assert.doesNotMatch(cargoToolbarSource, /Excel 导入用于一次创建多条订单草稿/)
|
||||||
assert.match(source, /导入成功的数据只创建草稿,不会直接提交审核/)
|
assert.match(source, /导入成功的数据只创建草稿,不会直接提交审核/)
|
||||||
assert.match(source, /下载正式模板[\s\S]*选择 Excel/)
|
assert.match(source, /下载正式模板[\s\S]*选择 Excel/)
|
||||||
assert.match(source, /仅支持 \.xlsx,文件不超过 5MB、最多 50 行/)
|
assert.match(source, /仅支持 \.xlsx,文件不超过 5MB、最多 50 行/)
|
||||||
@@ -460,7 +460,7 @@ test('matches the prototype two-column create layout and reset action', () => {
|
|||||||
|
|
||||||
test('shows an optional LX inbound order number for one-click dropship orders', () => {
|
test('shows an optional LX inbound order number for one-click dropship orders', () => {
|
||||||
assert.match(source, /v-if="form\.fulfillmentType === 'ONE_CLICK_DROPSHIP'" label="LX入库单号" prop="lxCode"/)
|
assert.match(source, /v-if="form\.fulfillmentType === 'ONE_CLICK_DROPSHIP'" label="LX入库单号" prop="lxCode"/)
|
||||||
assert.match(source, /v-model="form\.lxCode"[^>]*placeholder="请输入LX入库单号"/)
|
assert.match(source, /v-model="form\.lxCode"[^>]*placeholder=""/)
|
||||||
assert.doesNotMatch(source, /label="LX入库单号"[^>]*required/)
|
assert.doesNotMatch(source, /label="LX入库单号"[^>]*required/)
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -623,7 +623,7 @@ test('loads merchant inbound billing as an isolated read-only detail section', (
|
|||||||
assert.match(source, /error instanceof ApiError && error\.code === 'A0404'/)
|
assert.match(source, /error instanceof ApiError && error\.code === 'A0404'/)
|
||||||
assert.match(source, /error\.message \|\| unavailableMessage/)
|
assert.match(source, /error\.message \|\| unavailableMessage/)
|
||||||
assert.match(source, /order\.status === 'DRAFT'/)
|
assert.match(source, /order\.status === 'DRAFT'/)
|
||||||
assert.match(source, /feeConfirmationOpen\.value[\s\S]*\? '未推送计费重'[\s\S]*: '订单提交后可查看入库结果'/)
|
assert.match(source, /feeConfirmationOpen\.value[\s\S]*\? '未推送费用'[\s\S]*: '订单提交后可查看入库结果'/)
|
||||||
assert.match(source, /订单提交后可查看入库结果/)
|
assert.match(source, /订单提交后可查看入库结果/)
|
||||||
assert.doesNotMatch(source, /confirmMerchantInbound|adjustMerchantInbound|sendMerchantInbound/)
|
assert.doesNotMatch(source, /confirmMerchantInbound|adjustMerchantInbound|sendMerchantInbound/)
|
||||||
})
|
})
|
||||||
@@ -636,18 +636,47 @@ test('keeps platform enterprise scope and tenant terminology out of the customer
|
|||||||
test('opens billing-weight confirmation independently from order details', () => {
|
test('opens billing-weight confirmation independently from order details', () => {
|
||||||
const handler = source.slice(source.indexOf('function openFeeConfirmation'), source.indexOf('async function retryDetail'))
|
const handler = source.slice(source.indexOf('function openFeeConfirmation'), source.indexOf('async function retryDetail'))
|
||||||
assert.match(handler, /feeConfirmationOpen\.value = true/)
|
assert.match(handler, /feeConfirmationOpen\.value = true/)
|
||||||
assert.match(handler, /loadInboundBilling\(order, '未推送计费重'\)/)
|
assert.match(handler, /loadInboundBilling\(order, '未推送费用'\)/)
|
||||||
assert.doesNotMatch(handler, /openDetail\(/)
|
assert.doesNotMatch(handler, /openDetail\(/)
|
||||||
assert.match(source, /v-if="feeConfirmationOpen"[\s\S]*dialog-only[\s\S]*auto-open/)
|
assert.match(source, /v-if="feeConfirmationOpen"[\s\S]*dialog-only[\s\S]*auto-open/)
|
||||||
assert.match(source, /unavailable-message="未推送计费重"/)
|
assert.match(source, /unavailable-message="未推送费用"/)
|
||||||
})
|
})
|
||||||
|
|
||||||
test('shows billing-weight confirmation only when the backend marks it pending', () => {
|
test('only offers published-fee confirmation for pending orders with confirmation permission', () => {
|
||||||
assert.match(source, /if \(canConfirmInboundFee\.value && order\.businessSummary\.customerFeeConfirmationRequired\) \{\s*actions\.push\(\{ key: 'fee'/)
|
const actions = source.slice(source.indexOf('function getOrderRowActions'), source.indexOf('function getOrderRowActions') + 1800)
|
||||||
|
assert.match(actions, /actions\.push\(\{ key: 'fee', label: '确认计费重', run: \(\) => openFeeConfirmation\(order\) \}\)/)
|
||||||
|
assert.match(actions, /if \(canConfirmInboundFee\.value && order\.businessSummary\.customerFeeConfirmationRequired\) \{\s*actions\.push\(\{ key: 'fee'/)
|
||||||
|
assert.doesNotMatch(actions, /label: '确认费用'|key: 'weight'/)
|
||||||
|
assert.doesNotMatch(source, /ChargeableWeightDialog|weightConfirmationOrderId/)
|
||||||
assert.match(source, /:row-actions="getOrderRowActions"/)
|
assert.match(source, /:row-actions="getOrderRowActions"/)
|
||||||
assert.match(orderStoreSource, /customerFeeConfirmationRequired: summary\?\.customerFeeConfirmationRequired \?\? false/)
|
assert.match(orderStoreSource, /customerFeeConfirmationRequired: summary\?\.customerFeeConfirmationRequired \?\? false/)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
test('hides confirmation for confirmed, unpushed and unauthorized orders and refreshes after confirmation', () => {
|
||||||
|
const start = source.indexOf('function getOrderRowActions')
|
||||||
|
const end = source.indexOf('\nasync function copyOrder', start)
|
||||||
|
const body = source.slice(start, end)
|
||||||
|
.replace('function getOrderRowActions(row: object): TableAction[]', 'function getOrderRowActions(row)')
|
||||||
|
.replace('const order = row as FirstLegOrder', 'const order = row')
|
||||||
|
.replace('const actions: TableAction[]', 'const actions')
|
||||||
|
const actionsFor = new Function('canConfirmInboundFee', 'canCreateOrder', 'canEditOrder',
|
||||||
|
'canOfferCancellation', 'eligibleCustomsDetail', 'openFeeConfirmation',
|
||||||
|
`${body}; return getOrderRowActions`)
|
||||||
|
for (const [permitted, pending] of [[true, true], [true, false], [false, true], [false, false]]) {
|
||||||
|
const opened = []
|
||||||
|
const order = { id: 'order-1', businessSummary: { customerFeeConfirmationRequired: pending } }
|
||||||
|
const getActions = actionsFor({ value: permitted }, { value: false }, { value: false },
|
||||||
|
() => false, () => false, row => opened.push(row.id))
|
||||||
|
const confirm = getActions(order).filter(action => action.key === 'fee')
|
||||||
|
assert.equal(confirm.length, permitted && pending ? 1 : 0)
|
||||||
|
if (confirm.length) {
|
||||||
|
confirm[0].run()
|
||||||
|
assert.deepEqual(opened, ['order-1'])
|
||||||
|
}
|
||||||
|
}
|
||||||
|
assert.match(source, /function handleInboundFeeConfirmed\(\) \{\s*if \(!isCreatePage\.value && !isDetailPage\.value\) void loadOrderPage\(\)/)
|
||||||
|
})
|
||||||
|
|
||||||
test('submits only selected draft orders in one batch action', () => {
|
test('submits only selected draft orders in one batch action', () => {
|
||||||
assert.match(source, /selectedDraftOrders = computed\(\(\) => selectedOrders\.value\.filter\(\(order\) => order\.status === 'DRAFT'\)\)/)
|
assert.match(source, /selectedDraftOrders = computed\(\(\) => selectedOrders\.value\.filter\(\(order\) => order\.status === 'DRAFT'\)\)/)
|
||||||
assert.match(source, /Promise\.allSettled\(ids\.map\(id => store\.submitSaved/)
|
assert.match(source, /Promise\.allSettled\(ids\.map\(id => store\.submitSaved/)
|
||||||
|
|||||||
@@ -85,7 +85,6 @@ const canCreateOrder = computed(() => auth.hasPermission('order:first-leg:create
|
|||||||
const canEditOrder = computed(() => auth.hasPermission('order:first-leg:edit'))
|
const canEditOrder = computed(() => auth.hasPermission('order:first-leg:edit'))
|
||||||
const canCancelOrder = computed(() => auth.hasPermission('order:first-leg:cancel'))
|
const canCancelOrder = computed(() => auth.hasPermission('order:first-leg:cancel'))
|
||||||
const cancellingOrderId = ref('')
|
const cancellingOrderId = ref('')
|
||||||
const pendingCancellation = shallowRef<{ id: string; expectedVersion: number; reason: string; businessNo: string; statusLabel: string }>()
|
|
||||||
|
|
||||||
function canOfferCancellation(order: FirstLegOrder) {
|
function canOfferCancellation(order: FirstLegOrder) {
|
||||||
return canCancelOrder.value && ['DRAFT', 'PENDING_REVIEW', 'WAIT_MEASURE'].includes(order.status)
|
return canCancelOrder.value && ['DRAFT', 'PENDING_REVIEW', 'WAIT_MEASURE'].includes(order.status)
|
||||||
@@ -95,40 +94,20 @@ async function cancelOrder(order: FirstLegOrder) {
|
|||||||
if (!canOfferCancellation(order) || cancellingOrderId.value) return
|
if (!canOfferCancellation(order) || cancellingOrderId.value) return
|
||||||
cancellingOrderId.value = order.id
|
cancellingOrderId.value = order.id
|
||||||
try {
|
try {
|
||||||
let command = pendingCancellation.value
|
|
||||||
if (command && command.id !== order.id) {
|
|
||||||
ElMessage.warning(`请先处理订单 ${command.businessNo} 未确认的取消结果`)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if (!command) {
|
|
||||||
const target = await store.prepareCancellation(order.id)
|
const target = await store.prepareCancellation(order.id)
|
||||||
const { value } = await ElMessageBox.prompt(`订单:${target.businessNo};当前状态:${target.statusLabel}。请填写取消原因。`, '取消订单', {
|
const { value } = await ElMessageBox.prompt(
|
||||||
|
`订单:${target.businessNo};当前状态:${target.statusLabel}。请填写取消原因。`, '取消订单', {
|
||||||
type: 'warning', inputType: 'textarea', confirmButtonText: '确认取消订单', cancelButtonText: '返回',
|
type: 'warning', inputType: 'textarea', confirmButtonText: '确认取消订单', cancelButtonText: '返回',
|
||||||
inputValidator: value => Boolean(value?.trim()) && value.trim().length <= 500 || '请填写 1–500 字取消原因',
|
inputValidator: value => Boolean(value?.trim()) && value.trim().length <= 500 || '请填写 1–500 字取消原因',
|
||||||
})
|
})
|
||||||
command = { ...target, reason: value.trim() }
|
await store.cancelOrder(target.id, target.expectedVersion, value.trim())
|
||||||
pendingCancellation.value = command
|
ElMessage.success('订单已取消'); await loadOrderPage()
|
||||||
} else {
|
|
||||||
await ElMessageBox.confirm(`订单:${command.businessNo};原状态:${command.statusLabel};原因:${command.reason}。将查询当前状态并重试原取消请求。`, '重试取消订单', {
|
|
||||||
type: 'warning', confirmButtonText: '重试原请求', cancelButtonText: '返回',
|
|
||||||
})
|
|
||||||
}
|
|
||||||
await store.cancelOrder(command.id, command.expectedVersion, command.reason)
|
|
||||||
pendingCancellation.value = undefined
|
|
||||||
ElMessage.success('订单已取消')
|
|
||||||
await loadOrderPage()
|
|
||||||
if (isDetailPage.value) await router.push({ name: 'first-leg-orders' })
|
if (isDetailPage.value) await router.push({ name: 'first-leg-orders' })
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
if (error === 'cancel' || error === 'close') return
|
if (error === 'cancel' || error === 'close') return
|
||||||
if (error instanceof ApiError && (error.code === 'A0409' || error.status === 409)) {
|
ElMessage.error(error instanceof Error ? error.message : '取消失败,请重新操作')
|
||||||
pendingCancellation.value = undefined
|
void loadOrderPage()
|
||||||
ElMessage.error(`${error.message}。请刷新订单后重新确认取消。`)
|
} finally { cancellingOrderId.value = '' }
|
||||||
} else {
|
|
||||||
ElMessage.error(error instanceof Error ? error.message : '取消失败,请重试原请求')
|
|
||||||
}
|
|
||||||
} finally {
|
|
||||||
cancellingOrderId.value = ''
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
const canSubmitOrder = computed(() => auth.hasPermission('order:first-leg:submit'))
|
const canSubmitOrder = computed(() => auth.hasPermission('order:first-leg:submit'))
|
||||||
const canConfirmInboundFee = computed(() => auth.hasPermission('order:first-leg:edit'))
|
const canConfirmInboundFee = computed(() => auth.hasPermission('order:first-leg:edit'))
|
||||||
@@ -242,7 +221,6 @@ const tablePageSize = ref(10)
|
|||||||
const downloadingMarks = ref(false)
|
const downloadingMarks = ref(false)
|
||||||
const exportingOrders = ref(false)
|
const exportingOrders = ref(false)
|
||||||
const batchSubmitting = ref(false)
|
const batchSubmitting = ref(false)
|
||||||
const pendingBatchSubmissionIds = ref<string[]>([])
|
|
||||||
const selectedOrders = ref<FirstLegOrder[]>([])
|
const selectedOrders = ref<FirstLegOrder[]>([])
|
||||||
const selectedOrderCount = computed(() => selectedOrders.value.length)
|
const selectedOrderCount = computed(() => selectedOrders.value.length)
|
||||||
const selectedDraftOrders = computed(() => selectedOrders.value.filter((order) => order.status === 'DRAFT'))
|
const selectedDraftOrders = computed(() => selectedOrders.value.filter((order) => order.status === 'DRAFT'))
|
||||||
@@ -423,7 +401,7 @@ function emptyDraft(): FirstLegOrderDraft {
|
|||||||
destinationCountryCode: 'US',
|
destinationCountryCode: 'US',
|
||||||
destinationWarehouseId: '',
|
destinationWarehouseId: '',
|
||||||
destinationWarehouseName: '',
|
destinationWarehouseName: '',
|
||||||
pickupMethod: 'SELF_EXPRESS',
|
pickupMethod: 'SELF_TRUCK',
|
||||||
trackingNumber: '',
|
trackingNumber: '',
|
||||||
channelCode: '',
|
channelCode: '',
|
||||||
channelName: '',
|
channelName: '',
|
||||||
@@ -1368,7 +1346,7 @@ function getOrderRowActions(row: object): TableAction[] {
|
|||||||
actions.push({ key: 'edit', label: '编辑', loading: openingEditor.value, run: () => openEdit(order) })
|
actions.push({ key: 'edit', label: '编辑', loading: openingEditor.value, run: () => openEdit(order) })
|
||||||
}
|
}
|
||||||
if (canOfferCancellation(order)) {
|
if (canOfferCancellation(order)) {
|
||||||
actions.push({ key: 'cancel', label: pendingCancellation.value?.id === order.id ? '重试取消' : '取消订单', loading: cancellingOrderId.value === order.id, disabled: Boolean(cancellingOrderId.value), run: () => cancelOrder(order) })
|
actions.push({ key: 'cancel', label: '取消订单', loading: cancellingOrderId.value === order.id, disabled: Boolean(cancellingOrderId.value), run: () => cancelOrder(order) })
|
||||||
}
|
}
|
||||||
if (eligibleCustomsDetail(order)) {
|
if (eligibleCustomsDetail(order)) {
|
||||||
actions.push({ key: 'customs', label: '报关资料', run: () => openCustomsDocuments(order) })
|
actions.push({ key: 'customs', label: '报关资料', run: () => openCustomsDocuments(order) })
|
||||||
@@ -1471,9 +1449,9 @@ async function loadDetailPage(orderId: string) {
|
|||||||
|
|
||||||
function openFeeConfirmation(order: FirstLegOrder) {
|
function openFeeConfirmation(order: FirstLegOrder) {
|
||||||
resetInboundBillingState()
|
resetInboundBillingState()
|
||||||
inboundBillingUnavailableMessage.value = '未推送计费重'
|
inboundBillingUnavailableMessage.value = '未推送费用'
|
||||||
feeConfirmationOpen.value = true
|
feeConfirmationOpen.value = true
|
||||||
void loadInboundBilling(order, '未推送计费重')
|
void loadInboundBilling(order, '未推送费用')
|
||||||
}
|
}
|
||||||
|
|
||||||
async function retryDetail() {
|
async function retryDetail() {
|
||||||
@@ -1508,7 +1486,7 @@ async function loadInboundBilling(order: FirstLegOrder, unavailableMessage = '
|
|||||||
if (order.status === 'DRAFT') {
|
if (order.status === 'DRAFT') {
|
||||||
inboundBillingUnavailable.value = true
|
inboundBillingUnavailable.value = true
|
||||||
inboundBillingUnavailableMessage.value = feeConfirmationOpen.value
|
inboundBillingUnavailableMessage.value = feeConfirmationOpen.value
|
||||||
? '未推送计费重'
|
? '未推送费用'
|
||||||
: '订单提交后可查看入库结果'
|
: '订单提交后可查看入库结果'
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -1523,7 +1501,7 @@ async function loadInboundBilling(order: FirstLegOrder, unavailableMessage = '
|
|||||||
if (error instanceof ApiError && error.code === 'A0404') {
|
if (error instanceof ApiError && error.code === 'A0404') {
|
||||||
inboundBillingUnavailable.value = true
|
inboundBillingUnavailable.value = true
|
||||||
inboundBillingUnavailableMessage.value = feeConfirmationOpen.value
|
inboundBillingUnavailableMessage.value = feeConfirmationOpen.value
|
||||||
? '未推送计费重'
|
? '未推送费用'
|
||||||
: error.message || unavailableMessage
|
: error.message || unavailableMessage
|
||||||
} else {
|
} else {
|
||||||
inboundBillingError.value = error instanceof Error ? error.message : '入库与费用加载失败'
|
inboundBillingError.value = error instanceof Error ? error.message : '入库与费用加载失败'
|
||||||
@@ -1535,7 +1513,7 @@ async function loadInboundBilling(order: FirstLegOrder, unavailableMessage = '
|
|||||||
|
|
||||||
async function retryInboundBilling() {
|
async function retryInboundBilling() {
|
||||||
const order = inboundBillingOrderId.value ? store.getById(inboundBillingOrderId.value) : undefined
|
const order = inboundBillingOrderId.value ? store.getById(inboundBillingOrderId.value) : undefined
|
||||||
if (order) await loadInboundBilling(order, feeConfirmationOpen.value ? '未推送计费重' : '还未测量推送')
|
if (order) await loadInboundBilling(order, feeConfirmationOpen.value ? '未推送费用' : '还未测量推送')
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleInboundFeeConfirmed() {
|
function handleInboundFeeConfirmed() {
|
||||||
@@ -1751,14 +1729,14 @@ function handleOrderSelectionChange(rows: FirstLegOrder[]) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function submitSelectedDraftOrders() {
|
async function submitSelectedDraftOrders() {
|
||||||
const ids = [...new Set([...pendingBatchSubmissionIds.value, ...selectedDraftOrders.value.map(order => order.id)])]
|
const ids = [...new Set(selectedDraftOrders.value.map(order => order.id))]
|
||||||
if (batchSubmitting.value || !ids.length) return
|
if (batchSubmitting.value || !ids.length) return
|
||||||
if (companySubmissionBlocked.value) {
|
if (companySubmissionBlocked.value) {
|
||||||
ElMessage.warning('企业资料审核通过后才能提交订单')
|
ElMessage.warning('企业资料审核通过后才能提交订单')
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
await ElMessageBox.confirm(`确认提交 ${ids.length} 条草稿订单吗?${pendingBatchSubmissionIds.value.length ? '上次结果未确认的订单将使用原提交命令重试。' : ''}`, '批量提交订单', {
|
await ElMessageBox.confirm(`确认提交 ${ids.length} 条草稿订单吗?`, '批量提交订单', {
|
||||||
type: 'warning',
|
type: 'warning',
|
||||||
confirmButtonText: '确认提交',
|
confirmButtonText: '确认提交',
|
||||||
cancelButtonText: '取消',
|
cancelButtonText: '取消',
|
||||||
@@ -1771,7 +1749,6 @@ async function submitSelectedDraftOrders() {
|
|||||||
batchSubmitting.value = true
|
batchSubmitting.value = true
|
||||||
try {
|
try {
|
||||||
const results = await Promise.allSettled(ids.map(id => store.submitSaved(id, companyAuditLoaded.value ? tenantStore.company.auditStatus : undefined)))
|
const results = await Promise.allSettled(ids.map(id => store.submitSaved(id, companyAuditLoaded.value ? tenantStore.company.auditStatus : undefined)))
|
||||||
pendingBatchSubmissionIds.value = ids.filter((id, index) => results[index]?.status === 'rejected' && store.hasPendingSubmission(id))
|
|
||||||
const successCount = results.filter((result) => result.status === 'fulfilled').length
|
const successCount = results.filter((result) => result.status === 'fulfilled').length
|
||||||
const failures = results.filter((result): result is PromiseRejectedResult => result.status === 'rejected')
|
const failures = results.filter((result): result is PromiseRejectedResult => result.status === 'rejected')
|
||||||
await searchOrders(appliedFilters.value)
|
await searchOrders(appliedFilters.value)
|
||||||
@@ -2024,7 +2001,6 @@ async function saveDraft() {
|
|||||||
if (!await validateEditorForm()) return
|
if (!await validateEditorForm()) return
|
||||||
saving.value = true
|
saving.value = true
|
||||||
try {
|
try {
|
||||||
if (!await confirmSubmissionEdit()) return
|
|
||||||
const order = await store.saveDraft(cloneDraft(form), tenantStore.company.companyName, editingId.value, editingSession.value)
|
const order = await store.saveDraft(cloneDraft(form), tenantStore.company.companyName, editingId.value, editingSession.value)
|
||||||
editingId.value = order.id
|
editingId.value = order.id
|
||||||
editingSession.value = store.beginDraftEdit(order)
|
editingSession.value = store.beginDraftEdit(order)
|
||||||
@@ -2039,20 +2015,6 @@ async function saveDraft() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function confirmSubmissionEdit() {
|
|
||||||
if (!editingId.value || !store.hasPendingSubmission(editingId.value)) return true
|
|
||||||
try {
|
|
||||||
await ElMessageBox.confirm('上次提交结果尚未确认。确认重新读取订单并按当前表单重新编辑吗?只有服务端仍为草稿时才能开始新的提交决定。', '重新编辑订单', {
|
|
||||||
type: 'warning', center: true, confirmButtonText: '确认重新编辑', cancelButtonText: '返回',
|
|
||||||
})
|
|
||||||
} catch (error) {
|
|
||||||
if (error === 'cancel' || error === 'close') return false
|
|
||||||
throw error
|
|
||||||
}
|
|
||||||
editingSession.value = await store.beginNewSubmissionEdit(editingId.value)
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
|
|
||||||
async function submitOrder() {
|
async function submitOrder() {
|
||||||
if (saving.value) return
|
if (saving.value) return
|
||||||
if (companySubmissionBlocked.value) {
|
if (companySubmissionBlocked.value) {
|
||||||
@@ -2071,14 +2033,12 @@ async function submitOrder() {
|
|||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
const retry = store.isSubmissionRetry(editingId.value, cloneDraft(form))
|
if (!await validateEditorForm()) return
|
||||||
if (!retry && !await validateEditorForm()) return
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
saving.value = true
|
saving.value = true
|
||||||
if (!retry && !await confirmSubmissionEdit()) return
|
|
||||||
const knownCompanyAuditStatus = companyAuditLoaded.value ? tenantStore.company.auditStatus : undefined
|
const knownCompanyAuditStatus = companyAuditLoaded.value ? tenantStore.company.auditStatus : undefined
|
||||||
const savedOrder = await store.saveDraftForSubmission(cloneDraft(form), tenantStore.company.companyName, editingId.value, editingSession.value)
|
const savedOrder = await store.saveDraft(cloneDraft(form), tenantStore.company.companyName, editingId.value, editingSession.value)
|
||||||
editingId.value = savedOrder.id
|
editingId.value = savedOrder.id
|
||||||
editingSession.value = store.beginDraftEdit(savedOrder)
|
editingSession.value = store.beginDraftEdit(savedOrder)
|
||||||
await store.submitSaved(savedOrder.id, knownCompanyAuditStatus)
|
await store.submitSaved(savedOrder.id, knownCompanyAuditStatus)
|
||||||
@@ -2115,8 +2075,6 @@ async function searchOrders(model: QueryModel) {
|
|||||||
<QueryToolbar v-model="filters" class="first-leg-query-toolbar" layout="grid" :fields="queryFields" ariaLabel="订单查询" @search="searchOrders" />
|
<QueryToolbar v-model="filters" class="first-leg-query-toolbar" layout="grid" :fields="queryFields" ariaLabel="订单查询" @search="searchOrders" />
|
||||||
|
|
||||||
<div class="client-card order-table-card">
|
<div class="client-card order-table-card">
|
||||||
<DataTable :page="tablePage" :page-size="tablePageSize" @update:page="changeOrderPage" @update:page-size="changeOrderPageSize" :data="pagedOrders" :columns="visibleOrderColumns" :key="orderTableVersion" :loading="store.loading" :total="store.total" :page-sizes="[10, 20, 50]" row-key="id" empty-text="暂无订单" class="prototype-order-table" :row-actions="getOrderRowActions" @selection-change="handleOrderSelectionChange">
|
|
||||||
<template #toolbar>
|
|
||||||
<nav class="order-queue-tabs" aria-label="订单事项分类">
|
<nav class="order-queue-tabs" aria-label="订单事项分类">
|
||||||
<button v-for="queue in ORDER_QUEUES" :key="queue.key" type="button"
|
<button v-for="queue in ORDER_QUEUES" :key="queue.key" type="button"
|
||||||
:class="{ active: activeOrderQueue === queue.key }" :aria-pressed="activeOrderQueue === queue.key"
|
:class="{ active: activeOrderQueue === queue.key }" :aria-pressed="activeOrderQueue === queue.key"
|
||||||
@@ -2125,6 +2083,8 @@ async function searchOrders(model: QueryModel) {
|
|||||||
:class="queue.todo ? 'queue-count' : 'queue-stage-count'">{{ queue.todo ? orderQueueCounts[queue.key] : `(${orderQueueCounts[queue.key]})` }}</span>
|
:class="queue.todo ? 'queue-count' : 'queue-stage-count'">{{ queue.todo ? orderQueueCounts[queue.key] : `(${orderQueueCounts[queue.key]})` }}</span>
|
||||||
</button>
|
</button>
|
||||||
</nav>
|
</nav>
|
||||||
|
<DataTable :page="tablePage" :page-size="tablePageSize" @update:page="changeOrderPage" @update:page-size="changeOrderPageSize" :data="pagedOrders" :columns="visibleOrderColumns" :key="orderTableVersion" :loading="store.loading" :total="store.total" :page-sizes="[10, 20, 50]" row-key="id" empty-text="暂无订单" class="prototype-order-table" :row-actions="getOrderRowActions" @selection-change="handleOrderSelectionChange">
|
||||||
|
<template #toolbar>
|
||||||
<span v-if="selectedOrderCount">已选 {{ selectedOrderCount }} 条</span>
|
<span v-if="selectedOrderCount">已选 {{ selectedOrderCount }} 条</span>
|
||||||
</template>
|
</template>
|
||||||
<template #toolbar-actions>
|
<template #toolbar-actions>
|
||||||
@@ -2133,7 +2093,7 @@ async function searchOrders(model: QueryModel) {
|
|||||||
<el-button class="column-settings-trigger" aria-label="设置订单列表显示列" title="设置显示列"><SlidersHorizontal :size="18" />显示字段筛选</el-button>
|
<el-button class="column-settings-trigger" aria-label="设置订单列表显示列" title="设置显示列"><SlidersHorizontal :size="18" />显示字段筛选</el-button>
|
||||||
</template>
|
</template>
|
||||||
<div class="column-settings-panel">
|
<div class="column-settings-panel">
|
||||||
<p>拖动调整顺序,也可使用上下移动按钮。</p>
|
|
||||||
<el-checkbox-group v-model="visibleColumnKeys" aria-label="订单列表显示列">
|
<el-checkbox-group v-model="visibleColumnKeys" aria-label="订单列表显示列">
|
||||||
<div
|
<div
|
||||||
v-for="(column, index) in orderedSelectableColumns"
|
v-for="(column, index) in orderedSelectableColumns"
|
||||||
@@ -2156,7 +2116,7 @@ async function searchOrders(model: QueryModel) {
|
|||||||
</el-popover>
|
</el-popover>
|
||||||
<el-button :loading="downloadingMarks" :disabled="selectedOrderCount === 0" @click="downloadShippingMarks"><Download :size="16" />下载唛头</el-button>
|
<el-button :loading="downloadingMarks" :disabled="selectedOrderCount === 0" @click="downloadShippingMarks"><Download :size="16" />下载唛头</el-button>
|
||||||
<el-button :loading="exportingOrders" :disabled="selectedOrderCount === 0" @click="exportOrderInformation"><Download :size="16" />导出订单信息</el-button>
|
<el-button :loading="exportingOrders" :disabled="selectedOrderCount === 0" @click="exportOrderInformation"><Download :size="16" />导出订单信息</el-button>
|
||||||
<el-button v-if="canSubmitOrder" :loading="batchSubmitting" :disabled="(selectedDraftOrders.length === 0 && pendingBatchSubmissionIds.length === 0) || companySubmissionBlocked" @click="submitSelectedDraftOrders"><Send :size="17" />{{ pendingBatchSubmissionIds.length ? '重试批量提交' : '批量提交草稿' }}</el-button>
|
<el-button v-if="canSubmitOrder" :loading="batchSubmitting" :disabled="selectedDraftOrders.length === 0 || companySubmissionBlocked" @click="submitSelectedDraftOrders"><Send :size="17" />批量提交草稿</el-button>
|
||||||
<el-button v-if="auth.hasPermission('order:first-leg:create')" @click="openBatchImport"><Upload :size="17" />批量导入订单</el-button>
|
<el-button v-if="auth.hasPermission('order:first-leg:create')" @click="openBatchImport"><Upload :size="17" />批量导入订单</el-button>
|
||||||
<el-button v-if="props.showCreateAction && auth.hasPermission('order:first-leg:create')" type="primary" :loading="pageDataLoading" :disabled="pageDataLoading || availableWarehouses.length === 0" @click="openCreate"><FilePlus2 :size="17" />创建订单</el-button>
|
<el-button v-if="props.showCreateAction && auth.hasPermission('order:first-leg:create')" type="primary" :loading="pageDataLoading" :disabled="pageDataLoading || availableWarehouses.length === 0" @click="openCreate"><FilePlus2 :size="17" />创建订单</el-button>
|
||||||
|
|
||||||
@@ -2244,18 +2204,18 @@ async function searchOrders(model: QueryModel) {
|
|||||||
<div class="order-section-heading"><span class="order-step-badge">01</span><h3>客户下单</h3><span class="order-section-context">国内交货与运输信息</span></div>
|
<div class="order-section-heading"><span class="order-step-badge">01</span><h3>客户下单</h3><span class="order-section-context">国内交货与运输信息</span></div>
|
||||||
<div class="prototype-form-flow shipping-form-flow">
|
<div class="prototype-form-flow shipping-form-flow">
|
||||||
<el-form-item label="履约类型" prop="fulfillmentType" required class="prototype-form-row prototype-form-row--tabs"><el-radio-group v-model="form.fulfillmentType" class="segmented-options" @change="changeFulfillmentType"><el-radio-button value="STANDARD">普通头程</el-radio-button><el-radio-button value="ONE_CLICK_DROPSHIP">一件代发</el-radio-button></el-radio-group><small v-if="form.fulfillmentType === 'ONE_CLICK_DROPSHIP'" class="field-guidance">测量完成后不办理国内库存入库,将直接推送 PDA 合托。</small></el-form-item>
|
<el-form-item label="履约类型" prop="fulfillmentType" required class="prototype-form-row prototype-form-row--tabs"><el-radio-group v-model="form.fulfillmentType" class="segmented-options" @change="changeFulfillmentType"><el-radio-button value="STANDARD">普通头程</el-radio-button><el-radio-button value="ONE_CLICK_DROPSHIP">一件代发</el-radio-button></el-radio-group><small v-if="form.fulfillmentType === 'ONE_CLICK_DROPSHIP'" class="field-guidance">测量完成后不办理国内库存入库,将直接推送 PDA 合托。</small></el-form-item>
|
||||||
<el-form-item v-if="form.fulfillmentType === 'ONE_CLICK_DROPSHIP'" label="LX入库单号" prop="lxCode" class="prototype-form-row prototype-form-row--wide"><el-input v-model="form.lxCode" maxlength="128" placeholder="请输入LX入库单号" /><small class="field-guidance">用于绑定领星入库单,提交后可在尾程订单、入库单和出库单中查询。</small></el-form-item>
|
<el-form-item v-if="form.fulfillmentType === 'ONE_CLICK_DROPSHIP'" label="LX入库单号" prop="lxCode" class="prototype-form-row prototype-form-row--wide"><el-input v-model="form.lxCode" maxlength="128" placeholder="" /></el-form-item>
|
||||||
<el-form-item label="取货方式" prop="pickupMethod" required class="prototype-form-row prototype-form-row--tabs"><el-radio-group v-model="form.pickupMethod" class="segmented-options" @change="changePickupMethod"><el-radio-button value="SELF_TRUCK">卡车自送</el-radio-button><el-radio-button value="PICKUP">我司提货</el-radio-button><el-radio-button value="SELF_EXPRESS">快递自提</el-radio-button></el-radio-group></el-form-item>
|
<el-form-item label="取货方式" prop="pickupMethod" required class="prototype-form-row prototype-form-row--tabs"><el-radio-group v-model="form.pickupMethod" class="segmented-options" @change="changePickupMethod"><el-radio-button value="SELF_TRUCK">卡车自送</el-radio-button><el-radio-button value="PICKUP">我司提货</el-radio-button><el-radio-button value="SELF_EXPRESS">快递自提</el-radio-button></el-radio-group></el-form-item>
|
||||||
<el-form-item v-if="form.pickupMethod === 'SELF_EXPRESS'" label="快递单号" prop="trackingNumber" class="prototype-form-row prototype-form-row--wide"><el-input v-model="form.trackingNumber" maxlength="128" placeholder="请输入快递单号(选填)" /></el-form-item>
|
<el-form-item v-if="form.pickupMethod === 'SELF_EXPRESS'" label="快递单号" prop="trackingNumber" class="prototype-form-row prototype-form-row--wide"><el-input v-model="form.trackingNumber" maxlength="128" placeholder="" /></el-form-item>
|
||||||
<template v-if="form.pickupMethod === 'PICKUP' && form.shipperPartySnapshot">
|
<template v-if="form.pickupMethod === 'PICKUP' && form.shipperPartySnapshot">
|
||||||
<el-form-item label="企业提货地址簿" prop="senderAddressId" required :rules="requiredSelectRules('请选择企业提货地址')" class="prototype-form-row prototype-form-row--wide address-book-row">
|
<el-form-item label="企业提货地址簿" prop="senderAddressId" required :rules="requiredSelectRules('请选择企业提货地址')" class="prototype-form-row prototype-form-row--wide address-book-row">
|
||||||
<div class="address-book-control"><el-select v-model="form.senderAddressId" clearable filterable :loading="orderAddressesLoading" placeholder="选择企业保存的提货地址" @change="selectPickupAddress"><el-option v-for="address in pickupAddresses" :key="String(address.id)" :label="addressLabel(address)" :value="String(address.id)" /></el-select><el-button @click="savePickupAddress">保存当前地址</el-button><el-button v-if="form.senderAddressId" link type="danger" @click="removeOrderAddress('PICKUP')">停用</el-button></div>
|
<div class="address-book-control"><el-select v-model="form.senderAddressId" clearable filterable :loading="orderAddressesLoading" placeholder="选择企业保存的提货地址" @change="selectPickupAddress"><el-option v-for="address in pickupAddresses" :key="String(address.id)" :label="addressLabel(address)" :value="String(address.id)" /></el-select><el-button @click="savePickupAddress">保存当前地址</el-button><el-button v-if="form.senderAddressId" link type="danger" @click="removeOrderAddress('PICKUP')">停用</el-button></div>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="提货联系人" prop="shipperPartySnapshot.contactName" required :rules="requiredTextRules('请输入提货联系人')" class="prototype-form-row prototype-form-row--compact"><el-input v-model="form.shipperPartySnapshot.contactName" maxlength="50" placeholder="请输入联系人姓名" /></el-form-item>
|
<el-form-item label="提货联系人" prop="shipperPartySnapshot.contactName" required :rules="requiredTextRules('请输入提货联系人')" class="prototype-form-row prototype-form-row--compact"><el-input v-model="form.shipperPartySnapshot.contactName" maxlength="50" placeholder="" /></el-form-item>
|
||||||
<el-form-item label="联系电话" prop="shipperPartySnapshot.phone" required :rules="requiredTextRules('请输入提货联系电话')" class="prototype-form-row prototype-form-row--compact"><el-input v-model="form.shipperPartySnapshot.phone" maxlength="30" placeholder="请输入联系电话" /></el-form-item>
|
<el-form-item label="联系电话" prop="shipperPartySnapshot.phone" required :rules="requiredTextRules('请输入提货联系电话')" class="prototype-form-row prototype-form-row--compact"><el-input v-model="form.shipperPartySnapshot.phone" maxlength="30" placeholder="" /></el-form-item>
|
||||||
<el-form-item label="州 / 省" class="prototype-form-row prototype-form-row--compact"><el-input v-model="form.shipperPartySnapshot.province" maxlength="100" placeholder="请输入州或省" /></el-form-item>
|
<el-form-item label="州 / 省" class="prototype-form-row prototype-form-row--compact"><el-input v-model="form.shipperPartySnapshot.province" maxlength="100" placeholder="" /></el-form-item>
|
||||||
<el-form-item label="城市" prop="shipperPartySnapshot.city" required :rules="requiredTextRules('请输入提货城市')" class="prototype-form-row prototype-form-row--compact"><el-input v-model="form.shipperPartySnapshot.city" maxlength="100" placeholder="请输入城市" /></el-form-item>
|
<el-form-item label="城市" prop="shipperPartySnapshot.city" required :rules="requiredTextRules('请输入提货城市')" class="prototype-form-row prototype-form-row--compact"><el-input v-model="form.shipperPartySnapshot.city" maxlength="100" placeholder="" /></el-form-item>
|
||||||
<el-form-item label="提货地址" prop="shipperPartySnapshot.address" required :rules="requiredTextRules('请输入提货地址')" class="prototype-form-row prototype-form-row--wide"><el-input v-model="form.shipperPartySnapshot.address" maxlength="300" placeholder="请输入详细提货地址" /></el-form-item>
|
<el-form-item label="提货地址" prop="shipperPartySnapshot.address" required :rules="requiredTextRules('请输入提货地址')" class="prototype-form-row prototype-form-row--wide"><el-input v-model="form.shipperPartySnapshot.address" maxlength="300" placeholder="" /></el-form-item>
|
||||||
</template>
|
</template>
|
||||||
<el-form-item label="国内收货仓" prop="receivingWarehouseId" required class="prototype-form-row prototype-form-row--wide"><el-radio-group v-model="form.receivingWarehouseId" class="warehouse-options" @change="loadSelectedWarehouse"><el-radio v-for="warehouse in availableWarehouses" :key="warehouse.id" :value="warehouse.id">{{ warehouse.name }}</el-radio></el-radio-group></el-form-item>
|
<el-form-item label="国内收货仓" prop="receivingWarehouseId" required class="prototype-form-row prototype-form-row--wide"><el-radio-group v-model="form.receivingWarehouseId" class="warehouse-options" @change="loadSelectedWarehouse"><el-radio v-for="warehouse in availableWarehouses" :key="warehouse.id" :value="warehouse.id">{{ warehouse.name }}</el-radio></el-radio-group></el-form-item>
|
||||||
</div>
|
</div>
|
||||||
@@ -2275,8 +2235,8 @@ async function searchOrders(model: QueryModel) {
|
|||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="买单 / 退税" prop="taxMode" required><el-radio-group v-model="form.taxMode"><el-radio value="BUY_DECLARATION">买单</el-radio><el-radio value="TAX_REFUND">退税</el-radio></el-radio-group></el-form-item>
|
<el-form-item label="买单 / 退税" prop="taxMode" required><el-radio-group v-model="form.taxMode"><el-radio value="BUY_DECLARATION">买单</el-radio><el-radio value="TAX_REFUND">退税</el-radio></el-radio-group></el-form-item>
|
||||||
<el-form-item label="是否整柜" prop="transportMode" required><el-radio-group v-model="form.transportMode"><el-radio value="FCL">整柜</el-radio><el-radio value="LCL">散货</el-radio></el-radio-group></el-form-item>
|
<el-form-item label="是否整柜" prop="transportMode" required><el-radio-group v-model="form.transportMode"><el-radio value="FCL">整柜</el-radio><el-radio value="LCL">散货</el-radio></el-radio-group></el-form-item>
|
||||||
<el-form-item label="期望出货日期"><el-date-picker v-model="form.expectedDepartureDate" type="date" value-format="YYYY-MM-DD" placeholder="请选择期望出货日期" /></el-form-item>
|
<el-form-item label="期望出货日期"><el-date-picker v-model="form.expectedDepartureDate" type="date" value-format="YYYY-MM-DD" placeholder="" /></el-form-item>
|
||||||
<el-form-item label="订单备注"><el-input v-model="form.customerRemark" type="textarea" :rows="3" resize="vertical" maxlength="300" show-word-limit placeholder="选填,例如:入仓前请电话联系" /></el-form-item>
|
<el-form-item label="订单备注"><el-input v-model="form.customerRemark" type="textarea" :rows="3" resize="vertical" maxlength="300" show-word-limit placeholder="" /></el-form-item>
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
@@ -2289,17 +2249,17 @@ async function searchOrders(model: QueryModel) {
|
|||||||
<div class="address-book-control"><el-select v-model="form.privateDestinationAddressId" clearable filterable :loading="orderAddressesLoading" placeholder="选择企业保存的私人仓地址" @change="selectPrivateAddress"><el-option v-for="address in privateAddresses" :key="String(address.id)" :label="addressLabel(address)" :value="String(address.id)" /></el-select><el-button @click="savePrivateAddress">保存当前地址</el-button><el-button v-if="form.privateDestinationAddressId" link type="danger" @click="removeOrderAddress('PRIVATE_DESTINATION')">停用</el-button></div>
|
<div class="address-book-control"><el-select v-model="form.privateDestinationAddressId" clearable filterable :loading="orderAddressesLoading" placeholder="选择企业保存的私人仓地址" @change="selectPrivateAddress"><el-option v-for="address in privateAddresses" :key="String(address.id)" :label="addressLabel(address)" :value="String(address.id)" /></el-select><el-button @click="savePrivateAddress">保存当前地址</el-button><el-button v-if="form.privateDestinationAddressId" link type="danger" @click="removeOrderAddress('PRIVATE_DESTINATION')">停用</el-button></div>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
|
|
||||||
<el-form-item v-if="form.destinationType !== 'PRIVATE'" :label="form.destinationType === 'FBA' ? 'FBA 仓' : '海外仓'" prop="destinationWarehouseId" required :rules="requiredSelectRules('请选择平台维护的目的仓')" class="prototype-form-row"><el-select v-model="form.destinationWarehouseId" filterable :loading="destinationWarehousesLoading" placeholder="请选择当前可送达的目的仓" @change="selectDestinationWarehouse"><el-option v-for="warehouse in availableDestinationWarehouses" :key="warehouse.id" :label="form.destinationType === 'FBA' ? warehouse.code : `${warehouse.name} · ${warehouse.code}`" :value="warehouse.id" /></el-select><small v-if="!destinationWarehousesLoading && availableDestinationWarehouses.length === 0" class="field-guidance">平台暂未维护可用的{{ form.destinationType === 'FBA' ? ' FBA 仓' : '海外仓' }},请联系平台管理员。</small></el-form-item>
|
<el-form-item v-if="form.destinationType !== 'PRIVATE'" :label="form.destinationType === 'FBA' ? 'FBA 仓' : '海外仓'" prop="destinationWarehouseId" required :rules="requiredSelectRules('请选择平台维护的目的仓')" class="prototype-form-row"><el-select v-model="form.destinationWarehouseId" filterable :loading="destinationWarehousesLoading" placeholder="" @change="selectDestinationWarehouse"><el-option v-for="warehouse in availableDestinationWarehouses" :key="warehouse.id" :label="form.destinationType === 'FBA' ? warehouse.code : `${warehouse.name} · ${warehouse.code}`" :value="warehouse.id" /></el-select><small v-if="!destinationWarehousesLoading && availableDestinationWarehouses.length === 0" class="field-guidance">平台暂未维护可用的{{ form.destinationType === 'FBA' ? ' FBA 仓' : '海外仓' }},请联系平台管理员。</small></el-form-item>
|
||||||
<div v-if="form.destinationType !== 'PRIVATE' && selectedDestinationWarehouse" class="selected-destination"><MapPin :size="17" /><div><span>{{ form.destinationType === 'FBA' ? selectedDestinationWarehouse.code : `${selectedDestinationWarehouse.name} · ${selectedDestinationWarehouse.code}` }} · {{ selectedDestinationWarehouse.countryCode }}</span><small v-if="selectedDestinationWarehouse.address">仓库地址:{{ selectedDestinationWarehouse.province }}{{ selectedDestinationWarehouse.city }} {{ selectedDestinationWarehouse.address }}</small><small v-if="selectedDestinationWarehouse.contactName || selectedDestinationWarehouse.contactPhone">联系人:{{ selectedDestinationWarehouse.contactName || '-' }} {{ selectedDestinationWarehouse.contactPhone }}</small></div></div>
|
<div v-if="form.destinationType !== 'PRIVATE' && selectedDestinationWarehouse" class="selected-destination"><MapPin :size="17" /><div><span>{{ form.destinationType === 'FBA' ? selectedDestinationWarehouse.code : `${selectedDestinationWarehouse.name} · ${selectedDestinationWarehouse.code}` }} · {{ selectedDestinationWarehouse.countryCode }}</span><small v-if="selectedDestinationWarehouse.address">仓库地址:{{ selectedDestinationWarehouse.province }}{{ selectedDestinationWarehouse.city }} {{ selectedDestinationWarehouse.address }}</small><small v-if="selectedDestinationWarehouse.contactName || selectedDestinationWarehouse.contactPhone">联系人:{{ selectedDestinationWarehouse.contactName || '-' }} {{ selectedDestinationWarehouse.contactPhone }}</small></div></div>
|
||||||
<template v-if="form.destinationType === 'PRIVATE' && form.consigneePartySnapshot">
|
<template v-if="form.destinationType === 'PRIVATE' && form.consigneePartySnapshot">
|
||||||
<el-form-item label="私人地址名称" prop="destinationWarehouseName" required class="prototype-form-row"><el-input v-model="form.destinationWarehouseName" maxlength="128" placeholder="例如:洛杉矶客户自有仓" @input="syncPrivateDestinationName" /></el-form-item>
|
<el-form-item label="私人地址名称" prop="destinationWarehouseName" required class="prototype-form-row"><el-input v-model="form.destinationWarehouseName" maxlength="128" placeholder="例如:洛杉矶客户自有仓" @input="syncPrivateDestinationName" /></el-form-item>
|
||||||
<el-form-item label="收件人姓名" prop="consigneePartySnapshot.contactName" required :rules="requiredTextRules('请输入收货联系人姓名')" class="prototype-form-row prototype-form-row--compact"><el-input v-model="form.consigneePartySnapshot.contactName" maxlength="50" placeholder="请输入收件人姓名" /></el-form-item>
|
<el-form-item label="收件人姓名" prop="consigneePartySnapshot.contactName" required :rules="requiredTextRules('请输入收货联系人姓名')" class="prototype-form-row prototype-form-row--compact"><el-input v-model="form.consigneePartySnapshot.contactName" maxlength="50" placeholder="" /></el-form-item>
|
||||||
<el-form-item label="收件人电话" prop="consigneePartySnapshot.phone" required :rules="requiredTextRules('请输入收货联系电话')" class="prototype-form-row prototype-form-row--compact"><el-input v-model="form.consigneePartySnapshot.phone" maxlength="30" placeholder="请输入收件人电话" /></el-form-item>
|
<el-form-item label="收件人电话" prop="consigneePartySnapshot.phone" required :rules="requiredTextRules('请输入收货联系电话')" class="prototype-form-row prototype-form-row--compact"><el-input v-model="form.consigneePartySnapshot.phone" maxlength="30" placeholder="" /></el-form-item>
|
||||||
<el-form-item label="收件国家代码" prop="destinationCountryCode" required class="prototype-form-row prototype-form-row--short"><el-input v-model="form.destinationCountryCode" maxlength="2" placeholder="例如:US" /></el-form-item>
|
<el-form-item label="收件国家代码" prop="destinationCountryCode" required class="prototype-form-row prototype-form-row--short"><el-input v-model="form.destinationCountryCode" maxlength="2" placeholder="例如:US" /></el-form-item>
|
||||||
<el-form-item label="州 / 省" class="prototype-form-row prototype-form-row--compact"><el-input v-model="form.consigneePartySnapshot.province" maxlength="100" placeholder="请输入州或省" /></el-form-item>
|
<el-form-item label="州 / 省" class="prototype-form-row prototype-form-row--compact"><el-input v-model="form.consigneePartySnapshot.province" maxlength="100" placeholder="" /></el-form-item>
|
||||||
<el-form-item label="城市" prop="consigneePartySnapshot.city" required :rules="requiredTextRules('请输入收件城市')" class="prototype-form-row prototype-form-row--compact"><el-input v-model="form.consigneePartySnapshot.city" maxlength="100" placeholder="请输入城市" /></el-form-item>
|
<el-form-item label="城市" prop="consigneePartySnapshot.city" required :rules="requiredTextRules('请输入收件城市')" class="prototype-form-row prototype-form-row--compact"><el-input v-model="form.consigneePartySnapshot.city" maxlength="100" placeholder="" /></el-form-item>
|
||||||
<el-form-item label="收件地址" prop="consigneePartySnapshot.address" required :rules="requiredTextRules('请输入本单实际收货地址')" class="prototype-form-row prototype-form-row--wide"><el-input v-model="form.consigneePartySnapshot.address" maxlength="300" placeholder="请输入收件详细地址" /></el-form-item>
|
<el-form-item label="收件地址" prop="consigneePartySnapshot.address" required :rules="requiredTextRules('请输入本单实际收货地址')" class="prototype-form-row prototype-form-row--wide"><el-input v-model="form.consigneePartySnapshot.address" maxlength="300" placeholder="" /></el-form-item>
|
||||||
<el-form-item label="邮编" class="prototype-form-row prototype-form-row--short"><el-input v-model="form.consigneePartySnapshot.postalCode" maxlength="20" placeholder="请输入邮编" /></el-form-item>
|
<el-form-item label="邮编" class="prototype-form-row prototype-form-row--short"><el-input v-model="form.consigneePartySnapshot.postalCode" maxlength="20" placeholder="" /></el-form-item>
|
||||||
</template>
|
</template>
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
@@ -2310,9 +2270,9 @@ async function searchOrders(model: QueryModel) {
|
|||||||
<div v-if="isCreatePage && !routeDraftId && canCreateOrder" class="cargo-import-actions">
|
<div v-if="isCreatePage && !routeDraftId && canCreateOrder" class="cargo-import-actions">
|
||||||
<el-button class="cargo-download-button" :loading="batchTemplateDownloading" @click="downloadBatchTemplate"><Download :size="16" />下载 Excel 模板</el-button>
|
<el-button class="cargo-download-button" :loading="batchTemplateDownloading" @click="downloadBatchTemplate"><Download :size="16" />下载 Excel 模板</el-button>
|
||||||
<el-button class="cargo-upload-button" type="primary" plain @click="openBatchImport"><Upload :size="16" />Excel 批量导入</el-button>
|
<el-button class="cargo-upload-button" type="primary" plain @click="openBatchImport"><Upload :size="16" />Excel 批量导入</el-button>
|
||||||
<span class="cargo-table-hint">Excel 导入用于一次创建多条订单草稿。</span>
|
|
||||||
</div>
|
</div>
|
||||||
<span v-else class="cargo-table-hint">可逐行维护货物明细。</span>
|
|
||||||
<div class="cargo-table-actions"><el-button @click="addCargoItem"><Plus :size="16" />添加行</el-button><el-button type="danger" plain :disabled="!selectedCargoIds.length" @click="removeSelectedCargoItems"><Trash2 :size="15" />删除所选行</el-button></div>
|
<div class="cargo-table-actions"><el-button @click="addCargoItem"><Plus :size="16" />添加行</el-button><el-button type="danger" plain :disabled="!selectedCargoIds.length" @click="removeSelectedCargoItems"><Trash2 :size="15" />删除所选行</el-button></div>
|
||||||
</div>
|
</div>
|
||||||
<div class="cargo-table-wrap" :class="{ 'is-dropship': form.fulfillmentType === 'ONE_CLICK_DROPSHIP' }">
|
<div class="cargo-table-wrap" :class="{ 'is-dropship': form.fulfillmentType === 'ONE_CLICK_DROPSHIP' }">
|
||||||
@@ -2335,7 +2295,7 @@ async function searchOrders(model: QueryModel) {
|
|||||||
<td><el-form-item :prop="`items.${index}.unitsPerPackage`" required :rules="positiveNumberRules('每箱数量必须大于 0', true)"><el-input-number v-model="item.unitsPerPackage" :min="1" :controls="false" placeholder="每箱数量" @change="syncSkuQuantity(item)" /></el-form-item></td><td><span v-if="isAdditionalMixedSku(item, index)" class="shared-carton-value">同箱</span><el-form-item v-else :prop="`items.${index}.packageCount`" required :rules="positiveNumberRules('箱数必须大于 0', true)"><el-input-number v-model="item.packageCount" :min="1" :controls="false" placeholder="箱数" @change="syncPackingGroupFields(item)" /></el-form-item></td><td><span v-if="isAdditionalMixedSku(item, index)" class="shared-carton-value">同箱</span><el-form-item v-else :prop="`items.${index}.grossWeightKg`" required :rules="positiveNumberRules('总毛重必须大于 0')"><el-input-number v-model="item.grossWeightKg" :min="0" :precision="3" :controls="false" placeholder="总毛重" @change="syncPackingGroupFields(item)" /></el-form-item></td><td><span v-if="isAdditionalMixedSku(item, index)" class="shared-carton-value">同箱</span><el-form-item v-else :prop="`items.${index}.volumeCbm`" required :rules="positiveNumberRules('总体积必须大于 0')"><el-input-number v-model="item.volumeCbm" :min="0" :precision="4" :controls="false" placeholder="总体积" @change="syncPackingGroupFields(item)" /></el-form-item></td><td><span v-if="isAdditionalMixedSku(item, index)" class="derived-sku-value">{{ item.pieces }}</span><el-form-item v-else :prop="`items.${index}.pieces`" required :rules="positiveNumberRules('总数量必须大于 0', true)"><el-input-number v-model="item.pieces" :min="1" :controls="false" placeholder="总数量" /></el-form-item></td><td><span v-if="isAdditionalMixedSku(item, index)" class="shared-carton-value">同箱</span><el-input-number v-else v-model="item.netWeightKg" :min="0" :precision="3" :controls="false" placeholder="净重" @change="syncPackingGroupFields(item)" /></td>
|
<td><el-form-item :prop="`items.${index}.unitsPerPackage`" required :rules="positiveNumberRules('每箱数量必须大于 0', true)"><el-input-number v-model="item.unitsPerPackage" :min="1" :controls="false" placeholder="每箱数量" @change="syncSkuQuantity(item)" /></el-form-item></td><td><span v-if="isAdditionalMixedSku(item, index)" class="shared-carton-value">同箱</span><el-form-item v-else :prop="`items.${index}.packageCount`" required :rules="positiveNumberRules('箱数必须大于 0', true)"><el-input-number v-model="item.packageCount" :min="1" :controls="false" placeholder="箱数" @change="syncPackingGroupFields(item)" /></el-form-item></td><td><span v-if="isAdditionalMixedSku(item, index)" class="shared-carton-value">同箱</span><el-form-item v-else :prop="`items.${index}.grossWeightKg`" required :rules="positiveNumberRules('总毛重必须大于 0')"><el-input-number v-model="item.grossWeightKg" :min="0" :precision="3" :controls="false" placeholder="总毛重" @change="syncPackingGroupFields(item)" /></el-form-item></td><td><span v-if="isAdditionalMixedSku(item, index)" class="shared-carton-value">同箱</span><el-form-item v-else :prop="`items.${index}.volumeCbm`" required :rules="positiveNumberRules('总体积必须大于 0')"><el-input-number v-model="item.volumeCbm" :min="0" :precision="4" :controls="false" placeholder="总体积" @change="syncPackingGroupFields(item)" /></el-form-item></td><td><span v-if="isAdditionalMixedSku(item, index)" class="derived-sku-value">{{ item.pieces }}</span><el-form-item v-else :prop="`items.${index}.pieces`" required :rules="positiveNumberRules('总数量必须大于 0', true)"><el-input-number v-model="item.pieces" :min="1" :controls="false" placeholder="总数量" /></el-form-item></td><td><span v-if="isAdditionalMixedSku(item, index)" class="shared-carton-value">同箱</span><el-input-number v-else v-model="item.netWeightKg" :min="0" :precision="3" :controls="false" placeholder="净重" @change="syncPackingGroupFields(item)" /></td>
|
||||||
<td><el-input-number v-model="item.unitDeclaredValue" :min="0" :precision="2" :controls="false" placeholder="申报单价" /></td><td><el-input-number v-model="item.declaredValue" :min="0" :precision="2" :controls="false" placeholder="申报总价" /></td><td><el-input v-model="item.usage" maxlength="128" placeholder="用途" /></td><td><el-input v-model="item.model" maxlength="64" placeholder="型号" /></td><td><el-input v-model="item.brand" maxlength="64" placeholder="品牌" /></td>
|
<td><el-input-number v-model="item.unitDeclaredValue" :min="0" :precision="2" :controls="false" placeholder="申报单价" /></td><td><el-input-number v-model="item.declaredValue" :min="0" :precision="2" :controls="false" placeholder="申报总价" /></td><td><el-input v-model="item.usage" maxlength="128" placeholder="用途" /></td><td><el-input v-model="item.model" maxlength="64" placeholder="型号" /></td><td><el-input v-model="item.brand" maxlength="64" placeholder="品牌" /></td>
|
||||||
<td class="cargo-dimensions-column"><div class="cargo-table-dimensions"><el-input-number v-model="item.productLengthCm" :min="0" :precision="2" :controls="false" placeholder="长" /><span>×</span><el-input-number v-model="item.productWidthCm" :min="0" :precision="2" :controls="false" placeholder="宽" /><span>×</span><el-input-number v-model="item.productHeightCm" :min="0" :precision="2" :controls="false" placeholder="高" /></div></td>
|
<td class="cargo-dimensions-column"><div class="cargo-table-dimensions"><el-input-number v-model="item.productLengthCm" :min="0" :precision="2" :controls="false" placeholder="长" /><span>×</span><el-input-number v-model="item.productWidthCm" :min="0" :precision="2" :controls="false" placeholder="宽" /><span>×</span><el-input-number v-model="item.productHeightCm" :min="0" :precision="2" :controls="false" placeholder="高" /></div></td>
|
||||||
<td><el-form-item :prop="`items.${index}.shipmentId`" :required="form.destinationType === 'FBA'" :rules="form.destinationType === 'FBA' ? requiredTextRules('FBA 货物请输入货件编号') : undefined"><el-input v-model="item.shipmentId" maxlength="64" placeholder="货件编号" /></el-form-item></td><td><el-form-item :prop="`items.${index}.referenceId`" :required="form.destinationType === 'FBA'" :rules="form.destinationType === 'FBA' ? requiredTextRules('FBA 货物请输入跟踪编号') : undefined"><el-input v-model="item.referenceId" maxlength="64" placeholder="跟踪编号" /></el-form-item></td><td><el-form-item :prop="`items.${index}.upc`"><el-input v-model="item.upc" maxlength="64" placeholder="UPC NO.(选填)" /></el-form-item></td><td><el-input v-model="item.remark" maxlength="500" placeholder="备注" /></td><td class="cargo-operation-column"><el-button v-if="form.fulfillmentType === 'ONE_CLICK_DROPSHIP'" link type="primary" :aria-label="`为货物 ${index + 1} 添加同箱 SKU`" @click="addSkuToPackingGroup(index)"><Plus :size="15" />添加 SKU</el-button><el-button link type="danger" :aria-label="`删除货物 ${index + 1}`" @click="removeCargoItem(index)"><Trash2 :size="15" />删除</el-button></td>
|
<td><el-form-item :prop="`items.${index}.shipmentId`" :required="form.destinationType === 'FBA'" :rules="form.destinationType === 'FBA' ? requiredTextRules('FBA 货物请输入货件编号') : undefined"><el-input v-model="item.shipmentId" maxlength="64" placeholder="货件编号" /></el-form-item></td><td><el-form-item :prop="`items.${index}.referenceId`" :required="form.destinationType === 'FBA'" :rules="form.destinationType === 'FBA' ? requiredTextRules('FBA 货物请输入跟踪编号') : undefined"><el-input v-model="item.referenceId" maxlength="64" placeholder="跟踪编号" /></el-form-item></td><td><el-form-item :prop="`items.${index}.upc`"><el-input v-model="item.upc" maxlength="64" placeholder="UPC NO.(选填)" /></el-form-item></td><td><el-input v-model="item.remark" maxlength="500" placeholder="" /></td><td class="cargo-operation-column"><el-button v-if="form.fulfillmentType === 'ONE_CLICK_DROPSHIP'" link type="primary" :aria-label="`为货物 ${index + 1} 添加同箱 SKU`" @click="addSkuToPackingGroup(index)"><Plus :size="15" />添加 SKU</el-button><el-button link type="danger" :aria-label="`删除货物 ${index + 1}`" @click="removeCargoItem(index)"><Trash2 :size="15" />删除</el-button></td>
|
||||||
</tr></tbody>
|
</tr></tbody>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
@@ -2343,7 +2303,7 @@ async function searchOrders(model: QueryModel) {
|
|||||||
</section>
|
</section>
|
||||||
|
|
||||||
<section class="order-form-section prototype-section cost-estimate-section" aria-label="费用预估">
|
<section class="order-form-section prototype-section cost-estimate-section" aria-label="费用预估">
|
||||||
<div class="order-section-heading"><div><h3>参考运费</h3><p>根据当前价格表、渠道、目的仓以及货物重量和体积实时试算。</p></div></div>
|
<div class="order-section-heading"><div><h3>参考运费</h3></div></div>
|
||||||
<div class="price-estimate" :class="{ 'is-loading': priceEstimateLoading }" aria-live="polite">
|
<div class="price-estimate" :class="{ 'is-loading': priceEstimateLoading }" aria-live="polite">
|
||||||
<div v-if="priceEstimateLoading" class="price-estimate__state" v-loading="true">正在获取实时参考报价</div>
|
<div v-if="priceEstimateLoading" class="price-estimate__state" v-loading="true">正在获取实时参考报价</div>
|
||||||
<div v-else-if="priceEstimateError" class="price-estimate__state is-error" role="alert">
|
<div v-else-if="priceEstimateError" class="price-estimate__state is-error" role="alert">
|
||||||
@@ -2423,7 +2383,7 @@ async function searchOrders(model: QueryModel) {
|
|||||||
<el-button link type="primary" class="detail-back-action" @click="router.push({ name: 'first-leg-orders' })">← 返回列表</el-button>
|
<el-button link type="primary" class="detail-back-action" @click="router.push({ name: 'first-leg-orders' })">← 返回列表</el-button>
|
||||||
<div><h2>{{ detailOrder.businessSummary.inboundCode || (detailOrder.status === 'CANCELLED' ? (detailOrder.orderNo || '—') : detailOrder.status === 'DRAFT' ? '入仓码提交后生成' : '入仓码待生成') }}</h2><p v-if="detailOrder.status === 'CANCELLED'">订单已取消。</p><p v-else>{{ getFirstLegTransportModeLabel(detailOrder.transportMode) }} · {{ detailOrder.origin || '起运地待更新' }} → {{ detailOrder.destination || '目的地待更新' }}</p></div>
|
<div><h2>{{ detailOrder.businessSummary.inboundCode || (detailOrder.status === 'CANCELLED' ? (detailOrder.orderNo || '—') : detailOrder.status === 'DRAFT' ? '入仓码提交后生成' : '入仓码待生成') }}</h2><p v-if="detailOrder.status === 'CANCELLED'">订单已取消。</p><p v-else>{{ getFirstLegTransportModeLabel(detailOrder.transportMode) }} · {{ detailOrder.origin || '起运地待更新' }} → {{ detailOrder.destination || '目的地待更新' }}</p></div>
|
||||||
</div>
|
</div>
|
||||||
<div class="detail-heading-actions"><el-tag :type="getFirstLegStatusTone(detailOrder.status)" effect="light">{{ getFirstLegStatusLabel(detailOrder.status) }}</el-tag><el-button v-if="canEditOrder && canClientEditFirstLegOrder(detailOrder.status)" type="primary" plain :loading="openingEditor" @click="openEdit(detailOrder)"><Pencil :size="16" />编辑草稿</el-button><el-button v-if="canOfferCancellation(detailOrder)" type="danger" plain :loading="cancellingOrderId === detailOrder.id" :disabled="!!cancellingOrderId" @click="cancelOrder(detailOrder)">{{ pendingCancellation?.id === detailOrder.id ? '重试取消' : '取消订单' }}</el-button></div>
|
<div class="detail-heading-actions"><el-tag :type="getFirstLegStatusTone(detailOrder.status)" effect="light">{{ getFirstLegStatusLabel(detailOrder.status) }}</el-tag><el-button v-if="canEditOrder && canClientEditFirstLegOrder(detailOrder.status)" type="primary" plain :loading="openingEditor" @click="openEdit(detailOrder)"><Pencil :size="16" />编辑草稿</el-button><el-button v-if="canOfferCancellation(detailOrder)" type="danger" plain :loading="cancellingOrderId === detailOrder.id" :disabled="!!cancellingOrderId" @click="cancelOrder(detailOrder)">取消订单</el-button></div>
|
||||||
</div>
|
</div>
|
||||||
<section class="detail-section">
|
<section class="detail-section">
|
||||||
<h3>订单与运输</h3>
|
<h3>订单与运输</h3>
|
||||||
@@ -2471,7 +2431,7 @@ async function searchOrders(model: QueryModel) {
|
|||||||
<el-table-column label="预计船期" width="170"><template #default="{ row }">{{ row.estimatedSailingAt ? formatDateTime(row.estimatedSailingAt) : '待更新' }}</template></el-table-column>
|
<el-table-column label="预计船期" width="170"><template #default="{ row }">{{ row.estimatedSailingAt ? formatDateTime(row.estimatedSailingAt) : '待更新' }}</template></el-table-column>
|
||||||
<el-table-column prop="pickingStatusLabel" label="拣货状态" width="120"><template #default="{ row }"><el-tag size="small" effect="plain">{{ row.pickingStatusLabel }}</el-tag></template></el-table-column>
|
<el-table-column prop="pickingStatusLabel" label="拣货状态" width="120"><template #default="{ row }"><el-tag size="small" effect="plain">{{ row.pickingStatusLabel }}</el-tag></template></el-table-column>
|
||||||
</el-table>
|
</el-table>
|
||||||
<p v-else class="detail-inline-empty">尚未分配柜次,后续柜次节点将在这里同步。</p>
|
<p v-else class="detail-inline-empty">尚未分配柜次</p>
|
||||||
<TransportFactsTable :fragments="detailOrder.businessSummary.transportFragments" />
|
<TransportFactsTable :fragments="detailOrder.businessSummary.transportFragments" />
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
@@ -2548,7 +2508,7 @@ async function searchOrders(model: QueryModel) {
|
|||||||
:data="inboundBilling"
|
:data="inboundBilling"
|
||||||
:loading="inboundBillingLoading"
|
:loading="inboundBillingLoading"
|
||||||
:unavailable="inboundBillingUnavailable"
|
:unavailable="inboundBillingUnavailable"
|
||||||
unavailable-message="未推送计费重"
|
unavailable-message="未推送费用"
|
||||||
:error="inboundBillingError"
|
:error="inboundBillingError"
|
||||||
:can-confirm="canConfirmInboundFee"
|
:can-confirm="canConfirmInboundFee"
|
||||||
@retry="retryInboundBilling"
|
@retry="retryInboundBilling"
|
||||||
@@ -2586,10 +2546,7 @@ async function searchOrders(model: QueryModel) {
|
|||||||
.supporting-data-error span { overflow-wrap: anywhere; color: var(--muted); font-size: 11px; line-height: 1.55; }
|
.supporting-data-error span { overflow-wrap: anywhere; color: var(--muted); font-size: 11px; line-height: 1.55; }
|
||||||
.order-row-actions, .editor-actions { display: flex; justify-content: flex-end; gap: 8px; }
|
.order-row-actions, .editor-actions { display: flex; justify-content: flex-end; gap: 8px; }
|
||||||
.order-table-card { padding: 0; overflow: hidden; border: 1px solid var(--client-border); border-radius: var(--client-radius); box-shadow: none; }
|
.order-table-card { padding: 0; overflow: hidden; border: 1px solid var(--client-border); border-radius: var(--client-radius); box-shadow: none; }
|
||||||
.prototype-order-table :deep(.data-table__toolbar) { flex-wrap: nowrap; }
|
.order-queue-tabs { display: flex; min-width: 0; align-items: center; gap: 4px; overflow-x: auto; padding: 14px 16px 10px; border-bottom: 1px solid var(--client-border); scrollbar-width: thin; }
|
||||||
.prototype-order-table :deep(.data-table__toolbar-heading) { min-width: 0; flex: 1; flex-wrap: nowrap; }
|
|
||||||
.prototype-order-table :deep(.data-table__toolbar-actions) { flex-shrink: 0; }
|
|
||||||
.order-queue-tabs { display: flex; min-width: 0; align-items: center; gap: 4px; overflow-x: auto; padding: 7px 0 10px; scrollbar-width: thin; }
|
|
||||||
.order-queue-tabs button { flex-shrink: 0; white-space: nowrap; }
|
.order-queue-tabs button { flex-shrink: 0; white-space: nowrap; }
|
||||||
.queue-stage-count { margin-left: 3px; }
|
.queue-stage-count { margin-left: 3px; }
|
||||||
.order-queue-tabs button { position: relative; min-height: 34px; padding: 0 12px; border: 1px solid transparent; border-radius: 7px; background: transparent; color: #667085; cursor: pointer; font: inherit; font-weight: 600; }
|
.order-queue-tabs button { position: relative; min-height: 34px; padding: 0 12px; border: 1px solid transparent; border-radius: 7px; background: transparent; color: #667085; cursor: pointer; font: inherit; font-weight: 600; }
|
||||||
|
|||||||
@@ -201,7 +201,7 @@ function buildOrderDraft(row: QuickOrderRow, channel: QuickChannelOption): First
|
|||||||
destinationCountryCode: row.destinationCountryCode,
|
destinationCountryCode: row.destinationCountryCode,
|
||||||
destinationWarehouseId: row.destinationWarehouseId,
|
destinationWarehouseId: row.destinationWarehouseId,
|
||||||
destinationWarehouseName: row.destinationWarehouseName,
|
destinationWarehouseName: row.destinationWarehouseName,
|
||||||
pickupMethod: 'SELF_EXPRESS',
|
pickupMethod: 'SELF_TRUCK',
|
||||||
trackingNumber: '',
|
trackingNumber: '',
|
||||||
channelCode: channel.channelCode,
|
channelCode: channel.channelCode,
|
||||||
channelName: channel.channelName,
|
channelName: channel.channelName,
|
||||||
@@ -422,7 +422,7 @@ onMounted(loadChannels)
|
|||||||
<section class="quick-order-page" aria-labelledby="quick-order-heading">
|
<section class="quick-order-page" aria-labelledby="quick-order-heading">
|
||||||
<header class="quick-order-intro">
|
<header class="quick-order-intro">
|
||||||
<h2 id="quick-order-heading">客户下单</h2>
|
<h2 id="quick-order-heading">客户下单</h2>
|
||||||
<p>只需输入渠道、目的仓、产品 SKU 和箱数,即可快速填写订单。</p>
|
|
||||||
<small v-if="manualInboundCodeRequired">当前全局使用旧系统入仓码,每张草稿都需要填写旧系统生成的入仓码。</small>
|
<small v-if="manualInboundCodeRequired">当前全局使用旧系统入仓码,每张草稿都需要填写旧系统生成的入仓码。</small>
|
||||||
<small>每一行会直接生成一张独立草稿单,其他明细可进入草稿后继续编辑并提交。</small>
|
<small>每一行会直接生成一张独立草稿单,其他明细可进入草稿后继续编辑并提交。</small>
|
||||||
</header>
|
</header>
|
||||||
@@ -483,7 +483,7 @@ onMounted(loadChannels)
|
|||||||
<td class="products-cell">
|
<td class="products-cell">
|
||||||
<div v-for="(product, productIndex) in row.products" :key="product.id" class="product-fields">
|
<div v-for="(product, productIndex) in row.products" :key="product.id" class="product-fields">
|
||||||
<el-input v-model="product.sku" maxlength="64" placeholder="产品 SKU" />
|
<el-input v-model="product.sku" maxlength="64" placeholder="产品 SKU" />
|
||||||
<el-input-number v-model="product.packageCount" :min="1" :max="99999" :precision="0" controls-position="right" aria-label="箱数" placeholder="请输入箱数" />
|
<el-input-number v-model="product.packageCount" :min="1" :max="99999" :precision="0" controls-position="right" aria-label="箱数" placeholder="" />
|
||||||
<el-button v-if="row.products.length > 1" text type="danger" aria-label="删除产品" @click="removeProduct(row, productIndex)"><Trash2 :size="15" /></el-button>
|
<el-button v-if="row.products.length > 1" text type="danger" aria-label="删除产品" @click="removeProduct(row, productIndex)"><Trash2 :size="15" /></el-button>
|
||||||
</div>
|
</div>
|
||||||
</td>
|
</td>
|
||||||
|
|||||||
@@ -76,7 +76,7 @@ watch(originWarehouseId, (value, previous) => { if (!value || previous === '') r
|
|||||||
<template>
|
<template>
|
||||||
<div class="pricing-page"><section class="pricing-inquiry"><div class="inquiry-copy"><span>SAILING PRICE INQUIRY</span><h2>船期价格查询</h2><p>重量或体积填写一项即可,系统会按计价规则自动换算</p></div><el-form class="pricing-form" label-position="top"><el-form-item label="起运仓"><el-select v-model="originWarehouseId" filterable :loading="loading" placeholder="选择起运仓"><el-option v-for="item in warehouses" :key="String(item.id)" :label="`${item.warehouseName} · ${item.warehouseCode}`" :value="item.id" /></el-select></el-form-item><el-form-item label="货物重量"><div class="unit-input"><el-input v-model.number="weight" type="number" min="0" placeholder="可选,输入重量" /><span>KG</span></div></el-form-item><el-form-item label="货物立方数"><div class="unit-input"><el-input v-model.number="volume" type="number" min="0" placeholder="可选,输入体积" /><span>CBM</span></div></el-form-item><el-form-item label="目的 FBA 仓"><el-select v-model="destinationWarehouseId" filterable :loading="loading" placeholder="输入或选择仓库代码"><el-option v-for="item in destinationWarehouses" :key="String(item.id)" :label="item.warehouseCode" :value="item.id" /></el-select></el-form-item><el-form-item label="报价方式"><el-radio-group v-model="taxMode"><el-radio-button value="TAX_INCLUDED" label="包税" /><el-radio-button value="TAX_EXCLUDED" label="不包税" /></el-radio-group></el-form-item><el-form-item class="query-item"><el-button type="primary" :loading="querying" @click="query"><Search :size="16" />立即查询</el-button></el-form-item></el-form>
|
<div class="pricing-page"><section class="pricing-inquiry"><div class="inquiry-copy"><span>SAILING PRICE INQUIRY</span><h2>船期价格查询</h2><p>重量或体积填写一项即可,系统会按计价规则自动换算</p></div><el-form class="pricing-form" label-position="top"><el-form-item label="起运仓"><el-select v-model="originWarehouseId" filterable :loading="loading" placeholder="选择起运仓"><el-option v-for="item in warehouses" :key="String(item.id)" :label="`${item.warehouseName} · ${item.warehouseCode}`" :value="item.id" /></el-select></el-form-item><el-form-item label="货物重量"><div class="unit-input"><el-input v-model.number="weight" type="number" min="0" placeholder="可选,输入重量" /><span>KG</span></div></el-form-item><el-form-item label="货物立方数"><div class="unit-input"><el-input v-model.number="volume" type="number" min="0" placeholder="可选,输入体积" /><span>CBM</span></div></el-form-item><el-form-item label="目的 FBA 仓"><el-select v-model="destinationWarehouseId" filterable :loading="loading" placeholder="输入或选择仓库代码"><el-option v-for="item in destinationWarehouses" :key="String(item.id)" :label="item.warehouseCode" :value="item.id" /></el-select></el-form-item><el-form-item label="报价方式"><el-radio-group v-model="taxMode"><el-radio-button value="TAX_INCLUDED" label="包税" /><el-radio-button value="TAX_EXCLUDED" label="不包税" /></el-radio-group></el-form-item><el-form-item class="query-item"><el-button type="primary" :loading="querying" @click="query"><Search :size="16" />立即查询</el-button></el-form-item></el-form>
|
||||||
<el-dialog v-model="quoteDialogOpen" class="quote-dialog" :show-close="false" :lock-scroll="false" width="min(1080px, calc(100vw - 48px))" top="6vh"><template #header><div class="quote-dialog-head"><div><h3>查询结果</h3><span>{{ resultSummary }}</span></div><button type="button" class="quote-close" aria-label="关闭" @click="quoteDialogOpen = false">×</button></div></template><div class="quote-grid"><article v-for="item in quoteCards" :key="item.quote.channelCode" class="quote-card" :class="recommendation(item)?.className"><div v-if="recommendation(item)" class="quote-ribbon">{{ recommendation(item)?.label }}</div><div class="quote-card-title"><strong>{{ item.channel.channelName }}</strong><span>{{ item.quote.pricingTaxMode === 'TAX_INCLUDED' ? '包税' : '不包税' }} / {{ item.quote.chargeUnit || 'CBM' }}</span></div><div class="quote-price"><b>{{ formatMoney(item.quote) }}</b><small>预估运费</small></div><div class="quote-meta"><div><span>单价</span><strong>{{ formatUnitPrice(item.quote) }}</strong></div><div><span>参考时效</span><strong>{{ item.channel.referenceTransit || '待更新' }}</strong></div><div><span>最晚进仓</span><strong>{{ item.channel.latestWarehouseEntry || '—' }}</strong></div><div><span>船期</span><strong>{{ item.channel.estimatedDepartureText || item.channel.estimatedDepartureDate || '待更新' }}</strong></div></div><el-button type="primary" plain class="quote-order" @click="placeOrder(item.quote.channelCode, item.channel.channelName)">下单</el-button></article></div></el-dialog></section>
|
<el-dialog v-model="quoteDialogOpen" class="quote-dialog" :show-close="false" :lock-scroll="false" width="min(1080px, calc(100vw - 48px))" top="6vh"><template #header><div class="quote-dialog-head"><div><h3>查询结果</h3><span>{{ resultSummary }}</span></div><button type="button" class="quote-close" aria-label="关闭" @click="quoteDialogOpen = false">×</button></div></template><div class="quote-grid"><article v-for="item in quoteCards" :key="item.quote.channelCode" class="quote-card" :class="recommendation(item)?.className"><div v-if="recommendation(item)" class="quote-ribbon">{{ recommendation(item)?.label }}</div><div class="quote-card-title"><strong>{{ item.channel.channelName }}</strong><span>{{ item.quote.pricingTaxMode === 'TAX_INCLUDED' ? '包税' : '不包税' }} / {{ item.quote.chargeUnit || 'CBM' }}</span></div><div class="quote-price"><b>{{ formatMoney(item.quote) }}</b><small>预估运费</small></div><div class="quote-meta"><div><span>单价</span><strong>{{ formatUnitPrice(item.quote) }}</strong></div><div><span>参考时效</span><strong>{{ item.channel.referenceTransit || '待更新' }}</strong></div><div><span>最晚进仓</span><strong>{{ item.channel.latestWarehouseEntry || '—' }}</strong></div><div><span>船期</span><strong>{{ item.channel.estimatedDepartureText || item.channel.estimatedDepartureDate || '待更新' }}</strong></div></div><el-button type="primary" plain class="quote-order" @click="placeOrder(item.quote.channelCode, item.channel.channelName)">下单</el-button></article></div></el-dialog></section>
|
||||||
<section class="pricing-results"><div class="section-title"><div><h2>匹配渠道</h2><span>{{ channels.length }} 个渠道 · 参考价格以服务端估价为准</span></div><Calculator :size="20" /></div><el-skeleton v-if="loading || querying" :rows="4" animated /><el-alert v-else-if="errorMessage" :title="errorMessage" type="error" show-icon /><el-empty v-else-if="!channels.length" description="暂无可用船期价格" /><el-table v-else :data="channels" stripe><el-table-column label="渠道" min-width="160"><template #default="{ row }"><strong>{{ row.channelName }}</strong><small>{{ row.channelCode }}</small></template></el-table-column><el-table-column label="参考船期" min-width="150"><template #default="{ row }">{{ row.estimatedDepartureText || row.estimatedDepartureDate || '待更新' }}</template></el-table-column><el-table-column label="最晚进仓" min-width="130"><template #default="{ row }">{{ row.latestWarehouseEntry || '—' }}</template></el-table-column><el-table-column label="参考时效" width="120"><template #default="{ row }">{{ row.referenceTransit || '—' }}</template></el-table-column><el-table-column label="预估运费" width="150"><template #default="{ row }"><span v-if="quotes.find((quote) => quote.channelCode === row.channelCode)">{{ formatMoney(quotes.find((quote) => quote.channelCode === row.channelCode)!) }}</span><span v-else class="muted">查询后显示</span></template></el-table-column><el-table-column label="附加费说明" min-width="180" prop="surchargeDescription" /><el-table-column label="操作" width="100" fixed="right"><template #default="{ row }"><el-button link type="primary" :disabled="!quotes.some((quote) => quote.channelCode === row.channelCode)" @click="placeOrder(row.channelCode, row.channelName)">下单</el-button></template></el-table-column></el-table></section>
|
<section class="pricing-results"><div class="section-title"><div><h2>匹配渠道</h2><span>{{ channels.length }} 个渠道 · 参考价格以服务端估价为准</span></div><Calculator :size="20" /></div><el-skeleton v-if="loading || querying" :rows="4" animated /><el-alert v-else-if="errorMessage" :title="errorMessage" type="error" show-icon /><el-empty v-else-if="!channels.length" description="暂无可用船期价格" /><el-table v-else :data="channels" stripe><el-table-column label="渠道" min-width="160"><template #default="{ row }"><strong>{{ row.channelName }}</strong><small>{{ row.channelCode }}</small></template></el-table-column><el-table-column label="参考船期" min-width="150"><template #default="{ row }">{{ row.estimatedDepartureText || row.estimatedDepartureDate || '待更新' }}</template></el-table-column><el-table-column label="最晚进仓" min-width="130"><template #default="{ row }">{{ row.latestWarehouseEntry || '—' }}</template></el-table-column><el-table-column label="参考时效" width="120"><template #default="{ row }">{{ row.referenceTransit || '—' }}</template></el-table-column><el-table-column label="预估运费" width="150"><template #default="{ row }"><span v-if="quotes.find((quote) => quote.channelCode === row.channelCode)">{{ formatMoney(quotes.find((quote) => quote.channelCode === row.channelCode)!) }}</span><span v-else class="muted">查询后显示</span></template></el-table-column><el-table-column label="附加费说明" min-width="180" prop="surchargeDescription" /></el-table></section>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,28 @@
|
|||||||
|
# Client 消息中心模块指引
|
||||||
|
|
||||||
|
## 路径基准与读取顺序
|
||||||
|
|
||||||
|
- 本文件适用于 `src/modules/notifications/`,代码路径相对本目录;应用公共规则见 `../../../AGENTS.md`。
|
||||||
|
- 页面:`views/NotificationsView.vue`(收件箱)、`views/NotificationDetailView.vue`(详情);状态在 `store/notifications.ts`,请求在 `api/notifications.ts`。
|
||||||
|
- 后端归 `iam/` 的 `notification/` 子域;契约见 `notification-v1.yaml`。
|
||||||
|
|
||||||
|
## 页面与入口
|
||||||
|
|
||||||
|
| 目标 | 页面/入口 | API 与后端 |
|
||||||
|
|---|---|---|
|
||||||
|
| 消息收件箱、未读与分页 | `views/NotificationsView.vue` | `api/notifications.ts`、`store/notifications.ts`;`iam/notification/` |
|
||||||
|
| 消息详情与业务跳转 | `views/NotificationDetailView.vue` | `api/notifications.ts` |
|
||||||
|
| 文案与类型映射 | `presentation.ts`、`contracts.ts` | 服务端模板字段 |
|
||||||
|
| 对外导出 | `public.ts` | — |
|
||||||
|
|
||||||
|
## 关键边界
|
||||||
|
|
||||||
|
- 未读计数与已读状态以服务端为准;本地乐观更新后必须回读,不长期保留本地计数。
|
||||||
|
- 消息跳转只带业务编号(订单号、入仓码、派送号等),不用内部 ID 作参数或标题。
|
||||||
|
- 只展示当前企业范围内的消息;模板变量由服务端填充,前端不补默认值。
|
||||||
|
- 消息列表失败要可重试,不清空已有内容。
|
||||||
|
|
||||||
|
## 验证
|
||||||
|
|
||||||
|
- 定向:`pnpm test src/modules/notifications/<目标测试>`;字段变化同时核对 `notification-v1.yaml`。
|
||||||
|
- 本文件或索引变更后,从后端根运行 `./scripts/agents-index-contract.ps1`。
|
||||||
@@ -0,0 +1,30 @@
|
|||||||
|
# Client 订单管理模块指引
|
||||||
|
|
||||||
|
## 路径基准与读取顺序
|
||||||
|
|
||||||
|
- 本文件适用于 `src/modules/order-management/`,代码路径相对本目录;应用公共规则见 `../../../AGENTS.md`,订单与入仓计划细则见 `../../../docs/business-index.md`。
|
||||||
|
- 本模块承载客户可见的**统一订单、海外仓入仓计划与派送单**;头程下单与费用确认归 `../first-leg/`。
|
||||||
|
- 后端只查 `lastleg-service/` 的 `inboundplan/`、`delivery/`;头程订单事实由 `../first-leg/` 与 `order/` 提供。
|
||||||
|
|
||||||
|
## 页面与入口
|
||||||
|
|
||||||
|
| 目标 | 页面/路由 | API 与后端 |
|
||||||
|
|---|---|---|
|
||||||
|
| 我的订单(统一列表) | `views/MyOrdersView.vue`;`orders/my` | 复用 `../first-leg/api/unifiedOrders.ts`;`order/` |
|
||||||
|
| 海外仓入库订单列表与详情 | `views/InboundOrdersView.vue`;`orders/inbound`、`orders/inbound/:planNo/detail` | `api/inboundPlans.ts`、`inboundPlanDisplay.ts`;`lastleg-service/inboundplan/` |
|
||||||
|
| 派送单列表 | `views/DeliveryOrdersView.vue`、`views/deliveryOrders.css`;`orders/delivery` | `api/deliveryOrders.ts`;`lastleg-service/delivery/` |
|
||||||
|
| 派送单详情与签收结果 | `views/DeliveryOrderDetailView.vue`;`orders/delivery/:deliveryNo` | `api/deliveryOrders.ts` |
|
||||||
|
| 浏览器读屏验收脚本 | `receiptBrowserAcceptance.mjs` | 仅本地验收,不写业务数据 |
|
||||||
|
|
||||||
|
## 关键边界
|
||||||
|
|
||||||
|
- 入仓计划与派送单对客户只读;任何状态推进由海外仓作业侧完成,客户端不提供完成/发车类动作。
|
||||||
|
- 派送单按目的 FBA 仓拆分,列表与详情必须显示目的 FBA 仓;不得用单个出库号覆盖整批派送。
|
||||||
|
- 业务标识用计划号、入仓码、派送号等正式编号;缺失显示“—”,不用内部 ID 回退。
|
||||||
|
- 客户与仓库范围只取服务端当前租户上下文,不从前端参数推断。
|
||||||
|
- 分页、筛选与导出只消费服务端结果,不在浏览器重排或本地累计。
|
||||||
|
|
||||||
|
## 验证
|
||||||
|
|
||||||
|
- 定向:`pnpm test src/modules/order-management/<目标测试>`;接口或类型变化同时运行 `pnpm typecheck`。
|
||||||
|
- 本文件或索引变更后,从后端根运行 `./scripts/agents-index-contract.ps1`。
|
||||||
@@ -104,17 +104,6 @@ interface DeliveryOrderDetailResponse {
|
|||||||
}>
|
}>
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface DeliveryTransferResult {
|
|
||||||
dispatchNo: string
|
|
||||||
outboundNo: string
|
|
||||||
outboundStatus: string
|
|
||||||
deliveryNo: string
|
|
||||||
deliveryStatus: string
|
|
||||||
palletCount: number
|
|
||||||
packageCount: number
|
|
||||||
replayed: boolean
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface DeliveryQuery {
|
export interface DeliveryQuery {
|
||||||
page: number
|
page: number
|
||||||
size: number
|
size: number
|
||||||
@@ -140,26 +129,6 @@ export function normalizeDeliveryPage(data: PageResult<DeliveryRow>): PageResult
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface DeliveryTransferPayload {
|
|
||||||
dispatchNo: string
|
|
||||||
idempotencyKey: string
|
|
||||||
plannedDeliveryAt: string
|
|
||||||
deliveryMethod: string
|
|
||||||
pickupMethod: string
|
|
||||||
loadingType: string
|
|
||||||
waybillNo?: string
|
|
||||||
carrierName?: string
|
|
||||||
vehicleType?: string
|
|
||||||
vehicleSize?: string
|
|
||||||
driverName?: string
|
|
||||||
driverPhone?: string
|
|
||||||
vehiclePlate?: string
|
|
||||||
appointmentAccount?: string
|
|
||||||
sellerName?: string
|
|
||||||
remark?: string
|
|
||||||
fees: DeliveryOrderFee[]
|
|
||||||
}
|
|
||||||
|
|
||||||
export function listDeliveryOrders(params: DeliveryQuery) {
|
export function listDeliveryOrders(params: DeliveryQuery) {
|
||||||
return apiRequest<PageResult<DeliveryRow>>({
|
return apiRequest<PageResult<DeliveryRow>>({
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
@@ -179,13 +148,3 @@ export function getDeliveryOrder(deliveryNo: string) {
|
|||||||
items: skus,
|
items: skus,
|
||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
|
|
||||||
export function createDeliveryOrder(payload: DeliveryTransferPayload) {
|
|
||||||
const { dispatchNo, ...request } = payload
|
|
||||||
return apiRequest<DeliveryTransferResult>({
|
|
||||||
method: 'POST',
|
|
||||||
url: '/merchant/v1/last-leg/delivery-orders',
|
|
||||||
params: { dispatchNo },
|
|
||||||
data: request,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import assert from 'node:assert/strict'
|
import assert from 'node:assert/strict'
|
||||||
import { readFileSync } from 'node:fs'
|
import { existsSync, readFileSync } from 'node:fs'
|
||||||
import test from 'node:test'
|
import test from 'node:test'
|
||||||
import ts from 'typescript'
|
import ts from 'typescript'
|
||||||
|
|
||||||
@@ -8,7 +8,6 @@ const routesSource = readFileSync(new URL('./routes.ts', import.meta.url), 'utf8
|
|||||||
const listSource = readFileSync(new URL('./views/DeliveryOrdersView.vue', import.meta.url), 'utf8')
|
const listSource = readFileSync(new URL('./views/DeliveryOrdersView.vue', import.meta.url), 'utf8')
|
||||||
const detailSource = readFileSync(new URL('./views/DeliveryOrderDetailView.vue', import.meta.url), 'utf8')
|
const detailSource = readFileSync(new URL('./views/DeliveryOrderDetailView.vue', import.meta.url), 'utf8')
|
||||||
const deliveryStyles = readFileSync(new URL('./views/deliveryOrders.css', import.meta.url), 'utf8')
|
const deliveryStyles = readFileSync(new URL('./views/deliveryOrders.css', import.meta.url), 'utf8')
|
||||||
const createSource = readFileSync(new URL('./views/DeliveryOrderCreateView.vue', import.meta.url), 'utf8')
|
|
||||||
const permissionSource = readFileSync(new URL('../tenant-management/contracts.ts', import.meta.url), 'utf8')
|
const permissionSource = readFileSync(new URL('../tenant-management/contracts.ts', import.meta.url), 'utf8')
|
||||||
|
|
||||||
async function importTypeScriptModule(source) {
|
async function importTypeScriptModule(source) {
|
||||||
@@ -33,22 +32,18 @@ for (const signedPackages of [null, 0, 3]) test(`preserves actual signed quantit
|
|||||||
test('uses only authenticated merchant delivery endpoints without customer scope or mock fallback', () => {
|
test('uses only authenticated merchant delivery endpoints without customer scope or mock fallback', () => {
|
||||||
assert.match(apiSource, /method: 'GET'[\s\S]*url: '\/merchant\/v1\/last-leg\/delivery-orders'/)
|
assert.match(apiSource, /method: 'GET'[\s\S]*url: '\/merchant\/v1\/last-leg\/delivery-orders'/)
|
||||||
assert.match(apiSource, /delivery-orders\/\$\{encodeURIComponent\(deliveryNo\)\}/)
|
assert.match(apiSource, /delivery-orders\/\$\{encodeURIComponent\(deliveryNo\)\}/)
|
||||||
assert.match(apiSource, /method: 'POST'[\s\S]*url: '\/merchant\/v1\/last-leg\/delivery-orders'/)
|
assert.doesNotMatch(apiSource, /method: '(?:POST|PUT|PATCH|DELETE)'|createDeliveryOrder|DeliveryTransferPayload|DeliveryTransferResult/)
|
||||||
assert.match(apiSource, /const \{ dispatchNo, \.\.\.request \} = payload/)
|
|
||||||
assert.match(apiSource, /params: \{ dispatchNo \}/)
|
|
||||||
assert.match(apiSource, /apiRequest<DeliveryOrderDetailResponse>/)
|
assert.match(apiSource, /apiRequest<DeliveryOrderDetailResponse>/)
|
||||||
assert.match(apiSource, /\.then\(\(\{ order, skus, fees \}\) => \(\{[\s\S]*\.\.\.order,[\s\S]*fees,[\s\S]*items: skus/)
|
assert.match(apiSource, /\.then\(\(\{ order, skus, fees \}\) => \(\{[\s\S]*\.\.\.order,[\s\S]*fees,[\s\S]*items: skus/)
|
||||||
assert.match(apiSource, /apiRequest<DeliveryTransferResult>/)
|
|
||||||
assert.doesNotMatch(apiSource, /customerId|tenantId|Record<string, unknown>|mock|fallback/i)
|
assert.doesNotMatch(apiSource, /customerId|tenantId|Record<string, unknown>|mock|fallback/i)
|
||||||
})
|
})
|
||||||
|
|
||||||
test('keeps list, read-only detail and create permissions independent in active routes', () => {
|
test('keeps customer delivery list and read-only detail active without a creation route', () => {
|
||||||
const listRoute = routesSource.match(/path: 'orders\/delivery',[\s\S]*?\n\s*},/)?.[0] ?? ''
|
const listRoute = routesSource.match(/path: 'orders\/delivery',[\s\S]*?\n\s*},/)?.[0] ?? ''
|
||||||
assert.match(listRoute, /permission: 'merchant:warehouse:delivery:list'/)
|
assert.match(listRoute, /permission: 'merchant:warehouse:delivery:list'/)
|
||||||
assert.match(listRoute, /navigation: \{ key: 'orders-delivery', icon: Truck \}/)
|
assert.match(listRoute, /navigation: \{ key: 'orders-delivery', icon: Truck \}/)
|
||||||
assert.match(routesSource, /path: 'orders\/delivery\/create'[\s\S]*DeliveryOrderCreateView\.vue[\s\S]*permission: 'merchant:warehouse:delivery:create'/)
|
assert.doesNotMatch(routesSource, /orders\/delivery\/create|orders-delivery-create|DeliveryOrderCreateView/)
|
||||||
assert.match(routesSource, /path: 'orders\/delivery\/:deliveryNo'[\s\S]*DeliveryOrderDetailView\.vue[\s\S]*props: true[\s\S]*permission: 'merchant:warehouse:delivery:list'/)
|
assert.match(routesSource, /path: 'orders\/delivery\/:deliveryNo'[\s\S]*DeliveryOrderDetailView\.vue[\s\S]*props: true[\s\S]*permission: 'merchant:warehouse:delivery:list'/)
|
||||||
assert.match(routesSource, /orders-delivery-create[\s\S]*keepAlive: false/)
|
|
||||||
assert.match(routesSource, /orders-delivery-detail[\s\S]*keepAlive: false/)
|
assert.match(routesSource, /orders-delivery-detail[\s\S]*keepAlive: false/)
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -70,10 +65,9 @@ test('renders the operation column first and covers loading, empty, error and pa
|
|||||||
assert.doesNotMatch(listSource, /row\.id[^a-zA-Z]|deliveryNo \|\| row\.id|customerId|tenantId/)
|
assert.doesNotMatch(listSource, /row\.id[^a-zA-Z]|deliveryNo \|\| row\.id|customerId|tenantId/)
|
||||||
})
|
})
|
||||||
|
|
||||||
test('shows the create button only with the independent create permission', () => {
|
test('does not expose customer delivery creation even to an account retaining an old permission snapshot', () => {
|
||||||
assert.match(listSource, /auth\.hasPermission\('merchant:warehouse:delivery:create'\)/)
|
assert.doesNotMatch(listSource, /delivery:create|canCreate|openCreate|orders-delivery-create|创建派送单/)
|
||||||
assert.match(listSource, /<el-button v-if="canCreate" type="primary" @click="openCreate"/)
|
assert.equal(existsSync(new URL('./views/DeliveryOrderCreateView.vue', import.meta.url)), false)
|
||||||
assert.doesNotMatch(listSource, /hasPermission\('merchant:warehouse:delivery:list'\)[\s\S]{0,120}创建派送单/)
|
|
||||||
})
|
})
|
||||||
|
|
||||||
test('loads a typed detail route by delivery number and never exposes an internal id fallback', () => {
|
test('loads a typed detail route by delivery number and never exposes an internal id fallback', () => {
|
||||||
@@ -126,33 +120,12 @@ test('renders a compact customer-readable delivery detail surface', () => {
|
|||||||
assert.match(deliveryStyles, /delivery-detail-surface \.delivery-detail-grid div\{display:grid;min-height:42px;/)
|
assert.match(deliveryStyles, /delivery-detail-surface \.delivery-detail-grid div\{display:grid;min-height:42px;/)
|
||||||
})
|
})
|
||||||
|
|
||||||
test('submits the complete create contract with stable retry idempotency and recoverable failures', () => {
|
test('keeps merchant delivery reads and removes creation from the advertised permission map', async () => {
|
||||||
for (const model of ['dispatchNo', 'plannedDeliveryAt', 'deliveryMethod', 'pickupMethod', 'loadingType', 'waybillNo', 'carrierName', 'vehicleType', 'vehicleSize', 'driverName', 'driverPhone', 'vehiclePlate', 'appointmentAccount', 'sellerName', 'remark']) {
|
|
||||||
assert.match(createSource, new RegExp(`v-model="form\\.${model}"`))
|
|
||||||
}
|
|
||||||
assert.match(createSource, /if \(!pendingIdempotencyKey\) pendingIdempotencyKey = createIdempotencyKey\(\)/)
|
|
||||||
assert.match(createSource, /createDeliveryOrder\(requestPayload\(\)\)/)
|
|
||||||
assert.match(createSource, /fees: form\.fees\.map/)
|
|
||||||
assert.match(createSource, /if \(form\.fees\.length === 0\)/)
|
|
||||||
assert.match(createSource, /请至少添加一条费用明细/)
|
|
||||||
for (const value of ['FBA_PICKUP', 'CUSTOMER_PICKUP', 'TRUCK_PALLET', 'TRUCK_FLOOR', 'EXPRESS', 'OUTSOURCED', 'DEDICATED_TRUCK', 'LTL']) {
|
|
||||||
assert.match(createSource, new RegExp(`value="${value}"`))
|
|
||||||
}
|
|
||||||
for (const value of ['ONE_PICKUP_ONE_DROP', 'ONE_PICKUP_MULTI_DROP', 'MULTI_PICKUP_ONE_DROP', 'MULTI_PICKUP_MULTI_DROP', 'WAREHOUSE_PICKUP', 'PALLET', 'FLOOR', 'MIXED']) {
|
|
||||||
assert.match(createSource, new RegExp(`value="${value}"`))
|
|
||||||
}
|
|
||||||
assert.doesNotMatch(createSource, /value="(?:TRUCK|COURIER|SELF_PICKUP|DOOR_PICKUP|LOOSE_CARTON)"/)
|
|
||||||
assert.match(createSource, /submitError\.value = error instanceof Error/)
|
|
||||||
assert.match(createSource, /useUnsavedWorkRegistration/)
|
|
||||||
assert.doesNotMatch(createSource, /customerId|tenantId|mock|fallback/i)
|
|
||||||
})
|
|
||||||
|
|
||||||
test('maps both merchant delivery permissions independently', async () => {
|
|
||||||
assert.match(permissionSource, /'merchant:warehouse:delivery:list': \['merchant:warehouse:delivery:list'\]/)
|
assert.match(permissionSource, /'merchant:warehouse:delivery:list': \['merchant:warehouse:delivery:list'\]/)
|
||||||
assert.match(permissionSource, /'merchant:warehouse:delivery:create': \['merchant:warehouse:delivery:create'\]/)
|
assert.doesNotMatch(permissionSource, /merchant:warehouse:delivery:create/)
|
||||||
const contracts = await importTypeScriptModule(permissionSource)
|
const contracts = await importTypeScriptModule(permissionSource)
|
||||||
assert.equal(contracts.hasMappedMerchantPermission('merchant:warehouse:delivery:list', new Set(['merchant:warehouse:delivery:list'])), true)
|
assert.equal(contracts.hasMappedMerchantPermission('merchant:warehouse:delivery:list', new Set(['merchant:warehouse:delivery:list'])), true)
|
||||||
assert.equal(contracts.hasMappedMerchantPermission('merchant:warehouse:delivery:list', new Set(['merchant:warehouse:delivery:create'])), false)
|
assert.equal(contracts.hasMappedMerchantPermission('merchant:warehouse:delivery:list', new Set(['merchant:warehouse:delivery:create'])), false)
|
||||||
assert.equal(contracts.hasMappedMerchantPermission('merchant:warehouse:delivery:create', new Set(['merchant:warehouse:delivery:create'])), true)
|
assert.equal(Object.hasOwn(contracts.FRONTEND_TO_MERCHANT_PERMISSION_CODES, 'merchant:warehouse:delivery:create'), false)
|
||||||
assert.equal(contracts.hasMappedMerchantPermission('merchant:warehouse:delivery:create', new Set(['merchant:warehouse:delivery:list'])), false)
|
assert.equal(contracts.hasMappedMerchantPermission('merchant:warehouse:delivery:create', new Set(['merchant:warehouse:delivery:list'])), false)
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -37,13 +37,6 @@ export const orderManagementModule = {
|
|||||||
meta: { title: '派送订单列表', description: '查询海外仓派送订单', permission: 'merchant:warehouse:delivery:list' },
|
meta: { title: '派送订单列表', description: '查询海外仓派送订单', permission: 'merchant:warehouse:delivery:list' },
|
||||||
navigation: { key: 'orders-delivery', icon: Truck },
|
navigation: { key: 'orders-delivery', icon: Truck },
|
||||||
},
|
},
|
||||||
{
|
|
||||||
path: 'orders/delivery/create',
|
|
||||||
name: 'orders-delivery-create',
|
|
||||||
component: () => import('./views/DeliveryOrderCreateView.vue'),
|
|
||||||
release: 'active',
|
|
||||||
meta: { title: '创建派送单', workspaceTitle: '派送订单 · 新建', description: '从排车单创建海外仓派送单', permission: 'merchant:warehouse:delivery:create', keepAlive: false },
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
path: 'orders/delivery/:deliveryNo',
|
path: 'orders/delivery/:deliveryNo',
|
||||||
name: 'orders-delivery-detail',
|
name: 'orders-delivery-detail',
|
||||||
|
|||||||
@@ -1,201 +0,0 @@
|
|||||||
<script setup lang="ts">
|
|
||||||
import { computed, reactive, ref } from 'vue'
|
|
||||||
import { useRouter } from 'vue-router'
|
|
||||||
import { ArrowLeft, Plus, Trash2 } from '@lucide/vue'
|
|
||||||
import { ElMessage, ElMessageBox, type FormInstance, type FormRules } from 'element-plus'
|
|
||||||
import { useAuthStore } from '@/modules/auth/public'
|
|
||||||
import { useUnsavedWorkRegistration } from '@/navigation/workspace-tabs/unsavedWork'
|
|
||||||
import { createIdempotencyKey } from '@/utils/idempotencyKey'
|
|
||||||
import { createDeliveryOrder, type DeliveryOrderFee, type DeliveryTransferPayload } from '../api/deliveryOrders'
|
|
||||||
|
|
||||||
type DeliveryCreateForm = Omit<DeliveryTransferPayload, 'idempotencyKey'>
|
|
||||||
|
|
||||||
const router = useRouter()
|
|
||||||
const auth = useAuthStore()
|
|
||||||
const formRef = ref<FormInstance>()
|
|
||||||
const submitting = ref(false)
|
|
||||||
const submitError = ref('')
|
|
||||||
const submitted = ref(false)
|
|
||||||
let pendingIdempotencyKey = ''
|
|
||||||
|
|
||||||
const form = reactive<DeliveryCreateForm>({
|
|
||||||
dispatchNo: '',
|
|
||||||
plannedDeliveryAt: '',
|
|
||||||
deliveryMethod: '',
|
|
||||||
pickupMethod: '',
|
|
||||||
loadingType: '',
|
|
||||||
waybillNo: '',
|
|
||||||
carrierName: '',
|
|
||||||
vehicleType: '',
|
|
||||||
vehicleSize: '',
|
|
||||||
driverName: '',
|
|
||||||
driverPhone: '',
|
|
||||||
vehiclePlate: '',
|
|
||||||
appointmentAccount: '',
|
|
||||||
sellerName: '',
|
|
||||||
remark: '',
|
|
||||||
fees: [],
|
|
||||||
})
|
|
||||||
|
|
||||||
const rules: FormRules<DeliveryCreateForm> = {
|
|
||||||
dispatchNo: [{ required: true, message: '请输入排车单号', trigger: 'blur' }],
|
|
||||||
plannedDeliveryAt: [{ required: true, message: '请选择计划派送时间', trigger: 'change' }],
|
|
||||||
deliveryMethod: [{ required: true, message: '请选择派送方式', trigger: 'change' }],
|
|
||||||
pickupMethod: [{ required: true, message: '请选择提货方式', trigger: 'change' }],
|
|
||||||
loadingType: [{ required: true, message: '请选择装载类型', trigger: 'change' }],
|
|
||||||
}
|
|
||||||
|
|
||||||
const dirty = computed(() => !submitted.value && Boolean(
|
|
||||||
form.dispatchNo || form.plannedDeliveryAt || form.deliveryMethod || form.pickupMethod || form.loadingType
|
|
||||||
|| form.waybillNo || form.carrierName || form.vehicleType || form.vehicleSize || form.driverName
|
|
||||||
|| form.driverPhone || form.vehiclePlate || form.appointmentAccount || form.sellerName || form.remark || form.fees.length,
|
|
||||||
))
|
|
||||||
|
|
||||||
useUnsavedWorkRegistration({
|
|
||||||
key: 'delivery-order-create-form',
|
|
||||||
routeKey: 'orders-delivery-create',
|
|
||||||
label: '创建派送单',
|
|
||||||
dirty,
|
|
||||||
})
|
|
||||||
|
|
||||||
function optional(value: string | undefined) {
|
|
||||||
const normalized = value?.trim()
|
|
||||||
return normalized || undefined
|
|
||||||
}
|
|
||||||
|
|
||||||
function addFee() {
|
|
||||||
form.fees.push({ feeType: '', currency: 'USD', amount: 0, remark: '' })
|
|
||||||
}
|
|
||||||
|
|
||||||
function removeFee(index: number) {
|
|
||||||
form.fees.splice(index, 1)
|
|
||||||
}
|
|
||||||
|
|
||||||
function validateFees() {
|
|
||||||
if (form.fees.length === 0) {
|
|
||||||
ElMessage.warning('请至少添加一条费用明细')
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
const invalidIndex = form.fees.findIndex((fee) => !fee.feeType.trim() || !fee.currency.trim() || fee.amount <= 0)
|
|
||||||
if (invalidIndex < 0) return true
|
|
||||||
ElMessage.warning(`请完整填写第 ${invalidIndex + 1} 条费用的类型、币种和大于 0 的金额`)
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
function requestPayload(): DeliveryTransferPayload {
|
|
||||||
return {
|
|
||||||
dispatchNo: form.dispatchNo.trim(),
|
|
||||||
idempotencyKey: pendingIdempotencyKey,
|
|
||||||
plannedDeliveryAt: form.plannedDeliveryAt,
|
|
||||||
deliveryMethod: form.deliveryMethod,
|
|
||||||
pickupMethod: form.pickupMethod,
|
|
||||||
loadingType: form.loadingType,
|
|
||||||
waybillNo: optional(form.waybillNo),
|
|
||||||
carrierName: optional(form.carrierName),
|
|
||||||
vehicleType: optional(form.vehicleType),
|
|
||||||
vehicleSize: optional(form.vehicleSize),
|
|
||||||
driverName: optional(form.driverName),
|
|
||||||
driverPhone: optional(form.driverPhone),
|
|
||||||
vehiclePlate: optional(form.vehiclePlate),
|
|
||||||
appointmentAccount: optional(form.appointmentAccount),
|
|
||||||
sellerName: optional(form.sellerName),
|
|
||||||
remark: optional(form.remark),
|
|
||||||
fees: form.fees.map((fee): DeliveryOrderFee => ({
|
|
||||||
feeType: fee.feeType.trim(),
|
|
||||||
currency: fee.currency.trim().toUpperCase(),
|
|
||||||
amount: fee.amount,
|
|
||||||
remark: optional(fee.remark ?? ''),
|
|
||||||
})),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
async function submit() {
|
|
||||||
submitError.value = ''
|
|
||||||
const valid = await formRef.value?.validate().catch(() => false)
|
|
||||||
if (!valid || !validateFees()) return
|
|
||||||
if (!pendingIdempotencyKey) pendingIdempotencyKey = createIdempotencyKey()
|
|
||||||
submitting.value = true
|
|
||||||
try {
|
|
||||||
const created = await createDeliveryOrder(requestPayload())
|
|
||||||
submitted.value = true
|
|
||||||
pendingIdempotencyKey = ''
|
|
||||||
ElMessage.success('派送单创建成功')
|
|
||||||
if (auth.hasPermission('merchant:warehouse:delivery:list')) {
|
|
||||||
await router.replace({ name: 'orders-delivery-detail', params: { deliveryNo: created.deliveryNo } })
|
|
||||||
} else {
|
|
||||||
await router.replace('/')
|
|
||||||
}
|
|
||||||
} catch (error) {
|
|
||||||
submitError.value = error instanceof Error ? error.message : '派送单创建失败,请检查后重试'
|
|
||||||
} finally {
|
|
||||||
submitting.value = false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
async function cancel() {
|
|
||||||
if (dirty.value) {
|
|
||||||
try {
|
|
||||||
await ElMessageBox.confirm('当前派送单尚未提交,离开后填写内容将丢失。', '放弃创建?', { type: 'warning', confirmButtonText: '放弃', cancelButtonText: '继续填写' })
|
|
||||||
} catch (error) {
|
|
||||||
if (error === 'cancel' || error === 'close') return
|
|
||||||
throw error
|
|
||||||
}
|
|
||||||
}
|
|
||||||
submitted.value = true
|
|
||||||
await router.push({ name: 'orders-delivery' })
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<template>
|
|
||||||
<section class="delivery-page" aria-labelledby="delivery-create-title">
|
|
||||||
<button type="button" class="delivery-back" @click="cancel"><ArrowLeft :size="16" />返回派送单列表</button>
|
|
||||||
<div class="delivery-heading"><div><h2 id="delivery-create-title">创建派送单</h2><p>从已确认的排车单创建本企业海外仓派送任务。</p></div></div>
|
|
||||||
|
|
||||||
<div v-if="submitError" class="delivery-card delivery-state delivery-state--error" role="alert"><p>{{ submitError }}</p></div>
|
|
||||||
|
|
||||||
<el-form ref="formRef" :model="form" :rules="rules" label-position="top" class="delivery-card delivery-form" @submit.prevent="submit">
|
|
||||||
<section>
|
|
||||||
<h3>基础信息</h3>
|
|
||||||
<div class="delivery-form-grid">
|
|
||||||
<el-form-item label="排车单号" prop="dispatchNo" required><el-input v-model="form.dispatchNo" maxlength="64" placeholder="请输入排车单号" /></el-form-item>
|
|
||||||
<el-form-item label="计划派送时间" prop="plannedDeliveryAt" required><el-date-picker v-model="form.plannedDeliveryAt" type="datetime" value-format="YYYY-MM-DDTHH:mm:ss" placeholder="请选择计划派送时间" /></el-form-item>
|
|
||||||
<el-form-item label="派送方式" prop="deliveryMethod" required><el-select v-model="form.deliveryMethod" placeholder="请选择派送方式"><el-option label="FBA自提" value="FBA_PICKUP" /><el-option label="客户自提" value="CUSTOMER_PICKUP" /><el-option label="卡派打托" value="TRUCK_PALLET" /><el-option label="卡派地板" value="TRUCK_FLOOR" /><el-option label="快递" value="EXPRESS" /><el-option label="外配" value="OUTSOURCED" /><el-option label="专车直送" value="DEDICATED_TRUCK" /><el-option label="零担派送" value="LTL" /></el-select></el-form-item>
|
|
||||||
<el-form-item label="提货方式" prop="pickupMethod" required><el-select v-model="form.pickupMethod" placeholder="请选择提货方式"><el-option label="一提一卸" value="ONE_PICKUP_ONE_DROP" /><el-option label="一提多卸" value="ONE_PICKUP_MULTI_DROP" /><el-option label="多提一卸" value="MULTI_PICKUP_ONE_DROP" /><el-option label="多提多卸" value="MULTI_PICKUP_MULTI_DROP" /><el-option label="仓库自提" value="WAREHOUSE_PICKUP" /></el-select></el-form-item>
|
|
||||||
<el-form-item label="装载类型" prop="loadingType" required><el-select v-model="form.loadingType" placeholder="请选择装载类型"><el-option label="托盘" value="PALLET" /><el-option label="地板" value="FLOOR" /><el-option label="混装" value="MIXED" /></el-select></el-form-item>
|
|
||||||
<el-form-item label="运单号"><el-input v-model="form.waybillNo" maxlength="64" placeholder="选填" /></el-form-item>
|
|
||||||
</div>
|
|
||||||
</section>
|
|
||||||
|
|
||||||
<section>
|
|
||||||
<h3>承运与车辆</h3>
|
|
||||||
<div class="delivery-form-grid">
|
|
||||||
<el-form-item label="承运商"><el-input v-model="form.carrierName" maxlength="128" placeholder="选填" /></el-form-item>
|
|
||||||
<el-form-item label="车型"><el-input v-model="form.vehicleType" maxlength="64" placeholder="选填" /></el-form-item>
|
|
||||||
<el-form-item label="车辆尺寸"><el-input v-model="form.vehicleSize" maxlength="64" placeholder="选填" /></el-form-item>
|
|
||||||
<el-form-item label="车牌号"><el-input v-model="form.vehiclePlate" maxlength="32" placeholder="选填" /></el-form-item>
|
|
||||||
<el-form-item label="司机姓名"><el-input v-model="form.driverName" maxlength="64" placeholder="选填" /></el-form-item>
|
|
||||||
<el-form-item label="司机电话"><el-input v-model="form.driverPhone" maxlength="32" placeholder="选填" /></el-form-item>
|
|
||||||
<el-form-item label="预约账号"><el-input v-model="form.appointmentAccount" maxlength="128" placeholder="选填" /></el-form-item>
|
|
||||||
<el-form-item label="卖家名称"><el-input v-model="form.sellerName" maxlength="128" placeholder="选填" /></el-form-item>
|
|
||||||
<el-form-item label="备注" class="delivery-span-3"><el-input v-model="form.remark" type="textarea" :rows="3" maxlength="500" show-word-limit placeholder="选填" /></el-form-item>
|
|
||||||
</div>
|
|
||||||
</section>
|
|
||||||
|
|
||||||
<section>
|
|
||||||
<div class="delivery-fee-heading"><h3>费用明细</h3><el-button @click="addFee"><Plus :size="16" />添加费用</el-button></div>
|
|
||||||
<el-table v-if="form.fees.length" :data="form.fees" table-layout="fixed">
|
|
||||||
<el-table-column label="操作" width="88"><template #default="{ $index }"><el-button link type="danger" aria-label="删除费用" @click="removeFee($index)"><Trash2 :size="16" />删除</el-button></template></el-table-column>
|
|
||||||
<el-table-column label="费用类型" min-width="180"><template #default="{ row }"><el-input v-model="row.feeType" maxlength="64" placeholder="请输入费用类型" /></template></el-table-column>
|
|
||||||
<el-table-column label="币种" width="140"><template #default="{ row }"><el-input v-model="row.currency" maxlength="3" placeholder="USD" /></template></el-table-column>
|
|
||||||
<el-table-column label="金额" width="180"><template #default="{ row }"><el-input-number v-model="row.amount" :min="0" :precision="2" :step="1" controls-position="right" placeholder="请输入金额" /></template></el-table-column>
|
|
||||||
<el-table-column label="备注" min-width="220"><template #default="{ row }"><el-input v-model="row.remark" maxlength="200" placeholder="选填" /></template></el-table-column>
|
|
||||||
</el-table>
|
|
||||||
<div v-else class="delivery-fee-empty">请至少添加一条费用明细后再提交。</div>
|
|
||||||
</section>
|
|
||||||
|
|
||||||
<div class="delivery-form-actions"><el-button :disabled="submitting" @click="cancel">取消</el-button><el-button type="primary" native-type="submit" :loading="submitting">提交创建</el-button></div>
|
|
||||||
</el-form>
|
|
||||||
</section>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<style scoped src="./deliveryOrders.css"></style>
|
|
||||||
@@ -1,16 +1,13 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { computed, onMounted, reactive, ref, watch } from 'vue'
|
import { computed, onMounted, reactive, ref, watch } from 'vue'
|
||||||
import { useRouter } from 'vue-router'
|
import { useRouter } from 'vue-router'
|
||||||
import { Plus } from '@lucide/vue'
|
|
||||||
import dayjs from 'dayjs'
|
import dayjs from 'dayjs'
|
||||||
import { useAuthStore } from '@/modules/auth/public'
|
|
||||||
import { listDeliveryOrders, type DeliveryQuery, type DeliveryRow } from '../api/deliveryOrders'
|
import { listDeliveryOrders, type DeliveryQuery, type DeliveryRow } from '../api/deliveryOrders'
|
||||||
import QueryToolbar, { type QueryField, type QueryModel } from '@/components/common/QueryToolbar.vue'
|
import QueryToolbar, { type QueryField, type QueryModel } from '@/components/common/QueryToolbar.vue'
|
||||||
import DataTable, { type DataTableColumn } from '@/components/common/DataTable.vue'
|
import DataTable, { type DataTableColumn } from '@/components/common/DataTable.vue'
|
||||||
import type { TableAction } from '@/components/common/tableActions'
|
import type { TableAction } from '@/components/common/tableActions'
|
||||||
|
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
const auth = useAuthStore()
|
|
||||||
const loading = ref(false)
|
const loading = ref(false)
|
||||||
const errorMessage = ref('')
|
const errorMessage = ref('')
|
||||||
const records = ref<DeliveryRow[]>([])
|
const records = ref<DeliveryRow[]>([])
|
||||||
@@ -18,7 +15,6 @@ const total = ref(0)
|
|||||||
const page = ref(1)
|
const page = ref(1)
|
||||||
const pageSize = ref(20)
|
const pageSize = ref(20)
|
||||||
const filters = reactive({ documentNo: '', dispatchNo: '', waybillNo: '', status: '', deliveryMethod: '', plannedRange: [] as string[] })
|
const filters = reactive({ documentNo: '', dispatchNo: '', waybillNo: '', status: '', deliveryMethod: '', plannedRange: [] as string[] })
|
||||||
const canCreate = computed(() => auth.hasPermission('merchant:warehouse:delivery:create'))
|
|
||||||
let requestSequence = 0
|
let requestSequence = 0
|
||||||
|
|
||||||
const deliveryMethodOptions = [
|
const deliveryMethodOptions = [
|
||||||
@@ -142,9 +138,6 @@ function openDetail(row: DeliveryRow) {
|
|||||||
void router.push({ name: 'orders-delivery-detail', params: { deliveryNo: row.deliveryNo } })
|
void router.push({ name: 'orders-delivery-detail', params: { deliveryNo: row.deliveryNo } })
|
||||||
}
|
}
|
||||||
|
|
||||||
function openCreate() {
|
|
||||||
void router.push({ name: 'orders-delivery-create' })
|
|
||||||
}
|
|
||||||
function rowActions(candidate: object): TableAction[] {
|
function rowActions(candidate: object): TableAction[] {
|
||||||
const row = candidate as DeliveryRow
|
const row = candidate as DeliveryRow
|
||||||
return [{ key: 'detail', label: '详情', disabled: !row.deliveryNo, run: () => openDetail(row) }]
|
return [{ key: 'detail', label: '详情', disabled: !row.deliveryNo, run: () => openDetail(row) }]
|
||||||
@@ -163,7 +156,6 @@ watch([page, pageSize], ([nextPage, nextSize], [previousPage, previousSize]) =>
|
|||||||
|
|
||||||
<div class="delivery-card delivery-table-card">
|
<div class="delivery-card delivery-table-card">
|
||||||
<DataTable v-model:page="page" v-model:page-size="pageSize" :data="records" :columns="tableColumns" :loading="loading" :total="total" :page-sizes="[10, 20, 50, 100]" :row-actions="rowActions" row-key="deliveryNo" empty-text="暂无派送单">
|
<DataTable v-model:page="page" v-model:page-size="pageSize" :data="records" :columns="tableColumns" :loading="loading" :total="total" :page-sizes="[10, 20, 50, 100]" :row-actions="rowActions" row-key="deliveryNo" empty-text="暂无派送单">
|
||||||
<template #toolbar-actions><el-button v-if="canCreate" type="primary" @click="openCreate"><Plus :size="16" />创建派送单</el-button></template>
|
|
||||||
<template v-if="errorMessage" #error><div class="delivery-state delivery-state--error" role="alert"><p>{{ errorMessage }}</p><el-button @click="loadOrders">重试</el-button></div></template>
|
<template v-if="errorMessage" #error><div class="delivery-state delivery-state--error" role="alert"><p>{{ errorMessage }}</p><el-button @click="loadOrders">重试</el-button></div></template>
|
||||||
<template #status="{ row }"><el-tag :type="statusType(row.status)" effect="light">{{ statusLabel(row.status) }}</el-tag></template>
|
<template #status="{ row }"><el-tag :type="statusType(row.status)" effect="light">{{ statusLabel(row.status) }}</el-tag></template>
|
||||||
<template #planned="{ row }">{{ formatDateTime(row.plannedDeliveryAt) }}</template>
|
<template #planned="{ row }">{{ formatDateTime(row.plannedDeliveryAt) }}</template>
|
||||||
|
|||||||
@@ -0,0 +1,34 @@
|
|||||||
|
# Client 海外仓模块指引
|
||||||
|
|
||||||
|
## 路径基准与读取顺序
|
||||||
|
|
||||||
|
- 本文件适用于 `src/modules/overseas-warehouse/`,代码路径相对本目录;应用公共规则见 `../../../AGENTS.md`,页面与字段细则见 `../../../docs/business-index.md`。
|
||||||
|
- 五类自助业务共用三个页面文件:`WarehouseServiceView.vue`(贴标、仓储转运、货物废弃)、`ReturnOrdersView.vue`(退货预报与签收)、`ReturnInventoryView.vue`(退货库存与箱号);按路由区分模式。
|
||||||
|
- 后端只查 `lastleg-service/` 的 `relabel/`、`transfer/`、`discard/`、`returnreceipt/`;资源与库位归 `warehouse-overseas-service/`;纯页面与文案不读后端。
|
||||||
|
|
||||||
|
## 页面与入口
|
||||||
|
|
||||||
|
| 目标 | 页面/路由 | API 与后端 |
|
||||||
|
|---|---|---|
|
||||||
|
| 贴标申请列表、新建、详情 | `views/WarehouseServiceView.vue`;`overseas-warehouse/labeling`、`.../create`、`.../:detailNo/detail` | `api/warehouseServices.ts`;`lastleg-service/relabel/` |
|
||||||
|
| 仓储转运列表、详情与入库测量 | `views/WarehouseServiceView.vue`;`overseas-warehouse/storage-transfer`、`.../:detailNo/detail` | `api/warehouseServices.ts`、`api/transferPickups.ts`;`components/TransferPickupProgressPanel.vue`;`lastleg-service/transfer/` |
|
||||||
|
| 货物废弃列表、新建与详情 | `views/WarehouseServiceView.vue`;`overseas-warehouse/cargo-disposal`、`.../:detailNo/detail` | `api/warehouseServices.ts`、`utils/discardDocuments.ts`;`lastleg-service/discard/` |
|
||||||
|
| 退货预报、新建与签收详情 | `views/ReturnOrdersView.vue`;`overseas-warehouse/return-relabel`、`.../create`、`.../:returnNo/detail` | `api/returnOrders.ts`、`utils/returnReceiptDisplay.ts`;`lastleg-service/returnreceipt/` |
|
||||||
|
| 退货库存查询 | `views/ReturnInventoryView.vue`;`overseas-warehouse/return-inventory` | `api/returnInventory.ts` |
|
||||||
|
| 退货箱号与箱内明细 | `views/ReturnInventoryView.vue`;`overseas-warehouse/return-cartons`、`.../:cartonMark/detail` | `api/returnInventory.ts`、`utils/returnReceiptDisplay.ts` |
|
||||||
|
| 换标完工确认与驳回提示 | `components/CompletionConfirmationDialog.vue`、`components/ReviewRejectionNotice.vue`、`components/RelabelDocumentsPanel.vue` | `api/warehouseServices.ts`、`utils/relabelSkuDisplay.ts` |
|
||||||
|
|
||||||
|
`views/LabelingView.vue`、`views/ReturnInboundView.vue`、`views/ReturnOutboundView.vue` 当前未在 `routes.ts` 注册;改动前先确认是否已废弃或仅被内嵌,不要据此认定页面开放。
|
||||||
|
|
||||||
|
## 关键边界
|
||||||
|
|
||||||
|
- 换标申请必须提交正数 CNY `chargeAmount`;金额与资金状态以服务端返回为准,不在客户端模拟冻结成功。
|
||||||
|
- 退货预报与签收只消费服务端状态与箱号;退货库存按箱号和 SKU 查询,箱内明细以服务端实收为准,不按预报箱数推算。
|
||||||
|
- 仓储转运的测量与打托由仓库侧完成,客户端只读展示与确认;转运进度以 `TransferPickupProgressPanel.vue` 消费的服务端事实为准。
|
||||||
|
- 货物废弃在待审锁定与实际确认扣减之间不可回退,前端只按服务端允许动作开放按钮。
|
||||||
|
- 页面承载方式按已确认原型:贴标、转运、废弃为独立路由页面,退货预报为独立页面,不擅自改为弹框或抽屉。
|
||||||
|
|
||||||
|
## 验证
|
||||||
|
|
||||||
|
- 定向:`pnpm test src/modules/overseas-warehouse/<目标测试>`;接口或类型变化同时运行 `pnpm typecheck`。
|
||||||
|
- 本文件或索引变更后,从后端根运行 `./scripts/agents-index-contract.ps1`。
|
||||||
@@ -0,0 +1,28 @@
|
|||||||
|
import { apiRequest } from '@/api/http'
|
||||||
|
|
||||||
|
export interface RelabelQuantity {
|
||||||
|
sourcePalletCount?: number | string | null
|
||||||
|
targetPalletCount?: number | string | null
|
||||||
|
sourceUnitCounts?: Record<string, number | string> | null
|
||||||
|
labelPieceCount: number | string | null
|
||||||
|
cartonCount: number | string | null
|
||||||
|
skuCount: number | string
|
||||||
|
duplicateCarton: boolean
|
||||||
|
}
|
||||||
|
export interface RelabelQuantityTotals {
|
||||||
|
knownSourcePalletCount?: number | string
|
||||||
|
unknownSourcePalletOrders?: number | string
|
||||||
|
knownTargetPalletCount?: number | string
|
||||||
|
unknownTargetPalletOrders?: number | string
|
||||||
|
orderCount: number | string
|
||||||
|
skuCount: number | string
|
||||||
|
knownLabelPieceCount: number | string
|
||||||
|
unknownPieceOrders: number | string
|
||||||
|
knownCartonCount: number | string
|
||||||
|
unknownCartonOrders: number | string
|
||||||
|
orders: Record<string, RelabelQuantity>
|
||||||
|
}
|
||||||
|
/** 客户范围来自会话,数量汇总覆盖全部筛选结果。 */
|
||||||
|
export function getRelabelQuantities(params: Record<string, unknown>) {
|
||||||
|
return apiRequest<RelabelQuantityTotals>({ method: 'GET', url: '/merchant/v1/last-leg/relabel-applications/quantity-summary', params })
|
||||||
|
}
|
||||||
@@ -2,6 +2,10 @@ import { apiRequest, apiBlobRequest } from '@/api/http'
|
|||||||
import type { PageResult } from './warehouseServices'
|
import type { PageResult } from './warehouseServices'
|
||||||
|
|
||||||
export interface ReturnOrderSummary {
|
export interface ReturnOrderSummary {
|
||||||
|
remainingQuantity?: number
|
||||||
|
receivedBoxCount?: number
|
||||||
|
receivedParcelCount?: number
|
||||||
|
receivedPalletCount?: number
|
||||||
relabelApplications?: Array<{ relabelNo: string; status: string; quantity: number; quantityUnit?: string; createdAt: string }>
|
relabelApplications?: Array<{ relabelNo: string; status: string; quantity: number; quantityUnit?: string; createdAt: string }>
|
||||||
returnNo: string; overseasWarehouseId: string; warehouseContactName?: string; warehouseContactPhone?: string; customerReferenceNo?: string; status: string
|
returnNo: string; overseasWarehouseId: string; warehouseContactName?: string; warehouseContactPhone?: string; customerReferenceNo?: string; status: string
|
||||||
skuTypes: number; expectedQuantity: number; receivedQuantity: number; needRelabel: boolean; relabelNo?: string; relabelStatus?: string; createdAt: string
|
skuTypes: number; expectedQuantity: number; receivedQuantity: number; needRelabel: boolean; relabelNo?: string; relabelStatus?: string; createdAt: string
|
||||||
@@ -30,6 +34,13 @@ export interface ReturnOrderCreate {
|
|||||||
export function listReturnOrders(params: Record<string, unknown>) {
|
export function listReturnOrders(params: Record<string, unknown>) {
|
||||||
return apiRequest<PageResult<ReturnOrderSummary>>({ method: 'GET', url: '/merchant/v1/last-leg/return-orders', params })
|
return apiRequest<PageResult<ReturnOrderSummary>>({ method: 'GET', url: '/merchant/v1/last-leg/return-orders', params })
|
||||||
}
|
}
|
||||||
|
export interface ReturnOrderStatistics {
|
||||||
|
totals: { orderCount: number; skuTypes: number; expectedQuantity: number; receivedQuantity: number; remainingQuantity: number; receivedBoxCount: number; receivedParcelCount: number; receivedPalletCount: number }
|
||||||
|
pageDimensions: Array<{ returnNo: string; remainingQuantity: number; receivedBoxCount: number; receivedParcelCount: number; receivedPalletCount: number }>
|
||||||
|
}
|
||||||
|
export function getReturnOrderStatistics(params: Record<string, unknown>) {
|
||||||
|
return apiRequest<ReturnOrderStatistics>({ method: 'GET', url: '/merchant/v1/last-leg/return-orders/statistics', params })
|
||||||
|
}
|
||||||
export function getReturnOrder(returnNo: string) {
|
export function getReturnOrder(returnNo: string) {
|
||||||
return apiRequest<ReturnOrderDetail>({ method: 'GET', url: `/merchant/v1/last-leg/return-orders/${encodeURIComponent(returnNo)}` })
|
return apiRequest<ReturnOrderDetail>({ method: 'GET', url: `/merchant/v1/last-leg/return-orders/${encodeURIComponent(returnNo)}` })
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,8 +25,8 @@ export interface RelabelDetail {
|
|||||||
tailOrders?: Array<{ id: string; orderNo: string; overseasWarehouseId: string; packageCount: number; status: string }>
|
tailOrders?: Array<{ id: string; orderNo: string; overseasWarehouseId: string; packageCount: number; status: string }>
|
||||||
completionEvidence?: { taskId: string; photoFileIds: string[]; completionRemark?: string; reviewerName?: string; reviewRemark?: string; completedAt?: string; customerConfirmedAt?: string }
|
completionEvidence?: { taskId: string; photoFileIds: string[]; completionRemark?: string; reviewerName?: string; reviewRemark?: string; completedAt?: string; customerConfirmedAt?: string }
|
||||||
}
|
}
|
||||||
export interface DiscardSummary { id: string; discardNo: string; outboundNo?: string; inboundCodes: string; overseasWarehouseId: string; overseasWarehouseName: string; totalPackages: number; totalFee: number; currency: string; status: string; createdAt: string; completedAt?: string; customerConfirmedAt?: string }
|
export interface DiscardSummary { id: string; discardNo: string; outboundNo?: string; inboundCodes: string; overseasWarehouseId: string; overseasWarehouseName: string; totalPackages: number; totalFee: number; currency: string; status: string; createdAt: string; completedAt?: string; customerConfirmedAt?: string; skuCodes: string[]; skuCount: number; requestedPackages: number; actualPackages: number | null }
|
||||||
export interface DiscardBox { cartonId: string; cartonMark: string; palletNo?: string; skus: Array<{ skuCode: string; productName: string; availablePackages: number }> }
|
export interface DiscardBox { cartonId: string; cartonMark: string; palletNo?: string; skus: Array<{ skuCode: string; productName: string; availablePackages: number; availablePieces?: number | null }> }
|
||||||
export interface DiscardCandidate { cartons?: DiscardBox[]; cartonSelectionSupported?: boolean; cartonSelectionBlockReason?: string; orderId: string; sourceType?: 'DROPSHIP' | 'RETURN_CARTON' | 'INVENTORY'; inventoryPositionId?: string; palletNo?: string; returnCartonId?: string; cartonMark?: string; inboundCode: string; inboundOrderNo: string; overseasWarehouseId: string; overseasWarehouseName: string; availablePackages: number; skus: Array<{ skuCode: string; productName: string; availablePackages: number }> }
|
export interface DiscardCandidate { cartons?: DiscardBox[]; cartonSelectionSupported?: boolean; cartonSelectionBlockReason?: string; orderId: string; sourceType?: 'DROPSHIP' | 'RETURN_CARTON' | 'INVENTORY'; inventoryPositionId?: string; palletNo?: string; returnCartonId?: string; cartonMark?: string; inboundCode: string; inboundOrderNo: string; overseasWarehouseId: string; overseasWarehouseName: string; availablePackages: number; skus: Array<{ skuCode: string; productName: string; availablePackages: number }> }
|
||||||
export interface RelabelInventoryCandidate {
|
export interface RelabelInventoryCandidate {
|
||||||
cartonSkuItems: Array<{ skuCode: string; quantity: number }>; cartonAvailablePackages: number | string
|
cartonSkuItems: Array<{ skuCode: string; quantity: number }>; cartonAvailablePackages: number | string
|
||||||
|
|||||||
@@ -0,0 +1,39 @@
|
|||||||
|
<script setup lang="ts">
|
||||||
|
import { ref, watch } from 'vue'
|
||||||
|
import { getRelabelQuantities, type RelabelQuantityTotals } from '../api/relabelQuantities'
|
||||||
|
const props = defineProps<{ query?: Record<string, unknown>; relabelNo?: string }>()
|
||||||
|
const data = ref<RelabelQuantityTotals | null>(null)
|
||||||
|
const error = ref('')
|
||||||
|
let generation = 0
|
||||||
|
function dimension(known: number, unknown: number, unit: string) {
|
||||||
|
if (unknown > 0 && known === 0) return `—(${unknown} 票)`
|
||||||
|
return `已知 ${known} ${unit}${unknown > 0 ? `(${unknown} 票 —)` : ''}`
|
||||||
|
}
|
||||||
|
watch(() => [props.query, props.relabelNo], async () => {
|
||||||
|
const current = ++generation
|
||||||
|
data.value = null; error.value = ''
|
||||||
|
try {
|
||||||
|
const result = await getRelabelQuantities({ ...props.query, ...(props.relabelNo ? { relabelNo: props.relabelNo } : {}) })
|
||||||
|
if (current === generation) data.value = result
|
||||||
|
} catch { if (current === generation) error.value = '数量汇总加载失败,请刷新重试' }
|
||||||
|
}, { immediate: true, deep: true })
|
||||||
|
</script>
|
||||||
|
<template>
|
||||||
|
<section class="relabel-quantity-panel" aria-label="贴标数量维度">
|
||||||
|
<p v-if="error" role="alert">{{ error }}</p>
|
||||||
|
<template v-else-if="data">
|
||||||
|
<strong>{{ relabelNo ? '本单数量' : '全部筛选结果' }}</strong>
|
||||||
|
<span>{{ data.orderCount }} 票</span><span>{{ data.skuCount }} 种 SKU</span>
|
||||||
|
<span>贴标件数:{{ dimension(Number(data.knownLabelPieceCount), Number(data.unknownPieceOrders), '件') }}</span>
|
||||||
|
<span>箱数:{{ dimension(Number(data.knownCartonCount), Number(data.unknownCartonOrders), '箱') }}</span>
|
||||||
|
<span>原托盘:{{ dimension(Number(data.knownSourcePalletCount ?? 0), Number(data.unknownSourcePalletOrders ?? data.orderCount), '托') }}</span>
|
||||||
|
<span>本轮目标托盘:{{ dimension(Number(data.knownTargetPalletCount ?? 0), Number(data.unknownTargetPalletOrders ?? data.orderCount), '托') }}</span>
|
||||||
|
<p v-if="relabelNo && data.orders[relabelNo]?.duplicateCarton" role="status">存在重复箱唛关联,箱数已去重,贴标件数待核查。</p>
|
||||||
|
</template>
|
||||||
|
<span v-else>数量加载中…</span>
|
||||||
|
</section>
|
||||||
|
</template>
|
||||||
|
<style scoped>
|
||||||
|
.relabel-quantity-panel { display: flex; gap: 12px; flex-wrap: wrap; padding: 12px 16px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface, white); margin-bottom: 12px; }
|
||||||
|
.relabel-quantity-panel p { margin: 0; }
|
||||||
|
</style>
|
||||||
@@ -0,0 +1,52 @@
|
|||||||
|
<script setup lang="ts">
|
||||||
|
const props = defineProps<{ modelValue: number }>()
|
||||||
|
const emit = defineEmits<{ 'update:modelValue': [value: number] }>()
|
||||||
|
let drag: { pointerId: number; startX: number; startValue: number; width: number } | null = null
|
||||||
|
|
||||||
|
function resize(value: number) {
|
||||||
|
emit('update:modelValue', Math.min(65, Math.max(35, value)))
|
||||||
|
}
|
||||||
|
function startDrag(event: PointerEvent) {
|
||||||
|
if (event.button !== 0 || !event.isPrimary) return
|
||||||
|
const handle = event.currentTarget as HTMLElement
|
||||||
|
const width = (handle.parentElement?.getBoundingClientRect().width ?? 0) - 16
|
||||||
|
if (width <= 0) return
|
||||||
|
event.preventDefault()
|
||||||
|
handle.focus()
|
||||||
|
drag = { pointerId: event.pointerId, startX: event.clientX, startValue: props.modelValue, width }
|
||||||
|
handle.setPointerCapture(event.pointerId)
|
||||||
|
}
|
||||||
|
function moveDrag(event: PointerEvent) {
|
||||||
|
if (!drag || drag.pointerId !== event.pointerId) return
|
||||||
|
resize(drag.startValue + (event.clientX - drag.startX) / drag.width * 100)
|
||||||
|
}
|
||||||
|
function endDrag(event: PointerEvent) {
|
||||||
|
if (drag?.pointerId !== event.pointerId) return
|
||||||
|
drag = null
|
||||||
|
const handle = event.currentTarget as HTMLElement
|
||||||
|
if (handle.hasPointerCapture(event.pointerId)) handle.releasePointerCapture(event.pointerId)
|
||||||
|
}
|
||||||
|
function keyResize(event: KeyboardEvent) {
|
||||||
|
const value = { ArrowLeft: props.modelValue - 2, ArrowRight: props.modelValue + 2, Home: 35, End: 65, Enter: 43 }[event.key]
|
||||||
|
if (value === undefined) return
|
||||||
|
event.preventDefault()
|
||||||
|
resize(value)
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<div class="transfer-pane-divider" role="separator" tabindex="0" aria-label="调整转运信息和换标申请宽度"
|
||||||
|
aria-orientation="vertical" :aria-valuenow="Math.round(modelValue)" :aria-valuemin="35" :aria-valuemax="65"
|
||||||
|
aria-controls="transfer-main-pane transfer-relabel-pane" title="左右拖动调整宽度,双击恢复"
|
||||||
|
@pointerdown="startDrag" @pointermove="moveDrag" @pointerup="endDrag" @pointercancel="endDrag"
|
||||||
|
@lostpointercapture="drag = null" @keydown="keyResize" @dblclick="resize(43)">
|
||||||
|
<span aria-hidden="true" />
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
.transfer-pane-divider { display:flex; width:16px; align-items:center; justify-content:center; align-self:stretch; cursor:col-resize; touch-action:none; user-select:none; outline:none; }
|
||||||
|
.transfer-pane-divider span { width:4px; height:64px; border-radius:4px; background:#c5d1e1; transition:background .15s; }
|
||||||
|
.transfer-pane-divider:hover, .transfer-pane-divider:focus-visible { background:#e9f1ff; border-radius:6px; }
|
||||||
|
.transfer-pane-divider:hover span, .transfer-pane-divider:focus-visible span { background:#3478c8; }
|
||||||
|
</style>
|
||||||
@@ -29,7 +29,7 @@ watch(() => props.transferNo, load, { immediate: true }); onBeforeUnmount(() =>
|
|||||||
<div><dt>取货进度</dt><dd>{{ labels[progress.status] || progress.status }}</dd></div><div><dt>车次号</dt><dd>{{ progress.tripNo || '待安排' }}</dd></div>
|
<div><dt>取货进度</dt><dd>{{ labels[progress.status] || progress.status }}</dd></div><div><dt>车次号</dt><dd>{{ progress.tripNo || '待安排' }}</dd></div>
|
||||||
<div><dt>车牌</dt><dd>{{ progress.vehiclePlate || '待分配' }}</dd></div><div><dt>司机</dt><dd>{{ progress.driverName || '待分配' }}</dd></div>
|
<div><dt>车牌</dt><dd>{{ progress.vehiclePlate || '待分配' }}</dd></div><div><dt>司机</dt><dd>{{ progress.driverName || '待分配' }}</dd></div>
|
||||||
<div><dt>司机电话</dt><dd>{{ progress.driverPhone || '—' }}</dd></div><div><dt>计划取货发车</dt><dd>{{ time(progress.plannedDepartureAt) }}</dd></div>
|
<div><dt>司机电话</dt><dd>{{ progress.driverPhone || '—' }}</dd></div><div><dt>计划取货发车</dt><dd>{{ time(progress.plannedDepartureAt) }}</dd></div>
|
||||||
<div><dt>实提箱数</dt><dd>{{ progress.actualPackages ?? '待取货' }}</dd></div><div><dt>取货时间</dt><dd>{{ time(progress.pickedAt) }}</dd></div>
|
<div><dt>实际取货数量(箱)</dt><dd>{{ progress.actualPackages ?? '待取货' }}</dd></div><div><dt>取货时间</dt><dd>{{ time(progress.pickedAt) }}</dd></div>
|
||||||
<div><dt>送仓时间</dt><dd>{{ time(progress.arrivedAt) }}</dd></div><div v-if="progress.remark"><dt>取货备注</dt><dd>{{ progress.remark }}</dd></div>
|
<div><dt>送仓时间</dt><dd>{{ time(progress.arrivedAt) }}</dd></div><div v-if="progress.remark"><dt>取货备注</dt><dd>{{ progress.remark }}</dd></div>
|
||||||
</dl>
|
</dl>
|
||||||
<div v-if="progress?.evidence.length" class="pickup-files"><span>取货凭证</span><el-button v-for="file in progress.evidence" :key="file.fileId" link type="primary" @click="download(file)">{{ file.fileName }}</el-button></div>
|
<div v-if="progress?.evidence.length" class="pickup-files"><span>取货凭证</span><el-button v-for="file in progress.evidence" :key="file.fileId" link type="primary" @click="download(file)">{{ file.fileName }}</el-button></div>
|
||||||
|
|||||||
@@ -5,6 +5,17 @@ export const overseasWarehouseModule = {
|
|||||||
key: 'overseas-warehouse',
|
key: 'overseas-warehouse',
|
||||||
navigationGroup: { title: '海外仓', icon: Warehouse },
|
navigationGroup: { title: '海外仓', icon: Warehouse },
|
||||||
routes: [
|
routes: [
|
||||||
|
{
|
||||||
|
path: 'overseas-warehouse/storage-transfer/create', name: 'overseas-storage-transfer-create',
|
||||||
|
component: () => import('./views/WarehouseServiceView.vue'), props: { service: 'transfer', createPage: true }, release: 'active',
|
||||||
|
meta: { title: '新增仓储转运单', workspaceTitle: '仓储转运 · 新建', description: '填写并提交仓储转运申请', permission: 'merchant:overseas-warehouse:transfer:create', keepAlive: false },
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: 'overseas-warehouse/cargo-disposal/create', name: 'overseas-cargo-disposal-create',
|
||||||
|
component: () => import('./views/WarehouseServiceView.vue'), props: { service: 'disposal', createPage: true }, release: 'active',
|
||||||
|
meta: { title: '新增货物废弃申请', workspaceTitle: '货物废弃 · 新建', description: '填写并提交货物废弃申请', permission: 'merchant:overseas-warehouse:discard:create', keepAlive: false },
|
||||||
|
},
|
||||||
|
|
||||||
{
|
{
|
||||||
path: 'overseas-warehouse/labeling/create', name: 'overseas-labeling-create',
|
path: 'overseas-warehouse/labeling/create', name: 'overseas-labeling-create',
|
||||||
component: () => import('./views/WarehouseServiceView.vue'), props: { service: 'labeling', createPage: true }, release: 'active',
|
component: () => import('./views/WarehouseServiceView.vue'), props: { service: 'labeling', createPage: true }, release: 'active',
|
||||||
|
|||||||
@@ -36,3 +36,27 @@ test('缺少箱级记录时合并仓位可用箱数并保持全部废弃明细',
|
|||||||
assert.equal(result.cartonSelectionSupported, false)
|
assert.equal(result.cartonSelectionSupported, false)
|
||||||
assert.equal(result.sources.length, 2)
|
assert.equal(result.sources.length, 2)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
test('接口 Long 字符串按数值相加,不串联数字', () => {
|
||||||
|
const source = { ...returned('1'), sourceType: 'INVENTORY', cartonSelectionSupported: false }
|
||||||
|
const sources = ['50', '100', '97'].map((availablePackages, index) => ({ ...source, orderId: `inventory:${index}`, returnCartonId: undefined, availablePackages }))
|
||||||
|
assert.equal(groupDiscardDocuments(sources)[0].availablePackages, 247)
|
||||||
|
assert.equal(groupDiscardDocuments([{ ...source, orderId: 'i:1', returnCartonId: undefined, availablePackages: '125' }, { ...source, orderId: 'i:2', returnCartonId: undefined, availablePackages: '125' }])[0].availablePackages, 250)
|
||||||
|
})
|
||||||
|
|
||||||
|
test('相同仓位重复关联只计一次,零值与未知可用量不进入可选来源', () => {
|
||||||
|
const source = { ...returned('1'), returnCartonId: undefined, sourceType: 'INVENTORY', inventoryPositionId: 'position:1', cartonSelectionSupported: false, availablePackages: 2 }
|
||||||
|
assert.equal(groupDiscardDocuments([source, source])[0].availablePackages, 2)
|
||||||
|
for (const availablePackages of [0, null, undefined, 'invalid']) assert.equal(groupDiscardDocuments([{ ...source, availablePackages }]).length, 0)
|
||||||
|
})
|
||||||
|
|
||||||
|
test('相同来源的混箱分片保留全部SKU和实箱,且不修改接口原始对象', () => {
|
||||||
|
const a = { ...returned('1'), sourceType: 'INVENTORY', inventoryPositionId: 'P', skus: [{ skuCode: 'A', availablePackages: 1 }] }
|
||||||
|
const b = { ...a, skus: [{ skuCode: 'B', availablePackages: 1 }], cartons: [{ ...a.cartons[0], skus: [{ skuCode: 'B', availablePackages: 1 }] }] }
|
||||||
|
const doc = groupDiscardDocuments([a, b])[0]
|
||||||
|
assert.equal(doc.availablePackages, 1)
|
||||||
|
assert.equal(doc.sources.length, 1)
|
||||||
|
assert.deepEqual(doc.sources[0].skus.map(sku => sku.skuCode), ['A', 'B'])
|
||||||
|
assert.deepEqual(doc.sources[0].cartons[0].skus.map(sku => sku.skuCode), ['A', 'B'])
|
||||||
|
assert.equal(a.skus.length, 1)
|
||||||
|
})
|
||||||
|
|||||||
@@ -7,7 +7,28 @@ export interface DiscardDocument extends DiscardCandidate {
|
|||||||
/** 下拉按来源单据和操作仓汇总;原始库存身份保留给选箱与提交。 */
|
/** 下拉按来源单据和操作仓汇总;原始库存身份保留给选箱与提交。 */
|
||||||
export function groupDiscardDocuments(candidates: DiscardCandidate[]): DiscardDocument[] {
|
export function groupDiscardDocuments(candidates: DiscardCandidate[]): DiscardDocument[] {
|
||||||
const groups = new Map<string, DiscardDocument>()
|
const groups = new Map<string, DiscardDocument>()
|
||||||
|
const identities = new Map<string, DiscardCandidate>()
|
||||||
for (const candidate of candidates) {
|
for (const candidate of candidates) {
|
||||||
|
const available = Number(candidate.availablePackages)
|
||||||
|
if (candidate.availablePackages == null || !Number.isFinite(available) || available <= 0) continue
|
||||||
|
// 按真实来源身份去重;缺身份的旧接口行仍独立保留,不合并不同库存。
|
||||||
|
const identity = candidate.sourceType === 'RETURN_CARTON' ? candidate.returnCartonId : candidate.inventoryPositionId || candidate.orderId
|
||||||
|
const sourceKey = identity ? JSON.stringify([candidate.overseasWarehouseId, candidate.sourceType, identity]) : null
|
||||||
|
const existing = sourceKey ? identities.get(sourceKey) : undefined
|
||||||
|
if (existing) {
|
||||||
|
// 同一仓位的分片响应合并 SKU 和箱,重复关联不会丢掉箱内商品。
|
||||||
|
existing.skus = [...new Map([...existing.skus, ...candidate.skus].map(sku => [sku.skuCode, sku])).values()]
|
||||||
|
const cartons = new Map((existing.cartons || []).map(box => [box.cartonId, box]))
|
||||||
|
for (const box of candidate.cartons || []) {
|
||||||
|
const old = cartons.get(box.cartonId)
|
||||||
|
cartons.set(box.cartonId, old ? { ...old, skus: [...new Map([...old.skus, ...box.skus].map(sku => [sku.skuCode, sku])).values()] } : { ...box })
|
||||||
|
}
|
||||||
|
existing.cartons = [...cartons.values()]
|
||||||
|
existing.availablePackages = Math.max(Number(existing.availablePackages), available)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
const source = { ...candidate, skus: [...candidate.skus], cartons: candidate.cartons?.map(box => ({ ...box, skus: [...box.skus] })) }
|
||||||
|
if (sourceKey) identities.set(sourceKey, source)
|
||||||
const documentNo = candidate.inboundOrderNo || candidate.inboundCode
|
const documentNo = candidate.inboundOrderNo || candidate.inboundCode
|
||||||
const key = JSON.stringify([candidate.overseasWarehouseId, candidate.sourceType, documentNo || candidate.orderId])
|
const key = JSON.stringify([candidate.overseasWarehouseId, candidate.sourceType, documentNo || candidate.orderId])
|
||||||
let document = groups.get(key)
|
let document = groups.get(key)
|
||||||
@@ -15,7 +36,7 @@ export function groupDiscardDocuments(candidates: DiscardCandidate[]): DiscardDo
|
|||||||
document = { ...candidate, orderId: key, sources: [], availablePackages: 0 }
|
document = { ...candidate, orderId: key, sources: [], availablePackages: 0 }
|
||||||
groups.set(key, document)
|
groups.set(key, document)
|
||||||
}
|
}
|
||||||
document.sources.push(candidate)
|
document.sources.push(source)
|
||||||
}
|
}
|
||||||
for (const document of groups.values()) {
|
for (const document of groups.values()) {
|
||||||
const boxes = new Set<string>()
|
const boxes = new Set<string>()
|
||||||
@@ -27,7 +48,9 @@ export function groupDiscardDocuments(candidates: DiscardCandidate[]): DiscardDo
|
|||||||
} else if (source.cartonSelectionSupported && source.cartons?.length) {
|
} else if (source.cartonSelectionSupported && source.cartons?.length) {
|
||||||
for (const box of source.cartons) boxes.add(`${source.sourceType}:${box.cartonId}`)
|
for (const box of source.cartons) boxes.add(`${source.sourceType}:${box.cartonId}`)
|
||||||
} else {
|
} else {
|
||||||
untrackedPackages += source.availablePackages
|
// Long 序列化可能返回字符串,必须先转数值再汇总,避免拼成 005010097。
|
||||||
|
const packages = Number(source.availablePackages)
|
||||||
|
untrackedPackages += Number.isFinite(packages) && packages > 0 ? packages : 0
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
document.availablePackages = boxes.size + untrackedPackages
|
document.availablePackages = boxes.size + untrackedPackages
|
||||||
|
|||||||
@@ -20,6 +20,14 @@ test('签收箱号只包含箱子和托盘签收,包裹实物记录不重复
|
|||||||
assert.deepEqual(exports.receiptBoxDetails(receipts.slice(0, 1), cartons), [])
|
assert.deepEqual(exports.receiptBoxDetails(receipts.slice(0, 1), cartons), [])
|
||||||
})
|
})
|
||||||
|
|
||||||
|
test('零箱、未记录箱数和包裹不补造一箱,缺少箱数时可使用真实标签', () => {
|
||||||
|
assert.equal(exports.receiptPrintableBoxCount([{ unitType: 'BOX', boxCount: 0, labels: [] }]), 0)
|
||||||
|
assert.equal(exports.receiptPrintableBoxCount([{ unitType: 'PALLET', boxCount: null, labels: [] }]), 0)
|
||||||
|
assert.equal(exports.receiptPrintableBoxCount([{ unitType: 'PARCEL', boxCount: 1, labels: [{}] }]), 0)
|
||||||
|
assert.equal(exports.receiptPrintableBoxCount([{ unitType: 'PALLET', boxCount: null, labels: [{}, {}] }]), 2)
|
||||||
|
assert.equal(exports.receiptPrintableBoxCount([{ boxCount: -1 }, { boxCount: 'bad' }]), 0)
|
||||||
|
})
|
||||||
|
|
||||||
test('volume rounds upward to exactly three decimal places without increasing exact thousandths', () => {
|
test('volume rounds upward to exactly three decimal places without increasing exact thousandths', () => {
|
||||||
for (const [input, expected] of [[0.186624, '0.187'], [0.15, '0.150'], [1.001, '1.001'], [1.00100001, '1.002'], [0.0000001, '0.001'], [0, '0.000'], [null, '—'], [NaN, '—']]) {
|
for (const [input, expected] of [[0.186624, '0.187'], [0.15, '0.150'], [1.001, '1.001'], [1.00100001, '1.002'], [0.0000001, '0.001'], [0, '0.000'], [null, '—'], [NaN, '—']]) {
|
||||||
assert.equal(exports.formatReturnVolume(input), expected)
|
assert.equal(exports.formatReturnVolume(input), expected)
|
||||||
|
|||||||
@@ -1,7 +1,12 @@
|
|||||||
import type { ReturnPallet, ReturnReceipt, ReturnReceiptCarton } from '../api/returnOrders'
|
import type { ReturnPallet, ReturnReceipt, ReturnReceiptCarton } from '../api/returnOrders'
|
||||||
|
|
||||||
export function receiptPrintableBoxCount(receipts: ReturnReceipt[]) {
|
export function receiptPrintableBoxCount(receipts: ReturnReceipt[]) {
|
||||||
return receipts.reduce((total, receipt) => total + Number(receipt.labels?.length || receipt.boxCount || 1), 0)
|
// 只累计真实箱数;缺少箱数时使用已生成标签,不凭空补一箱。
|
||||||
|
return receipts.reduce((total, receipt) => {
|
||||||
|
if (receipt.unitType === 'PARCEL') return total
|
||||||
|
const count = Number(receipt.boxCount ?? receipt.labels?.length ?? 0)
|
||||||
|
return total + (Number.isSafeInteger(count) && count >= 0 ? count : 0)
|
||||||
|
}, 0)
|
||||||
}
|
}
|
||||||
|
|
||||||
export function receiptPhysicalDetails(pallets: ReturnPallet[], boxes: ReturnReceiptCarton[]) {
|
export function receiptPhysicalDetails(pallets: ReturnPallet[], boxes: ReturnReceiptCarton[]) {
|
||||||
|
|||||||
@@ -285,7 +285,7 @@ onMounted(() => { if (props.detailPage) void Promise.all([loadCartonDetail(), lo
|
|||||||
<template #time="{ row }"><span class="inventory-time">{{ formatInventoryTime(row.updatedAt || row.createdAt || row.receivedAt) }}</span></template>
|
<template #time="{ row }"><span class="inventory-time">{{ formatInventoryTime(row.updatedAt || row.createdAt || row.receivedAt) }}</span></template>
|
||||||
</DataTable>
|
</DataTable>
|
||||||
</div>
|
</div>
|
||||||
<el-dialog v-model="showPackingCreate" title="创建合箱计划" width="720px" destroy-on-close><el-form label-width="110px"><el-form-item label="已完成退货单"><el-input v-model="packingForm.returnNos" type="textarea" :rows="2" placeholder="输入退货单号,多个用空格或逗号分隔" /></el-form-item><el-form-item label="合箱 SKU"><div class="packing-sku-grid"><div v-for="item in summaryRows" :key="item.skuCode" class="packing-sku-row"><el-checkbox :model-value="packingForm.selectedSkus[item.skuCode] !== undefined" @change="togglePackingSku(item.skuCode, Boolean($event))">{{ item.skuCode }}</el-checkbox><span>可用 {{ item.availableQuantity }}</span><el-input-number v-if="packingForm.selectedSkus[item.skuCode] !== undefined" v-model="packingForm.selectedSkus[item.skuCode]" :min="1" :max="item.availableQuantity" :controls="false" placeholder="数量" /></div></div></el-form-item><el-form-item label="箱规"><div class="packing-dimensions"><el-input-number v-model="packingForm.length" :min="1" placeholder="长 cm" /><el-input-number v-model="packingForm.width" :min="1" placeholder="宽 cm" /><el-input-number v-model="packingForm.height" :min="1" placeholder="高 cm" /><el-input-number v-model="packingForm.weight" :min="1" placeholder="重量 kg" /></div></el-form-item><el-form-item label="备注"><el-input v-model="packingForm.remark" placeholder="可填写合箱说明" /></el-form-item></el-form><template #footer><el-button @click="showPackingCreate = false">取消</el-button><el-button type="primary" :loading="packingSaving" @click="submitPackingPlan">提交审核</el-button></template></el-dialog>
|
<el-dialog v-model="showPackingCreate" title="创建合箱计划" width="720px" destroy-on-close><el-form label-width="110px"><el-form-item label="已完成退货单"><el-input v-model="packingForm.returnNos" type="textarea" :rows="2" placeholder="输入退货单号,多个用空格或逗号分隔" /></el-form-item><el-form-item label="合箱 SKU"><div class="packing-sku-grid"><div v-for="item in summaryRows" :key="item.skuCode" class="packing-sku-row"><el-checkbox :model-value="packingForm.selectedSkus[item.skuCode] !== undefined" @change="togglePackingSku(item.skuCode, Boolean($event))">{{ item.skuCode }}</el-checkbox><span>可用 {{ item.availableQuantity }}</span><el-input-number v-if="packingForm.selectedSkus[item.skuCode] !== undefined" v-model="packingForm.selectedSkus[item.skuCode]" :min="1" :max="item.availableQuantity" :controls="false" placeholder="数量" /></div></div></el-form-item><el-form-item label="箱规"><div class="packing-dimensions"><el-input-number v-model="packingForm.length" :min="1" placeholder="长 cm" /><el-input-number v-model="packingForm.width" :min="1" placeholder="宽 cm" /><el-input-number v-model="packingForm.height" :min="1" placeholder="高 cm" /><el-input-number v-model="packingForm.weight" :min="1" placeholder="重量 kg" /></div></el-form-item><el-form-item label="备注"><el-input v-model="packingForm.remark" placeholder="" /></el-form-item></el-form><template #footer><el-button @click="showPackingCreate = false">取消</el-button><el-button type="primary" :loading="packingSaving" @click="submitPackingPlan">提交审核</el-button></template></el-dialog>
|
||||||
</template>
|
</template>
|
||||||
<article v-else v-loading="loading" class="carton-detail-surface">
|
<article v-else v-loading="loading" class="carton-detail-surface">
|
||||||
<template v-if="cartonDetail">
|
<template v-if="cartonDetail">
|
||||||
|
|||||||
@@ -6,6 +6,45 @@ import ts from 'typescript'
|
|||||||
const view = readFileSync(new URL('./ReturnOrdersView.vue', import.meta.url), 'utf8')
|
const view = readFileSync(new URL('./ReturnOrdersView.vue', import.meta.url), 'utf8')
|
||||||
const api = readFileSync(new URL('../api/returnOrders.ts', import.meta.url), 'utf8')
|
const api = readFileSync(new URL('../api/returnOrders.ts', import.meta.url), 'utf8')
|
||||||
|
|
||||||
|
function listHarness(list, summary) {
|
||||||
|
const state = { query: { page: 1, size: 1, skuCode: 'FILTER' }, loading: { value: false }, listError: { value: '' }, rows: { value: [] }, total: { value: 0 } }
|
||||||
|
const source = view.slice(view.indexOf('async function load()'), view.indexOf('\nfunction changePage('))
|
||||||
|
const js = ts.transpileModule(source, { compilerOptions: { target: ts.ScriptTarget.ES2022 } }).outputText
|
||||||
|
const load = new Function(...Object.keys(state), 'listReturnOrders', 'getReturnOrderStatistics', `let listRequest=0; ${js}; return load`)(...Object.values(state), list, summary)
|
||||||
|
return { ...state, load }
|
||||||
|
}
|
||||||
|
|
||||||
|
test('分页行按服务器单号映射载体,不展示全筛选汇总', async () => {
|
||||||
|
const calls = []
|
||||||
|
const totals = { orderCount: 3, skuTypes: 3, expectedQuantity: 19, receivedQuantity: 14, remainingQuantity: 5 }
|
||||||
|
const h = listHarness(async p => { calls.push(p); return { total: '3', records: [{ returnNo: 'RT-1', receivedQuantity: 8 }] } }, async p => { calls.push(p); return { totals, pageDimensions: [{ returnNo: 'RT-1', receivedParcelCount: 1, receivedBoxCount: 1 }] } })
|
||||||
|
await h.load()
|
||||||
|
assert.equal(h.total.value, 3)
|
||||||
|
assert.doesNotMatch(view, /return-filter-summary|预报箱\/包裹\/托数/)
|
||||||
|
assert.equal(h.rows.value[0].receivedParcelCount, 1)
|
||||||
|
h.query.page = 2
|
||||||
|
await h.load()
|
||||||
|
assert.equal(h.rows.value[0].receivedBoxCount, 1)
|
||||||
|
assert.deepEqual(calls[2], calls[3])
|
||||||
|
assert.equal(calls[3].page, 2)
|
||||||
|
})
|
||||||
|
|
||||||
|
test('维度查询失败清空旧列表,并忽略较旧查询的迟到结果', async () => {
|
||||||
|
let fail = false, finish
|
||||||
|
const h = listHarness(async () => ({ total: 1, records: [{ returnNo: 'RT-1' }] }), async p => {
|
||||||
|
if (fail) throw Error('统计服务不可用')
|
||||||
|
if (p.page === 1) return new Promise(resolve => { finish = resolve })
|
||||||
|
return { totals: { orderCount: 2 }, pageDimensions: [{ returnNo: 'RT-1', receivedBoxCount: 2 }] }
|
||||||
|
})
|
||||||
|
const old = h.load(); h.query.page = 2; await h.load()
|
||||||
|
finish({ totals: { orderCount: 999 }, pageDimensions: [] }); await old
|
||||||
|
assert.equal(h.rows.value[0].receivedBoxCount, 2)
|
||||||
|
fail = true; await h.load()
|
||||||
|
assert.deepEqual(h.rows.value, [])
|
||||||
|
assert.equal(h.listError.value, '统计服务不可用')
|
||||||
|
assert.equal(h.loading.value, false)
|
||||||
|
})
|
||||||
|
|
||||||
function submitHarness(failure) {
|
function submitHarness(failure) {
|
||||||
const source = view.slice(view.indexOf('async function submit()'), view.indexOf('\nfunction statusType('))
|
const source = view.slice(view.indexOf('async function submit()'), view.indexOf('\nfunction statusType('))
|
||||||
const state = { requests: [], loads: 0, routes: [], errors: [], successes: [] }
|
const state = { requests: [], loads: 0, routes: [], errors: [], successes: [] }
|
||||||
@@ -77,11 +116,10 @@ test('新建退货预报使用独立路由页面,编辑仍保留加宽弹框',
|
|||||||
assert.match(view, /class="return-create-actions"[\s\S]*?<el-button type="primary" :loading="creating" @click="submit">提交预报<\/el-button>/)
|
assert.match(view, /class="return-create-actions"[\s\S]*?<el-button type="primary" :loading="creating" @click="submit">提交预报<\/el-button>/)
|
||||||
})
|
})
|
||||||
|
|
||||||
test('新建预报铺满工作区,联系字段与数量输入保持紧凑', () => {
|
test('新建预报铺满工作区,基础字段等宽对齐且数量输入保持紧凑', () => {
|
||||||
assert.match(view, /return-create-surface \{ width:100%; min-width:0;[^}]*margin:0;/)
|
assert.match(view, /return-create-surface \{ width:100%; min-width:0;[^}]*margin:0;/)
|
||||||
assert.match(view, /<el-form label-width="130px" class="return-create-form">/)
|
assert.match(view, /<el-form label-width="130px" class="return-create-form">/)
|
||||||
assert.match(view, /return-create-form :deep\(\.el-input\) \{ max-width:320px;/)
|
assert.match(view, /return-create-form :deep\(\.el-input\), \.return-create-body \.return-create-form :deep\(\.el-select\) \{ width:100%; max-width:none;/)
|
||||||
assert.match(view, /return-create-form :deep\(\.el-select\) \{ max-width:520px;/)
|
|
||||||
assert.match(view, /:deep\(\.el-table \.el-input-number\) \{ width:120px;/)
|
assert.match(view, /:deep\(\.el-table \.el-input-number\) \{ width:120px;/)
|
||||||
assert.match(view, /<el-table class="return-forecast-table"[^>]*>/)
|
assert.match(view, /<el-table class="return-forecast-table"[^>]*>/)
|
||||||
assert.match(view, /return-forecast-table \{[^}]*border-radius:8px;/)
|
assert.match(view, /return-forecast-table \{[^}]*border-radius:8px;/)
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ import { getMerchantWarehouses, type MerchantWarehouse } from '@/modules/first-l
|
|||||||
import { createIdempotencyKey } from '@/utils/idempotencyKey'
|
import { createIdempotencyKey } from '@/utils/idempotencyKey'
|
||||||
import { createReturnOrder, downloadReturnPhoto, getReturnOrder, listReturnOrders, updateReturnOrder, type ReturnOrderDetail, type ReturnOrderSummary, type ReturnReceipt } from '../api/returnOrders'
|
import { createReturnOrder, downloadReturnPhoto, getReturnOrder, listReturnOrders, updateReturnOrder, type ReturnOrderDetail, type ReturnOrderSummary, type ReturnReceipt } from '../api/returnOrders'
|
||||||
import ReviewRejectionNotice from '../components/ReviewRejectionNotice.vue'
|
import ReviewRejectionNotice from '../components/ReviewRejectionNotice.vue'
|
||||||
|
import { getReturnOrderStatistics } from '../api/returnOrders'
|
||||||
import { getReturnInventoryLabel } from '../api/returnInventory'
|
import { getReturnInventoryLabel } from '../api/returnInventory'
|
||||||
import { formatReturnVolume, receiptBoxDetails, receiptPhysicalDetails, receiptPrintableBoxCount, receiptTrackingNo } from '../utils/returnReceiptDisplay'
|
import { formatReturnVolume, receiptBoxDetails, receiptPhysicalDetails, receiptPrintableBoxCount, receiptTrackingNo } from '../utils/returnReceiptDisplay'
|
||||||
|
|
||||||
@@ -40,6 +41,8 @@ const printableBoxCount = computed(() => receiptPrintableBoxCount(printableRecei
|
|||||||
const photoUrls = reactive<Record<string, string>>({})
|
const photoUrls = reactive<Record<string, string>>({})
|
||||||
const rows = ref<ReturnOrderSummary[]>([])
|
const rows = ref<ReturnOrderSummary[]>([])
|
||||||
const total = ref(0)
|
const total = ref(0)
|
||||||
|
const listError = ref('')
|
||||||
|
let listRequest = 0
|
||||||
const operationWarehouses = ref<MerchantWarehouse[]>([])
|
const operationWarehouses = ref<MerchantWarehouse[]>([])
|
||||||
const operationWarehousesLoading = ref(false)
|
const operationWarehousesLoading = ref(false)
|
||||||
const operationWarehousesError = ref('')
|
const operationWarehousesError = ref('')
|
||||||
@@ -62,8 +65,13 @@ const tableColumns: DataTableColumn[] = [
|
|||||||
{ key: 'actions', label: '操作', slotName: 'actions', width: 220, fixed: 'left' },
|
{ key: 'actions', label: '操作', slotName: 'actions', width: 220, fixed: 'left' },
|
||||||
{ prop: 'returnNo', label: '退货单号', minWidth: 190 }, { prop: 'customerReferenceNo', label: '客户参考号', minWidth: 160 },
|
{ prop: 'returnNo', label: '退货单号', minWidth: 190 }, { prop: 'customerReferenceNo', label: '客户参考号', minWidth: 160 },
|
||||||
{ key: 'warehouse', label: '操作仓', slotName: 'warehouse', minWidth: 200 }, { key: 'relabel', label: '换标', slotName: 'relabel', width: 100 },
|
{ key: 'warehouse', label: '操作仓', slotName: 'warehouse', minWidth: 200 }, { key: 'relabel', label: '换标', slotName: 'relabel', width: 100 },
|
||||||
{ prop: 'skuTypes', label: 'SKU 种类', width: 105 }, { prop: 'expectedQuantity', label: '预报数量', width: 110 },
|
{ prop: 'skuTypes', label: 'SKU 种类', width: 105 }, { prop: 'expectedQuantity', label: '预报(件)', width: 110 },
|
||||||
{ prop: 'receivedQuantity', label: '实收数量', width: 110 }, { key: 'status', label: '状态', slotName: 'status', width: 150 },
|
{ prop: 'receivedQuantity', label: '实收(件)', width: 110 },
|
||||||
|
{ prop: 'remainingQuantity', label: '待收(件)', width: 110 },
|
||||||
|
{ prop: 'receivedBoxCount', label: '签收箱数', width: 110 },
|
||||||
|
{ prop: 'receivedParcelCount', label: '签收包裹数', width: 115 },
|
||||||
|
{ prop: 'receivedPalletCount', label: '签收托数', width: 110 },
|
||||||
|
{ key: 'status', label: '状态', slotName: 'status', width: 150 },
|
||||||
{ key: 'relabelApplications', label: '换标子单', slotName: 'relabelApplications', minWidth: 340 },
|
{ key: 'relabelApplications', label: '换标子单', slotName: 'relabelApplications', minWidth: 340 },
|
||||||
{ key: 'createdAt', label: '创建时间', slotName: 'createdAt', width: 180 },
|
{ key: 'createdAt', label: '创建时间', slotName: 'createdAt', width: 180 },
|
||||||
]
|
]
|
||||||
@@ -147,9 +155,21 @@ async function openEdit(returnNo: string) {
|
|||||||
function addItem() { form.items.push(emptySku()) }
|
function addItem() { form.items.push(emptySku()) }
|
||||||
function removeItem(index: number) { if (form.items.length > 1) form.items.splice(index, 1) }
|
function removeItem(index: number) { if (form.items.length > 1) form.items.splice(index, 1) }
|
||||||
async function load() {
|
async function load() {
|
||||||
|
const request = ++listRequest
|
||||||
loading.value = true
|
loading.value = true
|
||||||
try { const response = await listReturnOrders({ ...query, returnNo: query.returnNo || undefined, trackingNo: query.trackingNo || undefined, skuCode: query.skuCode || undefined, status: query.status || undefined }); rows.value = response.records; total.value = Number(response.total); if (!Number.isFinite(total.value)) total.value = response.records.length }
|
listError.value = ''
|
||||||
finally { loading.value = false }
|
try {
|
||||||
|
const params = { ...query, returnNo: query.returnNo || undefined, trackingNo: query.trackingNo || undefined, skuCode: query.skuCode || undefined, status: query.status || undefined }
|
||||||
|
const [response, summary] = await Promise.all([listReturnOrders(params), getReturnOrderStatistics(params)])
|
||||||
|
if (request !== listRequest) return
|
||||||
|
const dimensions = new Map(summary.pageDimensions.map(row => [row.returnNo, row]))
|
||||||
|
rows.value = response.records.map(row => ({ ...row, ...dimensions.get(row.returnNo) }))
|
||||||
|
total.value = Number(response.total)
|
||||||
|
} catch (error) {
|
||||||
|
if (request !== listRequest) return
|
||||||
|
rows.value = []; total.value = 0
|
||||||
|
listError.value = error instanceof Error ? error.message : '退货列表加载失败'
|
||||||
|
} finally { if (request === listRequest) loading.value = false }
|
||||||
}
|
}
|
||||||
function changePage(page: number) {
|
function changePage(page: number) {
|
||||||
if (page === query.page) return
|
if (page === query.page) return
|
||||||
@@ -323,6 +343,7 @@ onBeforeUnmount(clearPhotoUrls)
|
|||||||
|
|
||||||
<template v-else-if="!props.detailPage">
|
<template v-else-if="!props.detailPage">
|
||||||
<QueryToolbar v-model="queryModel" class="return-query" layout="grid" ariaLabel="退货签收筛选" :fields="queryFields" @search="search" />
|
<QueryToolbar v-model="queryModel" class="return-query" layout="grid" ariaLabel="退货签收筛选" :fields="queryFields" @search="search" />
|
||||||
|
<el-alert v-if="listError" type="error" :closable="false" :title="listError"><el-button @click="load">重新加载</el-button></el-alert>
|
||||||
<div class="return-table-card">
|
<div class="return-table-card">
|
||||||
<DataTable v-model:page="query.page" v-model:page-size="query.size" :data="rows" :columns="tableColumns" :loading="loading" :total="total" :page-sizes="[15, 30, 50, 100]" :row-actions="rowActions" row-key="returnNo" empty-text="暂无退货预报">
|
<DataTable v-model:page="query.page" v-model:page-size="query.size" :data="rows" :columns="tableColumns" :loading="loading" :total="total" :page-sizes="[15, 30, 50, 100]" :row-actions="rowActions" row-key="returnNo" empty-text="暂无退货预报">
|
||||||
<template #toolbar-actions><el-button v-if="canCreate" type="primary" @click="openCreate"><Plus :size="16" />新建退货预报</el-button></template>
|
<template #toolbar-actions><el-button v-if="canCreate" type="primary" @click="openCreate"><Plus :size="16" />新建退货预报</el-button></template>
|
||||||
@@ -364,7 +385,7 @@ onBeforeUnmount(clearPhotoUrls)
|
|||||||
<section class="return-detail-section">
|
<section class="return-detail-section">
|
||||||
<h3>签收概览</h3>
|
<h3>签收概览</h3>
|
||||||
<div class="return-detail-grid">
|
<div class="return-detail-grid">
|
||||||
<div><span>实收 / 预报</span><strong>{{ selected.order.receivedQuantity }} / {{ selected.order.expectedQuantity }}</strong></div>
|
<div><span>预报(件)</span><strong>{{ selected.order.expectedQuantity }}</strong></div><div><span>实收(件)</span><strong>{{ selected.order.receivedQuantity }}</strong></div><div><span>待收(件)</span><strong>{{ Math.max(selected.order.expectedQuantity - selected.order.receivedQuantity, 0) }}</strong></div>
|
||||||
<div><span>SKU 种类</span><strong>{{ selected.order.skuTypes }}</strong></div>
|
<div><span>SKU 种类</span><strong>{{ selected.order.skuTypes }}</strong></div>
|
||||||
<div><span>是否换标</span><strong>{{ selected.order.needRelabel ? '需要换标' : '否' }}</strong></div>
|
<div><span>是否换标</span><strong>{{ selected.order.needRelabel ? '需要换标' : '否' }}</strong></div>
|
||||||
<div><span>客户参考号</span><strong>{{ selected.order.customerReferenceNo || '—' }}</strong></div>
|
<div><span>客户参考号</span><strong>{{ selected.order.customerReferenceNo || '—' }}</strong></div>
|
||||||
@@ -484,16 +505,15 @@ onBeforeUnmount(clearPhotoUrls)
|
|||||||
.relabel-suborder { display: flex; align-items: center; gap: 8px; min-height: 30px; white-space: nowrap; }
|
.relabel-suborder { display: flex; align-items: center; gap: 8px; min-height: 30px; white-space: nowrap; }
|
||||||
.return-orders-page { display:grid; gap:12px; } .return-create-form { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); column-gap:20px; } .return-form-wide { grid-column:1 / -1; } .items-title { display:flex; justify-content:space-between; align-items:center; margin:16px 0 4px; font-weight:600; } h3 { margin:24px 0 10px; font-size:16px; } h4 { margin:16px 0 8px; font-size:14px; } .remark { white-space:pre-wrap; } .warehouse-error, .duplicate-sku-error { margin-top:6px; color:var(--el-color-danger); font-size:12px; } :deep(.duplicate-sku-input .el-input__wrapper) { box-shadow:0 0 0 1px var(--el-color-danger) inset; } :deep(.el-dialog .el-select) { width:100%; }
|
.return-orders-page { display:grid; gap:12px; } .return-create-form { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); column-gap:20px; } .return-form-wide { grid-column:1 / -1; } .items-title { display:flex; justify-content:space-between; align-items:center; margin:16px 0 4px; font-weight:600; } h3 { margin:24px 0 10px; font-size:16px; } h4 { margin:16px 0 8px; font-size:14px; } .remark { white-space:pre-wrap; } .warehouse-error, .duplicate-sku-error { margin-top:6px; color:var(--el-color-danger); font-size:12px; } :deep(.duplicate-sku-input .el-input__wrapper) { box-shadow:0 0 0 1px var(--el-color-danger) inset; } :deep(.el-dialog .el-select) { width:100%; }
|
||||||
.return-create-surface { width:100%; min-width:0; min-height:calc(100dvh - 198px); margin:0; box-sizing:border-box; overflow:hidden; border:1px solid var(--client-border); border-radius:var(--client-radius); background:#fff; }
|
.return-create-surface { width:100%; min-width:0; min-height:calc(100dvh - 198px); margin:0; box-sizing:border-box; overflow:hidden; border:1px solid var(--client-border); border-radius:var(--client-radius); background:#fff; }
|
||||||
.return-create-header, .return-create-body, .return-create-actions { width:calc(100% - 24px); max-width:1118px; margin-left:24px; box-sizing:border-box; }
|
.return-create-header, .return-create-body, .return-create-actions { width:100%; min-width:0; box-sizing:border-box; }
|
||||||
.return-create-header { display:flex; min-height:68px; align-items:center; justify-content:space-between; gap:20px; padding:12px 20px; border-bottom:1px solid var(--client-border); }
|
.return-create-header { display:flex; min-height:68px; align-items:center; justify-content:space-between; gap:20px; padding:12px 20px; border-bottom:1px solid var(--client-border); }
|
||||||
.return-create-header h2 { margin:0; color:#1f2d45; font-size:20px; }
|
.return-create-header h2 { margin:0; color:#1f2d45; font-size:20px; }
|
||||||
.return-create-body { padding:18px 20px 14px; }
|
.return-create-body { padding:18px 20px 14px; }
|
||||||
.return-create-body :deep(.el-select), .return-create-body :deep(.el-input-number) { width:100%; }
|
.return-create-body :deep(.el-select), .return-create-body :deep(.el-input-number) { width:100%; }
|
||||||
.return-create-body .return-create-form { max-width:900px; column-gap:24px; }
|
.return-create-body .return-create-form { width:100%; column-gap:24px; }
|
||||||
.return-create-body .return-create-form :deep(.el-form-item) { margin-bottom:16px; }
|
.return-create-body .return-create-form :deep(.el-form-item) { margin-bottom:16px; }
|
||||||
.return-create-body .return-create-form :deep(.el-form-item__content) { min-width:0; }
|
.return-create-body .return-create-form :deep(.el-form-item__content) { min-width:0; }
|
||||||
.return-create-body .return-create-form :deep(.el-input) { max-width:320px; }
|
.return-create-body .return-create-form :deep(.el-input), .return-create-body .return-create-form :deep(.el-select) { width:100%; max-width:none; }
|
||||||
.return-create-body .return-create-form :deep(.el-select) { max-width:520px; }
|
|
||||||
.return-create-body .return-create-form :deep(.el-textarea) { max-width:100%; }
|
.return-create-body .return-create-form :deep(.el-textarea) { max-width:100%; }
|
||||||
.return-create-body :deep(.el-table .el-input-number) { width:120px; }
|
.return-create-body :deep(.el-table .el-input-number) { width:120px; }
|
||||||
.return-forecast-table { overflow:hidden; border:1px solid var(--client-border); border-radius:8px; --el-table-header-bg-color:#f5f7fb; --el-table-header-text-color:#526176; --el-table-border-color:#edf1f5; --el-table-row-hover-bg-color:#f8faff; }
|
.return-forecast-table { overflow:hidden; border:1px solid var(--client-border); border-radius:8px; --el-table-header-bg-color:#f5f7fb; --el-table-header-text-color:#526176; --el-table-border-color:#edf1f5; --el-table-row-hover-bg-color:#f8faff; }
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
@@ -28,7 +28,7 @@ test('废弃来源包含通用仓位,选择后带出全部库存且不把选
|
|||||||
function selectionRows(boxes, selectedKeys) {
|
function selectionRows(boxes, selectedKeys) {
|
||||||
const body = view.match(/function syncDiscardSelection\(\) \{([\s\S]*?)\n\}/)[1].replace('new Map<string, CargoRow>()', 'new Map()')
|
const body = view.match(/function syncDiscardSelection\(\) \{([\s\S]*?)\n\}/)[1].replace('new Map<string, CargoRow>()', 'new Map()')
|
||||||
const rows = { value: [] }
|
const rows = { value: [] }
|
||||||
new Function('discardSelectableBoxes', 'discardSelectedBoxKeys', 'cargoRows', 'createCargoRow', body)({ value: boxes }, { value: selectedKeys }, rows, () => ({}))
|
new Function('discardSourceBoxes', 'discardSelectedBoxKeys', 'cargoRows', 'createCargoRow', body)({ value: boxes }, { value: selectedKeys }, rows, () => ({}))
|
||||||
return rows.value
|
return rows.value
|
||||||
}
|
}
|
||||||
test('部分废弃只提交勾选的箱子,数量由箱子汇总,清空后无明细', () => {
|
test('部分废弃只提交勾选的箱子,数量由箱子汇总,清空后无明细', () => {
|
||||||
@@ -48,3 +48,12 @@ test('混合SKU箱按实物箱只计一次,退货箱仍整箱携带全部SKU',
|
|||||||
const returnRows = selectionRows([{ key: 'RETURN_CARTON:2', cartonId: '2', source: returned, skus }], ['RETURN_CARTON:2'])
|
const returnRows = selectionRows([{ key: 'RETURN_CARTON:2', cartonId: '2', source: returned, skus }], ['RETURN_CARTON:2'])
|
||||||
assert.deepEqual(returnRows.map(row => row.quantity), [2, 3]); assert.ok(returnRows.every(row => row.returnCartonId === '2' && row.discardCartonIds === undefined))
|
assert.deepEqual(returnRows.map(row => row.quantity), [2, 3]); assert.ok(returnRows.every(row => row.returnCartonId === '2' && row.discardCartonIds === undefined))
|
||||||
})
|
})
|
||||||
|
|
||||||
|
test('通用混箱同仓位保留全部SKU,跨仓位相同SKU保持独立来源', () => {
|
||||||
|
const skus = [{ skuCode: 'A', availablePackages: 1 }, { skuCode: 'B', availablePackages: 1 }]
|
||||||
|
const source = { orderId: null, inventoryPositionId: '42', sourceType: 'INVENTORY', availablePackages: 1, skus }
|
||||||
|
const boxes = [{ key: 'INVENTORY:1', cartonId: '1', source, skus }, { key: 'INVENTORY:2', cartonId: '2', source: { ...source, inventoryPositionId: '43' }, skus: [skus[0]] }]
|
||||||
|
const rows = selectionRows(boxes, ['INVENTORY:1', 'INVENTORY:2'])
|
||||||
|
assert.equal(rows.length, 3)
|
||||||
|
assert.deepEqual(rows.map(row => [row.sourceInventoryPositionId, row.sku, row.quantity, row.discardCartonIds]), [['42', 'A', 1, ['1']], ['42', 'B', 1, ['1']], ['43', 'A', 1, ['2']]])
|
||||||
|
})
|
||||||
|
|||||||
@@ -19,3 +19,11 @@ test('mixed carton detail and pallet summaries preserve every SKU without duplic
|
|||||||
assert.equal(display.receivedItemQuantity('2'), 7)
|
assert.equal(display.receivedItemQuantity('2'), 7)
|
||||||
assert.equal(display.receivedItemCartons('2').length, 1)
|
assert.equal(display.receivedItemCartons('2').length, 1)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
test('discard and shipment lifecycle keeps historical receipt quantities', () => {
|
||||||
|
const detail = { value: { items: [{ id: '1', skuCode: 'A' }], cartons: ['COUNTED', 'DISCARD_PENDING', 'DISCARDED', 'SHIPPED'].map((status, i) => ({ status, transferItemId: '1', transferPalletId: '9', quantity: i + 1 })) } }
|
||||||
|
const display = load(detail)
|
||||||
|
assert.equal(display.receivedItemCartons('1').length, 4)
|
||||||
|
assert.equal(display.receivedItemQuantity('1'), 10)
|
||||||
|
assert.equal(display.palletQuantity({ id: '9' }), 10)
|
||||||
|
})
|
||||||
|
|||||||
@@ -371,13 +371,13 @@ test('仓储转运基础货物不强制 SKU 和中文品名,只换箱唛不强
|
|||||||
assert.match(view, /v-model="row.expectedPackageCount"/)
|
assert.match(view, /v-model="row.expectedPackageCount"/)
|
||||||
assert.match(view, /Number.isSafeInteger\(row.quantity\)/)
|
assert.match(view, /Number.isSafeInteger\(row.quantity\)/)
|
||||||
assert.match(view, /Number.isSafeInteger\(row.expectedPackageCount\)/)
|
assert.match(view, /Number.isSafeInteger\(row.expectedPackageCount\)/)
|
||||||
assert.match(view, /carton.status === 'COUNTED'/)
|
assert.match(view, /\['COUNTED', 'DISCARD_PENDING', 'DISCARDED', 'SHIPPED'\]\.includes\(carton.status\)/)
|
||||||
assert.match(view, /实际签收箱数/)
|
assert.match(view, /实际签收箱数/)
|
||||||
})
|
})
|
||||||
|
|
||||||
test('转运客户详情保留预报并显示实际签收箱内明细和托盘汇总', () => {
|
test('转运客户详情保留预报并显示实际签收箱内明细和托盘汇总', () => {
|
||||||
for (const label of ['预报数量(件)', '预报 SKU 种数', '签收箱号明细', '查看箱号明细', 'SKU 汇总', '毛重(kg)', '体积(m³)']) assert.ok(view.includes(label), label)
|
for (const label of ['预报数量(件)', '预报 SKU 种数', '签收箱号明细', '查看箱号明细', 'SKU 汇总', '毛重(kg)', '体积(m³)']) assert.ok(view.includes(label), label)
|
||||||
assert.match(view, /carton.status === 'COUNTED' && pallet.id != null/)
|
assert.match(view, /countedTransferCartons\(\)\.filter\(\(carton\) => pallet.id != null/)
|
||||||
assert.match(view, /String\(carton.transferPalletId\) === String\(pallet.id\)/)
|
assert.match(view, /String\(carton.transferPalletId\) === String\(pallet.id\)/)
|
||||||
assert.match(view, /carton.transferItemId != null && String\(item.id\) === String\(carton.transferItemId\)/)
|
assert.match(view, /carton.transferItemId != null && String\(item.id\) === String\(carton.transferItemId\)/)
|
||||||
assert.match(view, /@click="showTransferCartons = true"/)
|
assert.match(view, /@click="showTransferCartons = true"/)
|
||||||
|
|||||||
@@ -0,0 +1,24 @@
|
|||||||
|
# Client 系统页模块指引
|
||||||
|
|
||||||
|
## 路径基准与读取顺序
|
||||||
|
|
||||||
|
- 本文件适用于 `src/modules/system/`,代码路径相对本目录;应用公共规则见 `../../../AGENTS.md`。
|
||||||
|
- 只有 `views/ForbiddenView.vue`(403 无权限页)与 `routes.ts`;不承载业务。
|
||||||
|
|
||||||
|
## 页面与入口
|
||||||
|
|
||||||
|
| 目标 | 页面/入口 | 说明 |
|
||||||
|
|---|---|---|
|
||||||
|
| 无权限提示页 | `views/ForbiddenView.vue` | 路由守卫或接口 403 后跳转 |
|
||||||
|
| 系统页路由 | `routes.ts` | 由 `../../router/index.ts` 装配 |
|
||||||
|
|
||||||
|
## 关键边界
|
||||||
|
|
||||||
|
- 403 页只做提示与返回入口,不暴露权限码、内部角色或接口细节。
|
||||||
|
- 不在此模块新增业务页面或全局状态。
|
||||||
|
- 权限判断仍在服务端与 `core/access`,页面不补前端鉴权分支。
|
||||||
|
|
||||||
|
## 验证
|
||||||
|
|
||||||
|
- 定向:`pnpm test src/modules/system/<目标测试>`。
|
||||||
|
- 本文件或索引变更后,从后端根运行 `./scripts/agents-index-contract.ps1`。
|
||||||
@@ -0,0 +1,30 @@
|
|||||||
|
# Client 企业设置模块指引
|
||||||
|
|
||||||
|
## 路径基准与读取顺序
|
||||||
|
|
||||||
|
- 本文件适用于 `src/modules/tenant-management/`,代码路径相对本目录;应用公共规则见 `../../../AGENTS.md`,层级与权限语义见 `../../../docs/平台客户层级与权限契约.md`。
|
||||||
|
- 本模块承载企业资料、成员、角色与权限(`company/profile`、`organization/*`);账号与登录标识归 `backend auth/`,接入侧实现归 `backend iam/`。
|
||||||
|
- 模块对外只暴露 `public.ts` 与 `contracts.ts`,其他模块不得穿透内部 `views/`、`store/`。
|
||||||
|
|
||||||
|
## 页面与入口
|
||||||
|
|
||||||
|
| 目标 | 页面/路由 | API 与后端 |
|
||||||
|
|---|---|---|
|
||||||
|
| 企业资料、资质上传与状态 | `views/CompanyProfileView.vue`、`utils/qualificationFile.ts`、`utils/qualificationStatus.ts`;`company/profile` | `api/merchantIam.ts`;`iam/`、`file/` |
|
||||||
|
| 企业成员管理 | `views/MembersView.vue`;`organization/members` | 页面经 `store/tenantAdministration.ts` → `api/merchantIam.ts`;`iam/`、`auth/` |
|
||||||
|
| 企业角色 | `views/RolesView.vue`;`organization/roles` | 页面经 `store/tenantAdministration.ts` → `api/merchantIam.ts`;`iam/` |
|
||||||
|
| 角色权限分配 | `views/PermissionsView.vue`;`organization/permissions` | 页面经 `store/tenantAdministration.ts` → `api/merchantIam.ts`;权限码常量见 `contracts.ts` |
|
||||||
|
| 跨页状态与稳定契约 | `store/tenantAdministration.ts`、`contracts.ts`、`public.ts` | 服务端 DTO |
|
||||||
|
|
||||||
|
## 关键边界
|
||||||
|
|
||||||
|
- 企业资料只修改 `contactPhone` 等企业联系信息,不提交或回填成员登录手机号;两者独立维护。
|
||||||
|
- 成员登录手机号可选;修改时由 IAM/Auth 同步并撤销该账号现有会话,前端不互相回填或联动提交。
|
||||||
|
- 审核必填资质仅营业执照与统一社会信用代码;法人身份证选填,可在已有营业执照后单独补传或替换。
|
||||||
|
- 企业成员、角色与权限只能管理当前企业范围;前端隐藏不是安全控制,服务端必须重复校验租户与权限。
|
||||||
|
- 认证与会话统一经 `../../api/http.ts`、`../../api/session.ts`;页面不读写 Token,不自行处理 401 刷新。
|
||||||
|
|
||||||
|
## 验证
|
||||||
|
|
||||||
|
- 定向:`pnpm test src/modules/tenant-management/<目标测试>`;成员或权限字段变化同时运行 `pnpm typecheck`。
|
||||||
|
- 本文件或索引变更后,从后端根运行 `./scripts/agents-index-contract.ps1`。
|
||||||
@@ -57,7 +57,6 @@ export const TENANT_PERMISSION_GROUPS: readonly TenantPermissionGroup[] = [
|
|||||||
{ code: 'order:first-leg:submit', label: '提交订单', description: '提交草稿进入平台审核' },
|
{ code: 'order:first-leg:submit', label: '提交订单', description: '提交草稿进入平台审核' },
|
||||||
{ code: 'order:first-leg:cancel', label: '取消订单', description: '在允许的状态下取消订单' },
|
{ code: 'order:first-leg:cancel', label: '取消订单', description: '在允许的状态下取消订单' },
|
||||||
{ code: 'merchant:warehouse:delivery:list', label: '查看派送单', description: '分页查询本企业海外仓派送单' },
|
{ code: 'merchant:warehouse:delivery:list', label: '查看派送单', description: '分页查询本企业海外仓派送单' },
|
||||||
{ code: 'merchant:warehouse:delivery:create', label: '创建派送单', description: '从排车单创建海外仓派送单' },
|
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -145,7 +144,6 @@ export const FRONTEND_TO_MERCHANT_PERMISSION_CODES: Readonly<Record<string, read
|
|||||||
'order:first-leg:submit': ['merchant:order:submit'],
|
'order:first-leg:submit': ['merchant:order:submit'],
|
||||||
'order:first-leg:cancel': ['merchant:order:cancel'],
|
'order:first-leg:cancel': ['merchant:order:cancel'],
|
||||||
'merchant:warehouse:delivery:list': ['merchant:warehouse:delivery:list'],
|
'merchant:warehouse:delivery:list': ['merchant:warehouse:delivery:list'],
|
||||||
'merchant:warehouse:delivery:create': ['merchant:warehouse:delivery:create'],
|
|
||||||
'merchant:warehouse:inbound:list': ['merchant:warehouse:inbound:list'],
|
'merchant:warehouse:inbound:list': ['merchant:warehouse:inbound:list'],
|
||||||
'merchant:overseas-warehouse:return-inventory:list': ['merchant:overseas-warehouse:return-inventory:list'],
|
'merchant:overseas-warehouse:return-inventory:list': ['merchant:overseas-warehouse:return-inventory:list'],
|
||||||
'merchant:overseas-warehouse:last-mile-order:list': ['merchant:overseas-warehouse:last-mile-order:list'],
|
'merchant:overseas-warehouse:last-mile-order:list': ['merchant:overseas-warehouse:last-mile-order:list'],
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ test('keeps standalone business pages at the client sidebar root', () => {
|
|||||||
{ title: '首页', children: undefined },
|
{ title: '首页', children: undefined },
|
||||||
{
|
{
|
||||||
title: '订单中心',
|
title: '订单中心',
|
||||||
children: ['头程订单', '入库订单', '派送订单', '海外采购', '美国本土卡', '美本土散板'],
|
children: ['头程订单', '海外采购', '美国本土卡', '美本土散板'],
|
||||||
},
|
},
|
||||||
{ title: '报关资料', children: undefined },
|
{ title: '报关资料', children: undefined },
|
||||||
{ title: '船期价格', children: undefined },
|
{ title: '船期价格', children: undefined },
|
||||||
@@ -88,8 +88,6 @@ test('flattens visible leaves with unique paths', () => {
|
|||||||
assert.deepEqual(paths, [
|
assert.deepEqual(paths, [
|
||||||
'/',
|
'/',
|
||||||
'/orders/first-leg',
|
'/orders/first-leg',
|
||||||
'/orders/inbound',
|
|
||||||
'/orders/delivery',
|
|
||||||
'/cross-border/procurement',
|
'/cross-border/procurement',
|
||||||
'/cross-border/domestic-trucking',
|
'/cross-border/domestic-trucking',
|
||||||
'/cross-border/pallet-shipping',
|
'/cross-border/pallet-shipping',
|
||||||
@@ -121,22 +119,10 @@ test('filters inaccessible leaves and empty navigation groups', () => {
|
|||||||
assert.equal(getFirstAccessiblePath([]), '/forbidden')
|
assert.equal(getFirstAccessiblePath([]), '/forbidden')
|
||||||
})
|
})
|
||||||
|
|
||||||
test('exposes active inbound and delivery queries only with their existing read permissions', () => {
|
test('omits inbound and delivery entries from the customer sidebar', () => {
|
||||||
const deliveryOnly = ['merchant:warehouse:delivery:list']
|
const permissions = ['merchant:warehouse:delivery:list', 'merchant:warehouse:inbound:list']
|
||||||
const inboundOnly = ['merchant:warehouse:inbound:list']
|
assert.deepEqual(getNavigationLeaves(filterNavigationByPermissions(clientNavigation, permissions)), [])
|
||||||
assert.deepEqual(getNavigationLeaves(filterNavigationByPermissions(clientNavigation, deliveryOnly))
|
assert.equal(getFirstAccessiblePath(permissions), '/forbidden')
|
||||||
.map(({ title, path }) => ({ title, path })), [{ title: '派送订单', path: '/orders/delivery' }])
|
|
||||||
assert.deepEqual(getNavigationLeaves(filterNavigationByPermissions(clientNavigation, inboundOnly))
|
|
||||||
.map(({ title, path }) => ({ title, path })), [{ title: '入库订单', path: '/orders/inbound' }])
|
|
||||||
assert.equal(getFirstAccessiblePath(deliveryOnly), '/orders/delivery')
|
|
||||||
assert.equal(getFirstAccessiblePath(inboundOnly), '/orders/inbound')
|
|
||||||
assert.deepEqual(getNavigationLeaves(filterNavigationByPermissions(clientNavigation,
|
|
||||||
['merchant:warehouse:delivery:create'])), [])
|
|
||||||
assert.deepEqual(getRouteBreadcrumbs('/orders/delivery/DL-1', '派送单详情'), [
|
|
||||||
{ title: '首页', path: '/' }, { title: '订单中心' },
|
|
||||||
{ title: '派送订单', path: '/orders/delivery' }, { title: '派送单详情' },
|
|
||||||
])
|
|
||||||
assert.deepEqual(getNavigationParentKeys(clientNavigation, '/orders/delivery'), ['order-center'])
|
|
||||||
})
|
})
|
||||||
|
|
||||||
test('excludes entries marked for manual hiding without affecting other visible items', () => {
|
test('excludes entries marked for manual hiding without affecting other visible items', () => {
|
||||||
@@ -383,6 +369,8 @@ test('exposes customer business lists and keeps utility routes outside navigatio
|
|||||||
]
|
]
|
||||||
|
|
||||||
const hiddenActivePaths = new Set([
|
const hiddenActivePaths = new Set([
|
||||||
|
'orders/inbound',
|
||||||
|
'orders/delivery',
|
||||||
'first-leg/quick-order',
|
'first-leg/quick-order',
|
||||||
'overseas-warehouse/return-inventory',
|
'overseas-warehouse/return-inventory',
|
||||||
'overseas-warehouse/return-cartons',
|
'overseas-warehouse/return-cartons',
|
||||||
|
|||||||
@@ -52,8 +52,6 @@ export const clientNavigation: ClientNavigationNode[] = [
|
|||||||
icon: ClipboardList,
|
icon: ClipboardList,
|
||||||
children: [
|
children: [
|
||||||
requireLeaf('first-leg-orders', '头程订单'),
|
requireLeaf('first-leg-orders', '头程订单'),
|
||||||
requireLeaf('orders-inbound', '入库订单'),
|
|
||||||
requireLeaf('orders-delivery', '派送订单'),
|
|
||||||
requireLeaf('cross-border-procurement'),
|
requireLeaf('cross-border-procurement'),
|
||||||
requireLeaf('cross-border-domestic-trucking'),
|
requireLeaf('cross-border-domestic-trucking'),
|
||||||
requireLeaf('cross-border-pallet-shipping'),
|
requireLeaf('cross-border-pallet-shipping'),
|
||||||
|
|||||||
Reference in New Issue
Block a user