wujingjing
2024-12-30 849603716bd60432e2c1dccb71d8ecf1e03ba866
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
<!--  -->
<template>
  <div class="boxleft">
    <title-box-vue :title="titleName">
      <template v-slot:right>
        <slot name="titleright"></slot>
      </template>
    </title-box-vue>
    <el-input placeholder="输入关键字进行过滤" suffix-icon="fks-icon-search" v-model="filterText">
    </el-input>
    <el-tree ref="tree" :data="treedata" :props="defaultProps" :show-icon="true" default-expand-all node-key="id"
      current-node-key="1" :highlight-current="true" :filter-node-method="filterNode"
      @node-click="handleNodeClick"></el-tree>
  </div>
</template>
 
<script>
import titleBoxVue from "./titleBox.vue";
export default {
  name: "leftTree",
  components: { titleBoxVue },
  props: {
    /**左侧树 标题名称 */
    titleName: {
      type: String,
      default: '功能位置',
    },
    /**树数据 */
    treedata: {
      type: Array,
      default: () => {
        return [];
      },
    },
    /**树 默认属性配置 */
    defaultProps: {
      type: Object,
      default: () => {
        return {
          children: 'children',
          label: 'label',
          id: 'id',
        };
      },
    },
  },
  data() {
    return {
      filterText: "",
    };
  },
  created() { },
  mounted() { },
  computed: {},
  watch: {
    filterText(val) {
      this.$refs.tree.filter(val);
    },
  },
  methods: {
    handleNodeClick(data) {
      //   console.log(data, 74);
      this.$emit("click", data);
    },
    filterNode(value, data) {
      if (!value) return true;
      return data.label.indexOf(value) !== -1;
    },
  },
};
</script>
<style scoped>
.boxleft {
  background-color: #fff;
}
</style>