From 125879b02ce3e896157357196c1677d4be31ad7a Mon Sep 17 00:00:00 2001 From: chenghongxing <1126263215@qq.com> Date: Sun, 29 Nov 2020 11:56:52 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=EF=BC=9AAdvanceTable=20?= =?UTF-8?q?=E7=BB=84=E4=BB=B6=E5=BC=82=E6=AD=A5=E8=8E=B7=E5=8F=96=E5=88=97?= =?UTF-8?q?=E9=85=8D=E7=BD=AE=E4=B8=8D=E7=94=9F=E6=95=88=E7=9A=84=E9=97=AE?= =?UTF-8?q?=E9=A2=98=EF=BC=9B:bug:=20#159=20#160=20#161=20fix:=20the=20asy?= =?UTF-8?q?nc=20configuration=20of=20columns=20not=20to=20take=20effect=20?= =?UTF-8?q?in=20AdvanceTable.vue;?= 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 | 2 +- src/components/table/advance/SearchArea.vue | 20 ++++++++++---- 3 files changed, 33 insertions(+), 15 deletions(-) diff --git a/src/components/table/advance/ActionColumns.vue b/src/components/table/advance/ActionColumns.vue index 2dc9d06..3a97ec9 100644 --- a/src/components/table/advance/ActionColumns.vue +++ b/src/components/table/advance/ActionColumns.vue @@ -49,18 +49,16 @@ checkedCounts(val) { this.checkAll = val === this.columns.length this.indeterminate = val > 0 && val < this.columns.length + }, + columns(newVal, oldVal) { + if (newVal != oldVal) { + this.checkedCounts = newVal.length + this.formatColumns(newVal) + } } }, created() { - this.$emit('update:visibleColumns', [...this.columns]) - for (let col of this.columns) { - if (col.visible === undefined) { - this.$set(col, 'visible', true) - } - if (!col.visible) { - this.checkedCounts -= 1 - } - } + this.formatColumns(this.columns) }, methods: { onCheckChange(e, col) { @@ -126,6 +124,16 @@ conditions[col.dataIndex] = col.search.value }) return conditions + }, + formatColumns(columns) { + for (let col of columns) { + if (col.visible === undefined) { + this.$set(col, 'visible', true) + } + if (!col.visible) { + this.checkedCounts -= 1 + } + } } } } diff --git a/src/components/table/advance/AdvanceTable.vue b/src/components/table/advance/AdvanceTable.vue index fa8d05b..c64da1b 100644 --- a/src/components/table/advance/AdvanceTable.vue +++ b/src/components/table/advance/AdvanceTable.vue @@ -32,7 +32,7 @@ - +
@@ -70,12 +73,14 @@ props: ['columns', 'formatConditions'], inject: ['table'], created() { - this.columns.forEach(item => { - this.$set(item, 'search', {...item.search, visible: false, value: undefined, format: this.getFormat(item)}) - }) - console.log(this.columns) + this.formatColumns(this.columns) }, watch: { + columns(newVal, oldVal) { + if (newVal != oldVal) { + this.formatColumns(newVal) + } + }, searchCols(newVal, oldVal) { if (newVal.length != oldVal.length) { const newConditions = this.getConditions(newVal) @@ -218,6 +223,11 @@ return true } return false + }, + formatColumns(columns) { + columns.forEach(item => { + this.$set(item, 'search', {...item.search, visible: false, value: undefined, format: this.getFormat(item)}) + }) } } }