- 新增 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 说明
353 lines
8.2 KiB
Vue
353 lines
8.2 KiB
Vue
<!--
|
||
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>
|