级联选择器多选功能回显
// 选择器赋值 去除为children空数组
traverse(arr,value) {
if(arr.length){
arr.forEach(item => {
Vue.set(item,"name",item.label.name)
Vue.set(item,"id",item.label.id)
if (item.hasOwnProperty("children")&&item.children.length) {
idArr.push(item.label.id)
this.traverse(item.children,value);
} else {
if(idArr.length!=0){
idArrBox=[...idArr]
}
idArr=[]
if(!library.isNull(item.label.modelStorageId)){
if(item.label.modelJsonList[0].guid===value){
idArrBox.push(item.label.id)
this.entityArr.push(idArrBox)
this.entityArrCopy=[...this.entityArr]
return
}
}
//禁用类别
if(!item.label.modelStorageId){
Vue.set(item,"disabled",true)
}
delete item.children;
}
});
}
return arr
},
级联选择器单选功能回显
traverse(arr,num) {
if(arr.length){
arr.forEach(item => {
if(item.label.id==num){
idArr.push(item.label.id)
idArrBox=idArr
}
Vue.set(item,"name",item.label.name)
Vue.set(item,"id",item.label.id)
if (item.children.length) {
idArr.push(item.label.id)
this.traverse(item.children,num); //递归遍历
} else {
idArr=[]
delete item.children;//如果是值就显示
}
});
}
return arr
},