index.vue
2.8 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
124
125
<template>
<div class="app-add-dialog"
:tabindex="1"
@blur="treeBlur"
>
<el-input
ref="searchTreeInput"
class="orgina-dialog-input"
placeholder="请输入"
@keyup.enter.native="searchClick"
v-model="inputValue">
<i slot="suffix" class="el-input__icon el-icon-search" @click="searchClick"></i>
</el-input>
<el-tree
v-show="isAsyc"
ref="searchLoadTree"
accordion
node-key="id"
:props="parentTreeProps"
:load="nodeLoad"
@node-click="nodeClick"
@check="checkChange"
lazy
v-bind="$attrs"
>
</el-tree>
<el-tree
ref="searchTree"
v-show="!isAsyc"
default-expand-all
node-key="id"
:props="parentTreeProps"
:data='parentNoAsycData'
@node-click="nodeClick"
@check="checkChange"
v-bind="$attrs"
>
</el-tree>
</div>
</template>
<script>
export default {
name:'SearchTree',
data() {
return {
inputValue:'',
isAsyc:this.parentIsAysc,
};
},
props: {
parentIsAysc: {
type: Boolean,
default: true
},
parentNoAsycData: {
type: Array,
default: () => {
return []
}
},
parentTreeProps: {
type: Object,
default:() => {
return {}
}
},
isShow: {
type: Boolean,
default: false
},
},
watch: {
parentIsAysc(val){
// console.log(val,'***********&&&&&&&&&&&&&&&&&&&^^^^^^^^^^^^^')
this.isAsyc = val;
this.isAsyc ? this.inputValue = '' : ''
},
isShow(val){
console.log(val,'****************!!!!!!!!!!!!!!!~~~~~~~~~~~~~~~~~')
this.isShow ? this.inputValue = '' : ''
}
},
created() {},
methods: {
nodeLoad(node, resolve) {
// this.orginaGetAsycData(node, resolve)
this.$emit('nodeLoad',node,resolve)
},
nodeClick(node, resolve) {
// console.log(node,'点击当前组织 数据')
this.$emit('nodeClick',node)
},
searchClick(){
// console.log('组件内 点击到了 搜索 按钮')
// this.$emit('orginaClickVal','')
this.inputValue ? this.isAsyc=false : this.isAsyc=true;
this.$emit('searchClick',this.inputValue)
},
checkChange(data){
// console.log(this.$refs.searchLoadTree.getCheckedKeys(),'组件内 选择changge ')
this.$emit('checkChange',this.$refs.searchLoadTree.getCheckedKeys())
},
treeBlur(){
console.log('treeBlur')
},
}
};
</script>
<style rel="stylesheet/scss" lang="scss" >
.app-add-dialog{
//tree 样式 start
.el-tree-node:focus>.el-tree-node__content {
background-color: #409eff;
color:#fff;
}
//tree 样式 end
//input 样式
.orgina-dialog-input{
margin-bottom: 10px;
}
}
</style>