mirror of
https://github.com/iczer/vue-antd-admin
synced 2025-04-06 04:00:06 +08:00
fix: the async configuration of columns not to take effect in AdvanceTable.vue;
This commit is contained in:
parent
6451795046
commit
125879b02c
src/components/table/advance
@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -32,7 +32,7 @@
|
||||
</div>
|
||||
</div>
|
||||
<a-table
|
||||
v-bind="{...$options.propsData, columns: visibleColumns, title: undefined, loading: false}"
|
||||
v-bind="{...this.$props, columns: visibleColumns, title: undefined, loading: false}"
|
||||
:size="sSize"
|
||||
@expandedRowsChange="onExpandedRowsChange"
|
||||
@change="onChange"
|
||||
|
@ -7,7 +7,10 @@
|
||||
{{col.title}}:
|
||||
</template>
|
||||
<slot v-else-if="col.slots && col.slots.title" :name="col.slots.title"></slot>
|
||||
<a-switch @change="onSwitchChange(col)" class="switch" v-model="col.search.value" size="small" checked-children="是" un-checked-children="否" />
|
||||
<a-switch @change="onSwitchChange(col)" class="switch" v-model="col.search.value" size="small"
|
||||
:checked-children="(col.search.switchOptions && col.search.switchOptions.checkedText) || '是'"
|
||||
:un-checked-children="(col.search.switchOptions && col.search.switchOptions.uncheckedText) || '否'"
|
||||
/>
|
||||
<a-icon v-if="col.search.value !== undefined" class="close" @click="e => onCloseClick(e, col)" type="close-circle" theme="filled" />
|
||||
</div>
|
||||
<div v-else-if="col.dataType === 'time'" :class="['title', {active: col.search.value}]">
|
||||
@ -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)})
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user