mirror of
https://github.com/iczer/vue-antd-admin
synced 2025-04-06 04:00:06 +08:00
fix: the problem of hiding column of AdvancedTable.vue; 🐛 #139
修复:高级表格无法隐藏列的bug;
This commit is contained in:
parent
8130f9f250
commit
97979c5059
@ -59,8 +59,6 @@
|
|||||||
}
|
}
|
||||||
if (!col.visible) {
|
if (!col.visible) {
|
||||||
this.checkedCounts -= 1
|
this.checkedCounts -= 1
|
||||||
this.$set(col, 'colSpan', 0)
|
|
||||||
this.$set(col, 'customCell', () => ({style: 'display: none;'}))
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -68,12 +66,8 @@
|
|||||||
onCheckChange(e, col) {
|
onCheckChange(e, col) {
|
||||||
if (!col.visible) {
|
if (!col.visible) {
|
||||||
this.checkedCounts -= 1
|
this.checkedCounts -= 1
|
||||||
this.$set(col, 'colSpan', 0)
|
|
||||||
this.$set(col, 'customCell', () => ({style: 'display: none;'}))
|
|
||||||
} else {
|
} else {
|
||||||
this.checkedCounts += 1
|
this.checkedCounts += 1
|
||||||
this.$set(col, 'colSpan', undefined)
|
|
||||||
this.$set(col, 'customCell', undefined)
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
fixColumn(fixed, col) {
|
fixColumn(fixed, col) {
|
||||||
@ -85,7 +79,6 @@
|
|||||||
},
|
},
|
||||||
setSearch(col) {
|
setSearch(col) {
|
||||||
this.$set(col, 'searchAble', !col.searchAble)
|
this.$set(col, 'searchAble', !col.searchAble)
|
||||||
console.log(col)
|
|
||||||
if (!col.searchAble && col.search) {
|
if (!col.searchAble && col.search) {
|
||||||
this.resetSearch(col)
|
this.resetSearch(col)
|
||||||
}
|
}
|
||||||
@ -101,13 +94,8 @@
|
|||||||
backColumns.forEach((back, index) => {
|
backColumns.forEach((back, index) => {
|
||||||
const column = columns[index]
|
const column = columns[index]
|
||||||
column.visible = back.visible === undefined || back.visible
|
column.visible = back.visible === undefined || back.visible
|
||||||
if (column.visible) {
|
if (!column.visible) {
|
||||||
this.$set(column, 'colSpan', undefined)
|
|
||||||
this.$set(column, 'customCell', undefined)
|
|
||||||
} else {
|
|
||||||
counts -= 1
|
counts -= 1
|
||||||
this.$set(column, 'colSpan', 0)
|
|
||||||
this.$set(column, 'customCell', () => ({style: 'display: none;'}))
|
|
||||||
}
|
}
|
||||||
if (back.fixed !== undefined) {
|
if (back.fixed !== undefined) {
|
||||||
column.fixed = back.fixed
|
column.fixed = back.fixed
|
||||||
@ -125,18 +113,10 @@
|
|||||||
onCheckAllChange(e) {
|
onCheckAllChange(e) {
|
||||||
if (e.target.checked) {
|
if (e.target.checked) {
|
||||||
this.checkedCounts = this.columns.length
|
this.checkedCounts = this.columns.length
|
||||||
this.columns.forEach(col => {
|
this.columns.forEach(col => col.visible = true)
|
||||||
col.visible = true
|
|
||||||
this.$set(col, 'colSpan', undefined)
|
|
||||||
this.$set(col, 'customCell', undefined)
|
|
||||||
})
|
|
||||||
} else {
|
} else {
|
||||||
this.checkedCounts = 0
|
this.checkedCounts = 0
|
||||||
this.columns.forEach(col => {
|
this.columns.forEach(col => col.visible = false)
|
||||||
col.visible = false
|
|
||||||
this.$set(col, 'colSpan', 0)
|
|
||||||
this.$set(col, 'customCell', () => ({style: 'display: none;'}))
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
getConditions(columns) {
|
getConditions(columns) {
|
||||||
|
@ -32,7 +32,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<a-table
|
<a-table
|
||||||
v-bind="{...$options.propsData, title: undefined, loading: false}"
|
v-bind="{...$options.propsData, columns: visibleColumns, title: undefined, loading: false}"
|
||||||
:size="sSize"
|
:size="sSize"
|
||||||
@expandedRowsChange="onExpandedRowsChange"
|
@expandedRowsChange="onExpandedRowsChange"
|
||||||
@change="onChange"
|
@change="onChange"
|
||||||
@ -109,6 +109,9 @@
|
|||||||
},
|
},
|
||||||
scopedSlots() {
|
scopedSlots() {
|
||||||
return Object.keys(this.$scopedSlots).filter(slot => slot !== 'expandedRowRender' && slot !== 'title')
|
return Object.keys(this.$scopedSlots).filter(slot => slot !== 'expandedRowRender' && slot !== 'title')
|
||||||
|
},
|
||||||
|
visibleColumns(){
|
||||||
|
return this.columns.filter(col => col.visible)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
created() {
|
created() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user