mirror of
https://github.com/element-plus/element-plus.git
synced 2025-08-14 18:11:48 +08:00

* feat(components): [table] tree children add check strictly * fix(components): [table] remove utils console * fix(components): [table] error of selector state * docs: update * fix: remove unnecessary changes * fix: the toggleRowStatus has not been processed to selectable * docs: update * fix: the rowIndex error --------- Co-authored-by: qiang <qw13131wang@gmail.com>
78 lines
1.6 KiB
Vue
78 lines
1.6 KiB
Vue
<template>
|
|
<el-radio-group v-model="treeProps.checkStrictly">
|
|
<el-radio-button :value="true" label="true" />
|
|
<el-radio-button :value="false" label="false" />
|
|
</el-radio-group>
|
|
<el-table
|
|
:data="tableData"
|
|
:tree-props="treeProps"
|
|
row-key="id"
|
|
default-expand-all
|
|
>
|
|
<el-table-column type="selection" width="55" :selectable="selectable" />
|
|
<el-table-column prop="date" label="Date" />
|
|
<el-table-column prop="name" label="Name" />
|
|
<el-table-column prop="address" label="Address" />
|
|
</el-table>
|
|
</template>
|
|
|
|
<script lang="ts" setup>
|
|
import { reactive } from 'vue'
|
|
|
|
interface User {
|
|
id: number
|
|
date: string
|
|
name: string
|
|
address: string
|
|
hasChildren?: boolean
|
|
children?: User[]
|
|
}
|
|
|
|
const treeProps = reactive({
|
|
checkStrictly: false,
|
|
})
|
|
|
|
const selectable = (row: User) => ![1, 31].includes(row.id)
|
|
|
|
const tableData: User[] = [
|
|
{
|
|
id: 1,
|
|
date: '2016-05-02',
|
|
name: 'wangxiaohu',
|
|
address: 'No. 189, Grove St, Los Angeles',
|
|
},
|
|
{
|
|
id: 2,
|
|
date: '2016-05-04',
|
|
name: 'wangxiaohu',
|
|
address: 'No. 189, Grove St, Los Angeles',
|
|
},
|
|
{
|
|
id: 3,
|
|
date: '2016-05-01',
|
|
name: 'wangxiaohu',
|
|
address: 'No. 189, Grove St, Los Angeles',
|
|
children: [
|
|
{
|
|
id: 31,
|
|
date: '2016-05-01',
|
|
name: 'wangxiaohu',
|
|
address: 'No. 189, Grove St, Los Angeles',
|
|
},
|
|
{
|
|
id: 32,
|
|
date: '2016-05-01',
|
|
name: 'wangxiaohu',
|
|
address: 'No. 189, Grove St, Los Angeles',
|
|
},
|
|
],
|
|
},
|
|
{
|
|
id: 4,
|
|
date: '2016-05-03',
|
|
name: 'wangxiaohu',
|
|
address: 'No. 189, Grove St, Los Angeles',
|
|
},
|
|
]
|
|
</script>
|