- 新增 useTabOrder、tab-order 工具与 tab-order-registry 注册表,按模块集中登记 页面标签并懒加载默认标签;新增 TabOrderSettingsDialog、TabOrderDragList, 支持拖拽排序、设置默认页签与重置,SortSettingDialog / TabArea 迁移到同一套实现 - 用户偏好存储新增「用户级」globalMap(不随仓库隔离),tabOrder 写入用户级 scope, 旧 scope 一次性迁移并对齐回退读取;各页面 config 接入统一注册表, 移除页面内自写的排序与默认页签逻辑 - 新增 tbyc-config 统一配置文件与分区注册表,UpperTable 的配置导出/导入 升级为 tbyc-config.json(字段列、标签排序、界面显示、快捷键), 兼容旧版「全局字段配置」与 tabOrders 文件 - Element Plus 改为 unplugin-vue-components 按需自动引入,移除 app.use(ElementPlus)、dts 生成与强制 vendor-element-plus 分包 - ECharts 改为按需注册(折线/饼图 + 所需组件),dashboard 图表统一走 @/utils/echarts;移除 three.js 及 overlookControls / threeScene / threeUtils, 同步清理依赖、manualChunks 与 optimizeDeps - vue-devtools 支持 VITE_VUE_DEVTOOLS=off 关闭;抽离 wavePrintPayload 供订单、 复核页面复用,scanFields 承接批量搜索操作符与「包含商品」筛选项 - 补充标签排序与默认页签统一方案、tbyc-config 说明文档, 更新标签页性能测量结论与用户偏好保存方案
294 lines
7.9 KiB
Vue
294 lines
7.9 KiB
Vue
<!--
|
||
TabArea — 页面内多标签页(全局统一组件)
|
||
|
||
视觉基准:order/orderManagement、order/waveOrder 的卡片式标签
|
||
· header 渐变底 #f7fafd → #eef4fb,底部 1px 分隔线
|
||
· 标签 34px / 13px / 圆角 8px / 淡蓝卡片底
|
||
· 激活态白底 + #2f80ed + 左侧 8px 圆点,并用 1px 白色阴影盖住 header 分隔线
|
||
|
||
约定:
|
||
· 边框/阴影的清除由 src/styles/tab-area.scss 统一负责(border-card 自带外壳)
|
||
· 排序入口只在「页签数量 > 1」时渲染,单页签页面不显示
|
||
· 排序结果按账号保存在浏览器本地(useUserPreferenceStore),组件内部自行重排,
|
||
父组件无需感知顺序变化(用 name 映射内容组件,顺序无关)
|
||
|
||
用法:
|
||
<div class="tab-section">
|
||
<TabArea :tabs="tabs" :default-active="activeTab" @tab-change="handleTabChange" />
|
||
</div>
|
||
-->
|
||
<template>
|
||
<div
|
||
class="tab-area-wrapper"
|
||
:class="{ 'has-sort': showSortEntry, 'has-header-action': hasHeaderAction }"
|
||
>
|
||
<div v-if="showSortEntry" class="tab-sort-entry">
|
||
<el-tooltip content="标签排序" placement="bottom">
|
||
<el-button class="sort-entry-btn" size="small" link @click="sortDialogVisible = true">
|
||
<el-icon><Sort /></el-icon>
|
||
</el-button>
|
||
</el-tooltip>
|
||
</div>
|
||
|
||
<!-- 右侧操作区(可选):如「刷新角标」按钮、状态 chip -->
|
||
<div v-if="hasHeaderAction" class="tab-header-action">
|
||
<slot name="header-action" />
|
||
</div>
|
||
|
||
<el-tabs
|
||
v-model="activeTab"
|
||
tab-position="top"
|
||
type="border-card"
|
||
class="tab-container"
|
||
@tab-change="handleTabChange"
|
||
>
|
||
<el-tab-pane
|
||
v-for="tab in orderedTabs"
|
||
:key="tab.name"
|
||
:name="tab.name"
|
||
:lazy="false"
|
||
>
|
||
<template #label>
|
||
<span class="custom-tab-label">
|
||
<!-- 标签内容插槽:优先 label-{name},其次通用 label,最后纯文本 -->
|
||
<slot :name="`label-${tab.name}`" :tab="tab">
|
||
<slot name="label" :tab="tab">{{ tab.label }}</slot>
|
||
</slot>
|
||
</span>
|
||
</template>
|
||
</el-tab-pane>
|
||
</el-tabs>
|
||
|
||
<SortSettingDialog
|
||
v-if="showSortEntry"
|
||
v-model:visible="sortDialogVisible"
|
||
:tabs="props.tabs"
|
||
:page-key="pageKeyValue"
|
||
@saved="handleSortSaved"
|
||
/>
|
||
</div>
|
||
</template>
|
||
|
||
<script setup lang="ts">
|
||
import { computed, ref, useSlots, watch } from 'vue'
|
||
import { useRoute } from 'vue-router'
|
||
import { Sort } from '@element-plus/icons-vue'
|
||
import SortSettingDialog from '@/components/SortSettingDialog.vue'
|
||
import { useTabOrder } from '@/composables/useTabOrder'
|
||
import type { TabOption } from '@/utils/tab-order'
|
||
|
||
defineOptions({ name: 'TabArea' })
|
||
|
||
export interface TabAreaItem {
|
||
name: string
|
||
label: string
|
||
/** 允许页面携带额外字段(如角标 count),排序只依赖 name */
|
||
[key: string]: any
|
||
}
|
||
|
||
const props = withDefaults(
|
||
defineProps<{
|
||
tabs?: TabAreaItem[]
|
||
defaultActive?: string
|
||
/** 排序配置主键(注册表 key,如 order.management);缺省时按路由路径生成兜底 key */
|
||
pageKey?: string
|
||
/** 旧排序 scope(兼容旧调用,作为 legacyScopes 首项读取) */
|
||
sortScope?: string
|
||
/** 是否显示排序入口(默认显示;单标签页面始终不显示) */
|
||
showSort?: boolean
|
||
}>(),
|
||
{
|
||
tabs: () => [],
|
||
defaultActive: '',
|
||
pageKey: '',
|
||
sortScope: '',
|
||
showSort: true
|
||
}
|
||
)
|
||
|
||
const emit = defineEmits<{
|
||
(e: 'tab-change', tabName: string): void
|
||
}>()
|
||
|
||
const slots = useSlots()
|
||
const route = useRoute()
|
||
|
||
/** 右侧操作区插槽是否存在 */
|
||
const hasHeaderAction = computed(() => !!slots['header-action'])
|
||
|
||
/** 排序入口:多标签 + 未显式关闭 */
|
||
const showSortEntry = computed(() => props.showSort && props.tabs.length > 1)
|
||
|
||
/** 排序配置主键:未显式传入时按路由路径兜底(仅用于兼容) */
|
||
const pageKeyValue = computed(() => props.pageKey || `route:${route.path}`)
|
||
|
||
const { orderedTabs, defaultTabName, saveOrder, setDefault, seedLegacyIfNeeded } = useTabOrder(
|
||
pageKeyValue,
|
||
() => props.tabs as TabOption[],
|
||
{
|
||
// 兼容:旧 TabArea 用 tab-order:{path},旧内联页面用各自 scope
|
||
legacyScopes: () => [props.sortScope, `tab-order:${route.path}`].filter(Boolean) as string[],
|
||
// TabArea 不是 UpperTable 的祖先,pageKey 由页面自己 provide
|
||
provideKey: false
|
||
}
|
||
)
|
||
|
||
const sortDialogVisible = ref(false)
|
||
|
||
const activeTab = ref(props.defaultActive || defaultTabName.value || props.tabs[0]?.name || '')
|
||
|
||
function handleTabChange(name: string | number) {
|
||
const next = String(name)
|
||
if (activeTab.value !== next) activeTab.value = next
|
||
emit('tab-change', next)
|
||
}
|
||
|
||
/** 弹窗保存:写顺序 + 默认标签(store 更新后 orderedTabs 立即重排) */
|
||
function handleSortSaved(order: string[], defaultName: string) {
|
||
saveOrder(order)
|
||
setDefault(defaultName)
|
||
}
|
||
|
||
/** 标签集合变化(如权限变化)时补一次旧配置迁移 */
|
||
watch(
|
||
() => props.tabs.map((t) => t.name).join(','),
|
||
() => seedLegacyIfNeeded()
|
||
)
|
||
</script>
|
||
|
||
<style lang="scss" scoped>
|
||
.tab-area-wrapper {
|
||
position: relative;
|
||
flex-shrink: 0;
|
||
}
|
||
|
||
/* 标签排序入口(tab 区域左侧) */
|
||
.tab-sort-entry {
|
||
position: absolute;
|
||
top: 4px;
|
||
left: 12px;
|
||
height: 38px;
|
||
display: flex;
|
||
align-items: center;
|
||
z-index: 2;
|
||
|
||
.sort-entry-btn {
|
||
color: #606266;
|
||
font-size: 15px;
|
||
padding: 4px 6px;
|
||
border-radius: 4px;
|
||
transition: all 0.2s;
|
||
|
||
&:hover {
|
||
color: #409eff;
|
||
background-color: rgba(64, 158, 255, 0.08);
|
||
}
|
||
}
|
||
}
|
||
|
||
/* 右侧操作区(可选):与排序入口同一高度,绝对定位覆盖在标签栏右侧 */
|
||
.tab-header-action {
|
||
position: absolute;
|
||
top: 4px;
|
||
right: 16px;
|
||
height: 38px;
|
||
display: flex;
|
||
align-items: center;
|
||
gap: 8px;
|
||
z-index: 2;
|
||
}
|
||
|
||
.tab-container {
|
||
display: flex;
|
||
flex-direction: column;
|
||
|
||
/* border-card 自带外壳的清除统一由 src/styles/tab-area.scss 负责 */
|
||
|
||
:deep(.el-tabs__header) {
|
||
margin-bottom: 0;
|
||
flex-shrink: 0;
|
||
}
|
||
|
||
:deep(.el-tabs__header.is-top) {
|
||
padding: 8px 12px 0;
|
||
background: linear-gradient(180deg, #f7fafd 0%, #eef4fb 100%);
|
||
border-bottom: 1px solid #e8eef7;
|
||
margin: 0;
|
||
}
|
||
|
||
:deep(.el-tabs__nav-wrap::after) {
|
||
display: none;
|
||
}
|
||
|
||
:deep(.el-tabs__item.is-top) {
|
||
height: 34px;
|
||
line-height: 34px;
|
||
padding: 0 16px;
|
||
border-radius: 8px 8px 0 0;
|
||
color: #606266;
|
||
font-size: 13px;
|
||
font-weight: 500;
|
||
transition: all 0.25s cubic-bezier(0.645, 0.045, 0.355, 1);
|
||
border: 1px solid #e6edf8;
|
||
border-bottom: none;
|
||
background: #edf3fb;
|
||
margin-right: 6px;
|
||
box-shadow: inset 0 -1px 0 rgba(15, 23, 42, 0.03);
|
||
}
|
||
|
||
:deep(.el-tabs__item.is-top:hover) {
|
||
color: #409eff;
|
||
background-color: rgba(64, 158, 255, 0.06);
|
||
border-color: rgba(64, 158, 255, 0.12);
|
||
}
|
||
|
||
:deep(.el-tabs__item.is-top.is-active) {
|
||
color: #2f80ed;
|
||
font-weight: 600;
|
||
background: #ffffff;
|
||
border-color: #e8eef7;
|
||
/*
|
||
第二层阴影向下 1px 纯白,盖住 header 底部的 1px 分隔线,
|
||
让激活标签与下方内容区连通(box-shadow 不受标签 overflow:hidden 裁剪)。
|
||
*/
|
||
box-shadow: 0 -1px 8px rgba(47, 128, 237, 0.08), 0 1px 0 0 #ffffff;
|
||
z-index: 1;
|
||
position: relative;
|
||
|
||
&::before {
|
||
content: "";
|
||
display: inline-block;
|
||
width: 8px;
|
||
height: 8px;
|
||
border-radius: 50%;
|
||
background: #2f80ed;
|
||
margin-right: 6px;
|
||
vertical-align: middle;
|
||
flex-shrink: 0;
|
||
}
|
||
}
|
||
|
||
:deep(.el-tabs__active-bar) {
|
||
display: none;
|
||
}
|
||
|
||
/* 仅展示标签头,内容由页面自己渲染 */
|
||
:deep(.el-tabs__content) {
|
||
display: none;
|
||
}
|
||
}
|
||
|
||
/* 有排序入口时,标签从排序按钮右侧开始 */
|
||
.tab-area-wrapper.has-sort {
|
||
:deep(.el-tabs__header.is-top) {
|
||
padding-left: 46px;
|
||
}
|
||
}
|
||
|
||
.custom-tab-label {
|
||
display: inline-flex;
|
||
align-items: center;
|
||
gap: 6px;
|
||
}
|
||
</style>
|