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)}) + }) } } }