<el-tree
class="filter-tree mt-20"
show-checkbox
node-key="id"
accordion
:data="data"
:props="defaultProps"
default-expand-all
:filter-node-method="filterNode"
ref="tree"
>
<span slot-scope="{ node, data }" class="slot-t-node">
<template>
<i
:class="{
'el-icon-s-home': !node.expanded,
'el-icon-s-home': node.expanded,
'el-icon-user-solid': data.type === 1
}"
style="color: #333333"
/>
<span>{{ node.label }}</span>
</template>
</span>
</el-tree>
export default {
data() {
return {
defaultProps: {
children: 'children', // 将tree中的每项的 childrenList 映射为 children
label: 'label' // 将tree中的每项的 name 映射为 label
},
// 跟进人数据对象
data: [
{
id: 1,
label: '一级 1',
children: [
{
id: 4,
label: '二级 1-1',
type: 1,
children: [
{
id: 9,
label: '三级 1-1-1'
},
{
id: 10,
label: '三级 1-1-2'
}
]
}
]
}
]
}
},
method:{
filterNode(value, data) {
if (!value) return true
return data.label.indexOf(value) !== -1
},
}
}