Skip to content

Commit cadfdaa

Browse files
authored
fix(table): resolve colspan handling for multi-header (#3372)
1 parent 623ca35 commit cadfdaa

File tree

1 file changed

+18
-8
lines changed

1 file changed

+18
-8
lines changed

src/table/thead.tsx

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -77,17 +77,27 @@ export default defineComponent({
7777
// 单行表格合并
7878
const colspanSkipMap = computed(() => {
7979
const map: { [key: string]: boolean } = {};
80-
const list = props.thList[0];
81-
for (let i = 0, len = list.length; i < len; i++) {
82-
const item = list[i];
83-
if (item.colspan > 1) {
84-
for (let j = i + 1; j < i + item.colspan; j++) {
85-
if (list[j]) {
86-
map[list[j].colKey] = true;
80+
81+
const processColumns = (columns: BaseTableColumns) => {
82+
for (let i = 0, len = columns.length; i < len; i++) {
83+
const item = columns[i];
84+
if (item.colspan > 1) {
85+
for (let j = i + 1; j < i + item.colspan; j++) {
86+
if (columns[j]) {
87+
map[columns[j].colKey] = true;
88+
}
8789
}
8890
}
91+
// 如果有子列,递归处理
92+
if (item.children) {
93+
processColumns(item.children);
94+
}
8995
}
90-
}
96+
};
97+
98+
const list = props.thList[0];
99+
processColumns(list);
100+
91101
return map;
92102
});
93103

0 commit comments

Comments
 (0)