feat(settings): 新增统一设置中心,集中管理字段、标签、缓存等本地配置
- 新增 SettingsDialog 及 registry 分区注册表,按「表格 / 显示与交互 / 性能 / 导航 / 数据与维护」分组,分区组件全部懒加载,支持关键字搜索与作用域提示 - 新增 10 个设置分区:列表字段(宿主插槽)、所有表格字段、界面显示、 设备与打印、表格与性能、页面与标签缓存、标签排序、快捷入口、 导出字段、导入/导出与维护(tbyc-config.json) - Navbar 头像下拉新增「设置」入口;UpperTable 工具栏的「更多设置 / 标签排序」 收敛为「字段设置」,通过 #field-section 插槽注入当前表格列配置 - TabOrderSettingsDialog 重命名为可复用面板 TabOrderPanel,接入设置中心 - 抽离 table-column-config 工具与 tableColumnConfig store,支持跨页面管理 所有表格列配置,修改后按 tableId 版本号通知已打开表格重建列配置 - tbyc-config 新增 experimental、printer、订单导出字段等分区, 导入/导出覆盖更多本地配置,并兼容旧版字段配置与 tabOrders 文件 - 移除 MoreSettingsDialog;OrderExportColumnsDialog 与设置中心共用导出字段 存储,区分「未配置」与「空选择」;订单各页清理重复的下拉选项映射逻辑 - 新增《设置中心-设计与实施》文档,更新标签排序与 tbyc-config 说明
This commit is contained in:
parent
f41b37aa54
commit
03f7f73d70
@ -16,7 +16,8 @@ src/composables/useTabOrder.ts 唯一读取/排序/默认页签/保存
|
||||
src/components/TabArea/index.vue 唯一标签渲染组件(含排序入口 + 插槽)
|
||||
src/components/SortSettingDialog.vue 单页排序弹窗(TabArea 内置入口调用)
|
||||
src/components/TabOrderDragList.vue 拖拽列表(单页弹窗与全局面板共用)
|
||||
src/components/TabOrderSettingsDialog.vue 全项目标签排序面板(字段设置入口)
|
||||
src/components/TabOrderPanel.vue 全项目标签排序面板(设置中心 →导航→标签排序)
|
||||
src/components/settings/SettingsDialog.vue 设置中心外壳(左导航 + 右内容)
|
||||
src/components/UpperTable/index.vue 字段设置工具栏入口 + 全局配置导出/导入 + 故障修复
|
||||
```
|
||||
|
||||
@ -28,7 +29,7 @@ flowchart LR
|
||||
H --> P[页面 activeTab / 单页模式默认标签]
|
||||
T --> D1[SortSettingDialog]
|
||||
D1 --> H
|
||||
F[TabOrderSettingsDialog] --> S
|
||||
F[TabOrderPanel] --> S
|
||||
U[UpperTable 字段设置] --> F
|
||||
S --> G[全局配置 导出/导入]
|
||||
```
|
||||
@ -133,9 +134,9 @@ const { orderedTabs, defaultTabName, resolveInitialTab, saveOrder, setDefault, r
|
||||
|
||||
---
|
||||
|
||||
## 6. 全局面板(字段设置 → 标签排序)
|
||||
## 6. 标签排序面板
|
||||
|
||||
- 入口:`UpperTable` 字段设置工具栏「标签排序」(所有页面显示)
|
||||
- 入口:`设置`(Navbar 头像下拉)或列表页工具栏「字段设置」→ 设置中心 → 左侧「导航 → 标签排序」
|
||||
- 左侧:注册表中**标签数 ≥ 2** 的页面(打开时并行懒加载标签数量,加载完成前显示「加载中…」,避免单标签页面闪入闪出);按分组 + 搜索 + 已自定义标记,当前页面用蓝点标记
|
||||
- 右侧:拖拽排序 + 圆点设为默认;标题栏常驻显示「默认:XXX」(**用户未设置时也展示页面兜底默认**,便于确认当前生效值);默认行带「默认」标签
|
||||
- 保存:一次写入 `tabOrder` 文档;`useTabOrder` 为响应式读取,**保存后页面立即生效**
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
# 统一配置文件:tbyc-config.json
|
||||
|
||||
- 日期:2026-11-07
|
||||
- 入口:`字段设置 → 导出配置 / 导入配置`
|
||||
- 入口:`设置 → 导入 / 导出与维护`(Navbar 头像下拉「设置」,或列表页工具栏「字段设置」打开设置中心)
|
||||
- 目标:配置文件不再局限于「字段设置」,而是一个可扩展的分区容器,后续功能只需注册分区即可接入
|
||||
|
||||
---
|
||||
@ -50,6 +50,8 @@
|
||||
| `fieldColumns` | 字段设置 | UpperTable 列配置 | `upper_table_columns_{user}_{role}_{tableId}` |
|
||||
| `tabOrder` | 标签排序 / 默认页签 | 标签排序面板 | `user_prefs_{userId}` → scope `tabOrder` |
|
||||
| `display` | 界面显示 | settings store | `settings_{user}_{role}` |
|
||||
| `experimental` | 表格与缓存 | experimental store | `experimental_{user}_{role}` |
|
||||
| `printer` | 设备与打印 | userPreference | `user_prefs_{user}_{warehouse}` → scope `printer.autoReconnect` |
|
||||
| `shortcuts` | 快捷键 | shortcuts store | `shortcuts_{user}_{role}` |
|
||||
|
||||
---
|
||||
|
||||
148
docs/设置中心-设计与实施.md
Normal file
148
docs/设置中心-设计与实施.md
Normal file
@ -0,0 +1,148 @@
|
||||
# 设置中心:设计与实施
|
||||
|
||||
- 日期:2026-11-08
|
||||
- 状态:**已实现(P1–P5)**
|
||||
- 定位:项目内**所有"本机可修改配置"的唯一入口**,取代原「字段设置」弹窗
|
||||
|
||||
---
|
||||
|
||||
## 1. 入口
|
||||
|
||||
| 入口 | 位置 | 行为 |
|
||||
|---|---|---|
|
||||
| 全局 | Navbar 头像下拉 →「设置」 | 打开设置中心;无表格上下文,隐藏「当前页面 → 列表字段」 |
|
||||
| 页面 | 列表页工具栏「字段设置」 | 打开同一弹窗,定位到「列表字段」,行为与改造前一致 |
|
||||
|
||||
---
|
||||
|
||||
## 2. 分区结构
|
||||
|
||||
```
|
||||
设置(左导航 + 右内容,1280px)
|
||||
├─ 表格
|
||||
│ ├─ 列表字段 当前表格列显隐 / 顺序 / 固定(由 UpperTable 通过插槽注入)
|
||||
│ └─ 所有表格字段 跨页面管理全部已登记表格(搜索 / 显隐 / 顺序 / 固定 / 恢复默认)
|
||||
├─ 显示与交互
|
||||
│ ├─ 界面显示 布局模式 / 固定头部 / 侧栏 Logo / Scan-box / 工具栏 / 快捷键区域
|
||||
│ └─ 设备与打印 打印组件连接状态、失败自动重连、逐组件开关(账号 + 仓库)
|
||||
├─ 性能
|
||||
│ ├─ 表格与性能 表格工作模式(低占用 / 高性能)
|
||||
│ └─ 页面与标签缓存 页面缓存、tab 缓存(开关 + 上限)
|
||||
├─ 导航
|
||||
│ ├─ 标签排序 全项目页面标签顺序 + 默认页签
|
||||
│ └─ 快捷入口 侧边栏收藏的快捷入口集中管理
|
||||
└─ 数据与维护
|
||||
├─ 导出字段 订单管理各页「导出全部(不含明细)」的导出字段勾选(账号 + 角色)
|
||||
└─ 导入 / 导出与维护 导出/导入 tbyc-config.json、恢复全部默认、故障修复、诊断信息
|
||||
```
|
||||
|
||||
作用域提示直接显示在导航项右侧:`当前表格 / 账号 + 角色 / 账号 / 本机`,避免用户误以为会同步到服务端。
|
||||
|
||||
---
|
||||
|
||||
## 3. 代码结构
|
||||
|
||||
```
|
||||
components/settings/
|
||||
SettingsDialog.vue 外壳(左导航 / 搜索 / 右侧动态分区 / 底部提示)
|
||||
registry.ts 分区元数据(key/title/group/scope/slot/component 懒加载)
|
||||
sections/
|
||||
DisplaySection.vue 界面显示(含布局 / 固定头部 / 侧栏 Logo)
|
||||
DeviceSection.vue 设备与打印(复用 PrinterComponentConnectionPanel)
|
||||
PerformanceSection.vue
|
||||
CacheSection.vue
|
||||
TabOrderSection.vue → 复用 components/TabOrderPanel.vue
|
||||
ShortcutsSection.vue 快捷入口集中管理
|
||||
AllTablesSection.vue 所有表格字段(跨页面列配置管理)
|
||||
ExportColumnsSection.vue 导出字段(订单管理各页 · 导出全部不含明细)
|
||||
DataSection.vue 导入导出 / 恢复默认 / 故障修复 / 诊断
|
||||
shared.scss 分区通用样式
|
||||
```
|
||||
|
||||
### 所有表格字段(跨页面)
|
||||
|
||||
| 项 | 说明 |
|
||||
|---|---|
|
||||
| 数据来源 | `upper_table_columns_{user}_{role}_{tableId}`(页面打开一次后由 UpperTable 自动登记) |
|
||||
| 列表能力 | 按名称/tableId 搜索、仅看已自定义、显示已自定义标记 |
|
||||
| 编辑能力 | 显隐、上移/下移、左/右固定与取消固定、恢复默认 |
|
||||
| 即时生效 | 修改写入 localStorage + `tableColumnConfig.touch(tableId)`;已打开的表格监听版本号并重建列 |
|
||||
| 恢复默认 | 依赖配置中的 `defaultColumns` 快照(首次生成配置时记录);旧配置在下一次打开页面时补齐 |
|
||||
| 公共代码 | `utils/table-column-config.ts`(类型 / 读写 / 分区与归一化 / 自定义判定) |
|
||||
|
||||
- 表级「列表字段」不放进 registry 组件,由 `UpperTable` 通过 `#field-section` 插槽注入(列配置逻辑与表格渲染强耦合,不搬动逻辑)
|
||||
- 分区组件全部 `defineAsyncComponent`,打开设置中心不会一次性加载所有分区
|
||||
|
||||
### 导出字段(订单管理 · 导出全部不含明细)
|
||||
|
||||
| 项 | 说明 |
|
||||
|---|---|
|
||||
| 数据来源 | `order_export_columns_{user}_{role}_{scopeKey}_{mode}`(与 `OrderExportColumnsDialog` 同一 key) |
|
||||
| 页面范围 | `ORDER_TAB_LIST` ∩ `ORDER_INDEX_EXPORT_SCOPES`:待审核/待处理/待处理异常/待出库/委托外仓/配送/配送异常/归档 |
|
||||
| 本期模式 | 仅 `waybill`(导出全部 · 不含明细);`item`(含明细)存储已在配置分区中兼容 |
|
||||
| 字段来源 | `getOrderExportColumnGroupsByMode('waybill')`,与导出弹窗同一套中文表头分组 |
|
||||
| 默认值 | 未配置(无 localStorage key)= 全选 |
|
||||
| 即时生效 | 勾选即写 localStorage,下次打开导出弹窗读取;弹窗打开时不再回退为全选 |
|
||||
| 恢复默认 | 删除该页 key(回到未配置 = 全选) |
|
||||
|
||||
- 语义修正:`OrderExportColumnsDialog.loadSavedColumns()` 改为 `string[] \| null`,**空数组视为「显式清空」**而不是「未配置」,避免清空后在下次打开时被静默重置为全选
|
||||
|
||||
---
|
||||
|
||||
## 4. 交互约定
|
||||
|
||||
| 项 | 约定 |
|
||||
|---|---|
|
||||
| 保存 | **即时生效**(各分区直写对应 store),无全局"保存/取消" |
|
||||
| 重置 | 分区内「恢复默认」;「数据与维护」内提供「恢复全部默认」(二次确认) |
|
||||
| 危险操作 | 故障修复保留双重确认,并列出被清除的配置种类 |
|
||||
| 弹窗嵌套 | 已消除:标签排序从"二级弹窗"改为"设置中心内嵌分区" |
|
||||
| 底部提示 | `修改即时保存 · 仅保存在当前浏览器` |
|
||||
|
||||
---
|
||||
|
||||
## 5. 事件与数据流
|
||||
|
||||
```
|
||||
UpperTable ──(openColumnConfig)──▶ SettingsDialog(initialSection='field')
|
||||
▲ │
|
||||
└──── @columns-changed ◀───────────────┘
|
||||
(DataSection 导入 / 恢复默认 / 故障修复 后需要重建列配置)
|
||||
|
||||
DataSection ──▶ TBYC_CONFIG_SECTIONS(fieldColumns / tabOrder / display / experimental / printer / shortcuts / orderExportColumns)
|
||||
```
|
||||
|
||||
- Navbar 入口没有 `#field-section`,`DataSection` 的 `columns-changed` 无人监听:配置仍已写入 localStorage,表格下次挂载时自然生效
|
||||
|
||||
---
|
||||
|
||||
## 6. 与统一配置文件的关系
|
||||
|
||||
- 设置中心的分区 = `tbyc-config.json` 的 sections(可编辑项与可导出项保持一致)
|
||||
- `printer`(设备与打印)目前**仅参与导出/导入**,UI 后续补齐
|
||||
- `orderExportColumns`(订单导出字段):数据形如 `{ [scopeKey]: { waybill: string[], item: string[] } }`;导入时按 `ORDER_INDEX_EXPORT_SCOPES` 白名单过滤 scopeKey、按模式字段白名单过滤字段
|
||||
- 新增设置项:`registry.ts` 加一条 + `sections/` 新建组件(如需导出,再在 `tbyc-config-sections.ts` 加分区)
|
||||
|
||||
---
|
||||
|
||||
## 7. 已删除
|
||||
|
||||
| 文件 | 替代 |
|
||||
|---|---|
|
||||
| `components/UpperTable/MoreSettingsDialog.vue` | 「界面显示」「表格与性能」「页面与标签缓存」分区 |
|
||||
| `components/TabOrderSettingsDialog.vue` | 「标签排序」分区(`TabOrderPanel`) |
|
||||
|
||||
---
|
||||
|
||||
## 8. 验证清单
|
||||
|
||||
1. 列表页「字段设置」→ 停在「列表字段」,列显隐/排序/固定/恢复默认均正常
|
||||
2. Navbar「设置」→ 无「列表字段」,默认停在「所有表格字段」
|
||||
3. 「所有表格字段」:搜索、仅看已自定义、修改后当前页面表格即时刷新、恢复默认生效
|
||||
4. 界面显示:布局模式/固定头部/侧栏 Logo/Scan-box/工具栏/快捷键区域 即时生效,刷新后保持
|
||||
5. 设备与打印:连接状态、主开关、逐组件开关、全部重连
|
||||
6. 快捷入口:列表与侧边栏星标一致,移除/清空生效
|
||||
4. 标签排序:只列多标签页面;默认标签展示与保存正常;保存后当前页即时生效
|
||||
5. 导出 → 重置 → 导入:字段、标签、显示、缓存、快捷键全部恢复
|
||||
6. 故障修复:二次确认后清除并给出恢复项摘要
|
||||
7. 诊断信息:账号/角色/仓库、配置版本、占用体积、存储 key 正确
|
||||
@ -1,24 +1,17 @@
|
||||
<!--
|
||||
TabOrderSettingsDialog — 全项目标签排序 / 默认页签管理(唯一入口)
|
||||
TabOrderPanel — 全项目标签排序 / 默认页签管理面板(不含弹窗外壳)
|
||||
|
||||
入口:UpperTable「字段设置」工具栏 → 标签排序
|
||||
- 左侧:注册表内所有支持标签的页面(按分组,标注是否已自定义)
|
||||
- 右侧:拖拽调整顺序 + 圆点选择默认打开的页签
|
||||
- 保存:一次性写入 userPreference 的用户级 scope `tabOrder`(按账号,不分仓库)
|
||||
- 排序与默认值保存后,所有页面立即生效(useTabOrder 为响应式读取)
|
||||
用法:
|
||||
- 设置中心 →「导航 → 标签排序」分区(推荐)
|
||||
- 需要独立弹窗时可自行包一层 el-dialog
|
||||
|
||||
说明:
|
||||
- 左侧只列出「标签数 ≥ 2」的页面(打开时并行懒加载标签数量)
|
||||
- 右侧拖拽排序 + 圆点设为默认;标题栏常驻展示当前生效的默认标签
|
||||
- 保存写入 userPreference 用户级 scope `tabOrder`,页面即时生效
|
||||
-->
|
||||
<template>
|
||||
<el-dialog
|
||||
:model-value="visible"
|
||||
title="标签排序"
|
||||
width="920px"
|
||||
align-center
|
||||
append-to-body
|
||||
destroy-on-close
|
||||
:close-on-click-modal="false"
|
||||
@update:model-value="(v: boolean) => emit('update:visible', v)"
|
||||
@open="handleOpen"
|
||||
>
|
||||
<div class="tab-order-panel-wrapper">
|
||||
<div class="tab-order-panel">
|
||||
<!-- 左侧:页面列表 -->
|
||||
<div class="panel-left">
|
||||
@ -91,18 +84,17 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<template #footer>
|
||||
<div class="tab-order-actions">
|
||||
<el-button size="small" @click="resetAll">全部恢复默认</el-button>
|
||||
<el-button size="small" @click="handleClose">取消</el-button>
|
||||
<el-button size="small" type="primary" :disabled="!isDirty" @click="handleSave">
|
||||
保存
|
||||
</el-button>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { computed, reactive, ref } from 'vue'
|
||||
import { computed, onMounted, reactive, ref } from 'vue'
|
||||
import { useRoute } from 'vue-router'
|
||||
import { ElMessage } from 'element-plus'
|
||||
import TabOrderDragList from '@/components/TabOrderDragList.vue'
|
||||
@ -121,21 +113,16 @@ import {
|
||||
type TabOption
|
||||
} from '@/utils/tab-order'
|
||||
|
||||
defineOptions({ name: 'TabOrderSettingsDialog' })
|
||||
defineOptions({ name: 'TabOrderPanel' })
|
||||
|
||||
const props = withDefaults(
|
||||
defineProps<{
|
||||
visible: boolean
|
||||
/** 当前所在页面的注册表 key(用于高亮,可空) */
|
||||
currentPageKey?: string
|
||||
}>(),
|
||||
{ currentPageKey: '' }
|
||||
)
|
||||
|
||||
const emit = defineEmits<{
|
||||
(e: 'update:visible', v: boolean): void
|
||||
}>()
|
||||
|
||||
const keyword = ref('')
|
||||
const selectedKey = ref('')
|
||||
const loading = ref(false)
|
||||
@ -143,10 +130,11 @@ const loading = ref(false)
|
||||
const itemsReady = ref(false)
|
||||
const route = useRoute()
|
||||
|
||||
/** 当前页面 key:优先页面 provide,其次按路由路径兜底匹配 */
|
||||
/** 当前页面 key:优先外部传入,其次按路由路径兜底匹配 */
|
||||
const effectiveCurrentKey = computed(
|
||||
() => props.currentPageKey || matchTabOrderPageKey(route.path)
|
||||
)
|
||||
|
||||
/** 页面 key → 已加载的默认标签 */
|
||||
const tabsCache = reactive<Record<string, TabOption[]>>({})
|
||||
/** 页面 key → 草稿(顺序 + 默认标签) */
|
||||
@ -260,7 +248,7 @@ async function ensureTabs(item: TabOrderRegistryItem) {
|
||||
initDraft(item, tabs)
|
||||
return tabs
|
||||
} catch (error) {
|
||||
console.error('[TabOrderSettingsDialog] loadTabs failed:', item.key, error)
|
||||
console.error('[TabOrderPanel] loadTabs failed:', item.key, error)
|
||||
tabsCache[item.key] = []
|
||||
drafts[item.key] = { order: [], defaultName: '' }
|
||||
return []
|
||||
@ -278,7 +266,7 @@ async function loadAllTabs() {
|
||||
tabsCache[item.key] = tabs
|
||||
initDraft(item, tabs)
|
||||
} catch (error) {
|
||||
console.error('[TabOrderSettingsDialog] loadTabs failed:', item.key, error)
|
||||
console.error('[TabOrderPanel] loadTabs failed:', item.key, error)
|
||||
tabsCache[item.key] = []
|
||||
}
|
||||
})
|
||||
@ -313,7 +301,7 @@ function resetAll() {
|
||||
clearAll.value = true
|
||||
}
|
||||
|
||||
async function handleOpen() {
|
||||
async function initialize() {
|
||||
keyword.value = ''
|
||||
clearAll.value = false
|
||||
itemsReady.value = false
|
||||
@ -363,19 +351,32 @@ function handleSave() {
|
||||
|
||||
writeTabOrderDoc({ version: 1, orders, defaults })
|
||||
ElMessage.success('标签排序已保存,页面已即时生效')
|
||||
handleClose()
|
||||
clearAll.value = false
|
||||
// 保存后以最新文档刷新草稿基线,避免「保存」按钮持续可用
|
||||
Object.keys(tabsCache).forEach((key) => {
|
||||
const item = TAB_ORDER_REGISTRY.find((entry) => entry.key === key)
|
||||
if (item && tabsCache[key]?.length) initDraft(item, tabsCache[key]!)
|
||||
})
|
||||
}
|
||||
|
||||
function handleClose() {
|
||||
emit('update:visible', false)
|
||||
}
|
||||
onMounted(() => {
|
||||
void initialize()
|
||||
})
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.tab-order-panel-wrapper {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
height: 100%;
|
||||
min-height: 0;
|
||||
}
|
||||
|
||||
.tab-order-panel {
|
||||
display: flex;
|
||||
gap: 16px;
|
||||
height: 460px;
|
||||
flex: 1;
|
||||
min-height: 0;
|
||||
}
|
||||
|
||||
.panel-left {
|
||||
@ -383,7 +384,7 @@ function handleClose() {
|
||||
flex-shrink: 0;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
border-right: 1px solid #ebeef5;
|
||||
border-right: 1px solid #e8eef7;
|
||||
padding-right: 12px;
|
||||
}
|
||||
|
||||
@ -412,12 +413,13 @@ function handleClose() {
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 8px;
|
||||
padding: 7px 10px;
|
||||
border-radius: 6px;
|
||||
min-height: 32px;
|
||||
padding: 0 10px;
|
||||
border-radius: 4px;
|
||||
font-size: 13px;
|
||||
color: #303133;
|
||||
color: #606266;
|
||||
cursor: pointer;
|
||||
transition: background-color 0.15s;
|
||||
transition: background-color 0.2s, color 0.2s;
|
||||
|
||||
&:hover {
|
||||
background: #f5f7fa;
|
||||
@ -425,7 +427,7 @@ function handleClose() {
|
||||
|
||||
&.is-active {
|
||||
background: #ecf5ff;
|
||||
color: #2f80ed;
|
||||
color: #409eff;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
@ -513,4 +515,13 @@ function handleClose() {
|
||||
font-size: 13px;
|
||||
color: #909399;
|
||||
}
|
||||
|
||||
.tab-order-actions {
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
gap: 8px;
|
||||
padding-top: 12px;
|
||||
margin-top: 8px;
|
||||
border-top: 1px solid #e8eef7;
|
||||
}
|
||||
</style>
|
||||
@ -1,293 +0,0 @@
|
||||
<!--
|
||||
更多设置表单
|
||||
- 由 UpperTable「字段设置」中的「更多设置」按钮打开
|
||||
- 表格工作模式(原字段设置工具栏内嵌的 radio,迁移至此)
|
||||
- 界面显示(浏览器 localStorage 持久化选项:Scan-box 模式 / 工具栏按钮模式 / 快捷键区域)
|
||||
- 页面缓存 / tab 缓存分类(开关 / 最大缓存数量)
|
||||
- 存储:experimental_{userId}_{roleId}(experimental store)、settings_{userId}_{roleId}(settings store)
|
||||
-->
|
||||
<template>
|
||||
<el-dialog
|
||||
v-model="dialogVisible"
|
||||
title="更多设置"
|
||||
width="600px"
|
||||
align-center
|
||||
append-to-body
|
||||
class="more-settings-dialog"
|
||||
>
|
||||
<!-- ===== 表格工作模式 ===== -->
|
||||
<div class="more-section">
|
||||
<div class="more-section-title">表格工作模式</div>
|
||||
<div class="more-section-desc">调整大列表表格的渲染调度策略</div>
|
||||
<div class="more-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="more-section">
|
||||
<div class="more-section-title">界面显示</div>
|
||||
<div class="more-section-desc">
|
||||
以下选项保存在当前浏览器,仅影响本机显示,换电脑需重新设置
|
||||
</div>
|
||||
|
||||
<div class="more-setting-row">
|
||||
<span class="setting-label">Scan-box 显示模式</span>
|
||||
<el-radio-group v-model="scanBoxMode" size="small">
|
||||
<el-radio-button value="compact">紧凑(默认)</el-radio-button>
|
||||
<el-radio-button value="standard">标准</el-radio-button>
|
||||
</el-radio-group>
|
||||
<span class="setting-hint">紧凑模式行高更小,一屏显示更多筛选条件</span>
|
||||
</div>
|
||||
|
||||
<div class="more-setting-row">
|
||||
<span class="setting-label">工具栏按钮模式</span>
|
||||
<el-radio-group v-model="toolbarMode" size="small">
|
||||
<el-radio-button value="tile">平铺(默认)</el-radio-button>
|
||||
<el-radio-button value="collapse">折叠</el-radio-button>
|
||||
</el-radio-group>
|
||||
<span class="setting-hint">订单工具栏按钮组的排列方式</span>
|
||||
</div>
|
||||
|
||||
<div class="more-setting-row">
|
||||
<span class="setting-label">快捷键区域</span>
|
||||
<el-switch v-model="shortcutExpanded" />
|
||||
<span class="setting-hint">展开顶部快捷键面板(默认收起)</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<el-divider />
|
||||
|
||||
<!-- ===== 页面缓存分类 ===== -->
|
||||
<div class="more-section">
|
||||
<div class="more-section-title">页面缓存</div>
|
||||
<div class="more-section-desc">控制通过顶部导航栏 / 页面 tab 切换的路由页面缓存策略</div>
|
||||
|
||||
<div class="more-setting-row">
|
||||
<span class="setting-label">页面缓存</span>
|
||||
<el-switch v-model="pageCacheEnabled" @change="handlePageCacheEnabledChange" />
|
||||
</div>
|
||||
|
||||
<div class="more-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>
|
||||
|
||||
<el-divider />
|
||||
|
||||
<!-- ===== tab 缓存分类 ===== -->
|
||||
<div class="more-section">
|
||||
<div class="more-section-title">tab 缓存</div>
|
||||
<div class="more-section-desc">控制含 tab 标签页切换功能页面的 KeepAlive 缓存策略</div>
|
||||
|
||||
<div class="more-setting-row">
|
||||
<span class="setting-label">tab 缓存</span>
|
||||
<el-switch v-model="tabCacheEnabled" @change="handleTabCacheEnabledChange" />
|
||||
</div>
|
||||
|
||||
<div class="more-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>
|
||||
|
||||
<template #footer>
|
||||
<el-button size="small" type="danger" plain @click="handleResetDefaults">恢复默认</el-button>
|
||||
<el-button size="small" @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'
|
||||
import { useSettingsStore } from '@/stores/modules/settings'
|
||||
|
||||
const visible = defineModel<boolean>('visible', { default: false })
|
||||
|
||||
const dialogVisible = computed({
|
||||
get: () => visible.value,
|
||||
set: (val: boolean) => {
|
||||
visible.value = val
|
||||
}
|
||||
})
|
||||
|
||||
const experimentalStore = useExperimentalStore()
|
||||
const settingsStore = useSettingsStore()
|
||||
|
||||
const tableMode = computed({
|
||||
get: () => experimentalStore.tableMode,
|
||||
set: (mode: 'performance' | 'resource') => {
|
||||
experimentalStore.setTableMode(mode)
|
||||
}
|
||||
})
|
||||
|
||||
/* ===== 界面显示(浏览器持久化:settings store → localStorage settings_{userId}_{roleId}) ===== */
|
||||
|
||||
/** Scan-box 显示模式:standard=标准 / compact=紧凑 */
|
||||
const scanBoxMode = computed({
|
||||
get: () => settingsStore.scanBoxMode,
|
||||
set: (mode: 'standard' | 'compact') => {
|
||||
settingsStore.changeSetting({ key: 'scanBoxMode', value: mode })
|
||||
}
|
||||
})
|
||||
|
||||
/** 工具栏按钮组显示模式:tile=平铺 / collapse=折叠 */
|
||||
const toolbarMode = computed({
|
||||
get: () => settingsStore.toolbarMode,
|
||||
set: (mode: 'tile' | 'collapse') => {
|
||||
settingsStore.changeSetting({ key: 'toolbarMode', value: mode })
|
||||
}
|
||||
})
|
||||
|
||||
/** 顶部快捷键区域是否展开 */
|
||||
const shortcutExpanded = computed({
|
||||
get: () => settingsStore.shortcutExpanded,
|
||||
set: (expanded: boolean) => {
|
||||
settingsStore.changeSetting({ key: 'shortcutExpanded', value: expanded })
|
||||
}
|
||||
})
|
||||
|
||||
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(
|
||||
'确定恢复全部设置为默认配置吗?表格工作模式、界面显示(Scan-box 模式 / 工具栏按钮模式 / 快捷键区域)、页面缓存、tab 缓存都将恢复默认。',
|
||||
'恢复默认',
|
||||
{
|
||||
type: 'warning',
|
||||
confirmButtonText: '恢复',
|
||||
cancelButtonText: '取消'
|
||||
}
|
||||
)
|
||||
.then(() => {
|
||||
experimentalStore.resetToDefaults()
|
||||
settingsStore.resetDisplaySettings()
|
||||
ElMessage.success('已恢复默认配置')
|
||||
})
|
||||
.catch(() => {})
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
.more-settings-dialog {
|
||||
/* 固定高度 + 内部滚动:表单不随内容拉伸,超出部分滚动查看 */
|
||||
:deep(.el-dialog__body) {
|
||||
height: 400px;
|
||||
max-height: 60vh;
|
||||
overflow-y: auto;
|
||||
overflow-x: hidden;
|
||||
}
|
||||
|
||||
.more-section {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 8px;
|
||||
|
||||
.more-section-title {
|
||||
font-size: 14px;
|
||||
font-weight: 600;
|
||||
color: #303133;
|
||||
}
|
||||
|
||||
.more-section-desc {
|
||||
font-size: 12px;
|
||||
color: #909399;
|
||||
margin-bottom: 4px;
|
||||
}
|
||||
}
|
||||
|
||||
.more-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;
|
||||
}
|
||||
}
|
||||
|
||||
:deep(.el-divider--horizontal) {
|
||||
margin: 16px 0;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@ -246,169 +246,140 @@
|
||||
/>
|
||||
</div>
|
||||
|
||||
<el-dialog
|
||||
v-model="columnConfigDialogVisible"
|
||||
title="字段设置"
|
||||
width="1200px"
|
||||
align-center
|
||||
append-to-body
|
||||
<SettingsDialog
|
||||
v-model:visible="settingsVisible"
|
||||
:initial-section="settingsInitialSection"
|
||||
@columns-changed="rebuildColumnConfig"
|
||||
>
|
||||
<div class="column-config-toolbar">
|
||||
<el-button size="small" @click="resetColumnConfig">恢复默认</el-button>
|
||||
<el-button size="small" @click="exportGlobalColumnConfig">导出配置</el-button>
|
||||
<el-upload
|
||||
accept=".json"
|
||||
:show-file-list="false"
|
||||
:auto-upload="false"
|
||||
:on-change="handleImportColumnConfig"
|
||||
>
|
||||
<el-button size="small">导入配置</el-button>
|
||||
</el-upload>
|
||||
<el-button size="small" type="danger" plain @click="handleRepairColumnConfig">故障修复</el-button>
|
||||
<!-- 标签排序:全项目标签顺序 + 默认页签统一管理 -->
|
||||
<el-button size="small" @click="tabOrderDialogVisible = true">标签排序</el-button>
|
||||
<!-- 更多设置:表格工作模式、页面缓存 / tab 缓存等设置已迁移至该表单 -->
|
||||
<el-button size="small" @click="moreSettingsDialogVisible = true">更多设置</el-button>
|
||||
</div>
|
||||
<div class="column-config-list" ref="columnConfigListRef">
|
||||
<template v-for="section in columnConfigDialogSections" :key="section.key">
|
||||
<div class="column-config-section" :class="`column-config-section--${section.key}`">
|
||||
<div class="column-config-section-title">{{ section.title }}</div>
|
||||
<div class="column-config-section-body">
|
||||
<div
|
||||
v-for="(item, sIdx) in section.items"
|
||||
:key="item.prop"
|
||||
class="column-config-item"
|
||||
:class="{
|
||||
'is-fixed-column': section.key !== 'scroll',
|
||||
'is-draggable': true,
|
||||
'is-drag-over': dragOverProp === item.prop
|
||||
}"
|
||||
:draggable="true"
|
||||
@dragstart="onColumnDragStart($event, item)"
|
||||
@dragover.prevent="onColumnDragOver($event, item)"
|
||||
@drop.prevent="onColumnDrop(item)"
|
||||
@dragend="onColumnDragEnd"
|
||||
>
|
||||
<div class="column-config-main">
|
||||
<span class="drag-handle" aria-hidden="true">⋮⋮</span>
|
||||
<el-checkbox
|
||||
:model-value="item.visible"
|
||||
@change="(val: any) => onToggleColumnVisible(item.prop, !!val)"
|
||||
>
|
||||
{{ item.label || item.prop }}
|
||||
</el-checkbox>
|
||||
</div>
|
||||
<div class="column-config-actions">
|
||||
<!-- 不固定列:左箭头固定到左侧,右箭头固定到右侧 -->
|
||||
<el-button
|
||||
v-if="section.key === 'scroll'"
|
||||
text
|
||||
size="small"
|
||||
class="cfg-fix-btn"
|
||||
@click="setFixed(item.prop, 'left')"
|
||||
title="固定到左侧"
|
||||
>
|
||||
←
|
||||
</el-button>
|
||||
<el-button
|
||||
v-if="section.key === 'scroll'"
|
||||
text
|
||||
size="small"
|
||||
class="cfg-fix-btn"
|
||||
@click="setFixed(item.prop, 'right')"
|
||||
title="固定到右侧"
|
||||
>
|
||||
→
|
||||
</el-button>
|
||||
<!-- 左固定列:→ 回到不固定列 -->
|
||||
<el-button
|
||||
v-if="section.key === 'fixed-left'"
|
||||
text
|
||||
size="small"
|
||||
class="cfg-fix-btn"
|
||||
@click="setFixed(item.prop, false)"
|
||||
title="回到不固定列"
|
||||
>
|
||||
→
|
||||
</el-button>
|
||||
<!-- 右固定列:← 回到不固定列 -->
|
||||
<el-button
|
||||
v-if="section.key === 'fixed-right'"
|
||||
text
|
||||
size="small"
|
||||
class="cfg-fix-btn"
|
||||
@click="setFixed(item.prop, false)"
|
||||
title="回到不固定列"
|
||||
>
|
||||
←
|
||||
</el-button>
|
||||
<el-button
|
||||
text
|
||||
size="small"
|
||||
class="cfg-move-btn"
|
||||
:disabled="sIdx === 0"
|
||||
@click="moveColumn(item.prop, 'up')"
|
||||
>
|
||||
↑
|
||||
</el-button>
|
||||
<el-button
|
||||
text
|
||||
size="small"
|
||||
class="cfg-move-btn"
|
||||
:disabled="sIdx === section.items.length - 1"
|
||||
@click="moveColumn(item.prop, 'down')"
|
||||
>
|
||||
↓
|
||||
</el-button>
|
||||
</div>
|
||||
</div>
|
||||
<div v-if="!section.items.length" class="column-config-empty">
|
||||
<span>将列拖到此处固定</span>
|
||||
<template #field-section>
|
||||
<div class="field-section">
|
||||
<div class="field-section-head">
|
||||
<div>
|
||||
<div class="field-section-title">列表字段</div>
|
||||
<div class="field-section-desc">
|
||||
当前表格:勾选显示列、拖动调整顺序;导出/导入配置与故障修复请前往「数据与维护」。
|
||||
</div>
|
||||
</div>
|
||||
<el-button size="small" @click="resetColumnConfig">恢复默认</el-button>
|
||||
</div>
|
||||
</template>
|
||||
</div>
|
||||
<template #footer>
|
||||
<el-button size="small" @click="columnConfigDialogVisible = false">关闭</el-button>
|
||||
<div class="column-config-list" ref="columnConfigListRef">
|
||||
<template v-for="section in columnConfigDialogSections" :key="section.key">
|
||||
<div class="column-config-section" :class="`column-config-section--${section.key}`">
|
||||
<div class="column-config-section-title">{{ section.title }}</div>
|
||||
<div class="column-config-section-body">
|
||||
<div
|
||||
v-for="(item, sIdx) in section.items"
|
||||
:key="item.prop"
|
||||
class="column-config-item"
|
||||
:class="{
|
||||
'is-fixed-column': section.key !== 'scroll',
|
||||
'is-draggable': true,
|
||||
'is-drag-over': dragOverProp === item.prop
|
||||
}"
|
||||
:draggable="true"
|
||||
@dragstart="onColumnDragStart($event, item)"
|
||||
@dragover.prevent="onColumnDragOver($event, item)"
|
||||
@drop.prevent="onColumnDrop(item)"
|
||||
@dragend="onColumnDragEnd"
|
||||
>
|
||||
<div class="column-config-main">
|
||||
<span class="drag-handle" aria-hidden="true">⋮⋮</span>
|
||||
<el-checkbox
|
||||
:model-value="item.visible"
|
||||
@change="(val: any) => onToggleColumnVisible(item.prop, !!val)"
|
||||
>
|
||||
{{ item.label || item.prop }}
|
||||
</el-checkbox>
|
||||
</div>
|
||||
<div class="column-config-actions">
|
||||
<!-- 不固定列:左箭头固定到左侧,右箭头固定到右侧 -->
|
||||
<el-button
|
||||
v-if="section.key === 'scroll'"
|
||||
text
|
||||
size="small"
|
||||
class="cfg-fix-btn"
|
||||
@click="setFixed(item.prop, 'left')"
|
||||
title="固定到左侧"
|
||||
>
|
||||
←
|
||||
</el-button>
|
||||
<el-button
|
||||
v-if="section.key === 'scroll'"
|
||||
text
|
||||
size="small"
|
||||
class="cfg-fix-btn"
|
||||
@click="setFixed(item.prop, 'right')"
|
||||
title="固定到右侧"
|
||||
>
|
||||
→
|
||||
</el-button>
|
||||
<!-- 左固定列:→ 回到不固定列 -->
|
||||
<el-button
|
||||
v-if="section.key === 'fixed-left'"
|
||||
text
|
||||
size="small"
|
||||
class="cfg-fix-btn"
|
||||
@click="setFixed(item.prop, false)"
|
||||
title="回到不固定列"
|
||||
>
|
||||
→
|
||||
</el-button>
|
||||
<!-- 右固定列:← 回到不固定列 -->
|
||||
<el-button
|
||||
v-if="section.key === 'fixed-right'"
|
||||
text
|
||||
size="small"
|
||||
class="cfg-fix-btn"
|
||||
@click="setFixed(item.prop, false)"
|
||||
title="回到不固定列"
|
||||
>
|
||||
←
|
||||
</el-button>
|
||||
<el-button
|
||||
text
|
||||
size="small"
|
||||
class="cfg-move-btn"
|
||||
:disabled="sIdx === 0"
|
||||
@click="moveColumn(item.prop, 'up')"
|
||||
>
|
||||
↑
|
||||
</el-button>
|
||||
<el-button
|
||||
text
|
||||
size="small"
|
||||
class="cfg-move-btn"
|
||||
:disabled="sIdx === section.items.length - 1"
|
||||
@click="moveColumn(item.prop, 'down')"
|
||||
>
|
||||
↓
|
||||
</el-button>
|
||||
</div>
|
||||
</div>
|
||||
<div v-if="!section.items.length" class="column-config-empty">
|
||||
<span>将列拖到此处固定</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</SettingsDialog>
|
||||
|
||||
<qrcode-dialog v-model:visible="waybillQrVisible" :code="waybillQrCode" />
|
||||
|
||||
<more-settings-dialog v-model:visible="moreSettingsDialogVisible" />
|
||||
|
||||
<tab-order-settings-dialog
|
||||
v-model:visible="tabOrderDialogVisible"
|
||||
:current-page-key="tabOrderPageKey"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref, computed, watch, onMounted, onBeforeUnmount, nextTick } from 'vue'
|
||||
import { ref, computed, watch, onMounted, onBeforeUnmount, nextTick, useAttrs } from 'vue'
|
||||
import { Box } from '@element-plus/icons-vue'
|
||||
import { ElMessage, ElMessageBox } from 'element-plus'
|
||||
import type { UploadFile } from 'element-plus'
|
||||
import { ElMessage } 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 { useTableColumnConfigStore } from '@/stores/modules/tableColumnConfig'
|
||||
import type { ColumnConfigItem, TableColumnProfile } from '@/utils/table-column-config'
|
||||
import QrcodeDialog from '@/components/QR/qrcode.vue'
|
||||
import MoreSettingsDialog from './MoreSettingsDialog.vue'
|
||||
import TabOrderSettingsDialog from '@/components/TabOrderSettingsDialog.vue'
|
||||
import { injectTabOrderPageKey } from '@/composables/useTabOrder'
|
||||
import { useUserPreferenceStore } from '@/stores/modules/userPreference'
|
||||
import { TAB_ORDER_SCOPE } from '@/utils/tab-order'
|
||||
import {
|
||||
TBYC_CONFIG_FILENAME,
|
||||
buildTbycConfig,
|
||||
downloadJsonFile,
|
||||
isTbycConfig
|
||||
} from '@/utils/tbyc-config'
|
||||
import { TBYC_CONFIG_SECTIONS, getTbycConfigSection } from '@/config/tbyc-config-sections'
|
||||
import SettingsDialog from '@/components/settings/SettingsDialog.vue'
|
||||
|
||||
defineOptions({
|
||||
name: 'UpperTable'
|
||||
@ -625,11 +596,13 @@ const emit = defineEmits([
|
||||
const tableRef = ref<any>(null)
|
||||
const userStore = useUserStore()
|
||||
const experimentalStore = useExperimentalStore()
|
||||
const moreSettingsDialogVisible = ref(false)
|
||||
/** 标签排序全局面板(排序 + 默认页签统一管理) */
|
||||
const tabOrderDialogVisible = ref(false)
|
||||
/** 当前页面 key(由页面 useTabOrder provide,用于面板高亮;单标签页面为空) */
|
||||
const tabOrderPageKey = injectTabOrderPageKey()
|
||||
const attrs = useAttrs()
|
||||
/** 表格展示名称(页面通过 :title 传入,未声明为 prop,从 attrs 读取) */
|
||||
const tableTitle = computed(() => String((attrs.title as string) || ''))
|
||||
/** 设置中心可见性(字段设置 / 更多设置 / 标签排序 / 数据维护 统一入口) */
|
||||
const settingsVisible = ref(false)
|
||||
/** 打开时定位的分区:'field' = 当前表格的列表字段 */
|
||||
const settingsInitialSection = ref('field')
|
||||
|
||||
type ColumnItem = {
|
||||
prop?: string
|
||||
@ -639,24 +612,6 @@ type ColumnItem = {
|
||||
[key: string]: any
|
||||
}
|
||||
|
||||
type ColumnConfigItem = {
|
||||
prop: string
|
||||
label?: string
|
||||
visible: boolean
|
||||
order: number
|
||||
width?: number | string
|
||||
fixed?: 'left' | 'right' | false
|
||||
}
|
||||
|
||||
type TableColumnProfile = {
|
||||
schemaVersion: number
|
||||
tableId: string
|
||||
userId: string
|
||||
roleId: string | number
|
||||
updatedAt: number
|
||||
columns: ColumnConfigItem[]
|
||||
}
|
||||
|
||||
// State
|
||||
// const visibleData = ref<any[]>([]) // Removed
|
||||
// const rowHeight = ref(41) // Removed
|
||||
@ -669,7 +624,6 @@ const selectedRowKeys = ref<Set<any>>(new Set())
|
||||
// const lastScrollTop = ref(0) // Removed
|
||||
// let scrollTimer: any = null // Removed
|
||||
const checkboxUpdateKey = ref<number | null>(null)
|
||||
const columnConfigDialogVisible = ref(false)
|
||||
const editableColumnConfigs = ref<ColumnConfigItem[]>([])
|
||||
const columnConfigMap = ref<Record<string, ColumnConfigItem>>({})
|
||||
const draggingProp = ref<string>('')
|
||||
@ -790,12 +744,6 @@ const columnConfigStorageKey = computed(() => {
|
||||
return `upper_table_columns_${userId}_${roleId}_${effectiveTableId.value}`
|
||||
})
|
||||
|
||||
const globalColumnConfigStoragePrefix = computed(() => {
|
||||
const userId = userStore.user?.username || userStore.user?.id || 'unknown'
|
||||
const roleId = userStore.roleId || 'default'
|
||||
return `upper_table_columns_${userId}_${roleId}_`
|
||||
})
|
||||
|
||||
const displayColumns = computed(() => {
|
||||
if (!props.enableColumnConfig || !effectiveTableId.value) {
|
||||
return normalizedColumns.value
|
||||
@ -1106,8 +1054,12 @@ watch(
|
||||
}
|
||||
)
|
||||
|
||||
function saveColumnConfig(configs: ColumnConfigItem[]) {
|
||||
function saveColumnConfig(
|
||||
configs: ColumnConfigItem[],
|
||||
options: { defaultColumns?: ColumnConfigItem[] } = {}
|
||||
) {
|
||||
if (!columnConfigStorageKey.value) return
|
||||
const prev = readStoredProfile()
|
||||
const userId = String(userStore.user?.username || userStore.user?.id || 'unknown')
|
||||
const roleId = userStore.roleId || 'default'
|
||||
const payload: TableColumnProfile = {
|
||||
@ -1116,6 +1068,10 @@ function saveColumnConfig(configs: ColumnConfigItem[]) {
|
||||
userId,
|
||||
roleId,
|
||||
updatedAt: Date.now(),
|
||||
// 表格名称:便于「设置 → 所有表格字段」中辨认(页面通过 :title 传入)
|
||||
title: tableTitle.value || prev?.title,
|
||||
// 默认布局:首次生成配置时快照,供「恢复默认」使用
|
||||
defaultColumns: options.defaultColumns ?? prev?.defaultColumns,
|
||||
columns: configs
|
||||
}
|
||||
localStorage.setItem(columnConfigStorageKey.value, JSON.stringify(payload))
|
||||
@ -1193,7 +1149,7 @@ function buildMergedColumnConfigs(raw?: Partial<ColumnConfigItem>[]) {
|
||||
return normalizeColumnConfigOrders(merged)
|
||||
}
|
||||
|
||||
function readStoredColumnConfigs() {
|
||||
function readStoredProfile(): TableColumnProfile | null {
|
||||
if (!columnConfigStorageKey.value) return null
|
||||
const raw = localStorage.getItem(columnConfigStorageKey.value)
|
||||
if (!raw) return null
|
||||
@ -1202,20 +1158,38 @@ function readStoredColumnConfigs() {
|
||||
if (!parsed || !Array.isArray(parsed.columns)) return null
|
||||
const storedVersion = parsed.schemaVersion ?? 1
|
||||
if (storedVersion !== props.columnConfigSchemaVersion) return null
|
||||
return parsed.columns
|
||||
return parsed
|
||||
} catch {
|
||||
return null
|
||||
}
|
||||
}
|
||||
|
||||
function readStoredColumnConfigs() {
|
||||
return readStoredProfile()?.columns ?? null
|
||||
}
|
||||
|
||||
function rebuildColumnConfig() {
|
||||
const merged = buildMergedColumnConfigs(readStoredColumnConfigs() || undefined)
|
||||
const stored = readStoredProfile()
|
||||
const merged = buildMergedColumnConfigs(stored?.columns || undefined)
|
||||
applyColumnConfigMap(merged)
|
||||
if (props.enableColumnConfig && effectiveTableId.value) {
|
||||
saveColumnConfig(merged)
|
||||
// 首次(或旧数据缺少 defaultColumns)时,以当前默认列为快照
|
||||
saveColumnConfig(merged, {
|
||||
defaultColumns: stored?.defaultColumns || normalizeColumnConfigOrders(getDefaultColumnConfigs())
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
const tableColumnConfigStore = useTableColumnConfigStore()
|
||||
// 设置中心「所有表格字段」修改本表配置后,重建列配置(即时生效)
|
||||
watch(
|
||||
() => tableColumnConfigStore.versions[effectiveTableId.value || ''],
|
||||
() => {
|
||||
if (!props.enableColumnConfig || !effectiveTableId.value) return
|
||||
rebuildColumnConfig()
|
||||
}
|
||||
)
|
||||
|
||||
function resolveCopyRawValue(row: any, column: ColumnItem): unknown {
|
||||
if (typeof column.copyValue === 'function') {
|
||||
return column.copyValue(row)
|
||||
@ -1568,7 +1542,8 @@ function persistEditableConfigs() {
|
||||
|
||||
function openColumnConfig() {
|
||||
editableColumnConfigs.value = normalizeColumnConfigOrders(Object.values(columnConfigMap.value))
|
||||
columnConfigDialogVisible.value = true
|
||||
settingsInitialSection.value = 'field'
|
||||
settingsVisible.value = true
|
||||
}
|
||||
|
||||
function onToggleColumnVisible(prop: string, visible: boolean) {
|
||||
@ -1749,185 +1724,9 @@ function resetColumnConfig() {
|
||||
ElMessage.success('已恢复默认字段配置')
|
||||
}
|
||||
|
||||
/** 导出统一配置文件(tbyc-config.json:字段设置 / 标签排序 / 界面显示 / 快捷键 …) */
|
||||
function exportGlobalColumnConfig() {
|
||||
const identity = {
|
||||
userId: String(userStore.user?.username || userStore.user?.id || 'unknown'),
|
||||
roleId: String(userStore.roleId || 'default')
|
||||
}
|
||||
const sections: Record<string, unknown> = {}
|
||||
TBYC_CONFIG_SECTIONS.forEach((section) => {
|
||||
try {
|
||||
const data = section.collect()
|
||||
if (data === undefined || data === null) return
|
||||
sections[section.key] = data
|
||||
} catch (error) {
|
||||
console.error(`[tbyc-config] collect ${section.key} failed:`, error)
|
||||
}
|
||||
})
|
||||
|
||||
if (!Object.keys(sections).length) {
|
||||
ElMessage.warning('当前没有可导出的配置')
|
||||
return
|
||||
}
|
||||
|
||||
downloadJsonFile(TBYC_CONFIG_FILENAME, buildTbycConfig(identity, sections))
|
||||
ElMessage.success('配置文件已导出')
|
||||
}
|
||||
|
||||
/**
|
||||
* 解析导入文件 → 分区数据
|
||||
* - 新格式:{ format: 'tbyc-config', sections: { ... } }
|
||||
* - 旧格式:{ tables | tableId/columns } + { tabOrders }(兼容旧版「全局字段配置」导出文件)
|
||||
*/
|
||||
function resolveConfigSections(parsed: any): Record<string, unknown> {
|
||||
if (!parsed || typeof parsed !== 'object') return {}
|
||||
if (isTbycConfig(parsed) || (parsed.sections && typeof parsed.sections === 'object')) {
|
||||
return parsed.sections || {}
|
||||
}
|
||||
|
||||
const sections: Record<string, unknown> = {}
|
||||
if (Array.isArray(parsed.tables)) {
|
||||
sections.fieldColumns = parsed.tables
|
||||
} else if (parsed.tableId && Array.isArray(parsed.columns)) {
|
||||
sections.fieldColumns = [
|
||||
{ tableId: parsed.tableId, columns: parsed.columns, schemaVersion: parsed.schemaVersion }
|
||||
]
|
||||
}
|
||||
if (parsed.tabOrders) sections.tabOrder = parsed.tabOrders
|
||||
return sections
|
||||
}
|
||||
|
||||
function handleImportColumnConfig(file: UploadFile) {
|
||||
if (!file.raw) return
|
||||
const reader = new FileReader()
|
||||
reader.onload = () => {
|
||||
try {
|
||||
const parsed = JSON.parse(String(reader.result || '{}'))
|
||||
const sections = resolveConfigSections(parsed)
|
||||
const sectionKeys = Object.keys(sections)
|
||||
if (!sectionKeys.length) {
|
||||
ElMessage.error('未找到可导入的配置')
|
||||
return
|
||||
}
|
||||
|
||||
const applied: string[] = []
|
||||
let columnImported = false
|
||||
|
||||
TBYC_CONFIG_SECTIONS.forEach((section) => {
|
||||
if (!(section.key in sections)) return
|
||||
try {
|
||||
const count = section.apply(sections[section.key])
|
||||
if (count > 0) {
|
||||
applied.push(`${section.title} ${count} 项`)
|
||||
if (section.key === 'fieldColumns') columnImported = true
|
||||
}
|
||||
} catch (error) {
|
||||
console.error(`[tbyc-config] apply ${section.key} failed:`, error)
|
||||
}
|
||||
})
|
||||
|
||||
// 来自更新版本的未知分区:只提示,不阻断其它配置导入
|
||||
const unknownCount = sectionKeys.filter((key) => !getTbycConfigSection(key)).length
|
||||
if (!applied.length) {
|
||||
ElMessage.error(unknownCount ? '配置文件中的配置项当前版本不支持' : '未找到可导入的配置')
|
||||
return
|
||||
}
|
||||
|
||||
if (columnImported) rebuildColumnConfig()
|
||||
const suffix = unknownCount ? `(${unknownCount} 个未知配置项已忽略)` : ''
|
||||
ElMessage.success(`配置导入成功:${applied.join('、')}${suffix}`)
|
||||
} catch {
|
||||
ElMessage.error('配置文件解析失败')
|
||||
}
|
||||
}
|
||||
reader.readAsText(file.raw)
|
||||
}
|
||||
|
||||
async function handleRepairColumnConfig() {
|
||||
try {
|
||||
await ElMessageBox.confirm(
|
||||
'故障修复会清除当前电脑中此账号的全部字段配置、标签排序、显示设置及快捷键,并恢复所有默认配置。是否继续?',
|
||||
'确认故障修复',
|
||||
{
|
||||
type: 'warning',
|
||||
buttonSize: 'small',
|
||||
confirmButtonText: '确认清除',
|
||||
cancelButtonText: '取消'
|
||||
}
|
||||
)
|
||||
|
||||
await ElMessageBox.confirm(
|
||||
'请再次确认:该操作不可撤销,确定清除所有配置吗?',
|
||||
'二次确认',
|
||||
{
|
||||
type: 'warning',
|
||||
buttonSize: 'small',
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '返回'
|
||||
}
|
||||
)
|
||||
|
||||
// 1. 清除字段配置(表格列配置)
|
||||
const columnPrefix = globalColumnConfigStoragePrefix.value
|
||||
const removeKeys: string[] = []
|
||||
Object.keys(localStorage).forEach((key) => {
|
||||
if (key.startsWith(columnPrefix)) {
|
||||
removeKeys.push(key)
|
||||
}
|
||||
})
|
||||
removeKeys.forEach((key) => localStorage.removeItem(key))
|
||||
const columnCount = removeKeys.length
|
||||
|
||||
// 2. 清除并重置显示设置(toolbarMode、scanBoxMode 等)
|
||||
const settingsStore = useSettingsStore()
|
||||
const settingsKey = (() => {
|
||||
const userStore = useUserStore()
|
||||
const userId = userStore.user?.username || userStore.user?.id || 'unknown'
|
||||
const roleId = userStore.roleId || 'default'
|
||||
return `settings_${userId}_${roleId}`
|
||||
})()
|
||||
const hadSettings = localStorage.getItem(settingsKey) !== null
|
||||
localStorage.removeItem(settingsKey)
|
||||
// 将各项设置重置为默认值
|
||||
settingsStore.changeSetting({ key: 'showSettings', value: defaultSettings.showSettings })
|
||||
settingsStore.changeSetting({ key: 'tagsView', value: defaultSettings.tagsView })
|
||||
settingsStore.changeSetting({ key: 'fixedHeader', value: defaultSettings.fixedHeader })
|
||||
settingsStore.changeSetting({ key: 'sidebarLogo', value: defaultSettings.sidebarLogo })
|
||||
settingsStore.changeSetting({ key: 'layoutMode', value: 'top-bottom' })
|
||||
settingsStore.changeSetting({ key: 'shortcutExpanded', value: defaultSettings.shortcutExpanded })
|
||||
settingsStore.changeSetting({ key: 'toolbarMode', value: defaultSettings.toolbarMode })
|
||||
settingsStore.changeSetting({ key: 'scanBoxMode', value: defaultSettings.scanBoxMode })
|
||||
|
||||
// 3. 清除并重置快捷键
|
||||
const shortcutsStore = useShortcutsStore()
|
||||
const shortcutsKey = (() => {
|
||||
const userStore = useUserStore()
|
||||
const userId = userStore.user?.username || userStore.user?.id || 'unknown'
|
||||
const roleId = userStore.roleId || 'default'
|
||||
return `shortcuts_${userId}_${roleId}`
|
||||
})()
|
||||
const hadShortcuts = localStorage.getItem(shortcutsKey) !== null
|
||||
localStorage.removeItem(shortcutsKey)
|
||||
shortcutsStore.shortcuts = []
|
||||
|
||||
// 4. 清除标签排序 / 默认页签(用户级配置,不分仓库)
|
||||
const preferenceStore = useUserPreferenceStore()
|
||||
const hadTabOrder = !!preferenceStore.getGlobal(TAB_ORDER_SCOPE)
|
||||
if (hadTabOrder) preferenceStore.resetGlobal(TAB_ORDER_SCOPE)
|
||||
|
||||
rebuildColumnConfig()
|
||||
|
||||
const parts: string[] = []
|
||||
if (columnCount > 0) parts.push(`${columnCount} 个字段配置`)
|
||||
if (hadSettings) parts.push('显示设置')
|
||||
if (hadShortcuts) parts.push('快捷键')
|
||||
if (hadTabOrder) parts.push('标签排序')
|
||||
ElMessage.success(`故障修复完成${parts.length > 0 ? ',已恢复 ' + parts.join('、') : ''}`)
|
||||
} catch {
|
||||
// user cancelled
|
||||
}
|
||||
}
|
||||
|
||||
/** 方案⑧:formatter 结果按行缓存(WeakMap,行对象生命周期自动回收),避免滚动窗口切换时重复计算 */
|
||||
const formatterCache = new WeakMap<object, Map<string, string>>()
|
||||
@ -2623,6 +2422,28 @@ watch([virtualScrollTop, measuredRowHeight], () => {
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.field-section-head {
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
justify-content: space-between;
|
||||
gap: 12px;
|
||||
padding: 4px 0 8px 12px;
|
||||
}
|
||||
|
||||
.field-section-title {
|
||||
font-size: 13px;
|
||||
line-height: 20px;
|
||||
font-weight: 600;
|
||||
color: #303133;
|
||||
}
|
||||
|
||||
.field-section-desc {
|
||||
margin-top: 4px;
|
||||
font-size: 12px;
|
||||
line-height: 18px;
|
||||
color: #909399;
|
||||
}
|
||||
|
||||
.table-mode-label {
|
||||
font-size: 13px;
|
||||
color: #606266;
|
||||
|
||||
352
src/components/settings/SettingsDialog.vue
Normal file
352
src/components/settings/SettingsDialog.vue
Normal file
@ -0,0 +1,352 @@
|
||||
<!--
|
||||
SettingsDialog — 设置中心(项目内所有"本机可修改配置"的总入口)
|
||||
|
||||
入口:
|
||||
1. 列表页工具栏「字段设置」→ initialSection = 'field'(由 UpperTable 通过 #field-section 注入内容)
|
||||
2. Navbar 头像下拉「设置」→ 无表上下文,自动隐藏「当前页面」分组
|
||||
|
||||
约定:
|
||||
· 所有分区即时生效(各自写对应 store),不提供全局保存/取消
|
||||
· 分区元数据见 ./registry.ts;新增设置 = 注册一条 + 新建 section 组件
|
||||
-->
|
||||
<template>
|
||||
<el-dialog
|
||||
:model-value="visible"
|
||||
class="settings-dialog"
|
||||
width="1280px"
|
||||
align-center
|
||||
append-to-body
|
||||
destroy-on-close
|
||||
:show-close="false"
|
||||
:close-on-click-modal="false"
|
||||
@update:model-value="(v: boolean) => emit('update:visible', v)"
|
||||
>
|
||||
<div class="settings-shell">
|
||||
<!-- 头部(对齐 task-panel:18px 标题 + 12px 说明 + 24px 关闭) -->
|
||||
<header class="task-panel__head">
|
||||
<div class="task-panel__titles">
|
||||
<h2>设置</h2>
|
||||
<p>当前账号 · 仅保存在本机浏览器</p>
|
||||
</div>
|
||||
<button class="task-panel__close" type="button" aria-label="关闭" @click="handleClose">
|
||||
<svg viewBox="0 0 12 12" fill="none">
|
||||
<path
|
||||
d="M1 1L11 11M11 1L1 11"
|
||||
stroke="currentColor"
|
||||
stroke-width="1.4"
|
||||
stroke-linecap="round"
|
||||
/>
|
||||
</svg>
|
||||
</button>
|
||||
</header>
|
||||
|
||||
<!-- 主体:左导航 + 右内容 -->
|
||||
<div class="settings-body">
|
||||
<aside class="settings-nav">
|
||||
<el-input
|
||||
v-model="keyword"
|
||||
size="small"
|
||||
placeholder="搜索设置项"
|
||||
clearable
|
||||
class="settings-search"
|
||||
/>
|
||||
<div class="settings-nav-list">
|
||||
<template v-for="group in groups" :key="group.name">
|
||||
<div v-if="group.items.length" class="settings-group">
|
||||
<div class="settings-group-title">{{ group.name }}</div>
|
||||
<div
|
||||
v-for="item in group.items"
|
||||
:key="item.key"
|
||||
class="settings-nav-item"
|
||||
:class="{ 'is-active': item.key === currentKey }"
|
||||
@click="currentKey = item.key"
|
||||
>
|
||||
<span class="settings-nav-title">{{ item.title }}</span>
|
||||
<span v-if="item.scopeLabel" class="settings-nav-scope">{{ item.scopeLabel }}</span>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
<el-empty v-if="!groups.length" description="没有匹配的设置项" :image-size="60" />
|
||||
</div>
|
||||
</aside>
|
||||
|
||||
<section class="settings-content">
|
||||
<template v-if="currentSection">
|
||||
<component
|
||||
:is="currentSection.component"
|
||||
v-if="currentSection.component"
|
||||
@columns-changed="emit('columns-changed')"
|
||||
/>
|
||||
<slot v-else name="field-section" />
|
||||
</template>
|
||||
<el-empty v-else description="请选择左侧设置项" />
|
||||
</section>
|
||||
</div>
|
||||
|
||||
<!-- 底部 -->
|
||||
<footer class="settings-footer">
|
||||
<span class="settings-footer-tip">修改即时保存 · 仅保存在当前浏览器</span>
|
||||
<div class="settings-footer-actions">
|
||||
<el-button size="small" @click="handleClose">关闭</el-button>
|
||||
</div>
|
||||
</footer>
|
||||
</div>
|
||||
</el-dialog>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { computed, ref, useSlots, watch } from 'vue'
|
||||
import {
|
||||
SETTINGS_GROUPS,
|
||||
SETTINGS_SECTIONS,
|
||||
type SettingsSectionMeta
|
||||
} from './registry'
|
||||
|
||||
defineOptions({ name: 'SettingsDialog' })
|
||||
|
||||
const props = withDefaults(
|
||||
defineProps<{
|
||||
visible: boolean
|
||||
/** 打开时定位的分区 key(非法/不可见时回落到第一个) */
|
||||
initialSection?: string
|
||||
}>(),
|
||||
{ initialSection: '' }
|
||||
)
|
||||
|
||||
const emit = defineEmits<{
|
||||
(e: 'update:visible', v: boolean): void
|
||||
/** 字段配置发生变化(导入/重置/故障修复),由宿主重建列配置 */
|
||||
(e: 'columns-changed'): void
|
||||
}>()
|
||||
|
||||
const slots = useSlots()
|
||||
const keyword = ref('')
|
||||
const currentKey = ref('')
|
||||
|
||||
const hasFieldSlot = computed(() => !!slots['field-section'])
|
||||
|
||||
/** 当前入口下可见的分区(无插槽时隐藏表级「列表字段」) */
|
||||
const availableSections = computed<SettingsSectionMeta[]>(() =>
|
||||
SETTINGS_SECTIONS.filter((section) => !section.slot || hasFieldSlot.value)
|
||||
)
|
||||
|
||||
const groups = computed(() => {
|
||||
const kw = keyword.value.trim().toLowerCase()
|
||||
return SETTINGS_GROUPS.map((name) => ({
|
||||
name,
|
||||
items: availableSections.value.filter((section) => {
|
||||
if (section.group !== name) return false
|
||||
if (!kw) return true
|
||||
return (
|
||||
section.title.toLowerCase().includes(kw) || section.key.toLowerCase().includes(kw)
|
||||
)
|
||||
})
|
||||
})).filter((group) => group.items.length > 0)
|
||||
})
|
||||
|
||||
const currentSection = computed(() =>
|
||||
availableSections.value.find((section) => section.key === currentKey.value)
|
||||
)
|
||||
|
||||
watch(
|
||||
() => props.visible,
|
||||
(visible) => {
|
||||
if (!visible) return
|
||||
keyword.value = ''
|
||||
const preferred = availableSections.value.find((section) => section.key === props.initialSection)
|
||||
currentKey.value = preferred?.key || availableSections.value[0]?.key || ''
|
||||
},
|
||||
{ immediate: true }
|
||||
)
|
||||
|
||||
function handleClose() {
|
||||
emit('update:visible', false)
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.settings-shell {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
background: #fff;
|
||||
}
|
||||
|
||||
/* ===== 头部(对齐 task-panel) ===== */
|
||||
.task-panel__head {
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
gap: 12px;
|
||||
padding: 16px;
|
||||
}
|
||||
|
||||
.task-panel__titles {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
|
||||
h2 {
|
||||
margin: 0;
|
||||
font-size: 18px;
|
||||
line-height: 24px;
|
||||
font-weight: 400;
|
||||
color: #303133;
|
||||
}
|
||||
|
||||
p {
|
||||
margin: 4px 0 0;
|
||||
font-size: 12px;
|
||||
line-height: 18px;
|
||||
color: #909399;
|
||||
}
|
||||
}
|
||||
|
||||
.task-panel__close {
|
||||
width: 24px;
|
||||
height: 24px;
|
||||
flex: none;
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
border: none;
|
||||
border-radius: 4px;
|
||||
background: transparent;
|
||||
color: #909399;
|
||||
cursor: pointer;
|
||||
transition: color 0.2s;
|
||||
|
||||
svg {
|
||||
width: 12px;
|
||||
height: 12px;
|
||||
}
|
||||
|
||||
&:hover {
|
||||
color: #409eff;
|
||||
}
|
||||
}
|
||||
|
||||
/* ===== 主体 ===== */
|
||||
.settings-body {
|
||||
display: flex;
|
||||
height: min(560px, calc(100vh - 220px));
|
||||
min-height: 380px;
|
||||
padding: 4px 16px 0;
|
||||
}
|
||||
|
||||
.settings-nav {
|
||||
width: 208px;
|
||||
flex-shrink: 0;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
padding-right: 12px;
|
||||
border-right: 1px solid #ebeef5;
|
||||
}
|
||||
|
||||
.settings-search {
|
||||
margin-bottom: 8px;
|
||||
}
|
||||
|
||||
.settings-nav-list {
|
||||
flex: 1;
|
||||
overflow: auto;
|
||||
padding-right: 2px;
|
||||
}
|
||||
|
||||
.settings-group + .settings-group {
|
||||
margin-top: 10px;
|
||||
}
|
||||
|
||||
.settings-group-title {
|
||||
font-size: 12px;
|
||||
line-height: 20px;
|
||||
color: #909399;
|
||||
font-weight: 600;
|
||||
padding: 4px 2px;
|
||||
}
|
||||
|
||||
.settings-nav-item {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 8px;
|
||||
min-height: 32px;
|
||||
padding: 0 10px;
|
||||
border-radius: 4px;
|
||||
font-size: 13px;
|
||||
color: #606266;
|
||||
cursor: pointer;
|
||||
transition: background-color 0.2s, color 0.2s;
|
||||
|
||||
&:hover {
|
||||
background: #f5f7fa;
|
||||
}
|
||||
|
||||
&.is-active {
|
||||
background: #ecf5ff;
|
||||
color: #409eff;
|
||||
font-weight: 600;
|
||||
}
|
||||
}
|
||||
|
||||
.settings-nav-title {
|
||||
min-width: 0;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.settings-nav-scope {
|
||||
font-size: 11px;
|
||||
color: #c0c4cc;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.settings-content {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
overflow: auto;
|
||||
padding: 4px 0 0 16px;
|
||||
}
|
||||
|
||||
/* ===== 底部(对齐 task-panel__foot) ===== */
|
||||
.settings-footer {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 12px;
|
||||
padding: 16px;
|
||||
}
|
||||
|
||||
.settings-footer-tip {
|
||||
font-size: 12px;
|
||||
color: #909399;
|
||||
}
|
||||
|
||||
.settings-footer-actions {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
}
|
||||
</style>
|
||||
|
||||
<style lang="scss">
|
||||
/*
|
||||
el-dialog 会被 append 到 body,scoped 选择器命中不到;
|
||||
沿用项目内统一做法:全局块 + 自定义头部(隐藏默认头部)
|
||||
*/
|
||||
.el-dialog.settings-dialog {
|
||||
padding: 0;
|
||||
overflow: hidden;
|
||||
border-radius: 4px;
|
||||
|
||||
.el-dialog__header {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.el-dialog__body {
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.el-dialog__footer {
|
||||
padding: 0;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
98
src/components/settings/registry.ts
Normal file
98
src/components/settings/registry.ts
Normal file
@ -0,0 +1,98 @@
|
||||
/**
|
||||
* 设置中心分区注册表
|
||||
*
|
||||
* - 新增一个设置分区 = 加一条 + 在 sections/ 下新建组件
|
||||
* - `slot: true` 的分区不在此渲染组件,由宿主(UpperTable)通过 #field-section 插槽注入
|
||||
* - 组件全部懒加载,避免设置弹窗拖慢首屏
|
||||
*/
|
||||
import { defineAsyncComponent, type Component } from 'vue'
|
||||
|
||||
export interface SettingsSectionMeta {
|
||||
key: string
|
||||
title: string
|
||||
group: string
|
||||
/** 作用域提示(右侧小字),帮助用户理解"这条配置影响谁" */
|
||||
scopeLabel?: string
|
||||
/** 由宿主通过插槽提供内容(如表格列配置依赖当前表实例) */
|
||||
slot?: boolean
|
||||
component?: Component
|
||||
}
|
||||
|
||||
export const SETTINGS_GROUPS = ['表格', '显示与交互', '性能', '导航', '数据与维护'] as const
|
||||
|
||||
export const SETTINGS_SECTIONS: SettingsSectionMeta[] = [
|
||||
{
|
||||
key: 'field',
|
||||
title: '列表字段',
|
||||
group: '表格',
|
||||
scopeLabel: '当前表格',
|
||||
slot: true
|
||||
},
|
||||
{
|
||||
key: 'tables',
|
||||
title: '所有表格字段',
|
||||
group: '表格',
|
||||
scopeLabel: '账号 + 角色',
|
||||
component: defineAsyncComponent(() => import('./sections/AllTablesSection.vue'))
|
||||
},
|
||||
{
|
||||
key: 'display',
|
||||
title: '界面显示',
|
||||
group: '显示与交互',
|
||||
scopeLabel: '账号 + 角色',
|
||||
component: defineAsyncComponent(() => import('./sections/DisplaySection.vue'))
|
||||
},
|
||||
{
|
||||
key: 'device',
|
||||
title: '设备与打印',
|
||||
group: '显示与交互',
|
||||
scopeLabel: '账号 + 仓库',
|
||||
component: defineAsyncComponent(() => import('./sections/DeviceSection.vue'))
|
||||
},
|
||||
{
|
||||
key: 'performance',
|
||||
title: '表格与性能',
|
||||
group: '性能',
|
||||
scopeLabel: '账号 + 角色',
|
||||
component: defineAsyncComponent(() => import('./sections/PerformanceSection.vue'))
|
||||
},
|
||||
{
|
||||
key: 'cache',
|
||||
title: '页面与标签缓存',
|
||||
group: '性能',
|
||||
scopeLabel: '账号 + 角色',
|
||||
component: defineAsyncComponent(() => import('./sections/CacheSection.vue'))
|
||||
},
|
||||
{
|
||||
key: 'tabOrder',
|
||||
title: '标签排序',
|
||||
group: '导航',
|
||||
scopeLabel: '账号',
|
||||
component: defineAsyncComponent(() => import('./sections/TabOrderSection.vue'))
|
||||
},
|
||||
{
|
||||
key: 'shortcuts',
|
||||
title: '快捷入口',
|
||||
group: '导航',
|
||||
scopeLabel: '账号 + 角色',
|
||||
component: defineAsyncComponent(() => import('./sections/ShortcutsSection.vue'))
|
||||
},
|
||||
{
|
||||
key: 'exportColumns',
|
||||
title: '导出字段',
|
||||
group: '数据与维护',
|
||||
scopeLabel: '账号 + 角色',
|
||||
component: defineAsyncComponent(() => import('./sections/ExportColumnsSection.vue'))
|
||||
},
|
||||
{
|
||||
key: 'data',
|
||||
title: '导入 / 导出与维护',
|
||||
group: '数据与维护',
|
||||
scopeLabel: '本机',
|
||||
component: defineAsyncComponent(() => import('./sections/DataSection.vue'))
|
||||
}
|
||||
]
|
||||
|
||||
export function getSettingsSection(key: string): SettingsSectionMeta | undefined {
|
||||
return SETTINGS_SECTIONS.find((section) => section.key === key)
|
||||
}
|
||||
418
src/components/settings/sections/AllTablesSection.vue
Normal file
418
src/components/settings/sections/AllTablesSection.vue
Normal file
@ -0,0 +1,418 @@
|
||||
<!--
|
||||
表格 → 所有表格字段
|
||||
|
||||
跨页面管理本机已登记的所有表格字段配置(显隐 / 顺序 / 固定 / 恢复默认)。
|
||||
- 数据来源:localStorage `upper_table_columns_{user}_{role}_{tableId}`(页面打开一次后由 UpperTable 自动登记)
|
||||
- 修改即时写入,并通过 tableColumnConfig store 通知当前已打开的表格重建列配置
|
||||
-->
|
||||
<template>
|
||||
<div class="settings-section tables-section">
|
||||
<div class="section-header">
|
||||
<div>
|
||||
<div class="section-title">所有表格字段</div>
|
||||
<div class="section-desc">
|
||||
管理本机已登记的全部表格字段(显隐 / 顺序 / 固定)。页面打开一次后会自动登记到此处。
|
||||
</div>
|
||||
</div>
|
||||
<el-button size="small" @click="reload">刷新列表</el-button>
|
||||
</div>
|
||||
|
||||
<div class="tables-body">
|
||||
<aside class="tables-nav">
|
||||
<el-input
|
||||
v-model="keyword"
|
||||
size="small"
|
||||
placeholder="搜索表格名称 / tableId"
|
||||
clearable
|
||||
class="tables-search"
|
||||
/>
|
||||
<div class="tables-filter">
|
||||
<el-checkbox v-model="onlyCustomized" size="small">仅看已自定义</el-checkbox>
|
||||
<span class="tables-count">{{ filteredProfiles.length }} 张</span>
|
||||
</div>
|
||||
<div class="tables-list">
|
||||
<div
|
||||
v-for="item in filteredProfiles"
|
||||
:key="item.tableId"
|
||||
class="table-item"
|
||||
:class="{ 'is-active': item.tableId === selectedId }"
|
||||
@click="selectedId = item.tableId"
|
||||
>
|
||||
<span class="table-title">{{ item.title || item.tableId }}</span>
|
||||
<el-tag v-if="isColumnCustomized(item)" size="small" effect="plain">已自定义</el-tag>
|
||||
</div>
|
||||
<el-empty v-if="!filteredProfiles.length" description="暂无表格配置" :image-size="60" />
|
||||
</div>
|
||||
</aside>
|
||||
|
||||
<section class="tables-content">
|
||||
<template v-if="current">
|
||||
<div class="tables-head">
|
||||
<div class="tables-head-main">
|
||||
<div class="table-current-title">{{ current.title || current.tableId }}</div>
|
||||
<div class="table-current-id">{{ current.tableId }}</div>
|
||||
</div>
|
||||
<el-tooltip
|
||||
:disabled="hasDefaults"
|
||||
content="该表格尚未记录默认布局,打开一次对应页面后再试"
|
||||
placement="top"
|
||||
>
|
||||
<span>
|
||||
<el-button size="small" :disabled="!hasDefaults" @click="resetCurrent">
|
||||
恢复默认
|
||||
</el-button>
|
||||
</span>
|
||||
</el-tooltip>
|
||||
</div>
|
||||
|
||||
<div v-if="!current.columns.length" class="tables-empty">该表格没有可配置的字段</div>
|
||||
|
||||
<div
|
||||
v-for="section in columnSections"
|
||||
v-else
|
||||
:key="section.key"
|
||||
class="column-section"
|
||||
>
|
||||
<div class="column-section-title">{{ section.title }}</div>
|
||||
<div
|
||||
v-for="(col, idx) in section.items"
|
||||
:key="col.prop"
|
||||
class="column-item"
|
||||
>
|
||||
<el-checkbox
|
||||
:model-value="col.visible"
|
||||
@change="(val: any) => toggleVisible(col.prop, !!val)"
|
||||
>
|
||||
{{ col.label || col.prop }}
|
||||
</el-checkbox>
|
||||
<span class="column-prop">{{ col.prop }}</span>
|
||||
<div class="column-actions">
|
||||
<el-button
|
||||
v-if="section.key === 'scroll'"
|
||||
text
|
||||
size="small"
|
||||
title="固定到左侧"
|
||||
@click="setFixed(col.prop, 'left')"
|
||||
>←</el-button>
|
||||
<el-button
|
||||
v-if="section.key === 'scroll'"
|
||||
text
|
||||
size="small"
|
||||
title="固定到右侧"
|
||||
@click="setFixed(col.prop, 'right')"
|
||||
>→</el-button>
|
||||
<el-button
|
||||
v-if="section.key === 'fixed-left'"
|
||||
text
|
||||
size="small"
|
||||
title="取消左固定"
|
||||
@click="setFixed(col.prop, false)"
|
||||
>→</el-button>
|
||||
<el-button
|
||||
v-if="section.key === 'fixed-right'"
|
||||
text
|
||||
size="small"
|
||||
title="取消右固定"
|
||||
@click="setFixed(col.prop, false)"
|
||||
>←</el-button>
|
||||
<el-button
|
||||
text
|
||||
size="small"
|
||||
:disabled="idx === 0"
|
||||
title="上移"
|
||||
@click="moveColumn(col.prop, -1)"
|
||||
>↑</el-button>
|
||||
<el-button
|
||||
text
|
||||
size="small"
|
||||
:disabled="idx === section.items.length - 1"
|
||||
title="下移"
|
||||
@click="moveColumn(col.prop, 1)"
|
||||
>↓</el-button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
<el-empty v-else description="请从左侧选择一个表格" />
|
||||
</section>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { computed, onMounted, ref } from 'vue'
|
||||
import { ElMessage } from 'element-plus'
|
||||
import { useUserStore } from '@/stores/modules/user'
|
||||
import { useTableColumnConfigStore } from '@/stores/modules/tableColumnConfig'
|
||||
import {
|
||||
cloneColumns,
|
||||
isColumnCustomized,
|
||||
normalizeConfigOrders,
|
||||
partitionConfigColumns,
|
||||
readColumnProfiles,
|
||||
writeColumnProfile,
|
||||
type TableColumnProfile
|
||||
} from '@/utils/table-column-config'
|
||||
|
||||
defineOptions({ name: 'SettingsAllTablesSection' })
|
||||
|
||||
const userStore = useUserStore()
|
||||
const tableColumnConfigStore = useTableColumnConfigStore()
|
||||
|
||||
const profiles = ref<TableColumnProfile[]>([])
|
||||
const keyword = ref('')
|
||||
const onlyCustomized = ref(false)
|
||||
const selectedId = ref('')
|
||||
|
||||
const current = computed(
|
||||
() => profiles.value.find((item) => item.tableId === selectedId.value) || null
|
||||
)
|
||||
|
||||
const hasDefaults = computed(() => !!current.value?.defaultColumns?.length)
|
||||
|
||||
const filteredProfiles = computed(() => {
|
||||
const kw = keyword.value.trim().toLowerCase()
|
||||
return profiles.value.filter((item) => {
|
||||
if (onlyCustomized.value && !isColumnCustomized(item)) return false
|
||||
if (!kw) return true
|
||||
const title = (item.title || '').toLowerCase()
|
||||
return title.includes(kw) || item.tableId.toLowerCase().includes(kw)
|
||||
})
|
||||
})
|
||||
|
||||
const columnSections = computed(() => {
|
||||
const columns = current.value?.columns || []
|
||||
const { left, mid, right } = partitionConfigColumns(columns)
|
||||
return [
|
||||
{ key: 'fixed-left', title: '左侧固定', items: left },
|
||||
{ key: 'scroll', title: '不固定列', items: mid },
|
||||
{ key: 'fixed-right', title: '右侧固定', items: right }
|
||||
].filter((section) => section.items.length > 0)
|
||||
})
|
||||
|
||||
function reload() {
|
||||
const userId = String(userStore.user?.username || userStore.user?.id || 'unknown')
|
||||
const roleId = userStore.roleId || 'default'
|
||||
profiles.value = readColumnProfiles(userId, roleId)
|
||||
|
||||
if (!profiles.value.some((item) => item.tableId === selectedId.value)) {
|
||||
// 优先选中当前页面所在的表格,其次第一张
|
||||
selectedId.value = profiles.value[0]?.tableId || ''
|
||||
}
|
||||
}
|
||||
|
||||
/** 写回当前表格配置,并通知已打开的表格重建 */
|
||||
function persist() {
|
||||
const profile = current.value
|
||||
if (!profile) return
|
||||
profile.columns = normalizeConfigOrders(profile.columns)
|
||||
profile.updatedAt = Date.now()
|
||||
writeColumnProfile(profile)
|
||||
tableColumnConfigStore.touch(profile.tableId)
|
||||
}
|
||||
|
||||
function toggleVisible(prop: string, visible: boolean) {
|
||||
const col = current.value?.columns.find((item) => item.prop === prop)
|
||||
if (!col) return
|
||||
col.visible = visible
|
||||
persist()
|
||||
}
|
||||
|
||||
function moveColumn(prop: string, step: -1 | 1) {
|
||||
const profile = current.value
|
||||
if (!profile) return
|
||||
const { left, mid, right } = partitionConfigColumns(profile.columns)
|
||||
|
||||
const fixed = profile.columns.find((item) => item.prop === prop)?.fixed
|
||||
const section = fixed === 'left' ? left : fixed === 'right' ? right : mid
|
||||
const sectionIndex = section.findIndex((item) => item.prop === prop)
|
||||
if (sectionIndex < 0) return
|
||||
const swapIndex = sectionIndex + step
|
||||
if (swapIndex < 0 || swapIndex >= section.length) return
|
||||
|
||||
const a = section[sectionIndex]!
|
||||
const b = section[swapIndex]!
|
||||
const aOrder = a.order
|
||||
a.order = b.order
|
||||
b.order = aOrder
|
||||
persist()
|
||||
}
|
||||
|
||||
function setFixed(prop: string, position: 'left' | 'right' | false) {
|
||||
const profile = current.value
|
||||
if (!profile) return
|
||||
const col = profile.columns.find((item) => item.prop === prop)
|
||||
if (!col) return
|
||||
col.fixed = position === false ? false : position
|
||||
// 移到目标分区末尾
|
||||
const maxOrder = profile.columns.reduce((max, item) => Math.max(max, item.order), -1)
|
||||
col.order = maxOrder + 1
|
||||
persist()
|
||||
}
|
||||
|
||||
function resetCurrent() {
|
||||
const profile = current.value
|
||||
if (!profile?.defaultColumns?.length) return
|
||||
profile.columns = cloneColumns(profile.defaultColumns)
|
||||
profile.updatedAt = Date.now()
|
||||
writeColumnProfile(profile)
|
||||
tableColumnConfigStore.touch(profile.tableId)
|
||||
ElMessage.success('已恢复该表格的默认字段配置')
|
||||
}
|
||||
|
||||
onMounted(reload)
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
@use './shared.scss';
|
||||
|
||||
.tables-section {
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.tables-body {
|
||||
display: flex;
|
||||
gap: 16px;
|
||||
flex: 1;
|
||||
min-height: 0;
|
||||
}
|
||||
|
||||
.tables-nav {
|
||||
width: 260px;
|
||||
flex-shrink: 0;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
border-right: 1px solid #e8eef7;
|
||||
padding-right: 12px;
|
||||
}
|
||||
|
||||
.tables-search {
|
||||
margin-bottom: 6px;
|
||||
}
|
||||
|
||||
.tables-filter {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
padding: 0 2px 6px;
|
||||
border-bottom: 1px dashed #eef2f8;
|
||||
margin-bottom: 6px;
|
||||
}
|
||||
|
||||
.tables-count {
|
||||
font-size: 12px;
|
||||
color: #909399;
|
||||
}
|
||||
|
||||
.tables-list {
|
||||
flex: 1;
|
||||
overflow: auto;
|
||||
}
|
||||
|
||||
.table-item {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 8px;
|
||||
min-height: 32px;
|
||||
padding: 0 10px;
|
||||
border-radius: 4px;
|
||||
font-size: 13px;
|
||||
color: #606266;
|
||||
cursor: pointer;
|
||||
transition: background-color 0.2s, color 0.2s;
|
||||
|
||||
&:hover {
|
||||
background: #f5f7fa;
|
||||
}
|
||||
|
||||
&.is-active {
|
||||
background: #ecf5ff;
|
||||
color: #409eff;
|
||||
font-weight: 600;
|
||||
}
|
||||
}
|
||||
|
||||
.table-title {
|
||||
min-width: 0;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.tables-content {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
overflow: auto;
|
||||
padding-right: 4px;
|
||||
}
|
||||
|
||||
.tables-head {
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
justify-content: space-between;
|
||||
gap: 12px;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
.table-current-title {
|
||||
font-size: 14px;
|
||||
font-weight: 600;
|
||||
color: #303133;
|
||||
}
|
||||
|
||||
.table-current-id {
|
||||
margin-top: 2px;
|
||||
font-size: 12px;
|
||||
color: #909399;
|
||||
}
|
||||
|
||||
.column-section + .column-section {
|
||||
margin-top: 12px;
|
||||
}
|
||||
|
||||
.column-section-title {
|
||||
font-size: 12px;
|
||||
color: #909399;
|
||||
font-weight: 600;
|
||||
padding: 4px 0;
|
||||
}
|
||||
|
||||
.column-item {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 16px;
|
||||
min-height: 40px;
|
||||
padding: 4px 0 0 12px;
|
||||
border-bottom: 1px solid #f7f8fa;
|
||||
|
||||
&:last-child {
|
||||
border-bottom: none;
|
||||
}
|
||||
|
||||
:deep(.el-checkbox) {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
}
|
||||
}
|
||||
|
||||
.column-prop {
|
||||
font-size: 12px;
|
||||
color: #c0c4cc;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.column-actions {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 2px;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.tables-empty {
|
||||
padding: 32px 0;
|
||||
text-align: center;
|
||||
font-size: 13px;
|
||||
color: #909399;
|
||||
}
|
||||
</style>
|
||||
116
src/components/settings/sections/CacheSection.vue
Normal file
116
src/components/settings/sections/CacheSection.vue
Normal file
@ -0,0 +1,116 @@
|
||||
<!--
|
||||
性能 → 页面与标签缓存
|
||||
数据源:experimental store(localStorage: experimental_{user}_{role})
|
||||
-->
|
||||
<template>
|
||||
<div class="settings-section">
|
||||
<div class="section-header">
|
||||
<div>
|
||||
<div class="section-title">页面与标签缓存</div>
|
||||
<div class="section-desc">控制路由页面与页面内标签页的 KeepAlive 缓存策略(仅影响本机)。</div>
|
||||
</div>
|
||||
<el-button size="small" @click="handleReset">恢复默认</el-button>
|
||||
</div>
|
||||
|
||||
<div class="section-block">
|
||||
<div class="block-title">页面缓存</div>
|
||||
<div class="block-desc">通过顶部导航栏 / 页面 tab 切换的路由页面缓存策略</div>
|
||||
|
||||
<div class="settings-card">
|
||||
<div class="setting-row">
|
||||
<span class="setting-label">页面缓存</span>
|
||||
<el-switch v-model="pageCacheEnabled" />
|
||||
<span class="setting-hint">关闭后切换页面会重新加载</span>
|
||||
</div>
|
||||
<div class="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>
|
||||
</div>
|
||||
|
||||
<div class="section-block">
|
||||
<div class="block-title">tab 缓存</div>
|
||||
<div class="block-desc">含 tab 标签页切换功能页面的 KeepAlive 缓存策略</div>
|
||||
|
||||
<div class="settings-card">
|
||||
<div class="setting-row">
|
||||
<span class="setting-label">tab 缓存</span>
|
||||
<el-switch v-model="tabCacheEnabled" />
|
||||
</div>
|
||||
<div class="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>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { computed } from 'vue'
|
||||
import { ElMessage } from 'element-plus'
|
||||
import {
|
||||
useExperimentalStore,
|
||||
DEFAULT_PAGE_CACHE_MAX,
|
||||
DEFAULT_TAB_CACHE_MAX
|
||||
} from '@/stores/modules/experimental'
|
||||
|
||||
defineOptions({ name: 'SettingsCacheSection' })
|
||||
|
||||
const experimentalStore = useExperimentalStore()
|
||||
|
||||
const pageCacheEnabled = computed({
|
||||
get: () => experimentalStore.pageCacheEnabled,
|
||||
set: (val: boolean) => {
|
||||
experimentalStore.setPageCacheEnabled(val)
|
||||
}
|
||||
})
|
||||
|
||||
const pageCacheMax = computed(() => experimentalStore.pageCacheMax)
|
||||
|
||||
const tabCacheEnabled = computed({
|
||||
get: () => experimentalStore.tabCacheEnabled,
|
||||
set: (val: boolean) => {
|
||||
experimentalStore.setTabCacheEnabled(val)
|
||||
}
|
||||
})
|
||||
|
||||
const tabCacheMax = computed(() => experimentalStore.tabCacheMax)
|
||||
|
||||
function handlePageCacheMaxChange(val: number | undefined) {
|
||||
experimentalStore.setPageCacheMax(Number(val ?? 1))
|
||||
}
|
||||
|
||||
function handleTabCacheMaxChange(val: number | undefined) {
|
||||
experimentalStore.setTabCacheMax(Number(val ?? 1))
|
||||
}
|
||||
|
||||
function handleReset() {
|
||||
experimentalStore.setPageCacheEnabled(true)
|
||||
experimentalStore.setPageCacheMax(DEFAULT_PAGE_CACHE_MAX)
|
||||
experimentalStore.setTabCacheEnabled(true)
|
||||
experimentalStore.setTabCacheMax(DEFAULT_TAB_CACHE_MAX)
|
||||
ElMessage.success('已恢复缓存默认设置')
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
@use './shared.scss';
|
||||
</style>
|
||||
398
src/components/settings/sections/DataSection.vue
Normal file
398
src/components/settings/sections/DataSection.vue
Normal file
@ -0,0 +1,398 @@
|
||||
<!--
|
||||
数据与维护:配置文件导出/导入、恢复默认、故障修复、诊断信息
|
||||
|
||||
- 文件:tbyc-config.json(分区结构,见 docs/统一配置文件-tbyc-config.md)
|
||||
- 导入会覆盖同名配置,保留文件中未涉及的配置项
|
||||
- 字段配置发生变化时向父级发出 columns-changed,由表格重建列配置
|
||||
-->
|
||||
<template>
|
||||
<div class="settings-section">
|
||||
<!-- 配置文件 -->
|
||||
<div class="section-block">
|
||||
<div class="block-title">配置文件</div>
|
||||
<div class="block-desc">
|
||||
导出/导入当前账号在本机的全部可配置项(字段设置、标签排序、界面显示、缓存、快捷键等)。
|
||||
文件名:<code>tbyc-config.json</code>。
|
||||
</div>
|
||||
<div class="block-actions">
|
||||
<el-button size="small" type="primary" @click="handleExport">导出配置</el-button>
|
||||
<el-upload
|
||||
accept=".json"
|
||||
:show-file-list="false"
|
||||
:auto-upload="false"
|
||||
:on-change="handleImport"
|
||||
>
|
||||
<el-button size="small">导入配置</el-button>
|
||||
</el-upload>
|
||||
</div>
|
||||
<div class="block-desc" style="margin-top: 8px; margin-bottom: 0;">
|
||||
导入会覆盖同名配置,不会清空文件中未涉及的项;旧版字段配置文件仍可导入。
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 恢复默认 -->
|
||||
<div class="section-block">
|
||||
<div class="block-title">恢复默认</div>
|
||||
<div class="block-desc">
|
||||
恢复字段设置、界面显示、表格与缓存、标签排序为本机默认值(不影响快捷入口)。
|
||||
</div>
|
||||
<div class="block-actions">
|
||||
<el-button size="small" @click="handleResetAll">恢复全部默认</el-button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 故障修复 -->
|
||||
<div class="section-block">
|
||||
<div class="block-title">故障修复</div>
|
||||
<div class="block-desc">
|
||||
清除当前电脑中此账号的全部字段配置、标签排序、显示设置、表格与缓存设置及快捷键,并恢复默认配置(不可撤销)。
|
||||
</div>
|
||||
<div class="block-actions">
|
||||
<el-button size="small" type="danger" plain @click="handleRepair">故障修复</el-button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 诊断信息 -->
|
||||
<div class="section-block">
|
||||
<div class="block-title">诊断信息</div>
|
||||
<div class="block-desc">反馈问题时可提供以下信息(均为本机浏览器存储,不会上传)。</div>
|
||||
<el-descriptions :column="2" size="small" border>
|
||||
<el-descriptions-item label="账号">{{ identity.userId }}</el-descriptions-item>
|
||||
<el-descriptions-item label="角色">{{ identity.roleId }}</el-descriptions-item>
|
||||
<el-descriptions-item label="仓库">{{ identity.warehouseId || '—' }}</el-descriptions-item>
|
||||
<el-descriptions-item label="配置版本">tbyc-config v{{ TBYC_CONFIG_VERSION }}</el-descriptions-item>
|
||||
<el-descriptions-item label="本机配置占用">{{ storageSizeText }}</el-descriptions-item>
|
||||
<el-descriptions-item label="字段配置">{{ columnProfileCount }} 张表</el-descriptions-item>
|
||||
</el-descriptions>
|
||||
|
||||
<div class="storage-keys">
|
||||
<div v-for="item in storageKeys" :key="item.label" class="storage-key-row">
|
||||
<span class="storage-key-label">{{ item.label }}</span>
|
||||
<code class="storage-key-code">{{ item.key }}</code>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { computed } from 'vue'
|
||||
import { ElMessage, ElMessageBox } from 'element-plus'
|
||||
import type { UploadFile } from 'element-plus'
|
||||
import defaultSettings from '@/settings'
|
||||
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 { useUserPreferenceStore } from '@/stores/modules/userPreference'
|
||||
import { TAB_ORDER_SCOPE } from '@/utils/tab-order'
|
||||
import {
|
||||
TBYC_CONFIG_FILENAME,
|
||||
TBYC_CONFIG_VERSION,
|
||||
buildTbycConfig,
|
||||
downloadJsonFile,
|
||||
isTbycConfig
|
||||
} from '@/utils/tbyc-config'
|
||||
import { TBYC_CONFIG_SECTIONS, getTbycConfigSection } from '@/config/tbyc-config-sections'
|
||||
|
||||
defineOptions({ name: 'SettingsDataSection' })
|
||||
|
||||
const emit = defineEmits<{
|
||||
/** 字段配置(列配置)发生变化,需要表格重建列 */
|
||||
(e: 'columns-changed'): void
|
||||
}>()
|
||||
|
||||
const userStore = useUserStore()
|
||||
const settingsStore = useSettingsStore()
|
||||
const shortcutsStore = useShortcutsStore()
|
||||
const experimentalStore = useExperimentalStore()
|
||||
const preferenceStore = useUserPreferenceStore()
|
||||
|
||||
/** 当前身份(与各处存储 key 规则保持一致) */
|
||||
const identity = computed(() => {
|
||||
const user = userStore.user || {}
|
||||
const userId = String(user.username || user.id || 'unknown')
|
||||
const roleId = String(userStore.roleId || 'default')
|
||||
const warehouseId = String(user.warehouse_id ?? user.store_id ?? '')
|
||||
return { userId, roleId, warehouseId }
|
||||
})
|
||||
|
||||
const columnPrefix = computed(
|
||||
() => `upper_table_columns_${identity.value.userId}_${identity.value.roleId}_`
|
||||
)
|
||||
|
||||
const settingsKey = computed(() => `settings_${identity.value.userId}_${identity.value.roleId}`)
|
||||
const experimentalKey = computed(
|
||||
() => `experimental_${identity.value.userId}_${identity.value.roleId}`
|
||||
)
|
||||
const shortcutsKey = computed(() => `shortcuts_${identity.value.userId}_${identity.value.roleId}`)
|
||||
const preferenceKey = computed(() =>
|
||||
identity.value.warehouseId
|
||||
? `user_prefs_${identity.value.userId}_${identity.value.warehouseId}`
|
||||
: `user_prefs_${identity.value.userId}`
|
||||
)
|
||||
|
||||
const storageKeys = computed(() => [
|
||||
{ label: '字段配置', key: `${columnPrefix.value}*` },
|
||||
{ label: '显示设置', key: settingsKey.value },
|
||||
{ label: '表格与缓存', key: experimentalKey.value },
|
||||
{ label: '快捷键', key: shortcutsKey.value },
|
||||
{ label: '用户偏好(标签排序/打印)', key: preferenceKey.value }
|
||||
])
|
||||
|
||||
/** 当前身份下占用的 localStorage 体积(字节) */
|
||||
const storageSize = computed(() => {
|
||||
let bytes = 0
|
||||
try {
|
||||
Object.keys(localStorage).forEach((key) => {
|
||||
if (!storageKeys.value.some((item) => key.startsWith(item.key.replace(/\*$/, '')))) return
|
||||
bytes += (localStorage.getItem(key) || '').length
|
||||
})
|
||||
} catch {
|
||||
// 忽略存储不可用
|
||||
}
|
||||
return bytes
|
||||
})
|
||||
|
||||
const storageSizeText = computed(() => {
|
||||
const kb = storageSize.value / 1024
|
||||
return kb >= 1 ? `${kb.toFixed(1)} KB` : `${storageSize.value} B`
|
||||
})
|
||||
|
||||
const columnProfileCount = computed(() => {
|
||||
let count = 0
|
||||
try {
|
||||
Object.keys(localStorage).forEach((key) => {
|
||||
if (key.startsWith(columnPrefix.value)) count += 1
|
||||
})
|
||||
} catch {
|
||||
// 忽略
|
||||
}
|
||||
return count
|
||||
})
|
||||
|
||||
/* ==================== 导出 ==================== */
|
||||
function collectSections(): Record<string, unknown> {
|
||||
const sections: Record<string, unknown> = {}
|
||||
TBYC_CONFIG_SECTIONS.forEach((section) => {
|
||||
try {
|
||||
const data = section.collect()
|
||||
if (data === undefined || data === null) return
|
||||
sections[section.key] = data
|
||||
} catch (error) {
|
||||
console.error(`[tbyc-config] collect ${section.key} failed:`, error)
|
||||
}
|
||||
})
|
||||
return sections
|
||||
}
|
||||
|
||||
function handleExport() {
|
||||
const sections = collectSections()
|
||||
if (!Object.keys(sections).length) {
|
||||
ElMessage.warning('当前没有可导出的配置')
|
||||
return
|
||||
}
|
||||
downloadJsonFile(
|
||||
TBYC_CONFIG_FILENAME,
|
||||
buildTbycConfig(
|
||||
{ userId: identity.value.userId, roleId: identity.value.roleId },
|
||||
sections
|
||||
)
|
||||
)
|
||||
ElMessage.success('配置文件已导出')
|
||||
}
|
||||
|
||||
/* ==================== 导入 ==================== */
|
||||
/**
|
||||
* 解析导入文件 → 分区数据
|
||||
* - 新格式:{ format: 'tbyc-config', sections: { ... } }
|
||||
* - 旧格式:{ tables | tableId/columns } + { tabOrders }(兼容旧版「全局字段配置」导出文件)
|
||||
*/
|
||||
function resolveConfigSections(parsed: any): Record<string, unknown> {
|
||||
if (!parsed || typeof parsed !== 'object') return {}
|
||||
if (isTbycConfig(parsed) || (parsed.sections && typeof parsed.sections === 'object')) {
|
||||
return parsed.sections || {}
|
||||
}
|
||||
|
||||
const sections: Record<string, unknown> = {}
|
||||
if (Array.isArray(parsed.tables)) {
|
||||
sections.fieldColumns = parsed.tables
|
||||
} else if (parsed.tableId && Array.isArray(parsed.columns)) {
|
||||
sections.fieldColumns = [
|
||||
{ tableId: parsed.tableId, columns: parsed.columns, schemaVersion: parsed.schemaVersion }
|
||||
]
|
||||
}
|
||||
if (parsed.tabOrders) sections.tabOrder = parsed.tabOrders
|
||||
return sections
|
||||
}
|
||||
|
||||
function applySections(sections: Record<string, unknown>): string[] {
|
||||
const applied: string[] = []
|
||||
let columnsChanged = false
|
||||
|
||||
TBYC_CONFIG_SECTIONS.forEach((section) => {
|
||||
if (!(section.key in sections)) return
|
||||
try {
|
||||
const count = section.apply(sections[section.key])
|
||||
if (count > 0) {
|
||||
applied.push(`${section.title} ${count} 项`)
|
||||
if (section.key === 'fieldColumns') columnsChanged = true
|
||||
}
|
||||
} catch (error) {
|
||||
console.error(`[tbyc-config] apply ${section.key} failed:`, error)
|
||||
}
|
||||
})
|
||||
|
||||
if (columnsChanged) emit('columns-changed')
|
||||
return applied
|
||||
}
|
||||
|
||||
function handleImport(file: UploadFile) {
|
||||
if (!file.raw) return
|
||||
const reader = new FileReader()
|
||||
reader.onload = () => {
|
||||
try {
|
||||
const parsed = JSON.parse(String(reader.result || '{}'))
|
||||
const sections = resolveConfigSections(parsed)
|
||||
const sectionKeys = Object.keys(sections)
|
||||
if (!sectionKeys.length) {
|
||||
ElMessage.error('未找到可导入的配置')
|
||||
return
|
||||
}
|
||||
|
||||
const applied = applySections(sections)
|
||||
// 来自更新版本的未知分区:只提示,不阻断其它配置导入
|
||||
const unknownCount = sectionKeys.filter((key) => !getTbycConfigSection(key)).length
|
||||
|
||||
if (!applied.length) {
|
||||
ElMessage.error(unknownCount ? '配置文件中的配置项当前版本不支持' : '未找到可导入的配置')
|
||||
return
|
||||
}
|
||||
|
||||
const suffix = unknownCount ? `(${unknownCount} 个未知配置项已忽略)` : ''
|
||||
ElMessage.success(`配置导入成功:${applied.join('、')}${suffix}`)
|
||||
} catch {
|
||||
ElMessage.error('配置文件解析失败')
|
||||
}
|
||||
}
|
||||
reader.readAsText(file.raw)
|
||||
}
|
||||
|
||||
/* ==================== 恢复默认 / 故障修复 ==================== */
|
||||
function removeKeysByPrefix(prefix: string): number {
|
||||
const removeKeys: string[] = []
|
||||
Object.keys(localStorage).forEach((key) => {
|
||||
if (key.startsWith(prefix)) removeKeys.push(key)
|
||||
})
|
||||
removeKeys.forEach((key) => localStorage.removeItem(key))
|
||||
return removeKeys.length
|
||||
}
|
||||
|
||||
async function handleResetAll() {
|
||||
try {
|
||||
await ElMessageBox.confirm(
|
||||
'将恢复字段设置、界面显示、表格与缓存、标签排序为本机默认值(快捷入口不受影响)。是否继续?',
|
||||
'恢复全部默认',
|
||||
{ type: 'warning', buttonSize: 'small', confirmButtonText: '恢复', cancelButtonText: '取消' }
|
||||
)
|
||||
} catch {
|
||||
return
|
||||
}
|
||||
|
||||
removeKeysByPrefix(columnPrefix.value)
|
||||
settingsStore.resetDisplaySettings()
|
||||
experimentalStore.resetToDefaults()
|
||||
preferenceStore.resetGlobal(TAB_ORDER_SCOPE)
|
||||
|
||||
emit('columns-changed')
|
||||
ElMessage.success('已恢复全部默认配置')
|
||||
}
|
||||
|
||||
async function handleRepair() {
|
||||
try {
|
||||
await ElMessageBox.confirm(
|
||||
'故障修复会清除当前电脑中此账号的全部字段配置、标签排序、显示设置、表格与缓存设置及快捷键,并恢复所有默认配置。是否继续?',
|
||||
'确认故障修复',
|
||||
{ type: 'warning', buttonSize: 'small', confirmButtonText: '确认清除', cancelButtonText: '取消' }
|
||||
)
|
||||
await ElMessageBox.confirm(
|
||||
'请再次确认:该操作不可撤销,确定清除所有配置吗?',
|
||||
'二次确认',
|
||||
{ type: 'warning', buttonSize: 'small', confirmButtonText: '确定', cancelButtonText: '返回' }
|
||||
)
|
||||
} catch {
|
||||
return
|
||||
}
|
||||
|
||||
// 1. 字段配置
|
||||
const columnCount = removeKeysByPrefix(columnPrefix.value)
|
||||
|
||||
// 2. 显示设置
|
||||
const hadSettings = localStorage.getItem(settingsKey.value) !== null
|
||||
localStorage.removeItem(settingsKey.value)
|
||||
settingsStore.changeSetting({ key: 'showSettings', value: defaultSettings.showSettings })
|
||||
settingsStore.changeSetting({ key: 'tagsView', value: defaultSettings.tagsView })
|
||||
settingsStore.changeSetting({ key: 'fixedHeader', value: defaultSettings.fixedHeader })
|
||||
settingsStore.changeSetting({ key: 'sidebarLogo', value: defaultSettings.sidebarLogo })
|
||||
settingsStore.changeSetting({ key: 'layoutMode', value: 'top-bottom' })
|
||||
settingsStore.changeSetting({ key: 'shortcutExpanded', value: defaultSettings.shortcutExpanded })
|
||||
settingsStore.changeSetting({ key: 'toolbarMode', value: defaultSettings.toolbarMode })
|
||||
settingsStore.changeSetting({ key: 'scanBoxMode', value: defaultSettings.scanBoxMode })
|
||||
|
||||
// 3. 表格与缓存
|
||||
const hadExperimental = localStorage.getItem(experimentalKey.value) !== null
|
||||
experimentalStore.resetToDefaults()
|
||||
|
||||
// 4. 快捷键
|
||||
const hadShortcuts = localStorage.getItem(shortcutsKey.value) !== null
|
||||
localStorage.removeItem(shortcutsKey.value)
|
||||
shortcutsStore.shortcuts = []
|
||||
|
||||
// 5. 标签排序 / 默认页签(用户级)
|
||||
const hadTabOrder = !!preferenceStore.getGlobal(TAB_ORDER_SCOPE)
|
||||
if (hadTabOrder) preferenceStore.resetGlobal(TAB_ORDER_SCOPE)
|
||||
|
||||
emit('columns-changed')
|
||||
|
||||
const parts: string[] = []
|
||||
if (columnCount > 0) parts.push(`${columnCount} 个字段配置`)
|
||||
if (hadSettings) parts.push('显示设置')
|
||||
if (hadExperimental) parts.push('表格与缓存')
|
||||
if (hadShortcuts) parts.push('快捷键')
|
||||
if (hadTabOrder) parts.push('标签排序')
|
||||
ElMessage.success(`故障修复完成${parts.length ? ',已恢复 ' + parts.join('、') : ''}`)
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
@use './shared.scss';
|
||||
|
||||
.storage-keys {
|
||||
margin-top: 10px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 4px;
|
||||
}
|
||||
|
||||
.storage-key-row {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.storage-key-label {
|
||||
width: 160px;
|
||||
flex-shrink: 0;
|
||||
color: #909399;
|
||||
}
|
||||
|
||||
.storage-key-code {
|
||||
font-size: 12px;
|
||||
color: #606266;
|
||||
background: #f5f7fa;
|
||||
border-radius: 4px;
|
||||
padding: 1px 6px;
|
||||
word-break: break-all;
|
||||
}
|
||||
</style>
|
||||
30
src/components/settings/sections/DeviceSection.vue
Normal file
30
src/components/settings/sections/DeviceSection.vue
Normal file
@ -0,0 +1,30 @@
|
||||
<!--
|
||||
显示与交互 → 设备与打印
|
||||
|
||||
打印组件连接状态与失败自动重连配置(用户 + 仓库维度)。
|
||||
复用业务侧已有的连接面板,避免两套逻辑。
|
||||
-->
|
||||
<template>
|
||||
<div class="settings-section">
|
||||
<div class="section-header">
|
||||
<div>
|
||||
<div class="section-title">设备与打印</div>
|
||||
<div class="section-desc">
|
||||
打印组件连接状态与失败自动重连策略(按账号 + 仓库保存)。修改即时生效,不会断开已连接组件。
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<PrinterComponentConnectionPanel />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import PrinterComponentConnectionPanel from '@/views/order/waveOrder/component/PrinterComponentConnectionPanel.vue'
|
||||
|
||||
defineOptions({ name: 'SettingsDeviceSection' })
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
@use './shared.scss';
|
||||
</style>
|
||||
134
src/components/settings/sections/DisplaySection.vue
Normal file
134
src/components/settings/sections/DisplaySection.vue
Normal file
@ -0,0 +1,134 @@
|
||||
<!--
|
||||
显示与交互 → 界面显示
|
||||
数据源:settings store(localStorage: settings_{user}_{role})
|
||||
-->
|
||||
<template>
|
||||
<div class="settings-section">
|
||||
<div class="section-header">
|
||||
<div>
|
||||
<div class="section-title">界面显示</div>
|
||||
<div class="section-desc">以下选项保存在当前浏览器,仅影响本机显示,换电脑需重新设置。</div>
|
||||
</div>
|
||||
<el-button size="small" @click="handleReset">恢复默认</el-button>
|
||||
</div>
|
||||
|
||||
<div class="settings-card">
|
||||
<div class="setting-row">
|
||||
<span class="setting-label">布局模式</span>
|
||||
<el-radio-group v-model="layoutMode" size="small">
|
||||
<el-radio value="top-bottom">顶部导航(默认)</el-radio>
|
||||
<el-radio value="sidebar">侧边栏</el-radio>
|
||||
</el-radio-group>
|
||||
<span class="setting-hint">切换后立即生效</span>
|
||||
</div>
|
||||
|
||||
<div class="setting-row">
|
||||
<span class="setting-label">固定头部</span>
|
||||
<el-switch v-model="fixedHeader" />
|
||||
<span class="setting-hint">滚动时导航栏保持可见</span>
|
||||
</div>
|
||||
|
||||
<div class="setting-row">
|
||||
<span class="setting-label">侧栏 Logo</span>
|
||||
<el-switch v-model="sidebarLogo" />
|
||||
<span class="setting-hint">侧边栏模式下是否显示 Logo</span>
|
||||
</div>
|
||||
|
||||
<div class="setting-row">
|
||||
<span class="setting-label">Scan-box 显示模式</span>
|
||||
<el-radio-group v-model="scanBoxMode" size="small">
|
||||
<el-radio value="compact">紧凑(默认)</el-radio>
|
||||
<el-radio value="standard">标准</el-radio>
|
||||
</el-radio-group>
|
||||
<span class="setting-hint">紧凑模式行高更小,一屏显示更多筛选条件</span>
|
||||
</div>
|
||||
|
||||
<div class="setting-row">
|
||||
<span class="setting-label">工具栏按钮模式</span>
|
||||
<el-radio-group v-model="toolbarMode" size="small">
|
||||
<el-radio value="tile">平铺(默认)</el-radio>
|
||||
<el-radio value="collapse">折叠</el-radio>
|
||||
</el-radio-group>
|
||||
<span class="setting-hint">工具栏按钮组的排列方式</span>
|
||||
</div>
|
||||
|
||||
<div class="setting-row">
|
||||
<span class="setting-label">快捷键区域</span>
|
||||
<el-switch v-model="shortcutExpanded" />
|
||||
<span class="setting-hint">展开顶部快捷键面板(默认收起)</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { computed } from 'vue'
|
||||
import { ElMessage, ElMessageBox } from 'element-plus'
|
||||
import { useSettingsStore } from '@/stores/modules/settings'
|
||||
import defaultSettings from '@/settings'
|
||||
|
||||
defineOptions({ name: 'SettingsDisplaySection' })
|
||||
|
||||
const settingsStore = useSettingsStore()
|
||||
|
||||
const layoutMode = computed({
|
||||
get: () => settingsStore.layoutMode,
|
||||
set: (mode: 'sidebar' | 'top-bottom') => {
|
||||
settingsStore.changeSetting({ key: 'layoutMode', value: mode })
|
||||
}
|
||||
})
|
||||
|
||||
const fixedHeader = computed({
|
||||
get: () => settingsStore.fixedHeader,
|
||||
set: (value: boolean) => {
|
||||
settingsStore.changeSetting({ key: 'fixedHeader', value })
|
||||
}
|
||||
})
|
||||
|
||||
const sidebarLogo = computed({
|
||||
get: () => settingsStore.sidebarLogo,
|
||||
set: (value: boolean) => {
|
||||
settingsStore.changeSetting({ key: 'sidebarLogo', value })
|
||||
}
|
||||
})
|
||||
|
||||
const scanBoxMode = computed({
|
||||
get: () => settingsStore.scanBoxMode,
|
||||
set: (mode: 'standard' | 'compact') => {
|
||||
settingsStore.changeSetting({ key: 'scanBoxMode', value: mode })
|
||||
}
|
||||
})
|
||||
|
||||
const toolbarMode = computed({
|
||||
get: () => settingsStore.toolbarMode,
|
||||
set: (mode: 'tile' | 'collapse') => {
|
||||
settingsStore.changeSetting({ key: 'toolbarMode', value: mode })
|
||||
}
|
||||
})
|
||||
|
||||
const shortcutExpanded = computed({
|
||||
get: () => settingsStore.shortcutExpanded,
|
||||
set: (expanded: boolean) => {
|
||||
settingsStore.changeSetting({ key: 'shortcutExpanded', value: expanded })
|
||||
}
|
||||
})
|
||||
|
||||
function handleReset() {
|
||||
ElMessageBox.confirm(
|
||||
'将恢复界面显示为默认:顶部导航、固定头部开启、侧栏 Logo 开启、Scan-box 紧凑模式、工具栏平铺、快捷键区域收起。',
|
||||
'恢复默认',
|
||||
{ type: 'warning', confirmButtonText: '恢复', cancelButtonText: '取消' }
|
||||
)
|
||||
.then(() => {
|
||||
settingsStore.resetDisplaySettings()
|
||||
settingsStore.changeSetting({ key: 'fixedHeader', value: defaultSettings.fixedHeader })
|
||||
settingsStore.changeSetting({ key: 'sidebarLogo', value: defaultSettings.sidebarLogo })
|
||||
ElMessage.success('已恢复界面显示默认值')
|
||||
})
|
||||
.catch(() => {})
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
@use './shared.scss';
|
||||
</style>
|
||||
400
src/components/settings/sections/ExportColumnsSection.vue
Normal file
400
src/components/settings/sections/ExportColumnsSection.vue
Normal file
@ -0,0 +1,400 @@
|
||||
<!--
|
||||
数据与维护 → 导出字段
|
||||
|
||||
管理订单管理各子页「导出全部(不含明细)」使用的导出字段。
|
||||
- 存储:localStorage `order_export_columns_{user}_{role}_{scopeKey}_waybill`
|
||||
(与 OrderExportColumnsDialog 完全一致,导出弹窗打开时读取)
|
||||
- 未配置时默认全选;「恢复默认」= 删除该页配置,回到全选
|
||||
- 修改即时保存,下次打开导出弹窗生效
|
||||
-->
|
||||
<template>
|
||||
<div class="settings-section export-section">
|
||||
<div class="section-header">
|
||||
<div>
|
||||
<div class="section-title">导出字段</div>
|
||||
<div class="section-desc">
|
||||
订单管理各页「导出(不含明细)」的导出字段(导出全部 / 导出选中共用同一份配置);未配置时默认全选,修改即时保存,下次打开导出窗口生效。
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="export-body">
|
||||
<aside class="export-nav">
|
||||
<div class="export-nav-list">
|
||||
<div
|
||||
v-for="page in pageList"
|
||||
:key="page.name"
|
||||
class="page-item"
|
||||
:class="{ 'is-active': page.name === selectedPage }"
|
||||
@click="selectedPage = page.name"
|
||||
>
|
||||
<span class="page-title">{{ page.label }}</span>
|
||||
<el-tag v-if="isConfigured(page.name)" size="small" effect="plain">已配置</el-tag>
|
||||
</div>
|
||||
</div>
|
||||
</aside>
|
||||
|
||||
<section class="export-content">
|
||||
<div class="export-toolbar">
|
||||
<el-input
|
||||
v-model="keyword"
|
||||
placeholder="搜索字段"
|
||||
clearable
|
||||
size="small"
|
||||
class="export-search"
|
||||
>
|
||||
<template #prefix>
|
||||
<el-icon><Search /></el-icon>
|
||||
</template>
|
||||
</el-input>
|
||||
<el-checkbox
|
||||
:model-value="isAllSelected"
|
||||
:indeterminate="isIndeterminate"
|
||||
@change="handleToggleAll"
|
||||
>
|
||||
全选
|
||||
</el-checkbox>
|
||||
<el-button size="small" link type="primary" @click="handleReverse">反选</el-button>
|
||||
<el-button size="small" link type="danger" @click="handleClear">清空</el-button>
|
||||
<span class="export-count">已选 {{ selected.length }} / {{ allFields.length }}</span>
|
||||
<el-button size="small" link @click="resetCurrent">恢复默认(全选)</el-button>
|
||||
</div>
|
||||
|
||||
<div class="export-groups">
|
||||
<div v-for="group in visibleGroups" :key="group.name" class="export-group">
|
||||
<div class="export-group-head">
|
||||
<span class="export-group-name">{{ group.name }}</span>
|
||||
<el-checkbox
|
||||
size="small"
|
||||
:model-value="isGroupSelected(group.name)"
|
||||
:indeterminate="isGroupIndeterminate(group.name)"
|
||||
@change="(v: string | number | boolean) => handleToggleGroup(group.name, v)"
|
||||
>
|
||||
全选
|
||||
</el-checkbox>
|
||||
<span class="export-group-count">
|
||||
{{ getGroupSelectedCount(group.name) }}/{{ group.fields.length }}
|
||||
</span>
|
||||
</div>
|
||||
<div class="export-group-list">
|
||||
<el-checkbox-group :model-value="selected" @update:model-value="handleSelectedChange">
|
||||
<el-checkbox
|
||||
v-for="field in group.fields"
|
||||
:key="field"
|
||||
:value="field"
|
||||
class="export-field-item"
|
||||
>
|
||||
{{ field }}
|
||||
</el-checkbox>
|
||||
</el-checkbox-group>
|
||||
</div>
|
||||
</div>
|
||||
<el-empty v-if="!visibleGroups.length" description="未找到匹配的字段" :image-size="60" />
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { computed, ref, watch } from 'vue'
|
||||
import { Search } from '@element-plus/icons-vue'
|
||||
import { useUserStore } from '@/stores/modules/user'
|
||||
import {
|
||||
ORDER_TAB_LIST,
|
||||
getOrderExportColumnGroupsByMode,
|
||||
type OrderExportColumnMode
|
||||
} from '@/views/order/orderManagement/config/order-common-config'
|
||||
import { ORDER_INDEX_EXPORT_SCOPES } from '@/views/order/shared/orderListExport'
|
||||
|
||||
defineOptions({ name: 'SettingsExportColumnsSection' })
|
||||
|
||||
const userStore = useUserStore()
|
||||
|
||||
/** 本分区本期只覆盖「导出全部(不含明细)」= waybill 模式 */
|
||||
const EXPORT_MODE: OrderExportColumnMode = 'waybill'
|
||||
|
||||
/** 可配置的订单子页(与导出弹窗的 scopeKey 一一对应) */
|
||||
const pageList = ORDER_TAB_LIST.filter((page) => page.name in ORDER_INDEX_EXPORT_SCOPES)
|
||||
|
||||
const allFields = computed(() => {
|
||||
const groups = getOrderExportColumnGroupsByMode(EXPORT_MODE)
|
||||
return groups.flatMap((group) => group.fields)
|
||||
})
|
||||
|
||||
const columnGroups = computed(() => getOrderExportColumnGroupsByMode(EXPORT_MODE))
|
||||
|
||||
const selectedPage = ref(pageList[0]?.name || '')
|
||||
const selected = ref<string[]>([])
|
||||
const keyword = ref('')
|
||||
/** 触发 localStorage 重新读取(localStorage 本身不是响应式) */
|
||||
const version = ref(0)
|
||||
|
||||
function storageKeyOf(pageName: string): string {
|
||||
const userId = userStore.user?.username || userStore.user?.id || 'unknown'
|
||||
const roleId = userStore.roleId || 'default'
|
||||
return `order_export_columns_${userId}_${roleId}_${pageName}_${EXPORT_MODE}`
|
||||
}
|
||||
|
||||
function isConfigured(pageName: string): boolean {
|
||||
void version.value
|
||||
try {
|
||||
return localStorage.getItem(storageKeyOf(pageName)) !== null
|
||||
} catch {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
function loadForPage(pageName: string) {
|
||||
const valid = new Set(allFields.value)
|
||||
let saved: string[] | null = null
|
||||
let hasConfig = false
|
||||
try {
|
||||
const raw = localStorage.getItem(storageKeyOf(pageName))
|
||||
if (raw !== null) {
|
||||
hasConfig = true
|
||||
const parsed = JSON.parse(raw)
|
||||
if (Array.isArray(parsed)) {
|
||||
saved = parsed.filter((field): field is string => typeof field === 'string' && valid.has(field))
|
||||
}
|
||||
}
|
||||
} catch {
|
||||
hasConfig = false
|
||||
saved = null
|
||||
}
|
||||
// 未配置 → 默认全选;已配置(即使为空数组)→ 以配置为准
|
||||
selected.value = hasConfig ? saved || [] : allFields.value.slice()
|
||||
}
|
||||
|
||||
watch(
|
||||
[selectedPage, version],
|
||||
() => {
|
||||
if (selectedPage.value) loadForPage(selectedPage.value)
|
||||
},
|
||||
{ immediate: true }
|
||||
)
|
||||
|
||||
/** 任何勾选变化 → 立即写入该页配置 */
|
||||
function persist(next: string[]) {
|
||||
if (!selectedPage.value) return
|
||||
const valid = new Set(allFields.value)
|
||||
const fields = next.filter((field) => valid.has(field))
|
||||
try {
|
||||
localStorage.setItem(storageKeyOf(selectedPage.value), JSON.stringify(fields))
|
||||
} catch {
|
||||
// localStorage 不可用时静默失败
|
||||
}
|
||||
version.value += 1
|
||||
}
|
||||
|
||||
function handleSelectedChange(value: string[] | string | number | boolean | undefined) {
|
||||
const next = Array.isArray(value) ? value : []
|
||||
selected.value = next
|
||||
persist(next)
|
||||
}
|
||||
|
||||
const visibleGroups = computed(() => {
|
||||
const kw = keyword.value.trim().toLowerCase()
|
||||
if (!kw) return columnGroups.value
|
||||
return columnGroups.value
|
||||
.map((group) => ({ ...group, fields: group.fields.filter((field) => field.toLowerCase().includes(kw)) }))
|
||||
.filter((group) => group.fields.length > 0)
|
||||
})
|
||||
|
||||
const isAllSelected = computed(
|
||||
() => allFields.value.length > 0 && selected.value.length === allFields.value.length
|
||||
)
|
||||
const isIndeterminate = computed(() => selected.value.length > 0 && !isAllSelected.value)
|
||||
|
||||
function getGroupFields(groupName: string): string[] {
|
||||
return columnGroups.value.find((group) => group.name === groupName)?.fields || []
|
||||
}
|
||||
|
||||
function getGroupSelectedCount(groupName: string): number {
|
||||
const fields = getGroupFields(groupName)
|
||||
return selected.value.filter((field) => fields.includes(field)).length
|
||||
}
|
||||
|
||||
function isGroupSelected(groupName: string): boolean {
|
||||
const fields = getGroupFields(groupName)
|
||||
return fields.length > 0 && fields.every((field) => selected.value.includes(field))
|
||||
}
|
||||
|
||||
function isGroupIndeterminate(groupName: string): boolean {
|
||||
const count = getGroupSelectedCount(groupName)
|
||||
return count > 0 && !isGroupSelected(groupName)
|
||||
}
|
||||
|
||||
function handleToggleGroup(groupName: string, value: string | number | boolean) {
|
||||
const fields = getGroupFields(groupName)
|
||||
const set = new Set(selected.value)
|
||||
if (Boolean(value)) fields.forEach((field) => set.add(field))
|
||||
else fields.forEach((field) => set.delete(field))
|
||||
const next = allFields.value.filter((field) => set.has(field))
|
||||
selected.value = next
|
||||
persist(next)
|
||||
}
|
||||
|
||||
function handleToggleAll() {
|
||||
const next = isAllSelected.value ? [] : allFields.value.slice()
|
||||
selected.value = next
|
||||
persist(next)
|
||||
}
|
||||
|
||||
function handleReverse() {
|
||||
const current = new Set(selected.value)
|
||||
const next = allFields.value.filter((field) => !current.has(field))
|
||||
selected.value = next
|
||||
persist(next)
|
||||
}
|
||||
|
||||
function handleClear() {
|
||||
selected.value = []
|
||||
persist([])
|
||||
}
|
||||
|
||||
/** 恢复默认:删除该页配置(导出弹窗默认全选) */
|
||||
function resetCurrent() {
|
||||
if (!selectedPage.value) return
|
||||
try {
|
||||
localStorage.removeItem(storageKeyOf(selectedPage.value))
|
||||
} catch {
|
||||
// 忽略
|
||||
}
|
||||
selected.value = allFields.value.slice()
|
||||
version.value += 1
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
@use './shared.scss';
|
||||
|
||||
.export-section {
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.export-body {
|
||||
display: flex;
|
||||
gap: 16px;
|
||||
flex: 1;
|
||||
min-height: 0;
|
||||
}
|
||||
|
||||
.export-nav {
|
||||
width: 208px;
|
||||
flex-shrink: 0;
|
||||
padding-right: 12px;
|
||||
border-right: 1px solid #ebeef5;
|
||||
overflow: auto;
|
||||
}
|
||||
|
||||
.export-nav-list {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 2px;
|
||||
}
|
||||
|
||||
.page-item {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 8px;
|
||||
min-height: 32px;
|
||||
padding: 0 10px;
|
||||
border-radius: 4px;
|
||||
font-size: 13px;
|
||||
color: #606266;
|
||||
cursor: pointer;
|
||||
transition: background-color 0.2s, color 0.2s;
|
||||
|
||||
&:hover {
|
||||
background: #f5f7fa;
|
||||
}
|
||||
|
||||
&.is-active {
|
||||
background: #ecf5ff;
|
||||
color: #409eff;
|
||||
font-weight: 600;
|
||||
}
|
||||
}
|
||||
|
||||
.page-title {
|
||||
min-width: 0;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.export-content {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
min-height: 0;
|
||||
}
|
||||
|
||||
.export-toolbar {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 12px;
|
||||
flex-wrap: wrap;
|
||||
padding: 0 0 8px 12px;
|
||||
}
|
||||
|
||||
.export-search {
|
||||
width: 200px;
|
||||
}
|
||||
|
||||
.export-count {
|
||||
font-size: 12px;
|
||||
color: #909399;
|
||||
}
|
||||
|
||||
.export-groups {
|
||||
flex: 1;
|
||||
min-height: 0;
|
||||
overflow: auto;
|
||||
padding: 0 0 8px 12px;
|
||||
}
|
||||
|
||||
.export-group + .export-group {
|
||||
margin-top: 10px;
|
||||
}
|
||||
|
||||
.export-group-head {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 12px;
|
||||
padding: 2px 0;
|
||||
}
|
||||
|
||||
.export-group-name {
|
||||
font-size: 13px;
|
||||
font-weight: 600;
|
||||
color: #303133;
|
||||
}
|
||||
|
||||
.export-group-count {
|
||||
font-size: 12px;
|
||||
color: #909399;
|
||||
}
|
||||
|
||||
.export-group-list {
|
||||
:deep(.el-checkbox-group) {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(3, minmax(0, 1fr));
|
||||
column-gap: 12px;
|
||||
row-gap: 2px;
|
||||
margin-top: 2px;
|
||||
}
|
||||
|
||||
:deep(.el-checkbox) {
|
||||
margin-right: 0;
|
||||
height: 30px;
|
||||
}
|
||||
}
|
||||
|
||||
.export-field-item {
|
||||
font-size: 13px;
|
||||
}
|
||||
</style>
|
||||
52
src/components/settings/sections/PerformanceSection.vue
Normal file
52
src/components/settings/sections/PerformanceSection.vue
Normal file
@ -0,0 +1,52 @@
|
||||
<!--
|
||||
性能 → 表格与性能
|
||||
数据源:experimental store(localStorage: experimental_{user}_{role})
|
||||
-->
|
||||
<template>
|
||||
<div class="settings-section">
|
||||
<div class="section-header">
|
||||
<div>
|
||||
<div class="section-title">表格与性能</div>
|
||||
<div class="section-desc">调整大列表表格的渲染调度策略(仅影响本机)。</div>
|
||||
</div>
|
||||
<el-button size="small" @click="handleReset">恢复默认</el-button>
|
||||
</div>
|
||||
|
||||
<div class="settings-card">
|
||||
<div class="setting-row">
|
||||
<span class="setting-label">表格工作模式</span>
|
||||
<el-radio-group v-model="tableMode" size="small">
|
||||
<el-radio value="resource">低占用(默认)</el-radio>
|
||||
<el-radio value="performance">高性能</el-radio>
|
||||
</el-radio-group>
|
||||
<span class="setting-hint">低占用优先减少资源开销;高性能优先滚动与渲染流畅度</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { computed } from 'vue'
|
||||
import { ElMessage } from 'element-plus'
|
||||
import { useExperimentalStore, type TableMode } from '@/stores/modules/experimental'
|
||||
|
||||
defineOptions({ name: 'SettingsPerformanceSection' })
|
||||
|
||||
const experimentalStore = useExperimentalStore()
|
||||
|
||||
const tableMode = computed({
|
||||
get: () => experimentalStore.tableMode,
|
||||
set: (mode: TableMode) => {
|
||||
experimentalStore.setTableMode(mode)
|
||||
}
|
||||
})
|
||||
|
||||
function handleReset() {
|
||||
experimentalStore.setTableMode('resource')
|
||||
ElMessage.success('已恢复为低占用模式')
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
@use './shared.scss';
|
||||
</style>
|
||||
104
src/components/settings/sections/ShortcutsSection.vue
Normal file
104
src/components/settings/sections/ShortcutsSection.vue
Normal file
@ -0,0 +1,104 @@
|
||||
<!--
|
||||
导航 → 快捷入口
|
||||
|
||||
集中管理侧边栏「快捷入口」(通过菜单星标添加/取消)。
|
||||
数据源:shortcuts store(localStorage: shortcuts_{user}_{role})
|
||||
-->
|
||||
<template>
|
||||
<div class="settings-section">
|
||||
<div class="section-header">
|
||||
<div>
|
||||
<div class="section-title">快捷入口</div>
|
||||
<div class="section-desc">
|
||||
在侧边栏菜单项上点击 ★ 可添加/取消快捷入口;此处集中查看与移除(按账号 + 角色保存)。
|
||||
</div>
|
||||
</div>
|
||||
<el-button size="small" :disabled="!list.length" @click="clearAll">清空全部</el-button>
|
||||
</div>
|
||||
|
||||
<div v-if="list.length" class="shortcut-list">
|
||||
<div v-for="item in list" :key="item.path" class="shortcut-item">
|
||||
<div class="shortcut-main">
|
||||
<span class="shortcut-title">{{ item.title }}</span>
|
||||
<span class="shortcut-path">{{ item.path }}</span>
|
||||
</div>
|
||||
<el-button text size="small" @click="remove(item.path)">移除</el-button>
|
||||
</div>
|
||||
</div>
|
||||
<el-empty v-else description="还没有快捷入口,可在侧边栏菜单上点击 ★ 添加" :image-size="60" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { computed } from 'vue'
|
||||
import { ElMessageBox } from 'element-plus'
|
||||
import { useShortcutsStore } from '@/stores/modules/shortcuts'
|
||||
|
||||
defineOptions({ name: 'SettingsShortcutsSection' })
|
||||
|
||||
const shortcutsStore = useShortcutsStore()
|
||||
|
||||
const list = computed(() => shortcutsStore.shortcuts)
|
||||
|
||||
function remove(path: string) {
|
||||
shortcutsStore.removeShortcut(path)
|
||||
}
|
||||
|
||||
function clearAll() {
|
||||
ElMessageBox.confirm('确定清空全部快捷入口吗?', '清空快捷入口', {
|
||||
type: 'warning',
|
||||
confirmButtonText: '清空',
|
||||
cancelButtonText: '取消'
|
||||
})
|
||||
.then(() => {
|
||||
// store 内部 watch(deep) 会自动持久化
|
||||
shortcutsStore.shortcuts = []
|
||||
})
|
||||
.catch(() => {})
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
@use './shared.scss';
|
||||
|
||||
.shortcut-list {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 6px;
|
||||
}
|
||||
|
||||
.shortcut-item {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 12px;
|
||||
min-height: 40px;
|
||||
padding: 4px 0 0 12px;
|
||||
border-bottom: 1px solid #f5f7fa;
|
||||
|
||||
&:last-child {
|
||||
border-bottom: none;
|
||||
}
|
||||
}
|
||||
|
||||
.shortcut-main {
|
||||
display: flex;
|
||||
align-items: baseline;
|
||||
gap: 10px;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.shortcut-title {
|
||||
font-size: 13px;
|
||||
color: #303133;
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
.shortcut-path {
|
||||
font-size: 12px;
|
||||
color: #a8abb2;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
</style>
|
||||
16
src/components/settings/sections/TabOrderSection.vue
Normal file
16
src/components/settings/sections/TabOrderSection.vue
Normal file
@ -0,0 +1,16 @@
|
||||
<!--
|
||||
导航 → 标签排序(设置中心内嵌分区)
|
||||
复用 TabOrderPanel;pageKey 由页面 useTabOrder provide(无则按路由兜底匹配)
|
||||
-->
|
||||
<template>
|
||||
<TabOrderPanel :current-page-key="pageKey" />
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import TabOrderPanel from '@/components/TabOrderPanel.vue'
|
||||
import { injectTabOrderPageKey } from '@/composables/useTabOrder'
|
||||
|
||||
defineOptions({ name: 'SettingsTabOrderSection' })
|
||||
|
||||
const pageKey = injectTabOrderPageKey()
|
||||
</script>
|
||||
96
src/components/settings/sections/shared.scss
Normal file
96
src/components/settings/sections/shared.scss
Normal file
@ -0,0 +1,96 @@
|
||||
/* 设置中心分区通用样式
|
||||
视觉基准:task-panel(order/waveOrder 新建波次策略、basicManagement 新增投递计划)
|
||||
—— 输入/选项行透明无容器,12px 标签 #606266,间距 16px */
|
||||
|
||||
.settings-section {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
/* ===== 分区标题区 ===== */
|
||||
.section-header {
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
justify-content: space-between;
|
||||
gap: 12px;
|
||||
padding: 4px 0 0 12px;
|
||||
}
|
||||
|
||||
.section-title {
|
||||
font-size: 13px;
|
||||
line-height: 20px;
|
||||
font-weight: 600;
|
||||
color: #303133;
|
||||
}
|
||||
|
||||
.section-desc {
|
||||
margin-top: 4px;
|
||||
font-size: 12px;
|
||||
line-height: 18px;
|
||||
color: #909399;
|
||||
}
|
||||
|
||||
/* ===== 分组容器:保持透明,不再使用灰色圆角背景 ===== */
|
||||
.settings-card {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
padding: 0;
|
||||
border: none;
|
||||
border-radius: 0;
|
||||
background: transparent;
|
||||
}
|
||||
|
||||
/* ===== 设置行(对齐 task-panel__field--input) ===== */
|
||||
.setting-row {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 16px;
|
||||
min-height: 40px;
|
||||
padding: 4px 0 0 12px;
|
||||
}
|
||||
|
||||
.setting-label {
|
||||
flex: 0 0 88px;
|
||||
width: 88px;
|
||||
font-size: 12px;
|
||||
line-height: 20px;
|
||||
color: #606266;
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
.setting-hint {
|
||||
font-size: 12px;
|
||||
line-height: 18px;
|
||||
color: #909399;
|
||||
}
|
||||
|
||||
/* ===== 数据/维护类区块 ===== */
|
||||
.section-block + .section-block {
|
||||
margin-top: 12px;
|
||||
}
|
||||
|
||||
.block-title {
|
||||
font-size: 13px;
|
||||
line-height: 20px;
|
||||
font-weight: 600;
|
||||
color: #303133;
|
||||
padding-left: 2px;
|
||||
}
|
||||
|
||||
.block-desc {
|
||||
margin: 4px 0 8px;
|
||||
padding-left: 2px;
|
||||
font-size: 12px;
|
||||
line-height: 18px;
|
||||
color: #909399;
|
||||
}
|
||||
|
||||
.block-actions {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
flex-wrap: wrap;
|
||||
padding-left: 2px;
|
||||
}
|
||||
|
||||
@ -10,7 +10,12 @@
|
||||
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 { useUserPreferenceStore } from '@/stores/modules/userPreference'
|
||||
import { PRINTER_AUTO_RECONNECT_SCOPE } from '@/stores/modules/printerComponent'
|
||||
import { getTabOrderPageKeys } from '@/config/tab-order-registry'
|
||||
import { ORDER_INDEX_EXPORT_SCOPES } from '@/views/order/shared/orderListExport'
|
||||
import { getOrderExportColumnsByMode } from '@/views/order/orderManagement/config/order-common-config'
|
||||
import {
|
||||
normalizeTabOrderDoc,
|
||||
readTabOrderDoc,
|
||||
@ -201,7 +206,70 @@ const displaySection: TbycConfigSection = {
|
||||
}
|
||||
}
|
||||
|
||||
/** ============ 分区 4:快捷键 ============ */
|
||||
/** ============ 分区 4:表格与缓存(experimental store) ============ */
|
||||
const experimentalSection: TbycConfigSection = {
|
||||
key: 'experimental',
|
||||
title: '表格与缓存',
|
||||
collect: () => {
|
||||
const store = useExperimentalStore()
|
||||
return {
|
||||
tableMode: store.tableMode,
|
||||
tabCacheEnabled: store.tabCacheEnabled,
|
||||
tabCacheMax: store.tabCacheMax,
|
||||
pageCacheEnabled: store.pageCacheEnabled,
|
||||
pageCacheMax: store.pageCacheMax
|
||||
}
|
||||
},
|
||||
apply: (data) => {
|
||||
if (!data || typeof data !== 'object' || Array.isArray(data)) return 0
|
||||
const source = data as Record<string, any>
|
||||
const store = useExperimentalStore()
|
||||
let count = 0
|
||||
|
||||
if (source.tableMode === 'performance' || source.tableMode === 'resource') {
|
||||
store.setTableMode(source.tableMode)
|
||||
count += 1
|
||||
}
|
||||
if (typeof source.tabCacheEnabled === 'boolean') {
|
||||
store.setTabCacheEnabled(source.tabCacheEnabled)
|
||||
count += 1
|
||||
}
|
||||
if (Number.isInteger(source.tabCacheMax) && source.tabCacheMax > 0) {
|
||||
store.setTabCacheMax(source.tabCacheMax)
|
||||
count += 1
|
||||
}
|
||||
if (typeof source.pageCacheEnabled === 'boolean') {
|
||||
store.setPageCacheEnabled(source.pageCacheEnabled)
|
||||
count += 1
|
||||
}
|
||||
if (Number.isInteger(source.pageCacheMax) && source.pageCacheMax > 0) {
|
||||
store.setPageCacheMax(source.pageCacheMax)
|
||||
count += 1
|
||||
}
|
||||
|
||||
return count
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* ============ 分区 5:设备与打印(暂无 UI,仅导出/导入) ============
|
||||
* 数据源:userPreference 的仓库级 scope `printer.autoReconnect`
|
||||
*/
|
||||
const printerSection: TbycConfigSection = {
|
||||
key: 'printer',
|
||||
title: '设备与打印',
|
||||
collect: () => {
|
||||
const value = useUserPreferenceStore().get(PRINTER_AUTO_RECONNECT_SCOPE)
|
||||
return value ?? undefined
|
||||
},
|
||||
apply: (data) => {
|
||||
if (!data || typeof data !== 'object' || Array.isArray(data)) return 0
|
||||
useUserPreferenceStore().set(PRINTER_AUTO_RECONNECT_SCOPE, data)
|
||||
return 1
|
||||
}
|
||||
}
|
||||
|
||||
/** ============ 分区 6:快捷键 ============ */
|
||||
const shortcutsSection: TbycConfigSection = {
|
||||
key: 'shortcuts',
|
||||
title: '快捷键',
|
||||
@ -225,11 +293,69 @@ const shortcutsSection: TbycConfigSection = {
|
||||
}
|
||||
}
|
||||
|
||||
/** ============ 分区 7:订单导出字段(订单管理 · 导出弹窗的字段勾选) ============ */
|
||||
const ORDER_EXPORT_MODES = ['waybill', 'item'] as const
|
||||
|
||||
const orderExportColumnsSection: TbycConfigSection = {
|
||||
key: 'orderExportColumns',
|
||||
title: '订单导出字段',
|
||||
collect: () => {
|
||||
const { userId, roleId } = currentIdentity()
|
||||
const prefix = `order_export_columns_${userId}_${roleId}_`
|
||||
const result: Record<string, Record<string, string[]>> = {}
|
||||
Object.keys(localStorage).forEach((key) => {
|
||||
if (!key.startsWith(prefix)) return
|
||||
const [scopeKey, mode] = key.slice(prefix.length).split('_')
|
||||
if (!scopeKey || !mode) return
|
||||
try {
|
||||
const parsed = JSON.parse(localStorage.getItem(key) || 'null')
|
||||
if (!Array.isArray(parsed)) return
|
||||
const scope = result[scopeKey] || (result[scopeKey] = {})
|
||||
scope[mode] = parsed.filter((field: unknown): field is string => typeof field === 'string')
|
||||
} catch {
|
||||
// 忽略损坏的配置
|
||||
}
|
||||
})
|
||||
return Object.keys(result).length ? result : undefined
|
||||
},
|
||||
apply: (data) => {
|
||||
if (!data || typeof data !== 'object' || Array.isArray(data)) return 0
|
||||
const { userId, roleId } = currentIdentity()
|
||||
const prefix = `order_export_columns_${userId}_${roleId}_`
|
||||
const source = data as Record<string, Record<string, unknown>>
|
||||
let count = 0
|
||||
|
||||
Object.keys(source).forEach((scopeKey) => {
|
||||
if (!(scopeKey in ORDER_INDEX_EXPORT_SCOPES)) return
|
||||
const scoped = source[scopeKey]
|
||||
if (!scoped || typeof scoped !== 'object' || Array.isArray(scoped)) return
|
||||
|
||||
ORDER_EXPORT_MODES.forEach((mode) => {
|
||||
const list = scoped[mode]
|
||||
if (!Array.isArray(list)) return
|
||||
const valid = new Set(getOrderExportColumnsByMode(mode))
|
||||
const fields = list.filter((field): field is string => typeof field === 'string' && valid.has(field))
|
||||
try {
|
||||
localStorage.setItem(`${prefix}${scopeKey}_${mode}`, JSON.stringify(fields))
|
||||
count += 1
|
||||
} catch {
|
||||
// localStorage 不可用时跳过
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
return count
|
||||
}
|
||||
}
|
||||
|
||||
export const TBYC_CONFIG_SECTIONS: TbycConfigSection[] = [
|
||||
fieldColumnsSection,
|
||||
tabOrderSection,
|
||||
displaySection,
|
||||
shortcutsSection
|
||||
experimentalSection,
|
||||
printerSection,
|
||||
shortcutsSection,
|
||||
orderExportColumnsSection
|
||||
]
|
||||
|
||||
/** 按 key 取分区 */
|
||||
|
||||
@ -70,6 +70,10 @@
|
||||
{{ tMenu('Profile') }}
|
||||
</el-dropdown-item>
|
||||
</router-link>
|
||||
|
||||
<el-dropdown-item @click="settingsVisible = true">
|
||||
<span style="display:block;">设置</span>
|
||||
</el-dropdown-item>
|
||||
|
||||
<el-dropdown-item divided @click="logout">
|
||||
<span style="display:block;">{{ $t('login.logOut') || 'Log Out' }}</span>
|
||||
@ -86,6 +90,9 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 设置中心(全局入口:无表格上下文,隐藏「当前页面 → 列表字段」) -->
|
||||
<settings-dialog v-model:visible="settingsVisible" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@ -99,6 +106,7 @@ import { useFrontBrandStore, DEFAULT_BRAND_LOGO } from '@/stores/modules/frontBr
|
||||
import { useAiStore } from '@/stores/modules/ai'
|
||||
import { useRouter, useRoute } from 'vue-router'
|
||||
import Breadcrumb from '@/components/Breadcrumb/index.vue'
|
||||
import SettingsDialog from '@/components/settings/SettingsDialog.vue'
|
||||
import LangSelect from '@/components/LangSelect/index.vue'
|
||||
import TopMenu from './TopMenu.vue'
|
||||
import dayjs from 'dayjs'
|
||||
@ -115,6 +123,8 @@ const settingsStore = useSettingsStore()
|
||||
const aiStore = useAiStore()
|
||||
const router = useRouter()
|
||||
const route = useRoute()
|
||||
/** 设置中心可见性(全局入口) */
|
||||
const settingsVisible = ref(false)
|
||||
|
||||
const sidebar = computed(() => appStore.sidebar)
|
||||
const user = computed(() => userStore.user)
|
||||
|
||||
20
src/stores/modules/tableColumnConfig.ts
Normal file
20
src/stores/modules/tableColumnConfig.ts
Normal file
@ -0,0 +1,20 @@
|
||||
import { defineStore } from 'pinia'
|
||||
|
||||
/**
|
||||
* 表格字段配置版本号(用于跨组件刷新)
|
||||
*
|
||||
* - 设置中心「所有表格字段」修改某张表的配置后调用 touch(tableId)
|
||||
* - UpperTable 监听自己 tableId 的版本号变化,命中时重建列配置(rebuildColumnConfig)
|
||||
* - 不落盘:纯粹是会话内的刷新信号
|
||||
*/
|
||||
export const useTableColumnConfigStore = defineStore('tableColumnConfig', {
|
||||
state: () => ({
|
||||
versions: {} as Record<string, number>
|
||||
}),
|
||||
actions: {
|
||||
touch(tableId: string) {
|
||||
if (!tableId) return
|
||||
this.versions[tableId] = (this.versions[tableId] || 0) + 1
|
||||
}
|
||||
}
|
||||
})
|
||||
118
src/utils/table-column-config.ts
Normal file
118
src/utils/table-column-config.ts
Normal file
@ -0,0 +1,118 @@
|
||||
/**
|
||||
* 表格字段配置(列配置)公共类型与存储工具
|
||||
*
|
||||
* 存储:localStorage `upper_table_columns_{userId}_{roleId}_{tableId}`
|
||||
* 结构:TableColumnProfile
|
||||
*
|
||||
* 说明:
|
||||
* - 这类配置是「账号 + 角色 + 表」维度,由 UpperTable 在页面挂载时维护
|
||||
* - 本文件供「设置中心 → 表格 → 所有表格字段」跨页面管理使用
|
||||
*/
|
||||
|
||||
export interface ColumnConfigItem {
|
||||
prop: string
|
||||
label?: string
|
||||
visible: boolean
|
||||
order: number
|
||||
width?: number | string
|
||||
fixed?: 'left' | 'right' | false
|
||||
}
|
||||
|
||||
export interface TableColumnProfile {
|
||||
schemaVersion: number
|
||||
tableId: string
|
||||
userId: string
|
||||
roleId: string | number
|
||||
updatedAt: number
|
||||
/** 表格名称(UpperTable 的 title prop,便于在管理面板中辨认) */
|
||||
title?: string
|
||||
/** 首次生成配置时的默认布局(用于「恢复默认」) */
|
||||
defaultColumns?: ColumnConfigItem[]
|
||||
columns: ColumnConfigItem[]
|
||||
}
|
||||
|
||||
const STORAGE_PREFIX = 'upper_table_columns_'
|
||||
|
||||
/** 当前身份对应的配置 key 前缀 */
|
||||
export function getColumnConfigPrefix(userId: string, roleId: string | number): string {
|
||||
return `${STORAGE_PREFIX}${userId}_${roleId}_`
|
||||
}
|
||||
|
||||
/** 读取某身份下的全部表格字段配置(按更新时间倒序) */
|
||||
export function readColumnProfiles(userId: string, roleId: string | number): TableColumnProfile[] {
|
||||
const prefix = getColumnConfigPrefix(userId, roleId)
|
||||
const profiles: TableColumnProfile[] = []
|
||||
Object.keys(localStorage).forEach((key) => {
|
||||
if (!key.startsWith(prefix)) return
|
||||
try {
|
||||
const parsed = JSON.parse(localStorage.getItem(key) || 'null') as TableColumnProfile | null
|
||||
if (!parsed?.tableId || !Array.isArray(parsed.columns)) return
|
||||
profiles.push(parsed)
|
||||
} catch {
|
||||
// 忽略损坏的配置
|
||||
}
|
||||
})
|
||||
return profiles.sort((a, b) => (b.updatedAt || 0) - (a.updatedAt || 0))
|
||||
}
|
||||
|
||||
/** 写入单张表的字段配置 */
|
||||
export function writeColumnProfile(profile: TableColumnProfile): void {
|
||||
const prefix = getColumnConfigPrefix(profile.userId, profile.roleId)
|
||||
try {
|
||||
localStorage.setItem(`${prefix}${profile.tableId}`, JSON.stringify(profile))
|
||||
} catch {
|
||||
// localStorage 不可用时静默失败
|
||||
}
|
||||
}
|
||||
|
||||
/** fixed 归一化:undefined / false 视为不固定 */
|
||||
function normalizedFixed(item: ColumnConfigItem): 'left' | 'right' | undefined {
|
||||
return item.fixed === 'left' || item.fixed === 'right' ? item.fixed : undefined
|
||||
}
|
||||
|
||||
/** 按 fixed 拆成 左固定 / 不固定 / 右固定,各自按 order 排序 */
|
||||
export function partitionConfigColumns(columns: ColumnConfigItem[]) {
|
||||
const left: ColumnConfigItem[] = []
|
||||
const mid: ColumnConfigItem[] = []
|
||||
const right: ColumnConfigItem[] = []
|
||||
columns.forEach((item) => {
|
||||
const fixed = normalizedFixed(item)
|
||||
if (fixed === 'left') left.push(item)
|
||||
else if (fixed === 'right') right.push(item)
|
||||
else mid.push(item)
|
||||
})
|
||||
left.sort((a, b) => a.order - b.order)
|
||||
mid.sort((a, b) => a.order - b.order)
|
||||
right.sort((a, b) => a.order - b.order)
|
||||
return { left, mid, right }
|
||||
}
|
||||
|
||||
/** 归一分组顺序:左固定 → 不固定 → 右固定,并重排 order 为连续整数 */
|
||||
export function normalizeConfigOrders(columns: ColumnConfigItem[]): ColumnConfigItem[] {
|
||||
const { left, mid, right } = partitionConfigColumns(columns)
|
||||
let order = 0
|
||||
return [...left, ...mid, ...right].map((item) => ({ ...item, order: order++ }))
|
||||
}
|
||||
|
||||
export function cloneColumns(columns: ColumnConfigItem[]): ColumnConfigItem[] {
|
||||
return columns.map((item) => ({ ...item }))
|
||||
}
|
||||
|
||||
/** 当前配置是否与默认布局不一致(用于「已自定义」标记;无默认布局时视为未自定义) */
|
||||
export function isColumnCustomized(profile: TableColumnProfile): boolean {
|
||||
const defaults = profile.defaultColumns
|
||||
if (!Array.isArray(defaults) || !defaults.length) return false
|
||||
|
||||
const current = normalizeConfigOrders(profile.columns)
|
||||
const base = normalizeConfigOrders(cloneColumns(defaults))
|
||||
if (current.length !== base.length) return true
|
||||
|
||||
return current.some((item, index) => {
|
||||
const target = base[index]!
|
||||
return (
|
||||
item.prop !== target.prop ||
|
||||
item.visible !== target.visible ||
|
||||
(normalizedFixed(item) || '') !== (normalizedFixed(target) || '')
|
||||
)
|
||||
})
|
||||
}
|
||||
@ -160,7 +160,7 @@ watch(
|
||||
// 打开时优先读取持久化配置,否则默认全选
|
||||
keyword.value = ''
|
||||
const saved = loadSavedColumns()
|
||||
if (saved && saved.length) {
|
||||
if (saved) {
|
||||
selected.value = saved
|
||||
} else {
|
||||
selected.value = columnGroups.value.flatMap((g) => g.fields)
|
||||
@ -172,18 +172,18 @@ watch(
|
||||
{ immediate: true }
|
||||
)
|
||||
|
||||
/** 读取持久化的字段配置(过滤掉当前模式不存在的字段) */
|
||||
function loadSavedColumns(): string[] {
|
||||
if (!props.storageKey) return []
|
||||
/** 读取持久化的字段配置(过滤掉当前模式不存在的字段);null = 未配置 */
|
||||
function loadSavedColumns(): string[] | null {
|
||||
if (!props.storageKey) return null
|
||||
try {
|
||||
const raw = localStorage.getItem(props.storageKey)
|
||||
if (!raw) return []
|
||||
if (raw === null) return null
|
||||
const parsed = JSON.parse(raw)
|
||||
if (!Array.isArray(parsed)) return []
|
||||
if (!Array.isArray(parsed)) return null
|
||||
const valid = new Set(columnGroups.value.flatMap((g) => g.fields))
|
||||
return parsed.filter((f: unknown): f is string => typeof f === 'string' && valid.has(f))
|
||||
} catch {
|
||||
return []
|
||||
return null
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -1438,7 +1438,6 @@ export const receiverMobileScanField = scanBasicField({ label: '电话', value:
|
||||
export const receiverProvinceScanField = scanBasicField({ label: '省份', value: 'province', type: 'text' })
|
||||
export const receiverCityScanField = scanBasicField({ label: '城市', value: 'city', type: 'text' })
|
||||
export const receiverAreaScanField = scanBasicField({ label: '区县', value: 'area', type: 'text' })
|
||||
export const logisticsNameScanField = scanBasicField({ label: '物流公司', value: 'logistics_name', type: 'select', options: [] })
|
||||
export const waybillCodesScanField = scanBasicField({ label: '快递单号', value: 'waybill_codes', type: 'text', operators: ORDER_BULK_SEARCH_OPERATORS, defaultOperator: 'eq' })
|
||||
export const expressCodeScanField = scanBasicField({ label: '快递单号', value: 'express_code', type: 'text', operators: ORDER_BULK_SEARCH_OPERATORS, defaultOperator: 'eq' })
|
||||
export const createAtRangeScanField = scanBasicField({ label: '创建时间', value: 'create_at', type: 'datetimerange' })
|
||||
@ -1598,7 +1597,6 @@ export const deliveryAvailableFields = [
|
||||
{ ...shopNickScanField, group: SCAN_ORDER_INFO_GROUP },
|
||||
{ ...sysPlatformNameScanField, group: SCAN_ORDER_INFO_GROUP },
|
||||
{ ...createChannelScanField, group: SCAN_ORDER_INFO_GROUP },
|
||||
{ ...logisticsNameScanField, group: SCAN_ORDER_INFO_GROUP },
|
||||
{ ...expressCompanyScanField, group: SCAN_ORDER_INFO_GROUP },
|
||||
{ ...stockQueryScanField, group: SCAN_ORDER_INFO_GROUP },
|
||||
{ ...weightTypeScanField, group: SCAN_ORDER_INFO_GROUP },
|
||||
@ -1973,7 +1971,6 @@ export const pendingAvailableFields = [
|
||||
{ ...shopNickScanField, group: SCAN_ORDER_INFO_GROUP },
|
||||
{ ...sysPlatformNameScanField, group: SCAN_ORDER_INFO_GROUP },
|
||||
{ ...createChannelScanField, group: SCAN_ORDER_INFO_GROUP },
|
||||
{ ...logisticsNameScanField, group: SCAN_ORDER_INFO_GROUP },
|
||||
{ ...expressCompanyScanField, group: SCAN_ORDER_INFO_GROUP },
|
||||
{ ...stockQueryScanField, group: SCAN_ORDER_INFO_GROUP },
|
||||
{ ...weightTypeScanField, group: SCAN_ORDER_INFO_GROUP },
|
||||
@ -2372,7 +2369,6 @@ export const expectionOrderAvailableFields = [
|
||||
{ ...sourceOrderCodesScanField, group: SCAN_ORDER_INFO_GROUP },
|
||||
{ ...orderFlagScanField, group: SCAN_ORDER_INFO_GROUP },
|
||||
{ ...createChannelScanField, group: SCAN_ORDER_INFO_GROUP },
|
||||
{ ...logisticsNameScanField, group: SCAN_ORDER_INFO_GROUP },
|
||||
{ ...expressCompanyScanField, group: SCAN_ORDER_INFO_GROUP },
|
||||
{ ...stockQueryScanField, group: SCAN_ORDER_INFO_GROUP },
|
||||
{ ...weightTypeScanField, group: SCAN_ORDER_INFO_GROUP },
|
||||
|
||||
@ -521,15 +521,11 @@ async function loadOrderMetaOptions() {
|
||||
const expressRaw = expressData?.list || expressData || []
|
||||
const platformRaw = platformData?.list || platformData || []
|
||||
|
||||
const logisticsField = availableFieldsRef.find((i: any) => i.value === 'logistics_name')
|
||||
if (logisticsField) logisticsField.options = mapNameOptions(expressRaw, ['name', 'logistics_name', 'express_name'])
|
||||
fillExpressCompanyScanFieldOptions(availableFieldsRef, expressRaw)
|
||||
fillStoreScanFieldOptions(availableFieldsRef, extractStoreListFromResponse(storesRes))
|
||||
const platformField = availableFieldsRef.find((i: any) => i.value === 'sys_platform_name')
|
||||
if (platformField) platformField.options = mapNameOptions(platformRaw, ['name', 'platform_name'])
|
||||
} catch {
|
||||
const logisticsField = availableFieldsRef.find((i: any) => i.value === 'logistics_name')
|
||||
if (logisticsField) logisticsField.options = []
|
||||
fillExpressCompanyScanFieldOptions(availableFieldsRef, [])
|
||||
fillStoreScanFieldOptions(availableFieldsRef, [])
|
||||
const platformField = availableFieldsRef.find((i: any) => i.value === 'sys_platform_name')
|
||||
|
||||
@ -626,18 +626,6 @@ function mapCodeOptions(rawList: any[], codeKeys: string[], nameKeys: string[])
|
||||
return result
|
||||
}
|
||||
|
||||
function mapNameOptions(rawList: any[], nameKeys: string[]) {
|
||||
const result: Array<{ label: string; value: string }> = []
|
||||
const seen = new Set<string>()
|
||||
for (const item of rawList || []) {
|
||||
const name = normalizeCode(nameKeys.map((k) => item?.[k]).find((v) => v !== undefined && v !== null && v !== ''))
|
||||
if (!name || seen.has(name)) continue
|
||||
result.push({ value: name, label: name })
|
||||
seen.add(name)
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
function getSelectedIds(): number[] {
|
||||
const ids: number[] = []
|
||||
for (const item of selectionRows.value) {
|
||||
@ -791,16 +779,10 @@ async function loadOrderMetaOptions() {
|
||||
const platformRaw = platformData?.list || platformData || []
|
||||
expressCodeOptions.value = mapCodeOptions(expressRaw, ['code', 'logistics_code', 'express_code'], ['name', 'logistics_name', 'express_name'])
|
||||
platformCodeOptions.value = mapCodeOptions(platformRaw, ['code', 'platform_code'], ['name', 'platform_name'])
|
||||
const logisticsField = availableFieldsRef.find((i: any) => i.value === 'logistics_name')
|
||||
if (logisticsField) {
|
||||
logisticsField.options = mapNameOptions(expressRaw, ['name', 'logistics_name', 'express_name'])
|
||||
}
|
||||
fillExpressCompanyScanFieldOptions(availableFieldsRef, expressRaw)
|
||||
} catch {
|
||||
expressCodeOptions.value = []
|
||||
platformCodeOptions.value = []
|
||||
const logisticsField = availableFieldsRef.find((i: any) => i.value === 'logistics_name')
|
||||
if (logisticsField) logisticsField.options = []
|
||||
fillExpressCompanyScanFieldOptions(availableFieldsRef, [])
|
||||
}
|
||||
}
|
||||
|
||||
@ -465,15 +465,11 @@ async function loadOrderMetaOptions() {
|
||||
const expressRaw = expressData?.list || expressData || []
|
||||
const platformRaw = platformData?.list || platformData || []
|
||||
|
||||
const logisticsField = availableFieldsRef.find((i: any) => i.value === 'logistics_name')
|
||||
if (logisticsField) logisticsField.options = mapNameOptions(expressRaw, ['name', 'logistics_name', 'express_name'])
|
||||
fillExpressCompanyScanFieldOptions(availableFieldsRef, expressRaw)
|
||||
fillStoreScanFieldOptions(availableFieldsRef, extractStoreListFromResponse(storesRes))
|
||||
const platformField = availableFieldsRef.find((i: any) => i.value === 'sys_platform_name')
|
||||
if (platformField) platformField.options = mapNameOptions(platformRaw, ['name', 'platform_name'])
|
||||
} catch {
|
||||
const logisticsField = availableFieldsRef.find((i: any) => i.value === 'logistics_name')
|
||||
if (logisticsField) logisticsField.options = []
|
||||
fillExpressCompanyScanFieldOptions(availableFieldsRef, [])
|
||||
fillStoreScanFieldOptions(availableFieldsRef, [])
|
||||
const platformField = availableFieldsRef.find((i: any) => i.value === 'sys_platform_name')
|
||||
|
||||
@ -1099,10 +1099,6 @@ async function loadOrderMetaOptions() {
|
||||
const platformRaw = platformData?.list || platformData || []
|
||||
expressCodeOptions.value = mapCodeOptions(expressRaw, ['code', 'logistics_code', 'express_code'], ['name', 'logistics_name', 'express_name'])
|
||||
platformCodeOptions.value = mapCodeOptions(platformRaw, ['code', 'platform_code'], ['name', 'platform_name'])
|
||||
const logisticsField = availableFieldsRef.find((i: any) => i.value === 'logistics_name')
|
||||
if (logisticsField) {
|
||||
logisticsField.options = mapNameOptions(expressRaw, ['name', 'logistics_name', 'express_name'])
|
||||
}
|
||||
fillExpressCompanyScanFieldOptions(availableFieldsRef, expressRaw)
|
||||
const platformField = availableFieldsRef.find((i: any) => i.value === 'sys_platform_name')
|
||||
if (platformField) {
|
||||
@ -1111,8 +1107,6 @@ async function loadOrderMetaOptions() {
|
||||
} catch {
|
||||
expressCodeOptions.value = []
|
||||
platformCodeOptions.value = []
|
||||
const logisticsField = availableFieldsRef.find((i: any) => i.value === 'logistics_name')
|
||||
if (logisticsField) logisticsField.options = []
|
||||
fillExpressCompanyScanFieldOptions(availableFieldsRef, [])
|
||||
const platformField = availableFieldsRef.find((i: any) => i.value === 'sys_platform_name')
|
||||
if (platformField) platformField.options = []
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user