Browse Source

乐业社区下拉数据修改

fenbao
fp 1 month ago
parent
commit
16dc1560f9
  1. 37
      pages/tabBar/xjPage/xj.vue

37
pages/tabBar/xjPage/xj.vue

@ -175,8 +175,32 @@ export default {
}) })
}); });
}, },
getArea(arr) {
let newArr = [];
if (arr != undefined && arr.length > 0) {
newArr = arr.map(item => {
if (item.children != undefined && item.children.length > 0) {
this.getArea(item.children);
}
return item;
});
}
return newArr;
},
getCommunity(arr) {
if (arr != undefined && arr.length > 0) {
arr.forEach(async (item) => {
let communityList = await this.getListByParentId("1", item.deptId);
this.apartmentList = [...this.apartmentList,...communityList]
if (item.children != undefined && item.children.length > 0) {
this.getCommunity(item.children);
}
});
}
},
getTree(){ getTree(){
getdeptList().then(async (res) => { getdeptList().then((res) => {
this.deptOptions = this.handleTree( this.deptOptions = this.handleTree(
res.data, res.data,
"deptId", "deptId",
@ -184,15 +208,8 @@ export default {
"children", "children",
2 2
); );
console.log(this.deptOptions,'this.deptOptions'); const areaLst = this.getArea(this.deptOptions[0].children)
this.getCommunity(areaLst)
const deptInfo = this.deptOptions[0].children[0]
const newArr = this.deptOptions.map(item => ({
name: item.deptName,
}))
this.apartmentList = newArr
// this.deptOptions = await this.getListByParentId("1", deptInfo.deptId);
// console.log(this.deptOptions);
}); });
}, },
// //

Loading…
Cancel
Save