1
This commit is contained in:
parent
81b663de63
commit
ae95560aef
@ -1,8 +1,8 @@
|
||||
{
|
||||
"user": "root",
|
||||
"user": "webdev",
|
||||
"ip": "112.124.21.102",
|
||||
"basePath": "/www/wwwroot/web",
|
||||
"keepReleases": 5,
|
||||
"siteHost": "wms.wms.gztbyc.com",
|
||||
"sshKey": "C:\\Users\\lfmingren\\.ssh\\112.124.21.102_id_ed25519"
|
||||
"sshKey": "C:\\Users\\Administrator\\.ssh\\id_ed25519"
|
||||
}
|
||||
191
docs/页面切换渲染性能优化方案.md
Normal file
191
docs/页面切换渲染性能优化方案.md
Normal file
@ -0,0 +1,191 @@
|
||||
# 页面切换渲染性能优化方案
|
||||
|
||||
> 场景:顶部导航栏 / 页面 tab(tags-view)切换页面时,切换速度慢 + 存在显示渲染 bug
|
||||
> 状态:**P0 与 P1 部分已实施(2026-08-31)**;P1-方案 5/7 评估后保留;P2 未做
|
||||
> 日期:2026-08-31
|
||||
|
||||
---
|
||||
|
||||
## 一、背景与目标
|
||||
|
||||
当前通过「顶部导航栏(TopMenu/Navbar)」或「页面 tab(TaskView/tags-view)」切换路由页面时:
|
||||
|
||||
- **速度慢**:切换有明显卡顿/等待,重页面尤甚
|
||||
- **显示 bug**:切换过程白屏闪烁、页面位移跳动、内容被固定表头遮挡、同页参数变化整页重建
|
||||
|
||||
目标:在不改变业务功能的前提下,**提升页面切换渲染速度**并**修复切换显示问题**。
|
||||
|
||||
---
|
||||
|
||||
## 二、现状:页面切换渲染链路
|
||||
|
||||
```
|
||||
顶部导航/页面 tab
|
||||
│ router.push / router-link
|
||||
▼
|
||||
permission.ts router.beforeEach → NProgress.start() + 权限校验
|
||||
▼
|
||||
AppMain.vue <router-view v-slot> → 页面渲染核心
|
||||
│ <transition name="fade-transform">
|
||||
│ <keep-alive :include="cachedViews">
|
||||
│ <component :is="Component" :key="route.fullPath" />
|
||||
▼
|
||||
router.afterEach → NProgress.done()
|
||||
▼
|
||||
TaskView watch(route) → addTags() + moveToCurrentTag()
|
||||
```
|
||||
|
||||
### 关键代码位置
|
||||
|
||||
| 文件 | 职责 |
|
||||
|---|---|
|
||||
| `src/layout/component/AppMain.vue` | 路由页面渲染容器(transition + keep-alive + key) |
|
||||
| `src/layout/component/TaskView/index.vue` | 页面 tab 栏(tags-view),`watch(route)` 添加/维护 tab |
|
||||
| `src/layout/index.vue` | 主布局(fixed-header 固定表头 + task-view + app-main) |
|
||||
| `src/layout/component/Navbar.vue` / `TopMenu.vue` | 顶部导航栏 / 顶部菜单 |
|
||||
| `src/stores/modules/tagsView.ts` | `visitedViews` / `cachedViews`(keep-alive include 白名单) |
|
||||
| `src/permission.ts` | 路由守卫(beforeEach / afterEach,动态路由生成) |
|
||||
| `src/views/redirect/index.vue` | tab「刷新」用的中转页(`/redirect/:path`) |
|
||||
|
||||
---
|
||||
|
||||
## 三、问题根因分析
|
||||
|
||||
### 3.1 切换慢的原因
|
||||
|
||||
#### A1. `AppMain` 的 `:key="route.fullPath"` 导致过度销毁重建
|
||||
```html
|
||||
<component :is="Component" :key="route.fullPath" class="app-router-page" />
|
||||
```
|
||||
- `fullPath` = `path + query`。**只要 query 变化**(页面内部 `?tab=`、筛选条件 URL 化等),key 就变化 → Vue 视为不同实例 → 即使命中 keep-alive 也会触发「旧实例 deactivated + 新实例 created」→ 整页销毁重建、重复执行 `onMounted`、重复请求。
|
||||
- 已在 `order/orderManagement`、`order/waveOrder` 用「方案B 去路由化」局部规避(内部 tab 不写回 URL),但**根因仍在 AppMain**,其它带 query 参数的页面同样中招。
|
||||
|
||||
#### A2. 路由级 keep-alive 的 `:include="cachedViews"` 与组件 name 不匹配 → 缓存失效
|
||||
```html
|
||||
<keep-alive :include="cachedViews">
|
||||
```
|
||||
- `cachedViews` 由 `tagsView.addCachedView` 维护:`cachedViews.push(view.name)`,push 的是**路由 name**(如 `order/index`、`stock/stockManagement`)。
|
||||
- `<keep-alive :include>` 匹配的是**组件 name**(`defineOptions({ name })` 或 SFC 推断名)。
|
||||
- 项目大量路由页面组件**未定义 `defineOptions({ name })`**(`orderManagement/index.vue`、`waveOrder/index.vue`、`stockManagement/index.vue` 等),组件 name ≠ 路由 name → **include 匹配失败 → 这些页面实际从未被路由级缓存**,每次切换都全新挂载 + 重新请求 + 白屏闪烁。
|
||||
- 这是"切换慢 + 白屏"的**首要根因**。
|
||||
|
||||
#### A3. transition 无 `mode="out-in"` + 0.5s 动画 + 位移
|
||||
```css
|
||||
.fade-transform-leave-active, .fade-transform-enter-active { transition: all .5s; }
|
||||
.fade-transform-leave-active { position: absolute; width: 100%; }
|
||||
.fade-transform-enter-from { opacity: 0; transform: translateX(-30px); }
|
||||
.fade-transform-leave-to { opacity: 0; transform: translateX(30px); }
|
||||
```
|
||||
- `<transition>` 未设 `mode`(默认 enter/leave 同时进行):切换时**新旧两页同时存在/渲染**,重页面在切换瞬间渲染两份 → 主线程峰值高、感知慢。
|
||||
- `transition: all .5s`(0.5s)对重型页面过长;`translateX(±30px)` 产生横向位移。
|
||||
- 且离开页 `position: absolute` 与进入页重叠,易出现布局跳动。
|
||||
|
||||
#### A4. 大页面挂载成本高
|
||||
- `orderManagement` 等重页面 `onMounted` 同步发多个请求(`loadData` + `loadOrderMetaOptions` + `loadStoreOptions` + badge 等),一次渲染大量表格/标签/tooltip 组件。
|
||||
- 因 A1/A2 缓存失效,每次切换都重复走完整挂载流程 → 慢被放大。
|
||||
|
||||
#### A5. cachedViews 无限累积
|
||||
- 每打开一个新 tab,`cachedViews` 就追加一个 name,keep-alive 缓存实例持续增长 → 内存占用与切换匹配开销上升(无 `:max` 上限)。
|
||||
|
||||
### 3.2 显示 bug 的原因
|
||||
|
||||
| # | 现象 | 根因 |
|
||||
|---|---|---|
|
||||
| B1 | 切换白屏/闪烁 | A2 缓存失效 → 每次切换销毁重建,旧页消失、新页空白等待数据 |
|
||||
| B2 | 同页 query 变化整页重建 → tab/筛选闪烁 | A1 `:key=fullPath` |
|
||||
| B3 | 切换时两页叠加、横向位移跳动 | A3 无 `out-in` + `translateX` |
|
||||
| B4 | 内容被固定表头遮挡/偏移 | `AppMain.vue` `.fixed-header + .app-main { padding-top: 90px }` 为**固定值**,而 `layout/index.vue` 表头实际高度动态为 `97px`(普通)/ `134px`(快捷栏展开)→ 快捷栏展开时内容顶部被遮挡 |
|
||||
| B5 | tab「刷新」时多跳一次、闪烁 | `TaskView.refreshSelectedTag` = `delCachedView` → `router.replace('/redirect'+fullPath)` → redirect 组件再 `replace` 回原页,**两次跳转** |
|
||||
| B6 | 缓存复用时数据陈旧/事件重复 | 页面只写 `onMounted`/`onUnmounted`,未处理 `onActivated`/`onDeactivated` |
|
||||
|
||||
---
|
||||
|
||||
## 四、优化方案(分阶段实施)
|
||||
|
||||
> 原则:先低成本高收益(P0),再做治理(P1),最后可选优化(P2)。每阶段独立可上线、可回滚。
|
||||
|
||||
### P0 — 核心修复(✅ 已实施)
|
||||
|
||||
#### 方案 1:`:key` 从 `fullPath` 收窄为 `path` ✅ 已实施
|
||||
- 文件:`src/layout/component/AppMain.vue`
|
||||
- 实际做法:`:key="route.name ?? route.path"`(不含 query)。
|
||||
- 收益:同页面 query 变化不再触发销毁重建;仅跨路由切换才重建/切换缓存。
|
||||
- 风险:同页 query 需局部刷新(如筛选参数在 URL 的页面)→ 用页面内 `watch(() => route.query)` 局部刷新,不整页重建。
|
||||
- 回归点:所有依赖"query 变化自动重载"的页面。
|
||||
|
||||
#### 方案 2:修复 keep-alive `:include` 匹配 → 让路由级缓存真正生效 ✅ 已实施(采用 B 路线:包装组件)
|
||||
- 目标:`cachedViews`(路由 name)与组件 name 对齐。
|
||||
- **实际做法(B 路线的更优实现)**:动态路由 name 来自后端菜单,前端组件无法保证一一对应,因此改为在 `AppMain.vue` 用 `wrapRouteComponent(Component, route.name)` 将路由组件**包装为 name=路由 name 的组件**,使 `<keep-alive :include="cachedViews">` 真正匹配。
|
||||
- **关键约束**:keep-alive 必须始终存在(不能放 v-if:访问 Layout 外页面会卸载 KeepAlive 导致全部缓存清零)。
|
||||
- 收益:切回已打开过的 tab 页面**不重建、不重新请求**,白屏消除(实测切回 orderManagement 列表请求 = 0)。
|
||||
|
||||
#### 方案 3:transition 改 `mode="out-in"` + 缩短/简化动画 ✅ 已实施
|
||||
- 文件:`src/layout/component/AppMain.vue` + `src/styles/transition.scss`
|
||||
- 实际做法:`fade-transform` 收敛为纯淡入淡出(`opacity .2s`),去掉 `translateX`;AppMain 加 `mode="out-in"`。
|
||||
- 收益:新旧页面不再同时渲染(内存/主线程峰值下降),无横向位移。
|
||||
|
||||
### P1 — 缓存与布局治理
|
||||
|
||||
#### 方案 4:cachedViews / keep-alive 实例上限治理 ✅ 已实施
|
||||
- 文件:`src/layout/component/AppMain.vue`
|
||||
- 实际做法:`<keep-alive :include="cachedViews" :max="10">`(LRU 上限 10)。
|
||||
|
||||
#### 方案 5:统一 `onActivated` / `onDeactivated` 生命周期 ⏸ 评估后保留(长期治理)
|
||||
- 涉及所有缓存页面(几十个),需逐个评估业务逻辑(数据实时性 vs 缓存),风险高,不适合一次性大改。
|
||||
- 建议后续按需推进:把"进入需刷新"的数据加载从 `onMounted` 迁到 `onActivated`,清理逻辑迁到 `onDeactivated`。
|
||||
|
||||
#### 方案 6:fixed-header 高度动态化 ✅ 已实施
|
||||
- 文件:`src/layout/index.vue`
|
||||
- **实际做法**:spacer 高度由 `shortcutExpanded ? '134px' : '84px'` 改为 `'134px' : '97px'`,与 header minHeight 对齐(原 84 比 97 矮 13px → 内容顶部被固定表头遮挡)。实测内容 top 与 header bottom 对齐(gap=0)。
|
||||
|
||||
#### 方案 7:tab「刷新」减少一次跳转 ⏸ 评估后保留(`/redirect` 为必要机制)
|
||||
- `refreshSelectedTag` 的 `/redirect` 中转是 keep-alive 缓存体系下"强制重建"的必要机制:缓存 key 为 `route.name`,直接 replace 到同路径不会重建;必须先删缓存 + 跳转离场再回场才能强制刷新。
|
||||
- 收益有限且有破坏刷新功能的风险,保留现状。
|
||||
|
||||
### P2 — 可选 / 长期(未做)
|
||||
|
||||
#### 方案 8:重型页面渲染优化(与切换无关的既有性能债)
|
||||
- 继续 `UpperTable` 侧优化:列收敛、tooltip 收窄、长期评估 `el-table-v2`(详见 `docs/UpperTable-大列表滚动性能优化方案.md`)。
|
||||
- 收益:降低单页面板载成本,间接降低切换时的挂载耗时。
|
||||
|
||||
#### 方案 9:首屏按需加载评估
|
||||
- 确认动态 import 分包已生效;对超大页面评估首屏拆块(如详情面板懒渲染、非首屏 tab 懒挂载)。
|
||||
|
||||
---
|
||||
|
||||
## 五、预期效果
|
||||
|
||||
| 指标 | 现状 | P0 后 |
|
||||
|---|---|---|
|
||||
| 切回已打开 tab | 重建 + 重请求(白屏) | 缓存命中,瞬时恢复 |
|
||||
| 同页 query 变化 | 整页销毁重建 | 不重建,局部刷新 |
|
||||
| 切换动画 | 0.5s + 位移 + 双页叠加 | ~0.2s 淡入淡出,单页 |
|
||||
| 固定表头内容遮挡 | 快捷栏展开时被挡 | 高度联动,不再遮挡 |
|
||||
| tab 刷新 | 两次跳转 | 一次跳转 |
|
||||
|
||||
---
|
||||
|
||||
## 六、实施顺序与回归清单
|
||||
|
||||
### 实施顺序
|
||||
1. **P0-方案 2**(补组件 name)→ 让缓存先真正生效(收益最大、风险集中)
|
||||
2. **P0-方案 1**(`:key` 收窄)+ **P0-方案 3**(transition)→ 消除重建与叠加
|
||||
3. **P1**(上限治理 / 生命周期 / fixed-header / 刷新跳转)
|
||||
4. **P2** 视资源可选
|
||||
|
||||
### 回归清单(重点页面)
|
||||
- `order/orderManagement`(8 tab、query 参数、角标)
|
||||
- `order/waveOrder`、`stock/stockManagement`(多 tab + 详情 tab)
|
||||
- 筛选条件 URL 化的页面(验证 query 变化不整页重建、数据仍正确刷新)
|
||||
- 快捷栏展开/收起时各页面顶部内容不被遮挡
|
||||
- tab 打开/关闭/刷新/关闭其他/关闭全部 全流程
|
||||
- 登录态变化(用户/角色切换)后缓存不串数据
|
||||
|
||||
---
|
||||
|
||||
## 七、风险与备注
|
||||
|
||||
- **`:key` 收窄**是行为变更:需确认没有页面依赖"query 变化自动重建"。若有,用页面内 `watch(route.query)` 替代,切勿全局回退。
|
||||
- **补组件 name** 需与路由 name 一一对应,避免误缓存带草稿/表单态的页面;可在 `meta.noCache` 排除个别页面。
|
||||
- **transition 改 out-in** 会改变切换视觉,需与 UI 确认动画时长偏好。
|
||||
- 本方案仅针对「路由级页面切换」;页面**内部** tab(如 orderManagement 8 tab)已有独立 keep-alive 与实验性 tab 缓存设置,与本方案互补,不冲突。
|
||||
@ -261,8 +261,10 @@ export function inboxGroupMessages(data: InboxGroupMessagesParams) {
|
||||
|
||||
/** 群快速查询参数(下拉选择用,不分页) */
|
||||
export interface InboxGroupQuickListParams {
|
||||
/** 货主ID(>0 时按货主过滤;不传返回所有群) */
|
||||
store_id?: number // 货主ID,不传则返回全部
|
||||
/** 货主ID(可选,>0 时按货主过滤;不传返回所有货主的群) */
|
||||
store_id?: number | string
|
||||
/** 仓库ID(可选,>0 时按仓库过滤;不传返回所有仓库的群;与 store_id 可单独传或同时传 AND) */
|
||||
warehouse_id?: number | string
|
||||
keyword?: string // 关键词,模糊匹配群名称与外部群ID
|
||||
groupType?: string // 群类型筛选:store(货主) / warehouse(仓库) / express(快递)
|
||||
limit?: number // 返回条数上限,默认20,最大100(无分页)
|
||||
@ -285,9 +287,12 @@ export function inboxGroupQuickList(data: InboxGroupQuickListParams = {}) {
|
||||
|
||||
/** 查询群成员参数(下拉选择用) */
|
||||
export interface InboxGroupMembersParams {
|
||||
groupIds: number[] // 群记录主键ID数组(必填,非空)
|
||||
keyword?: string // 关键词,模糊匹配用户名与用户ID
|
||||
limit?: number // 返回条数上限,默认20,最大100(无分页)
|
||||
/** 群记录主键ID数组(wms_inbox_group.id,必填,非空;每个元素为正整数,支持数字或可解析数字字符串) */
|
||||
groupIds: Array<number | string>
|
||||
/** 关键词,模糊匹配 user_name(用户名)与 user_id(用户ID) */
|
||||
keyword?: string
|
||||
/** 返回条数上限,默认20,最大100(无分页) */
|
||||
limit?: number
|
||||
}
|
||||
|
||||
/** 查询多个群的成员列表(inbox.group.members) */
|
||||
|
||||
@ -5,18 +5,22 @@ const v = '1.0'
|
||||
/* ===== 报表导出任务 ===== */
|
||||
|
||||
export interface ReportGenerateParams {
|
||||
/** 报表编码(与 reportCode 二选一;均传时优先 reportCode) */
|
||||
report_code?: string
|
||||
/** 报表编码驼峰别名(兼容,优先级高于 report_code) */
|
||||
reportCode?: string
|
||||
/** 报表定义ID(与 reportId 二选一;均传时优先 reportId) */
|
||||
report_id?: number
|
||||
/** 报表定义ID驼峰别名(兼容,优先级高于 report_id) */
|
||||
reportId?: number
|
||||
/** 货主ID(可选,货主维度报表时传入;>0 生效,<=0 视为不按货主过滤) */
|
||||
store_id?: number
|
||||
/** 货主ID驼峰别名(兼容,优先级高于 store_id) */
|
||||
storeId?: number
|
||||
/** 查询器业务参数(透传,如 bizDate) */
|
||||
/** 查询器业务参数(透传) */
|
||||
params?: {
|
||||
/** 数据日期(YYYY-MM-DD) */
|
||||
/** 数据日期(YYYY-MM-DD),用于导出文件名 file_name 模板的 {date} 占位 */
|
||||
bizDate?: string
|
||||
/** 窗口数量覆盖(缺省 7,<=0 视为 7) */
|
||||
dayCount?: number
|
||||
/** 切点小时覆盖(缺省 7,错制到 0-23) */
|
||||
cutoverHour?: number
|
||||
}
|
||||
}
|
||||
|
||||
@ -91,8 +95,8 @@ export function generateTaskProgress(
|
||||
export interface DeliveryPlanSaveParams {
|
||||
/** 货主ID(必填,正整数;<=0 报错) */
|
||||
store_id: number
|
||||
/** 计划名称(必填,≤100 字符) */
|
||||
name: string
|
||||
/** 计划名称(可选,仅展示字段,不参与幂等/关联逻辑;未传不覆盖,null/空串/全空白归一化为 null 清空;非空 trim 后 ≤100 字符,超长报错) */
|
||||
name?: string | null
|
||||
/** 报表定义ID(必填,正整数;须为已启用 is_enabled=1 的报表定义;与 reportId 二选一,均传优先 reportId) */
|
||||
report_id: number
|
||||
/** 报表定义ID驼峰别名(兼容,优先级高于 report_id) */
|
||||
@ -170,9 +174,9 @@ export interface DeliveryPlanListParams {
|
||||
pageSize?: number
|
||||
}
|
||||
sort?: {
|
||||
/** 排序字段(白名单 id/created_at/updated_at/store_id/report_code,默认 id) */
|
||||
/** 排序字段(白名单 id/created_at/updated_at/store_id/report_definition_id,默认 id) */
|
||||
sortField?: string
|
||||
/** 排序方向(ASC/DESC,默认 DESC) */
|
||||
/** 排序方向(ASC/DESC,默认 DESC,大小写不敏感) */
|
||||
sortOrder?: string
|
||||
}
|
||||
}
|
||||
@ -240,8 +244,8 @@ export interface DeliveryLogListParams {
|
||||
where?: {
|
||||
/** 货主ID(>0 时精确过滤) */
|
||||
store_id?: number
|
||||
/** 报表编码(精确过滤) */
|
||||
report_code?: string
|
||||
/** 报表定义ID(>0 时精确过滤) */
|
||||
report_id?: number
|
||||
/** 投递状态过滤(pending/exporting/delivered/failed/cancelled;非法值忽略) */
|
||||
status?: string
|
||||
}
|
||||
@ -294,10 +298,10 @@ export function listDeliveryLog(
|
||||
/* ===== 报表元数据 ===== */
|
||||
|
||||
export interface ReportMetaParams {
|
||||
/** 报表编码(与 reportCode 二选一;均传时优先 reportCode) */
|
||||
report_code?: string
|
||||
/** 报表编码驼峰别名(兼容,优先级高于 report_code) */
|
||||
reportCode?: string
|
||||
/** 报表定义ID(与 reportId 二选一;均传时优先 reportId) */
|
||||
report_id?: number
|
||||
/** 报表定义ID驼峰别名(兼容,优先级高于 report_id) */
|
||||
reportId?: number
|
||||
}
|
||||
|
||||
export interface ReportMetaField {
|
||||
@ -306,20 +310,26 @@ export interface ReportMetaField {
|
||||
/** 字段中文名 */
|
||||
label: string
|
||||
/** 字段类型:string/number/boolean/array */
|
||||
type: 'string' | 'number' | 'boolean' | 'array'
|
||||
/** 是否格式化器预计算字段,仅 true 时返回 */
|
||||
type: string
|
||||
/** 是否预计算字段(非原始表字段),仅 true 时返回 */
|
||||
computed?: boolean
|
||||
/** 是否按文本单元格渲染落地(长数字串防科学计数法),仅 true 时返回 */
|
||||
asText?: boolean
|
||||
/** 该报表定义是否勾选此字段(true=已勾选) */
|
||||
selected?: boolean
|
||||
/** 数组类型字段的子字段清单,仅数组类型字段返回 */
|
||||
children?: ReportMetaField[]
|
||||
}
|
||||
|
||||
export interface ReportMetaResponse {
|
||||
report_code: string
|
||||
/** 报表定义ID(回显) */
|
||||
report_id: number
|
||||
/** 报表名称 */
|
||||
name: string
|
||||
/** 适用维度:warehouse=仓库 / store=货主 / open=通用 */
|
||||
scope: 'warehouse' | 'store' | 'open'
|
||||
/** 查询器 key */
|
||||
query: string
|
||||
/** 报表类型(注册 key,如 stockFlow) */
|
||||
type: string
|
||||
/** 导出文件名模板(支持 {date} 占位) */
|
||||
file_name: string
|
||||
/** 日窗口参数对象 */
|
||||
window: {
|
||||
/** 窗口数量(默认 7) */
|
||||
@ -327,7 +337,7 @@ export interface ReportMetaResponse {
|
||||
/** 切点小时 0-23(默认 7) */
|
||||
cutoverHour: number
|
||||
}
|
||||
/** 查询器静态字段清单 */
|
||||
/** 注册类型全量字段清单(含 selected/asText 标记) */
|
||||
fields: ReportMetaField[]
|
||||
code?: number
|
||||
}
|
||||
|
||||
@ -629,6 +629,107 @@ export function returnUnpackForceRecord(data: ReturnUnpackForceRecordParams): Pr
|
||||
} as any)
|
||||
}
|
||||
|
||||
// ============ returnUnpack.export ============
|
||||
|
||||
/** returnUnpack.export 请求参数(where/sort 语义与 returnUnpack.list 一致) */
|
||||
export type ReturnUnpackExportParams = {
|
||||
/** 查询条件,语义与 returnUnpack.list 的 where 一致;禁止传 warehouse_id/warehouseId(服务端注入) */
|
||||
where?: Record<string, any>
|
||||
/** 排序参数,语义与 returnUnpack.list 的 sort 一致 */
|
||||
sort?: {
|
||||
sortField?: string
|
||||
sortOrder?: string
|
||||
}
|
||||
}
|
||||
|
||||
/** returnUnpack.export 响应(提交成功即返回任务受理信息) */
|
||||
export type ReturnUnpackExportResponse = {
|
||||
/** 任务 ID */
|
||||
task_id: string
|
||||
/** 任务状态:submitted/running/success/failed/not_found */
|
||||
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
|
||||
}
|
||||
|
||||
/** returnUnpack.export:提交退回拆包导出任务(异步,返回 task_id) */
|
||||
export function returnUnpackExport(data: ReturnUnpackExportParams = {}): Promise<ReturnUnpackExportResponse> {
|
||||
return request({
|
||||
url: '/system',
|
||||
method: 'post',
|
||||
params: {
|
||||
method: 'returnUnpack.export',
|
||||
v,
|
||||
timestamp: new Date().getTime()
|
||||
},
|
||||
data,
|
||||
isSystemApi: true
|
||||
} as any)
|
||||
}
|
||||
|
||||
// ============ returnUnpack.exportTaskProgress ============
|
||||
|
||||
/** returnUnpack.exportTaskProgress 请求参数 */
|
||||
export type ReturnUnpackExportTaskProgressParams = {
|
||||
/** 任务 ID(下划线写法,与 taskId 二选一) */
|
||||
task_id?: string
|
||||
/** 任务 ID(驼峰写法,兼容) */
|
||||
taskId?: string
|
||||
}
|
||||
|
||||
/** returnUnpack.exportTaskProgress 响应 */
|
||||
export type ReturnUnpackExportTaskProgressResponse = {
|
||||
/** 任务 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
|
||||
}
|
||||
|
||||
/** returnUnpack.exportTaskProgress:按 task_id 查询退回拆包导出任务进度 */
|
||||
export function returnUnpackExportTaskProgress(data: ReturnUnpackExportTaskProgressParams): Promise<ReturnUnpackExportTaskProgressResponse> {
|
||||
return request({
|
||||
url: '/system',
|
||||
method: 'post',
|
||||
params: {
|
||||
method: 'returnUnpack.exportTaskProgress',
|
||||
v,
|
||||
timestamp: new Date().getTime()
|
||||
},
|
||||
data,
|
||||
isSystemApi: true
|
||||
} as any)
|
||||
}
|
||||
|
||||
// ============ 模块导出 ============
|
||||
|
||||
export const returnUnpackModule = {
|
||||
@ -642,5 +743,7 @@ export const returnUnpackModule = {
|
||||
detailList: returnUnpackDetailList,
|
||||
detail: returnUnpackDetail,
|
||||
delete: returnUnpackDelete,
|
||||
forceRecord: returnUnpackForceRecord
|
||||
forceRecord: returnUnpackForceRecord,
|
||||
export: returnUnpackExport,
|
||||
exportTaskProgress: returnUnpackExportTaskProgress
|
||||
}
|
||||
|
||||
@ -66,6 +66,8 @@ export type SettingWarehouseSubjectConfig = SettingWarehouseSenderConfig & {
|
||||
single_order_pack_max_minutes?: number
|
||||
/** 团购打包最大时长,单位:分钟,默认 40 */
|
||||
group_order_pack_max_minutes?: number
|
||||
/** 拆包最大录制时长,单位:分钟,默认 5,min 1;超过上限时拆包提交的结束时间自动截断为开始时间+上限 */
|
||||
return_unpack_max_record_minutes?: number
|
||||
max_wave_quantity?: number
|
||||
min_group_order_fetch_quantity?: number
|
||||
max_notice_webhook_count?: number
|
||||
|
||||
@ -533,3 +533,103 @@ export function storeWarehouseExportStorePrintQuantityLogsTaskProgress(data: {
|
||||
isSystemApi: true
|
||||
} as any)
|
||||
}
|
||||
|
||||
// ============ storeWarehouse.store.export ============
|
||||
|
||||
/** storeWarehouse.store.export 请求参数(筛选条件与 storeWarehouse.store.list 一致;page/page_size 忽略,全量导出) */
|
||||
export type StoreWarehouseExportParams = {
|
||||
/** 签约备注或主体名称关键字(与 list 一致,模糊匹配 store_remask/warehouse_remask/双方 company_name) */
|
||||
keyword?: string
|
||||
/** 对方主体ID(兼容 store_id),导出时过滤指定货主 */
|
||||
counterparty_id?: number
|
||||
/** 货主ID(counterparty_id 的别名,两者传一即可) */
|
||||
store_id?: number
|
||||
/** 签约状态过滤:1=申请中 2=已通过 3=已拒绝 4=已解除 5=已过期 */
|
||||
auth_status?: number
|
||||
/** 启用状态过滤:0=禁用 1=启用(兼容 warehouse_use_status) */
|
||||
use_status?: number
|
||||
/** 仓库侧启用状态过滤(use_status 的别名,两者传一即可) */
|
||||
warehouse_use_status?: number
|
||||
/** 签约关系ID,兼容 contract_id/relation_id;导出时仅导出该签约关系 */
|
||||
id?: number
|
||||
}
|
||||
|
||||
/** storeWarehouse.store.export 响应(提交成功即返回任务受理信息) */
|
||||
export type StoreWarehouseExportResponse = {
|
||||
/** 任务ID(格式 store_relation_list_export_{storeId}_{timestamp}_{random}) */
|
||||
task_id: string
|
||||
/** 任务状态:submitted/running/success/failed/not_found(提交成功时为 submitted) */
|
||||
status: string
|
||||
/** 当前进度百分比(0-100),提交时返回 0 */
|
||||
progress: number
|
||||
/** 任务提示信息 */
|
||||
message: string
|
||||
/** 任务执行结果(提交时为 null;后台完成后为上传信息对象,含 filename/fileKey/url/cdnUrl/cosUrl/total_count) */
|
||||
result: Record<string, unknown> | null
|
||||
/** 失败时的错误信息(非失败时为空字符串) */
|
||||
error: string
|
||||
/** 任务更新时间(Unix 毫秒时间戳) */
|
||||
update_time: number
|
||||
code?: number
|
||||
}
|
||||
|
||||
/** 提交货主签约列表导出任务(异步,全量导出,返回 task_id) */
|
||||
export function storeWarehouseExport(data: StoreWarehouseExportParams = {}) {
|
||||
return request({
|
||||
url: '/system',
|
||||
method: 'post',
|
||||
params: {
|
||||
method: 'storeWarehouse.store.export',
|
||||
v,
|
||||
timestamp: new Date().getTime()
|
||||
},
|
||||
data,
|
||||
isSystemApi: true
|
||||
} as any)
|
||||
}
|
||||
|
||||
// ============ storeWarehouse.store.exportTaskProgress ============
|
||||
|
||||
/** storeWarehouse.store.exportTaskProgress 请求参数 */
|
||||
export type StoreWarehouseExportTaskProgressParams = {
|
||||
/** 任务ID(下划线写法,与 taskId 二选一) */
|
||||
task_id?: string
|
||||
/** 任务ID(驼峰写法,兼容) */
|
||||
taskId?: string
|
||||
}
|
||||
|
||||
/** storeWarehouse.store.exportTaskProgress 响应 */
|
||||
export type StoreWarehouseExportTaskProgressResponse = {
|
||||
/** 任务ID(缺失时为回显空字符串,status=not_found) */
|
||||
task_id: string
|
||||
/** 任务状态:submitted/running/success/failed/not_found */
|
||||
status: string
|
||||
/** 进度百分比(0-100) */
|
||||
progress: number
|
||||
/** 任务提示信息 */
|
||||
message: string
|
||||
/** 任务执行结果对象(完成后含 filename/fileKey/url/cdnUrl/cosUrl/total_count 等;未完成或 not_found 时为 null) */
|
||||
result: Record<string, unknown> | null
|
||||
/** 失败时的错误信息(非失败时为空字符串) */
|
||||
error: string
|
||||
/** 任务完成后下载链接(从 result.url/cdnUrl/cosUrl/fileKey 兜底取);未完成或不存在时为空字符串 */
|
||||
download_url: string
|
||||
/** 最近一次状态更新时间(Unix 毫秒时间戳) */
|
||||
update_time: number
|
||||
code?: number
|
||||
}
|
||||
|
||||
/** 按 task_id 查询货主签约列表导出任务进度 */
|
||||
export function storeWarehouseExportTaskProgress(data: StoreWarehouseExportTaskProgressParams) {
|
||||
return request({
|
||||
url: '/system',
|
||||
method: 'post',
|
||||
params: {
|
||||
method: 'storeWarehouse.store.exportTaskProgress',
|
||||
v,
|
||||
timestamp: new Date().getTime()
|
||||
},
|
||||
data,
|
||||
isSystemApi: true
|
||||
} as any)
|
||||
}
|
||||
|
||||
@ -6,8 +6,8 @@ const v = '1.0'
|
||||
|
||||
/** waybill.warehouse.list 的 where 筛选条件 */
|
||||
export type WaybillWarehouseListWhere = {
|
||||
/** 运单号(模糊搜索) */
|
||||
waybillCode?: string
|
||||
/** 运单号筛选:字符串时为模糊搜索(LIKE '%值%',向后兼容);字符串数组时为精确匹配(Op.in,元素自动 trim 并过滤空值,空数组或全空值时不加该筛选条件) */
|
||||
waybillCode?: string | string[]
|
||||
/** 主单号(精确匹配),与 waybillCode 互斥,同时传入时 mainWaybillCode 优先 */
|
||||
mainWaybillCode?: string
|
||||
/** 订单ID(等值匹配) */
|
||||
@ -116,7 +116,12 @@ export function waybillWarehouseDetail(
|
||||
export type WaybillWarehouseExportParams = {
|
||||
where?: WaybillWarehouseListWhere
|
||||
sort?: WaybillWarehouseListSort
|
||||
/** 需要导出的字段列表,不传则导出全部字段 */
|
||||
/**
|
||||
* 需要导出的字段列表,不传则导出全部字段。可选字段:
|
||||
* waybill_code, main_waybill_code, waybill_type, order_no, warehouse_name, store_name,
|
||||
* business_key, status_text, logistics_code, logistics_name, logistics_interface_name,
|
||||
* platform_code, weighing_weight, package_material_name, print_count, last_print_at, create_at
|
||||
*/
|
||||
exportFields?: string[]
|
||||
}
|
||||
|
||||
|
||||
@ -151,6 +151,8 @@ export interface WorkbenchBusinessResponse {
|
||||
stock_unit?: string
|
||||
barcodes?: string[]
|
||||
image_url?: string
|
||||
/** 打包要求(来自 stock,未命中/异常时为空字符串) */
|
||||
packing_requirements?: string
|
||||
}>
|
||||
/** 订单命中分表:current(待处理表)或 dispatch(配送表) */
|
||||
source_table: 'current' | 'dispatch'
|
||||
|
||||
236
src/components/UpperTable/ExperimentSettingsDialog.vue
Normal file
236
src/components/UpperTable/ExperimentSettingsDialog.vue
Normal file
@ -0,0 +1,236 @@
|
||||
<!--
|
||||
实验性功能设置表单
|
||||
- 由 UpperTable「字段设置」中的「实验性功能」按钮打开
|
||||
- 表格工作模式(原字段设置工具栏内嵌的 radio,迁移至此)
|
||||
- tab 缓存分类(tab 缓存开关 / 最大缓存数量 / 应用范围)
|
||||
-->
|
||||
<template>
|
||||
<el-dialog
|
||||
v-model="dialogVisible"
|
||||
title="实验性功能"
|
||||
width="600px"
|
||||
align-center
|
||||
append-to-body
|
||||
class="experiment-settings-dialog"
|
||||
>
|
||||
<!-- ===== 表格工作模式 ===== -->
|
||||
<div class="experiment-section">
|
||||
<div class="experiment-section-title">表格工作模式</div>
|
||||
<div class="experiment-section-desc">实验性:调整大列表表格(UpperTable)的渲染调度策略。</div>
|
||||
<div class="experiment-setting-row">
|
||||
<el-radio-group v-model="tableMode" size="small" @change="handleTableModeChange">
|
||||
<el-radio-button value="resource">低占用(默认)</el-radio-button>
|
||||
<el-radio-button value="performance">高性能</el-radio-button>
|
||||
</el-radio-group>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<el-divider />
|
||||
|
||||
<!-- ===== 页面缓存分类 ===== -->
|
||||
<div class="experiment-section">
|
||||
<div class="experiment-section-title">页面缓存</div>
|
||||
<div class="experiment-section-desc">实验性:控制通过顶部导航栏 / 页面 tab 切换的路由页面缓存策略(AppMain 路由级 keep-alive)。</div>
|
||||
|
||||
<div class="experiment-setting-row">
|
||||
<span class="setting-label">页面缓存</span>
|
||||
<el-switch v-model="pageCacheEnabled" @change="handlePageCacheEnabledChange" />
|
||||
</div>
|
||||
|
||||
<div class="experiment-setting-row">
|
||||
<span class="setting-label">最大缓存页面数量</span>
|
||||
<el-input-number
|
||||
:model-value="pageCacheMax"
|
||||
:min="1"
|
||||
:max="50"
|
||||
size="small"
|
||||
:disabled="!pageCacheEnabled"
|
||||
@change="handlePageCacheMaxChange"
|
||||
/>
|
||||
<span class="setting-hint">超出后淘汰最久未使用的页面</span>
|
||||
</div>
|
||||
|
||||
<div class="experiment-setting-row">
|
||||
<span class="setting-label">应用范围</span>
|
||||
<span class="setting-value">
|
||||
全部通过顶部导航栏 / 页面 tab 切换的路由页面
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<el-divider />
|
||||
|
||||
<!-- ===== tab 缓存分类 ===== -->
|
||||
<div class="experiment-section">
|
||||
<div class="experiment-section-title">tab 缓存</div>
|
||||
<div class="experiment-section-desc">实验性:控制含 tab 标签页切换功能页面的 KeepAlive 缓存策略。</div>
|
||||
|
||||
<div class="experiment-setting-row">
|
||||
<span class="setting-label">tab 缓存</span>
|
||||
<el-switch v-model="tabCacheEnabled" @change="handleTabCacheEnabledChange" />
|
||||
</div>
|
||||
|
||||
<div class="experiment-setting-row">
|
||||
<span class="setting-label">最大缓存 tab 数量</span>
|
||||
<el-input-number
|
||||
:model-value="tabCacheMax"
|
||||
:min="1"
|
||||
:max="20"
|
||||
size="small"
|
||||
:disabled="!tabCacheEnabled"
|
||||
@change="handleTabCacheMaxChange"
|
||||
/>
|
||||
<span class="setting-hint">超出后淘汰最久未使用的 tab</span>
|
||||
</div>
|
||||
|
||||
<div class="experiment-setting-row">
|
||||
<span class="setting-label">应用范围</span>
|
||||
<span class="setting-value">
|
||||
订单管理、波次管理、商品明细
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<template #footer>
|
||||
<el-button size="small" type="danger" plain @click="handleResetDefaults">恢复默认</el-button>
|
||||
<el-button @click="dialogVisible = false">关闭</el-button>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { computed } from 'vue'
|
||||
import { ElMessage, ElMessageBox } from 'element-plus'
|
||||
import { useExperimentalStore } from '@/stores/modules/experimental'
|
||||
|
||||
const visible = defineModel<boolean>('visible', { default: false })
|
||||
|
||||
const dialogVisible = computed({
|
||||
get: () => visible.value,
|
||||
set: (val: boolean) => {
|
||||
visible.value = val
|
||||
}
|
||||
})
|
||||
|
||||
const experimentalStore = useExperimentalStore()
|
||||
|
||||
const tableMode = computed({
|
||||
get: () => experimentalStore.tableMode,
|
||||
set: (mode: 'performance' | 'resource') => {
|
||||
experimentalStore.setTableMode(mode)
|
||||
}
|
||||
})
|
||||
|
||||
const tabCacheEnabled = computed({
|
||||
get: () => experimentalStore.tabCacheEnabled,
|
||||
set: (val: boolean) => {
|
||||
experimentalStore.setTabCacheEnabled(val)
|
||||
}
|
||||
})
|
||||
|
||||
const tabCacheMax = computed({
|
||||
get: () => experimentalStore.tabCacheMax,
|
||||
set: (val: number | undefined) => {
|
||||
experimentalStore.setTabCacheMax(Number(val ?? 1))
|
||||
}
|
||||
})
|
||||
|
||||
const pageCacheEnabled = computed({
|
||||
get: () => experimentalStore.pageCacheEnabled,
|
||||
set: (val: boolean) => {
|
||||
experimentalStore.setPageCacheEnabled(val)
|
||||
}
|
||||
})
|
||||
|
||||
const pageCacheMax = computed({
|
||||
get: () => experimentalStore.pageCacheMax,
|
||||
set: (val: number | undefined) => {
|
||||
experimentalStore.setPageCacheMax(Number(val ?? 1))
|
||||
}
|
||||
})
|
||||
|
||||
function handleTableModeChange(mode: 'performance' | 'resource') {
|
||||
experimentalStore.setTableMode(mode)
|
||||
}
|
||||
|
||||
function handleTabCacheEnabledChange(val: boolean | string | number) {
|
||||
experimentalStore.setTabCacheEnabled(Boolean(val))
|
||||
}
|
||||
|
||||
function handleTabCacheMaxChange(val: number | undefined) {
|
||||
experimentalStore.setTabCacheMax(Number(val ?? 1))
|
||||
}
|
||||
|
||||
function handlePageCacheEnabledChange(val: boolean | string | number) {
|
||||
experimentalStore.setPageCacheEnabled(Boolean(val))
|
||||
}
|
||||
|
||||
function handlePageCacheMaxChange(val: number | undefined) {
|
||||
experimentalStore.setPageCacheMax(Number(val ?? 1))
|
||||
}
|
||||
|
||||
/** 恢复全部实验性设置为默认配置(表格工作模式 / 页面缓存 / tab 缓存) */
|
||||
function handleResetDefaults() {
|
||||
ElMessageBox.confirm('确定恢复全部实验性功能为默认配置吗?', '恢复默认', {
|
||||
type: 'warning',
|
||||
confirmButtonText: '恢复',
|
||||
cancelButtonText: '取消'
|
||||
})
|
||||
.then(() => {
|
||||
experimentalStore.resetToDefaults()
|
||||
ElMessage.success('已恢复默认配置')
|
||||
})
|
||||
.catch(() => {})
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
.experiment-settings-dialog {
|
||||
.experiment-section {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 8px;
|
||||
|
||||
.experiment-section-title {
|
||||
font-size: 14px;
|
||||
font-weight: 600;
|
||||
color: #303133;
|
||||
}
|
||||
|
||||
.experiment-section-desc {
|
||||
font-size: 12px;
|
||||
color: #909399;
|
||||
margin-bottom: 4px;
|
||||
}
|
||||
}
|
||||
|
||||
.experiment-setting-row {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 12px;
|
||||
min-height: 32px;
|
||||
|
||||
.setting-label {
|
||||
flex-shrink: 0;
|
||||
width: 128px;
|
||||
font-size: 13px;
|
||||
color: #606266;
|
||||
}
|
||||
|
||||
.setting-hint {
|
||||
font-size: 12px;
|
||||
color: #909399;
|
||||
}
|
||||
|
||||
.setting-value {
|
||||
font-size: 12px;
|
||||
color: #606266;
|
||||
line-height: 1.6;
|
||||
}
|
||||
}
|
||||
|
||||
:deep(.el-divider--horizontal) {
|
||||
margin: 16px 0;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@ -218,11 +218,8 @@
|
||||
append-to-body
|
||||
>
|
||||
<div class="column-config-toolbar">
|
||||
<span class="table-mode-label">表格工作模式</span>
|
||||
<el-radio-group v-model="activeTableMode" size="small" @change="handleTableModeChange">
|
||||
<el-radio-button value="resource">低占用</el-radio-button>
|
||||
<el-radio-button value="performance">高性能</el-radio-button>
|
||||
</el-radio-group>
|
||||
<!-- 实验性功能:表格工作模式等实验性设置已迁移至该表单 -->
|
||||
<el-button size="small" @click="experimentDialogVisible = true">实验性功能</el-button>
|
||||
<el-button size="small" @click="resetColumnConfig">恢复默认</el-button>
|
||||
<el-button size="small" @click="exportGlobalColumnConfig">导出全局配置</el-button>
|
||||
<el-upload
|
||||
@ -341,6 +338,8 @@
|
||||
</el-dialog>
|
||||
|
||||
<qrcode-dialog v-model:visible="waybillQrVisible" :code="waybillQrCode" />
|
||||
|
||||
<experiment-settings-dialog v-model:visible="experimentDialogVisible" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@ -352,8 +351,10 @@ import type { UploadFile } from 'element-plus'
|
||||
import { useUserStore } from '@/stores/modules/user'
|
||||
import { useSettingsStore } from '@/stores/modules/settings'
|
||||
import { useShortcutsStore } from '@/stores/modules/shortcuts'
|
||||
import { useExperimentalStore } from '@/stores/modules/experimental'
|
||||
import defaultSettings from '@/settings'
|
||||
import QrcodeDialog from '@/components/QR/qrcode.vue'
|
||||
import ExperimentSettingsDialog from './ExperimentSettingsDialog.vue'
|
||||
|
||||
defineOptions({
|
||||
name: 'UpperTable'
|
||||
@ -549,6 +550,8 @@ const emit = defineEmits([
|
||||
// Refs
|
||||
const tableRef = ref<any>(null)
|
||||
const userStore = useUserStore()
|
||||
const experimentalStore = useExperimentalStore()
|
||||
const experimentDialogVisible = ref(false)
|
||||
|
||||
type ColumnItem = {
|
||||
prop?: string
|
||||
@ -907,30 +910,19 @@ function applyColumnConfigMap(configs: ColumnConfigItem[]) {
|
||||
editableColumnConfigs.value = [...configs].sort((a, b) => a.order - b.order)
|
||||
}
|
||||
|
||||
/** 表格工作模式 localStorage key(全局,不区分 tableId) */
|
||||
const tableModeStorageKey = computed(() => {
|
||||
const userId = String(userStore.user?.username || userStore.user?.id || 'unknown')
|
||||
const roleId = userStore.roleId || 'default'
|
||||
return `upper_table_mode_${userId}_${roleId}`
|
||||
})
|
||||
|
||||
function readStoredTableMode(): 'performance' | 'resource' | null {
|
||||
const raw = localStorage.getItem(tableModeStorageKey.value)
|
||||
return raw === 'performance' || raw === 'resource' ? raw : null
|
||||
}
|
||||
|
||||
function saveTableMode(mode: 'performance' | 'resource') {
|
||||
localStorage.setItem(tableModeStorageKey.value, mode)
|
||||
}
|
||||
|
||||
/** 初始化:优先读 localStorage,兜底 props.tableMode */
|
||||
/** 初始化:优先读实验性设置 store,兜底 props.tableMode */
|
||||
function initTableMode() {
|
||||
activeTableMode.value = readStoredTableMode() || (props.tableMode as 'performance' | 'resource')
|
||||
activeTableMode.value = experimentalStore.tableMode
|
||||
}
|
||||
|
||||
/** 用户在字段设置中切换工作模式:持久化 + 重置虚拟滚动状态 */
|
||||
/** 切换工作模式(实验性功能表单触发):持久化到 store + 重置虚拟滚动状态 */
|
||||
function handleTableModeChange(mode: 'performance' | 'resource') {
|
||||
saveTableMode(mode)
|
||||
experimentalStore.setTableMode(mode)
|
||||
resetVirtualScrollState()
|
||||
}
|
||||
|
||||
/** 重置虚拟滚动窗口状态(滚动位置、方向、节流计时器) */
|
||||
function resetVirtualScrollState() {
|
||||
virtualScrollTop.value = 0
|
||||
scrollDirection.value = 'down'
|
||||
lastWindowSyncTime = 0
|
||||
@ -942,6 +934,16 @@ function handleTableModeChange(mode: 'performance' | 'resource') {
|
||||
syncVirtualViewport()
|
||||
}
|
||||
|
||||
// 全局实验性设置中的表格工作模式变化 → 所有 UpperTable 实例即时响应
|
||||
watch(
|
||||
() => experimentalStore.tableMode,
|
||||
(mode) => {
|
||||
if (!mode || activeTableMode.value === mode) return
|
||||
activeTableMode.value = mode
|
||||
resetVirtualScrollState()
|
||||
}
|
||||
)
|
||||
|
||||
function saveColumnConfig(configs: ColumnConfigItem[]) {
|
||||
if (!columnConfigStorageKey.value) return
|
||||
const userId = String(userStore.user?.username || userStore.user?.id || 'unknown')
|
||||
|
||||
@ -2,11 +2,21 @@
|
||||
<section class="app-main">
|
||||
<div class="app-main__body">
|
||||
<router-view v-slot="{ Component, route }">
|
||||
<transition name="fade-transform">
|
||||
<keep-alive :include="cachedViews">
|
||||
<transition name="fade-transform" mode="out-in">
|
||||
<!--
|
||||
路由级缓存修复(方案P0):
|
||||
1. keep-alive 始终存在(不能放 v-if 里:访问 Layout 外页面卸载 KeepAlive 会清空缓存)
|
||||
2. include 仍用 cachedViews(路由 name 列表);将路由组件包装为 name=路由 name 的组件,
|
||||
使 include 真正匹配(原 include 匹配「组件 name」与「路由 name」不一致 → 缓存从未生效)
|
||||
3. :key 收窄为 route.name ?? route.path → 同页 query 变化不再触发整页销毁重建
|
||||
4. transition 加 mode="out-in" → 新旧页面不再同时渲染
|
||||
注:访问 Layout 外的页面(/404、/login、/redirect)会卸载整个 Layout 并清空路由缓存,
|
||||
这是布局重建的自然行为(非缓存 bug),正常业务页面间切换不受影响。
|
||||
-->
|
||||
<keep-alive :include="pageCacheEnabled ? cachedViews : []" :max="pageCacheMax">
|
||||
<component
|
||||
:is="Component"
|
||||
:key="route.fullPath"
|
||||
:is="wrapRouteComponent(Component, route.name)"
|
||||
:key="route.name ?? route.path"
|
||||
class="app-router-page"
|
||||
/>
|
||||
</keep-alive>
|
||||
@ -17,11 +27,41 @@
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { computed } from 'vue'
|
||||
import { computed, defineComponent, h, markRaw } from 'vue'
|
||||
import { useTagsViewStore } from '@/stores/modules/tagsView'
|
||||
import { useExperimentalStore } from '@/stores/modules/experimental'
|
||||
|
||||
const tagsViewStore = useTagsViewStore()
|
||||
const experimentalStore = useExperimentalStore()
|
||||
const cachedViews = computed(() => tagsViewStore.cachedViews)
|
||||
|
||||
/** 页面缓存开关(实验性设置,默认开);关闭时路由级 keep-alive 不缓存任何页面 */
|
||||
const pageCacheEnabled = computed(() => experimentalStore.pageCacheEnabled)
|
||||
/** 路由级 keep-alive 最大缓存实例数(实验性设置,默认 8,LRU 淘汰最久未用) */
|
||||
const pageCacheMax = computed(() => experimentalStore.pageCacheMax)
|
||||
|
||||
/** 已包装组件缓存(路由 name → 包装组件),避免每次渲染重建包装组件导致页面重新挂载 */
|
||||
const routeWrapperCache = new Map<string, any>()
|
||||
|
||||
/**
|
||||
* 将路由组件包装为 name=路由 name 的组件,使 keep-alive 的 :include(cachedViews=路由 name)
|
||||
* 能正确匹配。路由页面组件(<script setup>)大多无组件 name,原 include 匹配失败导致缓存从未生效,
|
||||
* 每次切换都销毁重建 + 重新请求(白屏闪烁)。
|
||||
*/
|
||||
function wrapRouteComponent(Component: any, routeName: string | symbol | undefined): any {
|
||||
if (!routeName || typeof routeName !== 'string') return Component
|
||||
let wrapped = routeWrapperCache.get(routeName)
|
||||
if (!wrapped) {
|
||||
wrapped = markRaw(
|
||||
defineComponent({
|
||||
name: routeName,
|
||||
render: () => h(Component)
|
||||
})
|
||||
)
|
||||
routeWrapperCache.set(routeName, wrapped)
|
||||
}
|
||||
return wrapped
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
|
||||
@ -9,6 +9,7 @@
|
||||
<div :class="{ 'fixed-header': fixedHeader, 'fixed-header-top': layoutMode === 'top-bottom' }" :style="{ minHeight: shortcutExpanded ? '134px' : '97px' }">
|
||||
<task-view />
|
||||
</div>
|
||||
<!-- spacer 高度与 header minHeight 对齐(97/134),避免固定表头遮挡内容顶部(原 84 比 97 矮 13px) -->
|
||||
<div v-if="fixedHeader" :style="{ height: shortcutExpanded ? '134px' : '84px', minHeight: shortcutExpanded ? '134px' : '84px' }"></div>
|
||||
<div class="main-box">
|
||||
<app-main />
|
||||
|
||||
168
src/stores/modules/experimental.ts
Normal file
168
src/stores/modules/experimental.ts
Normal file
@ -0,0 +1,168 @@
|
||||
import { defineStore } from 'pinia'
|
||||
import { ref, computed, watch } from 'vue'
|
||||
import { useUserStore } from './user'
|
||||
|
||||
export type TableMode = 'performance' | 'resource'
|
||||
|
||||
/** tab 缓存默认最大数量(超出后按 LRU 淘汰最久未使用) */
|
||||
export const DEFAULT_TAB_CACHE_MAX = 2
|
||||
|
||||
/** 页面缓存默认最大数量(路由级 keep-alive,超出后按 LRU 淘汰最久未使用) */
|
||||
export const DEFAULT_PAGE_CACHE_MAX = 8
|
||||
|
||||
/**
|
||||
* 实验性功能设置(全局,按 用户+角色 持久化到 localStorage)
|
||||
*
|
||||
* 包含:
|
||||
* - tableMode:表格工作模式(原 UpperTable 内部 localStorage key `upper_table_mode_*` 迁移至此)
|
||||
* - tabCacheEnabled / tabCacheMax:tab 缓存分类(应用到所有含 tab 标签页切换功能的页面)
|
||||
*
|
||||
* 持久化 key:experimental_{userId}_{roleId}
|
||||
*/
|
||||
export const useExperimentalStore = defineStore('experimental', () => {
|
||||
const userStore = useUserStore()
|
||||
|
||||
/** 表格工作模式(实验性):resource=低占用(默认)/ performance=高性能 */
|
||||
const tableMode = ref<TableMode>('resource')
|
||||
/** tab 缓存功能开关(默认开启) */
|
||||
const tabCacheEnabled = ref(true)
|
||||
/** 最大缓存 tab 数量(默认 2,超出后淘汰最久未使用) */
|
||||
const tabCacheMax = ref<number>(DEFAULT_TAB_CACHE_MAX)
|
||||
/** 页面缓存功能开关(路由级 keep-alive,默认开启) */
|
||||
const pageCacheEnabled = ref(true)
|
||||
/** 最大缓存页面数量(默认 8,超出后淘汰最久未使用) */
|
||||
const pageCacheMax = ref<number>(DEFAULT_PAGE_CACHE_MAX)
|
||||
|
||||
const storageKey = computed(() => {
|
||||
if (!userStore.user?.username && !userStore.user?.id) return null
|
||||
const userId = userStore.user.username || userStore.user.id || 'unknown'
|
||||
return `experimental_${userId}_${userStore.roleId || 'default'}`
|
||||
})
|
||||
|
||||
/** 旧版表格工作模式存储 key(迁移用) */
|
||||
const legacyTableModeKey = computed(() => {
|
||||
if (!userStore.user?.username && !userStore.user?.id) return null
|
||||
const userId = userStore.user.username || userStore.user.id || 'unknown'
|
||||
return `upper_table_mode_${userId}_${userStore.roleId || 'default'}`
|
||||
})
|
||||
|
||||
const load = () => {
|
||||
if (!storageKey.value) return
|
||||
const saved = localStorage.getItem(storageKey.value)
|
||||
if (saved) {
|
||||
try {
|
||||
const parsed = JSON.parse(saved)
|
||||
if (parsed.tableMode === 'performance' || parsed.tableMode === 'resource') {
|
||||
tableMode.value = parsed.tableMode
|
||||
}
|
||||
if (typeof parsed.tabCacheEnabled === 'boolean') {
|
||||
tabCacheEnabled.value = parsed.tabCacheEnabled
|
||||
}
|
||||
if (Number.isInteger(parsed.tabCacheMax) && parsed.tabCacheMax > 0) {
|
||||
tabCacheMax.value = parsed.tabCacheMax
|
||||
}
|
||||
if (typeof parsed.pageCacheEnabled === 'boolean') {
|
||||
pageCacheEnabled.value = parsed.pageCacheEnabled
|
||||
}
|
||||
if (Number.isInteger(parsed.pageCacheMax) && parsed.pageCacheMax > 0) {
|
||||
pageCacheMax.value = parsed.pageCacheMax
|
||||
}
|
||||
return
|
||||
} catch (e) {
|
||||
console.error('Failed to parse experimental settings from storage', e)
|
||||
}
|
||||
}
|
||||
// 兼容迁移:旧版表格工作模式 key 未写入新 store 时并入
|
||||
if (legacyTableModeKey.value) {
|
||||
const raw = localStorage.getItem(legacyTableModeKey.value)
|
||||
if (raw === 'performance' || raw === 'resource') {
|
||||
tableMode.value = raw
|
||||
save()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const save = () => {
|
||||
if (!storageKey.value) return
|
||||
const payload = {
|
||||
tableMode: tableMode.value,
|
||||
tabCacheEnabled: tabCacheEnabled.value,
|
||||
tabCacheMax: tabCacheMax.value,
|
||||
pageCacheEnabled: pageCacheEnabled.value,
|
||||
pageCacheMax: pageCacheMax.value
|
||||
}
|
||||
try {
|
||||
localStorage.setItem(storageKey.value, JSON.stringify(payload))
|
||||
} catch (e) {
|
||||
console.error('Failed to save experimental settings', e)
|
||||
}
|
||||
}
|
||||
|
||||
// 用户/角色变化时重载(登录/登出/切换角色)
|
||||
watch(
|
||||
storageKey,
|
||||
(key) => {
|
||||
if (key) {
|
||||
load()
|
||||
} else {
|
||||
// 无用户时重置为默认
|
||||
tableMode.value = 'resource'
|
||||
tabCacheEnabled.value = true
|
||||
tabCacheMax.value = DEFAULT_TAB_CACHE_MAX
|
||||
pageCacheEnabled.value = true
|
||||
pageCacheMax.value = DEFAULT_PAGE_CACHE_MAX
|
||||
}
|
||||
},
|
||||
{ immediate: true }
|
||||
)
|
||||
|
||||
const setTableMode = (mode: TableMode) => {
|
||||
tableMode.value = mode
|
||||
save()
|
||||
}
|
||||
|
||||
const setTabCacheEnabled = (enabled: boolean) => {
|
||||
tabCacheEnabled.value = enabled
|
||||
save()
|
||||
}
|
||||
|
||||
const setTabCacheMax = (max: number) => {
|
||||
tabCacheMax.value = Math.max(1, Math.floor(Number(max) || 1))
|
||||
save()
|
||||
}
|
||||
|
||||
const setPageCacheEnabled = (enabled: boolean) => {
|
||||
pageCacheEnabled.value = enabled
|
||||
save()
|
||||
}
|
||||
|
||||
const setPageCacheMax = (max: number) => {
|
||||
pageCacheMax.value = Math.max(1, Math.floor(Number(max) || 1))
|
||||
save()
|
||||
}
|
||||
|
||||
/** 恢复全部实验性设置为默认值并持久化(表格工作模式 / 页面缓存 / tab 缓存) */
|
||||
const resetToDefaults = () => {
|
||||
tableMode.value = 'resource'
|
||||
tabCacheEnabled.value = true
|
||||
tabCacheMax.value = DEFAULT_TAB_CACHE_MAX
|
||||
pageCacheEnabled.value = true
|
||||
pageCacheMax.value = DEFAULT_PAGE_CACHE_MAX
|
||||
save()
|
||||
}
|
||||
|
||||
return {
|
||||
tableMode,
|
||||
tabCacheEnabled,
|
||||
tabCacheMax,
|
||||
pageCacheEnabled,
|
||||
pageCacheMax,
|
||||
storageKey,
|
||||
setTableMode,
|
||||
setTabCacheEnabled,
|
||||
setTabCacheMax,
|
||||
setPageCacheEnabled,
|
||||
setPageCacheMax,
|
||||
resetToDefaults
|
||||
}
|
||||
})
|
||||
@ -12,24 +12,16 @@
|
||||
}
|
||||
|
||||
/* fade-transform */
|
||||
/* 方案P0:收敛为纯淡入淡出(配合 AppMain mode="out-in"),去掉 translateX 位移与 0.5s 全属性过渡,
|
||||
避免切换时新旧两页叠加、横向位移、主线程峰值过高 */
|
||||
.fade-transform-leave-active,
|
||||
.fade-transform-enter-active {
|
||||
transition: all .5s;
|
||||
}
|
||||
|
||||
.fade-transform-leave-active {
|
||||
position: absolute;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.fade-transform-enter-from {
|
||||
opacity: 0;
|
||||
transform: translateX(-30px);
|
||||
transition: opacity .2s;
|
||||
}
|
||||
|
||||
.fade-transform-enter-from,
|
||||
.fade-transform-leave-to {
|
||||
opacity: 0;
|
||||
transform: translateX(30px);
|
||||
}
|
||||
|
||||
/* breadcrumb transition */
|
||||
|
||||
@ -140,7 +140,7 @@
|
||||
import { ref, reactive, onMounted } from 'vue'
|
||||
import { ElMessage } from 'element-plus'
|
||||
import { Search, Refresh } from '@element-plus/icons-vue'
|
||||
import { storeWarehouseWarehouseList } from '@/api/storeWarehouse.warehouse/storeWarehouse'
|
||||
import { storeWarehouseWarehouseList } from '@/api/storewarehouse.warehouse/storeWarehouse'
|
||||
import ScanBox from '@/components/ScanBox/index.vue'
|
||||
import UpperTable from '@/components/UpperTable/index.vue'
|
||||
|
||||
|
||||
288
src/views/express/returnUnpack/components/ExportDialog.vue
Normal file
288
src/views/express/returnUnpack/components/ExportDialog.vue
Normal file
@ -0,0 +1,288 @@
|
||||
<!--
|
||||
ReturnUnpackExportDialog — 退回拆包导出 功能表单
|
||||
对接接口:
|
||||
- returnUnpack.export(提交异步导出任务,立即返回 task_id)
|
||||
- returnUnpack.exportTaskProgress(按 task_id 轮询进度,完成后返回 download_url 并自动下载)
|
||||
说明:
|
||||
- where/sort 语义与 returnUnpack.list 完全一致;warehouse_id/warehouseId 禁止传递(服务端注入)
|
||||
- 表单预填当前列表的筛选条件(ScanBox),提交前可再调整
|
||||
-->
|
||||
<template>
|
||||
<el-dialog
|
||||
:model-value="visible"
|
||||
title="导出退回拆包单"
|
||||
width="560px"
|
||||
align-center
|
||||
destroy-on-close
|
||||
:close-on-click-modal="false"
|
||||
@closed="handleClosed"
|
||||
>
|
||||
<div class="export-form-body">
|
||||
<el-form ref="formRef" :model="form" label-width="110px" size="small">
|
||||
<el-form-item label="拆包单号">
|
||||
<el-input v-model="form.unpack_no" placeholder="拆包单号模糊搜索" clearable />
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="退回运单号">
|
||||
<el-input v-model="form.waybill_code" placeholder="退回运单号模糊搜索" clearable />
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="拆包状态">
|
||||
<el-select v-model="form.status" placeholder="全部" clearable style="width: 100%">
|
||||
<el-option label="拆包中" value="unpacking" />
|
||||
<el-option label="已完成" value="completed" />
|
||||
<el-option label="已作废" value="cancelled" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="明细识别状态">
|
||||
<el-select v-model="form.detail_status" placeholder="全部" clearable style="width: 100%">
|
||||
<el-option label="全部识别" value="all_recognized" />
|
||||
<el-option label="部分识别" value="partial_recognized" />
|
||||
<el-option label="未识别" value="none_recognized" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="拆包日期">
|
||||
<el-date-picker
|
||||
v-model="form.unpack_date"
|
||||
type="datetimerange"
|
||||
value-format="YYYY-MM-DD HH:mm:ss"
|
||||
start-placeholder="开始时间"
|
||||
end-placeholder="结束时间"
|
||||
style="width: 100%"
|
||||
/>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="货主">
|
||||
<el-select
|
||||
v-model="form.store_id"
|
||||
filterable
|
||||
clearable
|
||||
placeholder="全部"
|
||||
style="width: 100%"
|
||||
>
|
||||
<el-option
|
||||
v-for="opt in storeOptions"
|
||||
:key="String(opt.value)"
|
||||
:label="opt.label"
|
||||
:value="opt.value"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="排序方式">
|
||||
<span class="export-form-body__sort">{{ sortLabel || '默认排序' }}</span>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
|
||||
<div class="export-form-body__tip">
|
||||
将按以上筛选条件提交异步导出任务,任务完成后自动下载文件;如需继续编辑可在进度弹窗中等待。
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<template #footer>
|
||||
<el-button size="small" @click="handleClosed">取消</el-button>
|
||||
<el-button size="small" type="primary" :loading="exportLoading" @click="handleSubmit">
|
||||
提交导出
|
||||
</el-button>
|
||||
</template>
|
||||
</el-dialog>
|
||||
|
||||
<!-- 导出任务进度(提交后接管,完成后自动下载) -->
|
||||
<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"
|
||||
/>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { computed, onMounted, reactive, ref, watch } from 'vue'
|
||||
import { useAsyncExportTask } from '@/composables/useAsyncExportTask'
|
||||
import AsyncExportProgressDialog from '@/components/AsyncExportProgressDialog.vue'
|
||||
import { returnUnpackExport, returnUnpackExportTaskProgress } from '@/api/returnunpack'
|
||||
import { loadStores } from '@/api/index/index'
|
||||
import { extractStoreListFromResponse, mapStoreListToSelectOptions } from '@/views/order/orderManagement/config/order-common-config'
|
||||
|
||||
defineOptions({ name: 'ReturnUnpackExportDialog' })
|
||||
|
||||
const props = defineProps<{
|
||||
visible: boolean
|
||||
/** 当前列表筛选条件(ScanBox 原始条件,语义与 returnUnpack.list 一致,用于预填表单) */
|
||||
conditions?: Record<string, any>
|
||||
/** 当前列表排序 */
|
||||
sort?: { prop?: string; order?: string }
|
||||
}>()
|
||||
|
||||
const emit = defineEmits<{
|
||||
(e: 'update:visible', v: boolean): void
|
||||
(e: 'success'): void
|
||||
(e: 'loading-change', v: boolean): void
|
||||
}>()
|
||||
|
||||
const formRef = ref<any>(null)
|
||||
|
||||
const form = reactive<{
|
||||
unpack_no: string
|
||||
waybill_code: string
|
||||
status?: string
|
||||
detail_status?: string
|
||||
unpack_date?: [string, string]
|
||||
store_id?: number
|
||||
}>({
|
||||
unpack_no: '',
|
||||
waybill_code: '',
|
||||
status: undefined,
|
||||
detail_status: undefined,
|
||||
unpack_date: undefined,
|
||||
store_id: undefined,
|
||||
})
|
||||
|
||||
const storeOptions = ref<Array<{ label: string; value: number | string }>>([])
|
||||
|
||||
// 提交导出 + 轮询进度(storageKey 用于恢复被中断的导出任务)
|
||||
const {
|
||||
exportLoading,
|
||||
exportDialogVisible,
|
||||
exportTaskProgress,
|
||||
exportProgressPercent,
|
||||
exportProgressStatus,
|
||||
exportStatusLabel,
|
||||
submitExportTask,
|
||||
resumeExportTaskFromStorage,
|
||||
} = useAsyncExportTask({
|
||||
storageKey: 'express:returnUnpack:exportTaskId',
|
||||
submitExport: (payload) => returnUnpackExport(payload as any),
|
||||
queryProgress: (params) => returnUnpackExportTaskProgress(params),
|
||||
})
|
||||
|
||||
const sortLabel = computed(() => {
|
||||
const prop = props.sort?.prop
|
||||
if (!prop) return ''
|
||||
const order = props.sort?.order === 'ascending' ? '升序' : '降序'
|
||||
const map: Record<string, string> = {
|
||||
id: 'ID',
|
||||
unpack_no: '拆包单号',
|
||||
waybill_code: '退回运单号',
|
||||
created_at: '创建时间',
|
||||
}
|
||||
return `${map[prop] || prop}(${order})`
|
||||
})
|
||||
|
||||
/** 兼容 ScanBox 条件:{ value: x } 或原始值 */
|
||||
function condValue(cond: any): any {
|
||||
if (cond === undefined || cond === null) return undefined
|
||||
return cond && typeof cond === 'object' && 'value' in cond ? cond.value : cond
|
||||
}
|
||||
|
||||
function prefillFromConditions() {
|
||||
const c = props.conditions ?? {}
|
||||
const unpackNo = condValue(c.unpack_no)
|
||||
form.unpack_no = typeof unpackNo === 'string' ? unpackNo : ''
|
||||
const waybill = condValue(c.waybill_code)
|
||||
form.waybill_code = typeof waybill === 'string' ? waybill : ''
|
||||
const status = condValue(c.status)
|
||||
form.status = status != null ? String(status) : undefined
|
||||
const detailStatus = condValue(c.detail_status)
|
||||
form.detail_status = detailStatus != null ? String(detailStatus) : undefined
|
||||
const dateRange = condValue(c.unpack_date)
|
||||
form.unpack_date =
|
||||
Array.isArray(dateRange) && dateRange.length === 2 ? (dateRange as [string, string]) : undefined
|
||||
const storeId = condValue(c.store_id)
|
||||
form.store_id = storeId != null && !Number.isNaN(Number(storeId)) ? Number(storeId) : undefined
|
||||
}
|
||||
|
||||
watch(
|
||||
() => props.visible,
|
||||
(v) => {
|
||||
if (v) {
|
||||
prefillFromConditions()
|
||||
formRef.value?.clearValidate?.()
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
// 导出加载状态同步给父级(工具栏「导出」按钮 loading)
|
||||
watch(exportLoading, (v) => emit('loading-change', v))
|
||||
|
||||
onMounted(async () => {
|
||||
// 加载货主下拉选项
|
||||
try {
|
||||
const storesRes: any = await loadStores()
|
||||
storeOptions.value = mapStoreListToSelectOptions(extractStoreListFromResponse(storesRes))
|
||||
} catch {
|
||||
storeOptions.value = []
|
||||
}
|
||||
// 恢复被中断的导出任务(存在未完成任务时自动弹进度弹窗继续轮询)
|
||||
resumeExportTaskFromStorage()
|
||||
})
|
||||
|
||||
function handleClosed() {
|
||||
emit('update:visible', false)
|
||||
}
|
||||
|
||||
/** 依据表单构建 returnUnpack.export 的 where(与 returnUnpack.list 语义一致,禁止传 warehouse_id) */
|
||||
function buildExportPayload(): Record<string, any> {
|
||||
const where: Record<string, any> = {}
|
||||
const unpackNo = form.unpack_no.trim()
|
||||
if (unpackNo) where.unpack_no = { operator: 'like', value: unpackNo }
|
||||
const waybillCode = form.waybill_code.trim()
|
||||
if (waybillCode) where.waybill_code = { operator: 'like', value: waybillCode }
|
||||
if (form.status) where.status = String(form.status)
|
||||
if (form.detail_status) where.detail_status = String(form.detail_status)
|
||||
if (form.unpack_date && form.unpack_date[0] && form.unpack_date[1]) {
|
||||
where.unpack_date = { operator: 'between', value: form.unpack_date }
|
||||
}
|
||||
if (form.store_id != null) where.store_id = Number(form.store_id)
|
||||
|
||||
const payload: Record<string, any> = { where }
|
||||
if (props.sort?.prop) {
|
||||
payload.sort = {
|
||||
sortField: props.sort.prop,
|
||||
sortOrder: props.sort.order === 'ascending' ? 'asc' : 'desc',
|
||||
}
|
||||
}
|
||||
return payload
|
||||
}
|
||||
|
||||
async function handleSubmit() {
|
||||
try {
|
||||
await formRef.value?.validate()
|
||||
} catch {
|
||||
return
|
||||
}
|
||||
// 提交导出任务;进度弹窗接管展示,完成后自动下载(useAsyncExportTask 内部处理)
|
||||
await submitExportTask(buildExportPayload())
|
||||
emit('success')
|
||||
emit('update:visible', false)
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.export-form-body {
|
||||
padding: 4px 4px 0;
|
||||
|
||||
&__sort {
|
||||
color: #606266;
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
&__tip {
|
||||
margin-top: 4px;
|
||||
padding: 8px 12px;
|
||||
border-radius: 4px;
|
||||
background: #f5f7fa;
|
||||
color: #909399;
|
||||
font-size: 12px;
|
||||
line-height: 1.6;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@ -277,6 +277,15 @@
|
||||
:video="playingVideo"
|
||||
/>
|
||||
|
||||
<!-- 退回拆包导出(功能表单:returnUnpack.export + returnUnpack.exportTaskProgress) -->
|
||||
<ReturnUnpackExportDialog
|
||||
v-model:visible="exportDialogVisible"
|
||||
:conditions="currentConditions"
|
||||
:sort="currentSort"
|
||||
@success="handleRefresh"
|
||||
@loading-change="exportLoading = $event"
|
||||
/>
|
||||
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@ -303,6 +312,7 @@ 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'
|
||||
|
||||
// ==================== 常量 / 工具 ====================
|
||||
|
||||
@ -448,7 +458,11 @@ const columns = returnUnpackColumns
|
||||
const tableSize = 'small'
|
||||
const toolbarButtons: ToolbarButtonConfig[] = returnUnpackToolbarButtons
|
||||
|
||||
const buttonLoadingMap = ref<Record<string, boolean>>({ loading: false })
|
||||
const exportLoading = ref(false)
|
||||
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('')
|
||||
@ -468,6 +482,7 @@ function resolveButtonLabel(defaultLabel: string, dynamicLabelKey?: string) {
|
||||
const toolbarActionMap: Record<string, () => void> = {
|
||||
loadData: () => { handleRefresh() },
|
||||
openColumnConfigPanel: () => openColumnConfigPanel(),
|
||||
openExportDialog: () => { exportDialogVisible.value = true },
|
||||
}
|
||||
|
||||
function openColumnConfigPanel() {
|
||||
@ -489,6 +504,7 @@ const queryTime = ref(0)
|
||||
const tableData = ref<any[]>([])
|
||||
const currentConditions = ref<Record<string, any>>({})
|
||||
const currentSort = ref<{ prop: string; order: string }>({ prop: '', order: '' })
|
||||
const exportDialogVisible = ref(false)
|
||||
|
||||
const pagination = reactive({ currentPage: 1, pageSize: 20, total: 0 })
|
||||
const upperPagination = reactive({ currentPage: 1, pageSize: 20, total: 0 })
|
||||
|
||||
@ -90,5 +90,13 @@ export const returnUnpackColumns = [
|
||||
// ============================================================
|
||||
export const returnUnpackToolbarButtons: ToolbarButtonConfig[] = [
|
||||
{ key: 'refresh', label: '刷新', category: 'refresh', size: 'small', loadingKey: 'loading', action: 'loadData' },
|
||||
{
|
||||
key: 'export',
|
||||
label: '导出',
|
||||
category: 'action',
|
||||
size: 'small',
|
||||
loadingKey: 'exportLoading',
|
||||
action: 'openExportDialog',
|
||||
},
|
||||
{ key: 'columnConfig', label: '字段设置', category: 'setting', size: 'small', action: 'openColumnConfigPanel' },
|
||||
]
|
||||
|
||||
@ -1725,6 +1725,7 @@ export const deliveryOrderToolbarButtonKeys = [
|
||||
...simpleListToolbarButtonKeys,
|
||||
'batchPrint',
|
||||
'allocateSubOrderNumber',
|
||||
'subWaybillPrint',
|
||||
]
|
||||
export const deliveryOrderToolbarButtons = pickToolbarButtons(deliveryOrderToolbarButtonKeys)
|
||||
|
||||
|
||||
@ -203,6 +203,60 @@
|
||||
@refresh="handleBatchPrintRefresh"
|
||||
@print-success="onBatchPrintSuccess"
|
||||
/>
|
||||
<wave-platform-print-preview-dialog
|
||||
v-model="subWaybillPrintDialogVisible"
|
||||
:error-message="subWaybillPrintErrorMessage"
|
||||
:payload="subWaybillPrintPayload"
|
||||
:request-meta="subWaybillPrintRequestMeta"
|
||||
@refresh="handleSubWaybillPrintRefresh"
|
||||
@print-success="onSubWaybillPrintSuccess"
|
||||
/>
|
||||
|
||||
<!-- 子单号打印:选择运单号 -->
|
||||
<el-dialog
|
||||
v-model="subWaybillSelectDialogVisible"
|
||||
title="选择运单号打印"
|
||||
width="680px"
|
||||
:close-on-click-modal="false"
|
||||
>
|
||||
<el-alert
|
||||
v-if="subWaybillSelectErrorMessage"
|
||||
:title="subWaybillSelectErrorMessage"
|
||||
type="error"
|
||||
:closable="false"
|
||||
show-icon
|
||||
style="margin-bottom: 12px"
|
||||
/>
|
||||
<el-table
|
||||
:data="subWaybillOptions"
|
||||
:loading="subWaybillSelectLoading"
|
||||
max-height="420"
|
||||
size="small"
|
||||
@selection-change="onSubWaybillSelectChange"
|
||||
>
|
||||
<el-table-column type="selection" width="48" />
|
||||
<el-table-column prop="waybill_code" label="运单号" min-width="190" show-overflow-tooltip />
|
||||
<el-table-column label="类型" width="80" align="center">
|
||||
<template #default="{ row }">
|
||||
<el-tag :type="row.is_main ? 'info' : 'success'" size="small">
|
||||
{{ row.is_main ? '主单' : '子单' }}
|
||||
</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="logistics_name" label="物流公司" min-width="130" show-overflow-tooltip />
|
||||
</el-table>
|
||||
<template #footer>
|
||||
<el-button size="small" @click="closeSubWaybillSelectDialog">取消</el-button>
|
||||
<el-button
|
||||
size="small"
|
||||
type="primary"
|
||||
:loading="subWaybillPrintLoading"
|
||||
@click="confirmSubWaybillPrint"
|
||||
>
|
||||
打印所选运单
|
||||
</el-button>
|
||||
</template>
|
||||
</el-dialog>
|
||||
|
||||
<allocate-sub-order-number-form
|
||||
v-model="allocateSubOrderNumberDialogVisible"
|
||||
@ -268,6 +322,7 @@ import { createOrderPageExport } from './utils/order-page-export'
|
||||
import { buildOrderWhereConditions, parseOrderListResponse, resolveOrderRecheckStatus } from './utils/order-index-helpers'
|
||||
import { useOrderListPageCleanup } from './utils/use-order-list-page-cleanup'
|
||||
import { useOrderBatchPrint } from './utils/use-order-batch-print'
|
||||
import { useDeliveryOrderSubWaybillPrint } from './utils/use-delivery-sub-waybill-print'
|
||||
import { useVerticalSplitPane } from '@/composables/useVerticalSplitPane'
|
||||
import OrderToolbarButtonGroup from './component/OrderToolbarButtonGroup.vue'
|
||||
import AllocateSubOrderNumberForm from './form/AllocateSubOrderNumberForm.vue'
|
||||
@ -347,11 +402,37 @@ const {
|
||||
emptySelectionMessage: '请先勾选需要批量打印的订单'
|
||||
})
|
||||
|
||||
const {
|
||||
dialogVisible: subWaybillPrintDialogVisible,
|
||||
loading: subWaybillPrintLoading,
|
||||
errorMessage: subWaybillPrintErrorMessage,
|
||||
payload: subWaybillPrintPayload,
|
||||
requestMeta: subWaybillPrintRequestMeta,
|
||||
resetState: resetSubWaybillPrintState,
|
||||
handlePrint: handleSubWaybillPrint,
|
||||
handleRefresh: handleSubWaybillPrintRefresh,
|
||||
onPrintSuccess: onSubWaybillPrintSuccess,
|
||||
selectDialogVisible: subWaybillSelectDialogVisible,
|
||||
selectLoading: subWaybillSelectLoading,
|
||||
waybillOptions: subWaybillOptions,
|
||||
selectErrorMessage: subWaybillSelectErrorMessage,
|
||||
onSelectChange: onSubWaybillSelectChange,
|
||||
confirmPrintWaybills: confirmSubWaybillPrint,
|
||||
closeSelectDialog: closeSubWaybillSelectDialog
|
||||
} = useDeliveryOrderSubWaybillPrint({
|
||||
getSelectionRows: () => selectionRows.value,
|
||||
onPrintSuccess: () => loadData(),
|
||||
emptySelectionMessage: '请先勾选需要打印子单号的订单'
|
||||
})
|
||||
|
||||
useOrderListPageCleanup({
|
||||
list,
|
||||
selectionRows,
|
||||
selectedOrderId,
|
||||
onCleanup: resetBatchPrintState
|
||||
onCleanup: () => {
|
||||
resetBatchPrintState()
|
||||
resetSubWaybillPrintState()
|
||||
}
|
||||
})
|
||||
|
||||
function normalizeOptionValue(value: unknown) {
|
||||
@ -515,6 +596,7 @@ const buttonLoadingMap = computed<Record<string, boolean>>(() => ({
|
||||
exportLoading: exportLoading.value,
|
||||
exportSelectionLoading: exportSelectionLoading.value,
|
||||
batchPrintLoading: batchPrintLoading.value,
|
||||
subWaybillPrintLoading: subWaybillPrintLoading.value,
|
||||
allocateSubOrderNumberLoading: allocateSubOrderNumberLoading.value
|
||||
}))
|
||||
|
||||
@ -548,6 +630,7 @@ const { actionMap: toolbarActionMap } = createSimpleListToolbarController({
|
||||
})
|
||||
|
||||
toolbarActionMap.handleBatchPrint = handleBatchPrint
|
||||
toolbarActionMap.handleSubWaybillPrint = handleSubWaybillPrint
|
||||
|
||||
// 分配子单号
|
||||
const allocateSubOrderNumberDialogVisible = ref(false)
|
||||
|
||||
@ -40,7 +40,15 @@
|
||||
<!-- 主内容区容器(对齐 stock/stockManagement 的 main-container) -->
|
||||
<div class="main-container">
|
||||
<transition name="tab-fade" mode="out-in">
|
||||
<component :is="activeComponent" :key="activeTab" />
|
||||
<!--
|
||||
tab 缓存策略由「实验性功能」设置控制(tabCacheEnabled / tabCacheMax):
|
||||
启用时用 KeepAlive 缓存各 tab 组件(超出 max 按 LRU 淘汰最久未用),
|
||||
关闭时不缓存、每次切换重新挂载。
|
||||
-->
|
||||
<KeepAlive v-if="tabCacheEnabled" :max="tabCacheMax">
|
||||
<component :is="activeComponent" :key="activeTab" />
|
||||
</KeepAlive>
|
||||
<component v-else :is="activeComponent" :key="activeTab" />
|
||||
</transition>
|
||||
</div>
|
||||
</template>
|
||||
@ -59,6 +67,7 @@
|
||||
import { ref, watch, onMounted, computed, markRaw } from 'vue'
|
||||
import { useRoute } from 'vue-router'
|
||||
import { useSettingsStore } from '@/stores/modules/settings'
|
||||
import { useExperimentalStore } from '@/stores/modules/experimental'
|
||||
import { orderBadgeCount } from '@/api/order.index/orderindex'
|
||||
import ReviewOrder from './reviewOrder.vue'
|
||||
import PendingOrder from './pendingOrder.vue'
|
||||
@ -75,6 +84,11 @@ import { ORDER_PAGE_CONFIG } from './config/order-common-config'
|
||||
|
||||
const route = useRoute()
|
||||
const settingsStore = useSettingsStore()
|
||||
const experimentalStore = useExperimentalStore()
|
||||
/** tab 缓存开关(实验性设置,默认开) */
|
||||
const tabCacheEnabled = computed(() => experimentalStore.tabCacheEnabled)
|
||||
/** tab 缓存最大数量(实验性设置,默认 2,超出 LRU 淘汰最久未用) */
|
||||
const tabCacheMax = computed(() => experimentalStore.tabCacheMax)
|
||||
const singlePage = ORDER_PAGE_CONFIG.singlePage
|
||||
const badgeLoading = ref(false)
|
||||
const workbenchDialogVisible = ref(false)
|
||||
|
||||
@ -0,0 +1,296 @@
|
||||
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 {
|
||||
isOrderIndexApiSuccess,
|
||||
parseOrderDetailPayload,
|
||||
normalizeOrderExpressList
|
||||
} from '../utils/order-index-helpers'
|
||||
import { useUserStore } from '@/stores/modules/user'
|
||||
|
||||
type DeliverySubWaybillPrintRequestMeta = {
|
||||
waybill_codes: string[]
|
||||
order_ids: Array<number | string>
|
||||
/** 仓库 ID(弹窗打印/解锁需要) */
|
||||
warehouse_id?: number
|
||||
}
|
||||
|
||||
/** 运单号选择项(来源于 order.deliveryOrder.detail 的运单信息) */
|
||||
export type WaybillPrintOption = {
|
||||
waybill_code: string
|
||||
order_id: number | string
|
||||
logistics_name: string
|
||||
logistics_code: string
|
||||
sys_logistics_name: string
|
||||
business_key: string
|
||||
is_main: boolean
|
||||
}
|
||||
|
||||
type UseDeliveryOrderSubWaybillPrintOptions = {
|
||||
getSelectionRows: () => any[]
|
||||
onPrintSuccess?: () => void
|
||||
emptySelectionMessage?: string
|
||||
}
|
||||
|
||||
function isPrintApiSuccess(code: unknown) {
|
||||
return code === undefined || code === null || code === 1 || code === 200 || code === 0
|
||||
}
|
||||
|
||||
/** 从勾选的配送订单行收集订单 ID(row.id,正整数去重) */
|
||||
function collectOrderIds(rows: any[]): number[] {
|
||||
const ids: number[] = []
|
||||
const seen = new Set<number>()
|
||||
for (const row of rows || []) {
|
||||
const id = Number(row?.id)
|
||||
if (Number.isInteger(id) && id > 0 && !seen.has(id)) {
|
||||
seen.add(id)
|
||||
ids.push(id)
|
||||
}
|
||||
}
|
||||
return ids
|
||||
}
|
||||
|
||||
/** 按用户勾选的运单号过滤 waveGroups 中的 orders(order 需含 waybill_code/waybill_no/express_code;无法匹配时保留原样避免误伤) */
|
||||
function filterWaveGroupsByWaybills(
|
||||
waveGroups: unknown[] | undefined,
|
||||
selectedSet: Set<string>
|
||||
): unknown[] | undefined {
|
||||
if (!Array.isArray(waveGroups) || !selectedSet.size) return waveGroups
|
||||
|
||||
// 只有 waveGroups 内 order 带运单号字段时才过滤,避免结构不匹配导致打印丢失
|
||||
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)
|
||||
)
|
||||
: 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. 勾选配送订单行 → 取订单 ID(row.id)
|
||||
* 2. order.deliveryOrder.detail 获取该发货单号的运单号列表(配送模型,含子单/运单信息)
|
||||
* 3. 用户选择要打印的运单号
|
||||
* 4. order.print.getPrintDataByWaybillCodes 按选中的运单号获取打印数据
|
||||
* 5. print.send / print.getList 弹窗内发送打印 / 打印台列表
|
||||
*/
|
||||
export function useDeliveryOrderSubWaybillPrint(options: UseDeliveryOrderSubWaybillPrintOptions) {
|
||||
const userStore = useUserStore()
|
||||
const dialogVisible = ref(false)
|
||||
const loading = ref(false)
|
||||
const errorMessage = ref('')
|
||||
const payload = ref<WavePlatformPrintDataPayload | null>(null)
|
||||
const requestMeta = ref<DeliverySubWaybillPrintRequestMeta | null>(null)
|
||||
|
||||
// 运单号选择对话框
|
||||
const selectDialogVisible = ref(false)
|
||||
const selectLoading = ref(false)
|
||||
const waybillOptions = ref<WaybillPrintOption[]>([])
|
||||
const selectedWaybills = ref<WaybillPrintOption[]>([])
|
||||
const selectErrorMessage = ref('')
|
||||
/** 当前选中的仓库 ID(弹窗打印/解锁需要) */
|
||||
const currentWarehouseId = ref(0)
|
||||
|
||||
function resetState() {
|
||||
payload.value = null
|
||||
requestMeta.value = null
|
||||
errorMessage.value = ''
|
||||
waybillOptions.value = []
|
||||
selectedWaybills.value = []
|
||||
selectErrorMessage.value = ''
|
||||
}
|
||||
|
||||
/** 点击「子单号打印」:收集订单 ID → order.deliveryOrder.detail 获取运单号列表 → 打开选择对话框 */
|
||||
async function handlePrint() {
|
||||
const rows = options.getSelectionRows()
|
||||
if (!rows.length) {
|
||||
ElMessage.warning(options.emptySelectionMessage || '请先勾选需要打印子单号的订单')
|
||||
return
|
||||
}
|
||||
if (selectLoading.value || loading.value) return
|
||||
|
||||
const orderIds = collectOrderIds(rows)
|
||||
if (!orderIds.length) {
|
||||
ElMessage.warning('当前勾选记录缺少可用的订单 ID')
|
||||
return
|
||||
}
|
||||
|
||||
// 仓库 ID:优先取勾选行,其次当前登录用户上下文(与批量打印一致)
|
||||
const warehouseId = Number(
|
||||
rows[0]?.warehouse_id ?? userStore.user?.warehouse_id ?? userStore.user?.store_id
|
||||
)
|
||||
currentWarehouseId.value = Number.isFinite(warehouseId) && warehouseId > 0 ? warehouseId : 0
|
||||
|
||||
selectLoading.value = true
|
||||
selectErrorMessage.value = ''
|
||||
waybillOptions.value = []
|
||||
selectedWaybills.value = []
|
||||
|
||||
try {
|
||||
const list: WaybillPrintOption[] = []
|
||||
const seen = new Set<string>()
|
||||
for (const id of orderIds) {
|
||||
const res: any = await orderDeliveryOrder.detail({ id, ids: [id], tableType: 'dispatch' })
|
||||
if (!isOrderIndexApiSuccess(res)) continue
|
||||
const data = parseOrderDetailPayload(res)
|
||||
for (const item of normalizeOrderExpressList(data)) {
|
||||
const code = item?.waybill_code
|
||||
if (!code || seen.has(code)) continue
|
||||
seen.add(code)
|
||||
list.push({
|
||||
waybill_code: code,
|
||||
order_id: id,
|
||||
logistics_name: item?.logistics_name || item?.sys_logistics_name || '',
|
||||
logistics_code: item?.logistics_code || item?.sys_logistics_code || '',
|
||||
sys_logistics_name: item?.sys_logistics_name || '',
|
||||
business_key: String(item?.business_key ?? ''),
|
||||
is_main: item?.is_main ?? false
|
||||
})
|
||||
}
|
||||
}
|
||||
if (!list.length) {
|
||||
throw new Error('未从选中订单获取到运单号,请确认订单已分配快递号')
|
||||
}
|
||||
waybillOptions.value = list
|
||||
selectDialogVisible.value = true
|
||||
} catch (error: any) {
|
||||
selectErrorMessage.value = error?.message || '获取运单号列表失败'
|
||||
ElMessage.error(selectErrorMessage.value)
|
||||
} finally {
|
||||
selectLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
/** 选择对话框勾选变化 */
|
||||
function onSelectChange(rows: WaybillPrintOption[]) {
|
||||
selectedWaybills.value = rows || []
|
||||
}
|
||||
|
||||
/** 确认选中的运单号 → 按运单号获取打印数据并打开预览弹窗 */
|
||||
async function confirmPrintWaybills() {
|
||||
const codes = selectedWaybills.value.map((i) => i.waybill_code).filter(Boolean)
|
||||
if (!codes.length) {
|
||||
ElMessage.warning('请先选择要打印的运单号')
|
||||
return
|
||||
}
|
||||
if (loading.value) return
|
||||
|
||||
const orderIds = waybillOptions.value.map((i) => i.order_id)
|
||||
loading.value = true
|
||||
errorMessage.value = ''
|
||||
payload.value = null
|
||||
try {
|
||||
const res: any = await getPrintDataByWaybillCodes({ waybill_codes: codes })
|
||||
if (!isPrintApiSuccess(res?.code)) {
|
||||
throw new Error(res?.message || '获取打印数据失败')
|
||||
}
|
||||
const rawPayload = unwrapWavePlatformPrintPayload(res)
|
||||
// 仅保留用户勾选的运单号对应的面单,避免后端按订单返回主单+子单多张被同时打印
|
||||
rawPayload.waveGroups = filterWaveGroupsByWaybills(
|
||||
rawPayload.waveGroups,
|
||||
new Set(codes)
|
||||
)
|
||||
payload.value = rawPayload
|
||||
requestMeta.value = {
|
||||
waybill_codes: codes,
|
||||
order_ids: orderIds,
|
||||
warehouse_id: currentWarehouseId.value || undefined
|
||||
}
|
||||
selectDialogVisible.value = false
|
||||
selectedWaybills.value = []
|
||||
dialogVisible.value = true
|
||||
ElMessage.success(res?.message || `已获取 ${codes.length} 个运单的打印数据`)
|
||||
} catch (error: any) {
|
||||
payload.value = null
|
||||
errorMessage.value = error?.message || '获取打印数据失败'
|
||||
dialogVisible.value = true
|
||||
ElMessage.error(errorMessage.value)
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
/** 关闭选择对话框 */
|
||||
function closeSelectDialog() {
|
||||
selectDialogVisible.value = false
|
||||
selectedWaybills.value = []
|
||||
}
|
||||
|
||||
async function handleRefresh() {
|
||||
const meta = requestMeta.value
|
||||
if (!meta || !meta.waybill_codes.length) return
|
||||
try {
|
||||
const res: any = await getPrintDataByWaybillCodes({ waybill_codes: meta.waybill_codes })
|
||||
if (!isPrintApiSuccess(res?.code)) {
|
||||
throw new Error(res?.message || '刷新打印数据失败')
|
||||
}
|
||||
payload.value = unwrapWavePlatformPrintPayload(res)
|
||||
errorMessage.value = ''
|
||||
} catch (error: any) {
|
||||
payload.value = null
|
||||
errorMessage.value = error?.message || '刷新打印数据失败'
|
||||
ElMessage.error(errorMessage.value)
|
||||
}
|
||||
}
|
||||
|
||||
function onPrintSuccess() {
|
||||
options.onPrintSuccess?.()
|
||||
}
|
||||
|
||||
return {
|
||||
dialogVisible,
|
||||
loading,
|
||||
errorMessage,
|
||||
payload,
|
||||
requestMeta,
|
||||
resetState,
|
||||
handlePrint,
|
||||
handleRefresh,
|
||||
onPrintSuccess,
|
||||
selectDialogVisible,
|
||||
selectLoading,
|
||||
waybillOptions,
|
||||
selectedWaybills,
|
||||
selectErrorMessage,
|
||||
onSelectChange,
|
||||
confirmPrintWaybills,
|
||||
closeSelectDialog
|
||||
}
|
||||
}
|
||||
@ -30,13 +30,19 @@
|
||||
<!-- 主内容区容器(对齐 order/orderManagement 的 main-container) -->
|
||||
<div class="main-container">
|
||||
<transition name="tab-fade" mode="out-in">
|
||||
<keep-alive>
|
||||
<keep-alive v-if="tabCacheEnabled" :max="tabCacheMax">
|
||||
<component
|
||||
:is="activeComponent"
|
||||
:key="activeTab"
|
||||
v-bind="activeTabProps"
|
||||
/>
|
||||
</keep-alive>
|
||||
<component
|
||||
v-else
|
||||
:is="activeComponent"
|
||||
:key="activeTab"
|
||||
v-bind="activeTabProps"
|
||||
/>
|
||||
</transition>
|
||||
</div>
|
||||
</template>
|
||||
@ -58,6 +64,7 @@
|
||||
import { ref, watch, computed, markRaw } from 'vue'
|
||||
import { useRoute } from 'vue-router'
|
||||
import { useSettingsStore } from '@/stores/modules/settings'
|
||||
import { useExperimentalStore } from '@/stores/modules/experimental'
|
||||
import GroupWaveBatchListPanel from './GroupWaveBatchListPanel.vue'
|
||||
import SandanWaveBatchListPanel from './SandanWaveBatchListPanel.vue'
|
||||
import FallbackOrderListPanel from './FallbackOrderListPanel.vue'
|
||||
@ -68,6 +75,11 @@ import { WAVE_PAGE_CONFIG } from './config/wave-config'
|
||||
|
||||
const route = useRoute()
|
||||
const settingsStore = useSettingsStore()
|
||||
const experimentalStore = useExperimentalStore()
|
||||
/** tab 缓存开关(实验性设置,默认开) */
|
||||
const tabCacheEnabled = computed(() => experimentalStore.tabCacheEnabled)
|
||||
/** tab 缓存最大数量(实验性设置,默认 2,超出 LRU 淘汰最久未用) */
|
||||
const tabCacheMax = computed(() => experimentalStore.tabCacheMax)
|
||||
|
||||
const shortcutExpanded = computed(() => settingsStore.shortcutExpanded)
|
||||
const singlePage = WAVE_PAGE_CONFIG.singlePage
|
||||
|
||||
@ -142,8 +142,9 @@
|
||||
|
||||
<div class="detail-container">
|
||||
<!-- KeepAlive 直子须为组件 vnode(不能是包装 div),:key=activeTab 使各详情 tab 独立缓存,
|
||||
切换时保留组件状态、不重建/不重复请求,避免详情 tab 切换卡顿 -->
|
||||
<KeepAlive>
|
||||
切换时保留组件状态、不重建/不重复请求,避免详情 tab 切换卡顿。
|
||||
缓存策略由「实验性功能」设置控制(tabCacheEnabled / tabCacheMax)。 -->
|
||||
<KeepAlive v-if="tabCacheEnabled" :max="tabCacheMax">
|
||||
<component
|
||||
:is="activeComponent"
|
||||
:key="activeTab"
|
||||
@ -153,6 +154,15 @@
|
||||
@refresh="handleRefresh"
|
||||
/>
|
||||
</KeepAlive>
|
||||
<component
|
||||
v-else
|
||||
:is="activeComponent"
|
||||
:key="activeTab"
|
||||
:id="currentStockId"
|
||||
type="stock"
|
||||
class="detail-page order-detail-wrapper"
|
||||
@refresh="handleRefresh"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@ -255,6 +265,7 @@ import type { StockWarehouseListSort } from '@/api/stock/stock'
|
||||
import * as indexApi from '@/api/index/index'
|
||||
// Store
|
||||
import { useUserStore } from '@/stores/modules/user'
|
||||
import { useExperimentalStore } from '@/stores/modules/experimental'
|
||||
import { useVerticalSplitPane } from '@/composables/useVerticalSplitPane'
|
||||
|
||||
// Utils
|
||||
@ -264,6 +275,11 @@ import { safeInvoke } from '@/utils/safe-invoke'
|
||||
// import { labelInner } from 'echarts/types/src/label/labelStyle.js'
|
||||
|
||||
const userStore = useUserStore()
|
||||
const experimentalStore = useExperimentalStore()
|
||||
/** 详情 tab 缓存开关(实验性设置,默认开) */
|
||||
const tabCacheEnabled = computed(() => experimentalStore.tabCacheEnabled)
|
||||
/** 详情 tab 缓存最大数量(实验性设置,默认 2,超出 LRU 淘汰最久未用) */
|
||||
const tabCacheMax = computed(() => experimentalStore.tabCacheMax)
|
||||
const hasPermission = (perm: string) => {
|
||||
return userStore.checkPermission(perm)
|
||||
}
|
||||
|
||||
@ -22,9 +22,10 @@
|
||||
<!-- ===== 主内容区容器(对齐 setting/encoding / waveOrder2 的 main-container) ===== -->
|
||||
<div class="main-container">
|
||||
<transition name="tab-fade" mode="out-in">
|
||||
<keep-alive>
|
||||
<keep-alive v-if="tabCacheEnabled" :max="tabCacheMax">
|
||||
<component :is="tabs.find(t => t.name === activeTab)?.component" :key="activeTab" />
|
||||
</keep-alive>
|
||||
<component v-else :is="tabs.find(t => t.name === activeTab)?.component" :key="activeTab" />
|
||||
</transition>
|
||||
</div>
|
||||
</div>
|
||||
@ -34,12 +35,18 @@
|
||||
import { computed, markRaw, ref, watch } from 'vue'
|
||||
import { useRoute } from 'vue-router'
|
||||
import { useSettingsStore } from '@/stores/modules/settings'
|
||||
import { useExperimentalStore } from '@/stores/modules/experimental'
|
||||
import { safeInvoke } from '@/utils/safe-invoke'
|
||||
import StockDetail from '../stock/index.vue'
|
||||
import ComboStock from '../combo_stock/index.vue'
|
||||
|
||||
const route = useRoute()
|
||||
const settingsStore = useSettingsStore()
|
||||
const experimentalStore = useExperimentalStore()
|
||||
/** tab 缓存开关(实验性设置,默认开) */
|
||||
const tabCacheEnabled = computed(() => experimentalStore.tabCacheEnabled)
|
||||
/** tab 缓存最大数量(实验性设置,默认 2,超出 LRU 淘汰最久未用) */
|
||||
const tabCacheMax = computed(() => experimentalStore.tabCacheMax)
|
||||
|
||||
const shortcutExpanded = computed(() => settingsStore.shortcutExpanded)
|
||||
const containerHeight = computed(() =>
|
||||
|
||||
@ -331,6 +331,24 @@ export const FIELD_DICT: Record<string, FieldDefinition> = {
|
||||
slot: null,
|
||||
detailLabel: '关联报表'
|
||||
},
|
||||
/** 报表定义(report.meta 查询用,下拉选择报表定义启用项;value=报表定义ID) */
|
||||
report_id: {
|
||||
key: 'report_id',
|
||||
label: '报表',
|
||||
scanBox: { type: 'select', group: SCANBOX_GROUPS.basic, options: reportDefinitionOptions as any },
|
||||
table: { minWidth: 120, showOverflowTooltip: true },
|
||||
slot: null,
|
||||
detailLabel: '报表'
|
||||
},
|
||||
/** 导出文件名模板(支持 {date} 占位) */
|
||||
file_name: {
|
||||
key: 'file_name',
|
||||
label: '导出文件名',
|
||||
scanBox: null,
|
||||
table: { minWidth: 180, showOverflowTooltip: true },
|
||||
slot: null,
|
||||
detailLabel: '导出文件名'
|
||||
},
|
||||
/** 每日投递时间点(HH:mm 数组) */
|
||||
schedule_times: {
|
||||
key: 'schedule_times',
|
||||
@ -1048,12 +1066,12 @@ export const tabPages: TabPageRawConfig[] = [
|
||||
name: 'export',
|
||||
label: '导出任务',
|
||||
scanBoxCacheKey: 'generalreport-export',
|
||||
scanBoxFieldKeys: ['report_code'],
|
||||
tableColumnKeys: ['report_code', 'name', 'scope', 'query', 'day_count', 'cutover_hour', 'operation'],
|
||||
scanBoxFieldKeys: ['report_id'],
|
||||
tableColumnKeys: ['report_id', 'name', 'type', 'file_name', 'day_count', 'cutover_hour', 'operation'],
|
||||
upperTableDefaults: {
|
||||
title: '报表定义(report.meta)',
|
||||
showSelection: false,
|
||||
emptyText: '请输入报表编码查询报表元数据'
|
||||
emptyText: '请选择报表查询报表元数据'
|
||||
},
|
||||
detailTabs: [
|
||||
{ name: 'detail', label: '报表详情', componentKey: 'DetailPanel' }
|
||||
@ -1062,7 +1080,7 @@ export const tabPages: TabPageRawConfig[] = [
|
||||
{
|
||||
title: '报表信息',
|
||||
columnCount: 3,
|
||||
fieldKeys: ['report_code', 'name', 'scope', 'query', 'day_count', 'cutover_hour']
|
||||
fieldKeys: ['report_id', 'name', 'type', 'file_name', 'day_count', 'cutover_hour']
|
||||
},
|
||||
{
|
||||
title: '可导出字段',
|
||||
@ -1077,7 +1095,7 @@ export const tabPages: TabPageRawConfig[] = [
|
||||
return { list: res?.data?.list ?? [], total: res?.data?.total ?? 0 }
|
||||
},
|
||||
buildListParams({ conditions }) {
|
||||
return { report_code: conditions?.report_code }
|
||||
return { report_id: conditions?.report_id }
|
||||
}
|
||||
},
|
||||
operationButtons: [
|
||||
@ -1103,23 +1121,23 @@ export const templateTabs = tabPages.map((t) => ({ name: t.name, label: t.label,
|
||||
// ExportReportDialog 内使用 useAsyncExportTask 处理(不写任何本地存储)。
|
||||
// ============================================================
|
||||
/**
|
||||
* 按报表编码调用 report.meta 查询报表元数据,包装为列表行(Tab3 的 api.list)。
|
||||
* 未传报表编码时返回空列表。
|
||||
* 按报表定义ID调用 report.meta 查询报表元数据,包装为列表行(Tab3 的 api.list)。
|
||||
* 未传报表定义ID时返回空列表。
|
||||
*/
|
||||
export async function queryReportMetaList(params?: { report_code?: string }): Promise<any> {
|
||||
const code = params?.report_code
|
||||
if (!code) {
|
||||
export async function queryReportMetaList(params?: { report_id?: number }): Promise<any> {
|
||||
const id = params?.report_id
|
||||
if (!id) {
|
||||
return { code: 1, data: { list: [], total: 0 } }
|
||||
}
|
||||
try {
|
||||
const res: any = await meta({ report_code: code })
|
||||
const res: any = await meta({ report_id: id })
|
||||
const payload = res?.data ?? res
|
||||
if (payload && payload.report_code) {
|
||||
if (payload && payload.report_id) {
|
||||
const row = {
|
||||
report_code: payload.report_code,
|
||||
report_id: payload.report_id,
|
||||
name: payload.name,
|
||||
scope: payload.scope,
|
||||
query: payload.query,
|
||||
type: payload.type,
|
||||
file_name: payload.file_name,
|
||||
day_count: payload.window?.dayCount,
|
||||
cutover_hour: payload.window?.cutoverHour,
|
||||
fields: payload.fields ?? []
|
||||
|
||||
@ -235,7 +235,7 @@
|
||||
/>
|
||||
<ExportReportDialog
|
||||
v-model:visible="exportReportVisible"
|
||||
:report-code="exportInitialReportCode"
|
||||
:report-id="exportInitialReportId"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
@ -263,6 +263,7 @@ import {
|
||||
resolveTabConfig,
|
||||
getTabToolbarButtons,
|
||||
loadStoreOptions,
|
||||
loadReportDefinitions,
|
||||
type TabPageConfig,
|
||||
type DetailTabConfig,
|
||||
type ToolbarButtonConfig,
|
||||
@ -451,8 +452,8 @@ async function handleOperationAction(key: string, row: Record<string, any>) {
|
||||
loadData()
|
||||
break
|
||||
case 'exportThisReport':
|
||||
// 将该报表编码带入导出弹窗
|
||||
exportInitialReportCode.value = row?.report_code ?? ''
|
||||
// 将该报表定义ID带入导出弹窗
|
||||
exportInitialReportId.value = Number(row?.report_id ?? row?.id) || 0
|
||||
exportReportVisible.value = true
|
||||
break
|
||||
default:
|
||||
@ -465,8 +466,8 @@ async function handleOperationAction(key: string, row: Record<string, any>) {
|
||||
// ============================================================
|
||||
const createPlanVisible = ref(false)
|
||||
const exportReportVisible = ref(false)
|
||||
/** 导出弹窗初始报表编码(Tab3 行「导出此报表」带入) */
|
||||
const exportInitialReportCode = ref('')
|
||||
/** 导出弹窗初始报表定义ID(Tab3 行「导出此报表」带入) */
|
||||
const exportInitialReportId = ref(0)
|
||||
|
||||
function handlePlanSaved() {
|
||||
ElMessage.success('投递计划已保存')
|
||||
@ -499,11 +500,11 @@ const loadData = async () => {
|
||||
// 使用真实接口
|
||||
const conditions = scanBoxRef.value?.getConditions?.() || {}
|
||||
|
||||
// 导出任务页:report.meta 需报表编码才能查询,未输入时不发请求并给出引导
|
||||
if (activeTabName.value === 'export' && !conditions?.report_code) {
|
||||
// 导出任务页:report.meta 需报表定义ID才能查询,未选择时不发请求并给出引导
|
||||
if (activeTabName.value === 'export' && !conditions?.report_id) {
|
||||
listData.value = []
|
||||
pagination.total = 0
|
||||
ElMessage.info('请输入报表编码后查询报表元数据')
|
||||
ElMessage.info('请选择报表后查询报表元数据')
|
||||
return
|
||||
}
|
||||
|
||||
@ -659,6 +660,7 @@ const upperPaneFullStyle = computed(() => ({
|
||||
// ============================================================
|
||||
onMounted(() => {
|
||||
void loadStoreOptions()
|
||||
void loadReportDefinitions()
|
||||
loadData()
|
||||
})
|
||||
</script>
|
||||
|
||||
@ -21,8 +21,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">
|
||||
@ -82,14 +94,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
|
||||
/** 初始报表编码(Tab3 行「导出此报表」带入) */
|
||||
reportCode?: string
|
||||
/** 初始报表定义ID(Tab3 行「导出此报表」带入) */
|
||||
reportId?: number
|
||||
}>()
|
||||
|
||||
const emit = defineEmits<{
|
||||
@ -99,13 +111,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 → 不写任何本地存储)
|
||||
@ -124,7 +136,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?.()
|
||||
@ -133,6 +145,7 @@ watch(() => props.visible, (v) => {
|
||||
|
||||
onMounted(() => {
|
||||
void loadStoreOptions()
|
||||
void loadReportDefinitions()
|
||||
})
|
||||
|
||||
function handleClosed() {
|
||||
@ -148,7 +161,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 } } : {})
|
||||
})
|
||||
|
||||
@ -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'
|
||||
|
||||
232
src/views/store/stores/component/ExportDialog.vue
Normal file
232
src/views/store/stores/component/ExportDialog.vue
Normal file
@ -0,0 +1,232 @@
|
||||
<!--
|
||||
StoreExportDialog — 货主列表(签约关系)导出 功能表单
|
||||
对接接口:
|
||||
- storeWarehouse.store.export(提交异步导出任务,全量导出,立即返回 task_id)
|
||||
- storeWarehouse.store.exportTaskProgress(按 task_id 轮询进度,完成后返回 download_url 并自动下载)
|
||||
说明:
|
||||
- 表单字段与 storeWarehouse.store.export 入参对齐(keyword/store_id/auth_status/use_status)
|
||||
- 提交前可调整筛选条件;page/page_size 由服务端忽略,导出为全量
|
||||
-->
|
||||
<template>
|
||||
<el-dialog
|
||||
:model-value="visible"
|
||||
title="导出签约货主列表"
|
||||
width="520px"
|
||||
align-center
|
||||
destroy-on-close
|
||||
:close-on-click-modal="false"
|
||||
@closed="handleClosed"
|
||||
>
|
||||
<div class="export-form-body">
|
||||
<el-form ref="formRef" :model="form" label-width="100px" size="small">
|
||||
<el-form-item label="关键词">
|
||||
<el-input v-model="form.keyword" placeholder="签约备注或主体名称关键字" clearable />
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="货主">
|
||||
<el-select
|
||||
v-model="form.store_id"
|
||||
filterable
|
||||
clearable
|
||||
placeholder="全部"
|
||||
style="width: 100%"
|
||||
>
|
||||
<el-option
|
||||
v-for="opt in storeOptions"
|
||||
:key="String(opt.value)"
|
||||
:label="opt.label"
|
||||
:value="opt.value"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="签约状态">
|
||||
<el-select v-model="form.auth_status" clearable placeholder="全部" style="width: 100%">
|
||||
<el-option label="待审核" :value="1" />
|
||||
<el-option label="已通过" :value="2" />
|
||||
<el-option label="已拒绝" :value="3" />
|
||||
<el-option label="已解除" :value="4" />
|
||||
<el-option label="已过期" :value="5" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="使用状态">
|
||||
<el-select v-model="form.use_status" clearable placeholder="全部" style="width: 100%">
|
||||
<el-option label="启用" :value="1" />
|
||||
<el-option label="禁用" :value="0" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
|
||||
<div class="export-form-body__tip">
|
||||
将按以上筛选条件提交异步导出任务(全量导出签约列表),任务完成后自动下载文件。
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<template #footer>
|
||||
<el-button size="small" @click="handleClosed">取消</el-button>
|
||||
<el-button size="small" type="primary" :loading="exportLoading" @click="handleSubmit">
|
||||
提交导出
|
||||
</el-button>
|
||||
</template>
|
||||
</el-dialog>
|
||||
|
||||
<!-- 导出任务进度(提交后接管,完成后自动下载) -->
|
||||
<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"
|
||||
/>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { onMounted, reactive, ref, watch } from 'vue'
|
||||
import { useAsyncExportTask } from '@/composables/useAsyncExportTask'
|
||||
import AsyncExportProgressDialog from '@/components/AsyncExportProgressDialog.vue'
|
||||
import {
|
||||
storeWarehouseExport,
|
||||
storeWarehouseExportTaskProgress,
|
||||
} from '@/api/storeWarehouse.store/storeWarehouse'
|
||||
import { loadStores } from '@/api/index/index'
|
||||
|
||||
defineOptions({ name: 'StoreExportDialog' })
|
||||
|
||||
const props = defineProps<{
|
||||
visible: boolean
|
||||
/** 当前列表筛选条件(与 storeWarehouse.store.list 入参一致,用于预填表单) */
|
||||
conditions?: Record<string, any>
|
||||
}>()
|
||||
|
||||
const emit = defineEmits<{
|
||||
(e: 'update:visible', v: boolean): void
|
||||
(e: 'success'): void
|
||||
(e: 'loading-change', v: boolean): void
|
||||
}>()
|
||||
|
||||
const formRef = ref<any>(null)
|
||||
|
||||
const form = reactive<{
|
||||
keyword: string
|
||||
store_id?: number | string
|
||||
auth_status?: number | string
|
||||
use_status?: number | string
|
||||
}>({
|
||||
keyword: '',
|
||||
store_id: undefined,
|
||||
auth_status: undefined,
|
||||
use_status: undefined,
|
||||
})
|
||||
|
||||
const storeOptions = ref<Array<{ label: string; value: number | string }>>([])
|
||||
|
||||
// 提交导出 + 轮询进度(storageKey 用于恢复被中断的导出任务)
|
||||
const {
|
||||
exportLoading,
|
||||
exportDialogVisible,
|
||||
exportTaskProgress,
|
||||
exportProgressPercent,
|
||||
exportProgressStatus,
|
||||
exportStatusLabel,
|
||||
submitExportTask,
|
||||
resumeExportTaskFromStorage,
|
||||
} = useAsyncExportTask({
|
||||
storageKey: 'store:stores:listExportTaskId',
|
||||
submitExport: (payload) => storeWarehouseExport(payload as any),
|
||||
queryProgress: (params) => storeWarehouseExportTaskProgress(params),
|
||||
})
|
||||
|
||||
function prefillFromConditions() {
|
||||
const c = props.conditions ?? {}
|
||||
const keyword = c.keyword
|
||||
form.keyword = typeof keyword === 'string' ? keyword : ''
|
||||
const storeId = c.store_id
|
||||
form.store_id = storeId != null && !Number.isNaN(Number(storeId)) ? Number(storeId) : undefined
|
||||
const auth = c.auth_status
|
||||
form.auth_status = auth != null && !Number.isNaN(Number(auth)) ? Number(auth) : undefined
|
||||
const useStatus = c.use_status
|
||||
form.use_status =
|
||||
useStatus != null && !Number.isNaN(Number(useStatus)) ? Number(useStatus) : undefined
|
||||
}
|
||||
|
||||
watch(
|
||||
() => props.visible,
|
||||
(v) => {
|
||||
if (v) {
|
||||
prefillFromConditions()
|
||||
formRef.value?.clearValidate?.()
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
// 导出加载状态同步给父级(工具栏「导出」按钮 loading)
|
||||
watch(exportLoading, (v) => emit('loading-change', v))
|
||||
|
||||
onMounted(async () => {
|
||||
// 加载货主下拉选项
|
||||
try {
|
||||
const res: any = await loadStores()
|
||||
const stores = res?.stores || res?.data?.stores || res?.data || []
|
||||
storeOptions.value = stores
|
||||
.map((item: any) => {
|
||||
const id = item?.store_id ?? item?.id ?? item?.value
|
||||
const name = item?.store_name ?? item?.name ?? item?.label ?? String(id)
|
||||
return { label: name, value: id }
|
||||
})
|
||||
.filter((opt: any) => opt.value != null && opt.value !== '')
|
||||
} catch {
|
||||
storeOptions.value = []
|
||||
}
|
||||
// 恢复被中断的导出任务(存在未完成任务时自动弹进度弹窗继续轮询)
|
||||
resumeExportTaskFromStorage()
|
||||
})
|
||||
|
||||
function handleClosed() {
|
||||
emit('update:visible', false)
|
||||
}
|
||||
|
||||
/** 依据表单构建 storeWarehouse.store.export 入参(与 module.json 字段一致) */
|
||||
function buildExportPayload(): Record<string, any> {
|
||||
const payload: Record<string, any> = {}
|
||||
const keyword = form.keyword.trim()
|
||||
if (keyword) payload.keyword = keyword
|
||||
if (form.store_id != null && Number(form.store_id) > 0) payload.store_id = Number(form.store_id)
|
||||
if (form.auth_status != null) payload.auth_status = Number(form.auth_status)
|
||||
if (form.use_status != null) payload.use_status = Number(form.use_status)
|
||||
return payload
|
||||
}
|
||||
|
||||
async function handleSubmit() {
|
||||
try {
|
||||
await formRef.value?.validate()
|
||||
} catch {
|
||||
return
|
||||
}
|
||||
// 提交导出任务;进度弹窗接管展示,完成后自动下载(useAsyncExportTask 内部处理)
|
||||
await submitExportTask(buildExportPayload())
|
||||
emit('success')
|
||||
emit('update:visible', false)
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.export-form-body {
|
||||
padding: 4px 4px 0;
|
||||
|
||||
&__tip {
|
||||
margin-top: 4px;
|
||||
padding: 8px 12px;
|
||||
border-radius: 4px;
|
||||
background: #f5f7fa;
|
||||
color: #909399;
|
||||
font-size: 12px;
|
||||
line-height: 1.6;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@ -992,6 +992,14 @@
|
||||
@update:visible="exportDialogVisible = $event"
|
||||
/>
|
||||
|
||||
<!-- 签约货主列表导出(功能表单:storeWarehouse.store.export + exportTaskProgress) -->
|
||||
<StoreExportDialog
|
||||
v-model:visible="listExportDialogVisible"
|
||||
:conditions="currentCondition"
|
||||
@success="loadList"
|
||||
@loading-change="listExportLoading = $event"
|
||||
/>
|
||||
|
||||
<!-- 生成加群授权码弹窗 -->
|
||||
<el-dialog
|
||||
v-model="bindCodeDialog.visible"
|
||||
@ -1052,6 +1060,7 @@ 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()
|
||||
@ -1191,7 +1200,8 @@ function toggleDetailVisible() {
|
||||
const toolbarButtons = storeToolbarButtons
|
||||
|
||||
const buttonLoadingMap = computed(() => ({
|
||||
loading: loading.value
|
||||
loading: loading.value,
|
||||
listExportLoading: listExportLoading.value
|
||||
}))
|
||||
|
||||
const buttonDisabledMap = computed(() => ({}))
|
||||
@ -1229,6 +1239,9 @@ const toolbarActionMap: Record<string, () => void> = {
|
||||
void loadList()
|
||||
},
|
||||
openOpenAccountDialog: () => openOpenAccountDialog(),
|
||||
openExportDialog: () => {
|
||||
listExportDialogVisible.value = true
|
||||
},
|
||||
toggleBalance: () => toggleBalance(),
|
||||
toggleDetailVisible: () => toggleDetailVisible()
|
||||
}
|
||||
@ -1246,6 +1259,8 @@ const availableFields = reactive(defaultAvailableFields)
|
||||
const presetTree = ref<any[]>(defaultPresetTree)
|
||||
|
||||
const currentCondition = ref<any>({ use_status: 1 })
|
||||
const listExportDialogVisible = ref(false)
|
||||
const listExportLoading = ref(false)
|
||||
|
||||
async function loadList() {
|
||||
loading.value = true
|
||||
|
||||
@ -245,6 +245,14 @@ export const presetTree: any[] = []
|
||||
/** 货主列表主工具栏按钮(action 与 stores/index.vue 内 toolbarActionMap 键一致) */
|
||||
export const storeToolbarButtons: ToolbarButtonConfig[] = [
|
||||
{ key: 'refresh', label: '刷新', category: 'refresh', size: 'small', loadingKey: 'loading', action: 'loadList' },
|
||||
{
|
||||
key: 'export',
|
||||
label: '导出',
|
||||
category: 'action',
|
||||
size: 'small',
|
||||
loadingKey: 'listExportLoading',
|
||||
action: 'openExportDialog'
|
||||
},
|
||||
{
|
||||
key: 'toggleBalance',
|
||||
label: '显示余额',
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user