From 97979c5059e2846a0180954060960c5e2216f35c Mon Sep 17 00:00:00 2001 From: chenghongxing <1126263215@qq.com> Date: Sun, 8 Nov 2020 16:18:43 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20the=20problem=20of=20hiding=20column=20o?= =?UTF-8?q?f=20AdvancedTable.vue;=20:bug:=20#139=20=E4=BF=AE=E5=A4=8D?= =?UTF-8?q?=EF=BC=9A=E9=AB=98=E7=BA=A7=E8=A1=A8=E6=A0=BC=E6=97=A0=E6=B3=95?= =?UTF-8?q?=E9=9A=90=E8=97=8F=E5=88=97=E7=9A=84bug=EF=BC=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../table/advance/ActionColumns.vue | 26 +++---------------- src/components/table/advance/AdvanceTable.vue | 5 +++- 2 files changed, 7 insertions(+), 24 deletions(-) diff --git a/src/components/table/advance/ActionColumns.vue b/src/components/table/advance/ActionColumns.vue index 8e357c4..2dc9d06 100644 --- a/src/components/table/advance/ActionColumns.vue +++ b/src/components/table/advance/ActionColumns.vue @@ -59,8 +59,6 @@ } if (!col.visible) { this.checkedCounts -= 1 - this.$set(col, 'colSpan', 0) - this.$set(col, 'customCell', () => ({style: 'display: none;'})) } } }, @@ -68,12 +66,8 @@ onCheckChange(e, col) { if (!col.visible) { this.checkedCounts -= 1 - this.$set(col, 'colSpan', 0) - this.$set(col, 'customCell', () => ({style: 'display: none;'})) } else { this.checkedCounts += 1 - this.$set(col, 'colSpan', undefined) - this.$set(col, 'customCell', undefined) } }, fixColumn(fixed, col) { @@ -85,7 +79,6 @@ }, setSearch(col) { this.$set(col, 'searchAble', !col.searchAble) - console.log(col) if (!col.searchAble && col.search) { this.resetSearch(col) } @@ -101,13 +94,8 @@ backColumns.forEach((back, index) => { const column = columns[index] column.visible = back.visible === undefined || back.visible - if (column.visible) { - this.$set(column, 'colSpan', undefined) - this.$set(column, 'customCell', undefined) - } else { + if (!column.visible) { counts -= 1 - this.$set(column, 'colSpan', 0) - this.$set(column, 'customCell', () => ({style: 'display: none;'})) } if (back.fixed !== undefined) { column.fixed = back.fixed @@ -125,18 +113,10 @@ onCheckAllChange(e) { if (e.target.checked) { this.checkedCounts = this.columns.length - this.columns.forEach(col => { - col.visible = true - this.$set(col, 'colSpan', undefined) - this.$set(col, 'customCell', undefined) - }) + this.columns.forEach(col => col.visible = true) } else { this.checkedCounts = 0 - this.columns.forEach(col => { - col.visible = false - this.$set(col, 'colSpan', 0) - this.$set(col, 'customCell', () => ({style: 'display: none;'})) - }) + this.columns.forEach(col => col.visible = false) } }, getConditions(columns) { diff --git a/src/components/table/advance/AdvanceTable.vue b/src/components/table/advance/AdvanceTable.vue index 573ab2a..fa8d05b 100644 --- a/src/components/table/advance/AdvanceTable.vue +++ b/src/components/table/advance/AdvanceTable.vue @@ -32,7 +32,7 @@ slot !== 'expandedRowRender' && slot !== 'title') + }, + visibleColumns(){ + return this.columns.filter(col => col.visible) } }, created() {