Merge branch 'main' of http://192.168.9.101:4000/liufumingren/WEB
This commit is contained in:
commit
01f0727602
417
docs/用户偏好配置-排序与跨设备同步设计.md
Normal file
417
docs/用户偏好配置-排序与跨设备同步设计.md
Normal file
@ -0,0 +1,417 @@
|
||||
# 用户偏好配置:每账号每页面自定义排序(纯浏览器本地保存方案)
|
||||
|
||||
- 状态:**已决策** —— 接口方案已废弃,正式采用纯浏览器本地保存(方案B,见 §8)
|
||||
- 决策日期:2026-09-01
|
||||
- 版本:v2.0(方案B 为正式方案;§2~§6 接口方案存档仅参考)
|
||||
|
||||
## 读者导航
|
||||
|
||||
| 角色 | 重点阅读 |
|
||||
|------|---------|
|
||||
| **前端(实现设计)** | §8 正式方案(纯浏览器保存)、§7 前端设计(复用 store 抽象与接入模板) |
|
||||
| **后端** | 无需开发接口;如需了解已废弃方案可参考 §2~§6(勿按此实现) |
|
||||
|
||||
---
|
||||
|
||||
## 0. 方案决策(2026-09-01)
|
||||
|
||||
> **接口方案(方案A,§2~§6 的 `user.preference.*`)已废弃**,不再开发后端接口。
|
||||
> 正式方案为 **§8 纯浏览器本地保存(localStorage)**:零后端依赖、每账号按 user_id 隔离、同设备跨刷新/会话生效。
|
||||
> **已放弃「跨设备同步」**:浏览器数据不经过服务端,无法跨设备。若将来需跨设备,再评估是否恢复接口方案。
|
||||
> 前端实现只需关注 §8、§7(store 抽象 / 接入模板 / 兜底);§2~§6 仅存档参考。
|
||||
|
||||
---
|
||||
|
||||
## 1. 背景与目标
|
||||
|
||||
订单管理 `order/orderManagement` 各 tab(待审核订单、待处理订单、待处理异常订单、配送单等)当前排序由用户本次操作决定,刷新/换设备后丢失。需要:
|
||||
|
||||
1. 每个 tab 页可配置自定义排序(排序字段 + 排序方向)。
|
||||
2. 排序配置**绑定账号**(同设备内按 user_id 隔离保存)。
|
||||
3. **刷新/重新登录后自动应用**已保存配置。
|
||||
|
||||
> 说明:原「跨设备同步」目标因采用纯浏览器方案(§8)而**放弃**(浏览器数据不经过服务端,见 §0 决策)。
|
||||
|
||||
该机制设计为**模块无关**:除订单模块外,`order/waveOrder`、`setting/basicManagement` 等页面均可复用(按同一 key 规范注册即可)。
|
||||
|
||||
### 非目标(本期不做)
|
||||
|
||||
- **不做跨设备同步**(纯浏览器方案的固有取舍,见 §0)。
|
||||
- 不要求"不刷新页面也实时同步"(浏览器本地保存天然即时生效,无需轮询)。
|
||||
- 不做多用户/角色的差异化权限(配置仅按 user_id 隔离)。
|
||||
- 不做复杂多级排序 UI(数据结构预留 `secondary`,UI 本期只做单字段)。
|
||||
|
||||
---
|
||||
|
||||
## 2. 通用约定(前后端共用)【已废弃:接口方案存档】
|
||||
|
||||
> ⚠️ 本节及 §3~§6 为**已废弃的接口方案(方案A)存档**,仅供将来可能恢复时参考;当前实现**不采用**,勿按此开发接口。正式方案见 §8。
|
||||
|
||||
### 2.1 接口风格
|
||||
|
||||
- 全部走统一系统接口:`POST /system`
|
||||
- URL Query:`method` / `v`(=1.0)/ `timestamp`
|
||||
- 请求体:`data`(业务参数,JSON)
|
||||
- 请求头:`Authorization: Bearer <token>`,`platform: web`,`project: all`
|
||||
|
||||
### 2.2 认证与用户隔离
|
||||
|
||||
- 所有接口需登录(`isNeedAuth=false`、`isNeedLogin=true` 口径与 `order.export` 一致)。
|
||||
- `user_id` **一律由服务端从 token 解析**,接口不接受前端传 user_id(安全边界)。
|
||||
|
||||
### 2.3 scope 命名规范
|
||||
|
||||
统一格式:`<模块>.<能力>.<页面标识>`,全小写,`.` 分隔。示例:`order.sort.pending`。
|
||||
|
||||
### 2.4 value 即不透明 JSON
|
||||
|
||||
- `value` 对接口层是**不透明 JSON**:后端只做白名单校验 + 存储 + 体积校验,不解析业务结构;业务结构由前端各页面定义与校验(见 §6.3)。
|
||||
- 这样保证"新增一个功能 = 新增一个 scope",后端接口零改动。
|
||||
|
||||
---
|
||||
|
||||
## 3. 通用响应封装
|
||||
|
||||
```jsonc
|
||||
// 成功
|
||||
{ "code": 200, "flag": "success", "message": "ok", "data": { ... } }
|
||||
// 失败
|
||||
{ "code": 40007, "flag": "fail", "message": "scope 未在白名单内", "data": null }
|
||||
```
|
||||
|
||||
- 成功码:`200 / 20000 / 1 / 0`(前端 `request.ts` 统一判定)。
|
||||
- `code !== 成功码` 时,前端优先展示 `message`,并可按 code 做分支处理(见 §4)。
|
||||
|
||||
---
|
||||
|
||||
## 4. 错误码表(后端按此实现)
|
||||
|
||||
> 建议码段,后端可对齐现有 `ERROR_CODE_MAP` 惯例后调整,但**前端会按这些语义分支**,请保持语义一致。
|
||||
|
||||
| code | 含义 | 前端行为 |
|
||||
|------|------|---------|
|
||||
| 200 / 20000 / 1 / 0 | 成功 | - |
|
||||
| 40007 | `scope` 未在白名单 / 格式非法 | 提示错误,不写入、不覆盖本地 |
|
||||
| 40008 | `value` 超过体积上限(>4KB) | 提示错误,不写入 |
|
||||
| 40009 | 乐观锁冲突(`base_updated_at` 与服务端 `updated_at` 不一致) | 弹窗提示「该配置已在其他设备更新」,提供「以本地为准覆盖」或「放弃」 |
|
||||
| 40010 | 参数缺失 / 类型错误(如缺 `scope`、`value` 非对象) | 提示错误 |
|
||||
| 401 / 50008 / 50012 / 50014 | 未登录 / 登录失效 | 跳转登录 |
|
||||
| 403 / 40005 / 40006 | 无操作权限 | 提示无权限 |
|
||||
|
||||
---
|
||||
|
||||
## 5. 接口契约(后端按此开发)【已废弃:接口方案存档】
|
||||
|
||||
### 5.1 `user.preference.get` — 获取偏好
|
||||
|
||||
**请求**
|
||||
|
||||
| 项 | 值 |
|
||||
|----|----|
|
||||
| method | `user.preference.get` |
|
||||
| 入参(data) | 见下表 |
|
||||
|
||||
| 字段 | 类型 | 必填 | 说明 |
|
||||
|------|------|------|------|
|
||||
| scope | string | 否 | 指定时只返回该 scope;缺省返回该用户**全部**偏好 |
|
||||
| scope[](扩展,待确认) | array<string> | 否 | 可选支持批量查询(见 §11-2) |
|
||||
|
||||
**响应 `data`**
|
||||
|
||||
```
|
||||
data: {
|
||||
[scope: string]: {
|
||||
value: object, // 该 scope 的配置内容(不透明 JSON)
|
||||
updated_at: number // 毫秒时间戳,写入/乐观锁使用
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
- 未注册的 `scope`(不在白名单):**返回空对象,不报错**(幂等友好)。
|
||||
- 该用户无任何配置:`data = {}`。
|
||||
|
||||
**成功示例**
|
||||
|
||||
```jsonc
|
||||
// 请求
|
||||
POST /system?method=user.preference.get&v=1.0×tamp=...
|
||||
{ "scope": "order.sort.pending" }
|
||||
|
||||
// 响应
|
||||
{
|
||||
"code": 200,
|
||||
"flag": "success",
|
||||
"message": "ok",
|
||||
"data": {
|
||||
"order.sort.pending": {
|
||||
"value": { "field": "create_at", "order": "desc", "secondary": [{ "field": "id", "order": "asc" }] },
|
||||
"updated_at": 1720000000000
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### 5.2 `user.preference.set` — 保存偏好
|
||||
|
||||
**请求**
|
||||
|
||||
| 项 | 值 |
|
||||
|----|----|
|
||||
| method | `user.preference.set` |
|
||||
| 入参(data) | 见下表 |
|
||||
|
||||
| 字段 | 类型 | 必填 | 说明 |
|
||||
|------|------|------|------|
|
||||
| scope | string | 是 | 必须命中白名单,否则返回 `40007` |
|
||||
| value | object | 是 | 可 JSON 序列化对象;非对象返回 `40010`;序列化后 >4KB 返回 `40008`;传 `{}` 视为**清空/重置该 scope**(后端删除该行) |
|
||||
| base_updated_at | number | 否 | 乐观锁:不传 = 强制覆盖(首次写入用);传入后与服务端当前 `updated_at` 不一致 → 返回 `40009` 冲突,不写入 |
|
||||
|
||||
**响应 `data`**
|
||||
|
||||
```
|
||||
data: {
|
||||
scope: string, // 写入的 scope
|
||||
updated_at: number // 本次写入后的最新毫秒时间戳(后续 set 用其作为 base_updated_at)
|
||||
}
|
||||
```
|
||||
|
||||
**成功示例**
|
||||
|
||||
```jsonc
|
||||
// 请求
|
||||
POST /system?method=user.preference.set&v=1.0×tamp=...
|
||||
{
|
||||
"scope": "order.sort.pending",
|
||||
"value": { "field": "create_at", "order": "desc" },
|
||||
"base_updated_at": 1720000000000
|
||||
}
|
||||
|
||||
// 响应
|
||||
{ "code": 200, "flag": "success", "message": "ok", "data": { "scope": "order.sort.pending", "updated_at": 1720000100000 } }
|
||||
```
|
||||
|
||||
**冲突示例(40009)**
|
||||
|
||||
```jsonc
|
||||
// 请求(base_updated_at 与服务端已不一致)
|
||||
{ "scope": "order.sort.pending", "value": { "field": "id", "order": "asc" }, "base_updated_at": 1720000000000 }
|
||||
|
||||
// 响应
|
||||
{ "code": 40009, "flag": "fail", "message": "配置已在其他设备更新", "data": { "current_updated_at": 1720000200000 } }
|
||||
```
|
||||
|
||||
> 冲突时建议后端在 `data` 返回 `current_updated_at`,供前端展示/提示「以本地为准覆盖」时使用。
|
||||
|
||||
---
|
||||
|
||||
## 6. 数据模型与 scope 注册表
|
||||
|
||||
### 6.1 存储模型(后端)
|
||||
|
||||
**关系表方案(推荐)**
|
||||
|
||||
```sql
|
||||
CREATE TABLE `user_preferences` (
|
||||
`user_id` BIGINT NOT NULL COMMENT '用户ID(服务端从 token 取)',
|
||||
`scope` VARCHAR(128) NOT NULL COMMENT '命名空间 key:<模块>.<能力>.<页面标识>',
|
||||
`value` JSON NOT NULL COMMENT '配置内容(不透明 JSON,前端各页定义结构)',
|
||||
`updated_at` BIGINT NOT NULL COMMENT '毫秒时间戳,用于乐观锁与跨设备同步探测',
|
||||
PRIMARY KEY (`user_id`, `scope`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='用户偏好配置';
|
||||
```
|
||||
|
||||
**Redis 方案(可选)**:`user_prefs:{userId}` Hash,field=scope,value=JSON;另存 `updated_at` 字段于同一 hash(或 `user_prefs_ver:{userId}`)。
|
||||
|
||||
### 6.2 scope 注册表(前后端共享白名单)
|
||||
|
||||
> 后端以此表做 `set` 白名单校验;前端以此表注册各页消费。新增功能 = 在此表加一行。
|
||||
|
||||
**本期(排序)**
|
||||
|
||||
| scope | 含义 |
|
||||
|-------|------|
|
||||
| `order.sort.review` | 待审核订单排序 |
|
||||
| `order.sort.pending` | 待处理订单排序 |
|
||||
| `order.sort.pendingException` | 待处理异常订单排序 |
|
||||
| `order.sort.delivery` | 配送单排序 |
|
||||
| `order.sort.archive` | 归档单排序 |
|
||||
| `order.sort.outbound` | 出库单排序 |
|
||||
|
||||
**预留(后续功能直接注册,后端接口零改动)**
|
||||
|
||||
| scope | 含义 |
|
||||
|-------|------|
|
||||
| `order.columns.<tab>` | 列显隐/顺序 |
|
||||
| `order.filter.preset.<tab>` | 筛选条件预设 |
|
||||
| `order.table.<tab>` | pageSize / 表格密度 |
|
||||
| `setting.*` | 基础管理设置类页面偏好(按 `模块.能力.页面` 命名) |
|
||||
|
||||
### 6.3 排序 value 结构(排序类 scope 的约定结构)
|
||||
|
||||
> 接口层不感知此结构(§2.4);下表是**前端各排序页面统一遵守**的 value 约定,便于跨页复用与后端抽查时理解。
|
||||
|
||||
```jsonc
|
||||
{
|
||||
"field": "create_at", // string:排序字段名,须命中各页 sort 白名单(前端校验)
|
||||
"order": "desc", // 'asc' | 'desc'
|
||||
"secondary": [ // 可选:多级排序预留(数组顺序=优先级)
|
||||
{ "field": "id", "order": "asc" }
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
- 消费时主排序取 `field/order`,转各列表接口的 `{ sortField, sortOrder }`(如 `order.list`)。
|
||||
- 若后端列表接口暂只支持单字段排序,本期只透传主排序(见 §11-3)。
|
||||
|
||||
---
|
||||
|
||||
## 7. 前端设计(前端按此实现)【接口方案版;方案B 复用其中 store 抽象、接入模板与兜底思路】
|
||||
|
||||
### 7.1 `userPreference` store 职责
|
||||
|
||||
新建 `src/stores/modules/userPreference.ts`(Pinia):
|
||||
|
||||
- `load()`:调 `user.preference.get`(不传 scope)拉取全部偏好 → 写内存 + localStorage(key 含 user_id,如 `user_prefs_{userId}`)。
|
||||
- `get(scope)`:内存 → localStorage → 默认值,逐级兜底。
|
||||
- `set(scope, value)`:本地立即生效 + 防抖写回 `user.preference.set`(带 `base_updated_at`)。
|
||||
- `reset(scope)`:`set(scope, {})` 清空该 scope。
|
||||
- `isLoaded` / `lastLoadedAt`:避免会话内重复全量拉取。
|
||||
|
||||
### 7.2 拉取时机(核心)
|
||||
|
||||
| 触发点 | 行为 |
|
||||
|--------|------|
|
||||
| 登录成功 / 整页刷新(`permission.ts` 守卫走 `userStore.getInfo()` 成功后) | 调 `preferenceStore.load()` 一次 |
|
||||
| SPA 内部切换 tab(`hasGetUserInfo` 早退分支) | **不**重复拉取(避免高频请求) |
|
||||
| 切到某 tab 时 | 读对应 `order.sort.<tabKey>`,填充 `currentSort` |
|
||||
|
||||
> 关键:`load()` 挂在 `getInfo` 成功路径之后,天然覆盖「登录」与「整页刷新」两种场景,满足跨设备刷新同步。
|
||||
|
||||
### 7.3 跨设备刷新同步机制
|
||||
|
||||
```mermaid
|
||||
sequenceDiagram
|
||||
participant A as 设备A(订单页)
|
||||
participant S as 服务端
|
||||
participant B as 设备B(另一台登录设备)
|
||||
A->>S: user.preference.set(order.sort.pending, 新排序)
|
||||
S-->>A: ok(updated_at)
|
||||
Note over B: 用户在设备B 刷新页面
|
||||
B->>S: getInfo(认证) → user.preference.get
|
||||
S-->>B: 返回最新配置
|
||||
B->>B: 填充 currentSort → 重新拉列表(带新排序)
|
||||
```
|
||||
|
||||
- 刷新即最新(每次刷新重新 `getInfo` + `preference.get`)。
|
||||
- 可选增强(非本期必需):`user.preference.version` 轻量探测 + 前端定时轮询,实现"不刷新也近实时"。
|
||||
|
||||
### 7.4 写回与乐观锁冲突处理
|
||||
|
||||
- 排序变更(`@sort-change`)→ 更新本地 `currentSort` → 防抖 500ms → `preference.set({ scope, value, base_updated_at })`。
|
||||
- `base_updated_at` = 最近一次 `get` 返回的该 scope `updated_at`。
|
||||
- 收到 `40009` 冲突:弹窗「该配置已在其他设备更新」→ 用户选择「以本地为准覆盖」(用 `data.current_updated_at` 作为新 base 重试 set)或「放弃本次修改」(用服务端最新值回填本地)。
|
||||
- 写回失败(网络/后端故障):不回滚本地排序,保留 `dirty` 标记,下次 `@sort-change` 或进入页面时重试。
|
||||
|
||||
### 7.5 排序消费(各页接入模板)
|
||||
|
||||
订单各子页(`reviewOrder/pendingOrder/pendingException/...`)、`waveOrder`、`basicManagement` 均已具备 `currentSort` → 列表 `sort` 参数链路,接入只需:
|
||||
|
||||
1. 定义 `tabKey`(稳定标识,如 `'pending'`,勿用易变路由 path)。
|
||||
2. 挂载时:`currentSort = normalizeSort(preferenceStore.get('order.sort.' + tabKey)) ?? 默认`。
|
||||
3. `@sort-change`:更新 `currentSort` 后 `preferenceStore.set('order.sort.' + tabKey, { field, order })`。
|
||||
4. 默认值来源:各页既有默认(如 `created_at desc`),无配置时行为与现在一致。
|
||||
|
||||
> 建议抽通用 composable `usePageSortPreference(tabKey, { whitelist, defaultSort })`,收敛多页重复代码。
|
||||
|
||||
### 7.6 兜底与降级
|
||||
|
||||
| 场景 | 行为 |
|
||||
|------|------|
|
||||
| `get` 失败(超时/报错/后端故障) | **不抛出、不阻塞**登录与路由;优先级:localStorage 缓存(记 `lastLoadedAt`)→ 各页默认配置;`console.warn` 一次 |
|
||||
| 响应结构异常(缺 data、scope 值非对象、value 非法) | 视为该 scope 无配置,走默认值,不让单条坏数据拖垮整包 |
|
||||
| `set` 失败(40008/40010/网络) | 提示错误;不回滚本地,保留 `dirty` 待重试 |
|
||||
| `set` 冲突(40009) | 见 §7.4 弹窗处理 |
|
||||
|
||||
---
|
||||
|
||||
## 8. 正式方案:纯浏览器本地保存(不使用接口)
|
||||
|
||||
> 本章为**正式方案(方案B)**:不新增任何后端接口,仅用浏览器存储保存配置。零后端依赖、每账号按 user_id 隔离、同设备跨刷新/会话生效;代价是**放弃跨设备同步**(§0 决策)。
|
||||
|
||||
### 8.1 定位与关键限制
|
||||
|
||||
- **零后端开发、零接口依赖**,纯前端实现。
|
||||
- **关键限制**:纯浏览器方案**无法实现「跨设备同步」**——数据不经过服务端,仅在同一设备、同一浏览器的跨刷新/跨会话内生效。若将来需要跨设备同步,再评估恢复接口方案(见 §0)。
|
||||
|
||||
### 8.2 实现
|
||||
|
||||
- **存储**:`localStorage`(key=`user_prefs_{userId}`,JSON 对象);配置体量增大或接近 5MB 上限时改用 IndexedDB。
|
||||
- **结构**:与接口方案保持一致(`{ [scope]: { value, updated_at } }`),便于将来无痛切换数据源。
|
||||
- **读写**:`userPreference` store 改为纯本地读写,无网络请求。
|
||||
- **每账号隔离**:key 含 user_id;登出不清除(保留账号配置),登录时按 user_id 读取。
|
||||
- **校验**:无服务端白名单,由前端自校验 scope / 结构 / 体积(仍建议单 scope ≤ 4KB)。
|
||||
- **写回**:直接写 localStorage;无网络开销,可即时写,也可防抖合并写入降低 IO。
|
||||
|
||||
### 8.3 与接口方案对比
|
||||
|
||||
| 能力 | 方案B(纯浏览器) | 方案A(接口) |
|
||||
|------|------------------|--------------|
|
||||
| 每账号绑定 | ✅ 同设备按 user_id 分 key | ✅ 服务端隔离 |
|
||||
| 刷新页面保留 | ✅ | ✅ |
|
||||
| **跨设备同步** | ❌ 无法 | ✅ |
|
||||
| 登录后自动获取 | ✅ 读本地 | ✅ 接口拉取 |
|
||||
| 后端开发量 | 零 | 需开发 get/set + 存储 |
|
||||
| 多端并发 / 乐观锁 | 不涉及(单端) | 需要(base_updated_at) |
|
||||
| 数据迁移 | 手动导出/导入 JSON | 天然同步 |
|
||||
| 安全 / 容量 | 前端自管,约 5MB/域名 | 服务端校验 + 体积上限 |
|
||||
|
||||
### 8.4 适用场景与建议
|
||||
|
||||
- 「跨设备同步」为硬需求 → **必须用接口方案**;纯浏览器方案仅作为其 **localStorage 兜底层**(即 §7.6 已有内容)。
|
||||
- 后端暂未排期、以单设备为主、可接受手动迁移 → 可先用方案B快速上线。
|
||||
- **推荐组合**:接口方案为正式形态;前端 store 将数据源抽象为「本地 / 服务端」两层,接口就绪前用本地层,就绪后切服务端层,**页面接入代码不变**(§7.5 的 `usePageSortPreference` 不感知数据源)。
|
||||
|
||||
### 8.5 从方案B平滑升级到方案A
|
||||
|
||||
1. store 定义统一读写接口:`load()` / `get(scope)` / `set(scope, value)`(页面只调这些,不关心数据源)。
|
||||
2. 本地层:读写 localStorage;服务端层:调 `user.preference.get/set`。
|
||||
3. 接口就绪后,将 store 数据源实现替换为服务端层,同时保留 localStorage 作为缓存/降级(§7.6)。
|
||||
4. scope 与 value 结构两端保持一致,无需迁移数据格式。
|
||||
|
||||
---
|
||||
|
||||
## 9. 扩展性设计
|
||||
|
||||
**新增一个功能 = 新增一个 scope**,与既有数据、登录接口、前端 store 互不干扰:
|
||||
|
||||
- 列配置 `order.columns.<tab>`:存 `{ visible, order }`,前端列表列渲染消费。
|
||||
- 筛选预设 `order.filter.preset.<tab>`:存 `{ name, where }`。
|
||||
- 其他模块 `report.*` / `storage.*` / `setting.*` 按同一命名规范注册即可。
|
||||
- 数据结构升级:每个 scope 可带 `schema_version`,前端按版本做 normalize 迁移。
|
||||
|
||||
因此可支撑 tab 数量增加与其他功能扩展,且**登录接口载荷恒定**(偏好不经过 getInfo)。
|
||||
|
||||
---
|
||||
|
||||
## 10. 里程碑
|
||||
|
||||
| 阶段 | 内容 | 验收 |
|
||||
|------|------|------|
|
||||
| M1 服务端 | `user_preferences` 存储 + `user.preference.get/set` + scope 白名单 + 体积/乐观锁 | 接口联调通过 |
|
||||
| M2 前端基础 | `userPreference` store + 登录/刷新拉取 + localStorage 缓存 | 登录后控制台可见偏好已加载 |
|
||||
| M3 排序落地 | 订单各 tab(+waveOrder/basicManagement)挂载读取 + `@sort-change` 防抖写回 | 双设备刷新互相同步通过 |
|
||||
| M4 扩展 | 列配置/筛选预设等新 scope 接入 | 新功能走同一套机制上线 |
|
||||
|
||||
---
|
||||
|
||||
## 11. 待确认事项(评审时与后端对齐)
|
||||
|
||||
1. 服务端存储选型:关系表 vs Redis。
|
||||
2. `user.preference.get` 是否支持 `scope` 批量(`scope[]`),还是先只支持缺省全量。
|
||||
3. 多级排序 `secondary` 本期是否透传到列表接口(取决于 `order.list` 是否支持多字段 sort;不支持则本期只用主排序)。
|
||||
4. 是否本期就做 `user.preference.version` 轮询增强,还是先做"刷新即同步"。
|
||||
5. 错误码段(§4)是否与现有后端错误码体系合并/调整。
|
||||
6. `value = {}` 表示清空该 scope 的约定是否可接受(后端需实现删除语义)。
|
||||
|
||||
193
docs/用户偏好配置-浏览器本地保存方案.md
Normal file
193
docs/用户偏好配置-浏览器本地保存方案.md
Normal file
@ -0,0 +1,193 @@
|
||||
# 用户偏好配置:每账号每页面自定义配置(浏览器本地保存方案)
|
||||
|
||||
- 状态:**已决策(正式方案)**
|
||||
- 日期:2026-09-01
|
||||
- 版本:v1.1
|
||||
- 说明:原「接口方案」已废弃(存档见 `docs/用户偏好配置-排序与跨设备同步设计.md`,不再使用)。**本文档为正式落地方案的唯一依据。**
|
||||
- 本期实现:**订单管理多标签页自定义排序**(v1.0 曾规划「列排序」,已按需求更正为「标签页顺序」,见 §3.3/§3.4/§4.5)。
|
||||
|
||||
---
|
||||
|
||||
## 1. 背景与目标
|
||||
|
||||
订单管理 `order/orderManagement` 顶部多标签页(待审核订单、待处理订单、待处理异常订单、配送单等)的显示顺序固定,部分账号希望把常用页签(如「待处理订单」)排到更靠前的位置。需要:
|
||||
|
||||
1. 可自定义**多标签页的显示顺序**(如把「待处理订单」拖到「待审核订单」前面)。
|
||||
2. 配置**绑定账号**(同设备内按 user_id 隔离保存)。
|
||||
3. **刷新 / 重新登录后自动应用**已保存配置。
|
||||
|
||||
> 取舍说明:本方案**不做「跨设备同步」**——数据保存在浏览器本地,不经过服务端,无法跨设备;仅同设备、同浏览器内跨刷新/跨会话生效。若将来需要跨设备同步,再评估是否引入接口方案。
|
||||
|
||||
方案设计为**模块无关**:除订单模块外,`order/waveOrder`、`setting/basicManagement` 等页面均可复用(按同一 key 规范注册即可)。
|
||||
|
||||
### 非目标(本期不做)
|
||||
|
||||
- 不做跨设备同步。
|
||||
- 不做多用户/角色的差异化权限(配置仅按 user_id 隔离)。
|
||||
- 不做列表数据列排序(如按订单ID/发货单号排序列表)——本期仅做**标签页顺序**,列排序留待后续按需接入。
|
||||
|
||||
---
|
||||
|
||||
## 2. 方案总览(纯浏览器本地保存)
|
||||
|
||||
- **存储**:`localStorage`,key = `user_prefs_{userId}`(JSON 对象);配置体量增大或接近 5MB 上限时改用 IndexedDB。
|
||||
- **每账号隔离**:key 含 user_id;登出**不清除**(保留账号配置),登录时按 user_id 读取。
|
||||
- **读写**:通过 `userPreference` store 统一读写,页面不直接操作 localStorage。
|
||||
- **即时生效**:标签顺序变更直接写本地,刷新/重登自动读取。
|
||||
|
||||
```mermaid
|
||||
flowchart LR
|
||||
A[标签排序弹窗拖拽] -->|保存| B[userPreference store]
|
||||
B --> C[(localStorage<br/>user_prefs_{userId})]
|
||||
D[登录/整页刷新] --> E[store.load 读取本地]
|
||||
E --> F[index.vue 按已存顺序重排 tabs]
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 3. 数据与命名规范
|
||||
|
||||
### 3.1 存储结构
|
||||
|
||||
```jsonc
|
||||
// localStorage key: user_prefs_{userId}
|
||||
{
|
||||
"order.tabs.order": {
|
||||
"value": ["pendingOrder", "reviewOrder", "exceptionOrder", "outboundOrder", "entrustWarehouse", "deliveryOrder", "deliveryException", "archiveOrder"],
|
||||
"updated_at": 1720000000000 // 毫秒时间戳,用于脏标记/冲突识别(预留)
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
- 预留 `updated_at` 是为了将来接入接口方案时无需迁移格式(§6)。
|
||||
- 单 scope `value` 仍建议 ≤ 4KB。
|
||||
|
||||
### 3.2 key 命名规范(scope)
|
||||
|
||||
统一格式:`<模块>.<能力>.<页面标识>`,全小写,`.` 分隔。
|
||||
|
||||
### 3.3 本期 scope 表(标签排序)
|
||||
|
||||
| scope | 含义 |
|
||||
|-------|------|
|
||||
| `order.tabs.order` | 订单管理多标签页显示顺序 |
|
||||
| `order.wave.tabs.order` | 波次管理(waveOrder)标签顺序 |
|
||||
| `stock.tabs.order` | 商品管理(stock/stockManagement)标签顺序 |
|
||||
| `setting.basicManagement.tabs.order` | 基础设置(basicManagement/newview)标签顺序 |
|
||||
| `order.sort.<tab>` | 各 tab 列表列排序(预留,v1.0 曾规划) |
|
||||
|
||||
预留(后续功能直接注册新 key):
|
||||
|
||||
| scope | 含义 |
|
||||
|-------|------|
|
||||
| `order.columns.<tab>` | 列显隐/顺序 |
|
||||
| `order.filter.preset.<tab>` | 筛选条件预设 |
|
||||
| `order.table.<tab>` | pageSize / 表格密度 |
|
||||
|
||||
### 3.4 标签顺序 value 结构(`order.tabs.order`)
|
||||
|
||||
```jsonc
|
||||
// value = tab.name 数组,数组顺序即标签页显示顺序
|
||||
{
|
||||
"order": ["pendingOrder", "reviewOrder", "exceptionOrder", "outboundOrder", "entrustWarehouse", "deliveryOrder", "deliveryException", "archiveOrder"]
|
||||
}
|
||||
```
|
||||
|
||||
- 消费时按数组顺序重排 `index.vue` 的 `tabs`(`applyTabOrder`);缺失/非法 tab 名自动剔除,新增 tab 自动补在末尾。
|
||||
- 未配置时使用默认顺序(`ORDER_TAB_LIST` 定义的顺序)。
|
||||
|
||||
---
|
||||
|
||||
## 4. 前端实现
|
||||
|
||||
### 4.1 `userPreference` store
|
||||
|
||||
新建 `src/stores/modules/userPreference.ts`(Pinia):
|
||||
|
||||
| 方法 | 行为 |
|
||||
|------|------|
|
||||
| `load()` | 按当前 user_id 从 localStorage 读取全部偏好 → 写内存;无缓存则置空 |
|
||||
| `get(scope)` | 内存 → 默认值,逐级兜底 |
|
||||
| `set(scope, value)` | 本地立即生效(写内存 + localStorage) |
|
||||
| `reset(scope)` | 删除该 scope(`localStorage` 中移除该 key) |
|
||||
| `isLoaded` / `lastLoadedAt` | 会话内加载状态标记 |
|
||||
|
||||
- `load()` 在 `src/permission.ts` 路由守卫 `userStore.getInfo()` 成功后调用一次(覆盖登录 + 整页刷新);SPA 内部切 tab 不重复调用。
|
||||
- `set()` 写回本地即时生效,无需网络;可防抖合并(500ms)减少 IO。
|
||||
|
||||
### 4.2 加载时机
|
||||
|
||||
| 触发点 | 行为 |
|
||||
|--------|------|
|
||||
| 登录成功 / 整页刷新(`getInfo` 成功后) | `preferenceStore.load()` 一次 |
|
||||
| SPA 内部切换 tab | 不重复 load |
|
||||
| orderManagement 挂载时 | 读 `order.tabs.order` 重排 tabs(`applySavedTabOrder`) |
|
||||
|
||||
### 4.3 写回
|
||||
|
||||
- 标签排序弹窗点「保存」→ `preferenceStore.set('order.tabs.order', tab.name 数组)` → 本地即时生效 + 持久化;父级按新顺序重排 tabs。
|
||||
|
||||
### 4.4 兜底与边界
|
||||
|
||||
| 场景 | 行为 |
|
||||
|------|------|
|
||||
| 无缓存 / 首次使用 | 用各页默认排序,不报错 |
|
||||
| localStorage 不可用/满(抛异常) | try/catch 兜底,降级为内存态,不阻塞页面 |
|
||||
| 结构异常(value 非对象等) | 视为该 scope 无配置,走默认值 |
|
||||
| 登出 | 不清除 localStorage(保留账号配置),重新登录按 user_id 读取 |
|
||||
|
||||
### 4.5 标签排序接入(本期已实现)
|
||||
|
||||
已接入页面(弹窗为**共享组件** `src/components/SortSettingDialog.vue`,props 传 `tabs`(默认顺序)+ `scope`(存储 key),各页只做入口 + 应用顺序):
|
||||
|
||||
1. **订单管理** `order/orderManagement`:配置 `ORDER_TAB_LIST`(`config/order-common-config.ts`),scope=`order.tabs.order`。
|
||||
2. **波次管理** `order/waveOrder`:inline tabs(5 个),scope=`order.wave.tabs.order`。
|
||||
3. **商品管理** `stock/stockManagement`:inline tabs(2 个),scope=`stock.tabs.order`。
|
||||
4. **基础设置** `setting/basicManagement`(newview):`tabPages` 配置驱动,scope=`setting.basicManagement.tabs.order`;`TabArea.vue` 增加 `headerLeftInset` 给入口按钮让位。
|
||||
|
||||
每页接入模式:
|
||||
|
||||
1. 入口:tab 区域左侧「标签排序」按钮(`.sort-entry-btn`)→ 打开 `SortSettingDialog`。
|
||||
2. 弹窗:`VueDraggable` 拖拽重排默认 tab 列表,点「保存」→ `preferenceStore.set(scope, names)` + `emit('saved', names)`。
|
||||
3. `index.vue`:`handleSortSaved(order)` → `applyTabOrder(order)` 重排 tabs;挂载时 `applySavedTabOrder()` 读取已存顺序。
|
||||
4. 无配置时保持默认顺序;非法/缺失项自动处理(缺失 tab 补末尾)。
|
||||
|
||||
---
|
||||
|
||||
## 5. 扩展性
|
||||
|
||||
**新增一个功能 = 新增一个 scope key**,store 与页面接入模板不变:
|
||||
|
||||
- 列配置 `order.columns.<tab>`:存 `{ visible, order }`。
|
||||
- 筛选预设 `order.filter.preset.<tab>`:存 `{ name, where }`。
|
||||
- 其他模块 `report.*` / `storage.*` / `setting.*` 按同一命名规范注册。
|
||||
|
||||
数据结构升级:每个 scope 可带 `schema_version`,前端按版本做 normalize 迁移。
|
||||
|
||||
---
|
||||
|
||||
## 6. 升级路径(将来如需跨设备同步)
|
||||
|
||||
1. store 保持统一读写接口 `load()/get(scope)/set(scope,value)/reset(scope)`,页面不感知数据源。
|
||||
2. 增加「服务端数据源」实现(`user.preference.get/set`),与本地层并存。
|
||||
3. 接口就绪后切换数据源,localStorage 降级为缓存/兜底。
|
||||
4. 数据结构(§3.1)两端保持一致,无需迁移格式。
|
||||
|
||||
---
|
||||
|
||||
## 7. 里程碑
|
||||
|
||||
| 阶段 | 内容 | 验收 |
|
||||
|------|------|------|
|
||||
| M1 store | `userPreference` store + 登录/刷新 load + localStorage 读写 | 登录后控制台可见偏好已加载 |
|
||||
| M2 标签排序落地 | orderManagement 标签排序弹窗 + 保存 + 挂载恢复 | 刷新/重登后标签顺序保持 |
|
||||
| M2.5 扩展页 | waveOrder / stockManagement / basicManagement 接入共享弹窗 | 4 页均可拖拽排序并持久化 |
|
||||
| M3 扩展 | 列配置/筛选预设等新 scope 接入 | 新功能走同一套机制上线 |
|
||||
|
||||
---
|
||||
|
||||
## 8. 遗留 / 待确认
|
||||
|
||||
1. 是否把标签排序扩展到其他多标签模块(如 `setting/encoding`、`express/waybill` 等,同机制注册新 scope)。
|
||||
2. 列表列排序(`order.sort.<tab>`)是否按需接入(本期仅做标签顺序)。
|
||||
3. 跨设备同步暂不做;若业务上出现强需求,再走 §6 升级路径。
|
||||
@ -119,11 +119,114 @@ export function returnReceivedDelete(data: ReturnReceivedDeleteParams): Promise<
|
||||
} as any)
|
||||
}
|
||||
|
||||
// ============ returnReceived.export ============
|
||||
|
||||
/** returnReceived.export 请求参数(where/sort 语义与 returnReceived.list 一致) */
|
||||
export type ReturnReceivedExportParams = {
|
||||
/** 查询条件,语义与 returnReceived.list 的 where 一致;禁止传 warehouse_id/warehouseId(服务端注入) */
|
||||
where?: Record<string, any>
|
||||
/** 排序参数,语义与 returnReceived.list 的 sort 一致 */
|
||||
sort?: {
|
||||
sortField?: string
|
||||
sortOrder?: string
|
||||
}
|
||||
}
|
||||
|
||||
/** returnReceived.export 响应(提交成功即返回任务受理信息) */
|
||||
export type ReturnReceivedExportResponse = {
|
||||
/** 任务 ID(后端生成,格式 return_received_export_{warehouseId}_{timestamp}_{random}) */
|
||||
task_id: string
|
||||
/** 任务状态:submitted/running/success/failed/not_found(提交成功时为 submitted) */
|
||||
status: string
|
||||
/** 当前进度百分比(0-100),提交时返回 0 */
|
||||
progress: number
|
||||
/** 当前已处理记录数(登记记录条数) */
|
||||
current_count: number
|
||||
/** 总记录数 */
|
||||
total_count: number
|
||||
/** 任务提示信息 */
|
||||
message: string
|
||||
/** 任务执行结果(提交时为 null;完成后为上传信息对象) */
|
||||
result: Record<string, unknown> | null
|
||||
/** 失败时的错误信息 */
|
||||
error: string
|
||||
/** 任务更新时间(Unix 毫秒时间戳) */
|
||||
update_time: number
|
||||
code?: number
|
||||
}
|
||||
|
||||
/** returnReceived.export:提交退回收到登记导出任务(异步,返回 task_id) */
|
||||
export function returnReceivedExport(data: ReturnReceivedExportParams = {}): Promise<ReturnReceivedExportResponse> {
|
||||
return request({
|
||||
url: '/system',
|
||||
method: 'post',
|
||||
params: {
|
||||
method: 'returnReceived.export',
|
||||
v,
|
||||
timestamp: new Date().getTime()
|
||||
},
|
||||
data,
|
||||
isSystemApi: true
|
||||
} as any)
|
||||
}
|
||||
|
||||
// ============ returnReceived.exportTaskProgress ============
|
||||
|
||||
/** returnReceived.exportTaskProgress 请求参数 */
|
||||
export type ReturnReceivedExportTaskProgressParams = {
|
||||
/** 任务 ID(下划线写法,兼容) */
|
||||
task_id?: string
|
||||
/** 任务 ID(驼峰写法,兼容) */
|
||||
taskId?: string
|
||||
}
|
||||
|
||||
/** returnReceived.exportTaskProgress 响应 */
|
||||
export type ReturnReceivedExportTaskProgressResponse = {
|
||||
/** 任务 ID(缺失时为空字符串,status=not_found) */
|
||||
task_id: string
|
||||
/** 任务状态:submitted/running/success/failed/not_found */
|
||||
status: string
|
||||
/** 进度百分比(0-100) */
|
||||
progress: number
|
||||
/** 当前已处理记录数(登记记录条数) */
|
||||
current_count: number
|
||||
/** 总记录数 */
|
||||
total_count: number
|
||||
/** 任务提示信息 */
|
||||
message: string
|
||||
/** 任务执行结果对象(完成后含 filename/url/fileKey/cdnUrl/cosUrl 等) */
|
||||
result: Record<string, unknown> | null
|
||||
/** 失败时的错误信息 */
|
||||
error: string
|
||||
/** 任务完成后下载链接;未完成或不存在时为空字符串 */
|
||||
download_url: string
|
||||
/** 最近一次状态更新时间(Unix 毫秒时间戳) */
|
||||
update_time: number
|
||||
code?: number
|
||||
}
|
||||
|
||||
/** returnReceived.exportTaskProgress:按 task_id 查询退回收到导出任务进度 */
|
||||
export function returnReceivedExportTaskProgress(data: ReturnReceivedExportTaskProgressParams): Promise<ReturnReceivedExportTaskProgressResponse> {
|
||||
return request({
|
||||
url: '/system',
|
||||
method: 'post',
|
||||
params: {
|
||||
method: 'returnReceived.exportTaskProgress',
|
||||
v,
|
||||
timestamp: new Date().getTime()
|
||||
},
|
||||
data,
|
||||
isSystemApi: true
|
||||
} as any)
|
||||
}
|
||||
|
||||
// ============ 模块导出 ============
|
||||
|
||||
export const returnReceivedModule = {
|
||||
create: returnReceivedCreate,
|
||||
list: returnReceivedList,
|
||||
detail: returnReceivedDetail,
|
||||
delete: returnReceivedDelete
|
||||
delete: returnReceivedDelete,
|
||||
export: returnReceivedExport,
|
||||
exportTaskProgress: returnReceivedExportTaskProgress
|
||||
}
|
||||
@ -435,10 +435,69 @@ export function backData(data: any) {
|
||||
} as any)
|
||||
}
|
||||
|
||||
/** stock.warehouse.getStockDetail 库存明细行(storageList 元素) */
|
||||
export type StockWarehouseStorageItem = {
|
||||
/** 明细ID */
|
||||
id?: number
|
||||
/** 库位ID */
|
||||
space_id?: number
|
||||
/** 库位名称 */
|
||||
space_name?: string
|
||||
/** 批次号(group_by_batch=false 按库位合并时为 null) */
|
||||
batch_no?: string | null
|
||||
/** 生产日期(按库位合并时为 null) */
|
||||
production_date?: string | null
|
||||
/** 到期日期(按库位合并时为 null) */
|
||||
expiry_date?: string | null
|
||||
/** 入库时间(按库位合并时为 null) */
|
||||
inbound_time?: string | null
|
||||
/** 入库单号(按库位合并时为 null) */
|
||||
inbound_order_no?: string | null
|
||||
/** 供应商批次号(按库位合并时为 null) */
|
||||
supplier_batch_no?: string | null
|
||||
/** 数量 */
|
||||
quantity?: number
|
||||
/** 锁定数量 */
|
||||
locked_quantity?: number
|
||||
/** 拦截锁定数量(按库位合并明细,默认 0) */
|
||||
intercept_locked_quantity?: number
|
||||
/** 可用数量 = quantity - locked_quantity - intercept_locked_quantity */
|
||||
available_quantity?: number
|
||||
[key: string]: any
|
||||
}
|
||||
|
||||
/** stock.warehouse.getStockDetail 响应 */
|
||||
export type StockWarehouseDetailResponse = {
|
||||
code?: number
|
||||
message?: string
|
||||
/** 响应数据 */
|
||||
data?: {
|
||||
/** 商品概要,包含 id、item_code、item_name、sku_property、stock_unit、quantity、locked_quantity 等 */
|
||||
stockItem?: {
|
||||
id?: number
|
||||
item_code?: string
|
||||
item_name?: string
|
||||
sku_property?: string
|
||||
stock_unit?: string
|
||||
quantity?: number
|
||||
locked_quantity?: number
|
||||
[key: string]: any
|
||||
}
|
||||
/** 库存明细数组;group_by_batch=true 返回 wms_storage 明细,false 按库位合并 */
|
||||
storageList?: StockWarehouseStorageItem[]
|
||||
/** 分页信息 */
|
||||
pagination?: {
|
||||
page: number
|
||||
pageSize: number
|
||||
total: number
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export function getStockDetail(
|
||||
stock_id: number,
|
||||
options?: { page?: number; pageSize?: number; group_by_batch?: boolean }
|
||||
) {
|
||||
): Promise<StockWarehouseDetailResponse> {
|
||||
const data: Record<string, unknown> = { stock_id }
|
||||
if (options?.group_by_batch !== undefined) {
|
||||
data.group_by_batch = options.group_by_batch
|
||||
|
||||
@ -523,6 +523,7 @@
|
||||
<span v-else class="no-value-tip">无需填值</span>
|
||||
</div>
|
||||
<template v-else-if="isRangeOperator(resolveFieldOperator(field))">
|
||||
<span class="compact-field-label">{{ field.label }}</span>
|
||||
<div class="compact-field-control">
|
||||
<el-input
|
||||
:model-value="customConditions[field.value].valueMin"
|
||||
|
||||
172
src/components/SortSettingDialog.vue
Normal file
172
src/components/SortSettingDialog.vue
Normal file
@ -0,0 +1,172 @@
|
||||
<!--
|
||||
SortSettingDialog — 标签排序弹窗(通用)
|
||||
作用:调整页面顶部多标签页的显示顺序(如把「待处理订单」拖到「待审核订单」前面)
|
||||
存储:localStorage(key=user_prefs_{userId},scope 由调用方传入,value=tab.name 数组)
|
||||
设计文档:docs/用户偏好配置-浏览器本地保存方案.md
|
||||
用法:
|
||||
<SortSettingDialog
|
||||
v-model:visible="visible"
|
||||
:tabs="DEFAULT_TAB_OPTIONS" // { name, label }[],顺序即默认顺序
|
||||
:scope="'order.tabs.order'" // 存储 scope,按页面区分
|
||||
@saved="handleSortSaved" // (order: string[])
|
||||
/>
|
||||
-->
|
||||
<template>
|
||||
<el-dialog
|
||||
:model-value="visible"
|
||||
title="标签排序"
|
||||
width="520px"
|
||||
align-center
|
||||
destroy-on-close
|
||||
:close-on-click-modal="false"
|
||||
append-to-body
|
||||
@update:model-value="(v: boolean) => emit('update:visible', v)"
|
||||
@closed="handleClosed"
|
||||
>
|
||||
<div class="tab-order-tip">
|
||||
拖动左侧把手调整标签页显示顺序,保存后刷新/重新登录仍生效(按当前账号保存在浏览器本地)。
|
||||
</div>
|
||||
|
||||
<VueDraggable
|
||||
v-model="orderList"
|
||||
:animation="180"
|
||||
handle=".tab-order-handle"
|
||||
ghost-class="tab-order-ghost"
|
||||
class="tab-order-list"
|
||||
>
|
||||
<div v-for="(tab, idx) in orderList" :key="tab.name" class="tab-order-row">
|
||||
<span class="tab-order-handle">
|
||||
<el-icon><Rank /></el-icon>
|
||||
</span>
|
||||
<span class="tab-order-index">{{ idx + 1 }}</span>
|
||||
<span class="tab-order-label">{{ tab.label }}</span>
|
||||
</div>
|
||||
</VueDraggable>
|
||||
|
||||
<template #footer>
|
||||
<el-button size="small" @click="handleClosed">取消</el-button>
|
||||
<el-button size="small" @click="resetOrder">恢复默认</el-button>
|
||||
<el-button size="small" type="primary" @click="handleSave">保存</el-button>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref, watch } from 'vue'
|
||||
import { Rank } from '@element-plus/icons-vue'
|
||||
import { VueDraggable } from 'vue-draggable-plus'
|
||||
import { useUserPreferenceStore } from '@/stores/modules/userPreference'
|
||||
|
||||
defineOptions({ name: 'SortSettingDialog' })
|
||||
|
||||
export interface TabOrderOption {
|
||||
name: string
|
||||
label: string
|
||||
}
|
||||
|
||||
const props = defineProps<{
|
||||
visible: boolean
|
||||
/** 该页面全部 tab(name + 中文 label),顺序即默认顺序 */
|
||||
tabs: TabOrderOption[]
|
||||
/** 存储 scope(如 order.tabs.order / stock.tabs.order) */
|
||||
scope: string
|
||||
}>()
|
||||
|
||||
const emit = defineEmits<{
|
||||
(e: 'update:visible', v: boolean): void
|
||||
(e: 'saved', order: string[]): void
|
||||
}>()
|
||||
|
||||
const pref = useUserPreferenceStore()
|
||||
|
||||
const orderList = ref<TabOrderOption[]>([])
|
||||
|
||||
watch(
|
||||
() => props.visible,
|
||||
(v) => {
|
||||
if (!v) return
|
||||
orderList.value = buildOrderList()
|
||||
}
|
||||
)
|
||||
|
||||
/** 读取已保存顺序;非法项剔除,缺失的 tab 按 props.tabs 补在末尾(防新增 tab 丢项) */
|
||||
function buildOrderList(): TabOrderOption[] {
|
||||
const byName = new Map(props.tabs.map((t) => [t.name, t]))
|
||||
const saved = pref.get(props.scope)
|
||||
const names = Array.isArray(saved)
|
||||
? saved.filter((n: unknown) => typeof n === 'string' && byName.has(n))
|
||||
: []
|
||||
const result = Array.from(new Set(names)).map((n) => byName.get(n)!)
|
||||
for (const t of props.tabs) {
|
||||
if (!result.some((r) => r.name === t.name)) result.push({ ...t })
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
function resetOrder() {
|
||||
orderList.value = props.tabs.map((t) => ({ ...t }))
|
||||
}
|
||||
|
||||
function handleSave() {
|
||||
const names = orderList.value.map((t) => t.name)
|
||||
pref.set(props.scope, names)
|
||||
emit('saved', names)
|
||||
handleClosed()
|
||||
}
|
||||
|
||||
function handleClosed() {
|
||||
emit('update:visible', false)
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.tab-order-tip {
|
||||
font-size: 12px;
|
||||
color: #909399;
|
||||
margin-bottom: 12px;
|
||||
line-height: 1.6;
|
||||
}
|
||||
|
||||
.tab-order-list {
|
||||
max-height: 320px;
|
||||
overflow: auto;
|
||||
}
|
||||
|
||||
.tab-order-row {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 10px;
|
||||
padding: 9px 12px;
|
||||
margin-bottom: 8px;
|
||||
border: 1px solid #e8eef7;
|
||||
border-radius: 6px;
|
||||
background: #fafbfe;
|
||||
|
||||
.tab-order-handle {
|
||||
cursor: grab;
|
||||
color: #909399;
|
||||
display: inline-flex;
|
||||
&:active {
|
||||
cursor: grabbing;
|
||||
}
|
||||
}
|
||||
|
||||
.tab-order-index {
|
||||
width: 20px;
|
||||
text-align: center;
|
||||
font-size: 12px;
|
||||
color: #909399;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.tab-order-label {
|
||||
font-size: 13px;
|
||||
color: #303133;
|
||||
}
|
||||
}
|
||||
|
||||
.tab-order-ghost {
|
||||
opacity: 0.4;
|
||||
border-style: dashed;
|
||||
}
|
||||
</style>
|
||||
@ -1,4 +1,4 @@
|
||||
<template>
|
||||
<template>
|
||||
<div class="navbar">
|
||||
<img src="/logo/1.png" alt="logo" class="logo">
|
||||
<breadcrumb v-if="layoutMode !== 'top-bottom'" class="breadcrumb-container" />
|
||||
@ -101,7 +101,7 @@ import LangSelect from '@/components/LangSelect/index.vue'
|
||||
import TopMenu from './TopMenu.vue'
|
||||
import dayjs from 'dayjs'
|
||||
import { useFullscreen } from '@vueuse/core'
|
||||
import { afterSaleWorkCount, afterSaleWorkList } from '@/api/afterSale/index'
|
||||
import { afterSaleWorkCount, afterSaleWorkList } from '@/api/aftersale/index'
|
||||
|
||||
const { isFullscreen, toggle } = useFullscreen()
|
||||
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
import router from './router'
|
||||
import { useUserStore } from '@/stores/modules/user'
|
||||
import { useUserPreferenceStore } from '@/stores/modules/userPreference'
|
||||
import { usePermissionStore } from '@/stores/modules/permission'
|
||||
import { ElMessage } from 'element-plus'
|
||||
import NProgress from 'nprogress'
|
||||
@ -78,6 +79,9 @@ router.beforeEach(async (to, from) => {
|
||||
// get user info
|
||||
const user = await userStore.getInfo()
|
||||
ensurePrinterConnectionsAfterLogin()
|
||||
|
||||
// 加载用户偏好配置(浏览器本地保存:登录 + 整页刷新均在此触发)
|
||||
useUserPreferenceStore().load()
|
||||
|
||||
const permissionStore = usePermissionStore()
|
||||
// generate accessible routes based on menus
|
||||
|
||||
88
src/stores/modules/userPreference.ts
Normal file
88
src/stores/modules/userPreference.ts
Normal file
@ -0,0 +1,88 @@
|
||||
import { defineStore } from 'pinia'
|
||||
import { useUserStore } from './user'
|
||||
|
||||
/**
|
||||
* 用户偏好配置(纯浏览器本地保存,正式方案)
|
||||
*
|
||||
* - 存储:localStorage,key = `user_prefs_{userId}`,结构 `{ [scope]: { value, updated_at } }`
|
||||
* - 按账号(user_id)隔离:key 含 user_id;登出不清除,登录按 user_id 读取
|
||||
* - 设计文档:docs/用户偏好配置-浏览器本地保存方案.md
|
||||
*/
|
||||
interface PreferenceEntry {
|
||||
/** 配置内容(不透明 JSON,由各功能定义结构) */
|
||||
value: any
|
||||
/** 毫秒时间戳(预留:脏标记/将来接入服务端数据源的乐观锁) */
|
||||
updated_at: number
|
||||
}
|
||||
|
||||
interface State {
|
||||
/** scope → { value, updated_at } */
|
||||
map: Record<string, PreferenceEntry>
|
||||
/** 会话内是否已 load 过 */
|
||||
isLoaded: boolean
|
||||
/** 最近一次 load 时间戳 */
|
||||
lastLoadedAt: number
|
||||
}
|
||||
|
||||
const STORAGE_PREFIX = 'user_prefs_'
|
||||
|
||||
/** 稳定取当前用户标识:employees_id > id > roleId,取不到用 'unknown' */
|
||||
function currentUserId(): string {
|
||||
const userStore = useUserStore()
|
||||
const user = userStore.user || {}
|
||||
const id = user.employees_id ?? user.id ?? userStore.roleId
|
||||
return id != null && id !== '' ? String(id) : 'unknown'
|
||||
}
|
||||
|
||||
export const useUserPreferenceStore = defineStore('userPreference', {
|
||||
state: (): State => ({
|
||||
map: {},
|
||||
isLoaded: false,
|
||||
lastLoadedAt: 0
|
||||
}),
|
||||
|
||||
actions: {
|
||||
/** 按当前 user_id 从 localStorage 读取全部偏好;无缓存/解析失败置空,不抛异常 */
|
||||
load() {
|
||||
const key = STORAGE_PREFIX + currentUserId()
|
||||
try {
|
||||
const raw = localStorage.getItem(key)
|
||||
const parsed = raw ? JSON.parse(raw) : {}
|
||||
this.map = parsed && typeof parsed === 'object' && !Array.isArray(parsed) ? parsed : {}
|
||||
} catch {
|
||||
this.map = {}
|
||||
}
|
||||
this.isLoaded = true
|
||||
this.lastLoadedAt = Date.now()
|
||||
},
|
||||
|
||||
/** 读取某 scope 的 value;无配置返回 undefined */
|
||||
get(scope: string): any {
|
||||
return this.map[scope]?.value
|
||||
},
|
||||
|
||||
/** 写入某 scope:本地立即生效 + 持久化 */
|
||||
set(scope: string, value: any) {
|
||||
this.map[scope] = { value, updated_at: Date.now() }
|
||||
this.persist()
|
||||
},
|
||||
|
||||
/** 删除某 scope */
|
||||
reset(scope: string) {
|
||||
if (scope in this.map) {
|
||||
delete this.map[scope]
|
||||
this.persist()
|
||||
}
|
||||
},
|
||||
|
||||
/** 写入 localStorage;禁用/超限等异常静默降级为内存态,不阻塞页面 */
|
||||
persist() {
|
||||
const key = STORAGE_PREFIX + currentUserId()
|
||||
try {
|
||||
localStorage.setItem(key, JSON.stringify(this.map))
|
||||
} catch {
|
||||
// 忽略:降级为内存态
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
894
src/test.txt
894
src/test.txt
File diff suppressed because one or more lines are too long
@ -1,4 +1,4 @@
|
||||
<template>
|
||||
<template>
|
||||
<el-dialog
|
||||
:model-value="visible"
|
||||
:title="detail ? `售后明细 - ${detail.after_sale_no}` : '售后明细'"
|
||||
@ -254,7 +254,7 @@ import {
|
||||
type AfterSale,
|
||||
type AfterSaleStep,
|
||||
type AfterSaleRelated,
|
||||
} from '@/api/afterSale/index'
|
||||
} from '@/api/aftersale/index'
|
||||
import { orderQueryOrderLogList, type OrderLogListItem } from '@/api/order.index/orderindex'
|
||||
import { getCOSUploadConfig, uploadSuccessNotify } from '@/api/index/index'
|
||||
import {
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
<template>
|
||||
<template>
|
||||
<el-dialog v-model="visible" title="登记理赔" width="550px" align-center append-to-body destroy-on-close @closed="resetForm">
|
||||
<el-form ref="formRef" :model="form" :rules="rules" label-width="110px" size="small">
|
||||
<el-divider content-position="left">仓库理赔</el-divider>
|
||||
@ -35,7 +35,7 @@
|
||||
<script setup lang="ts">
|
||||
import { ref, reactive } from 'vue'
|
||||
import { ElMessage, type FormInstance, type FormRules } from 'element-plus'
|
||||
import { afterSaleRegisterClaim } from '@/api/afterSale/index'
|
||||
import { afterSaleRegisterClaim } from '@/api/aftersale/index'
|
||||
import { CLAIM_STATUS_MAP } from '@/views/afterSale/list/afterSale-config'
|
||||
|
||||
const props = defineProps<{ afterSaleId: number; claimNeeded?: 0|1; claimAmount?: number|null; claimStatus?: string|null; carrierClaimNeeded?: 0|1; carrierClaimAmount?: number|null; carrierClaimStatus?: string|null }>()
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
<template>
|
||||
<template>
|
||||
<el-dialog v-model="visible" title="处理工单" width="500px" align-center append-to-body destroy-on-close @closed="resetForm">
|
||||
<el-form ref="formRef" :model="form" :rules="rules" label-width="100px" size="small">
|
||||
<el-form-item label="更新状态" prop="status">
|
||||
@ -39,7 +39,7 @@
|
||||
import { ref, reactive } from 'vue'
|
||||
import { ElMessage, type FormInstance, type FormRules } from 'element-plus'
|
||||
import { Plus } from '@element-plus/icons-vue'
|
||||
import { afterSaleHandleWorkOrder } from '@/api/afterSale/index'
|
||||
import { afterSaleHandleWorkOrder } from '@/api/aftersale/index'
|
||||
import { getCOSUploadConfig, uploadSuccessNotify } from '@/api/index/index'
|
||||
|
||||
const props = defineProps<{ afterSaleId: number; currentStatus?: string }>()
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
<template>
|
||||
<template>
|
||||
<el-dialog v-model="visible" title="转单" width="450px" align-center append-to-body destroy-on-close @closed="resetForm">
|
||||
<el-form ref="formRef" :model="form" :rules="rules" label-width="100px" size="small">
|
||||
<el-form-item label="目标角色组" prop="role_group">
|
||||
@ -20,7 +20,7 @@
|
||||
<script setup lang="ts">
|
||||
import { ref, reactive } from 'vue'
|
||||
import { ElMessage, type FormInstance, type FormRules } from 'element-plus'
|
||||
import { afterSaleTransfer } from '@/api/afterSale/index'
|
||||
import { afterSaleTransfer } from '@/api/aftersale/index'
|
||||
|
||||
const props = defineProps<{ afterSaleId: number }>()
|
||||
const emit = defineEmits<{ success: [] }>()
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
<template>
|
||||
<template>
|
||||
<div class="after-sale-detail-container">
|
||||
<!-- 顶部标题栏 -->
|
||||
<div class="detail-header-bar">
|
||||
@ -353,7 +353,7 @@ import {
|
||||
type AfterSaleHandleWorkOrderParams,
|
||||
type AfterSaleTransferParams,
|
||||
type AfterSaleRegisterClaimParams,
|
||||
} from '@/api/afterSale/index'
|
||||
} from '@/api/aftersale/index'
|
||||
import { getCOSUploadConfig, uploadSuccessNotify } from '@/api/index/index'
|
||||
import {
|
||||
AFTER_SALE_TYPE_MAP,
|
||||
|
||||
@ -233,7 +233,7 @@ import {
|
||||
type AfterSaleCreateParams,
|
||||
type AfterSaleUpdateParams,
|
||||
type AfterSaleTransferParams,
|
||||
} from '@/api/afterSale/index'
|
||||
} from '@/api/aftersale/index'
|
||||
import {
|
||||
getAfterSaleAvailableFields,
|
||||
afterSaleAvailableFields,
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
<template>
|
||||
<template>
|
||||
<div class="order-sub-container">
|
||||
<scan-box
|
||||
ref="scanBox"
|
||||
@ -63,11 +63,13 @@
|
||||
:table-size="tableSize"
|
||||
:pagination="upperPagination"
|
||||
:show-index="true"
|
||||
:show-selection="true"
|
||||
:show-actions="true"
|
||||
:enable-column-config="true"
|
||||
:loading="loading"
|
||||
:query-time="queryTime"
|
||||
@current-change="handleRowClick"
|
||||
@selection-change="handleSelectionChange"
|
||||
@page-change="handlePageChange"
|
||||
@page-size-change="handlePageSizeChange"
|
||||
@refresh="handleRefresh"
|
||||
@ -171,13 +173,27 @@
|
||||
</template>
|
||||
</div>
|
||||
</el-dialog>
|
||||
|
||||
<!-- 退回收到导出进度(returnReceived.export + returnReceived.exportTaskProgress) -->
|
||||
<AsyncExportProgressDialog
|
||||
v-model:visible="exportDialogVisible"
|
||||
title="退回收到导出进度"
|
||||
:loading="exportLoading"
|
||||
:progress-percent="exportProgressPercent"
|
||||
:progress-status="exportProgressStatus"
|
||||
:status-label="exportStatusLabel"
|
||||
:task-id="exportTaskProgress.taskId"
|
||||
:message="exportTaskProgress.message"
|
||||
:error="exportTaskProgress.error"
|
||||
:update-time="exportTaskProgress.updateTime"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { computed, onMounted, reactive, ref } from 'vue'
|
||||
import { ElMessage, ElMessageBox } from 'element-plus'
|
||||
import { returnReceivedList, returnReceivedCreate, returnReceivedDetail, returnReceivedDelete } from '@/api/returnReceived'
|
||||
import { returnReceivedList, returnReceivedCreate, returnReceivedDetail, returnReceivedDelete, returnReceivedExport, returnReceivedExportTaskProgress } from '@/api/returnreceived'
|
||||
import { loadStores } from '@/api/index/index'
|
||||
import { extractStoreListFromResponse, fillStoreScanFieldOptions } from '@/views/order/orderManagement/config/order-common-config'
|
||||
import type { ToolbarButtonConfig } from '@/views/order/orderManagement/config/order-common-config'
|
||||
@ -185,6 +201,8 @@ import { returnReceivedAvailableFields, returnReceivedColumns, returnReceivedToo
|
||||
import ScanBox from '@/components/ScanBox/index.vue'
|
||||
import UpperTable from '@/components/UpperTable/index.vue'
|
||||
import OrderToolbarButtonGroup from '@/views/order/orderManagement/component/OrderToolbarButtonGroup.vue'
|
||||
import { useAsyncExportTask } from '@/composables/useAsyncExportTask'
|
||||
import AsyncExportProgressDialog from '@/components/AsyncExportProgressDialog.vue'
|
||||
import { safeInvoke } from '@/utils/safe-invoke'
|
||||
|
||||
// ==================== 常量 / 工具 ====================
|
||||
@ -242,7 +260,28 @@ const columns = returnReceivedColumns
|
||||
const tableSize = 'small'
|
||||
const toolbarButtons: ToolbarButtonConfig[] = returnReceivedToolbarButtons
|
||||
|
||||
const buttonLoadingMap = ref<Record<string, boolean>>({ loading: false })
|
||||
// ─── 退回收到导出(returnReceived.export + returnReceived.exportTaskProgress) ──
|
||||
// 下拉选项:导出选中(按勾选记录运单号导出)/ 导出全部(全量导出)
|
||||
const {
|
||||
exportLoading,
|
||||
exportDialogVisible,
|
||||
exportTaskProgress,
|
||||
exportProgressPercent,
|
||||
exportProgressStatus,
|
||||
exportStatusLabel,
|
||||
submitExportTask,
|
||||
resumeExportTaskFromStorage,
|
||||
hasPendingExportTask,
|
||||
} = useAsyncExportTask({
|
||||
storageKey: 'express:returnReceived:exportTaskId',
|
||||
submitExport: (payload) => returnReceivedExport(payload as any),
|
||||
queryProgress: (params) => returnReceivedExportTaskProgress(params),
|
||||
})
|
||||
|
||||
const buttonLoadingMap = computed<Record<string, boolean>>(() => ({
|
||||
loading: loading.value,
|
||||
exportLoading: exportLoading.value,
|
||||
}))
|
||||
const buttonDisabledMap = ref<Record<string, boolean>>({})
|
||||
const buttonLabelMap = ref<Record<string, string>>({})
|
||||
const toolbarLayoutKey = ref('')
|
||||
@ -262,6 +301,8 @@ function resolveButtonLabel(defaultLabel: string, dynamicLabelKey?: string) {
|
||||
const toolbarActionMap: Record<string, () => void> = {
|
||||
loadData: () => { handleRefresh() },
|
||||
openColumnConfigPanel: () => openColumnConfigPanel(),
|
||||
handleExportSelected: () => { void handleExportSelected() },
|
||||
handleExportAll: () => { void handleExportAll() },
|
||||
}
|
||||
|
||||
function openColumnConfigPanel() {
|
||||
@ -281,12 +322,73 @@ const upperTable = ref<any>(null)
|
||||
const loading = ref(false)
|
||||
const queryTime = ref(0)
|
||||
const tableData = ref<any[]>([])
|
||||
const selectionRows = ref<any[]>([])
|
||||
const currentConditions = ref<Record<string, any>>({})
|
||||
const currentSort = ref<{ prop: string; order: string }>({ prop: '', order: '' })
|
||||
|
||||
const pagination = reactive({ currentPage: 1, pageSize: 20, total: 0 })
|
||||
const upperPagination = reactive({ currentPage: 1, pageSize: 20, total: 0 })
|
||||
|
||||
// ─── 导出处理(导出选中 / 导出全部) ──────────────────────────────────────────
|
||||
// where/sort 语义与 returnReceived.list 一致:
|
||||
// - 导出选中:仅传勾选记录运单号 waybill_code({ operator:'in', value: waybillCodes }),不叠加筛选条件
|
||||
// - 导出全部:不传 where(全量导出,等价于 list 无筛选);sort 按当前排序透传
|
||||
function buildReturnReceivedExportPayload(selected: boolean): Record<string, any> {
|
||||
const payload: Record<string, any> = {}
|
||||
if (selected) {
|
||||
const waybillCodes = selectionRows.value
|
||||
.map((row: any) => row?.waybill_code)
|
||||
.filter((v: any) => v !== undefined && v !== null && String(v).trim() !== '')
|
||||
if (waybillCodes.length) {
|
||||
payload.where = { waybill_code: { operator: 'in', value: waybillCodes } }
|
||||
}
|
||||
}
|
||||
if (currentSort.value.prop) {
|
||||
payload.sort = {
|
||||
sortField: currentSort.value.prop,
|
||||
sortOrder: currentSort.value.order === 'ascending' ? 'asc' : 'desc',
|
||||
}
|
||||
}
|
||||
return payload
|
||||
}
|
||||
|
||||
async function handleExportSelected() {
|
||||
if (!selectionRows.value.length) {
|
||||
ElMessage.warning('请先勾选要导出的退回收件记录')
|
||||
return
|
||||
}
|
||||
if (hasPendingExportTask()) {
|
||||
ElMessage.warning('检测到未完成导出任务,请等待当前任务完成后再试')
|
||||
resumeExportTaskFromStorage()
|
||||
return
|
||||
}
|
||||
const waybillCodes = selectionRows.value
|
||||
.map((row: any) => row?.waybill_code)
|
||||
.filter((v: any) => v !== undefined && v !== null && String(v).trim() !== '')
|
||||
if (!waybillCodes.length) {
|
||||
ElMessage.warning('选中的记录无有效退回运单号')
|
||||
return
|
||||
}
|
||||
await submitExportTask(buildReturnReceivedExportPayload(true))
|
||||
}
|
||||
|
||||
async function handleExportAll() {
|
||||
if (!tableData.value.length) {
|
||||
ElMessage.warning('当前无数据可导出')
|
||||
return
|
||||
}
|
||||
if (hasPendingExportTask()) {
|
||||
ElMessage.warning('检测到未完成导出任务,请等待当前任务完成后再试')
|
||||
resumeExportTaskFromStorage()
|
||||
return
|
||||
}
|
||||
await submitExportTask(buildReturnReceivedExportPayload(false))
|
||||
}
|
||||
|
||||
function handleSelectionChange(rows: any[]) {
|
||||
selectionRows.value = rows || []
|
||||
}
|
||||
|
||||
// ==================== ScanBox 事件 ====================
|
||||
|
||||
function handleConditionChange(conditions: Record<string, any>) {
|
||||
@ -514,6 +616,8 @@ async function loadStoreOptions() {
|
||||
onMounted(() => {
|
||||
loadStoreOptions()
|
||||
fetchData()
|
||||
// 恢复被中断的退回收到导出任务(存在未完成任务时自动弹进度弹窗继续轮询)
|
||||
resumeExportTaskFromStorage()
|
||||
})
|
||||
</script>
|
||||
|
||||
|
||||
@ -68,5 +68,18 @@ export const returnReceivedColumns = [
|
||||
// ============================================================
|
||||
export const returnReceivedToolbarButtons: ToolbarButtonConfig[] = [
|
||||
{ key: 'refresh', label: '刷新', category: 'refresh', size: 'small', loadingKey: 'loading', action: 'loadData' },
|
||||
{
|
||||
key: 'export',
|
||||
label: '导出',
|
||||
category: 'setting',
|
||||
size: 'small',
|
||||
loadingKey: 'exportLoading',
|
||||
action: 'handleExportSelected',
|
||||
buttonType: 'dropdown',
|
||||
dropdownOptions: [
|
||||
{ label: '导出选中', action: 'handleExportSelected' },
|
||||
{ label: '导出全部', action: 'handleExportAll', divided: true }
|
||||
],
|
||||
},
|
||||
{ key: 'columnConfig', label: '字段设置', category: 'setting', size: 'small', action: 'openColumnConfigPanel' },
|
||||
]
|
||||
|
||||
@ -39,10 +39,12 @@
|
||||
:table-size="tableSize"
|
||||
:pagination="upperPagination"
|
||||
:show-index="true"
|
||||
:show-selection="true"
|
||||
:enable-column-config="true"
|
||||
:loading="loading"
|
||||
:query-time="queryTime"
|
||||
@current-change="handleRowClick"
|
||||
@selection-change="handleSelectionChange"
|
||||
@page-change="handlePageChange"
|
||||
@page-size-change="handlePageSizeChange"
|
||||
@refresh="handleRefresh"
|
||||
@ -277,13 +279,18 @@
|
||||
:video="playingVideo"
|
||||
/>
|
||||
|
||||
<!-- 退回拆包导出(功能表单:returnUnpack.export + returnUnpack.exportTaskProgress) -->
|
||||
<ReturnUnpackExportDialog
|
||||
<!-- 退回拆包导出进度(returnUnpack.export + returnUnpack.exportTaskProgress) -->
|
||||
<AsyncExportProgressDialog
|
||||
v-model:visible="exportDialogVisible"
|
||||
:conditions="currentConditions"
|
||||
:sort="currentSort"
|
||||
@success="handleRefresh"
|
||||
@loading-change="exportLoading = $event"
|
||||
title="退回拆包导出进度"
|
||||
:loading="exportLoading"
|
||||
:progress-percent="exportProgressPercent"
|
||||
:progress-status="exportProgressStatus"
|
||||
:status-label="exportStatusLabel"
|
||||
:task-id="exportTaskProgress.taskId"
|
||||
:message="exportTaskProgress.message"
|
||||
:error="exportTaskProgress.error"
|
||||
:update-time="exportTaskProgress.updateTime"
|
||||
/>
|
||||
|
||||
</div>
|
||||
@ -298,6 +305,8 @@ import {
|
||||
returnUnpackDetailList,
|
||||
returnUnpackVideoList,
|
||||
returnUnpackForceRecord,
|
||||
returnUnpackExport,
|
||||
returnUnpackExportTaskProgress,
|
||||
} from '@/api/returnunpack'
|
||||
import { loadStores } from '@/api/index/index'
|
||||
import { extractStoreListFromResponse, fillStoreScanFieldOptions } from '@/views/order/orderManagement/config/order-common-config'
|
||||
@ -312,7 +321,8 @@ import UnpackOrderItemsTable from './components/UnpackOrderItemsTable.vue'
|
||||
import VideoButton, { type VideoItem } from './components/VideoButton.vue'
|
||||
import VideoListDialog from './components/VideoListDialog.vue'
|
||||
import VideoPlayerDialog from './components/VideoPlayerDialog.vue'
|
||||
import ReturnUnpackExportDialog from './components/ExportDialog.vue'
|
||||
import { useAsyncExportTask } from '@/composables/useAsyncExportTask'
|
||||
import AsyncExportProgressDialog from '@/components/AsyncExportProgressDialog.vue'
|
||||
|
||||
// ==================== 常量 / 工具 ====================
|
||||
|
||||
@ -458,7 +468,24 @@ const columns = returnUnpackColumns
|
||||
const tableSize = 'small'
|
||||
const toolbarButtons: ToolbarButtonConfig[] = returnUnpackToolbarButtons
|
||||
|
||||
const exportLoading = ref(false)
|
||||
// ─── 退回拆包导出(returnUnpack.export + returnUnpack.exportTaskProgress) ──
|
||||
// 下拉选项:导出选中(按勾选拆包单ID导出)/ 导出全部(按当前筛选条件全量导出)
|
||||
const {
|
||||
exportLoading,
|
||||
exportDialogVisible,
|
||||
exportTaskProgress,
|
||||
exportProgressPercent,
|
||||
exportProgressStatus,
|
||||
exportStatusLabel,
|
||||
submitExportTask,
|
||||
resumeExportTaskFromStorage,
|
||||
hasPendingExportTask,
|
||||
} = useAsyncExportTask({
|
||||
storageKey: 'express:returnUnpack:exportTaskId',
|
||||
submitExport: (payload) => returnUnpackExport(payload as any),
|
||||
queryProgress: (params) => returnUnpackExportTaskProgress(params),
|
||||
})
|
||||
|
||||
const buttonLoadingMap = computed<Record<string, boolean>>(() => ({
|
||||
loading: loading.value,
|
||||
exportLoading: exportLoading.value,
|
||||
@ -482,7 +509,8 @@ function resolveButtonLabel(defaultLabel: string, dynamicLabelKey?: string) {
|
||||
const toolbarActionMap: Record<string, () => void> = {
|
||||
loadData: () => { handleRefresh() },
|
||||
openColumnConfigPanel: () => openColumnConfigPanel(),
|
||||
openExportDialog: () => { exportDialogVisible.value = true },
|
||||
handleExportSelected: () => { void handleExportSelected() },
|
||||
handleExportAll: () => { void handleExportAll() },
|
||||
}
|
||||
|
||||
function openColumnConfigPanel() {
|
||||
@ -502,9 +530,69 @@ const upperTable = ref<any>(null)
|
||||
const loading = ref(false)
|
||||
const queryTime = ref(0)
|
||||
const tableData = ref<any[]>([])
|
||||
const selectionRows = ref<any[]>([])
|
||||
const currentConditions = ref<Record<string, any>>({})
|
||||
const currentSort = ref<{ prop: string; order: string }>({ prop: '', order: '' })
|
||||
const exportDialogVisible = ref(false)
|
||||
|
||||
// ─── 导出处理(导出选中 / 导出全部) ──────────────────────────────────────────
|
||||
// where/sort 语义与 returnUnpack.list 一致:
|
||||
// - 导出选中:仅传勾选拆包单号 unpack_no({ operator:'in', value: unpackNos }),不叠加筛选条件
|
||||
// - 导出全部:不传 where(全量导出,等价于 list 无筛选);sort 按当前排序透传
|
||||
function buildReturnUnpackExportPayload(selected: boolean): Record<string, any> {
|
||||
const payload: Record<string, any> = {}
|
||||
if (selected) {
|
||||
const unpackNos = selectionRows.value
|
||||
.map((row: any) => row?.unpack_no)
|
||||
.filter((v: any) => v !== undefined && v !== null && String(v).trim() !== '')
|
||||
if (unpackNos.length) {
|
||||
payload.where = { unpack_no: { operator: 'in', value: unpackNos } }
|
||||
}
|
||||
}
|
||||
if (currentSort.value.prop) {
|
||||
payload.sort = {
|
||||
sortField: currentSort.value.prop,
|
||||
sortOrder: currentSort.value.order === 'ascending' ? 'asc' : 'desc',
|
||||
}
|
||||
}
|
||||
return payload
|
||||
}
|
||||
|
||||
async function handleExportSelected() {
|
||||
if (!selectionRows.value.length) {
|
||||
ElMessage.warning('请先勾选要导出的拆包单')
|
||||
return
|
||||
}
|
||||
if (hasPendingExportTask()) {
|
||||
ElMessage.warning('检测到未完成导出任务,请等待当前任务完成后再试')
|
||||
resumeExportTaskFromStorage()
|
||||
return
|
||||
}
|
||||
const unpackNos = selectionRows.value
|
||||
.map((row: any) => row?.unpack_no)
|
||||
.filter((v: any) => v !== undefined && v !== null && String(v).trim() !== '')
|
||||
if (!unpackNos.length) {
|
||||
ElMessage.warning('选中的记录无有效拆包单号')
|
||||
return
|
||||
}
|
||||
await submitExportTask(buildReturnUnpackExportPayload(true))
|
||||
}
|
||||
|
||||
async function handleExportAll() {
|
||||
if (!tableData.value.length) {
|
||||
ElMessage.warning('当前无数据可导出')
|
||||
return
|
||||
}
|
||||
if (hasPendingExportTask()) {
|
||||
ElMessage.warning('检测到未完成导出任务,请等待当前任务完成后再试')
|
||||
resumeExportTaskFromStorage()
|
||||
return
|
||||
}
|
||||
await submitExportTask(buildReturnUnpackExportPayload(false))
|
||||
}
|
||||
|
||||
function handleSelectionChange(rows: any[]) {
|
||||
selectionRows.value = rows || []
|
||||
}
|
||||
|
||||
const pagination = reactive({ currentPage: 1, pageSize: 20, total: 0 })
|
||||
const upperPagination = reactive({ currentPage: 1, pageSize: 20, total: 0 })
|
||||
@ -848,6 +936,8 @@ async function loadStoreOptions() {
|
||||
onMounted(() => {
|
||||
loadStoreOptions()
|
||||
fetchData()
|
||||
// 恢复被中断的退回拆包导出任务(存在未完成任务时自动弹进度弹窗继续轮询)
|
||||
resumeExportTaskFromStorage()
|
||||
})
|
||||
</script>
|
||||
|
||||
|
||||
@ -93,10 +93,15 @@ export const returnUnpackToolbarButtons: ToolbarButtonConfig[] = [
|
||||
{
|
||||
key: 'export',
|
||||
label: '导出',
|
||||
category: 'action',
|
||||
category: 'setting',
|
||||
size: 'small',
|
||||
loadingKey: 'exportLoading',
|
||||
action: 'openExportDialog',
|
||||
action: 'handleExportSelected',
|
||||
buttonType: 'dropdown',
|
||||
dropdownOptions: [
|
||||
{ label: '导出选中', action: 'handleExportSelected' },
|
||||
{ label: '导出全部', action: 'handleExportAll', divided: true }
|
||||
],
|
||||
},
|
||||
{ key: 'columnConfig', label: '字段设置', category: 'setting', size: 'small', action: 'openColumnConfigPanel' },
|
||||
]
|
||||
|
||||
@ -206,7 +206,7 @@ export const FIELD_DICT: Record<string, FieldDefinition> = {
|
||||
},
|
||||
order_no: {
|
||||
key: 'order_no',
|
||||
label: '订单号',
|
||||
label: '发货单号',
|
||||
scanBox: { type: 'text', group: SCANBOX_GROUPS.basic },
|
||||
table: { minWidth: 160, copyAction: 'copy', showOverflowTooltip: true },
|
||||
slot: null,
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
<template>
|
||||
<template>
|
||||
<el-dialog
|
||||
:model-value="visible"
|
||||
title="发起售后单"
|
||||
@ -152,11 +152,11 @@
|
||||
<script setup lang="ts">
|
||||
import { ref, reactive, computed, watch, onMounted } from 'vue'
|
||||
import { ElMessage, type FormInstance, type FormRules } from 'element-plus'
|
||||
import { afterSaleCreate, type AfterSaleCreateParams } from '@/api/afterSale/index'
|
||||
import { afterSaleCreate, type AfterSaleCreateParams } from '@/api/aftersale/index'
|
||||
import { AFTER_SALE_TYPE_MAP } from '@/views/afterSale/list/afterSale-config'
|
||||
import { loadStores } from '@/api/index/index'
|
||||
import { extractStoreListFromResponse, mapStoreListToSelectOptions } from '@/views/order/orderManagement/config/order-common-config'
|
||||
import { orderDeliveryOrderQuickSearch } from '@/api/order.deliveryOrder/orderdeliveryOrder'
|
||||
import { orderDeliveryOrderQuickSearch } from '@/api/order.deliveryorder/orderdeliveryOrder'
|
||||
import { getEntryList } from '@/api/storage.entry/entry'
|
||||
import { stockoutList } from '@/api/storage.stockout/stockout'
|
||||
import { getReceivingList } from '@/api/storage_receiving/receiving'
|
||||
|
||||
@ -218,7 +218,7 @@
|
||||
<script setup lang="ts">
|
||||
import { onMounted, reactive, ref, computed, watch } from 'vue'
|
||||
import { ElMessage, ElMessageBox } from 'element-plus'
|
||||
import { afterSaleWorkList, afterSaleBatchSetPendingFeedback, afterSaleBatchClose, type AfterSaleListParams } from '@/api/afterSale/index'
|
||||
import { afterSaleWorkList, afterSaleBatchSetPendingFeedback, afterSaleBatchClose, type AfterSaleListParams } from '@/api/aftersale/index'
|
||||
import {
|
||||
getAfterSaleAvailableFields,
|
||||
afterSaleAvailableFields,
|
||||
|
||||
@ -454,9 +454,9 @@ import {
|
||||
orderPendingOrder,
|
||||
orderPendingOrderParseAddress,
|
||||
type PendingOrderParseAddressData
|
||||
} from '@/api/order.pendingOrder/orderpendingOrder'
|
||||
} from '@/api/order.pendingorder/orderpendingOrder'
|
||||
import { parseOrderListResponse } from '../utils/order-index-helpers'
|
||||
import type { PendingOrderCreateOrderParams } from '@/api/order.pendingOrder/orderpendingOrder'
|
||||
import type { PendingOrderCreateOrderParams } from '@/api/order.pendingorder/orderpendingOrder'
|
||||
import {
|
||||
buildCityOptions,
|
||||
buildDistrictOptions,
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
<template>
|
||||
<template>
|
||||
<div class="order-items-detail" v-loading="loading">
|
||||
<div v-if="!row?.id" class="empty-tip">请从上方列表中选择一项查看商品明细</div>
|
||||
<template v-else>
|
||||
@ -39,7 +39,7 @@
|
||||
<script setup lang="ts">
|
||||
import { computed, onBeforeUnmount, ref, watch } from 'vue'
|
||||
import { ElMessage } from 'element-plus'
|
||||
import { orderPendingOrder } from '@/api/order.pendingOrder/orderpendingOrder'
|
||||
import { orderPendingOrder } from '@/api/order.pendingorder/orderpendingOrder'
|
||||
import {
|
||||
formatOrderTime,
|
||||
orderItemCompactColumns,
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
<template>
|
||||
<template>
|
||||
<div class="pending-order-detail" v-loading="loading">
|
||||
<div v-if="!row?.id" class="empty-tip">请从上方列表中选择一项查看订单明细</div>
|
||||
<template v-else-if="detail">
|
||||
@ -35,7 +35,7 @@
|
||||
<script setup lang="ts">
|
||||
import { computed, onBeforeUnmount, ref, watch } from 'vue'
|
||||
import { ElMessage } from 'element-plus'
|
||||
import { orderPendingOrder } from '@/api/order.pendingOrder/orderpendingOrder'
|
||||
import { orderPendingOrder } from '@/api/order.pendingorder/orderpendingOrder'
|
||||
import {
|
||||
ORDER_DETAIL_TIME_FIELDS,
|
||||
COMMON_TRANSLATIONS,
|
||||
|
||||
@ -1384,8 +1384,8 @@ export const waveScopeScanField = scanBasicField({
|
||||
]
|
||||
})
|
||||
export const deliveryOrderCodeScanField = scanBasicField({ label: '发货单号', value: 'delivery_order_code', type: 'text', operators: ORDER_BULK_SEARCH_OPERATORS, defaultOperator: 'eq' })
|
||||
/** ScanBox:外部订单号(待处理订单专用,模糊匹配发货单号,替代表格右上角快捷搜索) */
|
||||
export const pendingOrderQuickSearchScanField = scanBasicField({ label: '外部订单号', value: 'delivery_order_code', type: 'text', operators: ORDER_BULK_SEARCH_OPERATORS, defaultOperator: 'like' })
|
||||
/** ScanBox:发货单号(待处理订单/待处理异常订单/配送单通用,模糊匹配发货单号,替代表格右上角快捷搜索) */
|
||||
export const pendingOrderQuickSearchScanField = scanBasicField({ label: '发货单号', value: 'delivery_order_code', type: 'text', operators: ORDER_BULK_SEARCH_OPERATORS, defaultOperator: 'like' })
|
||||
/** ScanBox:搜索订单号(模糊匹配发货单号,替代表格右上角快捷搜索) */
|
||||
export const orderQuickSearchScanField = scanBasicField({ label: '搜索订单号', value: 'delivery_order_code', type: 'text', operators: ORDER_BULK_SEARCH_OPERATORS, defaultOperator: 'like' })
|
||||
export const sourceOrderCodesScanField = scanBasicField({ label: '平台交易单号', value: 'source_order_codes', type: 'text', operators: ORDER_BULK_SEARCH_OPERATORS, defaultOperator: 'eq' })
|
||||
@ -1934,9 +1934,9 @@ export const pendingAvailableFields = [
|
||||
]
|
||||
|
||||
export const pendingCloums = [
|
||||
{ prop: 'id', label: '订单ID', width: '80' },
|
||||
{ prop: 'id', label: '订单ID', width: '80', sortable: 'custom' },
|
||||
orderWaveIndexColumn,
|
||||
{ prop: 'delivery_order_code', label: '外部订单号', width: '170', fixed: 'left', showOverflowTooltip: true },
|
||||
{ prop: 'delivery_order_code', label: '发货单号', width: '170', fixed: 'left', showOverflowTooltip: true, sortable: 'custom' },
|
||||
{ prop: 'wave_no', label: '波次号', width: '170', showOverflowTooltip: true },
|
||||
{ prop: 'order_flag', label: '订单标记', minWidth: '260' },
|
||||
{ prop: 'shop_nick', label: '店铺名称', width: '140', showOverflowTooltip: true },
|
||||
@ -1955,13 +1955,13 @@ export const pendingCloums = [
|
||||
{ prop: 'intercept_status', label: '拦截状态', width: '100', tag: true },
|
||||
{ prop: 'lock_status', label: '锁定状态', width: '100' },
|
||||
{ prop: 'express_numbers', label: '快递单号', width: '160', formatter: waybillCodesFormatter, showOverflowTooltip: true },
|
||||
{ prop: 'items_count', label: '商品种类', width: '100' },
|
||||
{ prop: 'items_total', label: '商品总数', width: '100' },
|
||||
{ prop: 'items_weight', label: '商品重量(g)', width: '110' },
|
||||
{ prop: 'items_count', label: '商品种类', width: '100', sortable: 'custom' },
|
||||
{ prop: 'items_total', label: '商品总数', width: '100', sortable: 'custom' },
|
||||
{ prop: 'items_weight', label: '商品重量(g)', width: '110', sortable: 'custom' },
|
||||
{ prop: 'province', label: '省份', width: '100' },
|
||||
{ prop: 'create_at', label: '创建时间', width: '165', formatter: orderTimeFormatter },
|
||||
{ prop: 'pay_time', label: '支付时间', width: '160', formatter: orderTimeFormatter },
|
||||
{ prop: 'place_order_time', label: '下单时间', width: '165', formatter: orderTimeFormatter },
|
||||
{ prop: 'create_at', label: '创建时间', width: '165', formatter: orderTimeFormatter, sortable: 'custom' },
|
||||
{ prop: 'pay_time', label: '支付时间', width: '160', formatter: orderTimeFormatter, sortable: 'custom' },
|
||||
{ prop: 'place_order_time', label: '下单时间', width: '165', formatter: orderTimeFormatter, sortable: 'custom' },
|
||||
{ prop: 'create_channel', label: '来源', width: '120' },
|
||||
{ prop: 'source_order_codes', label: '平台交易单号', width: '140', showOverflowTooltip: true },
|
||||
{ prop: 'logistics_name', label: '快递', width: '120' },
|
||||
@ -2020,6 +2020,18 @@ export function buildPendingStyleColumns(baseColumns: ReadonlyArray<{ prop: stri
|
||||
return applyOrderListCopyActions(source)
|
||||
}
|
||||
|
||||
/** 订单管理模块 tab 清单(标签排序弹窗用;name 与 index.vue tabs[].name 一致,label 为中文标签) */
|
||||
export const ORDER_TAB_LIST: { name: string; label: string }[] = [
|
||||
{ name: 'reviewOrder', label: '待审核订单' },
|
||||
{ name: 'pendingOrder', label: '待处理订单' },
|
||||
{ name: 'exceptionOrder', label: '待处理异常订单' },
|
||||
{ name: 'outboundOrder', label: '待出库订单' },
|
||||
{ name: 'entrustWarehouse', label: '委托外仓订单' },
|
||||
{ name: 'deliveryOrder', label: '配送订单' },
|
||||
{ name: 'deliveryException', label: '配送异常订单' },
|
||||
{ name: 'archiveOrder', label: '归档订单' }
|
||||
]
|
||||
|
||||
export const pendingOrderDetail = [
|
||||
// 基础信息
|
||||
{ prop: 'delivery_order_code', label: '外部订单号' },
|
||||
@ -2301,9 +2313,9 @@ export const expectionOrderAvailableFields = [
|
||||
]
|
||||
|
||||
export const expectionColumns = [
|
||||
{ prop: 'id', label: '订单ID', width: '80' },
|
||||
{ prop: 'id', label: '订单ID', width: '80', sortable: 'custom' },
|
||||
orderWaveIndexColumn,
|
||||
{ prop: 'delivery_order_code', label: '发货单号', width: '170' },
|
||||
{ prop: 'delivery_order_code', label: '发货单号', width: '170', sortable: 'custom' },
|
||||
{ prop: 'wave_no', label: '波次号', width: '170' },
|
||||
{ prop: 'sys_platform_name', label: '平台编码', width: '120' },
|
||||
{ prop: 'create_channel', label: '来源', width: '120' },
|
||||
@ -2325,11 +2337,11 @@ export const expectionColumns = [
|
||||
{ prop: 'logistics_name', label: '快递', width: '120' },
|
||||
{ prop: 'pre_delivery_order_code', label: '前置单号', width: '140' },
|
||||
{ prop: 'order_flag', label: '订单标记', minWidth: '260' },
|
||||
{ prop: 'items_total', label: '商品总数', width: '100' },
|
||||
{ prop: 'items_weight', label: '商品重量(g)', width: '110' },
|
||||
{ prop: 'total_amount', label: '订单金额', width: '110' },
|
||||
{ prop: 'pay_time', label: '支付时间', width: '165', formatter: orderTimeFormatter },
|
||||
{ prop: 'create_at', label: '创建时间', width: '165', formatter: orderTimeFormatter },
|
||||
{ prop: 'items_total', label: '商品总数', width: '100', sortable: 'custom' },
|
||||
{ prop: 'items_weight', label: '商品重量(g)', width: '110', sortable: 'custom' },
|
||||
{ prop: 'total_amount', label: '订单金额', width: '110', sortable: 'custom' },
|
||||
{ prop: 'pay_time', label: '支付时间', width: '165', formatter: orderTimeFormatter, sortable: 'custom' },
|
||||
{ prop: 'create_at', label: '创建时间', width: '165', formatter: orderTimeFormatter, sortable: 'custom' },
|
||||
]
|
||||
|
||||
export const expectionOrderDetail = [
|
||||
|
||||
@ -295,8 +295,8 @@ import { ElMessage } from 'element-plus'
|
||||
import ScanBox from '@/components/ScanBox/index.vue'
|
||||
import UpperTable from '@/components/UpperTable/index.vue'
|
||||
import * as indexApi from '@/api/index/index'
|
||||
import { orderDeliveryOrder } from '@/api/order.deliveryOrder/orderdeliveryOrder'
|
||||
import { orderPendingOrder } from '@/api/order.pendingOrder/orderpendingOrder'
|
||||
import { orderDeliveryOrder } from '@/api/order.deliveryorder/orderdeliveryOrder'
|
||||
import { orderPendingOrder } from '@/api/order.pendingorder/orderpendingOrder'
|
||||
|
||||
import {
|
||||
deliveryAvailableFields,
|
||||
|
||||
@ -381,7 +381,7 @@ import ScanBox from '@/components/ScanBox/index.vue'
|
||||
import UpperTable from '@/components/UpperTable/index.vue'
|
||||
import * as indexApi from '@/api/index/index'
|
||||
import { orderExpectionOrder } from '@/api/order.expectionorder/orderexpectionorder'
|
||||
import { orderPendingOrder } from '@/api/order.pendingOrder/orderpendingOrder'
|
||||
import { orderPendingOrder } from '@/api/order.pendingorder/orderpendingOrder'
|
||||
|
||||
import {
|
||||
buildPendingStyleColumns,
|
||||
@ -465,7 +465,6 @@ const tableSize = ref('small')
|
||||
|
||||
const columns = ref(buildPendingStyleColumns(expectionColumns))
|
||||
|
||||
|
||||
const selectionRows = ref<any[]>([])
|
||||
const hasSelection = ref(false)
|
||||
const selectedOrderId = ref<number | string | null>(null)
|
||||
|
||||
@ -4,6 +4,14 @@
|
||||
<template v-if="!singlePage">
|
||||
<!-- 顶部多标签页区域(对齐 stock/stockManagement 的 tab-section) -->
|
||||
<div class="tab-section">
|
||||
<!-- 排序设置入口(tab 区域左侧,样式对齐 scan-box 模式切换按钮) -->
|
||||
<div class="tab-sort-entry">
|
||||
<el-tooltip content="标签排序" placement="bottom">
|
||||
<el-button class="sort-entry-btn" size="small" link @click="openSortDialog">
|
||||
<el-icon><Sort /></el-icon>
|
||||
</el-button>
|
||||
</el-tooltip>
|
||||
</div>
|
||||
<div class="tabs-header-action">
|
||||
<!-- <el-button size="small" @click="workbenchDialogVisible = true">统一查询</el-button> -->
|
||||
<!-- <el-button size="small" @click="bindByWaybillDialogVisible = true">按运单绑定包材</el-button> -->
|
||||
@ -46,9 +54,9 @@
|
||||
关闭时不缓存、每次切换重新挂载。
|
||||
-->
|
||||
<KeepAlive v-if="tabCacheEnabled" :max="tabCacheMax">
|
||||
<component :is="activeComponent" :key="activeTab" />
|
||||
<component :is="activeComponent" />
|
||||
</KeepAlive>
|
||||
<component v-else :is="activeComponent" :key="activeTab" />
|
||||
<component v-else :is="activeComponent" />
|
||||
</transition>
|
||||
</div>
|
||||
</template>
|
||||
@ -60,6 +68,7 @@
|
||||
|
||||
<order-workbench-list-dialog v-model="workbenchDialogVisible" />
|
||||
<BindPackageMaterialByWaybillDialog v-model="bindByWaybillDialogVisible" />
|
||||
<SortSettingDialog v-model:visible="sortDialogVisible" :tabs="ORDER_TAB_LIST" scope="order.tabs.order" @saved="handleSortSaved" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@ -79,8 +88,11 @@ import DeliveryException from './deliveryException.vue'
|
||||
import ArchiveOrder from './archiveOrder.vue'
|
||||
import OrderWorkbenchListDialog from './component/OrderWorkbenchListDialog.vue'
|
||||
import BindPackageMaterialByWaybillDialog from './component/BindPackageMaterialByWaybillDialog.vue'
|
||||
import SortSettingDialog from '@/components/SortSettingDialog.vue'
|
||||
import { Sort } from '@element-plus/icons-vue'
|
||||
import { safeInvoke } from '@/utils/safe-invoke'
|
||||
import { ORDER_PAGE_CONFIG } from './config/order-common-config'
|
||||
import { ORDER_PAGE_CONFIG, ORDER_TAB_LIST } from './config/order-common-config'
|
||||
import { useUserPreferenceStore } from '@/stores/modules/userPreference'
|
||||
|
||||
const route = useRoute()
|
||||
const settingsStore = useSettingsStore()
|
||||
@ -94,6 +106,39 @@ const badgeLoading = ref(false)
|
||||
const workbenchDialogVisible = ref(false)
|
||||
const bindByWaybillDialogVisible = ref(false)
|
||||
|
||||
// 标签排序弹窗
|
||||
const sortDialogVisible = ref(false)
|
||||
const preferenceStore = useUserPreferenceStore()
|
||||
|
||||
function openSortDialog() {
|
||||
sortDialogVisible.value = true
|
||||
}
|
||||
|
||||
/** 保存标签顺序:按新顺序重排 tabs 数组(组件对象原样复用,缺失项留在末尾) */
|
||||
function handleSortSaved(order: string[]) {
|
||||
applyTabOrder(order)
|
||||
}
|
||||
|
||||
/** 读取本账号保存的标签顺序并应用;无配置时保持默认顺序 */
|
||||
function applySavedTabOrder() {
|
||||
const saved = preferenceStore.get('order.tabs.order')
|
||||
if (!Array.isArray(saved) || !saved.length) return
|
||||
applyTabOrder(saved)
|
||||
}
|
||||
|
||||
/** 按给定 tab.name 顺序重排 tabs;非法项剔除,缺失项按当前 tabs 补在末尾 */
|
||||
function applyTabOrder(order: string[]) {
|
||||
const byName = new Map(tabs.value.map((t) => [t.name, t]))
|
||||
const ordered: OrderTabItem[] = []
|
||||
for (const name of order) {
|
||||
if (byName.has(name)) ordered.push(byName.get(name)!)
|
||||
}
|
||||
for (const t of tabs.value) {
|
||||
if (!ordered.some((x) => x.name === t.name)) ordered.push(t)
|
||||
}
|
||||
tabs.value = ordered
|
||||
}
|
||||
|
||||
const shortcutExpanded = computed(() => settingsStore.shortcutExpanded)
|
||||
const containerHeight = computed(() => shortcutExpanded.value ? 'calc(100vh - 150px)' : 'calc(100vh - 100px)')
|
||||
|
||||
@ -225,6 +270,7 @@ watch(
|
||||
)
|
||||
|
||||
onMounted(() => {
|
||||
applySavedTabOrder()
|
||||
loadBadgeCounts()
|
||||
})
|
||||
|
||||
@ -273,6 +319,30 @@ const handleTabChange = (tabName: string | number) => {
|
||||
z-index: 2;
|
||||
}
|
||||
|
||||
/* 排序设置入口(tab 区域左侧,样式对齐 scan-box 模式切换按钮) */
|
||||
.tab-sort-entry {
|
||||
position: absolute;
|
||||
top: 4px;
|
||||
left: 12px;
|
||||
height: 38px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
z-index: 2;
|
||||
|
||||
.sort-entry-btn {
|
||||
color: #606266;
|
||||
font-size: 15px;
|
||||
padding: 4px 6px;
|
||||
border-radius: 4px;
|
||||
transition: all 0.2s;
|
||||
|
||||
&:hover {
|
||||
color: #409eff;
|
||||
background-color: rgba(64, 158, 255, 0.08);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.tab-container {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
@ -283,7 +353,7 @@ const handleTabChange = (tabName: string | number) => {
|
||||
}
|
||||
|
||||
:deep(.el-tabs__header.is-top) {
|
||||
padding: 4px 12px 0;
|
||||
padding: 4px 12px 0 46px;
|
||||
background: #f8fbff;
|
||||
border-bottom: 1px solid #e8eef7;
|
||||
margin: 0;
|
||||
|
||||
@ -191,7 +191,7 @@ import { ElMessage } from 'element-plus'
|
||||
import ScanBox from '@/components/ScanBox/index.vue'
|
||||
import UpperTable from '@/components/UpperTable/index.vue'
|
||||
import * as indexApi from '@/api/index/index'
|
||||
import { orderOutboundOrder } from '@/api/order.outboundOrder/orderoutboundOrder'
|
||||
import { orderOutboundOrder } from '@/api/order.outboundorder/orderoutboundOrder'
|
||||
import {
|
||||
buildPendingStyleColumns,
|
||||
outboundAvailableFields,
|
||||
@ -326,7 +326,7 @@ async function loadData() {
|
||||
where: buildWhere(),
|
||||
sort: {
|
||||
sortField: 'updated_at',
|
||||
sortOrder: 'DESC'
|
||||
sortOrder: 'DESC' as const
|
||||
}
|
||||
})
|
||||
if (res && (res.code === 1 || res.code === 200)) {
|
||||
|
||||
@ -384,7 +384,7 @@ import { ElMessage, ElMessageBox } from 'element-plus'
|
||||
import ScanBox from '@/components/ScanBox/index.vue'
|
||||
import UpperTable from '@/components/UpperTable/index.vue'
|
||||
import TaskProgressDialog from '@/components/TaskProgressDialog.vue'
|
||||
import { orderPendingOrder } from '@/api/order.pendingOrder/orderpendingOrder'
|
||||
import { orderPendingOrder } from '@/api/order.pendingorder/orderpendingOrder'
|
||||
import { orderExpectionOrder } from '@/api/order.expectionorder/orderexpectionorder'
|
||||
import { confirmIntercept } from '@/api/order.recheckorder/recheckOrder'
|
||||
import * as indexApi from '@/api/index/index'
|
||||
@ -464,7 +464,6 @@ const tableSize = ref('small')
|
||||
|
||||
const columns = ref(buildPendingStyleColumns())
|
||||
|
||||
|
||||
const selectionRows = ref<any[]>([])
|
||||
const hasSelection = ref(false)
|
||||
|
||||
|
||||
@ -184,8 +184,8 @@ import { ElMessage, ElMessageBox } from 'element-plus'
|
||||
import ScanBox from '@/components/ScanBox/index.vue'
|
||||
import UpperTable from '@/components/UpperTable/index.vue'
|
||||
import * as indexApi from '@/api/index/index'
|
||||
import { orderReviewOrder } from '@/api/order.reviewOrder/orderreviewOrder'
|
||||
import { orderPendingOrder } from '@/api/order.pendingOrder/orderpendingOrder'
|
||||
import { orderReviewOrder } from '@/api/order.revieworder/orderreviewOrder'
|
||||
import { orderPendingOrder } from '@/api/order.pendingorder/orderpendingOrder'
|
||||
|
||||
import {
|
||||
reviewAvailableFields,
|
||||
@ -339,7 +339,11 @@ async function loadData() {
|
||||
page: pagination.currentPage,
|
||||
pageSize: pagination.pageSize
|
||||
},
|
||||
where
|
||||
where,
|
||||
sort: {
|
||||
sortField: 'updated_at',
|
||||
sortOrder: 'DESC' as const
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
|
||||
@ -1,11 +1,11 @@
|
||||
import { ref } from 'vue'
|
||||
import { ref } from 'vue'
|
||||
import { ElMessage } from 'element-plus'
|
||||
import {
|
||||
getPrintDataByWaybillCodes,
|
||||
type WavePlatformPrintDataPayload
|
||||
} from '@/api/order.print/orderprint'
|
||||
import { unwrapWavePlatformPrintPayload } from '@/views/order/waveOrder/config/wave-config'
|
||||
import { orderDeliveryOrder } from '@/api/order.deliveryOrder/orderdeliveryOrder'
|
||||
import { orderDeliveryOrder } from '@/api/order.deliveryorder/orderdeliveryOrder'
|
||||
import {
|
||||
isOrderIndexApiSuccess,
|
||||
parseOrderDetailPayload,
|
||||
@ -55,52 +55,87 @@ function collectOrderIds(rows: any[]): number[] {
|
||||
return ids
|
||||
}
|
||||
|
||||
/** 按用户勾选的运单号过滤 waveGroups 中的 orders(order 需含 waybill_code/waybill_no/express_code;无法匹配时保留原样避免误伤) */
|
||||
/**
|
||||
* 按用户勾选的运单号过滤 waveGroups:
|
||||
* - 第1层:按运单号过滤 orders(order 的运单号字段可能为 waybill_code/waybill_no/express_code/documentID)
|
||||
* - 第2层:过滤"无波次无 ID"的空壳分组(wave_id 与 wave_no 均缺失,如 wave_id=0、wave_no="")
|
||||
* 均带保护,避免结构不匹配时误删唯一数据源
|
||||
*/
|
||||
function filterWaveGroupsByWaybills(
|
||||
waveGroups: unknown[] | undefined,
|
||||
selectedSet: Set<string>
|
||||
): unknown[] | undefined {
|
||||
if (!Array.isArray(waveGroups) || !selectedSet.size) return waveGroups
|
||||
|
||||
// 只有 waveGroups 内 order 带运单号字段时才过滤,避免结构不匹配导致打印丢失
|
||||
// 只有 waveGroups 内 order 带运单号/documentID 字段时才过滤,避免结构不匹配导致打印丢失
|
||||
const hasWaybillField = waveGroups.some((wave: any) =>
|
||||
Array.isArray(wave?.platforms)
|
||||
? wave.platforms.some((p: any) =>
|
||||
Array.isArray(p?.orders)
|
||||
? p.orders.some(
|
||||
(o: any) => o && (o.waybill_code || o.waybill_no || o.express_code)
|
||||
(o: any) =>
|
||||
o && (o.waybill_code || o.waybill_no || o.express_code || o.documentID)
|
||||
)
|
||||
: false
|
||||
)
|
||||
: false
|
||||
)
|
||||
if (!hasWaybillField) return waveGroups
|
||||
|
||||
return waveGroups
|
||||
.map((wave: any) => {
|
||||
if (!wave || typeof wave !== 'object') return wave
|
||||
const platforms = Array.isArray(wave.platforms)
|
||||
? wave.platforms
|
||||
.map((p: any) => {
|
||||
if (!p || typeof p !== 'object') return p
|
||||
const orders = Array.isArray(p.orders)
|
||||
? p.orders.filter((o: any) => {
|
||||
if (!o || typeof o !== 'object') return false
|
||||
const code = String(
|
||||
o.waybill_code ?? o.waybill_no ?? o.express_code ?? ''
|
||||
).trim()
|
||||
return selectedSet.has(code)
|
||||
})
|
||||
: p.orders
|
||||
return { ...p, orders }
|
||||
})
|
||||
.filter((p: any) => p && (!Array.isArray(p.orders) || p.orders.length > 0))
|
||||
: wave.platforms
|
||||
return { ...wave, platforms }
|
||||
})
|
||||
.filter(
|
||||
(wave: any) => wave && (!Array.isArray(wave.platforms) || wave.platforms.length > 0)
|
||||
// 第1层:按勾选运单号过滤 orders(若 order 带运单号/documentID 字段)
|
||||
let groups = waveGroups
|
||||
if (hasWaybillField) {
|
||||
groups = waveGroups
|
||||
.map((wave: any) => {
|
||||
if (!wave || typeof wave !== 'object') return wave
|
||||
const platforms = Array.isArray(wave.platforms)
|
||||
? wave.platforms
|
||||
.map((p: any) => {
|
||||
if (!p || typeof p !== 'object') return p
|
||||
const orders = Array.isArray(p.orders)
|
||||
? p.orders.filter((o: any) => {
|
||||
if (!o || typeof o !== 'object') return false
|
||||
const code = String(
|
||||
o.waybill_code ?? o.waybill_no ?? o.express_code ?? o.documentID ?? ''
|
||||
).trim()
|
||||
return selectedSet.has(code)
|
||||
})
|
||||
: p.orders
|
||||
return { ...p, orders }
|
||||
})
|
||||
.filter((p: any) => p && (!Array.isArray(p.orders) || p.orders.length > 0))
|
||||
: wave.platforms
|
||||
return { ...wave, platforms }
|
||||
})
|
||||
.filter(
|
||||
(wave: any) => wave && (!Array.isArray(wave.platforms) || wave.platforms.length > 0)
|
||||
)
|
||||
// 保护:若过滤后一张面单都不剩(勾选运单号与返回结构完全不匹配),回退到原始数据避免误删
|
||||
const remainingOrders = groups.reduce(
|
||||
(total, w: any) =>
|
||||
total +
|
||||
(Array.isArray(w?.platforms)
|
||||
? w.platforms.reduce(
|
||||
(sum: number, p: any) =>
|
||||
sum + (Array.isArray(p?.orders) ? p.orders.length : 0),
|
||||
0
|
||||
)
|
||||
: 0),
|
||||
0
|
||||
)
|
||||
if (remainingOrders === 0) groups = waveGroups
|
||||
}
|
||||
|
||||
// 第2层:过滤"无波次无 ID"的空壳分组(wave_id 与 wave_no 均缺失)
|
||||
// 仅当还存在"有波次信息"的合法分组时才过滤,避免把唯一数据源误删
|
||||
const hasIdentifiedGroup = groups.some(
|
||||
(w: any) => w && typeof w === 'object' && (w.wave_id || w.wave_no)
|
||||
)
|
||||
if (hasIdentifiedGroup) {
|
||||
groups = groups.filter(
|
||||
(w: any) => w && typeof w === 'object' && (w.wave_id || w.wave_no)
|
||||
)
|
||||
}
|
||||
|
||||
return groups
|
||||
}
|
||||
|
||||
/**
|
||||
@ -261,7 +296,13 @@ export function useDeliveryOrderSubWaybillPrint(options: UseDeliveryOrderSubWayb
|
||||
if (!isPrintApiSuccess(res?.code)) {
|
||||
throw new Error(res?.message || '刷新打印数据失败')
|
||||
}
|
||||
payload.value = unwrapWavePlatformPrintPayload(res)
|
||||
const rawPayload = unwrapWavePlatformPrintPayload(res)
|
||||
// 与首次获取一致:过滤空壳分组与未勾选运单,避免刷新后多打"无波次无 ID"表单
|
||||
rawPayload.waveGroups = filterWaveGroupsByWaybills(
|
||||
rawPayload.waveGroups,
|
||||
new Set(meta.waybill_codes)
|
||||
)
|
||||
payload.value = rawPayload
|
||||
errorMessage.value = ''
|
||||
} catch (error: any) {
|
||||
payload.value = null
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
<template>
|
||||
<template>
|
||||
<div class="weighing-container" :style="{ height: containerHeight }">
|
||||
<div class="weighing-panel">
|
||||
<div class="panel-header">
|
||||
@ -112,7 +112,7 @@ import { computed, onMounted, reactive, ref } from 'vue'
|
||||
import { ElMessage } from 'element-plus'
|
||||
import UpperTable from '@/components/UpperTable/index.vue'
|
||||
import { useSettingsStore } from '@/stores/modules/settings'
|
||||
import { orderPendingOrderList } from '@/api/order.pendingOrder/orderpendingOrder'
|
||||
import { orderPendingOrderList } from '@/api/order.pendingorder/orderpendingOrder'
|
||||
import { isOrderIndexApiSuccess } from '@/views/order/orderManagement/utils/order-index-helpers'
|
||||
import ExpressWeighingForm, { type ExpressWeighingFormResult } from './ExpressWeighingForm.vue'
|
||||
|
||||
|
||||
@ -978,7 +978,7 @@ import type {
|
||||
} from '@/api/order.wave/orderwave'
|
||||
import { useUserStore } from '@/stores/modules/user'
|
||||
import { getWavePlatformPrintData } from '@/api/order.print/orderprint'
|
||||
import { orderPendingOrderList, orderPendingOrderDetail } from '@/api/order.pendingOrder/orderpendingOrder'
|
||||
import { orderPendingOrderList, orderPendingOrderDetail } from '@/api/order.pendingorder/orderpendingOrder'
|
||||
import type { WavePlatformPrintDataPayload } from '@/api/order.print/orderprint'
|
||||
import pcasCodeData from 'china-division/dist/pcas-code.json'
|
||||
|
||||
|
||||
@ -557,7 +557,7 @@ import type {
|
||||
|
||||
import { useUserStore } from '@/stores/modules/user'
|
||||
import { getWavePlatformPrintData } from '@/api/order.print/orderprint'
|
||||
import { orderPendingOrderList, orderPendingOrderDetail } from '@/api/order.pendingOrder/orderpendingOrder'
|
||||
import { orderPendingOrderList, orderPendingOrderDetail } from '@/api/order.pendingorder/orderpendingOrder'
|
||||
import type { WavePlatformPrintDataPayload } from '@/api/order.print/orderprint'
|
||||
const props = withDefaults(defineProps<{
|
||||
/** 与路由 path 组合,隔离 ScanBox 筛选缓存(波次各标签页须各不相同) */
|
||||
|
||||
@ -108,10 +108,6 @@
|
||||
<span>{{ row.creator_name || '—' }}</span>
|
||||
</template>
|
||||
|
||||
<template #column-allowed_owners="{ row }">
|
||||
<span>{{ formatArrayField(row.allowed_owners) }}</span>
|
||||
</template>
|
||||
|
||||
<template #column-allowed_expresses="{ row }">
|
||||
<span>{{ formatArrayField(row.allowed_expresses) }}</span>
|
||||
</template>
|
||||
|
||||
@ -178,7 +178,7 @@ import { computed, onMounted, reactive, ref, watch } from 'vue'
|
||||
import { ElMessage, ElMessageBox } from 'element-plus'
|
||||
import ScanBox from '@/components/ScanBox/index.vue'
|
||||
import UpperTable from '@/components/UpperTable/index.vue'
|
||||
import { orderPendingOrder } from '@/api/order.pendingOrder/orderpendingOrder'
|
||||
import { orderPendingOrder } from '@/api/order.pendingorder/orderpendingOrder'
|
||||
import { orderWaveBatchRemoveOrders } from '@/api/order.wave/orderwave'
|
||||
import * as indexApi from '@/api/index/index'
|
||||
import AllocateExpressForm from '@/views/order/orderManagement/form/AllocateExpressForm.vue'
|
||||
|
||||
@ -16,7 +16,7 @@ import {
|
||||
} from '@/views/order/orderManagement/config/order-common-config'
|
||||
import type { WavePlatformPrintDataPayload } from '@/api/order.print/orderprint'
|
||||
import type { WaveStrategyCreateParams, WaveStrategyUpdateParams } from '@/api/order.wave/orderwave'
|
||||
import { orderPendingOrder } from '@/api/order.pendingOrder/orderpendingOrder'
|
||||
import { orderPendingOrder } from '@/api/order.pendingorder/orderpendingOrder'
|
||||
import {
|
||||
isOrderIndexApiSuccess,
|
||||
normalizeOrderDetailItems,
|
||||
@ -351,7 +351,6 @@ export const waveStrategyColumns = [
|
||||
{ prop: 'group_batch_max_orders', label: '团购单波最大', width: 120, align: 'center' },
|
||||
{ prop: 'warehouse_id', label: '仓库ID', width: 90, align: 'center' },
|
||||
{ prop: 'creator_name', label: '创建人', width: 100, align: 'center' },
|
||||
{ prop: 'allowed_owners', label: '允许货主', minWidth: 130 },
|
||||
{ prop: 'allowed_expresses', label: '允许快递', minWidth: 130 },
|
||||
{ prop: 'allowed_provinces', label: '允许省份', minWidth: 130 },
|
||||
{ prop: 'allowed_platforms', label: '允许平台', minWidth: 130 },
|
||||
|
||||
@ -4,6 +4,14 @@
|
||||
<template v-if="!singlePage">
|
||||
<!-- 顶部多标签页区域(对齐 order/orderManagement 的 tab-section) -->
|
||||
<div class="tab-section">
|
||||
<!-- 标签排序入口(tab 区域左侧,对齐 order/orderManagement) -->
|
||||
<div class="tab-sort-entry">
|
||||
<el-tooltip content="标签排序" placement="bottom">
|
||||
<el-button class="sort-entry-btn" size="small" link @click="openSortDialog">
|
||||
<el-icon><Sort /></el-icon>
|
||||
</el-button>
|
||||
</el-tooltip>
|
||||
</div>
|
||||
<div class="tabs-header-action">
|
||||
<!-- <el-button size="small">操作按钮</el-button> -->
|
||||
</div>
|
||||
@ -57,14 +65,24 @@
|
||||
/>
|
||||
</keep-alive>
|
||||
</div>
|
||||
|
||||
<SortSettingDialog
|
||||
v-model:visible="sortDialogVisible"
|
||||
:tabs="DEFAULT_TAB_OPTIONS"
|
||||
scope="order.wave.tabs.order"
|
||||
@saved="handleSortSaved"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref, watch, computed, markRaw } from 'vue'
|
||||
import { ref, watch, computed, markRaw, onMounted } from 'vue'
|
||||
import { useRoute } from 'vue-router'
|
||||
import { useSettingsStore } from '@/stores/modules/settings'
|
||||
import { useExperimentalStore } from '@/stores/modules/experimental'
|
||||
import { Sort } from '@element-plus/icons-vue'
|
||||
import SortSettingDialog from '@/components/SortSettingDialog.vue'
|
||||
import { useUserPreferenceStore } from '@/stores/modules/userPreference'
|
||||
import GroupWaveBatchListPanel from './GroupWaveBatchListPanel.vue'
|
||||
import SandanWaveBatchListPanel from './SandanWaveBatchListPanel.vue'
|
||||
import FallbackOrderListPanel from './FallbackOrderListPanel.vue'
|
||||
@ -145,6 +163,44 @@ const tabs = ref<WaveTabItem[]>([
|
||||
}
|
||||
])
|
||||
|
||||
// ============================================================
|
||||
// 标签排序(浏览器本地保存,scope=order.wave.tabs.order)
|
||||
// ============================================================
|
||||
/** 默认 tab 顺序(弹窗选项 / 恢复默认用) */
|
||||
const DEFAULT_TAB_OPTIONS = tabs.value.map(({ name, label }) => ({ name, label }))
|
||||
const sortDialogVisible = ref(false)
|
||||
const preferenceStore = useUserPreferenceStore()
|
||||
const TAB_ORDER_SCOPE = 'order.wave.tabs.order'
|
||||
|
||||
function openSortDialog() {
|
||||
sortDialogVisible.value = true
|
||||
}
|
||||
|
||||
/** 保存标签顺序:按新顺序重排 tabs 数组(组件对象原样复用,缺失项留在末尾) */
|
||||
function handleSortSaved(order: string[]) {
|
||||
applyTabOrder(order)
|
||||
}
|
||||
|
||||
/** 读取本账号保存的标签顺序并应用;无配置时保持默认顺序 */
|
||||
function applySavedTabOrder() {
|
||||
const saved = preferenceStore.get(TAB_ORDER_SCOPE)
|
||||
if (!Array.isArray(saved) || !saved.length) return
|
||||
applyTabOrder(saved)
|
||||
}
|
||||
|
||||
/** 按给定 tab.name 顺序重排 tabs;非法项剔除,缺失项按当前 tabs 补在末尾 */
|
||||
function applyTabOrder(order: string[]) {
|
||||
const byName = new Map(tabs.value.map((t) => [t.name, t]))
|
||||
const ordered: WaveTabItem[] = []
|
||||
for (const name of order) {
|
||||
if (byName.has(name)) ordered.push(byName.get(name)!)
|
||||
}
|
||||
for (const t of tabs.value) {
|
||||
if (!ordered.some((x) => x.name === t.name)) ordered.push(t)
|
||||
}
|
||||
tabs.value = ordered
|
||||
}
|
||||
|
||||
/**
|
||||
* 首屏 / 外部导航时从地址栏恢复 tab。
|
||||
* 方案B:页签切换改为纯本地状态(handleTabChange 不写回路由),
|
||||
@ -179,6 +235,10 @@ const handleTabChange = (tabName: string | number) => {
|
||||
activeTab.value = name
|
||||
})
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
applySavedTabOrder()
|
||||
})
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
@ -212,6 +272,30 @@ const handleTabChange = (tabName: string | number) => {
|
||||
z-index: 2;
|
||||
}
|
||||
|
||||
/* 标签排序入口(tab 区域左侧,样式对齐 order/orderManagement) */
|
||||
.tab-sort-entry {
|
||||
position: absolute;
|
||||
top: 4px;
|
||||
left: 12px;
|
||||
height: 38px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
z-index: 2;
|
||||
|
||||
.sort-entry-btn {
|
||||
color: #606266;
|
||||
font-size: 15px;
|
||||
padding: 4px 6px;
|
||||
border-radius: 4px;
|
||||
transition: all 0.2s;
|
||||
|
||||
&:hover {
|
||||
color: #409eff;
|
||||
background-color: rgba(64, 158, 255, 0.08);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.tab-container {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
@ -222,7 +306,7 @@ const handleTabChange = (tabName: string | number) => {
|
||||
}
|
||||
|
||||
:deep(.el-tabs__header.is-top) {
|
||||
padding: 4px 12px 0;
|
||||
padding: 4px 12px 0 46px;
|
||||
background: #f8fbff;
|
||||
border-bottom: 1px solid #e8eef7;
|
||||
margin: 0;
|
||||
|
||||
@ -2,6 +2,14 @@
|
||||
<div class="stock-management-wrapper" :style="{ height: containerHeight }">
|
||||
<!-- ===== 顶部多标签页区域(对齐 setting/encoding / waveOrder2 的 TabArea) ===== -->
|
||||
<div class="tab-section">
|
||||
<!-- 标签排序入口(tab 区域左侧) -->
|
||||
<div class="tab-sort-entry">
|
||||
<el-tooltip content="标签排序" placement="bottom">
|
||||
<el-button class="sort-entry-btn" size="small" link @click="openSortDialog">
|
||||
<el-icon><Sort /></el-icon>
|
||||
</el-button>
|
||||
</el-tooltip>
|
||||
</div>
|
||||
<el-tabs
|
||||
v-model="activeTab"
|
||||
tab-position="top"
|
||||
@ -28,14 +36,24 @@
|
||||
<component v-else :is="tabs.find(t => t.name === activeTab)?.component" :key="activeTab" />
|
||||
</transition>
|
||||
</div>
|
||||
|
||||
<SortSettingDialog
|
||||
v-model:visible="sortDialogVisible"
|
||||
:tabs="DEFAULT_TAB_OPTIONS"
|
||||
scope="stock.tabs.order"
|
||||
@saved="handleSortSaved"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { computed, markRaw, ref, watch } from 'vue'
|
||||
import { computed, markRaw, ref, watch, onMounted } from 'vue'
|
||||
import { useRoute } from 'vue-router'
|
||||
import { useSettingsStore } from '@/stores/modules/settings'
|
||||
import { useExperimentalStore } from '@/stores/modules/experimental'
|
||||
import { Sort } from '@element-plus/icons-vue'
|
||||
import SortSettingDialog from '@/components/SortSettingDialog.vue'
|
||||
import { useUserPreferenceStore } from '@/stores/modules/userPreference'
|
||||
import { safeInvoke } from '@/utils/safe-invoke'
|
||||
import StockDetail from '../stock/index.vue'
|
||||
import ComboStock from '../combo_stock/index.vue'
|
||||
@ -72,6 +90,44 @@ const tabs = ref<StockTabItem[]>([
|
||||
}
|
||||
])
|
||||
|
||||
// ============================================================
|
||||
// 标签排序(浏览器本地保存,scope=stock.tabs.order)
|
||||
// ============================================================
|
||||
/** 默认 tab 顺序(弹窗选项 / 恢复默认用) */
|
||||
const DEFAULT_TAB_OPTIONS = tabs.value.map(({ name, label }) => ({ name, label }))
|
||||
const sortDialogVisible = ref(false)
|
||||
const preferenceStore = useUserPreferenceStore()
|
||||
const TAB_ORDER_SCOPE = 'stock.tabs.order'
|
||||
|
||||
function openSortDialog() {
|
||||
sortDialogVisible.value = true
|
||||
}
|
||||
|
||||
/** 保存标签顺序:按新顺序重排 tabs 数组(组件对象原样复用,缺失项留在末尾) */
|
||||
function handleSortSaved(order: string[]) {
|
||||
applyTabOrder(order)
|
||||
}
|
||||
|
||||
/** 读取本账号保存的标签顺序并应用;无配置时保持默认顺序 */
|
||||
function applySavedTabOrder() {
|
||||
const saved = preferenceStore.get(TAB_ORDER_SCOPE)
|
||||
if (!Array.isArray(saved) || !saved.length) return
|
||||
applyTabOrder(saved)
|
||||
}
|
||||
|
||||
/** 按给定 tab.name 顺序重排 tabs;非法项剔除,缺失项按当前 tabs 补在末尾 */
|
||||
function applyTabOrder(order: string[]) {
|
||||
const byName = new Map(tabs.value.map((t) => [t.name, t]))
|
||||
const ordered: StockTabItem[] = []
|
||||
for (const name of order) {
|
||||
if (byName.has(name)) ordered.push(byName.get(name)!)
|
||||
}
|
||||
for (const t of tabs.value) {
|
||||
if (!ordered.some((x) => x.name === t.name)) ordered.push(t)
|
||||
}
|
||||
tabs.value = ordered
|
||||
}
|
||||
|
||||
const activeTab = ref('stockDetail')
|
||||
|
||||
function resolveDefaultTab(): string {
|
||||
@ -116,6 +172,10 @@ const handleTabChange = (tabName: string | number) => {
|
||||
activeTab.value = name
|
||||
})
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
applySavedTabOrder()
|
||||
})
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
@ -135,6 +195,7 @@ const handleTabChange = (tabName: string | number) => {
|
||||
================================================================ */
|
||||
.tab-section {
|
||||
flex-shrink: 0;
|
||||
position: relative;
|
||||
background: #fff;
|
||||
border: 1px solid #e8eef7;
|
||||
border-bottom: none;
|
||||
@ -143,6 +204,30 @@ const handleTabChange = (tabName: string | number) => {
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
/* 标签排序入口(tab 区域左侧) */
|
||||
.tab-sort-entry {
|
||||
position: absolute;
|
||||
top: 4px;
|
||||
left: 12px;
|
||||
height: 38px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
z-index: 2;
|
||||
|
||||
.sort-entry-btn {
|
||||
color: #606266;
|
||||
font-size: 15px;
|
||||
padding: 4px 6px;
|
||||
border-radius: 4px;
|
||||
transition: all 0.2s;
|
||||
|
||||
&:hover {
|
||||
color: #409eff;
|
||||
background-color: rgba(64, 158, 255, 0.08);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.tab-container {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
@ -153,7 +238,7 @@ const handleTabChange = (tabName: string | number) => {
|
||||
}
|
||||
|
||||
:deep(.el-tabs__header.is-top) {
|
||||
padding: 4px 12px 0;
|
||||
padding: 4px 12px 0 46px;
|
||||
background: #f8fbff;
|
||||
border-bottom: 1px solid #e8eef7;
|
||||
margin: 0;
|
||||
|
||||
@ -483,7 +483,9 @@ export const PRODUCT_DETAIL_ACTIONS_COLUMN = {
|
||||
export const productquick = [
|
||||
{ prop: 'images', label: '图片', width: '120', align: 'center', fixed: 'left' },
|
||||
{ prop: 'product_name', label: '商品名称', width: '200', fixed: 'left' },
|
||||
{ prop: 'id', label: '收货编码', width: '100' },
|
||||
{ prop: 'barcode', label: '条码', width: '150' },
|
||||
{ prop: 'stock_id', label: 'SKUID', width: '100' },
|
||||
{ prop: 'match_status', label: '匹配状态', width: '100', align: 'center' },
|
||||
{ prop: 'actual_quantity', label: '收货数量', width: '100', align: 'right' },
|
||||
{ prop: 'box_quantity', label: '箱数', width: '100', align: 'right' },
|
||||
|
||||
@ -192,7 +192,7 @@
|
||||
<script setup lang="ts">
|
||||
import { ref, reactive, onMounted, computed } from 'vue'
|
||||
import { ElMessage, ElMessageBox } from 'element-plus'
|
||||
import { storeWarehouseWarehouseList } from '@/api/storeWarehouse.warehouse/storeWarehouse'
|
||||
import { storeWarehouseWarehouseList } from '@/api/storewarehouse.warehouse/storeWarehouse'
|
||||
import { storeWarehouseUnbind, storeWarehouseRename, storeWarehouseConfirmSign } from '@/api/storeWarehouse.store/storeWarehouse'
|
||||
import ScanBox from '@/components/ScanBox/index.vue'
|
||||
import UpperTable from '@/components/UpperTable/index.vue'
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
<!--
|
||||
<!--
|
||||
StoreExportDialog — 货主列表(签约关系)导出 功能表单
|
||||
对接接口:
|
||||
- storeWarehouse.store.export(提交异步导出任务,全量导出,立即返回 task_id)
|
||||
@ -93,7 +93,7 @@ import AsyncExportProgressDialog from '@/components/AsyncExportProgressDialog.vu
|
||||
import {
|
||||
storeWarehouseExport,
|
||||
storeWarehouseExportTaskProgress,
|
||||
} from '@/api/storeWarehouse.store/storeWarehouse'
|
||||
} from '@/api/storewarehouse.store/storeWarehouse'
|
||||
import { loadStores } from '@/api/index/index'
|
||||
|
||||
defineOptions({ name: 'StoreExportDialog' })
|
||||
|
||||
@ -992,12 +992,19 @@
|
||||
@update:visible="exportDialogVisible = $event"
|
||||
/>
|
||||
|
||||
<!-- 签约货主列表导出(功能表单:storeWarehouse.store.export + exportTaskProgress) -->
|
||||
<StoreExportDialog
|
||||
v-model:visible="listExportDialogVisible"
|
||||
:conditions="currentCondition"
|
||||
@success="loadList"
|
||||
@loading-change="listExportLoading = $event"
|
||||
<!-- 签约货主列表导出进度(storeWarehouse.store.export + exportTaskProgress) -->
|
||||
<AsyncExportProgressDialog
|
||||
:visible="listExportDialogVisible"
|
||||
title="导出签约货主列表进度"
|
||||
:loading="listExportLoading"
|
||||
:progress-percent="listExportProgressPercent"
|
||||
:progress-status="listExportProgressStatus"
|
||||
:status-label="listExportStatusLabel"
|
||||
:task-id="listExportTaskProgress.taskId"
|
||||
:message="listExportTaskProgress.message"
|
||||
:error="listExportTaskProgress.error"
|
||||
:update-time="listExportTaskProgress.updateTime"
|
||||
@update:visible="listExportDialogVisible = $event"
|
||||
/>
|
||||
|
||||
<!-- 生成加群授权码弹窗 -->
|
||||
@ -1043,8 +1050,10 @@ import { storeWarehouseList, storeWarehouseUnbind,
|
||||
storeWarehouseOpenAccount, storeWarehouseConfirmSign,
|
||||
storeWarehouseExportPrintQuantityLogs,
|
||||
storeWarehouseExportPrintQuantityLogsTaskProgress,
|
||||
storeWarehouseExport,
|
||||
storeWarehouseExportTaskProgress,
|
||||
storeWarehouseCreateUser
|
||||
} from '@/api/storeWarehouse.store/storeWarehouse'
|
||||
} from '@/api/storewarehouse.store/storeWarehouse'
|
||||
import { listInterfaceTypes, getExpressList, getPlatformList, getQimenAppList, loadStores } from '@/api/index/index'
|
||||
import ScanBox from '@/components/ScanBox/index.vue'
|
||||
import UpperTable from '@/components/UpperTable/index.vue'
|
||||
@ -1060,7 +1069,6 @@ import AsyncExportProgressDialog from '@/components/AsyncExportProgressDialog.vu
|
||||
import { safeInvoke } from '@/utils/safe-invoke'
|
||||
import { columns as defaultColumns, availableFields as defaultAvailableFields, presetTree as defaultPresetTree, qimenFormDefault, qimenFormItems, qimenTableColumns, adjustBalanceDialogDefault, adjustBalanceFormDefault, adjustBalanceFormItems, openAccountDialogDefault, openAccountFormDefault, openAccountFormItems, createUserDialogDefault, createUserFormDefault, createUserFormItems, storeToolbarButtons } from './store-config.ts'
|
||||
import { inboxBindCode } from '@/api/inbox/inbox'
|
||||
import StoreExportDialog from './component/ExportDialog.vue'
|
||||
|
||||
// ─── 列表 ───────────────────────────────────────────────────────────────────
|
||||
const settingsStore = useSettingsStore()
|
||||
@ -1239,9 +1247,8 @@ const toolbarActionMap: Record<string, () => void> = {
|
||||
void loadList()
|
||||
},
|
||||
openOpenAccountDialog: () => openOpenAccountDialog(),
|
||||
openExportDialog: () => {
|
||||
listExportDialogVisible.value = true
|
||||
},
|
||||
handleExportSelected: () => { void handleExportSelected() },
|
||||
handleExportAll: () => { void handleExportAll() },
|
||||
toggleBalance: () => toggleBalance(),
|
||||
toggleDetailVisible: () => toggleDetailVisible()
|
||||
}
|
||||
@ -1259,8 +1266,60 @@ const availableFields = reactive(defaultAvailableFields)
|
||||
const presetTree = ref<any[]>(defaultPresetTree)
|
||||
|
||||
const currentCondition = ref<any>({ use_status: 1 })
|
||||
const listExportDialogVisible = ref(false)
|
||||
const listExportLoading = ref(false)
|
||||
|
||||
// ─── 签约货主列表导出(storeWarehouse.store.export + exportTaskProgress) ──
|
||||
// 下拉选项:导出选中(按勾选签约ID导出)/ 导出全部(按当前筛选条件全量导出)
|
||||
const {
|
||||
exportLoading: listExportLoading,
|
||||
exportDialogVisible: listExportDialogVisible,
|
||||
exportTaskProgress: listExportTaskProgress,
|
||||
exportProgressPercent: listExportProgressPercent,
|
||||
exportProgressStatus: listExportProgressStatus,
|
||||
exportStatusLabel: listExportStatusLabel,
|
||||
submitExportTask: listExportSubmit,
|
||||
resumeExportTaskFromStorage: listExportResume,
|
||||
hasPendingExportTask: listExportHasPending
|
||||
} = useAsyncExportTask({
|
||||
storageKey: 'store:stores:listExportTaskId',
|
||||
submitExport: (payload) => storeWarehouseExport(payload as any),
|
||||
queryProgress: (params) => storeWarehouseExportTaskProgress(params as any)
|
||||
})
|
||||
|
||||
async function handleExportSelected() {
|
||||
if (!selectionRows.value.length) {
|
||||
ElMessage.warning('请先勾选要导出的货主')
|
||||
return
|
||||
}
|
||||
if (listExportHasPending()) {
|
||||
ElMessage.warning('检测到未完成导出任务,请等待当前任务完成后再试')
|
||||
listExportResume()
|
||||
return
|
||||
}
|
||||
const ids = selectionRows.value
|
||||
.map((row: any) => Number(row?.id))
|
||||
.filter((id: number) => Number.isFinite(id) && id > 0)
|
||||
if (!ids.length) {
|
||||
ElMessage.warning('选中的记录无有效签约ID')
|
||||
return
|
||||
}
|
||||
await listExportSubmit({
|
||||
...(currentCondition.value || {}),
|
||||
id: ids.length === 1 ? ids[0] : ids
|
||||
})
|
||||
}
|
||||
|
||||
async function handleExportAll() {
|
||||
if (!list.value.length) {
|
||||
ElMessage.warning('当前无数据可导出')
|
||||
return
|
||||
}
|
||||
if (listExportHasPending()) {
|
||||
ElMessage.warning('检测到未完成导出任务,请等待当前任务完成后再试')
|
||||
listExportResume()
|
||||
return
|
||||
}
|
||||
await listExportSubmit({ ...(currentCondition.value || {}) })
|
||||
}
|
||||
|
||||
async function loadList() {
|
||||
loading.value = true
|
||||
@ -2634,6 +2693,8 @@ async function loadStoreOptions() {
|
||||
onMounted(() => {
|
||||
loadList()
|
||||
loadStoreOptions()
|
||||
// 恢复被中断的货主列表导出任务(存在未完成任务时自动弹进度弹窗继续轮询)
|
||||
listExportResume()
|
||||
})
|
||||
</script>
|
||||
|
||||
|
||||
@ -248,10 +248,15 @@ export const storeToolbarButtons: ToolbarButtonConfig[] = [
|
||||
{
|
||||
key: 'export',
|
||||
label: '导出',
|
||||
category: 'action',
|
||||
category: 'setting',
|
||||
size: 'small',
|
||||
loadingKey: 'listExportLoading',
|
||||
action: 'openExportDialog'
|
||||
action: 'handleExportSelected',
|
||||
buttonType: 'dropdown',
|
||||
dropdownOptions: [
|
||||
{ label: '导出选中', action: 'handleExportSelected' },
|
||||
{ label: '导出全部', action: 'handleExportAll', divided: true }
|
||||
]
|
||||
},
|
||||
{
|
||||
key: 'toggleBalance',
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
<template>
|
||||
<div class="tab-area-wrapper">
|
||||
<div class="tab-area-wrapper" :style="{ '--tab-header-left': `${headerLeftInset}px` }">
|
||||
<el-tabs
|
||||
v-model="activeTab"
|
||||
tab-position="top"
|
||||
@ -35,10 +35,13 @@ const props = withDefaults(
|
||||
defineProps<{
|
||||
tabs?: TabItem[]
|
||||
defaultActive?: string
|
||||
/** 标签头左侧留白(px),给「标签排序」入口按钮让位,默认 12 */
|
||||
headerLeftInset?: number
|
||||
}>(),
|
||||
{
|
||||
tabs: () => [],
|
||||
defaultActive: ''
|
||||
defaultActive: '',
|
||||
headerLeftInset: 12
|
||||
}
|
||||
)
|
||||
|
||||
@ -72,7 +75,7 @@ const handleTabClick = (pane: any) => {
|
||||
}
|
||||
|
||||
:deep(.el-tabs__header.is-top) {
|
||||
padding: 4px 12px 0;
|
||||
padding: 4px 12px 0 var(--tab-header-left, 12px);
|
||||
background: #f8fbff;
|
||||
border-bottom: 1px solid #e8eef7;
|
||||
margin: 0;
|
||||
|
||||
@ -32,9 +32,18 @@
|
||||
<!-- ===== 多标签模式:显示顶部标签栏 ===== -->
|
||||
<template v-if="PAGE_CONFIG.showTabArea && !PAGE_CONFIG.singlePage">
|
||||
<div class="tab-section">
|
||||
<!-- 标签排序入口(tab 区域左侧) -->
|
||||
<div class="tab-sort-entry">
|
||||
<el-tooltip content="标签排序" placement="bottom">
|
||||
<el-button class="sort-entry-btn" size="small" link @click="openSortDialog">
|
||||
<el-icon><Sort /></el-icon>
|
||||
</el-button>
|
||||
</el-tooltip>
|
||||
</div>
|
||||
<TabArea
|
||||
:tabs="tabList"
|
||||
:default-active="activeTabName"
|
||||
:header-left-inset="46"
|
||||
@tab-change="handleTabChange"
|
||||
/>
|
||||
</div>
|
||||
@ -247,6 +256,13 @@
|
||||
v-model:visible="definitionCreateVisible"
|
||||
@success="handleDefinitionSaved"
|
||||
/>
|
||||
|
||||
<SortSettingDialog
|
||||
v-model:visible="sortDialogVisible"
|
||||
:tabs="DEFAULT_TAB_OPTIONS"
|
||||
:scope="TAB_ORDER_SCOPE"
|
||||
@saved="handleSortSaved"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@ -258,7 +274,10 @@ defineOptions({ name: 'BasicManagement' })
|
||||
|
||||
import { ref, computed, onMounted, reactive } from 'vue'
|
||||
import { ElMessage, ElMessageBox } from 'element-plus'
|
||||
import { Sort } from '@element-plus/icons-vue'
|
||||
import { useSettingsStore } from '@/stores/modules/settings'
|
||||
import { useUserPreferenceStore } from '@/stores/modules/userPreference'
|
||||
import SortSettingDialog from '@/components/SortSettingDialog.vue'
|
||||
import { useVerticalSplitPane } from '@/composables/useVerticalSplitPane'
|
||||
import ScanBox from '@/components/ScanBox/index.vue'
|
||||
import UpperTable from '@/components/UpperTable/index.vue'
|
||||
@ -297,9 +316,57 @@ const containerHeight = computed(() =>
|
||||
// ============================================================
|
||||
// 标签页
|
||||
// ============================================================
|
||||
const tabList = computed(() =>
|
||||
tabPages.map((t) => ({ name: t.name, label: t.label }))
|
||||
)
|
||||
/** 标签排序(浏览器本地保存,scope=setting.basicManagement.tabs.order) */
|
||||
const TAB_ORDER_SCOPE = 'setting.basicManagement.tabs.order'
|
||||
const preferenceStore = useUserPreferenceStore()
|
||||
/** 当前标签显示顺序(默认 = tabPages 配置顺序) */
|
||||
const tabPagesOrder = ref<string[]>(tabPages.map((t) => t.name))
|
||||
|
||||
/** 默认 tab 顺序(弹窗选项 / 恢复默认用) */
|
||||
const DEFAULT_TAB_OPTIONS = tabPages.map((t) => ({ name: t.name, label: t.label }))
|
||||
const sortDialogVisible = ref(false)
|
||||
|
||||
function openSortDialog() {
|
||||
sortDialogVisible.value = true
|
||||
}
|
||||
|
||||
/** 保存标签顺序:按新顺序重排 tabPagesOrder */
|
||||
function handleSortSaved(order: string[]) {
|
||||
applyTabOrder(order)
|
||||
}
|
||||
|
||||
/** 读取本账号保存的标签顺序并应用;无配置时保持默认顺序 */
|
||||
function applySavedTabOrder() {
|
||||
const saved = preferenceStore.get(TAB_ORDER_SCOPE)
|
||||
if (!Array.isArray(saved) || !saved.length) return
|
||||
applyTabOrder(saved)
|
||||
}
|
||||
|
||||
/** 按给定 tab.name 顺序重排;非法项剔除,缺失项按配置补在末尾 */
|
||||
function applyTabOrder(order: string[]) {
|
||||
const byName = new Map(tabPages.map((t) => [t.name, t]))
|
||||
const ordered: string[] = []
|
||||
for (const name of order) {
|
||||
if (byName.has(name)) ordered.push(name)
|
||||
}
|
||||
for (const t of tabPages) {
|
||||
if (!ordered.includes(t.name)) ordered.push(t.name)
|
||||
}
|
||||
tabPagesOrder.value = ordered
|
||||
}
|
||||
|
||||
/** 标签列表(按 tabPagesOrder 排序,缺失 tab 按配置补在末尾) */
|
||||
const tabList = computed(() => {
|
||||
const byName = new Map(tabPages.map((t) => [t.name, t]))
|
||||
const names: string[] = []
|
||||
for (const name of tabPagesOrder.value) {
|
||||
if (byName.has(name)) names.push(name)
|
||||
}
|
||||
for (const t of tabPages) {
|
||||
if (!names.includes(t.name)) names.push(t.name)
|
||||
}
|
||||
return names.map((n) => ({ name: n, label: byName.get(n)!.label }))
|
||||
})
|
||||
const activeTabName = ref(tabPages[0]?.name ?? 'tab1')
|
||||
|
||||
/** 当前激活标签页的完整配置 */
|
||||
@ -750,6 +817,7 @@ const upperPaneFullStyle = computed(() => ({
|
||||
// 初始化
|
||||
// ============================================================
|
||||
onMounted(() => {
|
||||
applySavedTabOrder()
|
||||
void loadStoreOptions()
|
||||
// 预加载报表类型注册清单(报表定义页 type 筛选下拉与表单字段依赖)
|
||||
void loadReportTypeList()
|
||||
@ -779,6 +847,7 @@ onMounted(() => {
|
||||
================================================================ */
|
||||
.tab-section {
|
||||
flex-shrink: 0;
|
||||
position: relative;
|
||||
background: #fff;
|
||||
border: 1px solid #e8eef7;
|
||||
border-bottom: none;
|
||||
@ -787,6 +856,30 @@ onMounted(() => {
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
/* 标签排序入口(tab 区域左侧) */
|
||||
.tab-sort-entry {
|
||||
position: absolute;
|
||||
top: 4px;
|
||||
left: 12px;
|
||||
height: 38px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
z-index: 2;
|
||||
|
||||
.sort-entry-btn {
|
||||
color: #606266;
|
||||
font-size: 15px;
|
||||
padding: 4px 6px;
|
||||
border-radius: 4px;
|
||||
transition: all 0.2s;
|
||||
|
||||
&:hover {
|
||||
color: #409eff;
|
||||
background-color: rgba(64, 158, 255, 0.08);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* ================================================================
|
||||
2. 主内容区
|
||||
================================================================ */
|
||||
|
||||
@ -22,8 +22,20 @@
|
||||
label-width="100px"
|
||||
size="small"
|
||||
>
|
||||
<el-form-item label="报表编码" prop="report_code">
|
||||
<el-input v-model="form.report_code" placeholder="请输入报表编码(须为已启用的报表定义)" />
|
||||
<el-form-item label="报表" prop="report_id">
|
||||
<el-select
|
||||
v-model="form.report_id"
|
||||
filterable
|
||||
placeholder="请选择报表定义(须为已启用的报表定义)"
|
||||
style="width: 100%"
|
||||
>
|
||||
<el-option
|
||||
v-for="opt in reportDefinitionOptions"
|
||||
:key="opt.value"
|
||||
:label="opt.label"
|
||||
:value="opt.value"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="货主" prop="store_id">
|
||||
@ -83,14 +95,14 @@ import { reactive, ref, watch, onMounted } from 'vue'
|
||||
import { useAsyncExportTask } from '@/composables/useAsyncExportTask'
|
||||
import AsyncExportProgressDialog from '@/components/AsyncExportProgressDialog.vue'
|
||||
import { generate, generateTaskProgress } from '@/api/report/report'
|
||||
import { storeOptions, loadStoreOptions } from '../config/template-config'
|
||||
import { storeOptions, loadStoreOptions, reportDefinitionOptions, loadReportDefinitions } from '../config/template-config'
|
||||
|
||||
defineOptions({ name: 'ExportReportDialog' })
|
||||
|
||||
const props = defineProps<{
|
||||
visible: boolean
|
||||
/** 初始报表编码(导出任务行「导出此报表」带入) */
|
||||
reportCode?: string
|
||||
/** 初始报表定义ID(导出任务行「导出此报表」带入) */
|
||||
reportId?: number
|
||||
}>()
|
||||
|
||||
const emit = defineEmits<{
|
||||
@ -100,13 +112,13 @@ const emit = defineEmits<{
|
||||
const formRef = ref<any>(null)
|
||||
|
||||
const form = reactive({
|
||||
report_code: '',
|
||||
report_id: undefined as number | undefined,
|
||||
store_id: undefined as number | undefined,
|
||||
bizDate: ''
|
||||
})
|
||||
|
||||
const rules = {
|
||||
report_code: [{ required: true, message: '请输入报表编码', trigger: 'blur' }]
|
||||
report_id: [{ required: true, message: '请选择报表定义', trigger: 'change' }]
|
||||
}
|
||||
|
||||
// 提交导出 + 轮询进度(不传 storageKey → 不写任何本地存储)
|
||||
@ -125,7 +137,7 @@ const {
|
||||
|
||||
watch(() => props.visible, (v) => {
|
||||
if (v) {
|
||||
form.report_code = props.reportCode ?? ''
|
||||
form.report_id = props.reportId ?? undefined
|
||||
form.store_id = undefined
|
||||
form.bizDate = ''
|
||||
formRef.value?.clearValidate?.()
|
||||
@ -134,6 +146,7 @@ watch(() => props.visible, (v) => {
|
||||
|
||||
onMounted(() => {
|
||||
void loadStoreOptions()
|
||||
void loadReportDefinitions()
|
||||
})
|
||||
|
||||
function handleClosed() {
|
||||
@ -149,7 +162,7 @@ async function handleSubmit() {
|
||||
|
||||
// 提交导出任务;提交后进度在弹窗中展示,完成后自动下载(useAsyncExportTask 内部处理)
|
||||
await submitExportTask({
|
||||
report_code: form.report_code.trim(),
|
||||
report_id: form.report_id,
|
||||
...(form.store_id && form.store_id > 0 ? { store_id: form.store_id } : {}),
|
||||
...(form.bizDate ? { params: { bizDate: form.bizDate } } : {})
|
||||
})
|
||||
|
||||
@ -442,7 +442,7 @@ import {
|
||||
storeWarehouseExportStorePrintQuantityLogs,
|
||||
storeWarehouseExportStorePrintQuantityLogsTaskProgress,
|
||||
storeWarehouseQueryStorePrintQuantityLogs
|
||||
} from '@/api/storeWarehouse.store/storeWarehouse'
|
||||
} from '@/api/storewarehouse.store/storeWarehouse'
|
||||
import { listInterfaceTypes, getQimenAppList } from '@/api/index/index'
|
||||
import ScanBox from '@/components/ScanBox/index.vue'
|
||||
import UpperTable from '@/components/UpperTable/index.vue'
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user