syncTree.vue
2.75 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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
<template>
<div class="sync-tree scrollbar">
<el-tree
ref="synctree"
:accordion="true"
:filter-node-method="filterNode"
:data="syncTreeData"
class="resource-wrap"
node-key="id"
:expand-on-click-node="false"
@node-click="handleNodeClick"
>
<span class="custom-tree-node" slot-scope="{ node, data }">
<span>
<span class="tree-label">{{
data.label
}}</span>
</span>
<span class="tree-btn" v-if="node.label=='平台同步资源'">
<i :class="{'el-icon-refresh':true,'animterefresh':refreshload}" @click.stop="nodeRefreshClick(node, data)"></i>
</span>
</span>
</el-tree>
</div>
</template>
<script>
// import TreeRender from "../treeRender";
export default {
data() {
return {
isLoadingTree: false,
refreshload: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);
setTimeout(() => {
this.$refs.synctree.filter(val);
}, 100);
},
treeDatas(val) {
this.treeData[0].childs = val;
}
},
methods: {
initTree(data) {
this.syncTreeData[0].children = data;
this.refreshload = false;
this.isLoadingTree = true;
},
filterNode(value, data) {
if (!value) return true;
return data.label.indexOf(value) !== -1;
},
handleNodeClick(data) {
debugger
if (data.label !== "平台同步资源" && data.is_leaf) {
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();
},
nodeRefreshClick(){
this.refreshload = true;
this.$emit('refreshData')
}
}
};
</script>
<style scoped>
.sync-tree {
/* max-height: 216px; */
/* overflow: hidden; */
}
.animterefresh{
animation:turn 1s linear infinite;
}
@keyframes turn{
0%{-webkit-transform:rotate(0deg);}
25%{-webkit-transform:rotate(90deg);}
50%{-webkit-transform:rotate(180deg);}
75%{-webkit-transform:rotate(270deg);}
100%{-webkit-transform:rotate(360deg);}
}
</style>