1. <el-tree
    2. class="filter-tree mt-20"
    3. show-checkbox
    4. node-key="id"
    5. accordion
    6. :data="data"
    7. :props="defaultProps"
    8. default-expand-all
    9. :filter-node-method="filterNode"
    10. ref="tree"
    11. >
    12. <span slot-scope="{ node, data }" class="slot-t-node">
    13. <template>
    14. <i
    15. :class="{
    16. 'el-icon-s-home': !node.expanded,
    17. 'el-icon-s-home': node.expanded,
    18. 'el-icon-user-solid': data.type === 1
    19. }"
    20. style="color: #333333"
    21. />
    22. <span>{{ node.label }}</span>
    23. </template>
    24. </span>
    25. </el-tree>
    26. export default {
    27. data() {
    28. return {
    29. defaultProps: {
    30. children: 'children', // 将tree中的每项的 childrenList 映射为 children
    31. label: 'label' // 将tree中的每项的 name 映射为 label
    32. },
    33. // 跟进人数据对象
    34. data: [
    35. {
    36. id: 1,
    37. label: '一级 1',
    38. children: [
    39. {
    40. id: 4,
    41. label: '二级 1-1',
    42. type: 1,
    43. children: [
    44. {
    45. id: 9,
    46. label: '三级 1-1-1'
    47. },
    48. {
    49. id: 10,
    50. label: '三级 1-1-2'
    51. }
    52. ]
    53. }
    54. ]
    55. }
    56. ]
    57. }
    58. },
    59. method:{
    60. filterNode(value, data) {
    61. if (!value) return true
    62. return data.label.indexOf(value) !== -1
    63. },
    64. }
    65. }

    image.png