syncTree.vue
1.86 KB
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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
<template>
<div class="sync-tree scrollbar">
<el-tree
ref="synctree"
v-if="isLoadingTree"
:accordion="true"
:filter-node-method="filterNode"
:data="syncTreeData"
class="resource-wrap"
node-key="id"
:expand-on-click-node="false"
@node-click="handleNodeClick"
></el-tree>
</div>
</template>
<script>
// import TreeRender from "../treeRender";
export default {
data() {
return {
isLoadingTree: false,
syncTreeData: [
{
id: "0",
unid: "0",
label: "平台同步资源",
root: "平台同步资源",
children: []
}
],
defaultProps: {
children: "children",
label: "label"
}
};
},
props: {
filterText: {
type: String,
default: ""
},
treeDatas: {
type: Array,
defalut: []
}
},
components: {},
watch: {
filterText(val) {
this.$refs.synctree.filter(val);
},
treeDatas(val) {
this.treeData[0].childs = val;
}
},
methods: {
initTree(data) {
this.syncTreeData[0].children = data;
this.isLoadingTree = true;
},
filterNode(value, data) {
// console.log('filterNode:', data)
if (!value) return true;
return data.label.indexOf(value) !== -1;
},
handleNodeClick(data){
if(data.label === "平台同步资源") return;
this.$emit('syncTable', data)
},
handleRefresh(s, d, n) {
// console.log(s, d, n)
console.log("调用父级方法: ", this);
this.syncTreeData = [
{
id: "1",
label: "平台同步资源",
root: "平台同步资源",
children: []
}
];
this.$parent.getSyncTree();
}
}
};
</script>
<style scoped>
.sync-tree {
/* max-height: 216px; */
/* overflow: hidden; */
}
</style>