|
|
@@ -74,11 +74,12 @@
|
|
74
|
74
|
data() {
|
|
75
|
75
|
return {
|
|
76
|
76
|
candidates:[],
|
|
|
77
|
+ searchSelectData:[],
|
|
77
|
78
|
nodeList:[],
|
|
|
79
|
+
|
|
78
|
80
|
}
|
|
79
|
81
|
},
|
|
80
|
82
|
created() {
|
|
81
|
|
- // console.log(this.showSearch)
|
|
82
|
83
|
if (this.managedMode) {
|
|
83
|
84
|
return
|
|
84
|
85
|
}
|
|
|
@@ -87,19 +88,35 @@
|
|
87
|
88
|
})
|
|
88
|
89
|
},
|
|
89
|
90
|
methods: {
|
|
|
91
|
+
|
|
90
|
92
|
//搜索框选择员工
|
|
91
|
93
|
handleInput(e){
|
|
92
|
94
|
if(this.candidates.indexOf(e) != -1){
|
|
93
|
95
|
let index = this.candidates.indexOf(e);
|
|
94
|
96
|
let node = this.nodeList[index];
|
|
95
|
|
- console.log(this.candidates.indexOf(e));
|
|
96
|
|
- console.log(node);
|
|
97
|
|
- this._dispatchEvent()
|
|
98
|
|
- this.$emit('searchTrue', node)
|
|
99
|
|
- // this.$emit('change', node,'search')
|
|
100
|
|
- // this.$emit('datachange', node)
|
|
|
97
|
+ this.getSearchDataList(node)
|
|
|
98
|
+ }
|
|
|
99
|
+ },
|
|
|
100
|
+ getSearchDataList(node){
|
|
|
101
|
+ const posData = node.position.split('-')
|
|
|
102
|
+ this.dataList = []
|
|
|
103
|
+ let dataObj = {}
|
|
|
104
|
+ let dataSelectObj ={}
|
|
|
105
|
+ for(let i=1 ;i < posData.length; i++ ){
|
|
|
106
|
+ if(i===1){
|
|
|
107
|
+ dataObj = this.localdata
|
|
|
108
|
+ dataSelectObj = this.localdata[posData[i-1]*1]
|
|
|
109
|
+ }else {
|
|
|
110
|
+ dataObj = dataSelectObj.children
|
|
|
111
|
+ dataSelectObj = dataSelectObj.children[posData[i-1]*1]
|
|
|
112
|
+ }
|
|
|
113
|
+ this.dataList.push(dataObj)
|
|
|
114
|
+ this.selected.splice(this.selected.length-1,0,{
|
|
|
115
|
+ text:dataSelectObj.text,
|
|
|
116
|
+ value:dataSelectObj.value
|
|
|
117
|
+ })
|
|
101
|
118
|
}
|
|
102
|
|
- //console.log(this.loadData());
|
|
|
119
|
+ this.handleNodeClick(node, node.zIndex, node.sort)
|
|
103
|
120
|
},
|
|
104
|
121
|
//点击选择组别
|
|
105
|
122
|
handleClick(item){
|
|
|
@@ -129,28 +146,30 @@
|
|
129
|
146
|
this.selectedIndex = index
|
|
130
|
147
|
},
|
|
131
|
148
|
handleNodeClick(item, i, j) {
|
|
132
|
|
-
|
|
133
|
149
|
if (item.disable) {
|
|
134
|
150
|
return
|
|
135
|
151
|
}
|
|
136
|
152
|
const node = this.dataList[i][j]
|
|
137
|
153
|
const text = node[this.map.text]
|
|
138
|
154
|
const value = node[this.map.value]
|
|
|
155
|
+
|
|
139
|
156
|
if (i < this.selected.length - 1) {
|
|
140
|
157
|
this.selected.splice(i, this.selected.length - i)
|
|
141
|
158
|
this.selected.push({
|
|
142
|
159
|
text,
|
|
143
|
160
|
value
|
|
144
|
161
|
})
|
|
145
|
|
- // console.log(this.selected);
|
|
146
|
162
|
} else if (i === this.selected.length - 1) {
|
|
147
|
163
|
this.selected.splice(i, 1, {
|
|
148
|
164
|
text,
|
|
149
|
165
|
value
|
|
150
|
166
|
})
|
|
151
|
|
- // console.log(this.selected);
|
|
152
|
167
|
}
|
|
153
|
|
-
|
|
|
168
|
+ if(node.children&&node.children.length>0){
|
|
|
169
|
+ this._updateBindData(node)
|
|
|
170
|
+ this.onSelectedChange(node, false)
|
|
|
171
|
+ return
|
|
|
172
|
+ }
|
|
154
|
173
|
if (node.isleaf) {
|
|
155
|
174
|
this.onSelectedChange(node, node.isleaf)
|
|
156
|
175
|
return
|
|
|
@@ -182,7 +201,6 @@
|
|
182
|
201
|
}, this._nodeWhere())
|
|
183
|
202
|
return
|
|
184
|
203
|
}
|
|
185
|
|
-
|
|
186
|
204
|
this.onSelectedChange(node, false)
|
|
187
|
205
|
},
|
|
188
|
206
|
updateData(data) {
|
|
|
@@ -201,7 +219,6 @@
|
|
201
|
219
|
if (!this._treeData.length) {
|
|
202
|
220
|
this.loadData()
|
|
203
|
221
|
} else {
|
|
204
|
|
- //this.selected = data.selected
|
|
205
|
222
|
this._updateBindData()
|
|
206
|
223
|
}
|
|
207
|
224
|
},
|