From 9386328ad365d7008cde3f4ed0aaca685b75fd5e Mon Sep 17 00:00:00 2001 From: SHAOJIAHAO <55341701@qq.com> Date: Thu, 2 Sep 2021 16:08:20 +0800 Subject: [PATCH] =?UTF-8?q?[=E5=AE=8C=E5=96=84]=E5=AE=8C=E5=96=84planTempl?= =?UTF-8?q?ateData[index]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../create-plan-online-five.component.html | 6 +- .../create-plan-online-five.component.scss | 3 + .../create-plan-online-five.component.ts | 776 +++++++++--------- 3 files changed, 400 insertions(+), 385 deletions(-) diff --git a/src/app/plan-management/create-plan-online-five/create-plan-online-five.component.html b/src/app/plan-management/create-plan-online-five/create-plan-online-five.component.html index b1e9429..37c2507 100644 --- a/src/app/plan-management/create-plan-online-five/create-plan-online-five.component.html +++ b/src/app/plan-management/create-plan-online-five/create-plan-online-five.component.html @@ -175,10 +175,10 @@ 建筑列表
-
+
- {{item.name}} + {{item.name}}
@@ -681,7 +681,7 @@ display: flex; flex-direction: column; overflow-y: auto;"> -
+
{ - this.buildDataName = data - for (let i = 0; i < data.length; i++){ - this.http.get("/api/BuildingBasicInfos",{ // 循环请求当前单位建筑每一个建筑的信息保存到数组中 - params:{ - companyId :this.unitId, - buildingId:data[i].id, - buildingType:data[i].buildingTypes[0].id - } - }).subscribe((buildingsData:any)=>{ - //console.log(buildingsData) - this.buildingsData.push(buildingsData[0]) - resolve(this.buildingsData) - }) - } - //console.log(this.buildingsData) - if (this.planTemplateData[1].building == undefined) { - this.planTemplateData[1].building = [] - if(this.planTemplateData[1].attribute[1].attinf!=undefined){ - this.planTemplateData[1].attribute[1].attinf.forEach(pData => { - this.buildingsData.forEach((bDara,bi,bArr)=>{ - if(bDara.buildingBasicGroups.length>0){ - bDara.buildingBasicGroups[0].propertyInfos.forEach(bInfo => { - pData.propertyValue=pData.olddata=bInfo.propertyValue - }); - } - }) - }); + async getAllBuildingsInfo() { + let index = this.getArrayIndex(this.planTemplateData,'单位概况') + const result = await new Promise((resolve) => { + this.http.get("/api/Buildings", { + params: { + companyId: this.unitId + } + }).subscribe(async (data: any) => { + this.buildDataName = data + for (let i = 0; i < data.length; i++) { + this.http.get("/api/BuildingBasicInfos", { // 循环请求当前单位建筑每一个建筑的信息保存到数组中 + params: { + companyId: this.unitId, + buildingId: data[i].id, + buildingType: data[i].buildingTypes[0].id } - - for (var i = 0; i < this.buildDataName.length; i++) { - if (i == 0) { - 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,buildingId:this.buildDataName[i].id, body: JSON.parse(JSON.stringify(this.planTemplateData[1].attribute)), completed: false }) - } - + }).subscribe((buildingsData: any) => { + //console.log(buildingsData) + this.buildingsData.push(buildingsData[0]) + resolve(this.buildingsData) + }) + } + //console.log(this.buildingsData) + if (this.planTemplateData[index].building == undefined) { + this.planTemplateData[index].building = [] + if (this.planTemplateData[index].attribute[1].attinf != undefined) { + this.planTemplateData[index].attribute[1].attinf.forEach(pData => { + this.buildingsData.forEach((bDara, bi, bArr) => { + if (bDara.buildingBasicGroups.length > 0) { + bDara.buildingBasicGroups[0].propertyInfos.forEach(bInfo => { + pData.propertyValue = pData.olddata = bInfo.propertyValue + }); + } + }) + }); + } + + for (var i = 0; i < this.buildDataName.length; i++) { + if (i == 0) { + this.planTemplateData[index].building.push({ name: this.buildDataName[i].name, buildingId: this.buildDataName[i].id, body: JSON.parse(JSON.stringify(this.planTemplateData[index].attribute)), completed: true }) + } else { + this.planTemplateData[index].building.push({ name: this.buildDataName[i].name, buildingId: this.buildDataName[i].id, body: JSON.parse(JSON.stringify(this.planTemplateData[index].attribute)), completed: false }) } - + } - + + } + + }) }) - }) - - for(var a=0;a0){ - this.planTemplateData[1].building[a].body[0].completed=false + + for (var a = 0; a < this.planTemplateData[index].building.length; a++) { + if (a > 0) { + this.planTemplateData[index].building[a].body[0].completed = false + } } - } - this.buildZong=result + this.buildZong = result } @@ -516,8 +529,8 @@ export class CreatePlanOnlineFiveComponent implements OnInit { } this.planTemplateData.unshift(obj) } - else if(this.planTemplateData[0].groupName == '封面'){ - this.planTemplateData[0].attribute.objName=this.unitData.name + else if (this.planTemplateData[0].groupName == '封面') { + this.planTemplateData[0].attribute.objName = this.unitData.name } this.planTemplateData.forEach(element => { if (element.groupName == '重点图示') { @@ -550,9 +563,9 @@ export class CreatePlanOnlineFiveComponent implements OnInit { } //引入数据json - yinJson={ + yinJson = { //组织指挥 - organizationCommands:{ + organizationCommands: { tableCount: { totalCount: 0, tables: [ @@ -571,7 +584,7 @@ export class CreatePlanOnlineFiveComponent implements OnInit { } }, //社会联动 - socialLinkages:{ + socialLinkages: { tableCount: { totalCount: 0, tables: [ @@ -590,7 +603,7 @@ export class CreatePlanOnlineFiveComponent implements OnInit { } }, //勤务保障 - serviceSupports:{ + serviceSupports: { tableCount: { totalCount: 0, tables: [ @@ -609,7 +622,7 @@ export class CreatePlanOnlineFiveComponent implements OnInit { } }, //辅助决策 - decisionSupports:{ + decisionSupports: { tableCount: { totalCount: 0, tables: [ @@ -628,11 +641,11 @@ export class CreatePlanOnlineFiveComponent implements OnInit { } }, } - async yinRu(type){ - if(type==0){ - this.yinJson={ + async yinRu(type) { + if (type == 0) { + this.yinJson = { //组织指挥 - organizationCommands:{ + organizationCommands: { tableCount: { totalCount: 0, tables: [ @@ -651,7 +664,7 @@ export class CreatePlanOnlineFiveComponent implements OnInit { } }, //社会联动 - socialLinkages:{ + socialLinkages: { tableCount: { totalCount: 0, tables: [ @@ -670,7 +683,7 @@ export class CreatePlanOnlineFiveComponent implements OnInit { } }, //勤务保障 - serviceSupports:{ + serviceSupports: { tableCount: { totalCount: 0, tables: [ @@ -689,7 +702,7 @@ export class CreatePlanOnlineFiveComponent implements OnInit { } }, //辅助决策 - decisionSupports:{ + decisionSupports: { tableCount: { totalCount: 0, tables: [ @@ -708,231 +721,235 @@ export class CreatePlanOnlineFiveComponent implements OnInit { } }, } - var orgtableCount=0 - var orginputCount=0 - var orgtextAreaCount=0 - var orgtreeCount=0 - this.planTemplateData.forEach((value,index,array) => { - if(value.groupName=='组织指挥'){ - this.planTemplateData[4].attribute.forEach((orgvalue,orgi,orgArr) => { - if(orgArr[orgi].level=='1'){ + var orgtableCount = 0 + var orginputCount = 0 + var orgtextAreaCount = 0 + var orgtreeCount = 0 + this.planTemplateData.forEach((value, index, array) => { + if (value.groupName == '组织指挥') { + value.attribute.forEach((orgvalue, orgi, orgArr) => { + if (orgArr[orgi].level == '1') { orgtableCount++ - this.yinJson.organizationCommands.tableCount.tables.push({itemCount:orgArr[orgi].tableth.length}) - }else if(orgArr[orgi].level=='2'){ + this.yinJson.organizationCommands.tableCount.tables.push({ itemCount: orgArr[orgi].tableth.length }) + } else if (orgArr[orgi].level == '2') { orginputCount++ - this.yinJson.organizationCommands.inputCount.inputs.push({colCount:orgArr[orgi].lieNumber,rowCount:orgArr[orgi].hNumber}) - }else if(orgArr[orgi].level=='3'){ + this.yinJson.organizationCommands.inputCount.inputs.push({ colCount: orgArr[orgi].lieNumber, rowCount: orgArr[orgi].hNumber }) + } else if (orgArr[orgi].level == '3') { orgtextAreaCount++ - }else if(orgArr[orgi].level=='4'){ + } else if (orgArr[orgi].level == '4') { orgtreeCount++ } }); } - - this.yinJson.organizationCommands.tableCount.totalCount=orgtableCount - this.yinJson.organizationCommands.inputCount.totalCount=orginputCount - this.yinJson.organizationCommands.textAreaCount.totalCount=orgtextAreaCount - this.yinJson.organizationCommands.treeCount.totalCount=orgtreeCount - var shetableCount=0 - var sheinputCount=0 - var shetextAreaCount=0 - var shetreeCount=0 - if(value.groupName=='社会联动'){ - this.planTemplateData[6].attribute.forEach((orgvalue,orgi,orgArr) => { - if(orgArr[orgi].level=='1'){ + + this.yinJson.organizationCommands.tableCount.totalCount = orgtableCount + this.yinJson.organizationCommands.inputCount.totalCount = orginputCount + this.yinJson.organizationCommands.textAreaCount.totalCount = orgtextAreaCount + this.yinJson.organizationCommands.treeCount.totalCount = orgtreeCount + var shetableCount = 0 + var sheinputCount = 0 + var shetextAreaCount = 0 + var shetreeCount = 0 + if (value.groupName == '社会联动') { + value.attribute.forEach((orgvalue, orgi, orgArr) => { + if (orgArr[orgi].level == '1') { shetableCount++ //this.yinJson.organizationCommands.tableCount.tables.push({itemCount:orgtableCount}) - }else if(orgArr[orgi].level=='2'){ + } else if (orgArr[orgi].level == '2') { sheinputCount++ - this.yinJson.socialLinkages.inputCount.inputs.push({colCount:orgArr[orgi].lieNumber,rowCount:orgArr[orgi].hNumber}) - }else if(orgArr[orgi].level=='3'){ + this.yinJson.socialLinkages.inputCount.inputs.push({ colCount: orgArr[orgi].lieNumber, rowCount: orgArr[orgi].hNumber }) + } else if (orgArr[orgi].level == '3') { shetextAreaCount++ - }else if(orgArr[orgi].level=='4'){ + } else if (orgArr[orgi].level == '4') { shetreeCount++ } }); } - - this.yinJson.socialLinkages.tableCount.totalCount=shetableCount - this.yinJson.socialLinkages.inputCount.totalCount=sheinputCount - this.yinJson.socialLinkages.textAreaCount.totalCount=shetextAreaCount - this.yinJson.socialLinkages.treeCount.totalCount=shetreeCount - var qintableCount=0 - var qininputCount=0 - var qintextAreaCount=0 - var qintreeCount=0 - if(value.groupName=='勤务保障'){ - this.planTemplateData[7].attribute.forEach((orgvalue,orgi,orgArr) => { - if(orgArr[orgi].level=='1'){ + + this.yinJson.socialLinkages.tableCount.totalCount = shetableCount + this.yinJson.socialLinkages.inputCount.totalCount = sheinputCount + this.yinJson.socialLinkages.textAreaCount.totalCount = shetextAreaCount + this.yinJson.socialLinkages.treeCount.totalCount = shetreeCount + var qintableCount = 0 + var qininputCount = 0 + var qintextAreaCount = 0 + var qintreeCount = 0 + if (value.groupName == '勤务保障') { + value.attribute.forEach((orgvalue, orgi, orgArr) => { + if (orgArr[orgi].level == '1') { qintableCount++ //this.yinJson.organizationCommands.tableCount.tables.push({itemCount:orgtableCount}) - }else if(orgArr[orgi].level=='2'){ + } else if (orgArr[orgi].level == '2') { qininputCount++ - this.yinJson.serviceSupports.inputCount.inputs.push({colCount:orgArr[orgi].lieNumber,rowCount:orgArr[orgi].hNumber}) - }else if(orgArr[orgi].level=='3'){ + this.yinJson.serviceSupports.inputCount.inputs.push({ colCount: orgArr[orgi].lieNumber, rowCount: orgArr[orgi].hNumber }) + } else if (orgArr[orgi].level == '3') { qintextAreaCount++ - }else if(orgArr[orgi].level=='4'){ + } else if (orgArr[orgi].level == '4') { qintreeCount++ } }); } - - this.yinJson.serviceSupports.tableCount.totalCount=qintableCount - this.yinJson.serviceSupports.inputCount.totalCount=qininputCount - this.yinJson.serviceSupports.textAreaCount.totalCount=qintextAreaCount - this.yinJson.serviceSupports.treeCount.totalCount=qintreeCount - var futableCount=0 - var fuinputCount=0 - var futextAreaCount=0 - var futreeCount=0 - if(value.groupName=='辅助决策'){ - this.planTemplateData[9].attribute.forEach((orgvalue,orgi,orgArr) => { - if(orgArr[orgi].level=='1'){ + + this.yinJson.serviceSupports.tableCount.totalCount = qintableCount + this.yinJson.serviceSupports.inputCount.totalCount = qininputCount + this.yinJson.serviceSupports.textAreaCount.totalCount = qintextAreaCount + this.yinJson.serviceSupports.treeCount.totalCount = qintreeCount + var futableCount = 0 + var fuinputCount = 0 + var futextAreaCount = 0 + var futreeCount = 0 + if (value.groupName == '辅助决策') { + value.attribute.forEach((orgvalue, orgi, orgArr) => { + if (orgArr[orgi].level == '1') { futableCount++ //this.yinJson.organizationCommands.tableCount.tables.push({itemCount:orgtableCount}) - }else if(orgArr[orgi].level=='2'){ + } else if (orgArr[orgi].level == '2') { fuinputCount++ - this.yinJson.decisionSupports.inputCount.inputs.push({colCount:orgArr[orgi].lieNumber,rowCount:orgArr[orgi].hNumber}) - }else if(orgArr[orgi].level=='3'){ + this.yinJson.decisionSupports.inputCount.inputs.push({ colCount: orgArr[orgi].lieNumber, rowCount: orgArr[orgi].hNumber }) + } else if (orgArr[orgi].level == '3') { futextAreaCount++ - }else if(orgArr[orgi].level=='4'){ + } else if (orgArr[orgi].level == '4') { futreeCount++ } }); } - - this.yinJson.decisionSupports.tableCount.totalCount=futableCount - this.yinJson.decisionSupports.inputCount.totalCount=fuinputCount - this.yinJson.decisionSupports.textAreaCount.totalCount=futextAreaCount - this.yinJson.decisionSupports.treeCount.totalCount=futreeCount + + this.yinJson.decisionSupports.tableCount.totalCount = futableCount + this.yinJson.decisionSupports.inputCount.totalCount = fuinputCount + this.yinJson.decisionSupports.textAreaCount.totalCount = futextAreaCount + this.yinJson.decisionSupports.treeCount.totalCount = futreeCount }); - + } - if(type==5){ - var orgtableCount=0 - var orginputCount=0 - var orgtextAreaCount=0 - var orgtreeCount=0 - this.planTemplateData[4].attribute.forEach((orgvalue,orgi,orgArr) => { - if(orgArr[orgi].level=='1'){ + if (type == 5) { + var orgtableCount = 0 + var orginputCount = 0 + var orgtextAreaCount = 0 + var orgtreeCount = 0 + let index = this.getArrayIndex(this.planTemplateData,'组织指挥') + this.planTemplateData[index].attribute.forEach((orgvalue, orgi, orgArr) => { + if (orgArr[orgi].level == '1') { orgtableCount++ - this.yinJson.organizationCommands.tableCount.tables.push({itemCount:orgArr[orgi].tableth.length}) - }else if(orgArr[orgi].level=='2'){ + this.yinJson.organizationCommands.tableCount.tables.push({ itemCount: orgArr[orgi].tableth.length }) + } else if (orgArr[orgi].level == '2') { orginputCount++ - this.yinJson.organizationCommands.inputCount.inputs.push({colCount:orgArr[orgi].lieNumber,rowCount:orgArr[orgi].hNumber}) - }else if(orgArr[orgi].level=='3'){ + this.yinJson.organizationCommands.inputCount.inputs.push({ colCount: orgArr[orgi].lieNumber, rowCount: orgArr[orgi].hNumber }) + } else if (orgArr[orgi].level == '3') { orgtextAreaCount++ - }else if(orgArr[orgi].level=='4'){ + } else if (orgArr[orgi].level == '4') { orgtreeCount++ } }); - this.yinJson.organizationCommands.tableCount.totalCount=orgtableCount - this.yinJson.organizationCommands.inputCount.totalCount=orginputCount - this.yinJson.organizationCommands.textAreaCount.totalCount=orgtextAreaCount - this.yinJson.organizationCommands.treeCount.totalCount=orgtreeCount - this.yinJson.decisionSupports=null - this.yinJson.serviceSupports=null - this.yinJson.socialLinkages=null - }if(type==7){ - var orgtableCount=0 - var orginputCount=0 - var orgtextAreaCount=0 - var orgtreeCount=0 - this.planTemplateData[6].attribute.forEach((orgvalue,orgi,orgArr) => { - if(orgArr[orgi].level=='1'){ + this.yinJson.organizationCommands.tableCount.totalCount = orgtableCount + this.yinJson.organizationCommands.inputCount.totalCount = orginputCount + this.yinJson.organizationCommands.textAreaCount.totalCount = orgtextAreaCount + this.yinJson.organizationCommands.treeCount.totalCount = orgtreeCount + this.yinJson.decisionSupports = null + this.yinJson.serviceSupports = null + this.yinJson.socialLinkages = null + } if (type == 7) { + var orgtableCount = 0 + var orginputCount = 0 + var orgtextAreaCount = 0 + var orgtreeCount = 0 + let index = this.getArrayIndex(this.planTemplateData,'社会联动') + this.planTemplateData[index].attribute.forEach((orgvalue, orgi, orgArr) => { + if (orgArr[orgi].level == '1') { orgtableCount++ //this.yinJson.organizationCommands.tableCount.tables.push({itemCount:orgtableCount}) - }else if(orgArr[orgi].level=='2'){ + } else if (orgArr[orgi].level == '2') { orginputCount++ - this.yinJson.socialLinkages.inputCount.inputs.push({colCount:orgArr[orgi].lieNumber,rowCount:orgArr[orgi].hNumber}) - }else if(orgArr[orgi].level=='3'){ + this.yinJson.socialLinkages.inputCount.inputs.push({ colCount: orgArr[orgi].lieNumber, rowCount: orgArr[orgi].hNumber }) + } else if (orgArr[orgi].level == '3') { orgtextAreaCount++ - }else if(orgArr[orgi].level=='4'){ + } else if (orgArr[orgi].level == '4') { orgtreeCount++ } }); - this.yinJson.socialLinkages.tableCount.totalCount=orgtableCount - this.yinJson.socialLinkages.inputCount.totalCount=orginputCount - this.yinJson.socialLinkages.textAreaCount.totalCount=orgtextAreaCount - this.yinJson.socialLinkages.treeCount.totalCount=orgtreeCount - this.yinJson.serviceSupports=null - this.yinJson.organizationCommands=null - this.yinJson.decisionSupports=null - }if(type==8){ - var orgtableCount=0 - var orginputCount=0 - var orgtextAreaCount=0 - var orgtreeCount=0 - this.planTemplateData[7].attribute.forEach((orgvalue,orgi,orgArr) => { - if(orgArr[orgi].level=='1'){ + this.yinJson.socialLinkages.tableCount.totalCount = orgtableCount + this.yinJson.socialLinkages.inputCount.totalCount = orginputCount + this.yinJson.socialLinkages.textAreaCount.totalCount = orgtextAreaCount + this.yinJson.socialLinkages.treeCount.totalCount = orgtreeCount + this.yinJson.serviceSupports = null + this.yinJson.organizationCommands = null + this.yinJson.decisionSupports = null + } if (type == 8) { + var orgtableCount = 0 + var orginputCount = 0 + var orgtextAreaCount = 0 + var orgtreeCount = 0 + let index = this.getArrayIndex(this.planTemplateData,'勤务保障') + this.planTemplateData[index].attribute.forEach((orgvalue, orgi, orgArr) => { + if (orgArr[orgi].level == '1') { orgtableCount++ //this.yinJson.organizationCommands.tableCount.tables.push({itemCount:orgtableCount}) - }else if(orgArr[orgi].level=='2'){ + } else if (orgArr[orgi].level == '2') { orginputCount++ - this.yinJson.serviceSupports.inputCount.inputs.push({colCount:orgArr[orgi].lieNumber,rowCount:orgArr[orgi].hNumber}) - }else if(orgArr[orgi].level=='3'){ + this.yinJson.serviceSupports.inputCount.inputs.push({ colCount: orgArr[orgi].lieNumber, rowCount: orgArr[orgi].hNumber }) + } else if (orgArr[orgi].level == '3') { orgtextAreaCount++ - }else if(orgArr[orgi].level=='4'){ + } else if (orgArr[orgi].level == '4') { orgtreeCount++ } }); - this.yinJson.serviceSupports.tableCount.totalCount=orgtableCount - this.yinJson.serviceSupports.inputCount.totalCount=orginputCount - this.yinJson.serviceSupports.textAreaCount.totalCount=orgtextAreaCount - this.yinJson.serviceSupports.treeCount.totalCount=orgtreeCount - this.yinJson.decisionSupports=null - this.yinJson.organizationCommands=null - this.yinJson.socialLinkages=null - }if(type==10){ - var orgtableCount=0 - var orginputCount=0 - var orgtextAreaCount=0 - var orgtreeCount=0 - this.planTemplateData[9].attribute.forEach((orgvalue,orgi,orgArr) => { - if(orgArr[orgi].level=='1'){ + this.yinJson.serviceSupports.tableCount.totalCount = orgtableCount + this.yinJson.serviceSupports.inputCount.totalCount = orginputCount + this.yinJson.serviceSupports.textAreaCount.totalCount = orgtextAreaCount + this.yinJson.serviceSupports.treeCount.totalCount = orgtreeCount + this.yinJson.decisionSupports = null + this.yinJson.organizationCommands = null + this.yinJson.socialLinkages = null + } if (type == 10) { + var orgtableCount = 0 + var orginputCount = 0 + var orgtextAreaCount = 0 + var orgtreeCount = 0 + let index = this.getArrayIndex(this.planTemplateData,'处置要点') + this.planTemplateData[index].attribute.forEach((orgvalue, orgi, orgArr) => { + if (orgArr[orgi].level == '1') { orgtableCount++ //this.yinJson.organizationCommands.tableCount.tables.push({itemCount:orgtableCount}) - }else if(orgArr[orgi].level=='2'){ + } else if (orgArr[orgi].level == '2') { orginputCount++ - this.yinJson.decisionSupports.inputCount.inputs.push({colCount:orgArr[orgi].lieNumber,rowCount:orgArr[orgi].hNumber}) - }else if(orgArr[orgi].level=='3'){ + this.yinJson.decisionSupports.inputCount.inputs.push({ colCount: orgArr[orgi].lieNumber, rowCount: orgArr[orgi].hNumber }) + } else if (orgArr[orgi].level == '3') { orgtextAreaCount++ - }else if(orgArr[orgi].level=='4'){ + } else if (orgArr[orgi].level == '4') { orgtreeCount++ } }); - this.yinJson.decisionSupports.tableCount.totalCount=orgtableCount - this.yinJson.decisionSupports.inputCount.totalCount=orginputCount - this.yinJson.decisionSupports.textAreaCount.totalCount=orgtextAreaCount - this.yinJson.decisionSupports.treeCount.totalCount=orgtreeCount - this.yinJson.organizationCommands=null - this.yinJson.serviceSupports=null - this.yinJson.socialLinkages=null + this.yinJson.decisionSupports.tableCount.totalCount = orgtableCount + this.yinJson.decisionSupports.inputCount.totalCount = orginputCount + this.yinJson.decisionSupports.textAreaCount.totalCount = orgtextAreaCount + this.yinJson.decisionSupports.treeCount.totalCount = orgtreeCount + this.yinJson.organizationCommands = null + this.yinJson.serviceSupports = null + this.yinJson.socialLinkages = null } - console.log(this.yinJson) + // console.log(this.yinJson) } //查询能引入的预案 - yinruData={ - items:[] + yinruData = { + items: [] } - searchYuan(){ - this.yinRu(this.selectedItem=='组织指挥'?5:this.selectedItem=='社会联动'?7:this.selectedItem=='勤务保障'?8:10) + searchYuan() { + this.yinRu(this.selectedItem == '组织指挥' ? 5 : this.selectedItem == '社会联动' ? 7 : this.selectedItem == '勤务保障' ? 8 : 10) //console.log(JSON.stringify(this.yinJson)) - var urlbm=encodeURI(JSON.stringify(this.yinJson)) - let paramsdata:any={ - planCategory:this.planLevel, - buildingTypeId :this.route.snapshot.queryParams.unitTypeId, - OrganizationId:this.searchType=='0'?'':this.jsId, - CustomKeyword:this.searchType=='0'?this.zdysearch:'', - webTextStatistics:urlbm, + var urlbm = encodeURI(JSON.stringify(this.yinJson)) + let paramsdata: any = { + planCategory: this.planLevel, + buildingTypeId: this.route.snapshot.queryParams.unitTypeId, + OrganizationId: this.searchType == '0' ? '' : this.jsId, + CustomKeyword: this.searchType == '0' ? this.zdysearch : '', + webTextStatistics: urlbm, PageNumber: this.PageNumber || '1', PageSize: this.pageSizeOptions[0], } - - this.http.get("/api/PlanComponents/WebText",{params:paramsdata}).subscribe((data:any)=>{ - this.yinruData=null - this.yinruData=data - if(this.yinruData.items.length==0){ + + this.http.get("/api/PlanComponents/WebText", { params: paramsdata }).subscribe((data: any) => { + this.yinruData = null + this.yinruData = data + if (this.yinruData.items.length == 0) { const config = new MatSnackBarConfig(); config.verticalPosition = 'top'; config.duration = 3000 @@ -942,19 +959,19 @@ export class CreatePlanOnlineFiveComponent implements OnInit { }) } //可引入预案点击事件 - clickYinru(clicki){ + clickYinru(clicki) { const dialogRef = this.dialog.open(yinYong, { width: '750px', height: '700px', //disableClose: true - data: {selectedItem:this.selectedItem,yinruData:this.yinruData.items[clicki].webTextData} + data: { selectedItem: this.selectedItem, yinruData: this.yinruData.items[clicki].webTextData } }); dialogRef.afterClosed().subscribe(result => { - console.log(result) - if(result!=undefined){ + // console.log(result) + if (result != undefined) { this.planTemplateData.forEach(element => { - if(element.groupName==this.selectedItem){ - element.attribute=result + if (element.groupName == this.selectedItem) { + element.attribute = result } }); } @@ -1020,7 +1037,7 @@ export class CreatePlanOnlineFiveComponent implements OnInit { } //重点图示上传图片 filechange(e, i) { - console.log(i) + // console.log(i) let file = e.target.files[0] || null //获取上传的文件 let fileSize = file.size || null //上传文件的总大小 let maxSize = 5 * 1024 * 1024 //5MB一个分片 @@ -1028,22 +1045,22 @@ export class CreatePlanOnlineFiveComponent implements OnInit { if (file && fileSize <= maxSize) { //上传文件<=5MB时 let upload = this.uploadFile(this.route.snapshot.queryParams.companyId, this.route.snapshot.queryParams.planId, file) upload.then((res: any) => { - if(i.tableth!=undefined){ + if (i.tableth != undefined) { i.tableth.json.push('/api/Objects/PlanPlatform/' + res.objectName) - }else{ + } else { i.imgArr.push('/api/Objects/PlanPlatform/' + res.objectName) } - + }) } else { //上传文件>5MB时 let upload = this.sectionUpload(this.route.snapshot.queryParams.companyId, this.route.snapshot.queryParams.planId, file) upload.then(res => { - if(i.tableth!=undefined){ + if (i.tableth != undefined) { i.tableth.json.push('/api/Objects/PlanPlatform/' + res) - }else{ + } else { i.imgArr.push('/api/Objects/PlanPlatform/' + res) } - + }) } } @@ -1067,12 +1084,9 @@ export class CreatePlanOnlineFiveComponent implements OnInit { }) }) this.allBuildings = data - //this.group = this.planTemplateData[1].building - //delete this.planTemplateData[0].attribute - }) }) - + } //获取总平面图 sitePlanItems: any @@ -1127,7 +1141,6 @@ export class CreatePlanOnlineFiveComponent implements OnInit { addNumber = -1 addTd(key, i) { this.addNumber++ - //this.planTemplateData[key].attribute[i].push({tabletr:[]}) if (this.planTemplateData[key].attribute[i].tabletr == undefined) { this.planTemplateData[key].attribute[i].tabletr = [] } @@ -1165,50 +1178,49 @@ export class CreatePlanOnlineFiveComponent implements OnInit { clickBuilding(item, i) { 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 - + // console.log(item, this.clicki) } //单位概况增加一行 unitadd(surveyName, attacki, i) { +  let index = this.getArrayIndex(this.planTemplateData,'单位概况') + this.addNumber++ if (surveyName == '进攻通道') { - if (this.planTemplateData[1].building[attacki].body[4].attinf[i].tabletr == undefined) { - this.planTemplateData[1].building[attacki].body[4].attinf[i].tabletr = [] + if (this.planTemplateData[index].building[attacki].body[4].attinf[i].tabletr == undefined) { + this.planTemplateData[index].building[attacki].body[4].attinf[i].tabletr = [] } - this.planTemplateData[1].building[attacki].body[4].attinf[i].tabletr.push({ tabletd: [] }) - for (var j = 0; j < this.planTemplateData[1].building[attacki].body[4].attinf[i].tableth.length; j++) { - if (this.planTemplateData[1].building[attacki].body[4].attinf[i].tabletr != undefined) { - this.planTemplateData[1].building[attacki].body[4].attinf[i].tabletr[this.planTemplateData[1].building[attacki].body[4].attinf[i].tabletr.length - 1].tabletd.push('') + this.planTemplateData[index].building[attacki].body[4].attinf[i].tabletr.push({ tabletd: [] }) + for (var j = 0; j < this.planTemplateData[index].building[attacki].body[4].attinf[i].tableth.length; j++) { + if (this.planTemplateData[index].building[attacki].body[4].attinf[i].tabletr != undefined) { + this.planTemplateData[index].building[attacki].body[4].attinf[i].tabletr[this.planTemplateData[index].building[attacki].body[4].attinf[i].tabletr.length - 1].tabletd.push('') } else { - this.planTemplateData[1].building[attacki].body[4].attinf[i].tabletr[this.addNumber].tabletd.push('') + this.planTemplateData[index].building[attacki].body[4].attinf[i].tabletr[this.addNumber].tabletd.push('') } } // console.log(this.planTemplateData) } else if (surveyName == '功能分区') { - console.log(attacki) - this.planTemplateData[1].building[attacki].body[6].attinf.push({ name: '', value: '' }) + // console.log(attacki) + this.planTemplateData[index].building[attacki].body[6].attinf.push({ name: '', value: '' }) } else if (surveyName == '重点部位') { - this.planTemplateData[1].building[attacki].body[5].attinf.push({ heafName: '', body: [{ name: '重点部位名称', value: '' }, { name: '重点部位所在位置', value: '' }, { name: '建筑结构', value: '' }, { name: '使用性质', value: '' }, { name: '主要危险性', value: '' }] }) + this.planTemplateData[index].building[attacki].body[5].attinf.push({ heafName: '', body: [{ name: '重点部位名称', value: '' }, { name: '重点部位所在位置', value: '' }, { name: '建筑结构', value: '' }, { name: '使用性质', value: '' }, { name: '主要危险性', value: '' }] }) } } //单位概况删除一行 unitDel(surveyName, attacki, i) { + let index = this.getArrayIndex(this.planTemplateData,'单位概况') const config = new MatSnackBarConfig(); config.verticalPosition = 'top'; config.duration = 3000 let isTrue = confirm('您确定要删除该条信息吗') if (surveyName == '进攻通道') { if (isTrue) { - if (this.planTemplateData[1].building[attacki].body[4].attinf[i].tabletr != undefined) { - this.planTemplateData[1].building[attacki].body[4].attinf[i].tabletr.splice(this.planTemplateData[1].building[attacki].body[4].attinf[i].tabletr.length - 1, 1) + if (this.planTemplateData[index].building[attacki].body[4].attinf[i].tabletr != undefined) { + this.planTemplateData[index].building[attacki].body[4].attinf[i].tabletr.splice(this.planTemplateData[index].building[attacki].body[4].attinf[i].tabletr.length - 1, 1) this.addNumber-- - if (this.planTemplateData[1].building[attacki].body[4].attinf[i].tabletr.length == 0) { + if (this.planTemplateData[index].building[attacki].body[4].attinf[i].tabletr.length == 0) { this.addNumber = -1 } } else { @@ -1217,11 +1229,11 @@ export class CreatePlanOnlineFiveComponent implements OnInit { } } else if (surveyName == '功能分区') { if (isTrue) { - this.planTemplateData[1].building[attacki].body[6].attinf.splice(i, 1) + this.planTemplateData[index].building[attacki].body[6].attinf.splice(i, 1) } } else if (surveyName == '重点部位') { if (isTrue) { - this.planTemplateData[1].building[attacki].body[5].attinf.splice(i, 1) + this.planTemplateData[index].building[attacki].body[5].attinf.splice(i, 1) } } } @@ -1283,7 +1295,7 @@ export class CreatePlanOnlineFiveComponent implements OnInit { //console.log('提交信息', this.planTemplateData) let body = { webTextData: JSON.stringify(this.planTemplateData), - webTextStatistics:this.yinJson + webTextStatistics: this.yinJson } this.http.put(`/api/PlanComponents/${this.route.snapshot.queryParams.planId}`, body).subscribe(data => { // console.log('提交成功',data) @@ -1332,13 +1344,13 @@ export class CreatePlanOnlineFiveComponent implements OnInit { $(".mainbox").wordExport('word文档'); } //原数据点击 - oldData=false - clickoldData(){ - this.oldData=!this.oldData - + oldData = false + clickoldData() { + this.oldData = !this.oldData + } //新增功能(社会联动等引用) - searchType='0' + searchType = '0' } @@ -1393,43 +1405,43 @@ export class OpenPlanToolDialog { templateUrl: './yinyong.html', styleUrls: ['./create-plan-online-five.component.scss'] }) -export class yinYong{ +export class yinYong { constructor(public http: HttpClient, public snackBar: MatSnackBar, public dialogRef: MatDialogRef, @Inject(MAT_DIALOG_DATA) public data, public dialog: MatDialog) { } - ngOnInit(){ - this.selectedItem=this.data.selectedItem - this.planTemplateData=JSON.parse(this.data.yinruData) - this.yinData() - console.log(this.planTemplateData) - } - selectedItem//传来的组织指挥或者。。。 - planTemplateData//传来的数据 - selectData - xuanze:boolean - //imgUrl - //看看查的是哪个标题下的内容 - yinData(){ - this.planTemplateData.forEach((pvale,pi,parr) => { - if(pvale.groupName==this.selectedItem){ - this.selectData=pvale.attribute - } - }); - } - trackByFn(index) { - return index - } - //关闭弹窗 - closeDiv() { - let isTrue = confirm('您确定要引用该条预案吗') - if(isTrue){ - this.xuanze=true - this.dialogRef.close(this.selectData) - } - else{ - this.xuanze=false - this.dialogRef.close() + ngOnInit() { + this.selectedItem = this.data.selectedItem + this.planTemplateData = JSON.parse(this.data.yinruData) + this.yinData() + // console.log(this.planTemplateData) + } + selectedItem//传来的组织指挥或者。。。 + planTemplateData//传来的数据 + selectData + xuanze: boolean + //imgUrl + //看看查的是哪个标题下的内容 + yinData() { + this.planTemplateData.forEach((pvale, pi, parr) => { + if (pvale.groupName == this.selectedItem) { + this.selectData = pvale.attribute } - + }); + } + trackByFn(index) { + return index + } + //关闭弹窗 + closeDiv() { + let isTrue = confirm('您确定要引用该条预案吗') + if (isTrue) { + this.xuanze = true + this.dialogRef.close(this.selectData) } - + else { + this.xuanze = false + this.dialogRef.close() + } + + } + } \ No newline at end of file