Table: fix 修复 table 多级表头在固定时一级表头宽度不随子级表头宽度拖拽更新问题

pull/22187/head
dong 2022-10-11 10:20:15 +08:00
parent 5d7374bf16
commit 3b09a76774
1 changed files with 11 additions and 4 deletions

View File

@ -129,6 +129,13 @@ class TableLayout {
return false; return false;
} }
getFixedColumnWidth(column) {
if (column.children) {
return column.children.reduce((pre, cur) => pre + this.getFixedColumnWidth(cur), 0);
}
return column.realWidth || column.width;
}
updateColumnsWidth() { updateColumnsWidth() {
if (Vue.prototype.$isServer) return; if (Vue.prototype.$isServer) return;
const fit = this.fit; const fit = this.fit;
@ -198,8 +205,8 @@ class TableLayout {
if (fixedColumns.length > 0) { if (fixedColumns.length > 0) {
let fixedWidth = 0; let fixedWidth = 0;
fixedColumns.forEach(function(column) { fixedColumns.forEach((column) => {
fixedWidth += column.realWidth || column.width; fixedWidth += this.getFixedColumnWidth(column);
}); });
this.fixedWidth = fixedWidth; this.fixedWidth = fixedWidth;
@ -208,8 +215,8 @@ class TableLayout {
const rightFixedColumns = this.store.states.rightFixedColumns; const rightFixedColumns = this.store.states.rightFixedColumns;
if (rightFixedColumns.length > 0) { if (rightFixedColumns.length > 0) {
let rightFixedWidth = 0; let rightFixedWidth = 0;
rightFixedColumns.forEach(function(column) { rightFixedColumns.forEach((column) => {
rightFixedWidth += column.realWidth || column.width; rightFixedWidth += this.getFixedColumnWidth(column);
}); });
this.rightFixedWidth = rightFixedWidth; this.rightFixedWidth = rightFixedWidth;