xachary
2 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with
17 additions and
3 deletions
-
src/components/Table/src/hooks/useColumns.ts
|
|
|
@ -297,9 +297,23 @@ function sortFixedColumn(columns: BasicColumn[]) { |
|
|
|
} |
|
|
|
defColumns.push(column); |
|
|
|
} |
|
|
|
return [...fixedLeftColumns, ...defColumns, ...fixedRightColumns].filter( |
|
|
|
(item) => !item.defaultHidden, |
|
|
|
); |
|
|
|
// 筛选逻辑
|
|
|
|
const filterFunc = (item) => !item.defaultHidden; |
|
|
|
// 筛选首层显示列(1级表头)
|
|
|
|
const viewColumns = [...fixedLeftColumns, ...defColumns, ...fixedRightColumns].filter(filterFunc); |
|
|
|
// 筛选>=2级表头(深度优先)
|
|
|
|
const list = [...viewColumns]; |
|
|
|
while (list.length) { |
|
|
|
const current = list[0]; |
|
|
|
if (Array.isArray(current.children)) { |
|
|
|
current.children = current.children.filter(filterFunc); |
|
|
|
list.shift(); |
|
|
|
list.unshift(...current.children); |
|
|
|
} else { |
|
|
|
list.shift(); |
|
|
|
} |
|
|
|
} |
|
|
|
return viewColumns; |
|
|
|
} |
|
|
|
|
|
|
|
// format cell
|
|
|
|
|