2022-07-21 15:59:39 +08:00
|
|
|
<script>
|
|
|
|
export default {
|
2022-10-11 15:09:32 +08:00
|
|
|
name: 'TableBody',
|
2022-07-21 15:59:39 +08:00
|
|
|
functional: true,
|
|
|
|
props: {
|
|
|
|
columns: {
|
|
|
|
type: Array,
|
2022-10-11 15:09:32 +08:00
|
|
|
default: () => []
|
|
|
|
}
|
2022-07-21 15:59:39 +08:00
|
|
|
},
|
|
|
|
render(h, context) {
|
2022-10-11 15:09:32 +08:00
|
|
|
const nodes = []
|
|
|
|
const { columns } = context.props
|
|
|
|
const { children = [] } = context
|
|
|
|
if (!columns?.length) return children
|
2022-08-22 17:54:31 +08:00
|
|
|
children.forEach((ele) => {
|
2022-10-11 15:09:32 +08:00
|
|
|
const { prop, type } = ele.componentOptions?.propsData || {}
|
|
|
|
if (columns.includes(prop) || type === 'selection') {
|
|
|
|
nodes.push(ele)
|
2022-08-22 17:54:31 +08:00
|
|
|
}
|
2022-10-11 15:09:32 +08:00
|
|
|
})
|
|
|
|
return nodes
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</script>
|