From 3b09a7677436d52e6c3e7aa65f8ca582935d97fc Mon Sep 17 00:00:00 2001 From: dong <2710732812@qq.com> Date: Tue, 11 Oct 2022 10:20:15 +0800 Subject: [PATCH] =?UTF-8?q?Table:=20fix=20=E4=BF=AE=E5=A4=8D=20table=20?= =?UTF-8?q?=E5=A4=9A=E7=BA=A7=E8=A1=A8=E5=A4=B4=E5=9C=A8=E5=9B=BA=E5=AE=9A?= =?UTF-8?q?=E6=97=B6=E4=B8=80=E7=BA=A7=E8=A1=A8=E5=A4=B4=E5=AE=BD=E5=BA=A6?= =?UTF-8?q?=E4=B8=8D=E9=9A=8F=E5=AD=90=E7=BA=A7=E8=A1=A8=E5=A4=B4=E5=AE=BD?= =?UTF-8?q?=E5=BA=A6=E6=8B=96=E6=8B=BD=E6=9B=B4=E6=96=B0=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/table/src/table-layout.js | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/packages/table/src/table-layout.js b/packages/table/src/table-layout.js index 7f8942f98..3601d639a 100644 --- a/packages/table/src/table-layout.js +++ b/packages/table/src/table-layout.js @@ -129,6 +129,13 @@ class TableLayout { return false; } + getFixedColumnWidth(column) { + if (column.children) { + return column.children.reduce((pre, cur) => pre + this.getFixedColumnWidth(cur), 0); + } + return column.realWidth || column.width; + } + updateColumnsWidth() { if (Vue.prototype.$isServer) return; const fit = this.fit; @@ -198,8 +205,8 @@ class TableLayout { if (fixedColumns.length > 0) { let fixedWidth = 0; - fixedColumns.forEach(function(column) { - fixedWidth += column.realWidth || column.width; + fixedColumns.forEach((column) => { + fixedWidth += this.getFixedColumnWidth(column); }); this.fixedWidth = fixedWidth; @@ -208,8 +215,8 @@ class TableLayout { const rightFixedColumns = this.store.states.rightFixedColumns; if (rightFixedColumns.length > 0) { let rightFixedWidth = 0; - rightFixedColumns.forEach(function(column) { - rightFixedWidth += column.realWidth || column.width; + rightFixedColumns.forEach((column) => { + rightFixedWidth += this.getFixedColumnWidth(column); }); this.rightFixedWidth = rightFixedWidth;