Commit eaf68a37 by 杨北旺

添加递归方法处理组件问题

1 parent 85cbe588
......@@ -127,28 +127,12 @@ export default {
},
getDepartmentList() {
getDepartment({ id: 1 }).then(res => {
// res.map(item=>{
// if(item.relevanceMerchant){
// item.disabled = true
// }else{
// item.disabled = false
// }
// return item
// })
this.departmentList = res
this.departmentList = this.traverse(res,'relevanceMerchant')
})
},
getMerchantList() {
getMerchantTree().then(res => {
// res.map(item=>{
// if(item.entmicroName){
// item.disabled = true
// }else{
// item.disabled = false
// }
// return item
// })
this.shopList = res
this.shopList = this.traverse(res,'entmicroName')
})
},
// 关联当前选择的
......@@ -270,6 +254,22 @@ export default {
message: '已取消删除'
})
})
},
// 递归:处理层级数组
traverse(arr,string,arr1 =[]) {
arr.map((item)=>{
if(item[string]){
item.disabled = true
}else{
item.disabled = false
}
if(item.children&&item.children instanceof Array){
this.traverse(item.children,string,arr1 = [])
}
return arr1.push(item)
})
return arr1
}
}
}
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!