Commit eaf68a37 by 杨北旺

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

1 parent 85cbe588
...@@ -127,28 +127,12 @@ export default { ...@@ -127,28 +127,12 @@ export default {
}, },
getDepartmentList() { getDepartmentList() {
getDepartment({ id: 1 }).then(res => { getDepartment({ id: 1 }).then(res => {
// res.map(item=>{ this.departmentList = this.traverse(res,'relevanceMerchant')
// if(item.relevanceMerchant){
// item.disabled = true
// }else{
// item.disabled = false
// }
// return item
// })
this.departmentList = res
}) })
}, },
getMerchantList() { getMerchantList() {
getMerchantTree().then(res => { getMerchantTree().then(res => {
// res.map(item=>{ this.shopList = this.traverse(res,'entmicroName')
// if(item.entmicroName){
// item.disabled = true
// }else{
// item.disabled = false
// }
// return item
// })
this.shopList = res
}) })
}, },
// 关联当前选择的 // 关联当前选择的
...@@ -270,6 +254,22 @@ export default { ...@@ -270,6 +254,22 @@ export default {
message: '已取消删除' 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!