From b370cfd7060e5de6f0fef8592b8e618b3be05bfa Mon Sep 17 00:00:00 2001 From: yin <3313488199@qq.com> Date: Tue, 22 Sep 2026 18:10:52 +0800 Subject: [PATCH] 1 --- .gitignore | 3 + docs/项目瘦身-未引用页面清单.md | 144 ++ scripts/find-unused-modules.mjs | 318 ++++ src/api/{inbox => inbox-2}/autoReply.ts | 101 +- .../order.pendingorder/orderpendingOrder.ts | 41 + src/api/order.wave/orderwave.ts | 93 - src/api/order/order.ts | 98 ++ src/api/user/user.ts | 15 +- src/api/wechat/wechat.ts | 244 ++- src/utils/barcode.ts | 31 + .../components/ColumnCellRenderer.vue | 65 - .../components/OperationCellRenderer.vue | 175 -- .../newpackingflow/components/TabArea.vue | 132 -- .../newpackingflow/components/VideoButton.vue | 35 - .../components/VideoListDialog.vue | 134 -- .../components/VideoPlayerDialog.vue | 173 -- .../config/components/DetailPanel.vue | 160 -- .../config/components/LogPanel.vue | 227 --- .../config/packingflow-config.ts | 776 -------- src/views/data/newpackingflow/index.vue | 879 --------- .../pages/ExampleFormDialog.vue | 107 -- src/views/inbox/autoReply/autoReply-config.ts | 2 +- .../autoReply/components/FunctionPanel.vue | 2 +- .../inbox/autoReply/components/GroupPanel.vue | 2 +- .../autoReply/components/KeywordPanel.vue | 2 +- .../autoReply/components/NumberRulePanel.vue | 2 +- .../inbox/autoReply/components/ReplyPanel.vue | 2 +- .../components/SubTypeFormDialog.vue | 2 +- .../autoReply/components/TypeFormDialog.vue | 2 +- src/views/inbox/autoReply/index.vue | 2 +- .../components/ColumnCellRenderer.vue | 65 - .../components/OperationCellRenderer.vue | 175 -- .../packageMaterial2/components/TabArea.vue | 132 -- .../config/components/DetailPanel.vue | 159 -- .../config/components/LogPanel.vue | 227 --- .../config/template-config.ts | 727 -------- src/views/material/packageMaterial2/index.vue | 854 --------- .../pages/ExampleFormDialog.vue | 107 -- .../order/waveOrder/config/wave-config.ts | 5 +- src/views/order/waveOrder/index.vue | 2 +- .../components/ColumnCellRenderer.vue | 55 - .../order/waveOrder2/components/TabArea.vue | 141 -- .../components/public/DetailPanel.vue | 168 -- .../waveOrder2/components/public/LogPanel.vue | 204 --- .../public/OperationCellRenderer.vue | 171 -- .../waveOrder2/config/waveorder-config.ts | 1563 ----------------- src/views/order/waveOrder2/index.vue | 971 ---------- .../waveOrder2/pages/BatchOperationForm.vue | 246 --- .../waveOrder2/pages/FetchGroupOrderForm.vue | 556 ------ src/views/storage/stockout/stockout-config.ts | 22 +- .../basicManagement/ApiOpenInterface.vue | 756 -------- .../system/setting/basicManagement/index.vue | 1152 ------------ .../newview/pages/MiniProgramConfigForm.vue | 838 ++++++++- .../components/ColumnCellRenderer.vue | 65 - .../components/OperationCellRenderer.vue | 175 -- .../setting/encoding2/components/TabArea.vue | 132 -- .../config/components/DetailPanel.vue | 159 -- .../encoding2/config/components/LogPanel.vue | 227 --- .../encoding2/config/template-config.ts | 727 -------- src/views/system/setting/encoding2/index.vue | 1014 ----------- .../encoding2/pages/ExampleFormDialog.vue | 107 -- src/views/system/setting/workbench/index.vue | 966 ---------- .../setting/workbench/workbench-config.ts | 154 -- .../video/camera/component/CameraPlayer.vue | 192 -- .../camera/component/CameraPreviewDialog.vue | 314 ---- src/views/video/camera/index.vue | 993 ----------- src/views/video/cameraServer/index.vue | 626 ------- 67 files changed, 1773 insertions(+), 17343 deletions(-) create mode 100644 docs/项目瘦身-未引用页面清单.md create mode 100644 scripts/find-unused-modules.mjs rename src/api/{inbox => inbox-2}/autoReply.ts (79%) delete mode 100644 src/views/data/newpackingflow/components/ColumnCellRenderer.vue delete mode 100644 src/views/data/newpackingflow/components/OperationCellRenderer.vue delete mode 100644 src/views/data/newpackingflow/components/TabArea.vue delete mode 100644 src/views/data/newpackingflow/components/VideoButton.vue delete mode 100644 src/views/data/newpackingflow/components/VideoListDialog.vue delete mode 100644 src/views/data/newpackingflow/components/VideoPlayerDialog.vue delete mode 100644 src/views/data/newpackingflow/config/components/DetailPanel.vue delete mode 100644 src/views/data/newpackingflow/config/components/LogPanel.vue delete mode 100644 src/views/data/newpackingflow/config/packingflow-config.ts delete mode 100644 src/views/data/newpackingflow/index.vue delete mode 100644 src/views/data/newpackingflow/pages/ExampleFormDialog.vue delete mode 100644 src/views/material/packageMaterial2/components/ColumnCellRenderer.vue delete mode 100644 src/views/material/packageMaterial2/components/OperationCellRenderer.vue delete mode 100644 src/views/material/packageMaterial2/components/TabArea.vue delete mode 100644 src/views/material/packageMaterial2/config/components/DetailPanel.vue delete mode 100644 src/views/material/packageMaterial2/config/components/LogPanel.vue delete mode 100644 src/views/material/packageMaterial2/config/template-config.ts delete mode 100644 src/views/material/packageMaterial2/index.vue delete mode 100644 src/views/material/packageMaterial2/pages/ExampleFormDialog.vue delete mode 100644 src/views/order/waveOrder2/components/ColumnCellRenderer.vue delete mode 100644 src/views/order/waveOrder2/components/TabArea.vue delete mode 100644 src/views/order/waveOrder2/components/public/DetailPanel.vue delete mode 100644 src/views/order/waveOrder2/components/public/LogPanel.vue delete mode 100644 src/views/order/waveOrder2/components/public/OperationCellRenderer.vue delete mode 100644 src/views/order/waveOrder2/config/waveorder-config.ts delete mode 100644 src/views/order/waveOrder2/index.vue delete mode 100644 src/views/order/waveOrder2/pages/BatchOperationForm.vue delete mode 100644 src/views/order/waveOrder2/pages/FetchGroupOrderForm.vue delete mode 100644 src/views/system/setting/basicManagement/ApiOpenInterface.vue delete mode 100644 src/views/system/setting/basicManagement/index.vue delete mode 100644 src/views/system/setting/encoding2/components/ColumnCellRenderer.vue delete mode 100644 src/views/system/setting/encoding2/components/OperationCellRenderer.vue delete mode 100644 src/views/system/setting/encoding2/components/TabArea.vue delete mode 100644 src/views/system/setting/encoding2/config/components/DetailPanel.vue delete mode 100644 src/views/system/setting/encoding2/config/components/LogPanel.vue delete mode 100644 src/views/system/setting/encoding2/config/template-config.ts delete mode 100644 src/views/system/setting/encoding2/index.vue delete mode 100644 src/views/system/setting/encoding2/pages/ExampleFormDialog.vue delete mode 100644 src/views/system/setting/workbench/index.vue delete mode 100644 src/views/system/setting/workbench/workbench-config.ts delete mode 100644 src/views/video/camera/component/CameraPlayer.vue delete mode 100644 src/views/video/camera/component/CameraPreviewDialog.vue delete mode 100644 src/views/video/camera/index.vue delete mode 100644 src/views/video/cameraServer/index.vue diff --git a/.gitignore b/.gitignore index cd5c4641..75613227 100644 --- a/.gitignore +++ b/.gitignore @@ -47,3 +47,6 @@ __screenshots__/ # 本地离线二维码工具(独立小工具,不入库) /batchQrcode/ + +# 死代码扫描产物(本地产物,不入库) +/unused-report.json diff --git a/docs/项目瘦身-未引用页面清单.md b/docs/项目瘦身-未引用页面清单.md new file mode 100644 index 00000000..cfe7609e --- /dev/null +++ b/docs/项目瘦身-未引用页面清单.md @@ -0,0 +1,144 @@ +# 项目瘦身 · 未引用页面清单 + +> 扫描时间:2026-09-22 · 扫描脚本:`scripts/find-unused-modules.mjs` · 原始数据:`unused-report.json` + +## 一、判定方法(为什么不能只看 map.ts) + +`src/router/index.ts` 里有一段兜底逻辑: + +```ts +const viewModules = import.meta.glob('@/views/**/*.vue') +``` + +这意味着 **`src/views` 下的每一个 `.vue` 都会被 Vite 收集进构建图**(各自一个懒加载 chunk), +运行时后端菜单只要 `component` 字段能拼出路径,就能命中最上面的 glob。 + +所以"未被引用"必须区分两种情况: + +| 口径 | 含义 | 能否直接删 | +|---|---|---| +| **静态不可达** | 从 `src/main.ts` 出发,经 `import / import() / require()` 到不了 | 需先确认后端菜单没有指向它 | +| **完全死代码** | 既静态不可达,也不被任何 glob 模式匹配 | 可以直接删 | + +本次扫描结果(`src` 下共 582 个模块): + +- 静态可达:**480** +- 仅被 glob 兜底匹配:**80**(全部在 `src/views` 下) +- 完全死代码:**22** +- 待处理合计:**102 个文件**(约 974 KB 源码) + +## 二、第一批:整目录废弃(同功能新版已在 map.ts 中生效) + +这批是"做了新版没删旧版"的复制目录,**判断依据充分,可优先处理**。 +证据:废弃目录的文件修改时间统一停在 `2026-08-11`(模板生成日),而现行目录仍在持续更新。 + +| 废弃目录/文件 | 文件数 | 现行替代(map.ts 指向) | 备注 | +|---|---|---|---| +| `src/views/order/waveOrder2/` | 9 | `order/waveOrder/`(`order/waveOrder`、`wave/index`) | `waveOrder` 最近更新 09-21,`waveOrder2` 停在 08-11 | +| `src/views/data/newpackingflow/` | 11 | `data/packingflow/`(`data/packingflow`) | `packingflow` 更新 09-16 | +| `src/views/material/packageMaterial2/` | 8 | `material/packageMaterial/`(`material/packageMaterial/index`) | | +| `src/views/system/setting/encoding2/` | 8 | `system/setting/encoding/`(`system/setting/encoding/index`) | | +| `src/views/mode/` | 8 | — | 页面模板脚手架(`【页面模板 v2】`) | +| `src/views/video/camera/` | 3 | `video/newcamara/`(`video/camera/index` 已重指向) | | +| `src/views/video/cameraServer/` | 1 | `video/newcamaraserver/`(`video/cameraServer/index` 已重指向) | | +| `src/views/store/shipperSigning/` | 1 | `Externalwarehouse/shipperSigning/` | 同名页面两份 | +| `src/views/system/setting/workbench/` | 2 | `system/setting/workbench2/` | map.ts 的 key 仍是 `system/setting/workbench/index` | +| `src/views/system/setting/basicManagement/`(旧 `index.vue`、`ApiOpenInterface.vue`) | 2 | `system/setting/basicManagement/newview/` | 旧路径已在 map.ts 里重指向 newview | +| `src/views/warehouse/` 旧三件套 `zone.vue`、`SpaceList.vue`、`SpaceForm.vue` | 3 | `ZoneManagement.vue` / `RackSpaceManagement.vue` | `warehouse/index.vue` 已不再 import 这三个 | + +## 三、第二批:页面内孤立组件(页面本身在用,组件已废弃) + +| 文件 | 体积 | 说明 | +|---|---|---| +| `order/orderManagement/component/detail.vue` | 0.3 KB | 只 import 了 `OrderDetailPanel.vue` | +| `order/orderManagement/component/orderdetail.vue` | 2.5 KB | | +| `order/orderManagement/component/OrderDetailPanel.vue` | 2.1 KB | 仅被上面的 `detail.vue` 引用(链式死) | +| `order/orderManagement/component/ManualOutboundPanel.vue` | 6.0 KB | | +| `order/orderManagement/component/OrderReviewDialog.vue` | 2.7 KB | | +| `order/waveOrder/component/WaveBatchPrintPreviewDialog.vue` | 10.8 KB | | +| `express/returnUnpack/components/ExportDialog.vue` | 9.7 KB | 已被通用导出弹窗替代 | +| `express/returnUnpack/components/VideoListDialog.vue` | 4.3 KB | 该目录下 `VideoPlayerDialog.vue` 仍在使用 | +| `express/waybill/components/TabArea.vue` | 2.6 KB | | +| `express/waybill/pages/ExampleFormDialog.vue` | 2.7 KB | 模板残留 | +| `store/stores/component/ExportDialog.vue` | 7.6 KB | | +| `storage/entry/component/QuickInboundForm.vue` | 9.2 KB | `storage/entry/index.vue` 未引用 | +| `storage/inventory/component/InventoryStockPickerDialog.vue` | 14.7 KB | | +| `afterSale/detail/HandleDialog.vue` | 4.6 KB | 处理逻辑已内联在 `detail/index.vue` | +| `system/setting/printStation/components/Printer.vue` | 3.2 KB | 该页只 import `info.vue` / `add.vue` | +| `system/setting/printStation/components/expressCompany.vue` | 2.4 KB | 同上 | +| `system/setting/printStation/components/printComputer.vue` | 2.7 KB | 同上 | +| `system/setting/printcomputer/config/components/DetailPanel.vue` | 4.6 KB | | +| `system/setting/printcomputer/config/components/LogPanel.vue` | 5.9 KB | | +| `system/setting/printcomputer/pages/ExampleFormDialog.vue` | 2.7 KB | 模板残留 | +| `system/setting/workbench2/pages/ExampleFormDialog.vue` | 2.7 KB | 模板残留 | +| `system/setting/basicManagement/newview/pages/ExampleFormDialog.vue` | 2.7 KB | 模板残留 | +| `system/setting/basicManagement/newview/pages/ExportReportDialog.vue` | 6.7 KB | | +| `video/newcamaraserver/components/OperationCellRenderer.vue` | 5.1 KB | 该页未 import(`TabArea` / `ColumnCellRenderer` 在用) | +| `video/newcamara/pages/ExampleFormDialog.vue` | 2.7 KB | 模板残留 | +| `afterSale/typelist/pages/ExampleFormDialog.vue` | 2.7 KB | 模板残留 | +| `storage/generalreport/pages/ExampleFormDialog.vue` | 2.7 KB | 模板残留 | +| `views/account/index.vue` | 0.1 KB | 空壳(注意:map.ts 的 `account/index` 指向 `system/setting/account/index.vue`) | +| `views/permission/index.vue` | 0.1 KB | 空壳 | + +## 四、第三批:完全死代码(非页面,共 22 个 / 324 KB) + +### Vue2 迁移残留(8 个 / 43.4 KB) +- `src/utils/index.js`(2.7 KB)— vue-element-admin 工具集 +- `src/utils/warehouseData.js`(20.4 KB) +- `src/utils/zhijian.js`(6.3 KB)+ `src/utils/zhijian.ts`(6.9 KB)— 双份同名,均无引用 +- `src/icons/index.js`(0.3 KB)— SVG 图标已改走 `vite-plugin-svg-icons` +- `src/layout/AppMain.vue`(0.1 KB)— 实际使用的是 `src/layout/component/AppMain.vue` +- `src/stores/counter.ts`(0.3 KB)— Pinia 示例 +- `src/stores/modules/localCameraServer.ts`(4.9 KB) + +### 三维可视化遗留(5 个 / 约 114 KB) +- `src/utils/threeScene.js`(36.2 KB) +- `src/utils/threeUtils.js`(10.8 KB) +- `src/utils/overlookControls.js`(11.3 KB) +- `src/utils/CanvasRenderer.js`(26.6 KB)+ `src/utils/CanvasRenderer.ts`(28.8 KB)— 双份 + +### 模板配置残留 +- `src/views/mode/config/template-config.ts`(24.7 KB) +- `src/views/material/packageMaterial2/config/template-config.ts`(24.6 KB) +- `src/views/system/setting/encoding2/config/template-config.ts`(24.6 KB) +- `src/views/data/newpackingflow/config/packingflow-config.ts`(26.0 KB) +- `src/views/order/waveOrder2/config/waveorder-config.ts`(54.7 KB) +- `src/views/system/setting/workbench/workbench-config.ts`(4.6 KB) + +### API 模块(3 个 / 9.3 KB,建议单独确认后再删) +- `src/api/order.packing/packing.ts`(7.6 KB) +- `src/api/config/config.ts`(1.3 KB) +- `src/api/printer.station/printerstation.ts`(0.4 KB) + +> 对照:`src/api/waybill.warehouse/index.ts` 一开始被误判为死代码,实际 `express/waybill` 在用,**不要删**。 +> (原因是该目录名自带点号,脚本早期用 `path.extname` 判断扩展名导致解析失败,已修复。) + +## 五、删除前必须做的核对 + +因为 `import.meta.glob` 兜底的存在,**静态不可达 ≠ 可以删**。删之前请确认后端菜单 +`component` 字段没有指向待删路径: + +1. 导出菜单表里所有 `component` 字段值(形如 `order/waveOrder`、`system/setting/role/index`) +2. 与上表路径求交集,**有交集的一律保留** +3. 更省事的做法:直接在浏览器里按后台配的菜单逐个点一遍,确认页面不是待删文件 +4. 特别注意 map.ts 里那些**值相同、key 不同的兼容项**,例如: + - `system/setting/basicManagement` / `system/setting/basicManagement/index` / `basicManagement` → 全部指向 `newview` + - `video/camera/index` → `newcamara`;`video/cameraServer/index` → `newcamaraserver` + - `system/setting/workbench/index` → `workbench2` + - `stock/combo_stock` 相关 key 已注释掉(`combo_stock` 现为 `stockManagement` 内的标签页) + +## 六、如何复跑 + +```bash +node scripts/find-unused-modules.mjs # 完整报告 +node scripts/find-unused-modules.mjs --views-only # 只看页面 +``` + +脚本会打印分组清单 + 目录级汇总,并把机器可读结果写到 `unused-report.json`。 + +判定口径: +- 静态可达:从 `src/main.ts` 经 `import` / `import()` / `require()` / SCSS `@use` / `@import` 可达 +- glob 兜底:被 `import.meta.glob(...)` 模式匹配 +- 死代码:以上都不属于 + +> 已知盲区:仅覆盖 `src` 目录;不解析 `component` 字段的字符串拼接路径(本项目已确认无此类写法)。 diff --git a/scripts/find-unused-modules.mjs b/scripts/find-unused-modules.mjs new file mode 100644 index 00000000..b81b25a2 --- /dev/null +++ b/scripts/find-unused-modules.mjs @@ -0,0 +1,318 @@ +#!/usr/bin/env node +/** + * 死代码扫描:从入口出发对 src 做模块依赖图可达性分析。 + * + * 判定口径 + * - 静态可达:从入口(src/main.ts)经 import / export-from / import() / require() 能到达 + * - glob 兜底:被 import.meta.glob(...) 模式匹配到(构建期收集,运行时按后端菜单动态取用) + * - 死代码 :以上两类都不属于 + * + * 用法:node scripts/find-unused-modules.mjs [项目根目录] [--views-only] + */ +import fs from 'node:fs' +import path from 'node:path' + +const args = process.argv.slice(2) +const viewsOnly = args.includes('--views-only') +const rootArg = args.find((a) => !a.startsWith('--')) +const ROOT = rootArg ? path.resolve(rootArg) : process.cwd() +const SRC = path.join(ROOT, 'src') +const ENTRIES = [path.join(SRC, 'main.ts')] + +const WALK_EXT = new Set(['.ts', '.tsx', '.js', '.jsx', '.mjs', '.cjs', '.vue', '.scss', '.css']) +const RESOLVE_EXT = ['.ts', '.tsx', '.js', '.jsx', '.mjs', '.cjs', '.vue', '.json', '.scss', '.css', '.svg'] +const INDEX_EXT = ['.ts', '.js', '.vue'] +const SKIP_DIRS = new Set(['node_modules', '.git', 'dist', 'dist-ssr', '.vite']) + +/* ---------- 文件遍历 ---------- */ +function walk(dir, out = []) { + let entries + try { + entries = fs.readdirSync(dir, { withFileTypes: true }) + } catch { + return out + } + for (const e of entries) { + const full = path.join(dir, e.name) + if (e.isDirectory()) { + if (SKIP_DIRS.has(e.name)) continue + walk(full, out) + } else { + const ext = path.extname(e.name) + if (WALK_EXT.has(ext) || e.name.endsWith('.d.ts')) out.push(full) + } + } + return out +} + +/* ---------- 注释剥离(保留字符串字面量,避免 https:// 被误删) ---------- */ +function stripComments(code) { + let out = '' + let i = 0 + const n = code.length + while (i < n) { + const c = code[i] + const next = code[i + 1] + if (c === '/' && next === '/') { + while (i < n && code[i] !== '\n') i++ + continue + } + if (c === '/' && next === '*') { + i += 2 + while (i < n && !(code[i] === '*' && code[i + 1] === '/')) i++ + i += 2 + continue + } + if (c === '"' || c === "'" || c === '`') { + const q = c + out += c + i++ + while (i < n) { + if (code[i] === '\\') { + out += code[i] + code[i + 1] + i += 2 + continue + } + out += code[i] + if (code[i] === q) { + i++ + break + } + i++ + } + continue + } + out += c + i++ + } + return out +} + +const SPEC_RES = [ + /import\s*\(\s*['"]([^'"]+)['"]\s*\)/g, // 动态 import + /\bfrom\s*['"]([^'"]+)['"]/g, // import ... from / export ... from + /\bimport\s+['"]([^'"]+)['"]/g, // 副作用 import + /\brequire\s*\(\s*['"]([^'"]+)['"]\s*\)/g, + /new\s+URL\s*\(\s*['"]([^'"]+)['"]/g, + /@use\s+['"]([^'"]+)['"]/g, // SCSS + /@forward\s+['"]([^'"]+)['"]/g, +] +const GLOB_RE = /import\.meta\.glob(?:Eager)?\s*\(\s*['"]([^'"]+)['"]/g + +function scanFile(file) { + const raw = fs.readFileSync(file, 'utf8') + const code = stripComments(raw) + const specs = new Set() + for (const re of SPEC_RES) { + re.lastIndex = 0 + let m + while ((m = re.exec(code))) specs.add(m[1]) + } + const globs = [] + GLOB_RE.lastIndex = 0 + let g + while ((g = GLOB_RE.exec(code))) globs.push(g[1]) + return { specs: [...specs], globs } +} + +/* ---------- 说明符解析 ---------- */ +function resolveSpec(spec, fromFile) { + if (!spec || typeof spec !== 'string') return null + let base = null + const s = spec.split('?')[0].split('#')[0] + if (s.startsWith('@/')) base = path.join(SRC, s.slice(2)) + else if (s.startsWith('~@/')) base = path.join(SRC, s.slice(3)) + else if (s.startsWith('./') || s.startsWith('../')) base = path.resolve(path.dirname(fromFile), s) + else return null + + const candidates = [base] + for (const ext of RESOLVE_EXT) candidates.push(base + ext) + // 注意:目录名可能自带点号(api/order.packing、api/waybill.warehouse), + // 不能用 path.extname 判断,必须比对已知扩展名白名单 + const hasKnownExt = RESOLVE_EXT.includes(path.extname(base).toLowerCase()) + if (!hasKnownExt) for (const ext of INDEX_EXT) candidates.push(path.join(base, 'index' + ext)) + for (const c of candidates) { + try { + if (fs.statSync(c).isFile()) return path.normalize(c) + } catch { + /* ignore */ + } + } + return null +} + +/* ---------- glob 模式 → 正则 ---------- */ +function globToRegExp(pattern) { + let p = pattern + // 统一成相对项目根的路径(@/ 与 / 都指向 src) + if (p.startsWith('@/')) p = 'src/' + p.slice(2) + else if (p.startsWith('~@/')) p = 'src/' + p.slice(3) + p = p.replace(/^\//, '') + let re = '' + for (let i = 0; i < p.length; i++) { + const c = p[i] + if (c === '*' && p[i + 1] === '*') { + re += '[\\s\\S]*' + i++ + if (p[i + 1] === '/') i++ + continue + } + if (c === '*') { + re += '[^/]*' + continue + } + re += c.replace(/[.+^${}()|[\]\\]/g, '\\$&') + } + return new RegExp('^' + re + '$') +} + +/* ---------- 主流程 ---------- */ +const allFiles = walk(SRC) +const rel = (f) => path.relative(ROOT, f).replace(/\\/g, '/') + +const reachable = new Set() +const globOnly = new Set() +const queue = [] +const unresolvedSpecs = [] + +for (const f of ENTRIES) { + if (!fs.existsSync(f)) { + console.error(`入口不存在: ${f}`) + process.exit(1) + } + reachable.add(path.normalize(f)) + queue.push(path.normalize(f)) +} + +const globMatchers = [] +const fileCache = new Map() + +while (queue.length) { + const file = queue.pop() + let scanned = fileCache.get(file) + if (!scanned) { + scanned = scanFile(file) + fileCache.set(file, scanned) + } + for (const spec of scanned.specs) { + const resolved = resolveSpec(spec, file) + if (!resolved) { + // 只抱怨“本应能解析”的路径(@/ 与相对路径) + if (spec.startsWith('@/') || spec.startsWith('~/') || spec.startsWith('~@/')) { + unresolvedSpecs.push(`${rel(file)} -> ${spec}`) + } + continue + } + if (!reachable.has(resolved)) { + reachable.add(resolved) + if (WALK_EXT.has(path.extname(resolved).toLowerCase())) queue.push(resolved) + } + } + for (const pattern of scanned.globs) { + globMatchers.push({ from: file, pattern, re: globToRegExp(pattern) }) + } +} + +for (const f of allFiles) { + if (reachable.has(path.normalize(f))) continue + if (f.endsWith('.d.ts')) continue + const r = rel(f) + if (globMatchers.some((g) => g.re.test(r))) globOnly.add(path.normalize(f)) +} + +/* ---------- 输出 ---------- */ +const sizeOf = (f) => { + try { + return fs.statSync(f).size + } catch { + return 0 + } +} +const kb = (n) => (n / 1024).toFixed(1) + ' KB' +const norm = (f) => path.normalize(f) + +const dead = allFiles.filter((f) => !reachable.has(norm(f)) && !globOnly.has(norm(f)) && !f.endsWith('.d.ts')) +const deadViews = dead.filter((f) => rel(f).startsWith('src/views/') && f.endsWith('.vue')) +const deadOther = dead.filter((f) => !(rel(f).startsWith('src/views/') && f.endsWith('.vue'))) + +function groupByDir(files, depth = 3) { + const map = new Map() + for (const f of files) { + const r = rel(f) + const seg = r.split('/').slice(0, depth).join('/') + if (!map.has(seg)) map.set(seg, []) + map.get(seg).push(f) + } + return [...map.entries()].sort((a, b) => b[1].length - a[1].length) +} + +console.log('='.repeat(72)) +console.log(`扫描根目录:${ROOT}`) +console.log(`src 下模块总数:${allFiles.length} 静态可达:${reachable.size} 仅 glob 兜底:${globOnly.size} 死代码:${dead.length}`) +console.log('='.repeat(72)) + +if (deadViews.length) { + console.log(`\n## 未被引用的页面 (.vue):${deadViews.length} 个,合计 ${kb(deadViews.reduce((s, f) => s + sizeOf(f), 0))}\n`) + for (const [dir, files] of groupByDir(deadViews)) { + console.log(`● ${dir} (${files.length} 个, ${kb(files.reduce((s, f) => s + sizeOf(f), 0))})`) + for (const f of files.sort()) console.log(` ${rel(f).replace('src/views/', '')} ${kb(sizeOf(f))}`) + } +} + +if (globOnly.size) { + const gv = [...globOnly].filter((f) => f.endsWith('.vue')) + console.log(`\n## 仅被 import.meta.glob 兜底匹配的页面:${gv.length} 个(无法静态判定,需核对后端菜单 component 字段)\n`) + for (const [dir, files] of groupByDir(gv)) console.log(` ${dir} (${files.length} 个)`) +} + +if (!viewsOnly) { + console.log(`\n## 未被引用的非页面文件:${deadOther.length} 个,合计 ${kb(deadOther.reduce((s, f) => s + sizeOf(f), 0))}\n`) + for (const [dir, files] of groupByDir(deadOther)) { + console.log(`● ${dir} (${files.length} 个, ${kb(files.reduce((s, f) => s + sizeOf(f), 0))})`) + for (const f of files.sort()) console.log(` ${rel(f).replace('src/', '')} ${kb(sizeOf(f))}`) + } +} + +if (unresolvedSpecs.length) { + const uniq = [...new Set(unresolvedSpecs)] + console.log(`\n## 无法解析的 @/ 引用:${uniq.length} 条(疑似路径写错或文件已删)\n`) + for (const u of uniq.slice(0, 100)) console.log(' ' + u) +} + +/* 机器可读输出 */ +const aggregate = (files) => { + const m = {} + for (const f of files) { + const seg = rel(f).split('/').slice(0, 4).join('/') + if (!m[seg]) m[seg] = { count: 0, bytes: 0 } + m[seg].count += 1 + m[seg].bytes += sizeOf(f) + } + return m +} + +console.log('\n## 目录级汇总(按死代码文件数降序,便于分批删除)\n') +for (const [dir, v] of Object.entries(aggregate([...dead, ...globOnly])).sort((a, b) => b[1].count - a[1].count)) { + console.log(` ${dir} ${v.count} 个 / ${kb(v.bytes)}`) +} + +const outFile = path.join(ROOT, 'unused-report.json') +fs.writeFileSync( + outFile, + JSON.stringify( + { + scannedAt: new Date().toISOString(), + totals: { all: allFiles.length, reachable: reachable.size, globOnly: globOnly.size, dead: dead.length }, + deadViews: deadViews.map(rel), + deadOthers: deadOther.map(rel), + globOnlyViews: [...globOnly].filter((f) => f.endsWith('.vue')).map(rel), + globOnlyOthers: [...globOnly].filter((f) => !f.endsWith('.vue')).map(rel), + aggregate: aggregate([...dead, ...globOnly]), + unresolvedSpecs: [...new Set(unresolvedSpecs)], + }, + null, + 2 + ), + 'utf8' +) +console.log(`\n完整结果已写入 ${rel(outFile)}`) diff --git a/src/api/inbox/autoReply.ts b/src/api/inbox-2/autoReply.ts similarity index 79% rename from src/api/inbox/autoReply.ts rename to src/api/inbox-2/autoReply.ts index 351344d5..125fbb5a 100644 --- a/src/api/inbox/autoReply.ts +++ b/src/api/inbox-2/autoReply.ts @@ -29,7 +29,48 @@ export interface InboxV2Pagination { total: number } -function call(method: string, data?: Record): Promise> { +/** + * method → 响应业务数据类型映射。 + * + * 调用处直接写 method 字面量(如 `call('inbox.v2.type.list', data)`), + * 泛型由该字面量从本映射自动推断,因此调用处**不再写显式泛型实参**; + * 这样既保留类型安全,也让接口清单脚本能静态识别 method 与文件的归属关系。 + */ +interface InboxV2MethodMap { + 'inbox.v2.type.list': InboxV2TypeListData + 'inbox.v2.type.create': { id: number; message: string } + 'inbox.v2.type.update': { message: string } + 'inbox.v2.type.delete': { message: string } + 'inbox.v2.subType.list': InboxV2SubTypeListData + 'inbox.v2.subType.create': { id: number; message: string } + 'inbox.v2.subType.update': { message: string } + 'inbox.v2.subType.delete': { message: string } + 'inbox.v2.keyword.list': InboxV2KeywordListData + 'inbox.v2.keyword.create': { id: number; message: string } + 'inbox.v2.keyword.update': { message: string } + 'inbox.v2.keyword.delete': { message: string } + 'inbox.v2.numberRule.list': { list: InboxV2NumberRuleItem[] } + 'inbox.v2.function.list': { list: InboxV2FunctionItem[] } + 'inbox.v2.function.update': { message: string } + 'inbox.v2.reply.merged': InboxV2ReplyMergedData + 'inbox.v2.reply.list': InboxV2ReplyListData + 'inbox.v2.reply.save': InboxV2ReplySaveResult + 'inbox.v2.reply.restore': { message: string } + 'inbox.v2.reply.create': { id: number; message: string } + 'inbox.v2.reply.update': { message: string } + 'inbox.v2.reply.delete': { message: string } + 'inbox.v2.relation.function.list': { list: InboxV2SubTypeFunctionItem[] } + 'inbox.v2.relation.function.set': { message: string } + 'inbox.v2.relation.rule.list': { list: InboxV2SubTypeRuleItem[] } + 'inbox.v2.relation.rule.set': { message: string } + 'inbox.v2.relation.group.list': { list: InboxV2SubTypeGroupItem[] } + 'inbox.v2.relation.group.set': { message: string } +} + +function call( + method: M, + data?: Record +): Promise> { return request({ url: '/system', method: 'post', @@ -41,7 +82,7 @@ function call(method: string, data?: Record): Prom data: data ?? {}, // 自定义标记:request 内部据此走 /system 网关(非 axios 标准字段) isSystemApi: true, - } as AxiosRequestConfig) as unknown as Promise> + } as AxiosRequestConfig) as unknown as Promise> } /** @@ -84,7 +125,7 @@ export interface InboxV2TypeListData { /** 类型列表(系统级 + 本仓库自定义,分页) */ export function inboxV2TypeList(data: InboxV2TypeListParams = {}) { - return call('inbox.v2.type.list', data as Record) + return call('inbox.v2.type.list', data as Record) } export interface InboxV2TypeCreateParams { @@ -97,7 +138,7 @@ export interface InboxV2TypeCreateParams { /** 创建仓库自定义类型 */ export function inboxV2TypeCreate(data: InboxV2TypeCreateParams) { - return call<{ id: number; message: string }>('inbox.v2.type.create', data as unknown as Record) + return call('inbox.v2.type.create', data as unknown as Record) } export interface InboxV2TypeUpdateParams { @@ -109,12 +150,12 @@ export interface InboxV2TypeUpdateParams { /** 更新仓库自定义类型(系统预设拒绝修改) */ export function inboxV2TypeUpdate(data: InboxV2TypeUpdateParams) { - return call<{ message: string }>('inbox.v2.type.update', data as unknown as Record) + return call('inbox.v2.type.update', data as unknown as Record) } /** 删除仓库自定义类型(有子类型引用时拒绝) */ export function inboxV2TypeDelete(id: number) { - return call<{ message: string }>('inbox.v2.type.delete', { id }) + return call('inbox.v2.type.delete', { id }) } // ─────────────────────────── 子类型 ─────────────────────────── @@ -149,7 +190,7 @@ export interface InboxV2SubTypeListData { /** 子类型列表(系统级 + 本仓库自定义,分页) */ export function inboxV2SubTypeList(data: InboxV2SubTypeListParams = {}) { - return call('inbox.v2.subType.list', data as Record) + return call('inbox.v2.subType.list', data as Record) } export interface InboxV2SubTypeCreateParams { @@ -164,7 +205,7 @@ export interface InboxV2SubTypeCreateParams { /** 创建仓库自定义子类型 */ export function inboxV2SubTypeCreate(data: InboxV2SubTypeCreateParams) { - return call<{ id: number; message: string }>('inbox.v2.subType.create', data as unknown as Record) + return call('inbox.v2.subType.create', data as unknown as Record) } export interface InboxV2SubTypeUpdateParams { @@ -176,12 +217,12 @@ export interface InboxV2SubTypeUpdateParams { /** 更新仓库自定义子类型(系统预设拒绝修改) */ export function inboxV2SubTypeUpdate(data: InboxV2SubTypeUpdateParams) { - return call<{ message: string }>('inbox.v2.subType.update', data as unknown as Record) + return call('inbox.v2.subType.update', data as unknown as Record) } /** 删除仓库自定义子类型(有关联引用时拒绝) */ export function inboxV2SubTypeDelete(id: number) { - return call<{ message: string }>('inbox.v2.subType.delete', { id }) + return call('inbox.v2.subType.delete', { id }) } // ─────────────────────────── 关键词 ─────────────────────────── @@ -213,7 +254,7 @@ export interface InboxV2KeywordListData { /** 关键词列表 */ export function inboxV2KeywordList(data: InboxV2KeywordListParams = {}) { - return call('inbox.v2.keyword.list', data as Record) + return call('inbox.v2.keyword.list', data as Record) } export interface InboxV2KeywordCreateParams { @@ -225,7 +266,7 @@ export interface InboxV2KeywordCreateParams { /** 创建仓库自定义关键词 */ export function inboxV2KeywordCreate(data: InboxV2KeywordCreateParams) { - return call<{ id: number; message: string }>('inbox.v2.keyword.create', data as unknown as Record) + return call('inbox.v2.keyword.create', data as unknown as Record) } export interface InboxV2KeywordUpdateParams { @@ -238,12 +279,12 @@ export interface InboxV2KeywordUpdateParams { /** 更新仓库自定义关键词(系统预设拒绝修改) */ export function inboxV2KeywordUpdate(data: InboxV2KeywordUpdateParams) { - return call<{ message: string }>('inbox.v2.keyword.update', data as unknown as Record) + return call('inbox.v2.keyword.update', data as unknown as Record) } /** 删除仓库自定义关键词 */ export function inboxV2KeywordDelete(id: number) { - return call<{ message: string }>('inbox.v2.keyword.delete', { id }) + return call('inbox.v2.keyword.delete', { id }) } // ─────────────────────────── 取号规则(全局只读) ─────────────────────────── @@ -262,7 +303,7 @@ export interface InboxV2NumberRuleItem { /** 取号规则列表(只读,供关联配置选择) */ export function inboxV2NumberRuleList() { - return call<{ list: InboxV2NumberRuleItem[] }>('inbox.v2.numberRule.list') + return call('inbox.v2.numberRule.list') } // ─────────────────────────── 处理函数 ─────────────────────────── @@ -286,7 +327,7 @@ export interface InboxV2FunctionListParams { /** 处理函数列表 */ export function inboxV2FunctionList(data: InboxV2FunctionListParams = {}) { - return call<{ list: InboxV2FunctionItem[] }>('inbox.v2.function.list', data as Record) + return call('inbox.v2.function.list', data as Record) } export interface InboxV2FunctionUpdateParams { @@ -302,7 +343,7 @@ export interface InboxV2FunctionUpdateParams { * 本方法仅保留后端接口映射以备他用,页面侧不再调用。 */ export function inboxV2FunctionUpdate(data: InboxV2FunctionUpdateParams) { - return call<{ message: string }>('inbox.v2.function.update', data as unknown as Record) + return call('inbox.v2.function.update', data as unknown as Record) } // ─────────────────────────── 回复配置 ─────────────────────────── @@ -376,7 +417,7 @@ export interface InboxV2ReplyMergedData { * 返回结构为 `{ merged, total }`,不分页。 */ export function inboxV2ReplyMerged(data: InboxV2ReplyMergedParams = {}) { - return call('inbox.v2.reply.merged', data as Record) + return call('inbox.v2.reply.merged', data as Record) } /** @@ -384,7 +425,7 @@ export function inboxV2ReplyMerged(data: InboxV2ReplyMergedParams = {}) { * @deprecated 页面展示用 {@link inboxV2ReplyMerged}(合并后的生效配置);本接口保留供排查原始行使用。 */ export function inboxV2ReplyList(data: InboxV2ReplyListParams = {}) { - return call('inbox.v2.reply.list', data as Record) + return call('inbox.v2.reply.list', data as Record) } /** @@ -413,7 +454,7 @@ export interface InboxV2ReplySaveResult { /** 保存仓库级回复配置(upsert,推荐接口;未传字段保持原值) */ export function inboxV2ReplySave(data: InboxV2ReplySaveParams) { - return call('inbox.v2.reply.save', data as unknown as Record) + return call('inbox.v2.reply.save', data as unknown as Record) } /** @@ -421,7 +462,7 @@ export function inboxV2ReplySave(data: InboxV2ReplySaveParams) { * 无仓库级配置时同样返回成功(message 为「…已是系统级配置」)。 */ export function inboxV2ReplyRestore(subTypeId: number) { - return call<{ message: string }>('inbox.v2.reply.restore', { subTypeId }) + return call('inbox.v2.reply.restore', { subTypeId }) } /** @deprecated 见 {@link InboxV2ReplySaveParams} */ @@ -442,7 +483,7 @@ export interface InboxV2ReplyCreateParams { * @deprecated 后端保留的兼容接口,页面统一改用 {@link inboxV2ReplySave}(upsert)。 */ export function inboxV2ReplyCreate(data: InboxV2ReplyCreateParams) { - return call<{ id: number; message: string }>('inbox.v2.reply.create', data as unknown as Record) + return call('inbox.v2.reply.create', data as unknown as Record) } export interface InboxV2ReplyUpdateParams { @@ -459,7 +500,7 @@ export interface InboxV2ReplyUpdateParams { * @deprecated 后端保留的兼容接口,页面统一改用 {@link inboxV2ReplySave}(upsert)。 */ export function inboxV2ReplyUpdate(data: InboxV2ReplyUpdateParams) { - return call<{ message: string }>('inbox.v2.reply.update', data as unknown as Record) + return call('inbox.v2.reply.update', data as unknown as Record) } /** @@ -467,7 +508,7 @@ export function inboxV2ReplyUpdate(data: InboxV2ReplyUpdateParams) { * @deprecated 后端保留的兼容接口,页面统一改用 {@link inboxV2ReplyRestore}(幂等还原)。 */ export function inboxV2ReplyDelete(id: number) { - return call<{ message: string }>('inbox.v2.reply.delete', { id }) + return call('inbox.v2.reply.delete', { id }) } // ─────────────────────────── 子类型关联关系 ─────────────────────────── @@ -504,7 +545,7 @@ export interface InboxV2SubTypeGroupItem { /** 子类型已关联的处理函数列表 */ export function inboxV2RelationFunctionList(subTypeId: number) { - return call<{ list: InboxV2SubTypeFunctionItem[] }>('inbox.v2.relation.function.list', { subTypeId }) + return call('inbox.v2.relation.function.list', { subTypeId }) } /** 全量替换子类型的处理函数关联 */ @@ -512,7 +553,7 @@ export function inboxV2RelationFunctionSet( subTypeId: number, items: Array<{ functionId: number; sortOrder?: number }> ) { - return call<{ message: string }>('inbox.v2.relation.function.set', { + return call('inbox.v2.relation.function.set', { subTypeId, items, } as unknown as Record) @@ -520,7 +561,7 @@ export function inboxV2RelationFunctionSet( /** 子类型已关联的取号规则列表 */ export function inboxV2RelationRuleList(subTypeId: number) { - return call<{ list: InboxV2SubTypeRuleItem[] }>('inbox.v2.relation.rule.list', { subTypeId }) + return call('inbox.v2.relation.rule.list', { subTypeId }) } /** 全量替换子类型的取号规则关联 */ @@ -528,7 +569,7 @@ export function inboxV2RelationRuleSet( subTypeId: number, items: Array<{ ruleId: number; sortOrder?: number }> ) { - return call<{ message: string }>('inbox.v2.relation.rule.set', { + return call('inbox.v2.relation.rule.set', { subTypeId, items, } as unknown as Record) @@ -536,7 +577,7 @@ export function inboxV2RelationRuleSet( /** 子类型已关联的群白名单列表 */ export function inboxV2RelationGroupList(subTypeId: number) { - return call<{ list: InboxV2SubTypeGroupItem[] }>('inbox.v2.relation.group.list', { subTypeId }) + return call('inbox.v2.relation.group.list', { subTypeId }) } /** 替换子类型的群白名单(系统预设行后端自动保留) */ @@ -544,7 +585,7 @@ export function inboxV2RelationGroupSet( subTypeId: number, items: Array<{ groupType: string; subGroup: string; sortOrder?: number }> ) { - return call<{ message: string }>('inbox.v2.relation.group.set', { + return call('inbox.v2.relation.group.set', { subTypeId, items, } as unknown as Record) diff --git a/src/api/order.pendingorder/orderpendingOrder.ts b/src/api/order.pendingorder/orderpendingOrder.ts index 7d66e708..6a5eb5b1 100644 --- a/src/api/order.pendingorder/orderpendingOrder.ts +++ b/src/api/order.pendingorder/orderpendingOrder.ts @@ -624,6 +624,45 @@ export function orderPendingOrderParseAddress( } as any); } +/** order.pendingOrder.parseAddressLocal 入参(可选;两者均不传时后端用内置示例地址数据) */ +export type PendingOrderParseAddressLocalParams = { + /** 单条地址解析;也支持传字符串数组批量解析(与 addresses 二选一) */ + address?: string | string[]; + /** 批量地址解析(单次最多 50 条) */ + addresses?: string[]; +}; + +/** order.pendingOrder.parseAddressLocal 响应(结构同 parseAddress,额外含 data.source) */ +export type PendingOrderParseAddressLocalResponse = PendingOrderParseAddressResponse & { + data?: PendingOrderParseAddressData & { + list?: PendingOrderParseAddressItem[]; + /** 未传 address/addresses 时为 sample,表示结果来自内置示例地址数据 */ + source?: string; + }; +}; + +/** + * order.pendingOrder.parseAddressLocal:本地地址解析(不调 AI,内置省市区字典遍历识别)。 + * 与 parseAddress 解析逻辑等价;区别是可完全无参调用(返回内置示例地址数据的识别结果)。 + */ +export function orderPendingOrderParseAddressLocal( + data: PendingOrderParseAddressLocalParams = {}, +): Promise { + return request({ + url: "/system", + method: "post", + params: { + method: "order.pendingOrder.parseAddressLocal", + v, + timestamp: Date.now(), + }, + data, + isSystemApi: true, + // 批量解析(最多 50 条)耗时较长,超时时间延长至 10 分钟 + timeout: 600000, + } as any); +} + /** order.pendingOrder.batchIntercept:批量提交订单拦截请求 */ export function orderPendingOrderBatchIntercept(data: PendingOrderBatchInterceptParams): Promise { return request({ @@ -800,6 +839,7 @@ export type OrderPendingOrderApi = { importOrdersFromExcel: typeof orderPendingOrderImportOrdersFromExcel; downloadCreateTemplate: typeof orderPendingOrderDownloadCreateTemplate; parseAddress: typeof orderPendingOrderParseAddress; + parseAddressLocal: typeof orderPendingOrderParseAddressLocal; batchIntercept: typeof orderPendingOrderBatchIntercept; batchInterceptTaskProgress: typeof orderPendingOrderBatchInterceptTaskProgress; batchUnintercept: typeof orderPendingOrderBatchUnintercept; @@ -835,6 +875,7 @@ export const orderPendingOrder: OrderPendingOrderApi = { importOrdersFromExcel: orderPendingOrderImportOrdersFromExcel, downloadCreateTemplate: orderPendingOrderDownloadCreateTemplate, parseAddress: orderPendingOrderParseAddress, + parseAddressLocal: orderPendingOrderParseAddressLocal, batchIntercept: orderPendingOrderBatchIntercept, batchInterceptTaskProgress: orderPendingOrderBatchInterceptTaskProgress, batchUnintercept: orderPendingOrderBatchUnintercept, diff --git a/src/api/order.wave/orderwave.ts b/src/api/order.wave/orderwave.ts index 2f32b933..cfc21e20 100644 --- a/src/api/order.wave/orderwave.ts +++ b/src/api/order.wave/orderwave.ts @@ -1266,100 +1266,7 @@ export function orderWaveBatchRemoveOrders( } as any) } -/** order.wave.confirmPrintScan 入参:扫描波次内任一订单的面单号确认打印 */ -export type WaveConfirmPrintScanParams = { - /** 面单号/运单号(必填,用于定位订单及所属波次) */ - waybill_no: string -} - -/** order.wave.confirmPrintScan 业务 data */ -export type WaveConfirmPrintScanResponse = { - /** 扫描的面单号 */ - waybill_no?: string - /** 面单号匹配到的订单ID */ - matched_order_id?: number - /** 波次ID */ - wave_id?: number - /** 波次编码 */ - wave_no?: string - /** 波次下总订单数 */ - total_order_count?: number - /** 波次下拦截订单数(跳过确认) */ - intercepted_order_count?: number - /** 已确认打印订单数(confirm_print_status='fin') */ - confirmed_order_count?: number - /** 本次新增确认订单数(仅 status=confirmed 时返回) */ - newly_confirmed_order_count?: number - /** confirmed=本次完成确认 / already_confirmed=已全部确认 */ - status: 'confirmed' | 'already_confirmed' | string -} - -/** - * order.wave.confirmPrintScan:扫描波次内任一订单的面单号,将该波次下全部已打印(print_status='fin') - * 且非拦截订单批量置 confirm_print_status='fin',并写订单操作日志(ORDER_CONFIRM_PRINT)。 - * - 拦截订单跳过(不确认、不阻断); - * - 波次下存在未打印订单(print_status != 'fin')时阻断:返回 unprinted_order_count; - * - 全部已确认时重复扫描返回 status=already_confirmed。 - */ -export function orderWaveConfirmPrintScan( - data: WaveConfirmPrintScanParams -): Promise; unprinted_order_count?: number }> { - return request({ - url: '/system', - method: 'post', - params: { - method: 'order.wave.confirmPrintScan', - v, - timestamp: new Date().getTime() - }, - data, - isSystemApi: true - } as any) -} - -/** order.wave.confirmPrintUnclaimedWaveCount 入参:长轮询上次数量 */ -export type WaveConfirmPrintUnclaimedWaveCountParams = { - /** - * 上次返回的数量(长轮询游标): - * 不传 → 立即返回当前值(status=current);传入且与当前值不同 → 立即返回新值(status=changed); - * 相同 → 挂起等待,最长 60 秒(期间变化立即返回 changed,超时重查后返回 timeout)。 - */ - last_count?: number -} - -/** order.wave.confirmPrintUnclaimedWaveCount 业务 data */ -export type WaveConfirmPrintUnclaimedWaveCountResponse = { - /** 已确认打印(confirm_print_status='fin')但未领单(claim_status != 'fin')订单涉及的波次数量 */ - count: number - /** current=直接返回当前值 / changed=数量已变化 / timeout=等待超时后返回当前值 */ - status: 'current' | 'changed' | 'timeout' | string -} - -/** - * order.wave.confirmPrintUnclaimedWaveCount:查询「已确认打印但未领单」波次数量,支持长轮询。 - * 注意:长轮询最长挂起 60 秒,超过请求层默认 10 秒超时,故单独放开 timeout。 - */ -export function orderWaveConfirmPrintUnclaimedWaveCount( - data: WaveConfirmPrintUnclaimedWaveCountParams = {} -): Promise }> { - return request({ - url: '/system', - method: 'post', - params: { - method: 'order.wave.confirmPrintUnclaimedWaveCount', - v, - timestamp: new Date().getTime() - }, - data, - isSystemApi: true, - // 长轮询最长等待 60 秒(请求层默认 10 秒会提前中断) - timeout: 70000 - } as any) -} - export const orderWave = { - confirmPrintScan: orderWaveConfirmPrintScan, - confirmPrintUnclaimedWaveCount: orderWaveConfirmPrintUnclaimedWaveCount, wavePickTaskList: orderWaveWavePickTaskList, wavePickTaskCancel: orderWaveWavePickTaskCancel, wavePickTaskCancelSelf: orderWaveWavePickTaskCancelSelf, diff --git a/src/api/order/order.ts b/src/api/order/order.ts index c35aeceb..995ab809 100644 --- a/src/api/order/order.ts +++ b/src/api/order/order.ts @@ -407,8 +407,106 @@ export function orderModulePendingOrderBatchMarkPrinted( } as any) } +// ──────────────────────────────────────────────────────────── +// 以下两个接口的 method 前缀为 order.wave.*,但文档归属 folder = order, +// 故实现放在 src/api/order/(与 order.wave.batchList 同一归属规则)。 +// ──────────────────────────────────────────────────────────── + +/** order.wave.confirmPrintScan 入参:扫描波次内任一订单的面单号确认打印 */ +export type WaveConfirmPrintScanParams = { + /** 面单号/运单号(必填,用于定位订单及所属波次) */ + waybill_no: string +} + +/** order.wave.confirmPrintScan 业务 data */ +export type WaveConfirmPrintScanResponse = { + /** 扫描的面单号 */ + waybill_no?: string + /** 面单号匹配到的订单ID */ + matched_order_id?: number + /** 波次ID */ + wave_id?: number + /** 波次编码 */ + wave_no?: string + /** 波次下总订单数 */ + total_order_count?: number + /** 波次下拦截订单数(跳过确认) */ + intercepted_order_count?: number + /** 已确认打印订单数(confirm_print_status='fin') */ + confirmed_order_count?: number + /** 本次新增确认订单数(仅 status=confirmed 时返回) */ + newly_confirmed_order_count?: number + /** confirmed=本次完成确认 / already_confirmed=已全部确认 */ + status: 'confirmed' | 'already_confirmed' | string +} + +/** + * order.wave.confirmPrintScan:扫描波次内任一订单的面单号,将该波次下全部已打印(print_status='fin') + * 且非拦截订单批量置 confirm_print_status='fin',并写订单操作日志(ORDER_CONFIRM_PRINT)。 + * - 拦截订单跳过(不确认、不阻断); + * - 波次下存在未打印订单(print_status != 'fin')时阻断:返回 unprinted_order_count; + * - 全部已确认时重复扫描返回 status=already_confirmed。 + */ +export function orderWaveConfirmPrintScan( + data: WaveConfirmPrintScanParams +): Promise; unprinted_order_count?: number }> { + return request({ + url: '/system', + method: 'post', + params: { + method: 'order.wave.confirmPrintScan', + v, + timestamp: Date.now() + }, + data, + isSystemApi: true + } as any) +} + +/** order.wave.confirmPrintUnclaimedWaveCount 入参:长轮询上次数量 */ +export type WaveConfirmPrintUnclaimedWaveCountParams = { + /** + * 上次返回的数量(长轮询游标): + * 不传 → 立即返回当前值(status=current);传入且与当前值不同 → 立即返回新值(status=changed); + * 相同 → 挂起等待,最长 60 秒(期间变化立即返回 changed,超时重查后返回 timeout)。 + */ + last_count?: number +} + +/** order.wave.confirmPrintUnclaimedWaveCount 业务 data */ +export type WaveConfirmPrintUnclaimedWaveCountResponse = { + /** 已确认打印(confirm_print_status='fin')但未领单(claim_status != 'fin')订单涉及的波次数量 */ + count: number + /** current=直接返回当前值 / changed=数量已变化 / timeout=等待超时后返回当前值 */ + status: 'current' | 'changed' | 'timeout' | string +} + +/** + * order.wave.confirmPrintUnclaimedWaveCount:查询「已确认打印但未领单」波次数量,支持长轮询。 + * 注意:长轮询最长挂起 60 秒,超过请求层默认 10 秒超时,故单独放开 timeout。 + */ +export function orderWaveConfirmPrintUnclaimedWaveCount( + data: WaveConfirmPrintUnclaimedWaveCountParams = {} +): Promise }> { + return request({ + url: '/system', + method: 'post', + params: { + method: 'order.wave.confirmPrintUnclaimedWaveCount', + v, + timestamp: Date.now() + }, + data, + isSystemApi: true, + // 长轮询最长等待 60 秒(请求层默认 10 秒会提前中断) + timeout: 70000 + } as any) +} + export const orderModule = { waveBatchList: orderModuleWaveBatchList, + confirmPrintScan: orderWaveConfirmPrintScan, + confirmPrintUnclaimedWaveCount: orderWaveConfirmPrintUnclaimedWaveCount, pendingOrderDownloadCreateTemplate: orderModulePendingOrderDownloadCreateTemplate, pendingOrderManualWaybill: orderModulePendingOrderManualWaybill, bindExpressPackageMaterialByWaybill: orderBindExpressPackageMaterialByWaybill, diff --git a/src/api/user/user.ts b/src/api/user/user.ts index 32268a0d..0632d8b2 100644 --- a/src/api/user/user.ts +++ b/src/api/user/user.ts @@ -53,7 +53,20 @@ export function register (data:any):any { -export function getInfo(data: Record) { +/** + * user.info 入参 + * - 支持微信登录态中间层:未绑定真实用户时返回微信层信息(is_bound=false、id=0),不 401 + * - 可选 wechat_appId:按 wms_wechat_app.appid 反查归属仓库,过滤 employees 列表 + * (只保留非仓库工号与仅该仓库工号);未传或查不到仓库时保持原逻辑。 + */ +export interface UserInfoParams { + /** 小程序 AppID(可选) */ + wechat_appId?: string + /** 其它业务参数(以后端为准) */ + [key: string]: any +} + +export function getInfo(data: UserInfoParams = {}) { return request({ url: '/system', method: 'post', diff --git a/src/api/wechat/wechat.ts b/src/api/wechat/wechat.ts index ba5f1408..5d8cf693 100644 --- a/src/api/wechat/wechat.ts +++ b/src/api/wechat/wechat.ts @@ -39,18 +39,241 @@ export function wechatGetAuthUrl( } /** - * 获取「代注册小程序」链接(第三方平台快速创建小程序): - * 同样由用户点击按钮后才请求,并在新小窗口中打开;注册完成后调用业务侧查询接口刷新。 - * 若后端方法名不同,仅需改此处 method。 + * 查询当前仓库小程序的微信认证状态(wechat.queryauth)—— 无需入参,仓库由登录态上下文(ctx.user.store_id)决定。 */ -export function wechatGetRegisterUrl( - data: Record = {} -): Promise<{ code?: number; message?: string; data?: WeChatAuthUrlPayload } & Record> { +export type WeChatQueryAuthData = { + /** 小程序 AppID */ + appid: string + /** 认证状态:0 未认证、1 认证中、2 认证通过、3 认证失败 */ + auth_state: number + /** 认证状态中文文案 */ + auth_state_text: string +} + +export function wechatQueryAuth(): Promise< + { code?: number; message?: string; data?: WeChatQueryAuthData } & Record +> { return request({ url: '/system', method: 'post', params: { - method: 'wechat.getRegisterUrl', + method: 'wechat.queryauth', + v, + timestamp: new Date().getTime() + }, + data: {}, + isSystemApi: true + } as any) +} + +/** + * 快速注册企业小程序(wechat.registerMiniprogram)—— + * 调微信 fastregisterweapp?action=create(component_access_token)提交企业信息创建注册任务, + * 法人微信收到模板消息做人脸核身;审核结果由 notify_third_fasteregister 事件推送到后端授权事件接收 URL。 + * + * 注意:本接口返回 errcode/errmsg,**不返回可打开的链接**, + * 前端不应再按「取链接开小窗」的方式处理。 + */ +export type WeChatRegisterMiniprogramParams = { + /** 企业名(与工商登记一致;无主体名称个体工商户填「个体户+法人姓名」) */ + name: string + /** 企业代码 */ + code: string + /** 企业代码类型:1 统一社会信用代码(18位)、2 组织机构代码(9位)、3 营业执照注册号(15位) */ + code_type: 1 | 2 | 3 + /** 法人微信号(不支持手机号/微信名) */ + legal_persona_wechat: string + /** 法人姓名(绑定银行卡) */ + legal_persona_name: string + /** 第三方联系电话 */ + component_phone?: string +} + +export function wechatRegisterMiniprogram( + data: WeChatRegisterMiniprogramParams +): Promise< + { code?: number; message?: string; errcode?: number; errmsg?: string } & Record +> { + return request({ + url: '/system', + method: 'post', + params: { + method: 'wechat.registerMiniprogram', + v, + timestamp: new Date().getTime() + }, + data, + isSystemApi: true + } as any) +} + +/** + * 获取小程序模板库列表(wechat.getTemplateList)—— 只拉取普通模板(template_type=0), + * 后端 Redis 缓存 24h(命中缓存直接返回,from_cache=true),用于「上传代码生成体验版」时选模板。 + */ +export type WeChatTemplateItem = { + /** 代码模板 ID(= wechat.commit 的 template_id 入参) */ + template_id?: number + /** 模板版本号 */ + user_version?: string + /** 模板描述 */ + user_desc?: string + /** 模板创建时间(Unix 秒) */ + create_time?: number + /** 草稿 ID */ + draft_id?: number + /** 模板类型:0 普通模板 */ + template_type?: number + /** 源小程序 AppID */ + source_miniprogram_appid?: string + /** 源小程序账号 */ + source_miniprogram?: string + [key: string]: unknown +} + +export type WeChatTemplateListData = { + list: WeChatTemplateItem[] + /** 是否来自后端缓存(Redis 24h) */ + from_cache: boolean +} + +export function wechatGetTemplateList(): Promise< + { code?: number; message?: string; data?: WeChatTemplateListData } & Record +> { + return request({ + url: '/system', + method: 'post', + params: { + method: 'wechat.getTemplateList', + v, + timestamp: new Date().getTime() + }, + data: {}, + isSystemApi: true + } as any) +} + +/** + * 上传代码并生成体验版(wechat.commit)—— + * 后端取当前仓库启用小程序,校验授权权限集 18(代码管理)与模板存在性后调微信 wxa/commit 上传代码, + * 成功后回写 wms_wechat_app.template_id。 + */ +export type WeChatCommitParams = { + /** 代码库中的代码模板 ID(由 wechat.getTemplateList 获取) */ + template_id: number + /** ext.json 配置内容(JSON 字符串,控制 extAppid / 自定义字段等) */ + ext_json: string + /** 代码版本号(≤64 字符) */ + user_version: string + /** 代码描述 */ + user_desc: string +} + +export type WeChatCommitData = { + /** 小程序 AppID */ + appid: string + /** 已上传的模板 ID(同时回写 wms_wechat_app.template_id) */ + template_id: number +} + +export function wechatCommit( + data: WeChatCommitParams +): Promise<{ code?: number; message?: string; data?: WeChatCommitData } & Record> { + return request({ + url: '/system', + method: 'post', + params: { + method: 'wechat.commit', + v, + timestamp: new Date().getTime() + }, + data, + isSystemApi: true, + // 上传代码到微信耗时较长,超时放宽到 3 分钟 + timeout: 180000 + } as any) +} + +/** + * 获取体验版二维码(wechat.getTrialQRCode)—— + * 后端取当前仓库启用小程序,校验权限集 18 / 86 后调微信 wxa/get_qrcode 取二维码(jpeg), + * 转存 COS 后返回可访问的图片 URL。 + */ +export type WeChatTrialQRCodeParams = { + /** 扫码后进入的页面路径(可选,如 page/index?action=1,后端自动 urlencode) */ + path?: string +} + +export type WeChatTrialQRCodeData = { + /** 小程序 AppID */ + appid: string + /** 二维码图片 URL(COS) */ + url: string +} + +export function wechatGetTrialQRCode( + data: WeChatTrialQRCodeParams = {} +): Promise< + { code?: number; message?: string; data?: WeChatTrialQRCodeData } & Record +> { + return request({ + url: '/system', + method: 'post', + params: { + method: 'wechat.getTrialQRCode', + v, + timestamp: new Date().getTime() + }, + data, + isSystemApi: true + } as any) +} + +/** 审核项(item_list 元素):微信审核类目信息,后端原样透传 */ +export type WeChatAuditItem = { + /** 类目路径(如 教育/在线教育) */ + address?: string + /** 类目标签 */ + tag?: string + /** 一级类目 */ + first_class?: string + [key: string]: unknown +} + +/** + * 提交代码审核(wechat.submitAudit)—— + * 后端取当前仓库启用小程序,校验权限集 18;**仅 audit_status != 1(无审核中的版本)时允许提交**, + * 成功后记录 audit_status=1 与 audit_id(回写 wms_wechat_app.audit_id)。 + * + * 审核结果由微信事件(weapp_audit_success / weapp_audit_fail)回写后端:2 通过、3 驳回(含原因); + * ⚠️ 目前没有查询审核状态的接口,前端只能得到「已提交」与 auditid。 + */ +export type WeChatSubmitAuditParams = { + /** 审核项列表(可选,含 address/tag/first_class 等类目信息) */ + item_list?: WeChatAuditItem[] + /** 版本描述(可选) */ + version_desc?: string + /** 不使用地理位置接口声明(可选) */ + privacy_api_not_use?: boolean +} + +export type WeChatSubmitAuditData = { + /** 小程序 AppID */ + appid: string + /** 微信审核单 ID(同时回写 wms_wechat_app.audit_id) */ + auditid: number +} + +export function wechatSubmitAudit( + data: WeChatSubmitAuditParams = {} +): Promise< + { code?: number; message?: string; data?: WeChatSubmitAuditData } & Record +> { + return request({ + url: '/system', + method: 'post', + params: { + method: 'wechat.submitAudit', v, timestamp: new Date().getTime() }, @@ -61,7 +284,12 @@ export function wechatGetRegisterUrl( export const wechat = { getAuthUrl: wechatGetAuthUrl, - getRegisterUrl: wechatGetRegisterUrl + queryAuth: wechatQueryAuth, + registerMiniprogram: wechatRegisterMiniprogram, + getTemplateList: wechatGetTemplateList, + commit: wechatCommit, + getTrialQRCode: wechatGetTrialQRCode, + submitAudit: wechatSubmitAudit } export default wechat diff --git a/src/utils/barcode.ts b/src/utils/barcode.ts index 450978bd..acdb9736 100644 --- a/src/utils/barcode.ts +++ b/src/utils/barcode.ts @@ -97,3 +97,34 @@ export function formatBarcodeText( const items = normalizeBarcodeList(value, options) return items.length ? items.join(separator) : fallback } + +/** 行数据中可能承载条码的嵌套对象字段(按优先级) */ +const BARCODE_NESTED_KEYS = ['stock', 'store_stock', 'goods'] as const + +/** 收集单行(含 stock/store_stock/goods 嵌套)内的条码:先取 barcodes 数组,再取 barcode 单值 */ +function collectRowBarcodesInto(row: unknown, result: string[]): void { + if (!row || typeof row !== 'object' || Array.isArray(row)) return + const record = row as Record + result.push(...normalizeBarcodeList(record.barcodes, { splitText: false })) + const single = pickBarcodeText(record.barcode) + if (single) result.push(single) + for (const key of BARCODE_NESTED_KEYS) { + collectRowBarcodesInto(record[key], result) + } +} + +/** + * 从一行或多行数据(如订单明细行 + item_snapshot、库存行 + stock/goods 关联)中 + * 归一化收集商品条码,去重并保持顺序。 + * 支持 `barcode` 单值、`barcodes` 数组(字符串数组 / 对象数组 / JSON 字符串)与嵌套对象。 + */ +export function collectRowBarcodes(...rows: unknown[]): string[] { + const collected: string[] = [] + for (const row of rows) collectRowBarcodesInto(row, collected) + return Array.from(new Set(collected.filter(Boolean))) +} + +/** 取一行(或多行)数据中的首个商品条码;取不到时返回空串(不会输出 `[object Object]`) */ +export function resolveRowBarcode(...rows: unknown[]): string { + return collectRowBarcodes(...rows)[0] ?? '' +} diff --git a/src/views/data/newpackingflow/components/ColumnCellRenderer.vue b/src/views/data/newpackingflow/components/ColumnCellRenderer.vue deleted file mode 100644 index 1f34b5d2..00000000 --- a/src/views/data/newpackingflow/components/ColumnCellRenderer.vue +++ /dev/null @@ -1,65 +0,0 @@ - - - - - diff --git a/src/views/data/newpackingflow/components/OperationCellRenderer.vue b/src/views/data/newpackingflow/components/OperationCellRenderer.vue deleted file mode 100644 index 04420a5d..00000000 --- a/src/views/data/newpackingflow/components/OperationCellRenderer.vue +++ /dev/null @@ -1,175 +0,0 @@ - - - - - - diff --git a/src/views/data/newpackingflow/components/TabArea.vue b/src/views/data/newpackingflow/components/TabArea.vue deleted file mode 100644 index 288ec6f1..00000000 --- a/src/views/data/newpackingflow/components/TabArea.vue +++ /dev/null @@ -1,132 +0,0 @@ - - - - - diff --git a/src/views/data/newpackingflow/components/VideoButton.vue b/src/views/data/newpackingflow/components/VideoButton.vue deleted file mode 100644 index 03c3695b..00000000 --- a/src/views/data/newpackingflow/components/VideoButton.vue +++ /dev/null @@ -1,35 +0,0 @@ - - - diff --git a/src/views/data/newpackingflow/components/VideoListDialog.vue b/src/views/data/newpackingflow/components/VideoListDialog.vue deleted file mode 100644 index aa9ec7c8..00000000 --- a/src/views/data/newpackingflow/components/VideoListDialog.vue +++ /dev/null @@ -1,134 +0,0 @@ - - - - - diff --git a/src/views/data/newpackingflow/components/VideoPlayerDialog.vue b/src/views/data/newpackingflow/components/VideoPlayerDialog.vue deleted file mode 100644 index 827de7a6..00000000 --- a/src/views/data/newpackingflow/components/VideoPlayerDialog.vue +++ /dev/null @@ -1,173 +0,0 @@ - - - - - diff --git a/src/views/data/newpackingflow/config/components/DetailPanel.vue b/src/views/data/newpackingflow/config/components/DetailPanel.vue deleted file mode 100644 index fae019ed..00000000 --- a/src/views/data/newpackingflow/config/components/DetailPanel.vue +++ /dev/null @@ -1,160 +0,0 @@ - - - - - - diff --git a/src/views/data/newpackingflow/config/components/LogPanel.vue b/src/views/data/newpackingflow/config/components/LogPanel.vue deleted file mode 100644 index 0adae9f3..00000000 --- a/src/views/data/newpackingflow/config/components/LogPanel.vue +++ /dev/null @@ -1,227 +0,0 @@ - - - - - - diff --git a/src/views/data/newpackingflow/config/packingflow-config.ts b/src/views/data/newpackingflow/config/packingflow-config.ts deleted file mode 100644 index 4ed4e685..00000000 --- a/src/views/data/newpackingflow/config/packingflow-config.ts +++ /dev/null @@ -1,776 +0,0 @@ -/** - * 【打包流水】页面配置 — 基于 template v2 架构 - * - * 原 packingflow 页面迁移至 newpackingflow 新结构。 - * 仓库选择、运单号搜索等筛选条件统一整合到左侧 ScanBox 面板。 - */ - -import type { Component } from 'vue' -import DetailPanel from './components/DetailPanel.vue' -import LogPanel from './components/LogPanel.vue' -import { packingList, packingGet } from '@/api/order/packing/index' - -// ============================================================ -// 〇、全局页面配置 -// ============================================================ -export const PAGE_CONFIG = { - /** 是否显示顶部多标签栏 */ - showTabArea: false, - /** 单页模式:不显示标签栏,仅一个标签页内容 */ - singlePage: true, - /** 是否启用详情面板(底部分栏),false 时表格占满全高 */ - enableDetailPanel: true -} - -// ============================================================ -// 〇-A、组件注册表 -// ============================================================ -export const COMPONENT_REGISTRY: Record = { - DetailPanel, - LogPanel -} - -// ============================================================ -// 〇-B、SCANBOX_GROUPS — ScanBox 分组名称 -// ============================================================ -export const SCANBOX_GROUPS = { - basic: '基础信息', - process: '流程状态', - time: '时间范围' -} as const - -// ============================================================ -// 一、FIELD_DICT — 全局字段预设表(唯一真相来源) -// ============================================================ -// 每个字段拥有: -// label — 唯一翻译文本 -// scanBox — ScanBox 渲染配置(type/options/group) -// table — 表格列配置(minWidth/fixed/align/sortable) -// slot — 单元格渲染配置(tag/tagResolver/translateField) -// detailLabel — 明细面板中的标签文本(可选,默认用 label) -// filterParamMap — ScanBox 筛选值 → API 传参值映射 - -export interface FieldDefinition { - key: string - label: string - scanBox: { - type: 'text' | 'select' | 'daterange' | 'number' - group?: string - options?: { label: string; value: any }[] - } | null - table: { - minWidth?: number - width?: number - fixed?: 'left' | 'right' | boolean - align?: 'left' | 'center' | 'right' - sortable?: boolean - showOverflowTooltip?: boolean - copyAction?: 'copy' | 'copyQr' - copyValue?: (row: any) => any - } | null - slot: { - type: 'tag' | 'text' | 'default' | 'operation' - tagType?: string | Record - tagResolver?: string - translateField?: string - format?: 'datetime' - } | null - detailLabel?: string - filterParamMap?: Record -} - -// ============================================================ -// VALUE_MAPS — 值翻译映射(select options 和 tag 翻译共用) -// ============================================================ -export const VALUE_MAPS: Record> = { - status: { - '0': '未打包', '1': '打包中', '2': '已打包', - '未打包': '未打包', '打包中': '打包中', '已打包': '已打包' - }, - pack_mode: { - '1': '散单', '2': '团购', - '散单': '散单', '团购': '团购' - } -} - -/** 从 VALUE_MAPS 衍生 options(优先取中文值作为 option value) */ -export function getOptions(field: string): { label: string; value: string }[] { - const map = VALUE_MAPS[field] - if (!map) return [] - const seen = new Set() - const opts: { label: string; value: string }[] = [] - const chineseKeys: [string, string][] = [] - const otherKeys: [string, string][] = [] - for (const [v, l] of Object.entries(map)) { - if (/^[\u4e00-\u9fa5]/.test(v)) { - chineseKeys.push([v, l]) - } else { - otherKeys.push([v, l]) - } - } - for (const [v, l] of [...chineseKeys, ...otherKeys]) { - if (!seen.has(l)) { - seen.add(l) - opts.push({ label: l, value: v }) - } - } - return opts -} - -/** 翻译 value → label */ -export function translate(field: string, value: any): string { - const map = VALUE_MAPS[field] - if (!map) return String(value ?? '—') - return map[String(value)] ?? String(value ?? '—') -} - -/** 格式化时间戳为 YYYY-MM-DD HH:mm:ss */ -export function formatTime(value: any): string { - if (!value) return '—' - try { - const d = new Date(value) - if (isNaN(d.getTime())) return String(value) - const pad = (n: number) => String(n).padStart(2, '0') - return `${d.getFullYear()}-${pad(d.getMonth() + 1)}-${pad(d.getDate())} ${pad(d.getHours())}:${pad(d.getMinutes())}:${pad(d.getSeconds())}` - } catch { - return String(value) - } -} - -/** 计算打包时长(结束时间 - 开始时间),返回格式化字符串 */ -export function calcPackDuration(startTime: any, endTime: any): string { - if (!startTime || !endTime) return '—' - try { - const start = new Date(startTime) - const end = new Date(endTime) - if (isNaN(start.getTime()) || isNaN(end.getTime())) return '—' - const diff = end.getTime() - start.getTime() - if (diff < 0) return '—' - const hours = Math.floor(diff / 3600000) - const minutes = Math.floor((diff % 3600000) / 60000) - const seconds = Math.floor((diff % 60000) / 1000) - if (hours > 0) return `${hours}小时${minutes}分${seconds}秒` - if (minutes > 0) return `${minutes}分${seconds}秒` - return `${seconds}秒` - } catch { - return '—' - } -} - -// ============================================================ -// TAG_RESOLVERS — 标签颜色解析器 -// ============================================================ -export const TAG_RESOLVERS: Record string> = { - resolveStatusTag(v) { - const s = Number(v) - if (s === 0) return 'info' // 未打包 - if (s === 1) return 'warning' // 打包中 - if (s === 2) return 'success' // 已打包 - return 'info' - }, - resolvePackModeTag(v) { - const s = Number(v) - if (s === 2) return 'warning' // 团购 - return 'info' // 散单 - } -} - -// ============================================================ -// 二、FIELD_DICT 实例 — 打包流水字段定义 -// ============================================================ -export const FIELD_DICT: Record = { - id: { - key: 'id', - label: '任务ID', - scanBox: null, - table: { width: 90 }, - slot: null, - detailLabel: '任务ID' - }, - order_id: { - key: 'order_id', - label: '订单ID', - scanBox: { type: 'text', group: SCANBOX_GROUPS.basic }, - table: { width: 100 }, - slot: null, - detailLabel: '订单ID' - }, - waybill_code: { - key: 'waybill_code', - label: '运单号', - scanBox: { type: 'text', group: SCANBOX_GROUPS.basic }, - table: { minWidth: 160, showOverflowTooltip: true }, - slot: null, - detailLabel: '运单号' - }, - wave_no: { - key: 'wave_no', - label: '波次号', - scanBox: { type: 'text', group: SCANBOX_GROUPS.basic }, - table: { minWidth: 140, showOverflowTooltip: true }, - slot: null, - detailLabel: '波次号' - }, - operator_text: { - key: 'operator_text', - label: '打包员', - scanBox: null, - table: { width: 100 }, - slot: null, - detailLabel: '打包员' - }, - workbench_name: { - key: 'workbench_name', - label: '工作台', - scanBox: null, - table: { width: 120, showOverflowTooltip: true }, - slot: null, - detailLabel: '工作台' - }, - pack_quantity: { - key: 'pack_quantity', - label: '打包数量', - scanBox: null, - table: { width: 100, align: 'center', sortable: true }, - slot: null, - detailLabel: '打包数量' - }, - pack_mode: { - key: 'pack_mode', - label: '打包模式', - scanBox: { type: 'select', group: SCANBOX_GROUPS.process, options: getOptions('pack_mode') }, - table: { width: 100, align: 'center' }, - slot: { type: 'tag', tagResolver: 'resolvePackModeTag', translateField: 'pack_mode' }, - detailLabel: '打包模式', - filterParamMap: { '散单': '1', '团购': '2' } - }, - status: { - key: 'status', - label: '任务状态', - scanBox: { type: 'select', group: SCANBOX_GROUPS.process, options: getOptions('status') }, - table: { width: 100, align: 'center' }, - slot: { type: 'tag', tagResolver: 'resolveStatusTag', translateField: 'status' }, - detailLabel: '任务状态', - filterParamMap: { '未打包': '0', '打包中': '1', '已打包': '2' } - }, - start_time: { - key: 'start_time', - label: '开始时间', - scanBox: { type: 'daterange', group: SCANBOX_GROUPS.time }, - table: { width: 170, sortable: true }, - slot: { type: 'text', format: 'datetime' }, - detailLabel: '开始时间' - }, - end_time: { - key: 'end_time', - label: '结束时间', - scanBox: { type: 'daterange', group: SCANBOX_GROUPS.time }, - table: { width: 170, sortable: true }, - slot: { type: 'text', format: 'datetime' }, - detailLabel: '结束时间' - }, - pack_duration: { - key: 'pack_duration', - label: '打包时长', - scanBox: null, - table: { width: 120, align: 'center' }, - slot: { type: 'text' }, - detailLabel: '打包时长' - }, - create_time: { - key: 'create_time', - label: '创建时间', - scanBox: { type: 'daterange', group: SCANBOX_GROUPS.time }, - table: { width: 170, sortable: true }, - slot: { type: 'text', format: 'datetime' }, - detailLabel: '创建时间' - }, - /** 仓库 — 仅用于 ScanBox 筛选,options 由 index.vue 动态注入 */ - warehouse_id: { - key: 'warehouse_id', - label: '仓库', - scanBox: { type: 'select', group: SCANBOX_GROUPS.basic, options: [] }, - table: null, - slot: null - }, - /** 工作台ID — 仅用于 ScanBox 筛选 */ - workbench_id: { - key: 'workbench_id', - label: '工作台ID', - scanBox: { type: 'text', group: SCANBOX_GROUPS.basic }, - table: null, - slot: null - }, - /** 录像列 — 由 index.vue 自定义插槽渲染 VideoButton */ - videos: { - key: 'videos', - label: '录像', - scanBox: null, - table: { width: 110, fixed: 'right', align: 'center' }, - slot: null - } -} - -// ============================================================ -// 三、ColumnSlotConfig — 列单元格渲染配置 -// ============================================================ -export interface ColumnSlotConfig { - type: 'tag' | 'text' | 'default' | 'operation' - tagType?: string | Record - tagResolver?: string - translateField?: string - format?: 'datetime' -} - -// ============================================================ -// 三-A、OperationButtonConfig — 操作列按钮配置 -// ============================================================ -export interface OperationButtonConfig { - key: string - label: string - type?: 'primary' | 'success' | 'warning' | 'danger' | 'info' | '' - actionType: 'form' | 'action' - formKey?: string - formTitle?: string - formWidth?: string - paramMap?: Record - extraParams?: Record - disabledOnField?: string - confirmMessage?: string - confirmTitle?: string - confirmType?: 'warning' | 'danger' | 'info' - confirmButtonText?: string -} - -// ============================================================ -// 四、DetailFieldConfig / DetailSectionConfig — 明细面板配置 -// ============================================================ -export interface DetailFieldConfig { - key: string - label?: string - span?: number - renderType?: 'text' | 'tag' | 'pre' - tagType?: string | Record - tagResolver?: string - translateField?: string -} - -export interface DetailSectionConfig { - title: string - columnCount: number - fields: DetailFieldConfig[] -} - -export interface DetailTabConfig { - name: string - label: string - componentKey: string - component?: Component -} - -// ============================================================ -// 五、TabPageApiConfig — 标签页接口插槽配置 -// ============================================================ -export type ApiMethod = (...args: any[]) => Promise -export type ApiSource = 'api' | 'list' -export type ComponentApiConfig = { source: 'list' } | ApiMethod - -export interface TabPageApiConfig { - /** 列表查询接口 */ - list: ApiMethod - /** 明细面板接口(可选,不配则用 row 数据) */ - detail?: ComponentApiConfig - /** 操作日志接口(可选) */ - log?: ComponentApiConfig - /** 导出接口(可选) */ - export?: ApiMethod - /** 导出进度查询接口(可选) */ - exportProgress?: ApiMethod - /** ScanBox 下拉选项数据源接口(可选) */ - scanBoxOptions?: Record - /** 工具栏按钮 → API 方法映射(可选) */ - toolbar?: Record - /** 列表响应解析器 */ - parseListResponse?: (res: any) => { list: any[]; total: number } - /** 构建列表请求参数 */ - buildListParams?: (params: { - pagination: { page: number; pageSize: number } - conditions: Record - sort?: { prop: string; order: string } - }) => Record -} - -// ============================================================ -// 六、TabPageRawConfig — 标签页声明配置(仅用 key 引用) -// ============================================================ -export interface TabPageRawConfig { - name: string - label: string - scanBoxCacheKey: string - /** ScanBox 需要的字段 key 列表(从 FIELD_DICT 中查找) */ - scanBoxFieldKeys: string[] - /** 表格需要的列 key 列表(从 FIELD_DICT 中查找) */ - tableColumnKeys: string[] - upperTableDefaults: { - title: string - enableColumnConfig?: boolean - showIndex?: boolean - showSelection?: boolean - emptyText?: string - } - /** 明细面板标签页配置 */ - detailTabs?: { name: string; label: string; componentKey: string }[] - /** 明细面板分区配置(字段 key 列表,resolveTabConfig 展开) */ - detailSections: { - title: string - columnCount: number - fieldKeys: string[] - }[] - /** 接口配置(有 api 时启用真实接口) */ - api?: TabPageApiConfig - /** 操作列按钮配置(需 tableColumnKeys 包含 'operation') */ - operationButtons?: OperationButtonConfig[] -} - -// ============================================================ -// 七、TabPageConfig — 展开后的完整配置(给 index.vue 使用) -// ============================================================ -export interface TabPageConfig { - name: string - label: string - scanBoxCacheKey: string - scanBoxFields: Record[] - upperTable: { - title: string - enableColumnConfig: boolean - showIndex: boolean - showSelection: boolean - emptyText: string - columns: Record[] - } - columnSlots: Record - detailConfig: DetailSectionConfig[] - detailTabs: DetailTabConfig[] - api?: TabPageApiConfig - operationButtons?: OperationButtonConfig[] -} - -// ============================================================ -// 八、resolveTabConfig — 加载时将 RawConfig 展开为完整配置 -// ============================================================ -export function resolveTabConfig(raw: TabPageRawConfig): TabPageConfig { - // 展开 ScanBox 字段 - const scanBoxFields: Record[] = [] - for (const key of raw.scanBoxFieldKeys) { - const def = FIELD_DICT[key] - if (!def || !def.scanBox) continue - scanBoxFields.push({ - label: def.label, - value: def.key, - type: def.scanBox.type, - options: def.scanBox.options ? [...def.scanBox.options] : undefined, - group: def.scanBox.group, - required: (def.scanBox as any).required - }) - } - - // 展开表格列 - const columns: Record[] = [] - for (const key of raw.tableColumnKeys) { - const def = FIELD_DICT[key] - if (!def || !def.table) continue - columns.push({ - prop: def.key, - label: def.label, - ...def.table - }) - } - - // 展开列插槽 - const columnSlots: Record = {} - for (const key of raw.tableColumnKeys) { - const def = FIELD_DICT[key] - if (!def || !def.slot) continue - columnSlots[def.key] = { ...def.slot } - } - - // 展开明细面板配置 - const detailConfig: DetailSectionConfig[] = raw.detailSections.map((sec) => ({ - title: sec.title, - columnCount: sec.columnCount, - fields: sec.fieldKeys - .map((key): DetailFieldConfig | null => { - const def = FIELD_DICT[key] - if (!def) return null - return { - key: def.key, - label: def.detailLabel ?? def.label, - translateField: def.slot?.translateField, - tagResolver: def.slot?.tagResolver, - tagType: def.slot?.tagType, - renderType: def.slot?.type === 'tag' ? 'tag' : 'text' - } - }) - .filter((f): f is DetailFieldConfig => f !== null) - })) - - // 展开明细标签页(解析 componentKey → Component) - const detailTabs: DetailTabConfig[] = raw.detailTabs - ? raw.detailTabs.map((tab) => ({ - name: tab.name, - label: tab.label, - componentKey: tab.componentKey, - component: COMPONENT_REGISTRY[tab.componentKey] - })) - : [{ name: 'detail', label: '明细', componentKey: 'DetailPanel', component: COMPONENT_REGISTRY['DetailPanel'] }] - - return { - name: raw.name, - label: raw.label, - scanBoxCacheKey: raw.scanBoxCacheKey, - scanBoxFields, - upperTable: { - title: raw.upperTableDefaults.title, - enableColumnConfig: raw.upperTableDefaults.enableColumnConfig ?? true, - showIndex: raw.upperTableDefaults.showIndex ?? true, - showSelection: raw.upperTableDefaults.showSelection ?? true, - emptyText: raw.upperTableDefaults.emptyText ?? '暂无数据', - columns - }, - columnSlots, - detailConfig, - detailTabs, - api: raw.api, - operationButtons: raw.operationButtons - } -} - -// ============================================================ -// 九、buildWhereConditions — 将 ScanBox 条件转为 API where 参数 -// ============================================================ -export function buildWhereConditions(rawConditions: Record): Record { - const where: Record = {} - for (const [key, cond] of Object.entries(rawConditions || {})) { - let value: any = undefined - if (cond && typeof cond === 'object' && 'operator' in cond) { - value = (cond as any).value - } else if (cond !== undefined && cond !== null && cond !== '') { - value = Array.isArray(cond) ? cond[0] ?? '' : cond - } - if (value === undefined || value === null || value === '' || (Array.isArray(value) && value.length === 0)) { - continue - } - - const def = FIELD_DICT[key] - - // daterange 类型:拆分为 key_start / key_end - if (def?.scanBox?.type === 'daterange' && Array.isArray(value) && value.length === 2) { - where[`${key}_start`] = value[0] - where[`${key}_end`] = value[1] - continue - } - - // filterParamMap 值映射(如中文 → 数字) - if (def?.filterParamMap) { - const mapped = def.filterParamMap[String(value)] - if (mapped !== undefined) { - where[key] = mapped - continue - } - } - where[key] = value - } - return where -} - -// ============================================================ -// 十、工具栏按钮系统 -// ============================================================ -// 按钮分类对齐 storage/receiving 模式: -// refresh — 蓝底白字(刷新) -// setting — 白底黑字(导出、字段设置、显示详情) -// action — 白底蓝边框(功能操作) -// cancel — 红底白字(作废/删除) - -export interface ToolbarButtonConfig { - key: string - label: string - category: 'refresh' | 'setting' | 'action' | 'cancel' - size?: '' | 'default' | 'small' | 'large' - type?: '' | 'primary' | 'success' | 'warning' | 'info' | 'danger' - plain?: boolean - loadingKey?: string - disabledKey?: string - action: string - dynamicLabelKey?: string - onlyForTabs?: string[] - buttonType?: 'default' | 'dropdown' - dropdownOptions?: Array<{ label: string; action: string; divided?: boolean }> - formKey?: string -} - -export const TOOLBAR_BUTTONS: Record = { - refresh: { - key: 'refresh', - label: '刷新', - category: 'refresh', - size: 'small', - loadingKey: 'loading', - action: 'loadData' - }, - columnConfig: { - key: 'columnConfig', - label: '字段设置', - category: 'setting', - size: 'small', - action: 'openColumnConfigPanel' - }, - toggleDetail: { - key: 'toggleDetail', - label: '显示详情', - category: 'setting', - dynamicLabelKey: 'detailToggleLabel', - size: 'small', - action: 'toggleDetailVisible' - } -} - -/** 按标签页名称获取工具栏按钮列表(自动根据 PAGE_CONFIG 过滤) */ -export function getTabToolbarButtons(tabName: string): ToolbarButtonConfig[] { - return Object.values(TOOLBAR_BUTTONS).filter((btn) => { - if (btn.onlyForTabs && !btn.onlyForTabs.includes(tabName)) return false - // 详情面板禁用时,隐藏「显示/隐藏详情」按钮 - if (!PAGE_CONFIG.enableDetailPanel && btn.key === 'toggleDetail') return false - return true - }) -} - -// ============================================================ -// 十一、批量操作配置(可选,接入 BatchOperationForm 时使用) -// ============================================================ -export interface BatchOperationConfig { - action: string - title: string - confirmText: string - confirmType?: 'warning' | 'error' | 'info' | 'success' - confirmButtonText: string - successText: string - failText: string - apiMethod: (...args: any[]) => Promise - payloadKey?: string - idField?: string | string[] - payloadBuilder?: (rows: Record[]) => Record - useProgress?: boolean - progressApiMethod?: (...args: any[]) => Promise -} - -/** ★ 在此配置批量操作 */ -export const BATCH_OPERATION_CONFIGS: Record = { - // batchExample: { - // action: 'batchExample', - // title: '批量操作示例', - // confirmText: '确定对选中的 {count} 项执行操作吗?', - // confirmType: 'warning', - // confirmButtonText: '确认操作', - // successText: '批量操作成功', - // failText: '批量操作失败', - // apiMethod: yourBatchApi, - // payloadKey: 'ids', - // idField: 'id' - // } -} - -// ============================================================ -// 十二、标签页注册表 — 打包流水(单页模式) -// ============================================================ -export const tabPages: TabPageRawConfig[] = [ - { - name: 'packing', - label: '打包任务', - scanBoxCacheKey: 'packingflow-list', - scanBoxFieldKeys: [ - 'warehouse_id', 'waybill_code', 'wave_no', 'order_id', 'workbench_id', - 'status', 'pack_mode', - 'start_time' - ], - tableColumnKeys: [ - 'id', 'order_id', 'waybill_code', 'wave_no', 'operator_text', - 'workbench_name', 'pack_quantity', 'pack_mode', 'status', - 'start_time', 'end_time', 'pack_duration', 'create_time', 'videos' - ], - upperTableDefaults: { - title: '打包任务列表', - showIndex: true, - showSelection: false, - emptyText: '暂无打包任务数据' - }, - detailTabs: [ - { name: 'detail', label: '任务明细', componentKey: 'DetailPanel' } - ], - detailSections: [ - { - title: '基础信息', - columnCount: 2, - fieldKeys: ['id', 'order_id', 'wave_no', 'waybill_code', 'operator_text', 'workbench_name', 'pack_quantity', 'pack_mode', 'status'] - }, - { - title: '时间信息', - columnCount: 2, - fieldKeys: ['start_time', 'end_time', 'pack_duration', 'create_time'] - } - ], - api: { - list: packingList as ApiMethod, - detail: packingGet as ApiMethod, - parseListResponse(res: any) { - const codeOk = [200, 20000, 1, 0].includes(res.code) - if (!codeOk) throw new Error(res.message || '查询失败') - const list = (res.data?.list ?? []).map((item: any) => ({ - ...item, - waybill_code: extractWaybillCode(item), - pack_duration: calcPackDuration(item.start_time, item.end_time) - })) - return { - list, - total: res.data?.pagination?.total ?? 0 - } - }, - buildListParams({ pagination, conditions, sort }) { - // warehouse_id 提到顶层,其余进入 where - const { warehouse_id, ...rest } = buildWhereConditions(conditions) - return { - warehouse_id: warehouse_id || undefined, - pagination: { page: pagination.page, pageSize: pagination.pageSize }, - where: rest, - sort: sort?.prop - ? { sortField: sort.prop, sortOrder: sort.order === 'ascending' ? 'ASC' : 'DESC' } - : { sortField: 'create_time', sortOrder: 'DESC' } - } - } - } - } -] - -// ============================================================ -// 十三、工具函数 -// ============================================================ - -/** - * 从 API 返回数据中提取运单号 - * 优先取顶层 waybill_code,若为空则从 expresses 数组中拼接 - */ -export function extractWaybillCode(row: any): string | null { - if (row.waybill_code) return row.waybill_code - if (row.expresses?.length) { - return row.expresses - .map((e: any) => e.waybill_code) - .filter(Boolean) - .join(',') - } - return null -} - -// ============================================================ -// 十四、向后兼容导出 -// ============================================================ -export const templateTabs = tabPages.map((t) => ({ name: t.name, label: t.label, scanBoxCacheKey: t.scanBoxCacheKey })) \ No newline at end of file diff --git a/src/views/data/newpackingflow/index.vue b/src/views/data/newpackingflow/index.vue deleted file mode 100644 index 481f0fba..00000000 --- a/src/views/data/newpackingflow/index.vue +++ /dev/null @@ -1,879 +0,0 @@ - - - - - - diff --git a/src/views/data/newpackingflow/pages/ExampleFormDialog.vue b/src/views/data/newpackingflow/pages/ExampleFormDialog.vue deleted file mode 100644 index 945481b8..00000000 --- a/src/views/data/newpackingflow/pages/ExampleFormDialog.vue +++ /dev/null @@ -1,107 +0,0 @@ - - - - - - diff --git a/src/views/inbox/autoReply/autoReply-config.ts b/src/views/inbox/autoReply/autoReply-config.ts index 7aa6440c..0c0959f1 100644 --- a/src/views/inbox/autoReply/autoReply-config.ts +++ b/src/views/inbox/autoReply/autoReply-config.ts @@ -2,7 +2,7 @@ import type { InboxV2SubTypeGroupItem, InboxV2SubTypeItem, InboxV2TypeItem, -} from '@/api/inbox/autoReply' +} from '@/api/inbox-2/autoReply' // ============================================================ // 自动回复设置 - 常量与选项 diff --git a/src/views/inbox/autoReply/components/FunctionPanel.vue b/src/views/inbox/autoReply/components/FunctionPanel.vue index f6f30bc7..23566c41 100644 --- a/src/views/inbox/autoReply/components/FunctionPanel.vue +++ b/src/views/inbox/autoReply/components/FunctionPanel.vue @@ -111,7 +111,7 @@ import { inboxV2RelationFunctionSet, unwrapInboxV2Data, type InboxV2FunctionItem, -} from '@/api/inbox/autoReply' +} from '@/api/inbox-2/autoReply' import { functionColumns } from '../autoReply-config' const props = defineProps<{ diff --git a/src/views/inbox/autoReply/components/GroupPanel.vue b/src/views/inbox/autoReply/components/GroupPanel.vue index f0a85b38..ef446866 100644 --- a/src/views/inbox/autoReply/components/GroupPanel.vue +++ b/src/views/inbox/autoReply/components/GroupPanel.vue @@ -109,7 +109,7 @@ import { inboxV2RelationGroupSet, unwrapInboxV2Data, type InboxV2SubTypeGroupItem, -} from '@/api/inbox/autoReply' +} from '@/api/inbox-2/autoReply' import { getGroupTypeOptions, getSubGroupOptions, diff --git a/src/views/inbox/autoReply/components/KeywordPanel.vue b/src/views/inbox/autoReply/components/KeywordPanel.vue index 3fbe41ea..b4ae715b 100644 --- a/src/views/inbox/autoReply/components/KeywordPanel.vue +++ b/src/views/inbox/autoReply/components/KeywordPanel.vue @@ -129,7 +129,7 @@ import { inboxV2KeywordUpdate, unwrapInboxV2Data, type InboxV2KeywordItem, -} from '@/api/inbox/autoReply' +} from '@/api/inbox-2/autoReply' import { isSystemRecord, keywordColumns, diff --git a/src/views/inbox/autoReply/components/NumberRulePanel.vue b/src/views/inbox/autoReply/components/NumberRulePanel.vue index 7bf41ece..b6694622 100644 --- a/src/views/inbox/autoReply/components/NumberRulePanel.vue +++ b/src/views/inbox/autoReply/components/NumberRulePanel.vue @@ -93,7 +93,7 @@ import { inboxV2RelationRuleSet, unwrapInboxV2Data, type InboxV2NumberRuleItem, -} from '@/api/inbox/autoReply' +} from '@/api/inbox-2/autoReply' import { numberRuleColumns, numberRuleTargetLabel } from '../autoReply-config' const props = defineProps<{ diff --git a/src/views/inbox/autoReply/components/ReplyPanel.vue b/src/views/inbox/autoReply/components/ReplyPanel.vue index c9166792..ad98ae0b 100644 --- a/src/views/inbox/autoReply/components/ReplyPanel.vue +++ b/src/views/inbox/autoReply/components/ReplyPanel.vue @@ -74,7 +74,7 @@ import { inboxV2ReplySave, unwrapInboxV2Data, type InboxV2MergedReplyItem, -} from '@/api/inbox/autoReply' +} from '@/api/inbox-2/autoReply' import { replyPlaceholders, toFlag } from '../autoReply-config' const props = defineProps<{ diff --git a/src/views/inbox/autoReply/components/SubTypeFormDialog.vue b/src/views/inbox/autoReply/components/SubTypeFormDialog.vue index 5cc9e2e6..396d2924 100644 --- a/src/views/inbox/autoReply/components/SubTypeFormDialog.vue +++ b/src/views/inbox/autoReply/components/SubTypeFormDialog.vue @@ -52,7 +52,7 @@ import { inboxV2SubTypeCreate, inboxV2SubTypeUpdate, type InboxV2SubTypeItem, -} from '@/api/inbox/autoReply' +} from '@/api/inbox-2/autoReply' import { toFlag } from '../autoReply-config' const props = defineProps<{ diff --git a/src/views/inbox/autoReply/components/TypeFormDialog.vue b/src/views/inbox/autoReply/components/TypeFormDialog.vue index 2677df8c..d932a9e3 100644 --- a/src/views/inbox/autoReply/components/TypeFormDialog.vue +++ b/src/views/inbox/autoReply/components/TypeFormDialog.vue @@ -43,7 +43,7 @@ import { inboxV2TypeCreate, inboxV2TypeUpdate, type InboxV2TypeItem, -} from '@/api/inbox/autoReply' +} from '@/api/inbox-2/autoReply' import { toFlag } from '../autoReply-config' const props = defineProps<{ diff --git a/src/views/inbox/autoReply/index.vue b/src/views/inbox/autoReply/index.vue index 9a6f102c..91d3bf63 100644 --- a/src/views/inbox/autoReply/index.vue +++ b/src/views/inbox/autoReply/index.vue @@ -332,7 +332,7 @@ import { unwrapInboxV2Data, type InboxV2SubTypeItem, type InboxV2TypeItem, -} from '@/api/inbox/autoReply' +} from '@/api/inbox-2/autoReply' import { isSystemRecord, subTypeColumns, diff --git a/src/views/material/packageMaterial2/components/ColumnCellRenderer.vue b/src/views/material/packageMaterial2/components/ColumnCellRenderer.vue deleted file mode 100644 index 8aa6b3a8..00000000 --- a/src/views/material/packageMaterial2/components/ColumnCellRenderer.vue +++ /dev/null @@ -1,65 +0,0 @@ - - - - - diff --git a/src/views/material/packageMaterial2/components/OperationCellRenderer.vue b/src/views/material/packageMaterial2/components/OperationCellRenderer.vue deleted file mode 100644 index a1190233..00000000 --- a/src/views/material/packageMaterial2/components/OperationCellRenderer.vue +++ /dev/null @@ -1,175 +0,0 @@ - - - - - - diff --git a/src/views/material/packageMaterial2/components/TabArea.vue b/src/views/material/packageMaterial2/components/TabArea.vue deleted file mode 100644 index 288ec6f1..00000000 --- a/src/views/material/packageMaterial2/components/TabArea.vue +++ /dev/null @@ -1,132 +0,0 @@ - - - - - diff --git a/src/views/material/packageMaterial2/config/components/DetailPanel.vue b/src/views/material/packageMaterial2/config/components/DetailPanel.vue deleted file mode 100644 index eb992d25..00000000 --- a/src/views/material/packageMaterial2/config/components/DetailPanel.vue +++ /dev/null @@ -1,159 +0,0 @@ - - - - - - diff --git a/src/views/material/packageMaterial2/config/components/LogPanel.vue b/src/views/material/packageMaterial2/config/components/LogPanel.vue deleted file mode 100644 index 0adae9f3..00000000 --- a/src/views/material/packageMaterial2/config/components/LogPanel.vue +++ /dev/null @@ -1,227 +0,0 @@ - - - - - - diff --git a/src/views/material/packageMaterial2/config/template-config.ts b/src/views/material/packageMaterial2/config/template-config.ts deleted file mode 100644 index fba881a9..00000000 --- a/src/views/material/packageMaterial2/config/template-config.ts +++ /dev/null @@ -1,727 +0,0 @@ -/** - * 【页面模板】配置文件 v2 — 基于 waveOrder2 架构设计 - * - * ===== 核心设计 ===== - * - * 1. FIELD_DICT — 全局字段预设表,每个字段拥有唯一翻译(label)和完整元数据 - * 2. VALUE_MAPS — 值翻译映射表(select options 和 tag 翻译共用) - * 3. TAG_RESOLVERS — 标签颜色解析器(集中管理 tag 颜色逻辑) - * 4. 各标签页通过 key 引用所需字段(scanBoxFieldKeys / tableColumnKeys) - * 5. resolveTabConfig() — 加载时将 key 列表展开为完整配置 - * - * ===== 快速上手 ===== - * 1. 复制整个 views/mode/ 文件夹,重命名为你的页面名 - * 2. 在 FIELD_DICT 中添加你需要的字段定义 - * 3. 在 tabPages 中配置标签页(引用 FIELD_DICT 的 key) - * 4. 在 TabPageApiConfig 中接入真实接口 - * 5. 在 router/map.ts 中添加路由 - */ - -import type { Component } from 'vue' -import DetailPanel from './components/DetailPanel.vue' -import LogPanel from './components/LogPanel.vue' - -// ============================================================ -// 〇、全局页面配置 -// ============================================================ -export const PAGE_CONFIG = { - /** 是否显示顶部多标签栏 */ - showTabArea: true, - /** 单页模式:不显示标签栏,仅一个标签页内容 */ - singlePage: false, - /** 是否启用详情面板(底部分栏 + 显示/隐藏详情按钮),false 时表格占满全高 */ - enableDetailPanel: true -} - -// ============================================================ -// 〇-A、组件注册表 — 所有可复用组件在此注册 -// ============================================================ -export const COMPONENT_REGISTRY: Record = { - DetailPanel, - LogPanel -} - -// ============================================================ -// 〇-B、SCANBOX_GROUPS — ScanBox 分组名称 -// ============================================================ -export const SCANBOX_GROUPS = { - basic: '基础信息', - process: '流程状态', - time: '时间范围', - custom: '自定义字段' -} as const - -// ============================================================ -// 一、FIELD_DICT — 全局字段预设表(唯一真相来源) -// ============================================================ -// 每个字段拥有: -// label — 唯一翻译文本 -// scanBox — ScanBox 渲染配置(type/options/group) -// table — 表格列配置(minWidth/fixed/align/sortable) -// slot — 单元格渲染配置(tag/tagResolver/translateField) -// detailLabel — 明细面板中的标签文本(可选,默认用 label) -// filterParamMap — ScanBox 筛选值 → API 传参值映射 - -export interface FieldDefinition { - key: string - label: string - scanBox: { - type: 'text' | 'select' | 'daterange' | 'number' - group?: string - options?: { label: string; value: any }[] - } | null - table: { - minWidth?: number - width?: number - fixed?: 'left' | 'right' | boolean - align?: 'left' | 'center' | 'right' - sortable?: boolean - showOverflowTooltip?: boolean - copyAction?: 'copy' | 'copyQr' - copyValue?: (row: any) => any - } | null - slot: { - type: 'tag' | 'text' | 'default' | 'operation' - tagType?: string | Record - tagResolver?: string - translateField?: string - format?: 'datetime' - } | null - detailLabel?: string - filterParamMap?: Record -} - -// ============================================================ -// VALUE_MAPS — 值翻译映射(select options 和 tag 翻译共用) -// ============================================================ -export const VALUE_MAPS: Record> = { - status: { 'pending': '待处理', 'processing': '处理中', 'done': '已完成', '待处理': '待处理', '处理中': '处理中', '已完成': '已完成' }, - type: { 'A': '类型A', 'B': '类型B', 'C': '类型C', '类型A': '类型A', '类型B': '类型B', '类型C': '类型C' }, - bool: { '1': '是', '0': '否', '是': '是', '否': '否' } -} - -/** 从 VALUE_MAPS 衍生 options(优先取中文值作为 option value) */ -export function getOptions(field: string): { label: string; value: string }[] { - const map = VALUE_MAPS[field] - if (!map) return [] - const seen = new Set() - const opts: { label: string; value: string }[] = [] - const chineseKeys: [string, string][] = [] - const otherKeys: [string, string][] = [] - for (const [v, l] of Object.entries(map)) { - if (/^[\u4e00-\u9fa5]/.test(v)) { - chineseKeys.push([v, l]) - } else { - otherKeys.push([v, l]) - } - } - for (const [v, l] of [...chineseKeys, ...otherKeys]) { - if (!seen.has(l)) { - seen.add(l) - opts.push({ label: l, value: v }) - } - } - return opts -} - -/** 翻译 value → label */ -export function translate(field: string, value: any): string { - const map = VALUE_MAPS[field] - if (!map) return String(value ?? '—') - return map[String(value)] ?? String(value ?? '—') -} - -/** 格式化时间戳为 YYYY-MM-DD HH:mm:ss */ -export function formatTime(value: any): string { - if (!value) return '—' - try { - const d = new Date(value) - if (isNaN(d.getTime())) return String(value) - const pad = (n: number) => String(n).padStart(2, '0') - return `${d.getFullYear()}-${pad(d.getMonth() + 1)}-${pad(d.getDate())} ${pad(d.getHours())}:${pad(d.getMinutes())}:${pad(d.getSeconds())}` - } catch { - return String(value) - } -} - -// ============================================================ -// TAG_RESOLVERS — 标签颜色解析器 -// ============================================================ -// 颜色规则:未xx=info(灰) 已xx=success(绿) xx中/部分xx=warning(黄) 错误=danger(红) -export const TAG_RESOLVERS: Record string> = { - resolveStatusTag(v) { - if (!v) return 'info' - if (v === '已完成' || v === 'done') return 'success' - if (v === '处理中' || v === 'processing') return 'warning' - return 'info' - }, - resolveBoolTag(v) { - if (v === undefined || v === null) return 'info' - if (v === '是' || v === true || v === 1 || v === '1') return 'success' - return 'info' - } -} - -// ============================================================ -// 二、FIELD_DICT 实例 — 在此定义页面所需的所有字段 -// ============================================================ -export const FIELD_DICT: Record = { - code: { - key: 'code', - label: '编号', - scanBox: { type: 'text', group: SCANBOX_GROUPS.basic }, - table: { minWidth: 160, fixed: 'left', copyAction: 'copy', showOverflowTooltip: true }, - slot: null, - detailLabel: '编号' - }, - name: { - key: 'name', - label: '名称', - scanBox: { type: 'text', group: SCANBOX_GROUPS.basic }, - table: { minWidth: 150, showOverflowTooltip: true }, - slot: null, - detailLabel: '名称' - }, - type: { - key: 'type', - label: '类型', - scanBox: { type: 'select', group: SCANBOX_GROUPS.basic, options: getOptions('type') }, - table: { minWidth: 100, align: 'center' }, - slot: { type: 'tag', tagType: 'info', translateField: 'type' }, - detailLabel: '类型', - filterParamMap: { '类型A': 'A', '类型B': 'B', '类型C': 'C' } - }, - status: { - key: 'status', - label: '状态', - scanBox: { type: 'select', group: SCANBOX_GROUPS.process, options: getOptions('status') }, - table: { minWidth: 100, align: 'center' }, - slot: { type: 'tag', tagResolver: 'resolveStatusTag', translateField: 'status' }, - detailLabel: '状态', - filterParamMap: { '待处理': 'pending', '处理中': 'processing', '已完成': 'done' } - }, - count: { - key: 'count', - label: '数量', - scanBox: null, - table: { minWidth: 80, align: 'center', sortable: true }, - slot: null - }, - amount: { - key: 'amount', - label: '金额(元)', - scanBox: null, - table: { minWidth: 110, align: 'center', sortable: true }, - slot: null - }, - creator: { - key: 'creator', - label: '创建人', - scanBox: { type: 'text', group: SCANBOX_GROUPS.basic }, - table: { minWidth: 100 }, - slot: null, - detailLabel: '创建人' - }, - create_time: { - key: 'create_time', - label: '创建时间', - scanBox: { type: 'daterange', group: SCANBOX_GROUPS.time }, - table: { minWidth: 170, sortable: true }, - slot: { type: 'text', format: 'datetime' }, - detailLabel: '创建时间' - }, - update_time: { - key: 'update_time', - label: '更新时间', - scanBox: { type: 'daterange', group: SCANBOX_GROUPS.time }, - table: { minWidth: 170, sortable: true }, - slot: { type: 'text', format: 'datetime' }, - detailLabel: '更新时间' - }, - /** 操作列(虚拟字段,仅用于表格列渲染) */ - operation: { - key: 'operation', - label: '操作', - scanBox: null, - table: { minWidth: 180, fixed: 'right', align: 'center' }, - slot: { type: 'operation' } - } -} - -// ============================================================ -// 三、ColumnSlotConfig — 列单元格渲染配置 -// ============================================================ -export interface ColumnSlotConfig { - type: 'tag' | 'text' | 'default' | 'operation' - tagType?: string | Record - tagResolver?: string - translateField?: string - format?: 'datetime' -} - -// ============================================================ -// 三-A、OperationButtonConfig — 操作列按钮配置 -// ============================================================ -export interface OperationButtonConfig { - key: string - label: string - type?: 'primary' | 'success' | 'warning' | 'danger' | 'info' | '' - actionType: 'form' | 'action' - formKey?: string - formTitle?: string - formWidth?: string - paramMap?: Record - extraParams?: Record - disabledOnField?: string - confirmMessage?: string - confirmTitle?: string - confirmType?: 'warning' | 'danger' | 'info' - confirmButtonText?: string -} - -// ============================================================ -// 四、DetailFieldConfig / DetailSectionConfig — 明细面板配置 -// ============================================================ -export interface DetailFieldConfig { - key: string - label?: string - span?: number - renderType?: 'text' | 'tag' | 'pre' - tagType?: string | Record - tagResolver?: string - translateField?: string -} - -export interface DetailSectionConfig { - title: string - columnCount: number - fields: DetailFieldConfig[] -} - -export interface DetailTabConfig { - name: string - label: string - componentKey: string - component?: Component -} - -// ============================================================ -// 五、TabPageApiConfig — 标签页接口插槽配置 -// ============================================================ -export type ApiMethod = (...args: any[]) => Promise -export type ApiSource = 'api' | 'list' -export type ComponentApiConfig = { source: 'list' } | ApiMethod - -export interface TabPageApiConfig { - /** 列表查询接口 */ - list: ApiMethod - /** 明细面板接口(可选,不配则用 row 数据) */ - detail?: ComponentApiConfig - /** 操作日志接口(可选) */ - log?: ComponentApiConfig - /** 导出接口(可选) */ - export?: ApiMethod - /** 导出进度查询接口(可选) */ - exportProgress?: ApiMethod - /** ScanBox 下拉选项数据源接口(可选) */ - scanBoxOptions?: Record - /** 工具栏按钮 → API 方法映射(可选) */ - toolbar?: Record - /** 列表响应解析器 */ - parseListResponse?: (res: any) => { list: any[]; total: number } - /** 构建列表请求参数 */ - buildListParams?: (params: { - pagination: { page: number; pageSize: number } - conditions: Record - sort?: { prop: string; order: string } - }) => Record -} - -// ============================================================ -// 六、TabPageRawConfig — 标签页声明配置(仅用 key 引用) -// ============================================================ -export interface TabPageRawConfig { - name: string - label: string - scanBoxCacheKey: string - /** ScanBox 需要的字段 key 列表(从 FIELD_DICT 中查找) */ - scanBoxFieldKeys: string[] - /** 表格需要的列 key 列表(从 FIELD_DICT 中查找) */ - tableColumnKeys: string[] - upperTableDefaults: { - title: string - enableColumnConfig?: boolean - showIndex?: boolean - showSelection?: boolean - emptyText?: string - } - /** 明细面板标签页配置 */ - detailTabs?: { name: string; label: string; componentKey: string }[] - /** 明细面板分区配置(字段 key 列表,resolveTabConfig 展开) */ - detailSections: { - title: string - columnCount: number - fieldKeys: string[] - }[] - /** 接口配置(有 api 时启用真实接口) */ - api?: TabPageApiConfig - /** 操作列按钮配置(需 tableColumnKeys 包含 'operation') */ - operationButtons?: OperationButtonConfig[] -} - -// ============================================================ -// 七、TabPageConfig — 展开后的完整配置(给 index.vue 使用) -// ============================================================ -export interface TabPageConfig { - name: string - label: string - scanBoxCacheKey: string - scanBoxFields: Record[] - upperTable: { - title: string - enableColumnConfig: boolean - showIndex: boolean - showSelection: boolean - emptyText: string - columns: Record[] - } - columnSlots: Record - detailConfig: DetailSectionConfig[] - detailTabs: DetailTabConfig[] - api?: TabPageApiConfig - operationButtons?: OperationButtonConfig[] -} - -// ============================================================ -// 八、resolveTabConfig — 加载时将 RawConfig 展开为完整配置 -// ============================================================ -export function resolveTabConfig(raw: TabPageRawConfig): TabPageConfig { - // 展开 ScanBox 字段 - const scanBoxFields: Record[] = [] - for (const key of raw.scanBoxFieldKeys) { - const def = FIELD_DICT[key] - if (!def || !def.scanBox) continue - scanBoxFields.push({ - label: def.label, - value: def.key, - type: def.scanBox.type, - options: def.scanBox.options ? [...def.scanBox.options] : undefined, - group: def.scanBox.group, - required: (def.scanBox as any).required - }) - } - - // 展开表格列 - const columns: Record[] = [] - for (const key of raw.tableColumnKeys) { - const def = FIELD_DICT[key] - if (!def || !def.table) continue - columns.push({ - prop: def.key, - label: def.label, - ...def.table - }) - } - - // 展开列插槽 - const columnSlots: Record = {} - for (const key of raw.tableColumnKeys) { - const def = FIELD_DICT[key] - if (!def || !def.slot) continue - columnSlots[def.key] = { ...def.slot } - } - - // 展开明细面板配置 - const detailConfig: DetailSectionConfig[] = raw.detailSections.map((sec) => ({ - title: sec.title, - columnCount: sec.columnCount, - fields: sec.fieldKeys - .map((key): DetailFieldConfig | null => { - const def = FIELD_DICT[key] - if (!def) return null - return { - key: def.key, - label: def.detailLabel ?? def.label, - translateField: def.slot?.translateField, - tagResolver: def.slot?.tagResolver, - tagType: def.slot?.tagType, - renderType: def.slot?.type === 'tag' ? 'tag' : 'text' - } - }) - .filter((f): f is DetailFieldConfig => f !== null) - })) - - // 展开明细标签页(解析 componentKey → Component) - const detailTabs: DetailTabConfig[] = raw.detailTabs - ? raw.detailTabs.map((tab) => ({ - name: tab.name, - label: tab.label, - componentKey: tab.componentKey, - component: COMPONENT_REGISTRY[tab.componentKey] - })) - : [{ name: 'detail', label: '明细', componentKey: 'DetailPanel', component: COMPONENT_REGISTRY['DetailPanel'] }] - - return { - name: raw.name, - label: raw.label, - scanBoxCacheKey: raw.scanBoxCacheKey, - scanBoxFields, - upperTable: { - title: raw.upperTableDefaults.title, - enableColumnConfig: raw.upperTableDefaults.enableColumnConfig ?? true, - showIndex: raw.upperTableDefaults.showIndex ?? true, - showSelection: raw.upperTableDefaults.showSelection ?? true, - emptyText: raw.upperTableDefaults.emptyText ?? '暂无数据', - columns - }, - columnSlots, - detailConfig, - detailTabs, - api: raw.api, - operationButtons: raw.operationButtons - } -} - -// ============================================================ -// 九、buildWhereConditions — 将 ScanBox 条件转为 API where 参数 -// ============================================================ -export function buildWhereConditions(rawConditions: Record): Record { - const where: Record = {} - for (const [key, cond] of Object.entries(rawConditions || {})) { - let value: any = undefined - if (cond && typeof cond === 'object' && 'operator' in cond) { - value = (cond as any).value - } else if (cond !== undefined && cond !== null && cond !== '') { - value = Array.isArray(cond) ? cond[0] ?? '' : cond - } - if (value === undefined || value === null || value === '' || (Array.isArray(value) && value.length === 0)) { - continue - } - const def = FIELD_DICT[key] - if (def?.filterParamMap) { - const mapped = def.filterParamMap[String(value)] - if (mapped !== undefined) { - where[key] = mapped - continue - } - } - where[key] = value - } - return where -} - -// ============================================================ -// 十、工具栏按钮系统 -// ============================================================ -// 按钮分为三类: -// common — 公共按钮(刷新、导出) -// function — 功能按钮(打开表单/确认窗口) -// basic — 基础操作(字段设置、隐藏详情) - -export interface ToolbarButtonConfig { - key: string - label: string - category: 'common' | 'function' | 'basic' - size?: '' | 'default' | 'small' | 'large' - type?: '' | 'primary' | 'success' | 'warning' | 'info' | 'danger' - plain?: boolean - loadingKey?: string - disabledKey?: string - action: string - dynamicLabelKey?: string - onlyForTabs?: string[] - buttonType?: 'default' | 'dropdown' - dropdownOptions?: Array<{ label: string; action: string; divided?: boolean }> - formKey?: string -} - -export const TOOLBAR_BUTTONS: Record = { - // ===== 公共按钮 ===== - refresh: { - key: 'refresh', - label: '刷新', - category: 'common', - type: 'primary', - size: 'small', - loadingKey: 'loading', - action: 'loadData' - }, - export: { - key: 'export', - label: '导出', - category: 'common', - size: 'small', - loadingKey: 'exportLoading', - action: 'handleExport', - buttonType: 'dropdown', - dropdownOptions: [ - { label: '不含明细', action: 'handleExport' }, - { label: '含明细', action: 'handleExportItem', divided: true } - ] - }, - // ===== 基础操作 ===== - columnConfig: { - key: 'columnConfig', - label: '字段设置', - category: 'basic', - size: 'small', - action: 'openColumnConfigPanel' - }, - toggleDetail: { - key: 'toggleDetail', - label: '显示详情', - category: 'basic', - dynamicLabelKey: 'detailToggleLabel', - size: 'small', - action: 'toggleDetailVisible' - } - // ★ 在此添加功能按钮(如批量操作)★ -} - -/** 按标签页名称获取工具栏按钮列表(自动根据 PAGE_CONFIG 过滤) */ -export function getTabToolbarButtons(tabName: string): ToolbarButtonConfig[] { - return Object.values(TOOLBAR_BUTTONS).filter((btn) => { - if (btn.onlyForTabs && !btn.onlyForTabs.includes(tabName)) return false - // 详情面板禁用时,隐藏「显示/隐藏详情」按钮 - if (!PAGE_CONFIG.enableDetailPanel && btn.key === 'toggleDetail') return false - return true - }) -} - -// ============================================================ -// 十一、批量操作配置(可选,接入 BatchOperationForm 时使用) -// ============================================================ -export interface BatchOperationConfig { - action: string - title: string - confirmText: string - confirmType?: 'warning' | 'error' | 'info' | 'success' - confirmButtonText: string - successText: string - failText: string - apiMethod: (...args: any[]) => Promise - payloadKey?: string - idField?: string | string[] - payloadBuilder?: (rows: Record[]) => Record - useProgress?: boolean - progressApiMethod?: (...args: any[]) => Promise -} - -/** ★ 在此配置批量操作 */ -export const BATCH_OPERATION_CONFIGS: Record = { - // batchExample: { - // action: 'batchExample', - // title: '批量操作示例', - // confirmText: '确定对选中的 {count} 项执行操作吗?', - // confirmType: 'warning', - // confirmButtonText: '确认操作', - // successText: '批量操作成功', - // failText: '批量操作失败', - // apiMethod: yourBatchApi, - // payloadKey: 'ids', - // idField: 'id' - // } -} - -// ============================================================ -// 十二、标签页注册表 — 在此定义你的页面标签页 -// ============================================================ -export const tabPages: TabPageRawConfig[] = [ - // ===== 示例标签页一 ===== - { - name: 'tab1', - label: '标签页一', - scanBoxCacheKey: 'template-tab1', - scanBoxFieldKeys: ['code', 'type', 'status', 'creator', 'create_time'], - tableColumnKeys: ['code', 'name', 'type', 'status', 'count', 'amount', 'creator', 'create_time', 'operation'], - upperTableDefaults: { - title: '示例列表一', - showSelection: true - }, - detailTabs: [ - { name: 'detail', label: '明细', componentKey: 'DetailPanel' }, - { name: 'log', label: '操作日志', componentKey: 'LogPanel' } - ], - detailSections: [ - { - title: '基础信息', - columnCount: 3, - fieldKeys: ['code', 'name', 'type', 'status', 'count', 'amount', 'creator'] - }, - { - title: '时间信息', - columnCount: 2, - fieldKeys: ['create_time', 'update_time'] - } - ], - /** ★ 接入真实接口时取消注释 */ - // api: { - // list: yourListApi, - // detail: { source: 'list' }, - // parseListResponse(res) { - // return { list: res.data?.list ?? [], total: res.data?.pagination?.total ?? 0 } - // }, - // buildListParams({ pagination, conditions, sort }) { - // return { - // page: pagination.page, - // pageSize: pagination.pageSize, - // where: buildWhereConditions(conditions), - // ...(sort?.prop ? { sortField: sort.prop, sortOrder: sort.order === 'ascending' ? 'ASC' : 'DESC' } : {}) - // } - // } - // }, - operationButtons: [ - { - key: 'viewDetail', - label: '查看详情', - actionType: 'action', - type: 'primary' - }, - { - key: 'edit', - label: '编辑', - actionType: 'action', - type: 'warning' - } - ] - }, - - // ===== 示例标签页二 ===== - { - name: 'tab2', - label: '标签页二', - scanBoxCacheKey: 'template-tab2', - scanBoxFieldKeys: ['code', 'status', 'create_time'], - tableColumnKeys: ['code', 'name', 'status', 'count', 'creator', 'create_time', 'operation'], - upperTableDefaults: { - title: '示例列表二', - showSelection: true - }, - detailSections: [ - { - title: '基础信息', - columnCount: 3, - fieldKeys: ['code', 'name', 'status', 'count', 'creator'] - }, - { - title: '时间信息', - columnCount: 2, - fieldKeys: ['create_time', 'update_time'] - } - ], - operationButtons: [ - { - key: 'viewDetail', - label: '查看详情', - actionType: 'action', - type: 'primary' - } - ] - } -] - -// ============================================================ -// 十三、向后兼容导出 -// ============================================================ -export const templateTabs = tabPages.map((t) => ({ name: t.name, label: t.label, scanBoxCacheKey: t.scanBoxCacheKey })) - diff --git a/src/views/material/packageMaterial2/index.vue b/src/views/material/packageMaterial2/index.vue deleted file mode 100644 index 95de6a12..00000000 --- a/src/views/material/packageMaterial2/index.vue +++ /dev/null @@ -1,854 +0,0 @@ - - - - - - diff --git a/src/views/material/packageMaterial2/pages/ExampleFormDialog.vue b/src/views/material/packageMaterial2/pages/ExampleFormDialog.vue deleted file mode 100644 index 945481b8..00000000 --- a/src/views/material/packageMaterial2/pages/ExampleFormDialog.vue +++ /dev/null @@ -1,107 +0,0 @@ - - - - - - diff --git a/src/views/order/waveOrder/config/wave-config.ts b/src/views/order/waveOrder/config/wave-config.ts index a7de76e5..a0cf0758 100644 --- a/src/views/order/waveOrder/config/wave-config.ts +++ b/src/views/order/waveOrder/config/wave-config.ts @@ -23,6 +23,7 @@ import { parseOrderDetailPayload, parseOrderListResponse } from '@/views/order/orderManagement/utils/order-index-helpers' +import { resolveRowBarcode } from '@/utils/barcode' /** ScanBox 筛选字段分组(波次模块专用,策略/散单候选等页仍可使用) */ export const WAVE_SCAN_FIELD_GROUPS = { @@ -1608,6 +1609,8 @@ function mapPendingOrderItemsToPrintDetails(items: Record[]) { const itemCode = resolvePrintLineField(item, snap, 'item_code') const itemName = resolvePrintLineField(item, snap, 'item_name') const unitPrice = resolvePrintLineField(item, snap, 'actual_price', 'retail_price', 'price', 'unit_price') + // 商品条码:模板「商品明细」条码列(field_code=barcode)取值,兼容 barcode 单值与 barcodes 数组 + const barcode = resolveRowBarcode(item, snap) return { item_snapshot: { @@ -1619,7 +1622,7 @@ function mapPendingOrderItemsToPrintDetails(items: Record[]) { }, item_code: itemCode, item_name: itemName, - barcode: resolvePrintLineField(item, snap, 'barcode'), + barcode: barcode || SNAPSHOT_EMPTY_LABEL, sku_property: resolvePrintLineField(item, snap, 'sku_property', 'ext_code'), goods_code: resolvePrintLineField(item, snap, 'goods_code'), brand_name: resolvePrintLineField(item, snap, 'brand_name'), diff --git a/src/views/order/waveOrder/index.vue b/src/views/order/waveOrder/index.vue index 6462db9f..a6247fc8 100644 --- a/src/views/order/waveOrder/index.vue +++ b/src/views/order/waveOrder/index.vue @@ -98,7 +98,7 @@ import FallbackOrderListPanel from './FallbackOrderListPanel.vue' import WaveStrategyListPanel from './WaveStrategyListPanel.vue' import WavePickTaskListPanel from './WavePickTaskListPanel.vue' import { safeInvoke } from '@/utils/safe-invoke' -import { orderWaveConfirmPrintScan, orderWaveConfirmPrintUnclaimedWaveCount } from '@/api/order.wave/orderwave' +import { orderWaveConfirmPrintScan, orderWaveConfirmPrintUnclaimedWaveCount } from '@/api/order/order' import { useBarcodeScan } from '@/composables/useBarcodeScan' import { WAVE_PAGE_CONFIG } from './config/wave-config' diff --git a/src/views/order/waveOrder2/components/ColumnCellRenderer.vue b/src/views/order/waveOrder2/components/ColumnCellRenderer.vue deleted file mode 100644 index 5ec3e208..00000000 --- a/src/views/order/waveOrder2/components/ColumnCellRenderer.vue +++ /dev/null @@ -1,55 +0,0 @@ - - - diff --git a/src/views/order/waveOrder2/components/TabArea.vue b/src/views/order/waveOrder2/components/TabArea.vue deleted file mode 100644 index 9d030853..00000000 --- a/src/views/order/waveOrder2/components/TabArea.vue +++ /dev/null @@ -1,141 +0,0 @@ - - - - - diff --git a/src/views/order/waveOrder2/components/public/DetailPanel.vue b/src/views/order/waveOrder2/components/public/DetailPanel.vue deleted file mode 100644 index 6b9ad9f4..00000000 --- a/src/views/order/waveOrder2/components/public/DetailPanel.vue +++ /dev/null @@ -1,168 +0,0 @@ - - - - - diff --git a/src/views/order/waveOrder2/components/public/LogPanel.vue b/src/views/order/waveOrder2/components/public/LogPanel.vue deleted file mode 100644 index 1c24efce..00000000 --- a/src/views/order/waveOrder2/components/public/LogPanel.vue +++ /dev/null @@ -1,204 +0,0 @@ - - - - - diff --git a/src/views/order/waveOrder2/components/public/OperationCellRenderer.vue b/src/views/order/waveOrder2/components/public/OperationCellRenderer.vue deleted file mode 100644 index 2354fd12..00000000 --- a/src/views/order/waveOrder2/components/public/OperationCellRenderer.vue +++ /dev/null @@ -1,171 +0,0 @@ - - - - - - diff --git a/src/views/order/waveOrder2/config/waveorder-config.ts b/src/views/order/waveOrder2/config/waveorder-config.ts deleted file mode 100644 index 4f830b2c..00000000 --- a/src/views/order/waveOrder2/config/waveorder-config.ts +++ /dev/null @@ -1,1563 +0,0 @@ -/** - * waveOrder2 页面配置文件 v3 - * - * ===== 核心设计 ===== - * - * 1. FIELD_DICT — 全局字段预设表,每个字段拥有唯一翻译(label)和完整元数据 - * 2. 各标签页通过 key 引用所需字段(scanBoxFieldKeys / tableColumnKeys) - * 3. resolveTabConfig() — 加载时将 key 列表展开为完整配置,注入 index.vue - * - * 优势: - * - 字段定义集中管理,一处修改全局生效 - * - 页面只声明"我需要哪些字段",无需关心渲染细节 - * - 新增字段只需在 FIELD_DICT 追加,页面引用 key 即可 - */ - -import type { Component } from 'vue' -import DetailPanel from '../components/public/DetailPanel.vue' -import LogPanel from '../components/public/LogPanel.vue' -import { orderWaveBatchList, unwrapWaveBatchListResponse } from '@/api/order/order' -import type { WaveBatchListParams, WaveBatchListResponse } from '@/api/order/order' - -// ============================================================ -// 〇、组件注册表 — 所有可用组件在此注册,页面按 key 引用 -// ============================================================ -// 新增组件步骤:1. import 组件 2. 在 COMPONENT_REGISTRY 添加一条 3. 页面通过 key 引用 - -export const COMPONENT_REGISTRY: Record = { - DetailPanel, - LogPanel -} -// 每个字段拥有: -// label — 唯一翻译文本 -// scanBox — ScanBox 渲染配置(type/options/group/required) -// table — 表格列配置(minWidth/fixed/align/sortable) -// slot — 单元格渲染配置(tag/tagResolver/translateField) -// detailLabel — 明细面板中的标签文本(可选,默认用 label) -// filterParamMap — ScanBox 筛选值 → API 传参值映射(如 '团购'→'1') - -export interface FieldDefinition { - /** 字段唯一标识(作为 key 使用) */ - key: string - /** 字段唯一翻译文本 */ - label: string - /** ScanBox 筛选配置(null 表示不可筛选) */ - scanBox: { - type: 'text' | 'select' | 'daterange' | 'number' - group?: string - options?: { label: string; value: any }[] - required?: boolean - extraAction?: { label: string; action: string } - } | null - /** 表格列配置(null 表示不作为列显示) */ - table: { - minWidth?: number - width?: number - fixed?: 'left' | 'right' | boolean - align?: 'left' | 'center' | 'right' - sortable?: boolean - showOverflowTooltip?: boolean - /** UpperTable 点击复制:'copy' 仅复制;'copyQr' 复制并弹出二维码 */ - copyAction?: 'copy' | 'copyQr' - /** 自定义复制内容函数(row → 复制文本) */ - copyValue?: (row: any) => any - } | null - /** 单元格渲染配置(null 表示默认文本渲染) */ - slot: { - type: 'tag' | 'text' | 'default' | 'operation' - /** 固定 tag 颜色 或 值→颜色映射表 */ - tagType?: string | Record - /** tagResolver 函数名(查 TAG_RESOLVERS) */ - tagResolver?: string - /** 从 VALUE_MAPS 翻译显示文本 */ - translateField?: string - /** 格式化类型:'datetime' 将时间戳转为 YYYY-MM-DD HH:mm:ss */ - format?: 'datetime' - } | null - /** 明细面板标签文本(不设则用 label) */ - detailLabel?: string - /** ScanBox 筛选选项值 → API 传参值映射(如 '团购'→'1');未配置则原值传递 */ - filterParamMap?: Record -} - -// ============================================================ -// ScanBox 分组名称 -// ============================================================ -export const SCANBOX_GROUPS = { - basic: '基础信息', - process: '流程状态', - logistics: '物流信息', - time: '时间范围', - custom: '自定义字段' -} as const - -// ============================================================ -// VALUE_MAPS — 值翻译映射(select options 和 tag 翻译共用) -// ============================================================ -export const VALUE_MAPS: Record> = { - wave_type: { '1': '团购', '2': '散单', '团购': '团购', '散单': '散单' }, - wave_status: { '0': '自动加团中', '1': '已就绪', '自动加团中': '自动加团中', '已就绪': '已就绪' }, - distinguish_express: { '1': '是', '0': '否', '是': '是', '否': '否' }, - storage_assignment_status: { '未分配': '未分配', '已分配': '已分配', '部分分配': '部分分配' }, - express_assignment_status: { 'assigned': '已分配', 'unassigned': '未分配', '已分配': '已分配', '未分配': '未分配' }, - print_assignment_status: { 'printed': '已打印', 'unprinted': '未打印', '已打印': '已打印', '未打印': '未打印' }, - pick_assignment_status: { '未拣货': '未拣货', '部分拣货': '部分拣货', '已拣货': '已拣货' }, - review_assignment_status: { 'reviewed': '已复核', 'unreviewed': '未复核', '已复核': '已复核', '未复核': '未复核' }, - order_status: { 'pending': '待处理', 'processing': '处理中', 'done': '已完成' } -} - -/** 从 VALUE_MAPS 衍生 options(优先取中文值作为 option value) */ -export function getOptions(field: string): { label: string; value: string }[] { - const map = VALUE_MAPS[field] - if (!map) return [] - const seen = new Set() - const opts: { label: string; value: string }[] = [] - // 先收集中文 key(如 '团购'→'团购'),后收集数字 key(如 '1'→'团购') - const chineseKeys: [string, string][] = [] - const otherKeys: [string, string][] = [] - for (const [v, l] of Object.entries(map)) { - if (/^[\u4e00-\u9fa5]/.test(v)) { - chineseKeys.push([v, l]) - } else { - otherKeys.push([v, l]) - } - } - for (const [v, l] of [...chineseKeys, ...otherKeys]) { - if (!seen.has(l)) { - seen.add(l) - opts.push({ label: l, value: v }) - } - } - return opts -} - -/** 翻译 value → label */ -export function translate(field: string, value: any): string { - const map = VALUE_MAPS[field] - if (!map) return String(value ?? '—') - return map[String(value)] ?? String(value ?? '—') -} - -/** 格式化时间戳为 YYYY-MM-DD HH:mm:ss */ -export function formatTime(value: any): string { - if (!value) return '—' - try { - const d = new Date(value) - if (isNaN(d.getTime())) return String(value) - const pad = (n: number) => String(n).padStart(2, '0') - return `${d.getFullYear()}-${pad(d.getMonth() + 1)}-${pad(d.getDate())} ${pad(d.getHours())}:${pad(d.getMinutes())}:${pad(d.getSeconds())}` - } catch { - return String(value) - } -} - -// ============================================================ -// ============================================================ -// TAG_RESOLVERS — 标签颜色解析器 -// ============================================================ -// 颜色规则:未xx=info(灰) 已xx=success(绿) xx中/部分xx=warning(黄) 错误=danger(红) -// ============================================================ -export const TAG_RESOLVERS: Record string> = { - resolveAssignTag(v) { - if (!v) return 'info' - if (v === '已分配' || v === 'assigned') return 'success' - if (v === '部分分配' || v === 'partial') return 'warning' - return 'info' // 未分配 → 灰 - }, - resolvePrintTag(v) { - if (!v) return 'info' - return v === '已打印' || v === 'printed' ? 'success' : 'info' // 未打印 → 灰 - }, - resolvePickTag(v) { - if (!v) return 'info' - if (v === '已拣货') return 'success' - if (v === '部分拣货') return 'warning' - return 'info' // 未拣货 → 灰 - }, - resolveReviewTag(v) { - if (!v) return 'info' - return v === '已复核' || v === 'reviewed' ? 'success' : 'info' // 未复核 → 灰 - }, - resolveWaveStatusTag(v) { - if (!v) return 'info' - if (v === '已就绪' || v === '1') return 'success' - if (v === '自动加团中' || v === '0') return 'warning' // 进行中 → 黄 - return 'info' - }, - resolveBoolTag(v) { - if (v === undefined || v === null) return 'info' - if (v === '是' || v === true || v === 1 || v === '1') return 'warning' - return 'info' - } -} - -// ============================================================ -// 二、FIELD_DICT — 全局字段预设表(唯一真相来源) -// ============================================================ -export const FIELD_DICT: Record = { - // ---- 基础信息 ---- - wave_no: { - key: 'wave_no', - label: '波次编号', - scanBox: { type: 'text', group: SCANBOX_GROUPS.basic }, - table: { minWidth: 180, fixed: 'left', copyAction: 'copy', showOverflowTooltip: true }, - slot: null, - detailLabel: '波次编号' - }, - wave_type: { - key: 'wave_type', - label: '波次类型', - scanBox: { type: 'select', group: SCANBOX_GROUPS.basic, options: getOptions('wave_type') }, - table: { minWidth: 96, align: 'center' }, - slot: { type: 'tag', tagType: 'info', translateField: 'wave_type' }, - detailLabel: '波次类型', - filterParamMap: { '团购': '1', '散单': '2' } - }, - wave_status: { - key: 'wave_status', - label: '波次状态', - scanBox: { type: 'select', group: SCANBOX_GROUPS.basic, options: getOptions('wave_status') }, - table: { minWidth: 110, align: 'center' }, - slot: { type: 'tag', tagResolver: 'resolveWaveStatusTag', translateField: 'wave_status' }, - detailLabel: '波次状态', - filterParamMap: { '自动加团中': '0', '已就绪': '1' } - }, - total_orders: { - key: 'total_orders', - label: '总订单数', - scanBox: null, - table: { minWidth: 110, align: 'center', sortable: true }, - slot: null - }, - order_count: { - key: 'order_count', - label: '订单数量', - scanBox: null, - table: { minWidth: 100, align: 'center', sortable: true }, - slot: null - }, - processed_orders: { - key: 'processed_orders', - label: '已处理订单', - scanBox: null, - table: { minWidth: 108, align: 'center', sortable: true }, - slot: null - }, - distinguish_express: { - key: 'distinguish_express', - label: '区分快递', - scanBox: { type: 'select', group: SCANBOX_GROUPS.basic, options: getOptions('distinguish_express') }, - table: { minWidth: 100, align: 'center' }, - slot: { type: 'tag', tagResolver: 'resolveBoolTag', translateField: 'distinguish_express' }, - detailLabel: '区分快递', - filterParamMap: { '是': '1', '否': '0' } - }, - logistics_name: { - key: 'logistics_name', - label: '快递', - scanBox: { type: 'text', group: SCANBOX_GROUPS.basic }, - table: { minWidth: 120, showOverflowTooltip: true }, - slot: null, - detailLabel: '快递' - }, - creator: { - key: 'creator', - label: '创建人', - scanBox: { type: 'text', group: SCANBOX_GROUPS.basic }, - table: { minWidth: 100 }, - slot: null, - detailLabel: '创建人' - }, - warehouse_id: { - key: 'warehouse_id', - label: '仓库ID', - scanBox: null, - table: { minWidth: 110, align: 'center' }, - slot: null, - detailLabel: '仓库ID' - }, - create_time: { - key: 'create_time', - label: '创建时间', - scanBox: { type: 'daterange', group: SCANBOX_GROUPS.time }, - table: { minWidth: 168, sortable: true }, - slot: { type: 'text', format: 'datetime' }, - detailLabel: '创建时间' - }, - update_time: { - key: 'update_time', - label: '更新时间', - scanBox: { type: 'daterange', group: SCANBOX_GROUPS.time }, - table: { minWidth: 168, sortable: true }, - slot: { type: 'text', format: 'datetime' }, - detailLabel: '更新时间' - }, - - // ---- 流程状态 ---- - storage_assignment_status: { - key: 'storage_assignment_status', - label: '库位分配', - scanBox: { type: 'select', group: SCANBOX_GROUPS.process, options: getOptions('storage_assignment_status') }, - table: { minWidth: 120, align: 'center' }, - slot: { type: 'tag', tagResolver: 'resolveAssignTag', translateField: 'storage_assignment_status' }, - detailLabel: '库位分配状态', - filterParamMap: { '未分配': '未分配', '已分配': '已分配', '部分分配': '部分分配' } - }, - express_assignment_status: { - key: 'express_assignment_status', - label: '快递分配', - scanBox: { type: 'select', group: SCANBOX_GROUPS.process, options: getOptions('express_assignment_status') }, - table: { minWidth: 120, align: 'center' }, - slot: { type: 'tag', tagResolver: 'resolveAssignTag', translateField: 'express_assignment_status' }, - detailLabel: '快递分配状态', - filterParamMap: { '未分配': 'unassigned', '已分配': 'assigned' } - }, - print_assignment_status: { - key: 'print_assignment_status', - label: '打印状态', - scanBox: { type: 'select', group: SCANBOX_GROUPS.process, options: getOptions('print_assignment_status') }, - table: { minWidth: 110, align: 'center' }, - slot: { type: 'tag', tagResolver: 'resolvePrintTag', translateField: 'print_assignment_status' }, - detailLabel: '打印分配状态', - filterParamMap: { '未打印': 'unprinted', '已打印': 'printed' } - }, - pick_assignment_status: { - key: 'pick_assignment_status', - label: '拣货状态', - scanBox: { type: 'select', group: SCANBOX_GROUPS.process, options: getOptions('pick_assignment_status') }, - table: { minWidth: 110, align: 'center' }, - slot: { type: 'tag', tagResolver: 'resolvePickTag', translateField: 'pick_assignment_status' }, - detailLabel: '拣货状态', - filterParamMap: { '未拣货': 'unpicked', '部分拣货': 'partially_picked', '已拣货': 'picked' } - }, - review_assignment_status: { - key: 'review_assignment_status', - label: '复核状态', - scanBox: { type: 'select', group: SCANBOX_GROUPS.process, options: getOptions('review_assignment_status') }, - table: { minWidth: 110, align: 'center' }, - slot: { type: 'tag', tagResolver: 'resolveReviewTag', translateField: 'review_assignment_status' }, - detailLabel: '复核状态', - filterParamMap: { '未复核': 'unreviewed', '已复核': 'reviewed' } - }, - unreviewed_order_count: { - key: 'unreviewed_order_count', - label: '未复核数', - scanBox: null, - table: { minWidth: 96, align: 'center', sortable: true }, - slot: null, - detailLabel: '未复核订单数' - }, - - // ---- 订单相关 ---- - order_no: { - key: 'order_no', - label: '订单编号', - scanBox: { type: 'text', group: SCANBOX_GROUPS.basic }, - table: { minWidth: 180, fixed: 'left', copyAction: 'copy', showOverflowTooltip: true }, - slot: null - }, - order_status: { - key: 'order_status', - label: '订单状态', - scanBox: { type: 'select', group: SCANBOX_GROUPS.basic, options: getOptions('order_status') }, - table: { minWidth: 100, align: 'center' }, - slot: { type: 'tag', tagType: { 'pending': 'warning', 'processing': 'warning', 'done': 'success' }, translateField: 'order_status' } - }, - customer_name: { - key: 'customer_name', - label: '客户名称', - scanBox: { type: 'text', group: SCANBOX_GROUPS.basic }, - table: { minWidth: 120, showOverflowTooltip: true }, - slot: null - }, - sku_count: { - key: 'sku_count', - label: 'SKU数', - scanBox: null, - table: { minWidth: 80, align: 'center', sortable: true }, - slot: null - }, - total_qty: { - key: 'total_qty', - label: '总数量', - scanBox: null, - table: { minWidth: 80, align: 'center', sortable: true }, - slot: null - }, - total_amount: { - key: 'total_amount', - label: '总金额(元)', - scanBox: null, - table: { minWidth: 110, align: 'center', sortable: true }, - slot: null - }, - order_time: { - key: 'order_time', - label: '下单时间', - scanBox: { type: 'daterange', group: SCANBOX_GROUPS.time }, - table: { minWidth: 168, sortable: true }, - slot: { type: 'text', format: 'datetime' } - }, - - // ---- 快递相关 ---- - express_company: { - key: 'express_company', - label: '快递公司', - scanBox: { - type: 'select', group: SCANBOX_GROUPS.logistics, - options: [ - { label: '顺丰速运', value: 'SF' }, - { label: '圆通快递', value: 'YTO' }, - { label: '中通快递', value: 'ZTO' }, - { label: '韵达快递', value: 'YUNDA' }, - { label: '申通快递', value: 'STO' } - ] - }, - table: { minWidth: 120, showOverflowTooltip: true }, - slot: null - }, - express_bill_count: { - key: 'express_bill_count', - label: '快递单数', - scanBox: null, - table: { minWidth: 100, align: 'center', sortable: true }, - slot: null - }, - assigned_count: { - key: 'assigned_count', - label: '已分配数', - scanBox: null, - table: { minWidth: 90, align: 'center', sortable: true }, - slot: null - }, - unassigned_count: { - key: 'unassigned_count', - label: '未分配数', - scanBox: null, - table: { minWidth: 90, align: 'center', sortable: true }, - slot: null - }, - - // ---- 拣货相关 ---- - picker: { - key: 'picker', - label: '拣货员', - scanBox: { type: 'text', group: SCANBOX_GROUPS.process }, - table: { minWidth: 100 }, - slot: null - }, - pick_cart_no: { - key: 'pick_cart_no', - label: '拣货车', - scanBox: { type: 'text', group: SCANBOX_GROUPS.process }, - table: { minWidth: 120 }, - slot: null - }, - picked_sku_count: { - key: 'picked_sku_count', - label: '已拣SKU', - scanBox: null, - table: { minWidth: 90, align: 'center', sortable: true }, - slot: null - }, - unpicked_sku_count: { - key: 'unpicked_sku_count', - label: '未拣SKU', - scanBox: null, - table: { minWidth: 90, align: 'center', sortable: true }, - slot: null - }, - pick_start_time: { - key: 'pick_start_time', - label: '开始拣货', - scanBox: null, - table: { minWidth: 168, sortable: true }, - slot: { type: 'text', format: 'datetime' } - }, - pick_end_time: { - key: 'pick_end_time', - label: '完成拣货', - scanBox: null, - table: { minWidth: 168, sortable: true }, - slot: { type: 'text', format: 'datetime' } - }, - - // ---- 复核相关 ---- - reviewer: { - key: 'reviewer', - label: '复核员', - scanBox: { type: 'text', group: SCANBOX_GROUPS.process }, - table: { minWidth: 100 }, - slot: null - }, - reviewed_order_count: { - key: 'reviewed_order_count', - label: '已复核单', - scanBox: null, - table: { minWidth: 100, align: 'center', sortable: true }, - slot: null - }, - review_start_time: { - key: 'review_start_time', - label: '开始复核', - scanBox: null, - table: { minWidth: 168, sortable: true }, - slot: { type: 'text', format: 'datetime' } - }, - review_end_time: { - key: 'review_end_time', - label: '完成复核', - scanBox: null, - table: { minWidth: 168, sortable: true }, - slot: { type: 'text', format: 'datetime' } - }, - - // ---- 操作列(虚拟字段,仅用于表格列渲染) ---- - operation: { - key: 'operation', - label: '操作', - scanBox: null, - table: { minWidth: 180, fixed: 'right', align: 'center' }, - slot: { type: 'operation' } - } -} - -// ============================================================ -// 三、列插槽配置类型(与 ColumnCellRenderer 配合) -// ============================================================ -export interface ColumnSlotConfig { - type: 'tag' | 'text' | 'default' | 'operation' - tagType?: string | Record - tagResolver?: string - translateField?: string - /** 格式化类型:'datetime' 将时间戳转为 YYYY-MM-DD HH:mm:ss */ - format?: 'datetime' -} - -// ============================================================ -// 三-A、操作列按钮配置 -// ============================================================ - -/** 单个操作按钮配置 */ -export interface OperationButtonConfig { - /** 按钮唯一标识 */ - key: string - /** 按钮文本 */ - label: string - /** 按钮类型 */ - type?: 'primary' | 'success' | 'warning' | 'danger' | 'info' | '' - /** 按钮行为类型:'form' 打开表单组件 | 'action' 调用回调函数 */ - actionType: 'form' | 'action' - /** actionType='form' 时:表单组件 key(查 COMPONENT_REGISTRY) */ - formKey?: string - /** actionType='form' 时:表单对话框标题 */ - formTitle?: string - /** actionType='form' 时:表单对话框宽度 */ - formWidth?: string - /** 传递给表单的行数据字段列表(key: 表单prop, value: 行数据字段名) */ - paramMap?: Record - /** 传递给表单的固定参数(与 paramMap 合并) */ - extraParams?: Record - /** 按钮禁用条件字段(行数据中该字段为 falsy 时禁用) */ - disabledOnField?: string - /** 点击后先弹出确认框的提示文本(如"确定要批量拣货吗?") */ - confirmMessage?: string - /** 确认框标题 */ - confirmTitle?: string - /** 确认框类型 */ - confirmType?: 'warning' | 'danger' | 'info' - /** 确认按钮文本 */ - confirmButtonText?: string -} - -// ============================================================ -// 四、明细面板配置类型(与 DetailPanel 配合) -// ============================================================ - -/** 明细面板单个字段配置 */ -export interface DetailFieldConfig { - /** 字段 key(对应 row 数据中的属性名) */ - key: string - /** 显示标签(不设则从 FIELD_DICT 取 label) */ - label?: string - /** 列跨度 */ - span?: number - /** 渲染类型 */ - renderType?: 'text' | 'tag' | 'pre' - /** tag 颜色(固定值 或 值→颜色映射) */ - tagType?: string | Record - /** tagResolver 函数名 */ - tagResolver?: string - /** 翻译字段名(查 VALUE_MAPS) */ - translateField?: string - /** 格式化类型:'datetime' 将时间戳转为 YYYY-MM-DD HH:mm:ss */ - format?: 'datetime' -} - -/** 明细面板分区配置 */ -export interface DetailSectionConfig { - /** 分区标题 */ - title: string - /** el-descriptions 列数 */ - columnCount: number - /** 分区内字段列表 */ - fields: DetailFieldConfig[] -} - -/** 明细面板标签页配置 */ -export interface DetailTabConfig { - /** 标签页标识 */ - name: string - /** 标签页标题 */ - label: string - /** 标签页组件 key(查 COMPONENT_REGISTRY) */ - componentKey: string - /** 解析后的实际组件(resolveTabConfig 填充) */ - component?: Component -} - -// ============================================================ -// 五、TabPageRawConfig — 标签页声明配置(仅用 key 引用) -// ============================================================ - -export interface ToolbarButton { - key: string - label: string - type?: 'primary' | 'success' | 'warning' | 'danger' | 'info' | '' - icon?: string - disabled?: boolean -} - -// ============================================================ -// 五-A、TabPageApiConfig — 标签页接口插槽配置 -// ============================================================ - -/** API 方法泛型签名 */ -export type ApiMethod = (...args: any[]) => Promise - -/** 组件数据来源 */ -export type ApiSource = 'api' | 'list' - -/** - * 公共组件的接口配置(联合类型) - * - * - { source: 'list' } → 组件使用页面 list 接口返回的行数据,无需额外请求 - * - ApiMethod(函数) → 组件调用独立接口获取数据,与 list 字段写法一致 - * - * 示例: - * detail: { source: 'list' } // 明细面板直接用列表行数据 - * log: orderWaveApi.batchLog // 日志面板调独立接口(写法和 list 一致) - */ -export type ComponentApiConfig = { source: 'list' } | ApiMethod - -/** 标签页的接口契约:各公共组件通过此配置获取所需 API */ -export interface TabPageApiConfig { - /** 列表查询接口(index.vue loadData 调用) */ - list: ApiMethod - - /** 明细面板接口配置(DetailPanel),可选——不配时直接用 row 数据 */ - detail?: ComponentApiConfig - - /** 操作日志接口配置(LogPanel),可选——不配时用 row 生成日志 */ - log?: ComponentApiConfig - - /** 导出接口(导出按钮调用),可选 */ - export?: ApiMethod - - /** 导出进度查询接口,可选 */ - exportProgress?: ApiMethod - - /** ScanBox 中下拉选项的数据源接口,可选 */ - scanBoxOptions?: Record - - /** - * 工具栏按钮 → API 方法映射 - * key = toolbar button key,value = 对应 API 方法 - * 例如: { batchAssignExpress: orderWaveApi.assignExpress } - */ - toolbar?: Record - - /** 列表响应解析器(原始响应 → { list, total }) */ - parseListResponse?: (res: any) => { list: any[]; total: number } - - /** 构建列表请求参数(pagination + scanBox conditions → 接口参数),可选 */ - buildListParams?: (params: { - pagination: { page: number; pageSize: number } - conditions: Record - sort?: { prop: string; order: string } - }) => Record -} - -export interface TabPageRawConfig { - name: string - label: string - scanBoxCacheKey: string - /** ScanBox 需要的字段 key 列表(从 FIELD_DICT 中查找) */ - scanBoxFieldKeys: string[] - /** 表格需要的列 key 列表(从 FIELD_DICT 中查找) */ - tableColumnKeys: string[] - upperTableDefaults: { - title: string - enableColumnConfig?: boolean - showIndex?: boolean - showSelection?: boolean - emptyText?: string - } - detailComponentKey: string - /** 明细面板标签页配置(默认仅"波次明细",可追加"操作日志"等) */ - detailTabs?: { name: string; label: string; componentKey: string }[] - /** 明细面板分区配置(各页面按需配置字段 key,resolveTabConfig 展开) */ - detailSections: { - title: string - columnCount: number - fieldKeys: string[] - }[] - /** 接口配置(有 api 时优先使用真实接口) */ - api?: TabPageApiConfig - - /** 操作列按钮配置(需 tableColumnKeys 包含 'operation') */ - operationButtons?: OperationButtonConfig[] - - toolbar?: { - left?: ToolbarButton[] - showRefresh?: boolean - showExport?: boolean - } -} - -// ============================================================ -// 六、TabPageConfig — 展开后的完整配置(给 index.vue 使用) -// ============================================================ -export interface TabPageConfig { - name: string - label: string - scanBoxCacheKey: string - scanBoxFields: Record[] - upperTable: { - title: string - enableColumnConfig: boolean - showIndex: boolean - showSelection: boolean - emptyText: string - columns: Record[] - } - columnSlots: Record - /** 展开后的明细面板配置(可直接传给 DetailPanel) */ - detailConfig: DetailSectionConfig[] - /** 明细面板标签页列表(组件已解析) */ - detailTabs: DetailTabConfig[] - /** 接口配置(透传自 TabPageRawConfig.api) */ - api?: TabPageApiConfig - /** 操作列按钮配置 */ - operationButtons?: OperationButtonConfig[] - toolbar?: { - left?: ToolbarButton[] - showRefresh?: boolean - showExport?: boolean - } -} - -// ============================================================ -// 七、resolveTabConfig — 加载时将 RawConfig 展开为完整配置 -// ============================================================ -export function resolveTabConfig(raw: TabPageRawConfig): TabPageConfig { - // 展开 ScanBox 字段 - const scanBoxFields: Record[] = [] - let lastGroup = '' - for (const key of raw.scanBoxFieldKeys) { - const def = FIELD_DICT[key] - if (!def || !def.scanBox) continue - scanBoxFields.push({ - label: def.label, - value: def.key, - type: def.scanBox.type, - options: def.scanBox.options ? [...def.scanBox.options] : undefined, - group: def.scanBox.group, - required: def.scanBox.required, - extraAction: def.scanBox.extraAction - }) - } - - // 展开表格列 - const columns: Record[] = [] - for (const key of raw.tableColumnKeys) { - const def = FIELD_DICT[key] - if (!def || !def.table) continue - columns.push({ - prop: def.key, - label: def.label, - ...def.table - }) - } - - // 展开列插槽 - const columnSlots: Record = {} - for (const key of raw.tableColumnKeys) { - const def = FIELD_DICT[key] - if (!def || !def.slot) continue - columnSlots[def.key] = { ...def.slot } - } - - // 展开明细面板配置 - const detailConfig: DetailSectionConfig[] = raw.detailSections.map((sec) => ({ - title: sec.title, - columnCount: sec.columnCount, - fields: sec.fieldKeys - .map((key): DetailFieldConfig | null => { - const def = FIELD_DICT[key] - if (!def) return null - return { - key: def.key, - label: def.detailLabel ?? def.label, - translateField: def.slot?.translateField, - tagResolver: def.slot?.tagResolver, - tagType: def.slot?.tagType, - renderType: def.slot?.type === 'tag' ? 'tag' : 'text', - format: def.slot?.format - } - }) - .filter((f): f is DetailFieldConfig => f !== null) - })) - - // 展开明细标签页(解析 componentKey → Component) - const defaultComponent = COMPONENT_REGISTRY[raw.detailComponentKey] - const detailTabs: DetailTabConfig[] = raw.detailTabs - ? raw.detailTabs.map((tab) => ({ - name: tab.name, - label: tab.label, - componentKey: tab.componentKey, - component: COMPONENT_REGISTRY[tab.componentKey] - })) - : [{ name: 'detail', label: '波次明细', componentKey: raw.detailComponentKey, component: defaultComponent }] - - return { - name: raw.name, - label: raw.label, - scanBoxCacheKey: raw.scanBoxCacheKey, - scanBoxFields, - upperTable: { - title: raw.upperTableDefaults.title, - enableColumnConfig: raw.upperTableDefaults.enableColumnConfig ?? true, - showIndex: raw.upperTableDefaults.showIndex ?? true, - showSelection: raw.upperTableDefaults.showSelection ?? true, - emptyText: raw.upperTableDefaults.emptyText ?? '暂无数据', - columns - }, - columnSlots, - detailConfig, - detailTabs, - api: raw.api, - operationButtons: raw.operationButtons, - toolbar: raw.toolbar - } -} - -// ============================================================ -// 七-A、buildWhereConditions — 将 ScanBox 条件转为 API where 参数 -// ============================================================ -// 自动应用 FIELD_DICT.filterParamMap 进行值映射(如 '团购'→'1') - -/** - * 将 ScanBox 原始条件转换为接口 where 参数 - * 1. 提取条件值(支持 { operator, value } 和原始值两种格式) - * 2. 通过 FIELD_DICT[key].filterParamMap 映射值 - * 3. 过滤 warehouse_id(由框架层注入) - */ -export function buildWhereConditions(rawConditions: Record): Record { - const where: Record = {} - for (const [key, cond] of Object.entries(rawConditions || {})) { - // 跳过仓库ID(由框架层统一处理) - if (key === 'warehouse_id' || key === 'warehouseId') continue - - let value: any = undefined - - // ScanBox 标准格式:{ operator: '=', value: 'xxx' } - if (cond && typeof cond === 'object' && 'operator' in cond) { - value = (cond as any).value - } else if (cond !== undefined && cond !== null && cond !== '') { - // 原始值格式:字符串直接使用,数组取第一个 - value = Array.isArray(cond) ? cond[0] ?? '' : cond - } - - // 跳过空值 - if (value === undefined || value === null || value === '' || (Array.isArray(value) && value.length === 0)) { - continue - } - - // 通过 FIELD_DICT.filterParamMap 映射值 - const def = FIELD_DICT[key] - if (def?.filterParamMap) { - const mapped = def.filterParamMap[String(value)] - if (mapped !== undefined) { - where[key] = mapped - continue - } - } - - where[key] = value - } - return where -} - -// ============================================================ -// 七、标签页注册表(仅声明 key,由 resolveTabConfig 展开) -// ============================================================ - -export const waveOrder2TabPages: TabPageRawConfig[] = [ - // ===== 标签页一:团购波次(wave_type=1) ===== - { - name: 'tab1', - label: '团购波次', - scanBoxCacheKey: 'wave-order2-group-wave', - scanBoxFieldKeys: [ - 'wave_no', 'wave_type', 'wave_status', 'distinguish_express', - 'logistics_name', 'creator', - 'storage_assignment_status', 'express_assignment_status', - 'print_assignment_status', 'pick_assignment_status', 'review_assignment_status', - 'create_time', 'update_time' - ], - tableColumnKeys: [ - 'wave_no', 'wave_type', 'wave_status', - 'total_orders', 'order_count', 'processed_orders', - 'distinguish_express', - 'storage_assignment_status', 'express_assignment_status', - 'print_assignment_status', 'pick_assignment_status', 'review_assignment_status', - 'unreviewed_order_count', 'logistics_name', 'creator', 'warehouse_id', - 'create_time', 'update_time', 'operation' - ], - upperTableDefaults: { - title: '团购波次列表', - showSelection: true - }, - detailComponentKey: 'DetailPanel', - detailTabs: [ - { name: 'detail', label: '波次明细', componentKey: 'DetailPanel' }, - { name: 'log', label: '操作日志', componentKey: 'LogPanel' } - ], - detailSections: [ - { - title: '基础信息', - columnCount: 4, - fieldKeys: ['wave_no', 'wave_type', 'wave_status', 'distinguish_express', 'logistics_name', 'creator', 'warehouse_id', 'create_time'] - }, - { - title: '订单统计', - columnCount: 4, - fieldKeys: ['total_orders', 'order_count', 'processed_orders', 'unreviewed_order_count'] - }, - { - title: '流程状态', - columnCount: 3, - fieldKeys: ['storage_assignment_status', 'express_assignment_status', 'print_assignment_status', 'pick_assignment_status', 'review_assignment_status', 'update_time'] - } - ], - api: { - list: orderWaveBatchList, - // 波次明细数据来自列表行,无需额外接口调用 - detail: { source: 'list' }, - parseListResponse(res: any) { - const { list, pagination } = unwrapWaveBatchListResponse(res) - return { list, total: pagination.total ?? 0 } - }, - buildListParams({ pagination, conditions, sort }) { - const where: Record = { wave_type: 1 } - // 合并 ScanBox 条件(自动应用 filterParamMap 映射) - Object.assign(where, buildWhereConditions(conditions)) - const apiParams: Record = { pagination, where } - if (sort?.prop) { - apiParams.sort = { sortField: sort.prop, sortOrder: sort.order === 'ascending' ? 'ASC' : 'DESC' } - } - return apiParams - } - }, - operationButtons: [ - { - key: 'handleOrders', - label: '处理订单', - actionType: 'action', - type: 'primary' - }, - { - key: 'batchPick', - label: '批量拣货', - actionType: 'action', - type: 'success', - confirmMessage: '确定要对当前波次执行批量拣货(一键完成整个波次拣货)吗?', - confirmTitle: '批量拣货', - confirmType: 'warning', - confirmButtonText: '确认拣货' - } - ] - }, - - // ===== 标签页二:散单波次(wave_type=2) ===== - { - name: 'tab2', - label: '散单波次', - scanBoxCacheKey: 'wave-order2-sandan-wave', - scanBoxFieldKeys: [ - 'wave_no', 'wave_type', 'wave_status', 'distinguish_express', - 'logistics_name', 'creator', - 'storage_assignment_status', 'express_assignment_status', - 'print_assignment_status', 'pick_assignment_status', 'review_assignment_status', - 'create_time', 'update_time' - ], - tableColumnKeys: [ - 'wave_no', 'wave_type', 'wave_status', - 'total_orders', 'order_count', 'processed_orders', - 'distinguish_express', - 'storage_assignment_status', 'express_assignment_status', - 'print_assignment_status', 'pick_assignment_status', 'review_assignment_status', - 'unreviewed_order_count', 'logistics_name', 'creator', 'warehouse_id', - 'create_time', 'update_time', 'operation' - ], - upperTableDefaults: { - title: '散单波次列表', - showSelection: true - }, - detailComponentKey: 'DetailPanel', - detailTabs: [ - { name: 'detail', label: '波次明细', componentKey: 'DetailPanel' }, - { name: 'log', label: '操作日志', componentKey: 'LogPanel' } - ], - detailSections: [ - { - title: '基础信息', - columnCount: 4, - fieldKeys: ['wave_no', 'wave_type', 'wave_status', 'distinguish_express', 'logistics_name', 'creator', 'warehouse_id', 'create_time'] - }, - { - title: '订单统计', - columnCount: 4, - fieldKeys: ['total_orders', 'order_count', 'processed_orders', 'unreviewed_order_count'] - }, - { - title: '流程状态', - columnCount: 3, - fieldKeys: ['storage_assignment_status', 'express_assignment_status', 'print_assignment_status', 'pick_assignment_status', 'review_assignment_status', 'update_time'] - } - ], - api: { - list: orderWaveBatchList, - // 波次明细数据来自列表行,无需额外接口调用 - detail: { source: 'list' }, - parseListResponse(res: any) { - const { list, pagination } = unwrapWaveBatchListResponse(res) - return { list, total: pagination.total ?? 0 } - }, - buildListParams({ pagination, conditions, sort }) { - const where: Record = { wave_type: 2 } - // 合并 ScanBox 条件(自动应用 filterParamMap 映射) - Object.assign(where, buildWhereConditions(conditions)) - const apiParams: Record = { pagination, where } - if (sort?.prop) { - apiParams.sort = { sortField: sort.prop, sortOrder: sort.order === 'ascending' ? 'ASC' : 'DESC' } - } - return apiParams - } - }, - operationButtons: [ - { - key: 'handleOrders', - label: '处理订单', - actionType: 'action', - type: 'primary' - }, - { - key: 'batchPick', - label: '批量拣货', - actionType: 'action', - type: 'success', - confirmMessage: '确定要对当前波次执行批量拣货(一键完成整个波次拣货)吗?', - confirmTitle: '批量拣货', - confirmType: 'warning', - confirmButtonText: '确认拣货' - } - ] - }, - - // ===== 标签页三:快递分配 ===== - { - name: 'tab3', - label: '快递分配', - scanBoxCacheKey: 'wave-order2-tab3', - scanBoxFieldKeys: [ - 'wave_no', 'express_company', 'express_assignment_status', - 'distinguish_express', 'creator', 'create_time' - ], - tableColumnKeys: [ - 'wave_no', 'wave_type', 'express_company', 'express_assignment_status', - 'express_bill_count', 'distinguish_express', - 'assigned_count', 'unassigned_count', - 'creator', 'create_time' - ], - upperTableDefaults: { - title: '快递分配列表', - showSelection: true - }, - detailComponentKey: 'DetailPanel', - detailSections: [ - { - title: '快递分配信息', - columnCount: 3, - fieldKeys: ['wave_no', 'wave_type', 'express_company', 'express_assignment_status', 'express_bill_count', 'distinguish_express', 'assigned_count', 'unassigned_count', 'creator'] - }, - { - title: '时间信息', - columnCount: 2, - fieldKeys: ['create_time'] - } - ] - }, - - // ===== 标签页四:拣货状态 ===== - { - name: 'tab4', - label: '拣货状态', - scanBoxCacheKey: 'wave-order2-tab4', - scanBoxFieldKeys: [ - 'wave_no', 'pick_assignment_status', 'picker', 'pick_cart_no', - 'creator', 'create_time' - ], - tableColumnKeys: [ - 'wave_no', 'wave_type', 'pick_assignment_status', - 'picker', 'pick_cart_no', - 'picked_sku_count', 'unpicked_sku_count', - 'pick_start_time', 'pick_end_time', - 'create_time' - ], - upperTableDefaults: { - title: '拣货状态列表', - showSelection: true - }, - detailComponentKey: 'DetailPanel', - detailSections: [ - { - title: '拣货信息', - columnCount: 3, - fieldKeys: ['wave_no', 'wave_type', 'pick_assignment_status', 'picker', 'pick_cart_no', 'picked_sku_count', 'unpicked_sku_count'] - }, - { - title: '时间信息', - columnCount: 2, - fieldKeys: ['pick_start_time', 'pick_end_time', 'create_time'] - } - ] - }, - - // ===== 标签页五:复核状态 ===== - { - name: 'tab5', - label: '复核状态', - scanBoxCacheKey: 'wave-order2-tab5', - scanBoxFieldKeys: [ - 'wave_no', 'review_assignment_status', 'reviewer', - 'creator', 'create_time' - ], - tableColumnKeys: [ - 'wave_no', 'wave_type', 'review_assignment_status', - 'reviewer', 'reviewed_order_count', 'unreviewed_order_count', - 'review_start_time', 'review_end_time', - 'create_time' - ], - upperTableDefaults: { - title: '复核状态列表', - showSelection: true - }, - detailComponentKey: 'DetailPanel', - detailSections: [ - { - title: '复核信息', - columnCount: 3, - fieldKeys: ['wave_no', 'wave_type', 'review_assignment_status', 'reviewer', 'reviewed_order_count', 'unreviewed_order_count'] - }, - { - title: '时间信息', - columnCount: 2, - fieldKeys: ['review_start_time', 'review_end_time', 'create_time'] - } - ] - } -] - -// ============================================================ -// 十、向后兼容导出 -// ============================================================ -// 单页模式 singlePage -export const WAVEORDER2_PAGE_CONFIG = { showTabArea: true, singlePage: false, enableDetailPanel: true } - -export const waveOrder2Tabs = waveOrder2TabPages.map((t) => ({ - name: t.name, label: t.label, scanBoxCacheKey: t.scanBoxCacheKey -})) - -export const waveOrder2AvailableFields = (() => { - const raw = waveOrder2TabPages[0] - if (!raw) return [] - return resolveTabConfig(raw).scanBoxFields -})() - -export const waveOrder2UpperTableDefaults = (() => { - const raw = waveOrder2TabPages[0] - if (!raw) return { title: '', enableColumnConfig: true, showIndex: true, showSelection: true, emptyText: '', columns: [] } - return { ...resolveTabConfig(raw).upperTable } -})() - -export const waveOrder2Columns = (() => { - const raw = waveOrder2TabPages[0] - if (!raw) return [] - return resolveTabConfig(raw).upperTable.columns -})() - -// ============================================================ -// 十一、工具栏按钮系统(参照 orderManagement 设计) -// ============================================================ -// -// 按钮分为三类: -// 公共按钮 — 刷新、导出(不同页面调用不同接口) -// 功能按钮 — 点击后打开 pages/ 下对应表单组件 -// 基础接口 — 字段设置、隐藏详情 -// -// 按钮定义集中在 WAVEORDER2_TOOLBAR_BUTTONS,各标签页通过 -// getTabToolbarButtons(name) 获取属于该标签页的按钮列表。 - -export interface WaveOrder2ToolbarButtonConfig { - key: string - label: string - /** 按钮类别 */ - category: 'common' | 'function' | 'basic' - size?: '' | 'default' | 'small' | 'large' - type?: '' | 'primary' | 'success' | 'warning' | 'info' | 'danger' - plain?: boolean - loadingKey?: string - disabledKey?: string - action: string - /** 动态标签 key(如 detailToggleLabel) */ - dynamicLabelKey?: string - /** 仅指定标签页可见 */ - onlyForTabs?: string[] - /** 下拉按钮配置 */ - buttonType?: 'default' | 'dropdown' - dropdownOptions?: Array<{ label: string; action: string; divided?: boolean }> - /** 功能按钮关联的表单组件 key(查 FUNCTION_FORM_REGISTRY,可选) */ - formKey?: string -} - -/** 按钮类别常量 */ -export const TOOLBAR_CATEGORY = { - common: 'common', - function: 'function', - basic: 'basic' -} as const - -/** 工具栏按钮注册表(唯一真相来源) */ -export const WAVEORDER2_TOOLBAR_BUTTONS: Record = { - // ===== 公共按钮 ===== - refresh: { - key: 'refresh', - label: '刷新', - category: 'common', - type: 'primary', - size: 'small', - loadingKey: 'loading', - action: 'loadData' - }, - export: { - key: 'export', - label: '导出', - category: 'common', - size: 'small', - loadingKey: 'exportLoading', - action: 'handleExportWaybill', - buttonType: 'dropdown', - dropdownOptions: [ - { label: '不含明细', action: 'handleExportWaybill' }, - { label: '含明细', action: 'handleExportItem', divided: true } - ] - }, - - // ===== 基础接口 ===== - columnConfig: { - key: 'columnConfig', - label: '字段设置', - category: 'basic', - size: 'small', - action: 'openColumnConfigPanel' - }, - toggleDetail: { - key: 'toggleDetail', - label: '显示详情', - category: 'basic', - dynamicLabelKey: 'detailToggleLabel', - size: 'small', - action: 'toggleDetailVisible' - }, - - // ===== 功能按钮(打开表单/确认窗口) ===== - fetchGroupOrder: { - key: 'fetchGroupOrder', - label: '抓取团购单', - category: 'function', - type: 'warning', - size: 'small', - action: 'openFetchGroupOrderForm', - onlyForTabs: ['tab1'], - formKey: 'FetchGroupOrderForm' - }, - batchAutoGrouping: { - key: 'batchAutoGrouping', - label: '批量改为自动加团', - category: 'function', - type: 'warning', - size: 'small', - disabledKey: 'noSelection', - loadingKey: 'batchAutoGroupingLoading', - action: 'openBatchAutoGroupingForm', - formKey: 'BatchOperationForm' - }, - batchFinishAutoGrouping: { - key: 'batchFinishAutoGrouping', - label: '批量结束自动加团', - category: 'function', - type: 'success', - size: 'small', - disabledKey: 'noSelection', - loadingKey: 'batchFinishAutoGroupingLoading', - action: 'openBatchFinishAutoGroupingForm', - formKey: 'BatchOperationForm' - }, - batchCancel: { - key: 'batchCancel', - label: '批量取消波次', - category: 'function', - type: 'danger', - size: 'small', - disabledKey: 'noSelection', - loadingKey: 'batchCancelLoading', - action: 'openBatchCancelForm', - formKey: 'BatchOperationForm' - }, - batchAllocateExpress: { - key: 'batchAllocateExpress', - label: '快速分配快递号', - category: 'function', - type: 'success', - size: 'small', - disabledKey: 'noSelection', - loadingKey: 'batchAllocateExpressLoading', - action: 'openBatchAllocateExpressForm', - formKey: 'BatchOperationForm' - }, - batchAllocateStorage: { - key: 'batchAllocateStorage', - label: '批量分配储位', - category: 'function', - type: 'primary', - plain: true, - size: 'small', - disabledKey: 'noSelection', - loadingKey: 'batchAllocateStorageLoading', - action: 'openBatchAllocateStorageForm', - formKey: 'BatchOperationForm' - }, - batchRemoveExceptionOrders: { - key: 'batchRemoveExceptionOrders', - label: '批量移除异常订单', - category: 'function', - type: 'danger', - plain: true, - size: 'small', - disabledKey: 'noSelection', - loadingKey: 'batchRemoveExceptionOrdersLoading', - action: 'openBatchRemoveExceptionOrdersForm', - formKey: 'BatchOperationForm' - } -} - -/** 按标签页名称获取工具栏按钮列表(自动根据 PAGE_CONFIG 过滤) */ -export function getTabToolbarButtons(tabName: string): WaveOrder2ToolbarButtonConfig[] { - return Object.values(WAVEORDER2_TOOLBAR_BUTTONS).filter((btn) => { - if (btn.onlyForTabs && !btn.onlyForTabs.includes(tabName)) return false - // 详情面板禁用时,隐藏「显示/隐藏详情」按钮 - if (!WAVEORDER2_PAGE_CONFIG.enableDetailPanel && btn.key === 'toggleDetail') return false - return true - }) -} - -/** 按类别获取工具栏按钮 */ -export function getToolbarButtonsByCategory( - tabName: string, - category: string -): WaveOrder2ToolbarButtonConfig[] { - return getTabToolbarButtons(tabName).filter((btn) => btn.category === category) -} - -// ============================================================ -// 十二、功能按钮表单注册表 -// ============================================================ -// 功能按钮 → 表单组件的映射,组件放在 pages/ 目录下。 -// 新增功能按钮表单步骤: -// 1. 在 pages/ 下创建表单组件 -// 2. import 组件 -// 3. 在 FUNCTION_FORM_REGISTRY 添加一条 -// 4. 在 WAVEORDER2_TOOLBAR_BUTTONS 中设置 formKey - -import FetchGroupOrderForm from '../pages/FetchGroupOrderForm.vue' -import BatchOperationForm from '../pages/BatchOperationForm.vue' -import { - orderWaveBatchAutoGrouping, - orderWaveBatchFinishAutoGrouping, - orderWaveBatchCancel, - orderWaveBatchCancelTaskProgress, - orderWaveBatchAllocateExpress, - orderWaveBatchAllocateExpressTaskProgress, - orderWaveBatchAllocateStorage, - orderWaveBatchAllocateStorageTaskProgress, - orderWaveBatchRemoveExceptionOrders, - orderWaveBatchRemoveExceptionOrdersTaskProgress -} from '@/api/order.wave/orderwave' - -export const FUNCTION_FORM_REGISTRY: Record = { - FetchGroupOrderForm, - BatchOperationForm -} - -// ============================================================ -// 十三、批量操作表单配置(BatchOperationForm 用) -// ============================================================ - -export interface BatchOperationConfig { - /** 操作标识 */ - action: string - /** 弹窗标题 */ - title: string - /** 确认提示文本({count} 替换为选中数量) */ - confirmText: string - /** 确认按钮类型 */ - confirmType?: 'warning' | 'error' | 'info' | 'success' - /** 确认按钮文本 */ - confirmButtonText: string - /** 成功提示文本 */ - successText: string - /** 失败提示文本 */ - failText: string - /** API 方法(接收 ids 数组) */ - apiMethod: (...args: any[]) => Promise - /** 请求参数 key(默认 'ids') */ - payloadKey?: string - /** - * 从选中行提取 ID 的字段名。 - * - * 单字段(字符串):提取单个字段值组成一维数组。 - * 例 'wave_id' → [101, 102, 103] - * 支持 fallback:'wave_id,wave_no' → 优先 wave_id,无则取 wave_no - * - * 多字段(字符串数组):提取多个字段,组成 Record 数组。 - * 例 ['wave_id', 'wave_no'] → { wave_id: [101,102], wave_no: ['WV001','WV002'] } - * 此时会直接作为请求体传给 API,payloadKey 不再生效。 - * - * 未配置时默认使用 'wave_id'。 - */ - idField?: string | string[] - /** - * 自定义请求体构建函数。 - * 当需要多字段传参时使用(如同时传 wave_ids + warehouse_id), - * 传入完整的选中行数组,返回自定义 payload 对象。 - * 配置此项后,payloadKey / idField 仅用于 UI 展示。 - * - * @example - * payloadBuilder: (rows) => ({ - * wave_ids: rows.map(r => r.wave_id), - * warehouse_id: rows[0]?.warehouse_id - * }) - */ - payloadBuilder?: (rows: Record[]) => Record - /** 是否需要任务进度轮询 */ - useProgress?: boolean - /** 进度查询 API */ - progressApiMethod?: (...args: any[]) => Promise -} - -/** 各操作的配置映射 */ -export const BATCH_OPERATION_CONFIGS: Record = { - batchAutoGrouping: { - action: 'batchAutoGrouping', - title: '批量改为自动加团', - confirmText: '确定将选中的 {count} 个波次改为自动加团状态吗?', - confirmType: 'warning', - confirmButtonText: '确认修改', - successText: '批量改为自动加团成功', - failText: '批量改为自动加团失败', - apiMethod: orderWaveBatchAutoGrouping, - payloadKey: 'ids', - idField: 'wave_id' - }, - batchFinishAutoGrouping: { - action: 'batchFinishAutoGrouping', - title: '批量结束自动加团', - confirmText: '确定结束选中的 {count} 个波次的自动加团吗?', - confirmType: 'success', - confirmButtonText: '确认结束', - successText: '批量结束自动加团成功', - failText: '批量结束自动加团失败', - apiMethod: orderWaveBatchFinishAutoGrouping, - payloadKey: 'ids', - idField: 'wave_id' - }, - batchCancel: { - action: 'batchCancel', - title: '批量取消波次', - confirmText: '确定取消选中的 {count} 个波次吗?此操作不可撤销。', - confirmType: 'error', - confirmButtonText: '确认取消', - successText: '批量取消波次成功', - failText: '批量取消波次失败', - apiMethod: orderWaveBatchCancel, - payloadKey: 'wave_ids', - idField: 'wave_id', - useProgress: true, - progressApiMethod: orderWaveBatchCancelTaskProgress - }, - batchAllocateExpress: { - action: 'batchAllocateExpress', - title: '快速分配快递号', - confirmText: '确定为选中的 {count} 个波次快速分配快递号吗?', - confirmType: 'success', - confirmButtonText: '确认分配', - successText: '快递号分配任务已提交', - failText: '快递号分配失败', - apiMethod: orderWaveBatchAllocateExpress, - payloadKey: 'wave_ids', - idField: 'wave_id', - useProgress: true, - progressApiMethod: orderWaveBatchAllocateExpressTaskProgress - }, - batchAllocateStorage: { - action: 'batchAllocateStorage', - title: '批量分配储位', - confirmText: '确定为选中的 {count} 个波次批量分配储位吗?', - confirmType: 'warning', - confirmButtonText: '确认分配', - successText: '储位分配任务已提交', - failText: '储位分配失败', - apiMethod: orderWaveBatchAllocateStorage, - payloadKey: 'wave_ids', - idField: 'wave_id', - useProgress: true, - progressApiMethod: orderWaveBatchAllocateStorageTaskProgress - }, - batchRemoveExceptionOrders: { - action: 'batchRemoveExceptionOrders', - title: '批量移除异常订单', - confirmText: '确定移除选中的 {count} 个波次中的异常订单吗?', - confirmType: 'error', - confirmButtonText: '确认移除', - successText: '异常订单移除任务已提交', - failText: '移除异常订单失败', - apiMethod: orderWaveBatchRemoveExceptionOrders, - payloadKey: 'wave_ids', - idField: 'wave_id', - useProgress: true, - progressApiMethod: orderWaveBatchRemoveExceptionOrdersTaskProgress - } -} - diff --git a/src/views/order/waveOrder2/index.vue b/src/views/order/waveOrder2/index.vue deleted file mode 100644 index 64275d57..00000000 --- a/src/views/order/waveOrder2/index.vue +++ /dev/null @@ -1,971 +0,0 @@ - - - - - \ No newline at end of file diff --git a/src/views/order/waveOrder2/pages/BatchOperationForm.vue b/src/views/order/waveOrder2/pages/BatchOperationForm.vue deleted file mode 100644 index 1039f6c9..00000000 --- a/src/views/order/waveOrder2/pages/BatchOperationForm.vue +++ /dev/null @@ -1,246 +0,0 @@ - - - - - - diff --git a/src/views/order/waveOrder2/pages/FetchGroupOrderForm.vue b/src/views/order/waveOrder2/pages/FetchGroupOrderForm.vue deleted file mode 100644 index 4bde8279..00000000 --- a/src/views/order/waveOrder2/pages/FetchGroupOrderForm.vue +++ /dev/null @@ -1,556 +0,0 @@ - - - - - - diff --git a/src/views/storage/stockout/stockout-config.ts b/src/views/storage/stockout/stockout-config.ts index b02c0c4b..8497655a 100644 --- a/src/views/storage/stockout/stockout-config.ts +++ b/src/views/storage/stockout/stockout-config.ts @@ -1,4 +1,5 @@ import type { ToolbarButtonConfig } from '@/views/order/orderManagement/config/order-common-config' +import { resolveRowBarcode } from '@/utils/barcode' /** 出库单列表主工具栏按钮(action 与 stockout/index.vue 内 toolbarActionMap 键一致) * 排序与样式分类对齐 storage/receiving: @@ -340,15 +341,32 @@ export const productColumns = [ { prop: 'remark', label: '备注', minWidth: '120' } ] +/** item_snapshot 兼容对象与 JSON 字符串两种返回形态 */ +function resolvePrintItemSnapshot(raw: unknown): Record { + if (raw && typeof raw === 'object' && !Array.isArray(raw)) return raw as Record + if (typeof raw === 'string' && raw.trim()) { + try { + const parsed = JSON.parse(raw) + if (parsed && typeof parsed === 'object' && !Array.isArray(parsed)) { + return parsed as Record + } + } catch { + // 忽略非法 JSON,按无快照处理 + } + } + return {} +} + export function formatStockoutListItems(list: any[] = []) { return (list || []).map(item => { - const snap = item.item_snapshot || {} + const snap = resolvePrintItemSnapshot(item.item_snapshot) return { ...item, item_code: item.item_code || snap.item_code || '', item_name: item.item_name || snap.item_name || '', sku_property: item.sku_property ?? snap.sku_property ?? '', - barcode: item.barcode ?? snap.barcode ?? '', + // 商品条码:模板「商品明细」条码列(field_code=barcode)取值,兼容 barcode 单值与 barcodes 数组 + barcode: resolveRowBarcode(item, snap), stock_unit: item.stock_unit ?? snap.stock_unit ?? '', actual_qty: item.actual_qty ?? item.actual_quantity ?? '', batch_no: item.batch_no ?? '', diff --git a/src/views/system/setting/basicManagement/ApiOpenInterface.vue b/src/views/system/setting/basicManagement/ApiOpenInterface.vue deleted file mode 100644 index 251525da..00000000 --- a/src/views/system/setting/basicManagement/ApiOpenInterface.vue +++ /dev/null @@ -1,756 +0,0 @@ - - - - - - - diff --git a/src/views/system/setting/basicManagement/index.vue b/src/views/system/setting/basicManagement/index.vue deleted file mode 100644 index d5145059..00000000 --- a/src/views/system/setting/basicManagement/index.vue +++ /dev/null @@ -1,1152 +0,0 @@ - - - - - diff --git a/src/views/system/setting/basicManagement/newview/pages/MiniProgramConfigForm.vue b/src/views/system/setting/basicManagement/newview/pages/MiniProgramConfigForm.vue index 48a6404a..e7abace6 100644 --- a/src/views/system/setting/basicManagement/newview/pages/MiniProgramConfigForm.vue +++ b/src/views/system/setting/basicManagement/newview/pages/MiniProgramConfigForm.vue @@ -3,14 +3,26 @@ 对接接口: - setting.warehouse.getweChatApp(settingWarehouseGetWeChatApp):拉取当前仓库已授权的微信小程序配置 - wechat.getAuthUrl(wechatGetAuthUrl):未配置时点击「去授权」获取授权链接,并在新小窗口中打开 - - wechat.getRegisterUrl(wechatGetRegisterUrl):点击「代注册小程序」获取代注册链接,并在新小窗口中打开 + - wechat.queryauth(wechatQueryAuth):查询当前仓库小程序的微信认证进度(左菜单「认证状态」) + - wechat.registerMiniprogram(wechatRegisterMiniprogram):提交企业信息创建企业小程序注册任务 + (「代注册小程序」弹窗;后端调微信 fastregisterweapp,法人微信收模板消息做人脸核身, + 接口返回 errcode/errmsg、**不返回链接**,故不再开小窗) + - wechat.getTemplateList(wechatGetTemplateList):拉普通代码模板库列表(左菜单「发布」,后端缓存 24h) + - wechat.commit(wechatCommit):选定模板上传代码、生成体验版(需授权权限集 18) + - wechat.getTrialQRCode(wechatGetTrialQRCode):获取体验版二维码(后端转存 COS 后返回 URL) + - wechat.submitAudit(wechatSubmitAudit):提交代码审核(后端仅在 audit_status!=1 时允许;回写 audit_id) + ⚠️ 无审核状态查询接口,页面只能回显「已提交 + 审核单 ID」 交互约定: 1) 页面挂载即拉取配置;无配置(未授权)时提示「需要授权」并高亮「去授权」入口 - 2) 授权/代注册链接**不自动打开**:必须用户点击按钮后才请求接口并弹小窗 + 2) 授权链接**不自动打开**:必须用户点击按钮后才请求接口并弹小窗 3) 小窗口打开后:轮询配置,流程完成自动刷新;小窗关闭后做最后一次刷新 - 4) 域名限制:微信小程序授权/代注册页只能从**主域名**进入(主域名 = 品牌豁免域名 - VITE_FRONT_CONFIG_EXEMPT_HOSTS,与 frontBrand 同源);非主域名下禁用按钮并提示 + 4) 域名限制:微信小程序**授权页**只能从主域名进入(主域名 = 品牌豁免域名 + VITE_FRONT_CONFIG_EXEMPT_HOSTS,与 frontBrand 同源);非主域名下禁用授权按钮并提示。 + 代注册 / 发布走纯后端接口、无微信页面跳转,故不做域名限制。 + 5) 认证状态:切到「认证状态」菜单时按需查询一次,可手动刷新 + 6) 发布:切到「发布」菜单时按需拉模板列表;上传代码成功后自动刷新配置并重取体验版二维码; + 提交审核后可回显审核单 ID 使用方: 1) basicManagement/newview 的 viewType='form' 标签页「微信小程序」 @@ -29,15 +41,8 @@
刷新 - - - 代注册小程序 - - + + 代注册小程序 - + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - diff --git a/src/views/system/setting/encoding2/components/OperationCellRenderer.vue b/src/views/system/setting/encoding2/components/OperationCellRenderer.vue deleted file mode 100644 index a1190233..00000000 --- a/src/views/system/setting/encoding2/components/OperationCellRenderer.vue +++ /dev/null @@ -1,175 +0,0 @@ - - - - - - diff --git a/src/views/system/setting/encoding2/components/TabArea.vue b/src/views/system/setting/encoding2/components/TabArea.vue deleted file mode 100644 index 288ec6f1..00000000 --- a/src/views/system/setting/encoding2/components/TabArea.vue +++ /dev/null @@ -1,132 +0,0 @@ - - - - - diff --git a/src/views/system/setting/encoding2/config/components/DetailPanel.vue b/src/views/system/setting/encoding2/config/components/DetailPanel.vue deleted file mode 100644 index eb992d25..00000000 --- a/src/views/system/setting/encoding2/config/components/DetailPanel.vue +++ /dev/null @@ -1,159 +0,0 @@ - - - - - - diff --git a/src/views/system/setting/encoding2/config/components/LogPanel.vue b/src/views/system/setting/encoding2/config/components/LogPanel.vue deleted file mode 100644 index 0adae9f3..00000000 --- a/src/views/system/setting/encoding2/config/components/LogPanel.vue +++ /dev/null @@ -1,227 +0,0 @@ - - - - - - diff --git a/src/views/system/setting/encoding2/config/template-config.ts b/src/views/system/setting/encoding2/config/template-config.ts deleted file mode 100644 index fba881a9..00000000 --- a/src/views/system/setting/encoding2/config/template-config.ts +++ /dev/null @@ -1,727 +0,0 @@ -/** - * 【页面模板】配置文件 v2 — 基于 waveOrder2 架构设计 - * - * ===== 核心设计 ===== - * - * 1. FIELD_DICT — 全局字段预设表,每个字段拥有唯一翻译(label)和完整元数据 - * 2. VALUE_MAPS — 值翻译映射表(select options 和 tag 翻译共用) - * 3. TAG_RESOLVERS — 标签颜色解析器(集中管理 tag 颜色逻辑) - * 4. 各标签页通过 key 引用所需字段(scanBoxFieldKeys / tableColumnKeys) - * 5. resolveTabConfig() — 加载时将 key 列表展开为完整配置 - * - * ===== 快速上手 ===== - * 1. 复制整个 views/mode/ 文件夹,重命名为你的页面名 - * 2. 在 FIELD_DICT 中添加你需要的字段定义 - * 3. 在 tabPages 中配置标签页(引用 FIELD_DICT 的 key) - * 4. 在 TabPageApiConfig 中接入真实接口 - * 5. 在 router/map.ts 中添加路由 - */ - -import type { Component } from 'vue' -import DetailPanel from './components/DetailPanel.vue' -import LogPanel from './components/LogPanel.vue' - -// ============================================================ -// 〇、全局页面配置 -// ============================================================ -export const PAGE_CONFIG = { - /** 是否显示顶部多标签栏 */ - showTabArea: true, - /** 单页模式:不显示标签栏,仅一个标签页内容 */ - singlePage: false, - /** 是否启用详情面板(底部分栏 + 显示/隐藏详情按钮),false 时表格占满全高 */ - enableDetailPanel: true -} - -// ============================================================ -// 〇-A、组件注册表 — 所有可复用组件在此注册 -// ============================================================ -export const COMPONENT_REGISTRY: Record = { - DetailPanel, - LogPanel -} - -// ============================================================ -// 〇-B、SCANBOX_GROUPS — ScanBox 分组名称 -// ============================================================ -export const SCANBOX_GROUPS = { - basic: '基础信息', - process: '流程状态', - time: '时间范围', - custom: '自定义字段' -} as const - -// ============================================================ -// 一、FIELD_DICT — 全局字段预设表(唯一真相来源) -// ============================================================ -// 每个字段拥有: -// label — 唯一翻译文本 -// scanBox — ScanBox 渲染配置(type/options/group) -// table — 表格列配置(minWidth/fixed/align/sortable) -// slot — 单元格渲染配置(tag/tagResolver/translateField) -// detailLabel — 明细面板中的标签文本(可选,默认用 label) -// filterParamMap — ScanBox 筛选值 → API 传参值映射 - -export interface FieldDefinition { - key: string - label: string - scanBox: { - type: 'text' | 'select' | 'daterange' | 'number' - group?: string - options?: { label: string; value: any }[] - } | null - table: { - minWidth?: number - width?: number - fixed?: 'left' | 'right' | boolean - align?: 'left' | 'center' | 'right' - sortable?: boolean - showOverflowTooltip?: boolean - copyAction?: 'copy' | 'copyQr' - copyValue?: (row: any) => any - } | null - slot: { - type: 'tag' | 'text' | 'default' | 'operation' - tagType?: string | Record - tagResolver?: string - translateField?: string - format?: 'datetime' - } | null - detailLabel?: string - filterParamMap?: Record -} - -// ============================================================ -// VALUE_MAPS — 值翻译映射(select options 和 tag 翻译共用) -// ============================================================ -export const VALUE_MAPS: Record> = { - status: { 'pending': '待处理', 'processing': '处理中', 'done': '已完成', '待处理': '待处理', '处理中': '处理中', '已完成': '已完成' }, - type: { 'A': '类型A', 'B': '类型B', 'C': '类型C', '类型A': '类型A', '类型B': '类型B', '类型C': '类型C' }, - bool: { '1': '是', '0': '否', '是': '是', '否': '否' } -} - -/** 从 VALUE_MAPS 衍生 options(优先取中文值作为 option value) */ -export function getOptions(field: string): { label: string; value: string }[] { - const map = VALUE_MAPS[field] - if (!map) return [] - const seen = new Set() - const opts: { label: string; value: string }[] = [] - const chineseKeys: [string, string][] = [] - const otherKeys: [string, string][] = [] - for (const [v, l] of Object.entries(map)) { - if (/^[\u4e00-\u9fa5]/.test(v)) { - chineseKeys.push([v, l]) - } else { - otherKeys.push([v, l]) - } - } - for (const [v, l] of [...chineseKeys, ...otherKeys]) { - if (!seen.has(l)) { - seen.add(l) - opts.push({ label: l, value: v }) - } - } - return opts -} - -/** 翻译 value → label */ -export function translate(field: string, value: any): string { - const map = VALUE_MAPS[field] - if (!map) return String(value ?? '—') - return map[String(value)] ?? String(value ?? '—') -} - -/** 格式化时间戳为 YYYY-MM-DD HH:mm:ss */ -export function formatTime(value: any): string { - if (!value) return '—' - try { - const d = new Date(value) - if (isNaN(d.getTime())) return String(value) - const pad = (n: number) => String(n).padStart(2, '0') - return `${d.getFullYear()}-${pad(d.getMonth() + 1)}-${pad(d.getDate())} ${pad(d.getHours())}:${pad(d.getMinutes())}:${pad(d.getSeconds())}` - } catch { - return String(value) - } -} - -// ============================================================ -// TAG_RESOLVERS — 标签颜色解析器 -// ============================================================ -// 颜色规则:未xx=info(灰) 已xx=success(绿) xx中/部分xx=warning(黄) 错误=danger(红) -export const TAG_RESOLVERS: Record string> = { - resolveStatusTag(v) { - if (!v) return 'info' - if (v === '已完成' || v === 'done') return 'success' - if (v === '处理中' || v === 'processing') return 'warning' - return 'info' - }, - resolveBoolTag(v) { - if (v === undefined || v === null) return 'info' - if (v === '是' || v === true || v === 1 || v === '1') return 'success' - return 'info' - } -} - -// ============================================================ -// 二、FIELD_DICT 实例 — 在此定义页面所需的所有字段 -// ============================================================ -export const FIELD_DICT: Record = { - code: { - key: 'code', - label: '编号', - scanBox: { type: 'text', group: SCANBOX_GROUPS.basic }, - table: { minWidth: 160, fixed: 'left', copyAction: 'copy', showOverflowTooltip: true }, - slot: null, - detailLabel: '编号' - }, - name: { - key: 'name', - label: '名称', - scanBox: { type: 'text', group: SCANBOX_GROUPS.basic }, - table: { minWidth: 150, showOverflowTooltip: true }, - slot: null, - detailLabel: '名称' - }, - type: { - key: 'type', - label: '类型', - scanBox: { type: 'select', group: SCANBOX_GROUPS.basic, options: getOptions('type') }, - table: { minWidth: 100, align: 'center' }, - slot: { type: 'tag', tagType: 'info', translateField: 'type' }, - detailLabel: '类型', - filterParamMap: { '类型A': 'A', '类型B': 'B', '类型C': 'C' } - }, - status: { - key: 'status', - label: '状态', - scanBox: { type: 'select', group: SCANBOX_GROUPS.process, options: getOptions('status') }, - table: { minWidth: 100, align: 'center' }, - slot: { type: 'tag', tagResolver: 'resolveStatusTag', translateField: 'status' }, - detailLabel: '状态', - filterParamMap: { '待处理': 'pending', '处理中': 'processing', '已完成': 'done' } - }, - count: { - key: 'count', - label: '数量', - scanBox: null, - table: { minWidth: 80, align: 'center', sortable: true }, - slot: null - }, - amount: { - key: 'amount', - label: '金额(元)', - scanBox: null, - table: { minWidth: 110, align: 'center', sortable: true }, - slot: null - }, - creator: { - key: 'creator', - label: '创建人', - scanBox: { type: 'text', group: SCANBOX_GROUPS.basic }, - table: { minWidth: 100 }, - slot: null, - detailLabel: '创建人' - }, - create_time: { - key: 'create_time', - label: '创建时间', - scanBox: { type: 'daterange', group: SCANBOX_GROUPS.time }, - table: { minWidth: 170, sortable: true }, - slot: { type: 'text', format: 'datetime' }, - detailLabel: '创建时间' - }, - update_time: { - key: 'update_time', - label: '更新时间', - scanBox: { type: 'daterange', group: SCANBOX_GROUPS.time }, - table: { minWidth: 170, sortable: true }, - slot: { type: 'text', format: 'datetime' }, - detailLabel: '更新时间' - }, - /** 操作列(虚拟字段,仅用于表格列渲染) */ - operation: { - key: 'operation', - label: '操作', - scanBox: null, - table: { minWidth: 180, fixed: 'right', align: 'center' }, - slot: { type: 'operation' } - } -} - -// ============================================================ -// 三、ColumnSlotConfig — 列单元格渲染配置 -// ============================================================ -export interface ColumnSlotConfig { - type: 'tag' | 'text' | 'default' | 'operation' - tagType?: string | Record - tagResolver?: string - translateField?: string - format?: 'datetime' -} - -// ============================================================ -// 三-A、OperationButtonConfig — 操作列按钮配置 -// ============================================================ -export interface OperationButtonConfig { - key: string - label: string - type?: 'primary' | 'success' | 'warning' | 'danger' | 'info' | '' - actionType: 'form' | 'action' - formKey?: string - formTitle?: string - formWidth?: string - paramMap?: Record - extraParams?: Record - disabledOnField?: string - confirmMessage?: string - confirmTitle?: string - confirmType?: 'warning' | 'danger' | 'info' - confirmButtonText?: string -} - -// ============================================================ -// 四、DetailFieldConfig / DetailSectionConfig — 明细面板配置 -// ============================================================ -export interface DetailFieldConfig { - key: string - label?: string - span?: number - renderType?: 'text' | 'tag' | 'pre' - tagType?: string | Record - tagResolver?: string - translateField?: string -} - -export interface DetailSectionConfig { - title: string - columnCount: number - fields: DetailFieldConfig[] -} - -export interface DetailTabConfig { - name: string - label: string - componentKey: string - component?: Component -} - -// ============================================================ -// 五、TabPageApiConfig — 标签页接口插槽配置 -// ============================================================ -export type ApiMethod = (...args: any[]) => Promise -export type ApiSource = 'api' | 'list' -export type ComponentApiConfig = { source: 'list' } | ApiMethod - -export interface TabPageApiConfig { - /** 列表查询接口 */ - list: ApiMethod - /** 明细面板接口(可选,不配则用 row 数据) */ - detail?: ComponentApiConfig - /** 操作日志接口(可选) */ - log?: ComponentApiConfig - /** 导出接口(可选) */ - export?: ApiMethod - /** 导出进度查询接口(可选) */ - exportProgress?: ApiMethod - /** ScanBox 下拉选项数据源接口(可选) */ - scanBoxOptions?: Record - /** 工具栏按钮 → API 方法映射(可选) */ - toolbar?: Record - /** 列表响应解析器 */ - parseListResponse?: (res: any) => { list: any[]; total: number } - /** 构建列表请求参数 */ - buildListParams?: (params: { - pagination: { page: number; pageSize: number } - conditions: Record - sort?: { prop: string; order: string } - }) => Record -} - -// ============================================================ -// 六、TabPageRawConfig — 标签页声明配置(仅用 key 引用) -// ============================================================ -export interface TabPageRawConfig { - name: string - label: string - scanBoxCacheKey: string - /** ScanBox 需要的字段 key 列表(从 FIELD_DICT 中查找) */ - scanBoxFieldKeys: string[] - /** 表格需要的列 key 列表(从 FIELD_DICT 中查找) */ - tableColumnKeys: string[] - upperTableDefaults: { - title: string - enableColumnConfig?: boolean - showIndex?: boolean - showSelection?: boolean - emptyText?: string - } - /** 明细面板标签页配置 */ - detailTabs?: { name: string; label: string; componentKey: string }[] - /** 明细面板分区配置(字段 key 列表,resolveTabConfig 展开) */ - detailSections: { - title: string - columnCount: number - fieldKeys: string[] - }[] - /** 接口配置(有 api 时启用真实接口) */ - api?: TabPageApiConfig - /** 操作列按钮配置(需 tableColumnKeys 包含 'operation') */ - operationButtons?: OperationButtonConfig[] -} - -// ============================================================ -// 七、TabPageConfig — 展开后的完整配置(给 index.vue 使用) -// ============================================================ -export interface TabPageConfig { - name: string - label: string - scanBoxCacheKey: string - scanBoxFields: Record[] - upperTable: { - title: string - enableColumnConfig: boolean - showIndex: boolean - showSelection: boolean - emptyText: string - columns: Record[] - } - columnSlots: Record - detailConfig: DetailSectionConfig[] - detailTabs: DetailTabConfig[] - api?: TabPageApiConfig - operationButtons?: OperationButtonConfig[] -} - -// ============================================================ -// 八、resolveTabConfig — 加载时将 RawConfig 展开为完整配置 -// ============================================================ -export function resolveTabConfig(raw: TabPageRawConfig): TabPageConfig { - // 展开 ScanBox 字段 - const scanBoxFields: Record[] = [] - for (const key of raw.scanBoxFieldKeys) { - const def = FIELD_DICT[key] - if (!def || !def.scanBox) continue - scanBoxFields.push({ - label: def.label, - value: def.key, - type: def.scanBox.type, - options: def.scanBox.options ? [...def.scanBox.options] : undefined, - group: def.scanBox.group, - required: (def.scanBox as any).required - }) - } - - // 展开表格列 - const columns: Record[] = [] - for (const key of raw.tableColumnKeys) { - const def = FIELD_DICT[key] - if (!def || !def.table) continue - columns.push({ - prop: def.key, - label: def.label, - ...def.table - }) - } - - // 展开列插槽 - const columnSlots: Record = {} - for (const key of raw.tableColumnKeys) { - const def = FIELD_DICT[key] - if (!def || !def.slot) continue - columnSlots[def.key] = { ...def.slot } - } - - // 展开明细面板配置 - const detailConfig: DetailSectionConfig[] = raw.detailSections.map((sec) => ({ - title: sec.title, - columnCount: sec.columnCount, - fields: sec.fieldKeys - .map((key): DetailFieldConfig | null => { - const def = FIELD_DICT[key] - if (!def) return null - return { - key: def.key, - label: def.detailLabel ?? def.label, - translateField: def.slot?.translateField, - tagResolver: def.slot?.tagResolver, - tagType: def.slot?.tagType, - renderType: def.slot?.type === 'tag' ? 'tag' : 'text' - } - }) - .filter((f): f is DetailFieldConfig => f !== null) - })) - - // 展开明细标签页(解析 componentKey → Component) - const detailTabs: DetailTabConfig[] = raw.detailTabs - ? raw.detailTabs.map((tab) => ({ - name: tab.name, - label: tab.label, - componentKey: tab.componentKey, - component: COMPONENT_REGISTRY[tab.componentKey] - })) - : [{ name: 'detail', label: '明细', componentKey: 'DetailPanel', component: COMPONENT_REGISTRY['DetailPanel'] }] - - return { - name: raw.name, - label: raw.label, - scanBoxCacheKey: raw.scanBoxCacheKey, - scanBoxFields, - upperTable: { - title: raw.upperTableDefaults.title, - enableColumnConfig: raw.upperTableDefaults.enableColumnConfig ?? true, - showIndex: raw.upperTableDefaults.showIndex ?? true, - showSelection: raw.upperTableDefaults.showSelection ?? true, - emptyText: raw.upperTableDefaults.emptyText ?? '暂无数据', - columns - }, - columnSlots, - detailConfig, - detailTabs, - api: raw.api, - operationButtons: raw.operationButtons - } -} - -// ============================================================ -// 九、buildWhereConditions — 将 ScanBox 条件转为 API where 参数 -// ============================================================ -export function buildWhereConditions(rawConditions: Record): Record { - const where: Record = {} - for (const [key, cond] of Object.entries(rawConditions || {})) { - let value: any = undefined - if (cond && typeof cond === 'object' && 'operator' in cond) { - value = (cond as any).value - } else if (cond !== undefined && cond !== null && cond !== '') { - value = Array.isArray(cond) ? cond[0] ?? '' : cond - } - if (value === undefined || value === null || value === '' || (Array.isArray(value) && value.length === 0)) { - continue - } - const def = FIELD_DICT[key] - if (def?.filterParamMap) { - const mapped = def.filterParamMap[String(value)] - if (mapped !== undefined) { - where[key] = mapped - continue - } - } - where[key] = value - } - return where -} - -// ============================================================ -// 十、工具栏按钮系统 -// ============================================================ -// 按钮分为三类: -// common — 公共按钮(刷新、导出) -// function — 功能按钮(打开表单/确认窗口) -// basic — 基础操作(字段设置、隐藏详情) - -export interface ToolbarButtonConfig { - key: string - label: string - category: 'common' | 'function' | 'basic' - size?: '' | 'default' | 'small' | 'large' - type?: '' | 'primary' | 'success' | 'warning' | 'info' | 'danger' - plain?: boolean - loadingKey?: string - disabledKey?: string - action: string - dynamicLabelKey?: string - onlyForTabs?: string[] - buttonType?: 'default' | 'dropdown' - dropdownOptions?: Array<{ label: string; action: string; divided?: boolean }> - formKey?: string -} - -export const TOOLBAR_BUTTONS: Record = { - // ===== 公共按钮 ===== - refresh: { - key: 'refresh', - label: '刷新', - category: 'common', - type: 'primary', - size: 'small', - loadingKey: 'loading', - action: 'loadData' - }, - export: { - key: 'export', - label: '导出', - category: 'common', - size: 'small', - loadingKey: 'exportLoading', - action: 'handleExport', - buttonType: 'dropdown', - dropdownOptions: [ - { label: '不含明细', action: 'handleExport' }, - { label: '含明细', action: 'handleExportItem', divided: true } - ] - }, - // ===== 基础操作 ===== - columnConfig: { - key: 'columnConfig', - label: '字段设置', - category: 'basic', - size: 'small', - action: 'openColumnConfigPanel' - }, - toggleDetail: { - key: 'toggleDetail', - label: '显示详情', - category: 'basic', - dynamicLabelKey: 'detailToggleLabel', - size: 'small', - action: 'toggleDetailVisible' - } - // ★ 在此添加功能按钮(如批量操作)★ -} - -/** 按标签页名称获取工具栏按钮列表(自动根据 PAGE_CONFIG 过滤) */ -export function getTabToolbarButtons(tabName: string): ToolbarButtonConfig[] { - return Object.values(TOOLBAR_BUTTONS).filter((btn) => { - if (btn.onlyForTabs && !btn.onlyForTabs.includes(tabName)) return false - // 详情面板禁用时,隐藏「显示/隐藏详情」按钮 - if (!PAGE_CONFIG.enableDetailPanel && btn.key === 'toggleDetail') return false - return true - }) -} - -// ============================================================ -// 十一、批量操作配置(可选,接入 BatchOperationForm 时使用) -// ============================================================ -export interface BatchOperationConfig { - action: string - title: string - confirmText: string - confirmType?: 'warning' | 'error' | 'info' | 'success' - confirmButtonText: string - successText: string - failText: string - apiMethod: (...args: any[]) => Promise - payloadKey?: string - idField?: string | string[] - payloadBuilder?: (rows: Record[]) => Record - useProgress?: boolean - progressApiMethod?: (...args: any[]) => Promise -} - -/** ★ 在此配置批量操作 */ -export const BATCH_OPERATION_CONFIGS: Record = { - // batchExample: { - // action: 'batchExample', - // title: '批量操作示例', - // confirmText: '确定对选中的 {count} 项执行操作吗?', - // confirmType: 'warning', - // confirmButtonText: '确认操作', - // successText: '批量操作成功', - // failText: '批量操作失败', - // apiMethod: yourBatchApi, - // payloadKey: 'ids', - // idField: 'id' - // } -} - -// ============================================================ -// 十二、标签页注册表 — 在此定义你的页面标签页 -// ============================================================ -export const tabPages: TabPageRawConfig[] = [ - // ===== 示例标签页一 ===== - { - name: 'tab1', - label: '标签页一', - scanBoxCacheKey: 'template-tab1', - scanBoxFieldKeys: ['code', 'type', 'status', 'creator', 'create_time'], - tableColumnKeys: ['code', 'name', 'type', 'status', 'count', 'amount', 'creator', 'create_time', 'operation'], - upperTableDefaults: { - title: '示例列表一', - showSelection: true - }, - detailTabs: [ - { name: 'detail', label: '明细', componentKey: 'DetailPanel' }, - { name: 'log', label: '操作日志', componentKey: 'LogPanel' } - ], - detailSections: [ - { - title: '基础信息', - columnCount: 3, - fieldKeys: ['code', 'name', 'type', 'status', 'count', 'amount', 'creator'] - }, - { - title: '时间信息', - columnCount: 2, - fieldKeys: ['create_time', 'update_time'] - } - ], - /** ★ 接入真实接口时取消注释 */ - // api: { - // list: yourListApi, - // detail: { source: 'list' }, - // parseListResponse(res) { - // return { list: res.data?.list ?? [], total: res.data?.pagination?.total ?? 0 } - // }, - // buildListParams({ pagination, conditions, sort }) { - // return { - // page: pagination.page, - // pageSize: pagination.pageSize, - // where: buildWhereConditions(conditions), - // ...(sort?.prop ? { sortField: sort.prop, sortOrder: sort.order === 'ascending' ? 'ASC' : 'DESC' } : {}) - // } - // } - // }, - operationButtons: [ - { - key: 'viewDetail', - label: '查看详情', - actionType: 'action', - type: 'primary' - }, - { - key: 'edit', - label: '编辑', - actionType: 'action', - type: 'warning' - } - ] - }, - - // ===== 示例标签页二 ===== - { - name: 'tab2', - label: '标签页二', - scanBoxCacheKey: 'template-tab2', - scanBoxFieldKeys: ['code', 'status', 'create_time'], - tableColumnKeys: ['code', 'name', 'status', 'count', 'creator', 'create_time', 'operation'], - upperTableDefaults: { - title: '示例列表二', - showSelection: true - }, - detailSections: [ - { - title: '基础信息', - columnCount: 3, - fieldKeys: ['code', 'name', 'status', 'count', 'creator'] - }, - { - title: '时间信息', - columnCount: 2, - fieldKeys: ['create_time', 'update_time'] - } - ], - operationButtons: [ - { - key: 'viewDetail', - label: '查看详情', - actionType: 'action', - type: 'primary' - } - ] - } -] - -// ============================================================ -// 十三、向后兼容导出 -// ============================================================ -export const templateTabs = tabPages.map((t) => ({ name: t.name, label: t.label, scanBoxCacheKey: t.scanBoxCacheKey })) - diff --git a/src/views/system/setting/encoding2/index.vue b/src/views/system/setting/encoding2/index.vue deleted file mode 100644 index 81e052f5..00000000 --- a/src/views/system/setting/encoding2/index.vue +++ /dev/null @@ -1,1014 +0,0 @@ - - - - - - diff --git a/src/views/system/setting/encoding2/pages/ExampleFormDialog.vue b/src/views/system/setting/encoding2/pages/ExampleFormDialog.vue deleted file mode 100644 index 945481b8..00000000 --- a/src/views/system/setting/encoding2/pages/ExampleFormDialog.vue +++ /dev/null @@ -1,107 +0,0 @@ - - - - - - diff --git a/src/views/system/setting/workbench/index.vue b/src/views/system/setting/workbench/index.vue deleted file mode 100644 index 1bc4fc56..00000000 --- a/src/views/system/setting/workbench/index.vue +++ /dev/null @@ -1,966 +0,0 @@ - - - - - \ No newline at end of file diff --git a/src/views/system/setting/workbench/workbench-config.ts b/src/views/system/setting/workbench/workbench-config.ts deleted file mode 100644 index 6146c88b..00000000 --- a/src/views/system/setting/workbench/workbench-config.ts +++ /dev/null @@ -1,154 +0,0 @@ -export type WorkbenchRecord = { - id?: number - warehouse_id?: number - name?: string - barcode?: string - status?: number - type?: string - remark?: string - device_ids?: number[] | null - created_at?: string - updated_at?: string - deleted_at?: string | null -} - -export type WorkbenchDetail = WorkbenchRecord - -export const workbenchColumns = [ - { prop: 'id', label: 'ID', width: '80', sortable: true }, - { prop: 'name', label: '工作台名称', minWidth: '140', showOverflowTooltip: true }, - { prop: 'barcode', label: '条码', minWidth: '120', showOverflowTooltip: true }, - { prop: 'warehouse_id', label: '仓库ID', width: '100' }, - { prop: 'status', label: '状态', width: '80' }, - { prop: 'remark', label: '备注', minWidth: '140', showOverflowTooltip: true }, - { prop: 'device_ids', label: '绑定摄像头', width: '120' }, - { prop: 'created_at', label: '创建时间', minWidth: '160' }, - { prop: 'updated_at', label: '更新时间', minWidth: '160' }, - { prop: 'actions', label: '操作', width: '400', fixed: 'right' } -] - -export const workbenchScanFields = [ - { - value: 'quickWhere', - label: '关键词', - type: 'text', - placeholder: '名称/条码', - operators: ['contains'], - defaultOperator: 'contains' - }, - { - value: 'name', - label: '名称', - type: 'text', - placeholder: '请输入工作台名称', - operators: ['eq', 'contains', 'like'], - defaultOperator: 'contains' - }, - { - value: 'barcode', - label: '条码', - type: 'text', - placeholder: '请输入条码', - operators: ['eq', 'contains', 'like'], - defaultOperator: 'contains' - }, - { - value: 'status', - label: '状态', - type: 'select', - clearable: true, - options: [ - { label: '启用', value: '1' }, - { label: '禁用', value: '0' } - ] - } -] - -export function formatWorkbenchStatus(status: unknown): { text: string; type: 'success' | 'info' } { - const v = Number(status ?? 1) - return v === 1 ? { text: '启用', type: 'success' } : { text: '禁用', type: 'info' } -} - -function pad(n: number) { - return String(n).padStart(2, '0') -} - -export function formatTime(value: unknown): string { - if (!value) return '--' - const d = new Date(value as string) - if (isNaN(d.getTime())) return String(value) - return `${d.getFullYear()}-${pad(d.getMonth() + 1)}-${pad(d.getDate())} ${pad(d.getHours())}:${pad(d.getMinutes())}:${pad(d.getSeconds())}` -} - -function getFieldConfig(key: string, fields: typeof workbenchScanFields) { - return fields.find((f) => f.value === key) -} - -function mapFieldType(type: string, value: unknown) { - if (typeof value === 'number') return 'number' - return 'text' -} - -function processConditionValue(key: string, raw: any, fields: typeof workbenchScanFields) { - if (key === 'quickWhere') { - const val = raw?.value !== undefined ? raw.value : raw - const text = val == null ? '' : String(val).trim() - return text ? text : null - } - - const config = getFieldConfig(key, fields) - const fieldType = config?.type || 'text' - - if (raw && typeof raw === 'object' && !Array.isArray(raw)) { - const op = raw.operator || (fieldType === 'select' ? 'eq' : 'contains') - const type = raw.type || mapFieldType(fieldType, raw.value) - const value = raw.value - - if (fieldType === 'select') { - return { operator: 'eq', value: value != null ? Number(value) : undefined } - } - return { operator: op, type, value } - } - - if (fieldType === 'select') { - return raw != null ? { operator: 'eq', value: Number(raw) } : null - } - if (fieldType === 'number' && raw != null) { - return { operator: 'eq', value: Number(raw) } - } - - return raw != null ? raw : null -} - -export function normalizeWorkbenchScanConditionToWhere(rawCondition: any): Record { - if (!rawCondition) return {} - - const where: Record = {} - const entries = Array.isArray(rawCondition) ? rawCondition : Object.entries(rawCondition) - - for (const [key, raw] of entries) { - const processed = processConditionValue(String(key), raw, workbenchScanFields) - if (processed == null) continue - - if (key === 'quickWhere') { - where.name = { operator: 'contains', value: processed } - where.barcode = { operator: 'contains', value: processed } - continue - } - - where[key] = processed - } - - return where -} - -export function buildWorkbenchListPayload(params: { - page: number - pageSize: number - where?: Record -}) { - return { - pagination: { page: params.page, pageSize: params.pageSize }, - where: params.where || {} - } -} diff --git a/src/views/video/camera/component/CameraPlayer.vue b/src/views/video/camera/component/CameraPlayer.vue deleted file mode 100644 index 37a62802..00000000 --- a/src/views/video/camera/component/CameraPlayer.vue +++ /dev/null @@ -1,192 +0,0 @@ -