mirror of
https://github.com/iczer/vue-antd-admin
synced 2025-04-05 07:27:06 +08:00
feat: add responsive support for slots of StandardTable.vue; 🌟
新增:StandardTable.vue 组件的插槽增加响应式支持;
This commit is contained in:
parent
b2317e3209
commit
5b5a5ea3ef
@ -20,15 +20,20 @@
|
||||
:dataSource="dataSource"
|
||||
:rowKey="rowKey"
|
||||
:pagination="pagination"
|
||||
:expandedRowKeys="expandedRowKeys"
|
||||
:expandedRowRender="expandedRowRender"
|
||||
@change="onChange"
|
||||
:rowSelection="selectedRows ? {selectedRowKeys: selectedRowKeys, onChange: updateSelect} : undefined"
|
||||
>
|
||||
<template slot-scope="text, record, index" :slot="slot" v-for="slot in scopedSlots">
|
||||
<template slot-scope="text, record, index" :slot="slot" v-for="slot in Object.keys($scopedSlots).filter(key => key !== 'expandedRowRender') ">
|
||||
<slot :name="slot" v-bind="{text, record, index}"></slot>
|
||||
</template>
|
||||
<template :slot="slot" v-for="slot in slots">
|
||||
<template :slot="slot" v-for="slot in Object.keys($slots)">
|
||||
<slot :name="slot"></slot>
|
||||
</template>
|
||||
<template slot-scope="record, index, indent, expanded" slot="expandedRowRender" v-if="$scopedSlots.expandedRowRender">
|
||||
<slot v-bind="{record, index, indent, expanded}" name="expandedRowRender"></slot>
|
||||
</template>
|
||||
</a-table>
|
||||
</div>
|
||||
</template>
|
||||
@ -49,13 +54,13 @@ export default {
|
||||
type: [Object, Boolean],
|
||||
default: true
|
||||
},
|
||||
selectedRows: Array
|
||||
selectedRows: Array,
|
||||
expandedRowKeys: Array,
|
||||
expandedRowRender: Function
|
||||
},
|
||||
data () {
|
||||
return {
|
||||
needTotalList: [],
|
||||
scopedSlots: [],
|
||||
slots: []
|
||||
needTotalList: []
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
@ -73,16 +78,6 @@ export default {
|
||||
})
|
||||
return totalList
|
||||
},
|
||||
getScopedSlots(columns) {
|
||||
let scopedSlots = columns.filter(item => item.scopedSlots).map(item => item.scopedSlots)
|
||||
scopedSlots = scopedSlots.flatMap(item => Object.values(item))
|
||||
return scopedSlots
|
||||
},
|
||||
getSlots(columns) {
|
||||
let slots = columns.filter(item => item.slots).map(item => item.slots)
|
||||
slots = slots.flatMap(item => Object.values(item))
|
||||
return slots
|
||||
},
|
||||
onClear() {
|
||||
this.updateSelect([], [])
|
||||
this.$emit('clear')
|
||||
@ -92,8 +87,6 @@ export default {
|
||||
}
|
||||
},
|
||||
created () {
|
||||
this.scopedSlots = this.getScopedSlots(this.columns)
|
||||
this.slots = this.getSlots(this.columns)
|
||||
this.needTotalList = this.initTotalList(this.columns)
|
||||
},
|
||||
watch: {
|
||||
|
Loading…
x
Reference in New Issue
Block a user