ren
This commit is contained in:
@@ -343,7 +343,41 @@ export function useTableColumns(
|
||||
}
|
||||
|
||||
if (extracted.length > 0) {
|
||||
columns.value = extracted
|
||||
// 合并列配置:
|
||||
// - 第一次提取时直接赋值
|
||||
// - 后续提取时与已有列做并集,避免因为列被隐藏导致配置丢失,
|
||||
// 从而在“列设置”弹窗中看不到已隐藏的列
|
||||
if (columns.value.length === 0) {
|
||||
columns.value = extracted
|
||||
} else {
|
||||
const keyOf = (col: ColumnConfig) => col.prop || col.label
|
||||
const map = new Map<string, ColumnConfig>()
|
||||
|
||||
// 先放入已有列
|
||||
columns.value.forEach(col => {
|
||||
const key = keyOf(col)
|
||||
if (key) {
|
||||
map.set(key, { ...col })
|
||||
}
|
||||
})
|
||||
|
||||
// 再合并本次提取的列(更新宽度、fixed 等信息,避免旧配置过时)
|
||||
extracted.forEach(col => {
|
||||
const key = keyOf(col)
|
||||
if (!key) return
|
||||
const exist = map.get(key)
|
||||
if (exist) {
|
||||
map.set(key, {
|
||||
...exist,
|
||||
...col,
|
||||
})
|
||||
} else {
|
||||
map.set(key, { ...col })
|
||||
}
|
||||
})
|
||||
|
||||
columns.value = Array.from(map.values())
|
||||
}
|
||||
|
||||
// 初始化可见列
|
||||
if (storageKey) {
|
||||
|
||||
Reference in New Issue
Block a user