Browse Source

区域新增第三级, 项目新增修改列表 显示第三级

master
zhanyunjiu 3 years ago
parent
commit
2fa38230a3
  1. 25
      src/views/farm/area/index.vue
  2. 44
      src/views/farm/project/index.vue

25
src/views/farm/area/index.vue

@ -146,28 +146,23 @@ export default {
this.addBeginAndEndTime(params, this.dateRangeCreateTime, 'createTime');
//
getAreaPage(params).then(response => {
this.list = response.data.list;
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) => {
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;
});

44
src/views/farm/project/index.vue

@ -282,19 +282,31 @@ export default {
areasConvert(areas){
let areasName = "";
areas.forEach(selectArea =>{
this.areasList.forEach(son => {
//
let name = "";
if(selectArea == son.id){
this.areasList.forEach(parent =>{
if(parent.id == son.parentId){
name = parent.name +"/";
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;
}
})
name += son.name ;
areasName += name +"\n";
}
}
})
let name = "";
if(firstName != ''){
name = (firstName+"/"+secondName+"/"+thiredName+"\n");
}else{
name = (secondName+"/"+thiredName+"\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 })

Loading…
Cancel
Save