区域新增第三级, 项目新增修改列表 显示第三级
This commit is contained in:
@@ -148,26 +148,21 @@ export default {
|
||||
getAreaPage(params).then(response => {
|
||||
this.list = response.data.list;
|
||||
this.total = response.data.total;
|
||||
|
||||
this.allList = this.list;
|
||||
let filterList = this.list.filter(t => t.parentId == 0);
|
||||
let oneList = [];
|
||||
if(filterList.length == 0){
|
||||
//没有上级
|
||||
this.list.forEach(t => {
|
||||
oneList.push({id:one.id, name:one.name, occupied:one.occupied, area:one.area, createTime:one.createTime, children:twoList});
|
||||
})
|
||||
}else{
|
||||
filterList.forEach((one) => {
|
||||
let twoList = [];
|
||||
this.list.forEach((two) => {
|
||||
if(one.id == two.parentId){
|
||||
twoList.push({id:two.id, name:two.name, occupied:two.occupied, area:two.area, createTime:two.createTime})
|
||||
}
|
||||
let filterTwoList = this.list.filter(t => t.parentId == one.id);
|
||||
filterTwoList.forEach(two =>{
|
||||
let filterThreeList = this.list.filter(t => t.parentId == two.id);
|
||||
let threeList = [];
|
||||
filterThreeList.forEach(three =>{
|
||||
threeList.push({id:three.id, name:three.name, occupied:three.occupied, area:three.area, createTime:three.createTime});
|
||||
})
|
||||
twoList.push({id:two.id, name:two.name, occupied:two.occupied, area:two.area, createTime:two.createTime, children:threeList})
|
||||
})
|
||||
oneList.push({id:one.id, name:one.name, occupied:one.occupied, area:one.area, createTime:one.createTime, children:twoList});
|
||||
})
|
||||
}
|
||||
this.list = oneList;
|
||||
this.loading = false;
|
||||
});
|
||||
|
||||
@@ -282,19 +282,31 @@ export default {
|
||||
areasConvert(areas){
|
||||
let areasName = "";
|
||||
areas.forEach(selectArea =>{
|
||||
this.areasList.forEach(son => {
|
||||
//二级区域
|
||||
let firstName = "";
|
||||
let secondName = "";
|
||||
let thiredName = "";
|
||||
this.areasList.forEach(area => {
|
||||
if(area.id == selectArea){
|
||||
thiredName = area.name;
|
||||
if(area.parentId != 0){
|
||||
let tempArea = this.areasList.filter(parent => parent.id == area.parentId)[0];
|
||||
secondName = tempArea.name;
|
||||
if(tempArea.parentId != 0){
|
||||
tempArea = this.areasList.filter(parent => parent.id == tempArea.parentId)[0];
|
||||
firstName = tempArea.name;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
})
|
||||
|
||||
let name = "";
|
||||
if(selectArea == son.id){
|
||||
this.areasList.forEach(parent =>{
|
||||
if(parent.id == son.parentId){
|
||||
name = parent.name +"/";
|
||||
if(firstName != ''){
|
||||
name = (firstName+"/"+secondName+"/"+thiredName+"\n");
|
||||
}else{
|
||||
name = (secondName+"/"+thiredName+"\n");
|
||||
}
|
||||
})
|
||||
name += son.name ;
|
||||
areasName += name +"\n";
|
||||
}
|
||||
})
|
||||
areasName += name;
|
||||
})
|
||||
return areasName;
|
||||
},
|
||||
@@ -493,8 +505,16 @@ export default {
|
||||
let secondList = [];
|
||||
sonList.forEach(s => {
|
||||
if (p.id == s.parentId) {
|
||||
this.areasSonList.push(s);
|
||||
secondList.push({ value: s.id, label: s.name });
|
||||
let three = this.areasList.filter(t => t.parentId == s.id);
|
||||
if(three.length == 0){
|
||||
secondList.push({ value: s.id, label: s.name});
|
||||
}else{
|
||||
let threeList = [];
|
||||
three.forEach(three =>{
|
||||
threeList.push({value:three.id, label:three.name})
|
||||
})
|
||||
secondList.push({ value: s.id, label: s.name ,children:threeList});
|
||||
}
|
||||
}
|
||||
})
|
||||
firstList.push({ value: p.id, label: p.name, children: secondList })
|
||||
|
||||
Reference in New Issue
Block a user