diff --git a/src/app/plan-management/create-plan-online-five/create-plan-online-five.component.ts b/src/app/plan-management/create-plan-online-five/create-plan-online-five.component.ts index e0b472f..b475d61 100644 --- a/src/app/plan-management/create-plan-online-five/create-plan-online-five.component.ts +++ b/src/app/plan-management/create-plan-online-five/create-plan-online-five.component.ts @@ -4,7 +4,7 @@ * @Author: sueRimn * @Date: 2021-06-16 13:56:54 * @LastEditors: sueRimn - * @LastEditTime: 2021-08-25 08:44:19 + * @LastEditTime: 2021-08-27 15:27:29 */ import { HttpClient } from '@angular/common/http'; import { Component, Inject, OnInit, Renderer2, ViewChild, Input } from '@angular/core'; @@ -64,6 +64,7 @@ export class CreatePlanOnlineFiveComponent implements OnInit { this.pattern='edit' } this.getUnitData() + //this.getpili() this.getOrganizations(); //this.getAllBuildings() } @@ -162,6 +163,72 @@ export class CreatePlanOnlineFiveComponent implements OnInit { }); }) } + //获得四周毗邻信息 + pilinData=[] + async getpili(){ + let result = await new Promise((resolve) =>{ + this.planTemplateData[1].building.forEach(element => { + let id = {buildingId:element.buildingId} + this.http.get('/api/BuildingAdjoins',{params:id}).subscribe(data=>{ + this.pilinData.push(data) + resolve(data) + }) + }); + + }) + //this.pilinData.push(result) + this.pilinData=JSON.parse(JSON.stringify(this.pilinData)) + console.log(this.pilinData) + this.pilinData.forEach((pvalue,pindex,parr)=>{ + parr[pindex].forEach((nval,nindex,narr) => { + this.planTemplateData[1].building.forEach((value,i,arr) => { + if(narr[nindex].buildingId==arr[i].buildingId){ + if(nval.direction==0){ + this.planTemplateData[1].building[i].body[2].attinf[0].value=nval.name + }else if(nval.direction==1){ + this.planTemplateData[1].building[i].body[2].attinf[1].value=nval.name + }else if(nval.direction==2){ + this.planTemplateData[1].building[i].body[2].attinf[2].value=nval.name + }else if(nval.direction==3){ + this.planTemplateData[1].building[i].body[2].attinf[3].value=nval.name + } + } + }); + + }); + + + + }) + } + //获取重点部位 + buData=[] + async getbuwei(){ + let result = await new Promise((resolve) =>{ + this.planTemplateData[1].building.forEach(element => { + let id = {buildingId:element.buildingId} + this.http.get('/api/BuildingImportantLocations',{params:id}).subscribe(data=>{ + this.buData.push(data) + resolve(data) + }) + }); + + }) + this.buData=JSON.parse(JSON.stringify(this.buData)) + console.log(this.buData) + this.buData.forEach((pvalue,pindex,parr)=>{ + if(parr[pindex].length>0){ + parr[pindex].forEach((nval,nindex,narr) => { + this.planTemplateData[1].building[pindex].body[5].attinf[0].body[0].value=nval.name + this.planTemplateData[1].building[pindex].body[5].attinf[0].body[1].value=nval.nature + this.planTemplateData[1].building[pindex].body[5].attinf[0].body[2].value=nval.position + this.planTemplateData[1].building[pindex].body[5].attinf[0].body[3].value=nval.structure + this.planTemplateData[1].building[pindex].body[5].attinf[0].body[4].value=nval.hazards + }); + } + + }) + } selectedItem: string = '封面' async clickTitleItem(item) { @@ -257,14 +324,16 @@ export class CreatePlanOnlineFiveComponent implements OnInit { } else if (this.selectedItem == '单位概况') { await this.getAllBuildings() await this.getAllBuildingsInfo() - console.log(this.buildZong) + await this.getpili() + await this.getbuwei() + //console.log(this.buildZong) this.planTemplateData[1].building.forEach(element => { - element.body[0].attinf[0].olddata = this.unitData.usci - element.body[0].attinf[1].olddata = this.unitData.buildingTypes[0].name - element.body[0].attinf[2].olddata = this.unitData.contacts - element.body[0].attinf[3].olddata = this.unitData.phone - element.body[0].attinf[4].olddata = this.unitData.organizationName - element.body[0].attinf[5].olddata = this.unitData.address + element.body[0].attinf[0].value=element.body[0].attinf[0].olddata = this.unitData.usci + element.body[0].attinf[1].value=element.body[0].attinf[1].olddata = this.unitData.buildingTypes[0].name + element.body[0].attinf[2].value=element.body[0].attinf[2].olddata = this.unitData.contacts + element.body[0].attinf[3].value=element.body[0].attinf[3].olddata = this.unitData.phone + element.body[0].attinf[4].value=element.body[0].attinf[4].olddata = this.unitData.organizationName + element.body[0].attinf[5].value=element.body[0].attinf[5].olddata = this.unitData.address if(element.body[1].attinf!=undefined){ element.body[1].attinf.forEach(eBuild => { this.buildZong.forEach(oldBuild => { @@ -279,12 +348,12 @@ export class CreatePlanOnlineFiveComponent implements OnInit { }); - this.planTemplateData[1].attribute[0].attinf[0].value=this.planTemplateData[1].attribute[0].attinf[0].olddata = this.unitData.usci + /* this.planTemplateData[1].building[0].body[0].attinf[0].value=this.planTemplateData[1].attribute[0].attinf[0].olddata = this.unitData.usci this.planTemplateData[1].attribute[0].attinf[1].value=this.planTemplateData[1].attribute[0].attinf[1].olddata = this.unitData.buildingTypes[0].name this.planTemplateData[1].attribute[0].attinf[2].value=this.planTemplateData[1].attribute[0].attinf[2].olddata = this.unitData.contacts this.planTemplateData[1].attribute[0].attinf[3].value=this.planTemplateData[1].attribute[0].attinf[3].olddata = this.unitData.phone this.planTemplateData[1].attribute[0].attinf[4].value=this.planTemplateData[1].attribute[0].attinf[4].olddata = this.unitData.organizationName - this.planTemplateData[1].attribute[0].attinf[5].value=this.planTemplateData[1].attribute[0].attinf[5].olddata = this.unitData.address + this.planTemplateData[1].attribute[0].attinf[5].value=this.planTemplateData[1].attribute[0].attinf[5].olddata = this.unitData.address */ console.log(this.planTemplateData) } /* else if (this.selectedItem == '单位概况') { @@ -300,6 +369,7 @@ export class CreatePlanOnlineFiveComponent implements OnInit { buildZong //获得所有建筑信息 async getAllBuildingsInfo(){ + const result = await new Promise((resolve) =>{ this.http.get("/api/Buildings",{ params:{ @@ -320,7 +390,7 @@ export class CreatePlanOnlineFiveComponent implements OnInit { resolve(this.buildingsData) }) } - console.log(this.buildingsData) + //console.log(this.buildingsData) if (this.planTemplateData[1].building == undefined) { this.planTemplateData[1].building = [] if(this.planTemplateData[1].attribute[1].attinf!=undefined){ @@ -337,16 +407,23 @@ export class CreatePlanOnlineFiveComponent implements OnInit { for (var i = 0; i < this.buildDataName.length; i++) { if (i == 0) { - this.planTemplateData[1].building.push({ name: this.buildDataName[i].name, body: this.planTemplateData[1].attribute, completed: true }) + this.planTemplateData[1].building.push({ name: this.buildDataName[i].name,buildingId:this.buildDataName[i].id, body: JSON.parse(JSON.stringify(this.planTemplateData[1].attribute)), completed: true }) } else { - this.planTemplateData[1].building.push({ name: this.buildDataName[i].name, body: this.planTemplateData[1].attribute, completed: false }) + this.planTemplateData[1].building.push({ name: this.buildDataName[i].name,buildingId:this.buildDataName[i].id, body: JSON.parse(JSON.stringify(this.planTemplateData[1].attribute)), completed: false }) } } + } + }) }) - //console.log(result) + + for(var a=0;a0){ + this.planTemplateData[1].building[a].body[0].completed=false + } + } this.buildZong=result } @@ -991,18 +1068,7 @@ export class CreatePlanOnlineFiveComponent implements OnInit { }) }) this.allBuildings = data - /* if (this.planTemplateData[1].building == undefined) { - this.planTemplateData[1].building = [] - for (var i = 0; i < this.allBuildings.length; i++) { - if (i == 0) { - this.planTemplateData[1].building.push({ name: this.allBuildings[i].name, body: this.planTemplateData[1].attribute, completed: true }) - } else { - this.planTemplateData[1].building.push({ name: this.allBuildings[i].name, body: this.planTemplateData[1].attribute, completed: false }) - } - - } - } */ - this.group = this.planTemplateData[1].building + //this.group = this.planTemplateData[1].building //delete this.planTemplateData[0].attribute }) @@ -1101,6 +1167,8 @@ export class CreatePlanOnlineFiveComponent implements OnInit { this.buildingName = item.name this.clicki = i console.log(item, this.clicki) + /* this.planTemplateData[1].building[1].body[0].completed=false + this.planTemplateData[1].building[0].body[0].completed=true */ //this.group=this.planTemplateData[1].building[this.clicki].body }