From 3ca9bca1ab9780487b58a31479d4d7052c7bea3e Mon Sep 17 00:00:00 2001 From: SHAOJIAHAO <55341701@qq.com> Date: Tue, 2 Mar 2021 15:41:16 +0800 Subject: [PATCH 1/4] =?UTF-8?q?[=E6=96=B0=E5=A2=9E]=E6=96=B0=E5=A2=9E?= =?UTF-8?q?=E5=BE=85=E5=AE=A1=E6=A0=B8=E9=A1=B5=E9=9D=A2=E4=B8=AD=E6=B0=B4?= =?UTF-8?q?=E6=BA=90=E7=9A=84=E6=98=BE=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../wait-examineer/wait-examineer.component.html | 3 +-- .../wait-examineer/wait-examineer.component.scss | 3 +++ .../wait-examineer/wait-examineer.component.ts | 11 +++++++++-- .../plan-audit/water-audit/water-audit.component.html | 2 +- .../plan-audit/water-audit/water-audit.component.ts | 8 +++++--- 5 files changed, 19 insertions(+), 8 deletions(-) diff --git a/src/app/plan-audit/wait-examineer/wait-examineer.component.html b/src/app/plan-audit/wait-examineer/wait-examineer.component.html index a8fd8c8..d871e43 100644 --- a/src/app/plan-audit/wait-examineer/wait-examineer.component.html +++ b/src/app/plan-audit/wait-examineer/wait-examineer.component.html @@ -54,10 +54,9 @@ </table> <div class="tbodycss" id="tbodydiv" > <table cellspacing="0" cellpadding="0" id="table" > - <tr *ngFor="let item of tableDate;let key = index" (click)='radioClick($event,item)'> + <tr [ngClass]="{'selectedTr': item.id == id}" *ngFor="let item of tableDate;let key = index" (click)='radioClick($event,item)'> <td style="width: 15%;"> <mat-checkbox color="primary" (change)='radioClick($event,item)'></mat-checkbox> - <!-- <input type="checkbox" name="yuan" value={{item.id}} (click)='radioClick($event,item)'> --> {{item.contentType=='1'?'Ⅰ级预案':item.contentType=='2'?'Ⅱ级预案':item.contentType=='3'?'Ⅲ级预案':item.contentType=='4'?'Ⅳ级预案':item.contentType=='5'? 'Ⅴ级预案':item.contentType=='6'?'应急预案(国家级)':item.contentType=='7'?'应急预案(市级)':item.contentType=='8'?'类型预案':item.contentType=='11'?'重点单位':item.contentType=='12'?'水源':item.contentType=='13'?'消防力量':item.contentType=='14'?'联动力量':'未知'}}</td> <td style="width: 15%;" [ngClass]="{'green': item.operation == '1','red':item.operation == '2','blue':item.operation == '0'}">{{item.operation=='0'?'新增':item.operation=='1'?'更新':'删除'}}</td> diff --git a/src/app/plan-audit/wait-examineer/wait-examineer.component.scss b/src/app/plan-audit/wait-examineer/wait-examineer.component.scss index 62d563e..5f58468 100644 --- a/src/app/plan-audit/wait-examineer/wait-examineer.component.scss +++ b/src/app/plan-audit/wait-examineer/wait-examineer.component.scss @@ -50,6 +50,9 @@ overflow-y: auto; height: 700px; width: 100%; + .selectedTr{ + background-color: #b3d3ee; + } } table{ margin-left:10px; diff --git a/src/app/plan-audit/wait-examineer/wait-examineer.component.ts b/src/app/plan-audit/wait-examineer/wait-examineer.component.ts index 80263a3..6b72b2c 100644 --- a/src/app/plan-audit/wait-examineer/wait-examineer.component.ts +++ b/src/app/plan-audit/wait-examineer/wait-examineer.component.ts @@ -157,7 +157,7 @@ export class WaitExamineerComponent implements OnInit { radioClick(e,item){ this.showtype = -1 //e.target.parentElement.bgColor='#2196F3' - console.log(e,item) + console.log(item) this.organizationName='' this.id=item.id this.fetchUrl='' @@ -167,7 +167,14 @@ export class WaitExamineerComponent implements OnInit { sessionStorage.setItem('companyId',item.itemId) }else if(item.contentType == 12){ //水源 - this.showtype = 12 + + // console.log(item.itemId) + this.http.get(`/api/WaterSources/${item.itemId}`).subscribe((data)=>{ + + console.log('水源',data) + this.waterData = data + this.showtype = 12 + }) }else if(item.contentType == 13){ //消防力量 this.showtype = 13 diff --git a/src/app/plan-audit/water-audit/water-audit.component.html b/src/app/plan-audit/water-audit/water-audit.component.html index 3a3decd..be8eb68 100644 --- a/src/app/plan-audit/water-audit/water-audit.component.html +++ b/src/app/plan-audit/water-audit/water-audit.component.html @@ -4,7 +4,7 @@ <div class="tabsbox"> <div class="tabs"> <div class="selectedBtn"> - <span>消火栓</span> + <span>{{selectedWaterTypeIndex == 0 ? '消火栓' : selectedWaterTypeIndex == 1 ? '消防水池' : selectedWaterTypeIndex == 2 ? '天然水源' : null}}</span> </div> </div> </div> diff --git a/src/app/plan-audit/water-audit/water-audit.component.ts b/src/app/plan-audit/water-audit/water-audit.component.ts index 3e51e5d..cf81d83 100644 --- a/src/app/plan-audit/water-audit/water-audit.component.ts +++ b/src/app/plan-audit/water-audit/water-audit.component.ts @@ -15,10 +15,12 @@ export class WaterAuditComponent implements OnInit { ' <img style="width:20px;height:24px" src="/assets/images/定位.png">' + '</div>' ngOnInit(): void { - console.log(7777,this.waterData) + + this.selectedWaterTypeIndex = this.waterData.waterSourceType this.waterData.detailData = JSON.parse(this.waterData.detailData) this.fireCockData = this.waterData.detailData - console.log(789, this.fireCockData) + this.poolData = this.waterData.detailData + this.naturalWaterData = this.waterData.detailData setTimeout(() => { this.map = new AMap.Map('container', { zoom:18 @@ -39,7 +41,7 @@ export class WaterAuditComponent implements OnInit { }, 0); } - selectedWaterTypeIndex:number = 0//选择的水源类型 0消火栓 1水池 2天然水源 + selectedWaterTypeIndex:number //选择的水源类型 0消火栓 1水池 2天然水源 fireCockData:any = []//消火栓详情 poolData:any = []//水池详情 naturalWaterData:any = []//天然水源详情 From 8207a876ad8643fe1b21ffcbb44189ec2ba3abe7 Mon Sep 17 00:00:00 2001 From: SHAOJIAHAO <55341701@qq.com> Date: Tue, 2 Mar 2021 16:16:46 +0800 Subject: [PATCH 2/4] =?UTF-8?q?[=E6=96=B0=E5=A2=9E]=E6=B0=B4=E6=BA=90?= =?UTF-8?q?=E5=90=8C=E6=84=8F=E5=AE=A1=E6=A0=B8=E5=92=8C=E6=8B=92=E7=BB=9D?= =?UTF-8?q?=E5=AE=A1=E6=A0=B8=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../wait-examineer.component.ts | 231 +++++++++++------- 1 file changed, 138 insertions(+), 93 deletions(-) diff --git a/src/app/plan-audit/wait-examineer/wait-examineer.component.ts b/src/app/plan-audit/wait-examineer/wait-examineer.component.ts index d9c11b7..61ba0d9 100644 --- a/src/app/plan-audit/wait-examineer/wait-examineer.component.ts +++ b/src/app/plan-audit/wait-examineer/wait-examineer.component.ts @@ -334,40 +334,159 @@ export class WaitExamineerComponent implements OnInit { config.duration = 3000 console.log(this.shenheTable) if(this.shenheTable.length==0){ - this.snackBar.open('请选择要审核的预案!','确定',config); + this.snackBar.open('请勾选要审核的条目!','确定',config); } //单个审核 - else if(this.shenheTable.length==1){ - //重点单位审核 - if(this.shenheTable[0].contentType==11){ + else if(this.shenheTable.length == 1){ + let isTrue = window.confirm('确定同意选中条目的审核吗?') + if(isTrue){ + //重点单位审核 + if(this.shenheTable[0].contentType == 11){ + let body:any = { + id:this.shenheTable[0].id, + itemId:this.shenheTable[0].itemId, + verifyState:4, + contentType:11, + title:this.shenheTable[0].title+'基本信息' + } + this.http.put(`/api/ContentVerifies`,body).subscribe(data=>{ + this.snackBar.open('操作成功!','确定',config); + this.getAlltabledate() + }) + }else if(this.shenheTable[0].contentType == 12){ + let body:any = { + id:this.shenheTable[0].id, + itemId:this.shenheTable[0].itemId, + verifyState:4, + contentType:12, + title:this.shenheTable[0].title + } + this.http.put(`/api/ContentVerifies`,body).subscribe(data=>{ + this.snackBar.open('操作成功!','确定',config); + this.showtype = -1 + this.getAlltabledate() + }) + }else if(this.shenheTable[0].contentType == 13){ + + }else if(this.shenheTable[0].contentType == 14){ + + }else{ + //预案审核 + if(this.shenheTable[0].verifyState==0){ + this.http.put(`/api/PlanAudits/${this.shenheTable[0].itemId}/First`,{auditStatus:16}).subscribe(data=>{ + this.snackBar.open('操作成功!','确定',config); + this.getAlltabledate() + }) + }else if(this.shenheTable[0].verifyState==3){ + this.http.put(`/api/PlanAudits/${this.radioid}`,{auditStatus:2}).subscribe(data=>{ + this.snackBar.open('操作成功!','确定',config); + this.getAlltabledate() + }) + } + } + } + } + //批量审核 + else{ + let isTrue = window.confirm('确定同意选中条目的审核吗?') + if(isTrue){ + if(this.shenheTable[0].contentType==11||this.shenheTable[0].contentType==12){ //批量审批水源和重点单位 + for(var i=0;i<this.shenheTable.length;i++){ + var body={ + id:this.shenheTable[i].id, + itemId:this.shenheTable[i].itemId, + verifyState:4 + } + companyAgreeList.push(body) + } + this.http.put(`/api/ContentVerifies/Batch`,companyAgreeList).subscribe(data=>{ + this.snackBar.open('操作成功!','确定',config); + this.getAlltabledate() + }) + }else{ //批量审核预案 + for(var i=0;i<this.shenheTable.length;i++){ + var cart={ + planComponentId:this.shenheTable[i].itemId, + auditStatus:this.shenheTable[i].verifyState==3?2:16, + auditOpinion:'' + } + agreeList.push(cart) + } + this.http.put(`/api/PlanAudits/Batch`,agreeList).subscribe(data=>{ + this.snackBar.open('操作成功!','确定',config); + this.getAlltabledate() + }) + } + + } + + } + this.shenheTable=[] + } + //拒绝操作 + refuse(){ + const config = new MatSnackBarConfig(); + config.verticalPosition = 'top'; + config.duration = 3000 + var refuseList = [] + var companyrefuseList=[] + if(this.shenheTable.length==0){ + this.snackBar.open('请选择要审核的预案!','确定',config); + } + //单个审核拒绝 + else if(this.shenheTable.length==1){ + let isTrue = window.confirm('确定拒绝选中条目的审核吗?') + if(isTrue){ + //重点单位审核拒绝 + if(this.shenheTable[0].contentType == 11){ let body:any = { id:this.shenheTable[0].id, itemId:this.shenheTable[0].itemId, - verifyState:4, + verifyState:5, contentType:11, title:this.shenheTable[0].title+'基本信息' - } + } this.http.put(`/api/ContentVerifies`,body).subscribe(data=>{ this.snackBar.open('操作成功!','确定',config); this.getAlltabledate() }) + }else if(this.shenheTable[0].contentType == 12){ + let body:any = { + id:this.shenheTable[0].id, + itemId:this.shenheTable[0].itemId, + verifyState:5, + contentType:12, + title:this.shenheTable[0].title + } + this.http.put(`/api/ContentVerifies`,body).subscribe(data=>{ + this.showtype = -1 + this.snackBar.open('操作成功!','确定',config); + this.getAlltabledate() + }) + }else if(this.shenheTable[0].contentType == 13){ + + }else if(this.shenheTable[0].contentType == 14){ + }else{ - //预案审核 + //预案审核拒绝 if(this.shenheTable[0].verifyState==0){ - this.http.put(`/api/PlanAudits/${this.shenheTable[0].itemId}/First`,{auditStatus:16}).subscribe(data=>{ + this.http.put(`/api/PlanAudits/${this.shenheTable[0].itemId}/First`,{auditStatus:32}).subscribe(data=>{ this.snackBar.open('操作成功!','确定',config); this.getAlltabledate() }) }else if(this.shenheTable[0].verifyState==3){ - this.http.put(`/api/PlanAudits/${this.radioid}`,{auditStatus:2}).subscribe(data=>{ + this.http.put(`/api/PlanAudits/${this.radioid}`,{auditStatus:4}).subscribe(data=>{ this.snackBar.open('操作成功!','确定',config); this.getAlltabledate() }) } } } - //批量审核 - else{ + } + //批量审核 + else{ + let isTrue = window.confirm('确定拒绝选中条目的审核吗?') + if(isTrue){ if(this.shenheTable[0].contentType==11||this.shenheTable[0].contentType==12){ //批量审批水源和重点单位 for(var i=0;i<this.shenheTable.length;i++){ var body={ @@ -375,106 +494,32 @@ export class WaitExamineerComponent implements OnInit { itemId:this.shenheTable[i].itemId, verifyState:4 } - companyAgreeList.push(body) + companyrefuseList.push(body) } - this.http.put(`/api/ContentVerifies/Batch`,companyAgreeList).subscribe(data=>{ + this.http.put(`/api/ContentVerifies/Batch`,companyrefuseList).subscribe(data=>{ this.snackBar.open('操作成功!','确定',config); this.getAlltabledate() }) - }else{ //批量审核预案 + }else{ for(var i=0;i<this.shenheTable.length;i++){ var cart={ planComponentId:this.shenheTable[i].itemId, - auditStatus:this.shenheTable[i].verifyState==3?2:16, + auditStatus:this.shenheTable[i].verifyState==3?4:32, auditOpinion:'' } - agreeList.push(cart) + refuseList.push(cart) } - this.http.put(`/api/PlanAudits/Batch`,agreeList).subscribe(data=>{ + this.http.put(`/api/PlanAudits/Batch`,refuseList).subscribe(data=>{ this.snackBar.open('操作成功!','确定',config); this.getAlltabledate() }) } - - } - this.shenheTable=[] - } - //拒绝操作 - refuse(){ - const config = new MatSnackBarConfig(); - config.verticalPosition = 'top'; - config.duration = 3000 - var refuseList=[] - var companyrefuseList=[] - if(this.shenheTable.length==0){ - this.snackBar.open('请选择要审核的预案!','确定',config); - } - //单个审核拒绝 - else if(this.shenheTable.length==1){ - //重点单位审核拒绝 - if(this.shenheTable[0].contentType==11){ - let body:any = { - id:this.shenheTable[0].id, - itemId:this.shenheTable[0].itemId, - verifyState:5, - contentType:11, - title:this.shenheTable[0].title+'基本信息' - } - this.http.put(`/api/ContentVerifies`,body).subscribe(data=>{ - this.snackBar.open('操作成功!','确定',config); - this.getAlltabledate() - }) - }else{ - //预案审核拒绝 - if(this.shenheTable[0].verifyState==0){ - this.http.put(`/api/PlanAudits/${this.shenheTable[0].itemId}/First`,{auditStatus:32}).subscribe(data=>{ - this.snackBar.open('操作成功!','确定',config); - this.getAlltabledate() - }) - }else if(this.shenheTable[0].verifyState==3){ - this.http.put(`/api/PlanAudits/${this.radioid}`,{auditStatus:4}).subscribe(data=>{ - this.snackBar.open('操作成功!','确定',config); - this.getAlltabledate() - }) - } - } - - } - //批量审核 - else{ - if(this.shenheTable[0].contentType==11||this.shenheTable[0].contentType==12){ //批量审批水源和重点单位 - for(var i=0;i<this.shenheTable.length;i++){ - var body={ - id:this.shenheTable[i].id, - itemId:this.shenheTable[i].itemId, - verifyState:4 - } - companyrefuseList.push(body) } - this.http.put(`/api/ContentVerifies/Batch`,companyrefuseList).subscribe(data=>{ - this.snackBar.open('操作成功!','确定',config); - this.getAlltabledate() - }) - }else{ - for(var i=0;i<this.shenheTable.length;i++){ - var cart={ - planComponentId:this.shenheTable[i].itemId, - auditStatus:this.shenheTable[i].verifyState==3?4:32, - auditOpinion:'' - } - refuseList.push(cart) - } - this.http.put(`/api/PlanAudits/Batch`,refuseList).subscribe(data=>{ - this.snackBar.open('操作成功!','确定',config); - this.getAlltabledate() - }) } + this.shenheTable=[] - } - this.shenheTable=[] - - } + } //分数饼状图 bar(){ From 54fbd7b6732c78731668cdf77a1b4a87d3da473c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BE=90=E6=8C=AF=E5=8D=87?= <359059686@qq.com> Date: Wed, 3 Mar 2021 09:47:54 +0800 Subject: [PATCH 3/4] 1.4.1rc --- src/app/working-area/model/axImageShape.ts | 272 +++++++++++++++--- .../working-area/working-area.component.ts | 2 +- 2 files changed, 229 insertions(+), 45 deletions(-) diff --git a/src/app/working-area/model/axImageShape.ts b/src/app/working-area/model/axImageShape.ts index 44a1729..ddb7ccf 100644 --- a/src/app/working-area/model/axImageShape.ts +++ b/src/app/working-area/model/axImageShape.ts @@ -51,6 +51,16 @@ export class AxImageShape extends AxShape { upRight: PIXI.Sprite; downLeft: PIXI.Sprite; downRight: PIXI.Sprite; + + upDrag: boolean = false; + downDrag: boolean = false; + leftDrag: boolean = false; + rightDrag: boolean = false; + upLeftDrag: boolean = false; + upRightDrag: boolean = false; + downLeftDrag: boolean = false; + downRightDrag: boolean = false; + constructor(assetData: any, workingArea: WorkingAreaComponent) { super(assetData, workingArea); this.angle = -this.workingArea.backgroundImage.angle; @@ -74,8 +84,162 @@ export class AxImageShape extends AxShape { this.addChild(this.image); this.addChild(this.selectionBox); - // 是否拖动 - var pointerDrag = false; + // up + this.up = new PIXI.Sprite(this.pointTexture); + this.up.cursor = 'ns-resize'; + this.up.anchor.set(0.5); + this.addChild(this.up); + this.up.interactive = true; + this.up.on('pointerdown', event => { + this.upDrag = true; + this.image.anchor.set(0.5, 1); + this.image.position.set(this.image.position.x, this.image.position.y + (this.image.height / 2)); + event.stopPropagation(); + }); + this.up.on('pointermove', event => { + // 移动时调整形状大小,然后重绘边框 + // 检查右下角距离鼠标的位置, + if (this.upDrag) { + var pos = this.toLocal(event.data.global); + var dY = Math.abs(pos.y - this.image.y); + this.assetData.Height = Math.abs(dY); + this.refresh(); + AxMessageSystem.send(EVENT_IMAGE_RESIZE, this.assetData); + } + + }); + this.up.on('pointerup', event => { + if (this.upDrag) { + this.upDrag = false; + this.image.anchor.set(0.5); + this.image.position.set(this.image.position.x, this.image.position.y - (this.image.height / 2)); + } + }); + this.up.on('pointerupoutside', event => { + if (this.upDrag) { + this.upDrag = false; + this.image.anchor.set(0.5); + this.image.position.set(this.image.position.x, this.image.position.y - (this.image.height / 2)); + } + }); + this.up.visible = false; + // down + this.down = new PIXI.Sprite(this.pointTexture); + this.down.cursor = 'ns-resize'; + this.down.anchor.set(0.5); + this.addChild(this.down); + this.down.interactive = true; + this.down.on('pointerdown', event => { + this.downDrag = true; + this.image.anchor.set(0.5, 0); + this.image.position.set(this.image.position.x, this.image.position.y - (this.image.height / 2)); + event.stopPropagation(); + }); + this.down.on('pointermove', event => { + // 移动时调整形状大小,然后重绘边框 + // 检查右下角距离鼠标的位置, + if (this.downDrag) { + var pos = this.toLocal(event.data.global); + var dY = Math.abs(pos.y - this.image.y); + this.assetData.Height = Math.abs(dY); + this.refresh(); + AxMessageSystem.send(EVENT_IMAGE_RESIZE, this.assetData); + } + + }); + this.down.on('pointerup', event => { + if (this.downDrag) { + this.downDrag = false; + this.image.anchor.set(0.5); + this.image.position.set(this.image.position.x, this.image.position.y + (this.image.height / 2)); + } + }); + this.down.on('pointerupoutside', event => { + if (this.downDrag) { + this.downDrag = false; + this.image.anchor.set(0.5); + this.image.position.set(this.image.position.x, this.image.position.y + (this.image.height / 2)); + } + }); + this.down.visible = false; + // left + this.left = new PIXI.Sprite(this.pointTexture); + this.left.cursor = 'ew-resize'; + this.left.anchor.set(0.5); + this.addChild(this.left); + this.left.interactive = true; + this.left.on('pointerdown', event => { + this.leftDrag = true; + this.image.anchor.set(1, 0.5); + this.image.position.set(this.image.position.x + (this.image.width / 2), this.image.position.y); + event.stopPropagation(); + }); + this.left.on('pointermove', event => { + // 移动时调整形状大小,然后重绘边框 + // 检查右下角距离鼠标的位置, + if (this.leftDrag) { + var pos = this.toLocal(event.data.global); + var dX = Math.abs(pos.x - this.image.x); + this.assetData.Width = Math.abs(dX); + this.refresh(); + AxMessageSystem.send(EVENT_IMAGE_RESIZE, this.assetData); + } + + }); + this.left.on('pointerup', event => { + if (this.leftDrag) { + this.leftDrag = false; + this.image.anchor.set(0.5); + this.image.position.set(this.image.position.x - (this.image.width / 2), this.image.position.y); + } + }); + this.left.on('pointerupoutside', event => { + if (this.leftDrag) { + this.leftDrag = false; + this.image.anchor.set(0.5); + this.image.position.set(this.image.position.x - (this.image.width / 2), this.image.position.y); + } + }); + this.left.visible = false; + // right + this.right = new PIXI.Sprite(this.pointTexture); + this.right.cursor = 'ew-resize'; + this.right.anchor.set(0.5); + this.addChild(this.right); + this.right.interactive = true; + this.right.on('pointerdown', event => { + this.rightDrag = true; + this.image.anchor.set(0, 0.5); + this.image.position.set(this.image.position.x - (this.image.width / 2), this.image.position.y); + event.stopPropagation(); + }); + this.right.on('pointermove', event => { + // 移动时调整形状大小,然后重绘边框 + // 检查右下角距离鼠标的位置, + if (this.rightDrag) { + var pos = this.toLocal(event.data.global); + var dX = Math.abs(pos.x - this.image.x); + this.assetData.Width = Math.abs(dX); + this.refresh(); + AxMessageSystem.send(EVENT_IMAGE_RESIZE, this.assetData); + } + + }); + this.right.on('pointerup', event => { + if (this.rightDrag) { + this.rightDrag = false; + this.image.anchor.set(0.5); + this.image.position.set(this.image.position.x + (this.image.width / 2), this.image.position.y); + } + }); + this.right.on('pointerupoutside', event => { + if (this.rightDrag) { + this.rightDrag = false; + this.image.anchor.set(0.5); + this.image.position.set(this.image.position.x + (this.image.width / 2)); + } + }); + this.right.visible = false; // up-left this.upLeft = new PIXI.Sprite(this.pointTexture); this.upLeft.cursor = 'nwse-resize'; @@ -83,7 +247,7 @@ export class AxImageShape extends AxShape { this.addChild(this.upLeft); this.upLeft.interactive = true; this.upLeft.on('pointerdown', event => { - pointerDrag = true; + this.upLeftDrag = true; this.image.anchor.set(1); this.image.position.set(this.image.position.x + (this.image.width / 2), this.image.position.y + (this.image.height / 2)); event.stopPropagation(); @@ -91,7 +255,7 @@ export class AxImageShape extends AxShape { this.upLeft.on('pointermove', event => { // 移动时调整形状大小,然后重绘边框 // 检查右下角距离鼠标的位置, - if (pointerDrag) { + if (this.upLeftDrag) { var pos = this.toLocal(event.data.global); var dX = Math.abs(pos.x - this.image.x); var dY = Math.abs(pos.y - this.image.y); @@ -104,15 +268,15 @@ export class AxImageShape extends AxShape { }); this.upLeft.on('pointerup', event => { - if (pointerDrag) { - pointerDrag = false; + if (this.upLeftDrag) { + this.upLeftDrag = false; this.image.anchor.set(0.5); this.image.position.set(this.image.position.x - (this.image.width / 2), this.image.position.y - (this.image.height / 2)); } }); this.upLeft.on('pointerupoutside', event => { - if (pointerDrag) { - pointerDrag = false; + if (this.upLeftDrag) { + this.upLeftDrag = false; this.image.anchor.set(0.5); this.image.position.set(this.image.position.x - (this.image.width / 2), this.image.position.y - (this.image.height / 2)); } @@ -125,7 +289,7 @@ export class AxImageShape extends AxShape { this.addChild(this.upRight); this.upRight.interactive = true; this.upRight.on('pointerdown', event => { - pointerDrag = true; + this.upRightDrag = true; this.image.anchor.set(0, 1); this.image.position.set(this.image.position.x - (this.image.width / 2), this.image.position.y + (this.image.height / 2)); event.stopPropagation(); @@ -133,7 +297,7 @@ export class AxImageShape extends AxShape { this.upRight.on('pointermove', event => { // 移动时调整形状大小,然后重绘边框 // 检查右下角距离鼠标的位置, - if (pointerDrag) { + if (this.upRightDrag) { var pos = this.toLocal(event.data.global); var dX = Math.abs(pos.x - this.image.x); var dY = Math.abs(pos.y - this.image.y); @@ -146,15 +310,15 @@ export class AxImageShape extends AxShape { }); this.upRight.on('pointerup', event => { - if (pointerDrag) { - pointerDrag = false; + if (this.upRightDrag) { + this.upRightDrag = false; this.image.anchor.set(0.5); this.image.position.set(this.image.position.x + (this.image.width / 2), this.image.position.y - (this.image.height / 2)); } }); this.upRight.on('pointerupoutside', event => { - if (pointerDrag) { - pointerDrag = false; + if (this.upRightDrag) { + this.upRightDrag = false; this.image.anchor.set(0.5); this.image.position.set(this.image.position.x + (this.image.width / 2), this.image.position.y - (this.image.height / 2)); } @@ -167,7 +331,7 @@ export class AxImageShape extends AxShape { this.addChild(this.downLeft); this.downLeft.interactive = true; this.downLeft.on('pointerdown', event => { - pointerDrag = true; + this.downLeftDrag = true; this.image.anchor.set(1, 0); this.image.position.set(this.image.position.x + (this.image.width / 2), this.image.position.y - (this.image.height / 2)); event.stopPropagation(); @@ -175,7 +339,7 @@ export class AxImageShape extends AxShape { this.downLeft.on('pointermove', event => { // 移动时调整形状大小,然后重绘边框 // 检查右下角距离鼠标的位置, - if (pointerDrag) { + if (this.downLeftDrag) { var pos = this.toLocal(event.data.global); var dX = Math.abs(pos.x - this.image.x); var dY = Math.abs(pos.y - this.image.y); @@ -188,15 +352,15 @@ export class AxImageShape extends AxShape { }); this.downLeft.on('pointerup', event => { - if (pointerDrag) { - pointerDrag = false; + if (this.downLeftDrag) { + this.downLeftDrag = false; this.image.anchor.set(0.5); this.image.position.set(this.image.position.x - (this.image.width / 2), this.image.position.y + (this.image.height / 2)); } }); this.downLeft.on('pointerupoutside', event => { - if (pointerDrag) { - pointerDrag = false; + if (this.downLeftDrag) { + this.downLeftDrag = false; this.image.anchor.set(0.5); this.image.position.set(this.image.position.x - (this.image.width / 2), this.image.position.y + (this.image.height / 2)); } @@ -209,7 +373,7 @@ export class AxImageShape extends AxShape { this.addChild(this.downRight); this.downRight.interactive = true; this.downRight.on('pointerdown', event => { - pointerDrag = true; + this.downRightDrag = true; this.image.anchor.set(0, 0); this.image.position.set(this.image.position.x - (this.image.width / 2), this.image.position.y - (this.image.height / 2)); event.stopPropagation(); @@ -217,7 +381,7 @@ export class AxImageShape extends AxShape { this.downRight.on('pointermove', event => { // 移动时调整形状大小,然后重绘边框 // 检查右下角距离鼠标的位置, - if (pointerDrag) { + if (this.downRightDrag) { var pos = this.toLocal(event.data.global); var dX = Math.abs(pos.x - this.image.x); var dY = Math.abs(pos.y - this.image.y); @@ -230,15 +394,15 @@ export class AxImageShape extends AxShape { }); this.downRight.on('pointerup', event => { - if (pointerDrag) { - pointerDrag = false; + if (this.downRightDrag) { + this.downRightDrag = false; this.image.anchor.set(0.5); this.image.position.set(this.image.position.x + (this.image.width / 2), this.image.position.y + (this.image.height / 2)); } }); this.downRight.on('pointerupoutside', event => { - if (pointerDrag) { - pointerDrag = false; + if (this.downRightDrag) { + this.downRightDrag = false; this.image.anchor.set(0.5); this.image.position.set(this.image.position.x + (this.image.width / 2), this.image.position.y + (this.image.height / 2)); } @@ -247,32 +411,26 @@ export class AxImageShape extends AxShape { //// this.setItemScale(1 / this.workingArea.backgroundImage.scale.x); } - // // 设置选择框 - // public setSelectionBox(b: boolean, sprite?: PIXI.Sprite) { - // if (b) { - // this.selectionBox.lineStyle(2, 0x00EB00, 1); - // this.selectionBox.position = sprite.position; - // this.selectionBox.drawRect(- sprite.width / 2, - sprite.height / 2, sprite.width, sprite.height); - // } else { - // this.selectionBox.clear(); - // } - // } // 设置名称 public setNameVisible(value: boolean, mode: GameMode) { if (this.assetData.GameMode === mode) { this.text.visible = value; } } - // // 显示连接点 - // public showConnectionPoint(b: boolean) { - // this.connectPoint.visible = b; - // } /** * 设置点显示状态 * @param value 显示状态 */ public setPointVisiable(value: boolean) { const rect = this.getLocalBounds(); + this.up.x = rect.right - rect.width / 2; + this.up.y = rect.top; + this.down.x = rect.right - rect.width / 2; + this.down.y = rect.bottom; + this.left.x = rect.left; + this.left.y = rect.bottom - rect.height / 2; + this.right.x = rect.right; + this.right.y = rect.bottom - rect.height / 2; this.upLeft.x = rect.left; this.upLeft.y = rect.top; this.upRight.x = rect.right; @@ -281,6 +439,10 @@ export class AxImageShape extends AxShape { this.downLeft.y = rect.bottom; this.downRight.x = rect.right; this.downRight.y = rect.bottom; + this.up.visible = value; + this.down.visible = value; + this.left.visible = value; + this.right.visible = value; this.upLeft.visible = value; this.upRight.visible = value; this.downLeft.visible = value; @@ -296,6 +458,14 @@ export class AxImageShape extends AxShape { super.drawBorder(scale); const rect = this.getLocalBounds(); + this.up.x = rect.right - rect.width / 2; + this.up.y = rect.top; + this.down.x = rect.right - rect.width / 2; + this.down.y = rect.bottom; + this.left.x = rect.left; + this.left.y = rect.bottom - rect.height / 2; + this.right.x = rect.right; + this.right.y = rect.bottom - rect.height / 2; this.upLeft.x = rect.left; this.upLeft.y = rect.top; this.upRight.x = rect.right; @@ -315,6 +485,10 @@ export class AxImageShape extends AxShape { this.upRight.scale.set(scale); this.downLeft.scale.set(scale); this.downRight.scale.set(scale); + this.up.scale.set(scale); + this.down.scale.set(scale); + this.left.scale.set(scale); + this.right.scale.set(scale); } } // 刷新 @@ -326,26 +500,36 @@ export class AxImageShape extends AxShape { + '\r\n' + this.assetData.PropertyInfos?.find(item => item.PropertyName === '名称/编号')?.PropertyValue; + if (this.image.anchor.x == 0) { if (this.image.anchor.y == 0) { this.text.x = this.image.x + this.image.width / 2; this.text.y = this.image.y; } else if (this.image.anchor.y == 0.5) { - + this.text.x = this.image.x + this.image.width / 2; + this.text.y = this.image.y - this.image.height / 2; } else if (this.image.anchor.y == 1) { this.text.x = this.image.x + this.image.width / 2; this.text.y = this.image.y - this.image.height; } } else if (this.image.anchor.x == 0.5) { - this.text.x = this.image.x; - this.text.y = this.image.y - this.image.height / 2; + if (this.image.anchor.y == 0) { + this.text.x = this.image.x; + this.text.y = this.image.y; + } else if (this.image.anchor.y == 0.5) { + + } else if (this.image.anchor.y == 1) { + this.text.x = this.image.x; + this.text.y = this.image.y - this.image.height; + } } else if (this.image.anchor.x == 1) { if (this.image.anchor.y == 0) { this.text.x = this.image.x - this.image.width / 2; this.text.y = this.image.y; } else if (this.image.anchor.y == 0.5) { - + this.text.x = this.image.x - this.image.width / 2; + this.text.y = this.image.y - this.image.height / 2; } else if (this.image.anchor.y == 1) { this.text.x = this.image.x - this.image.width / 2; this.text.y = this.image.y - this.image.height; diff --git a/src/app/working-area/working-area.component.ts b/src/app/working-area/working-area.component.ts index f3b4165..60b6c20 100644 --- a/src/app/working-area/working-area.component.ts +++ b/src/app/working-area/working-area.component.ts @@ -166,7 +166,7 @@ export class WorkingAreaComponent extends EventEmitter implements OnInit, AfterV * 重大调整-主版本号增加 * 日期变更-日期版本号增加 */ - public VERSION = '1.4.0.20210302_rc'; + public VERSION = '1.4.1.20210303_rc'; /** * 数据初始化 */ From 525fa30f753dcaf6e5282b1e8b1845ae094982e4 Mon Sep 17 00:00:00 2001 From: SHAOJIAHAO <55341701@qq.com> Date: Wed, 3 Mar 2021 10:05:31 +0800 Subject: [PATCH 4/4] =?UTF-8?q?[=E6=96=B0=E5=A2=9E]=E5=8D=95=E4=BD=8D?= =?UTF-8?q?=E5=9F=BA=E6=9C=AC=E4=BF=A1=E6=81=AF=E6=A8=A1=E5=9D=97=E6=9B=BF?= =?UTF-8?q?=E6=8D=A2=E4=B8=BA=E6=9C=80=E6=96=B0=E7=89=88=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../basicinfo-look/basicinfo.component.html | 577 ++--- .../basicinfo-look/basicinfo.component.scss | 186 +- .../basicinfo-look/basicinfo.component.ts | 2037 ++++------------ .../basicinfo-look/lookmaster.component.html | 11 +- .../basicinfo/addhouseinfo.component.ts | 14 +- .../basicinfo/basicinfo.component.html | 537 ++--- .../basicinfo/basicinfo.component.scss | 146 +- .../key-unit/basicinfo/basicinfo.component.ts | 2056 ++++------------- 8 files changed, 1474 insertions(+), 4090 deletions(-) diff --git a/src/app/key-unit/basicinfo-look/basicinfo.component.html b/src/app/key-unit/basicinfo-look/basicinfo.component.html index 92548a9..52a1c4e 100644 --- a/src/app/key-unit/basicinfo-look/basicinfo.component.html +++ b/src/app/key-unit/basicinfo-look/basicinfo.component.html @@ -1,11 +1,10 @@ -<div style="height: 100%;display: flex; flex-direction: column;"> +<div style="height: 100%;display: flex; flex-direction: column;overflow: hidden;"> <!-- header --> <mat-accordion> - <mat-expansion-panel expanded hideToggle> + <mat-expansion-panel expanded> <mat-expansion-panel-header style="color: black;"> <mat-panel-title> 单位信息 - <mat-icon style="position: absolute;right:30px;">keyboard_arrow_down</mat-icon> </mat-panel-title> </mat-expansion-panel-header> <div class="topbox"> @@ -16,7 +15,7 @@ <span style="color: red;">*</span> <span>统一社会信用代码:</span> <mat-form-field> - <input readonly matInput id="creditcode" name="creditcode" type='text' #usci="ngModel" + <input matInput id="creditcode" name="creditcode" type='text' #usci="ngModel" required minlength="1" maxlength="18" [(ngModel)]="unitinfo.usci" (focus)="closeorganizationbox()" @@ -31,8 +30,8 @@ <div class="inputbox"> <span style="color: red;">*</span> <span>单位类型:</span> - <mat-form-field> - <mat-select disabled readonly required name="unittype" [(ngModel)]="defaultbuildingTypes"> + <mat-form-field (click)="closeorganizationbox()"> + <mat-select required name="unittype" [(ngModel)]="defaultbuildingTypes"> <mat-option [value]="item.id" *ngFor="let item of allunittype">{{item.name}}</mat-option> </mat-select> </mat-form-field> @@ -41,7 +40,7 @@ <span style="color: red;">*</span> <span>联系人:</span> <mat-form-field> - <input readonly matInput id="linkman" name="linkman" type='text' + <input matInput id="linkman" name="linkman" type='text' required minlength="1" [(ngModel)]="unitinfo.contacts" (focus)="closeorganizationbox()" @@ -52,7 +51,7 @@ <span style="color: red;">*</span> <span>联系电话:</span> <mat-form-field> - <input readonly matInput id="linkphone" name="linkphone" type='text' #linkphone="ngModel" + <input matInput id="linkphone" name="linkphone" type='text' #linkphone="ngModel" required pattern="^(?:\+?86)?1(?:3\d{3}|5[^4\D]\d{2}|8\d{3}|7(?:[35-8]\d{2}|4(?:0\d|1[0-2]|9\d))|9[0135-9]\d{2}|66\d{2})\d{6}$" [(ngModel)]="unitinfo.phone" (focus)="closeorganizationbox()" @@ -68,41 +67,59 @@ <span style="color: red;">*</span> <span>辖区中队:</span> <mat-form-field style="width: 538px;"> - <input readonly matInput id="organization" name="organization" type='text' + <input matInput id="organization" name="organization" type='text' required minlength="1" [(ngModel)]="selectedorganization" + (focus)="openorganizationbox()" readonly="value" > </mat-form-field> </div> - + <div id="organizationbox" class="organizationbox" *ngIf="isorganizationbox"> + <mat-tree [dataSource]="dataSource" [treeControl]="treeControl"> + <mat-tree-node *matTreeNodeDef="let node" matTreeNodePadding (click)='add(node)' class="organizationlist"> + <button type="button" mat-icon-button disabled ></button> + <li>{{node.name}}</li> + </mat-tree-node> + <mat-tree-node *matTreeNodeDef="let node;when: hasChild" matTreeNodePadding (click)='add(node)' class="organizationlist"> + <button + type="button" + mat-icon-button + matTreeNodeToggle + [attr.aria-label]="'toggle ' + node.name"> + <mat-icon class="mat-icon-rtl-mirror"> + {{treeControl.isExpanded(node) ? 'expand_more' : 'chevron_right'}} + </mat-icon> + </button> + <li>{{node.name}}</li> + </mat-tree-node> + </mat-tree> + </div> <div class="inputbox" style="width: 700px;"> <span style="color: red;">*</span> <span>单位地址:</span> <mat-form-field style="width: 538px;"> - <input readonly matInput id="unitaddress" name="unitaddress" type='text' + <input matInput id="unitaddress" name="unitaddress" type='text' required minlength="1" [(ngModel)]="unitinfo.address" (focus)="closeorganizationbox()"> </mat-form-field> </div> - <div class="uploadimg" (click)="lookmaster()"> + <div class="uploadimg"> <span>单位照片:</span> - <div class="uploadingimg"> - <img [src]="imgsrc" alt="" style="width: 299px; height: 170px;" > + <div class="uploadingimg" (click)="lookmaster()"> + <img [src]="imgsrc ? imgsrc : noImg" alt="" style="width: 299px; height: 170px;" > </div> <mat-spinner *ngIf="isspinner" diameter= 50></mat-spinner> </div> - <!-- <div class="image"> - <input id="selectedfile" type="file" name="imgFile" accept=".jpg,.png,.jpeg,.gif,.webp"> + <!-- <div class="image" (click)="closeorganizationbox()"> + <input id="selectedfile" type="file" ng2FileSelect [uploader]="uploader" (change)="filechange($event)" name="imgFile" accept=".jpg,.png,.jpeg,.gif,.webp"> </div> --> - <!-- <div class="addbtn"> - <button type="submit" color="primary" class="submit1" mat-button mat-raised-button>保存</button> - </div> --> </div> <div class="mainright" id="setPosition"> <div style="width: 100%;height: 100%;" id="container"> </div> + <div class="gistopbox" *ngIf="isGisTopBox"> <div class="positionItem"> <span> @@ -120,9 +137,18 @@ {{markerPosition.y || '暂未标注'}} </div> </div> - <!-- <div class="setPosition" (click)="setPosition()"> + <div class="setPosition"> <mat-icon style="width: 22px;height: 22px;font-size: 22px;">place</mat-icon> 位置 - </div> --> + </div> + </div> + <div class="gistopbox hidden" [ngClass]="{'show': isGisTopBoxTwo}"> + <div class="inputBox"> + <span>位置: </span> + <input name="position" [(ngModel)]="searchTitle" id="tipinput" class="positionInput" type="text" autocomplete="off"> + </div> + <div class="setPosition"> + 搜索 + </div> </div> </div> </div> @@ -130,61 +156,56 @@ </div> </mat-expansion-panel> </mat-accordion> - - <!-- body --> - <div class="bottombox" style="flex: 70%;overflow-y: auto;" > - <div class="houseinfobox" style="height: 100%; overflow-y: auto;padding-bottom: 34px; box-sizing:border-box"> - <!-- <button type="button" mat-icon-button class="addhouseinfo"><mat-icon style="font-size: 38px;">add_circle_outline</mat-icon></button> --> - <mat-tab-group style="height: 100%;;" > - <mat-tab [label]="item.username" *ngFor="let item of houses;let key = index"> - <form style="height: 100%; overflow-y:auto; display: block;" (ngSubmit)="onSubmit2(form.value,item,key,form.invalid)" #form="ngForm" class="example-container"> - - <!-- 正常建筑 --> - <div class="highinfo" *ngIf="item.tongyong"> - <div class="houseinfoinput" > - <span>建筑名称:</span> - <mat-form-field> - <input readonly matInput id="housename" name="housename" type='text' - minlength="1" [(ngModel)]="item.name" - > - </mat-form-field> - <span style="color: red;">*</span> - </div> - <div class="houseinfoinput"> - <span>建筑类型:</span> - <mat-form-field> - <mat-select disabled readonly name="unittype" [(ngModel)]="item.buildtype"> - <mat-option [value]="n.name" *ngFor="let n of allunittype">{{n.name}}</mat-option> - </mat-select> - </mat-form-field> - <span style="color: red;">*</span> - </div> - - <div *ngFor="let item of item.buildingBasicGroups;let www = index" style="float: left;"> - <h1 style="font-size: 22px;">{{item.name}}</h1> - <div class="houseinfoinput" *ngFor="let i of item.propertyInfos" style="float: left;margin-left: 250px;position: relative;"> + <div class="bodyBox" id="basicInfoBody"> + <!-- <div> + <button type="button" mat-icon-button (click)="addhouseinfo()" class="addBuilding"><mat-icon>add_circle_outline</mat-icon></button> + </div> --> + <div style="height: 100%; box-sizing:border-box;overflow-y: auto;padding-left: 26px;"> + <mat-tab-group style="height: 100%;" [selectedIndex]="selectedIndex" (selectedTabChange)="selectedTabChange($event)"> + <mat-tab *ngFor="let item of houses;let key = index" label="{{item.name}}"> + <ng-template matTabContent> + <form *ngIf="item.data && item.data.length!=0" style="height: 100%; overflow-y:auto; display: block;" (ngSubmit)="onSubmitBuildingInfo(form.value,item,key,form.invalid)" #form="ngForm" class="example-container"> + <div class="buildInfoInput" > + <span>建筑名称:</span> + <mat-form-field> + <input required matInput name="buildingName" type='text' minlength="1" [(ngModel)]="item.name"> + </mat-form-field> + <span style="color: red;">*</span> + </div> + <div class="buildInfoInput"> + <span>建筑类型:</span> + <mat-form-field> + <mat-select disabled name="buildingTypeName" [(ngModel)]="item.buildingTypes[0].name"> + <mat-option [value]="n.name" *ngFor="let n of allunittype" (click)="templateBuildtype(n,item,key)">{{n.name}}</mat-option> + </mat-select> + </mat-form-field> + <span style="color: red;">*</span> + </div> + <div *ngFor="let element of item.data[0].buildingBasicGroups;let groupsIndex = index "style="float: left;width:100%"> + <!-- 类型为表单并且不是 罐区 --> + <div *ngIf="element.type == 0 && element.name.indexOf('罐区') == -1"> + <p style="font-size: 22px;">{{element.name}}</p> + <div class="buildInfoInput" *ngFor="let i of element.propertyInfos;let inputIndex = index" style="float: left;margin-left: 250px;position: relative;"> <span>{{i.propertyName}}<span *ngIf="i.physicalUnit">({{i.physicalUnit}})</span>:</span> - <!-- 如果类型是文本 --> <mat-form-field *ngIf="i.propertyType == 0 && i.propertyName != '耐火等级'"> - <input readonly matInput name="{{i.propertyName}}{{www}}" type='text' + <input matInput name="{{groupsIndex}}{{inputIndex}}" type='text' required="{{ i.required==true ? 'true' : 'false' }}" [(ngModel)]="i.propertyValue"> </mat-form-field> - + <!-- 如果类型是数字 --> <mat-form-field *ngIf="i.propertyType == 2 && i.propertyName != '耐火等级'"> - <input readonly matInput name="{{i.propertyName}}{{www}}" type='number' + <input matInput name="{{groupsIndex}}{{inputIndex}}" type='number' required="{{ i.required==true ? 'true' : 'false' }}" [(ngModel)]="i.propertyValue" - + (change)="inputchange($event,i.ruleName,i.ruleValue,i)" > - <!-- <mat-error *ngIf="isshowrule">{{rulevalue}}</mat-error> --> </mat-form-field> - <!-- 如果类型是耐火等级 --> - <mat-form-field *ngIf="i.propertyName == '耐火等级'"> - <mat-select readonly name="{{i.propertyName}}{{www}}" required="{{ i.required==true ? 'true' : 'false' }}" placeholder="请选择耐火等级" [(ngModel)]="i.propertyValue"> + <!-- 如果类型是耐火等级 --> + <mat-form-field *ngIf="i.propertyName == '耐火等级'"> + <mat-select name="{{groupsIndex}}{{inputIndex}}" required="{{ i.required==true ? 'true' : 'false' }}" placeholder="请选择耐火等级" [(ngModel)]="i.propertyValue"> <mat-option value="0">1级</mat-option> <mat-option value="1">2级</mat-option> <mat-option value="2">3级</mat-option> @@ -192,352 +213,132 @@ </mat-select> </mat-form-field> <!-- 如果类型是多行文本 --> - <textarea readonly *ngIf="i.propertyType == 1 && i.propertyName != '耐火等级'" style="width: 180px;height: 60px;" required="{{ i.required==true ? 'true' : 'false' }}" [(ngModel)]="i.propertyValue" name="{{i.propertyName}}{{key}}"></textarea> + <textarea *ngIf="i.propertyType == 1 && i.propertyName != '耐火等级'" style="width: 180px;height: 60px;" required="{{ i.required==true ? 'true' : 'false' }}" [(ngModel)]="i.propertyValue" name="{{groupsIndex}}{{inputIndex}}"></textarea> <span style="color: red;" *ngIf="i.required">*</span> - <div *ngIf="i.isshowrule" style="position: absolute; - left: 205px; - top: 45px; - font-size: 11px; - color: red;"> + <div *ngIf="i.isshowrule" style="position: absolute;left: 205px;top: 45px;font-size: 11px;color: red;"> <span>{{i.rulevalue}}</span> </div> </div> </div> - - <div class="CustomData" style="width: 200px;"> - <!-- <mat-checkbox name="checkbuilding" [(ngModel)]="item.isCustomData" style="float: left;margin-right: 10px;"></mat-checkbox> --> - <h1 style="font-size: 22px;width: 200px;">自定义信息</h1> + <!-- 类型为表格 并且不是 罐区 --> + <div *ngIf="element.type == 1 && element.name.indexOf('罐区') == -1"> + <p style="font-size: 22px;"> + {{element.name}} + </p> + <table *ngIf="element.submitted"> + <tr> + <th *ngFor="let item of element.propertyInfos[0].origin;let index = index"> + {{item.propertyName}} + <span style="color: red;" *ngIf="item.required">*</span> + </th> + </tr> + <tr *ngFor="let item of element.propertyInfos;let line = index"> + <td *ngFor="let i of item.origin;let list = index"> + <input *ngIf="i.propertyType != 1" style="height:45px" class="tankinfo" name="{{element.name}}{{line + 1}}-{{list + 1}}" type="{{i.propertyType == 0 ? 'text' : 'number'}}" + required="{{ i.required==true ? 'true' : 'false' }}" [(ngModel)]="i.propertyValue"> + <textarea class="tankinfo" *ngIf="i.propertyType == 1" required="{{ i.required==true ? 'true' : 'false' }}" [(ngModel)]="i.propertyValue" name="{{element.name}}{{line + 1}}{{list + 1}}"> + + </textarea> + </td> + </tr> + </table> </div> - <div *ngIf="item.isCustomData" style="position: relative;"> - <!-- <button style="position: absolute;left: 0;" type="button" mat-icon-button class="addCustomData"><mat-icon style="font-size: 38px;">add_circle_outline</mat-icon></button> - <button style="position: absolute;left:60px;" type="button" mat-icon-button class="deleteCustomData"><mat-icon style="font-size: 38px;">remove_circle_outline</mat-icon></button> --> - <div class="houseinfoinput" style="float: left;margin-left: 250px;" *ngFor="let i of item.buildingCustomData.customProperties;let key = index"> - <mat-form-field> - <input readonly matInput type='text' name="{{key}}1CustomData" - required - [(ngModel)]="i.name"> - </mat-form-field> - <span>:</span> - <mat-form-field> - <input readonly matInput type='text' name="{{key}}2CustomData" - required - [(ngModel)]="i.value"> - </mat-form-field> - <span style="color: red;" *ngIf="i.required">*</span> - </div> - </div> - </div> - - <!-- 石油化工 --> - <div class="highinfo" *ngIf="item.isshiyou;let bigkey = index"> - - <div class="basicinfobox"> - <div class="houseinfoinput"> - <span>建筑名称:</span> - <mat-form-field> - <input readonly matInput id="housename" name="housename" type='text' - required minlength="1" [(ngModel)]="item.name" - > - </mat-form-field> - <span style="color: red;">*</span> - </div> - <div class="houseinfoinput" > - <span>建筑类型:</span> - <mat-form-field> - <mat-select disabled required name="unittype" [(ngModel)]="item.buildtype"> - <mat-option [value]="n.name" *ngFor="let n of allunittype">{{n.name}}</mat-option> - </mat-select> - </mat-form-field> - <span style="color: red;">*</span> - </div> - <h1 style="font-size: 22px;">{{item.buildingBasicGroups[0].name}}</h1> - <div class="houseinfoinput" *ngFor="let i of item.buildingBasicGroups[0].propertyInfos;let smkey = index" style="float: left;margin-left: 250px;position: relative;"> - <span>{{i.propertyName}} <span *ngIf="i.physicalUnit">({{i.physicalUnit}})</span> :</span> - + <!-- 类型为表单 是罐区--> + <div *ngIf="element.type == 0 && element.name.indexOf('罐区') != -1"> + <p style="font-size: 22px;"> + <span *ngIf="element.name == '罐区1'">罐区信息</span> + </p> + <div *ngIf="element.submitted" > + <p style="font-size: 22px;">{{element.name}}</p> - <!-- 如果类型是文本 --> - <mat-form-field *ngIf="i.propertyType == 0 && i.propertyName != '耐火等级'"> - <input readonly matInput name="{{i.propertyName}}" type='text' - required="{{ i.required==true ? 'true' : 'false' }}" - [(ngModel)]="i.propertyValue"> - </mat-form-field> - - <!-- 如果类型是数字 --> - <mat-form-field *ngIf="i.propertyType == 2 && i.propertyName != '耐火等级'"> - <input readonly matInput name="{{i.propertyName}}" type='number' - required="{{ i.required==true ? 'true' : 'false' }}" - [(ngModel)]="i.propertyValue" - - > - <!-- <mat-error *ngIf="isshowrule">{{rulevalue}}</mat-error> --> - </mat-form-field> - <!-- 如果类型是耐火等级 --> - <mat-form-field *ngIf="i.propertyName == '耐火等级'"> - <mat-select readonly name="{{i.propertyName}}" required="{{ i.required==true ? 'true' : 'false' }}" placeholder="请选择耐火等级" [(ngModel)]="i.propertyValue"> - <mat-option value="0">1级</mat-option> - <mat-option value="1">2级</mat-option> - <mat-option value="2">3级</mat-option> - <mat-option value="3">其它</mat-option> - </mat-select> - </mat-form-field> - <!-- 如果类型是多行文本 --> - <textarea readonly *ngIf="i.propertyType == 1 && i.propertyName != '耐火等级'" style="width: 180px;height: 60px;" required="{{ i.required==true ? 'true' : 'false' }}" [(ngModel)]="i.propertyValue" name="{{i.propertyName}}"></textarea> - <span style="color: red;" *ngIf="i.required">*</span> - <div *ngIf="i.isshowrule" style=" position: absolute; - left: 205px; - top: 45px; - font-size: 11px; - color: red;"> - <span>{{i.rulevalue}}</span> - </div> + <div class="buildInfoInput" *ngFor="let i of element.propertyInfos;let inputIndex = index" style="float: left;margin-left: 250px;position: relative;"> + <span>{{i.propertyName}}<span *ngIf="i.physicalUnit">({{i.physicalUnit}})</span>:</span> + <!-- 如果类型是文本 --> + <mat-form-field *ngIf="i.propertyType == 0 && i.propertyName != '耐火等级'"> + <input matInput name="{{groupsIndex}}{{inputIndex}}" type='text' + required="{{ i.required==true ? 'true' : 'false' }}" + [(ngModel)]="i.propertyValue"> + </mat-form-field> + + <!-- 如果类型是数字 --> + <mat-form-field *ngIf="i.propertyType == 2 && i.propertyName != '耐火等级'"> + <input matInput name="{{groupsIndex}}{{inputIndex}}" type='number' + required="{{ i.required==true ? 'true' : 'false' }}" + [(ngModel)]="i.propertyValue" + (change)="inputchange($event,i.ruleName,i.ruleValue,i)" + > + </mat-form-field> + <!-- 如果类型是耐火等级 --> + <mat-form-field *ngIf="i.propertyName == '耐火等级'"> + <mat-select name="{{groupsIndex}}{{inputIndex}}" required="{{ i.required==true ? 'true' : 'false' }}" placeholder="请选择耐火等级" [(ngModel)]="i.propertyValue"> + <mat-option value="0">1级</mat-option> + <mat-option value="1">2级</mat-option> + <mat-option value="2">3级</mat-option> + <mat-option value="3">其它</mat-option> + </mat-select> + </mat-form-field> + <!-- 如果类型是多行文本 --> + <textarea *ngIf="i.propertyType == 1 && i.propertyName != '耐火等级'" style="width: 180px;height: 60px;" required="{{ i.required==true ? 'true' : 'false' }}" [(ngModel)]="i.propertyValue" name="{{groupsIndex}}{{inputIndex}}"></textarea> + + <span style="color: red;" *ngIf="i.required">*</span> + <div *ngIf="i.isshowrule" style="position: absolute;left: 205px;top: 45px;font-size: 11px;color: red;"> + <span>{{i.rulevalue}}</span> + </div> + </div> </div> + </div> - - - <div class="deviceinfo"> - <div style="width: 200px;"> - <!-- <mat-checkbox name="item.buildingBasicGroups[1].name" *ngIf="item.buildingBasicGroups[1].isOptional" [(ngModel)]="item.buildingBasicGroups[1].submitted" style="float: left;margin-right: 10px;"></mat-checkbox> --> - <h1 style="font-size: 22px;width: 200px;">{{item.buildingBasicGroups[1].name}}</h1> - </div> - - <table mat-table [dataSource]="devicedataSourcebox[item.buildingId]" class="mat-elevation-z8" *ngIf="item.buildingBasicGroups[1].submitted"> - <ng-container matColumnDef="name"> - <th mat-header-cell *matHeaderCellDef> - <button style="width: 24px;" type="button" mat-icon-button class="adddeviceinfo2" ><mat-icon>add_circle_outline</mat-icon></button> - <button style="width: 24px;" type="button" mat-icon-button class="removedeviceinfo" ><mat-icon>remove_circle_outline</mat-icon></button> - 装置区名称<span style="color: red;">*</span></th> - <td mat-cell *matCellDef="let element;let key = index"> - <textarea readonly style="width: 100px;" [(ngModel)]="element.name" name="{{key}}1" required></textarea> - </td> - </ng-container> - <ng-container matColumnDef="flow"> - <th mat-header-cell *matHeaderCellDef>工艺流程<span style="color: red;">*</span></th> - <td mat-cell *matCellDef="let element;let key = index"> - <textarea readonly [(ngModel)]="element.flow" name="{{key}}2" required></textarea> - </td> - </ng-container> - <ng-container matColumnDef="danger"> - <th mat-header-cell *matHeaderCellDef>火灾危险性<span style="color: red;">*</span></th> - <td mat-cell *matCellDef="let element;let key = index"> - <textarea readonly [(ngModel)]="element.danger" name="{{key}}3" required></textarea> + <!-- 类型为表格 是罐区 --> + <div *ngIf="element.type == 1 && element.name.indexOf('罐区') != -1"> + <p style="font-size: 22px;" *ngIf="element.submitted"> + {{element.name}} + </p> + <table *ngIf="element.submitted"> + <tr> + <th *ngFor="let item of element.propertyInfos[0].origin;let index = index"> + {{item.propertyName}} + <span style="color: red;" *ngIf="item.required">*</span> + </th> + </tr> + <tr *ngFor="let item of element.propertyInfos;let line = index"> + <td *ngFor="let i of item.origin;let list = index"> + <input type="{{i.propertyType == 0 ? 'text' : 'number'}}" style="height:45px" class="tankinfo" name="{{element.name}}{{line + 1}}-{{list + 1}}" + required="{{ i.required==true ? 'true' : 'false' }}" [(ngModel)]="i.propertyValue"> </td> - </ng-container> - <ng-container matColumnDef="payattentionto"> - <th mat-header-cell *matHeaderCellDef>灭火注意事项</th> - <td mat-cell *matCellDef="let element;let key = index"> - <textarea readonly style="width: 100px;" [(ngModel)]="element.payattentionto" name="{{key}}4"></textarea> - </td> - </ng-container> - <tr mat-header-row *matHeaderRowDef="displayedColumns"></tr> - <tr mat-row *matRowDef="let row; columns: displayedColumns;"></tr> + </tr> </table> </div> - - <div style="width: 200px;"> - <!-- <mat-checkbox *ngIf="item.buildingBasicGroups[2].isOptional" name="item.buildingBasicGroups[2].name" [(ngModel)]="item.buildingBasicGroups[2].submitted" style="float: left;margin-right: 10px;"></mat-checkbox> --> - <h1 style="font-size: 22px;width: 200px;">储罐信息</h1> - </div> - - <!-- <button *ngIf="item.buildingBasicGroups[2].submitted" type="button" mat-raised-button color="primary" style="margin-top: 30px;margin-right: 5px;">添加储罐</button> - <button *ngIf="item.buildingBasicGroups[2].submitted" type="button" mat-raised-button color="warn" style="margin-top: 30px;" matTooltip="会将此建筑处于末尾的储罐移除">移除末尾储罐</button> --> - - - <div *ngIf="item.buildingBasicGroups[2].submitted" style="margin-top: 30px;"> - <div class="tankinfo" *ngFor="let x of item.bigfor;let www = index"> - <p style="font-size: 22px; width: 200px;">{{x[0].name}}</p> - <div class="basicinfobox" > - <div class="houseinfoinput" *ngFor="let i of x[0].propertyInfos;let key = index" style="line-height: 65px;"> - <span>{{i.propertyName}} {{i.physicalUnit}}:</span> - <mat-form-field *ngIf="i.propertyType == 0"> - <input readonly matInput name="{{www+2}}-tanker-{{key}}" type='text' - required="{{ i.required==true ? 'true' : 'false' }}" - [(ngModel)]="i.propertyValue" - > - </mat-form-field> - <textarea readonly style="width: 180px;height: 45px;" *ngIf="i.propertyType == 1" [(ngModel)]="i.propertyValue" name="{{www+2}}-tanker-{{key}}"></textarea> - <span style="color: red;" *ngIf="i.required">*</span> - </div> + </div> - </div> - <p style="font-size: 22px; width: 200px;">{{x[1].name}}</p> - <div class="tankdetailinfo"> - <table #table mat-table [dataSource]="x[1].propertyInfos" class="mat-elevation-z8" style="position: relative;"> - <ng-container matColumnDef="tank"> - <th mat-header-cell *matHeaderCellDef> - <!-- <button type="button" mat-icon-button class="adddeviceinfo" style="position: absolute;left: 0;"><mat-icon>add_circle_outline</mat-icon></button> - <button type="button" mat-icon-button class="removedeviceinfo"><mat-icon>remove_circle_outline</mat-icon></button> --> - 罐区 </th> - <td mat-cell *matCellDef="let element;let key = index"> - <input readonly style="height:45px" class="tankinfo" name="{{www}}{{element.tank}}tank{{key}}" type='text' - [(ngModel)]="element.tank"> - </td> - </ng-container> - <ng-container matColumnDef="tankid"> - <th mat-header-cell *matHeaderCellDef>罐区编号<span style="color: red;">*</span></th> - <td mat-cell *matCellDef="let element;let key = index"> - <input readonly style="height:45px" class="tankinfo" name="{{www}}{{element.tankid}}tank{{key}}" type='text' - required - [(ngModel)]="element.tankid"> - </td> - </ng-container> - <ng-container matColumnDef="tankmedium"> - <th mat-header-cell *matHeaderCellDef>储存介质<span style="color: red;">*</span></th> - <td mat-cell *matCellDef="let element;let key = index"> - <input readonly style="height:45px" class="tankinfo" name="{{www}}{{element.tankmedium}}tank{{key}}" type='text' - required - [(ngModel)]="element.tankmedium"> - </td> - </ng-container> - - <ng-container matColumnDef="tanktype"> - <th mat-header-cell *matHeaderCellDef>储罐类型<span style="color: red;">*</span></th> - <td mat-cell *matCellDef="let element;let key = index"> - <input readonly style="height:45px" class="tankinfo" name="{{www}}{{element.tanktype}}tank{{key}}" type='text' - required - [(ngModel)]="element.tanktype"> - </td> - </ng-container> - <ng-container matColumnDef="tankcapacity"> - <th mat-header-cell *matHeaderCellDef>容量(m³)<span style="color: red;">*</span></th> - <td mat-cell *matCellDef="let element;let key = index"> - <input readonly style="height:45px" class="tankinfo" name="{{www}}{{element.tankcapacity}}tank{{key}}" type='text' - required - [(ngModel)]="element.tankcapacity"> - </td> - </ng-container> - <ng-container matColumnDef="tankdiameter"> - <th mat-header-cell *matHeaderCellDef>直径(m)<span style="color: red;">*</span></th> - <td mat-cell *matCellDef="let element;let key = index"> - <input readonly style="height:45px" class="tankinfo" name="{{www}}{{element.tankdiameter}}tank{{key}}" type='text' - required - [(ngModel)]="element.tankdiameter"> - </td> - </ng-container> - <ng-container matColumnDef="tankheight"> - <th mat-header-cell *matHeaderCellDef>高度(m)<span style="color: red;">*</span></th> - <td mat-cell *matCellDef="let element;let key = index"> - <input readonly style="height:45px" class="tankinfo" name="{{www}}{{element.tankheight}}tank{{key}}" type='text' - required - [(ngModel)]="element.tankheight"> - </td> - </ng-container> - <ng-container matColumnDef="tanktectum"> - <th mat-header-cell *matHeaderCellDef>顶盖形式</th> - <td mat-cell *matCellDef="let element;let key = index"> - <input readonly style="height:45px" class="tankinfo" name="{{www}}{{element.tanktectum}}tank{{key}}" type='text' - [(ngModel)]="element.tanktectum"> - </td> - </ng-container> - <ng-container matColumnDef="tanktexture"> - <th mat-header-cell *matHeaderCellDef>浮盘材质</th> - <td mat-cell *matCellDef="let element;let key = index"> - <input readonly style="height:45px" class="tankinfo" name="{{www}}{{element.tanktexture}}tank{{key}}" type='text' - [(ngModel)]="element.tanktexture"> - </td> - </ng-container> - <ng-container matColumnDef="platetype"> - <th mat-header-cell *matHeaderCellDef>浮盘类型</th> - <td mat-cell *matCellDef="let element;let key = index"> - <input readonly style="height:45px" class="tankinfo" name="{{www}}{{element.platetype}}tank{{key}}" type='text' - [(ngModel)]="element.platetype"> - </td> - </ng-container> - <ng-container matColumnDef="foamgeneratorid"> - <th mat-header-cell *matHeaderCellDef>泡沫产生器型号</th> - <td mat-cell *matCellDef="let element;let key = index"> - <input readonly style="height:45px" class="tankinfo" name="{{www}}{{element.foamgeneratorid}}tank{{key}}" type='text' - [(ngModel)]="element.foamgeneratorid"> - </td> - </ng-container> - <ng-container matColumnDef="foamgeneratortype"> - <th mat-header-cell *matHeaderCellDef>泡沫产生器形式</th> - <td mat-cell *matCellDef="let element;let key = index"> - <input readonly style="height:45px" class="tankinfo" name="{{www}}{{element.foamgeneratortype}}tank{{key}}" type='text' - [(ngModel)]="element.foamgeneratortype"> - </td> - </ng-container> - <ng-container matColumnDef="isprotect"> - <th mat-header-cell *matHeaderCellDef>是否设置氮封惰化保护装置</th> - <td mat-cell *matCellDef="let element;let key = index"> - <input readonly style="height:45px" class="tankinfo" name="{{www}}{{element.isprotect}}tank{{key}}" type='text' - [(ngModel)]="element.isprotect"> - </td> - </ng-container> - <ng-container matColumnDef="fendinggroyneheight"> - <th mat-header-cell *matHeaderCellDef>防护堤高度(m)<span style="color: red;">*</span></th> - <td mat-cell *matCellDef="let element;let key = index"> - <input readonly style="height:45px" class="tankinfo" name="{{www}}{{element.fendinggroyneheight}}tank{{key}}" type='text' - required - [(ngModel)]="element.fendinggroyneheight"> - </td> - </ng-container> - <ng-container matColumnDef="portnum"> - <th mat-header-cell *matHeaderCellDef>半固定泡沫灭火接口数量</th> - <td mat-cell *matCellDef="let element;let key = index"> - <input readonly style="height:45px" class="tankinfo" name="{{www}}{{element.portnum}}tank{{key}}" type='text' - - [(ngModel)]="element.portnum"> - </td> - </ng-container> - <ng-container matColumnDef="else"> - <th mat-header-cell *matHeaderCellDef>其它设施</th> - <td mat-cell *matCellDef="let element;let key = index"> - <input readonly style="height:45px" class="tankinfo" name="{{www}}{{element.else}}tank{{key}}" type='text' - - [(ngModel)]="element.else"> - </td> - </ng-container> - - - <tr mat-header-row *matHeaderRowDef="displayedColumns2"></tr> - <tr mat-row *matRowDef="let row; columns: displayedColumns2;"></tr> - </table> - </div> - </div> - </div> + <div class="CustomData" style="width: 200px;margin-top: 60px;"> + <h1 style="font-size: 22px;width: 200px;">自定义信息</h1> + </div> + <div style="position: relative;" *ngIf="item.isCustomData"> - - <div class="CustomData" style="width: 200px;margin-top: 60px;"> - <!-- <mat-checkbox name="checkbuilding" [(ngModel)]="item.isCustomData" style="float: left;margin-right: 10px;"></mat-checkbox> --> - <h1 style="font-size: 22px;width: 200px;">自定义信息</h1> - </div> - <div *ngIf="item.isCustomData" style="position: relative;"> - <button style="position: absolute;left: 0;font-size: 11px;" type="button" mat-icon-button class="addCustomData"><mat-icon style="font-size: 38px;">add_circle_outline</mat-icon></button> - <button style="position: absolute;left:60px;" type="button" mat-icon-button class="deleteCustomData"><mat-icon style="font-size: 38px;">remove_circle_outline</mat-icon></button> - <div class="houseinfoinput" style="float: left;margin-left: 250px;" *ngFor="let i of item.buildingCustomData.customProperties;let key = index"> - <mat-form-field> - <input readonly matInput type='text' name="{{key}}1CustomData" - required - [(ngModel)]="i.name"> - </mat-form-field> - <span>:</span> - <mat-form-field> - <input readonly matInput type='text' name="{{key}}2CustomData" - required - [(ngModel)]="i.value"> - </mat-form-field> - <span style="color: red;" *ngIf="i.required">*</span> - </div> + <div class="houseinfoinput" style="float: left;margin-left: 250px;" *ngFor="let i of item.customData.customProperties;let key = index"> + <mat-form-field> + <input matInput type='text' name="customData{{key}}Name" + required + [(ngModel)]="i.name"> + </mat-form-field> + <span>:</span> + <mat-form-field> + <input matInput type='text' name="customData{{key}}Value" + required + [(ngModel)]="i.value"> + </mat-form-field> + <span style="color: red;" *ngIf="i.required">*</span> </div> - </div> - - - <!-- <div class="infobtnbox"> - <button type="submit()" mat-button mat-raised-button color="primary" >保存</button> - <button type="button" mat-raised-button color="warn">删除</button> - </div> --> - </form> - </mat-tab> + </ng-template> - </mat-tab-group> - + + </mat-tab> + </mat-tab-group> </div> - </div> - </div> diff --git a/src/app/key-unit/basicinfo-look/basicinfo.component.scss b/src/app/key-unit/basicinfo-look/basicinfo.component.scss index 2648fb9..9c6800b 100644 --- a/src/app/key-unit/basicinfo-look/basicinfo.component.scss +++ b/src/app/key-unit/basicinfo-look/basicinfo.component.scss @@ -1,7 +1,7 @@ .topbox{ height: 485px; width: 100%; - // border-bottom: 1px solid black; + padding-bottom: 20px; .mainbox{ height: 100%; position: relative; @@ -9,7 +9,6 @@ .mainleft{ width:800px; height: 100%; - // background-color: yellow; float: left; .inputbox{ width: 343px; @@ -41,13 +40,8 @@ } .addbtn{ width: 695px; - position: absolute; - bottom: -495px; - text-align: center; - margin-bottom:20px; - button{ - margin: 0 4px; - } + margin:20px 0; + padding-bottom: 20px; } .uploadimg{ width: 400px; @@ -56,18 +50,13 @@ margin-top:12px; position: relative; margin-left: 80px; - cursor: pointer; span{ float: left; } - // img{ - // float: left; - // } .uploadingimg{ width: 299px; height: 170px; - // background: url('../../../assets/images/upload2.png') no-repeat center center; - + cursor: pointer; position: absolute; top: 0px; left: 79px; @@ -77,20 +66,11 @@ } .image{ - // position: absolute; - // top: 199px; - // left: 160px; - // width: 299px; - // height: 170px; input{ - // width: 299px; - // height: 170px; width: 190px; margin-top: 160px; cursor: pointer; } - // opacity:0; - } } .mainright{ @@ -107,7 +87,6 @@ } .gistopbox{ position: absolute; - box-shadow: 0px 3px 6px rgba(0, 0, 0, 0.16); border-radius: 4px; left: 5%; @@ -146,55 +125,60 @@ align-items: center; justify-content: center; } - + .inputBox{ + width: 63%; + display: flex; + align-items: center; + .positionInput{ + border: 0; + border-radius: 6px; + width: 90%; + height: 34px; + background: #F2F2F2; + margin-left: 8px; + box-sizing: border-box; + padding-left: 10px; + } + } } + .hidden{ + opacity: 0; + z-index: -1; + } + .show{ + opacity: 1; + z-index: 1; + } } } } -.bottombox{ - // height:400px; - width: 100%; - // background-color: skyblue; - - .bottomtitle{ - height: 60px; - // background-color: orange; - line-height: 60px; - border-top: 1px solid black; - border-bottom: 1px solid black; +.bodyBox{ + flex: 70%;overflow-y: auto; + position: relative; + .addBuilding{ + position: absolute; + z-index: 999; + left: 0; + top: 3px; } - .houseinfobox{ - // height:340px; - overflow: auto; - .addhouseinfo{ - float: left; - } - .infobtnbox{ - margin-left: 800px; - position: absolute; - top: 30px; - right: 75px; - button{ - width: 80px; - height: 40px; - margin: 0 12px; - margin-top: 15px; - } - } - .infotitle{ - font-size: 28px; - font-weight: 900; - margin-left: 180px; - } - .houseinfoinput{ - width: 393px; - text-align: end; - margin-left:240px; + .buildInfoInput{ + width: 393px; + text-align: end; + margin-left:240px; + } + .infobtnbox{ + position: absolute; + top: 30px; + right: 75px; + button{ + width: 80px; + height: 40px; + margin: 0 12px; + margin-top: 15px; } } } - .btn{ width: 100%; text-align: center; @@ -206,37 +190,29 @@ margin-top: 58px; margin-left: 203px; } -.mat-table{ - width: 99%; -} + table{ - width: 1000px; - thead{ - tr{ - th{ - width: 60px; - display: block; - float: left; - - } + width: 99%; + tr{ + display: flex; + td,th{ + flex: 1; } - } - tbody{ - tr{ + th{ + display: flex; + align-items: center; + justify-content: center; - td{ - width: 60px; - display: block; - float: left; - text-align: center; - } + } + input{ + border: 0px ; } } } - +table,table tr th, table tr td { border: 0.1px solid gray; } +table { text-align: center; border-collapse: collapse; padding:2px;} .deviceinfo{ - // border-bottom: 1px solid black;; padding-bottom: 60px; } .tankdetailinfo{ @@ -250,14 +226,10 @@ table{ } .tankinfo{ display: block; - width: 100%; - // height: 45px; + width: 97.5%; text-align: center; + border: 0px; } -// .adddeviceinfo{ -// // position: absolute; -// // left: 0px; -// } .submit1{ margin-left: -66px !important; } @@ -269,31 +241,7 @@ textarea { height: 110px; resize: none; } - //预览图片旋转角度 - .img1{ - transform:rotate(90deg) scale(0.55); - height: 100%; -} -.img2{ - transform:rotate(180deg); - // height: 100%; -} -.img3{ - transform:rotate(270deg) scale(0.55); - // height: 100%; -} -.img4{ - transform:rotate(90deg) scale(1.3); - // height: 100%; -} -.img5{ - transform:rotate(180deg); - // height: 100%; -} -.img6{ - transform:rotate(270deg) scale(1.3); - // height: 100%; -} + .imgbox{ text-align: center; height: 750px; diff --git a/src/app/key-unit/basicinfo-look/basicinfo.component.ts b/src/app/key-unit/basicinfo-look/basicinfo.component.ts index afb4dc2..03a70aa 100644 --- a/src/app/key-unit/basicinfo-look/basicinfo.component.ts +++ b/src/app/key-unit/basicinfo-look/basicinfo.component.ts @@ -1,14 +1,13 @@ -import { Component, OnInit, Inject ,ViewChild, ElementRef, Renderer2} from '@angular/core'; +import { Component, OnInit, Inject ,ViewChild, Renderer2, ElementRef, Directive, forwardRef} from '@angular/core'; import { MatTreeFlatDataSource, MatTreeFlattener } from '@angular/material/tree'; import { FlatTreeControl } from '@angular/cdk/tree'; import { HttpClient,HttpHeaders, HttpEventType } from '@angular/common/http'; import { MatDialog, MatDialogRef, MAT_DIALOG_DATA } from '@angular/material/dialog'; -import { FormControl } from '@angular/forms'; +import { AbstractControl, FormControl, NG_VALIDATORS, Validator } from '@angular/forms'; import { MatSnackBar ,MatSnackBarConfig} from '@angular/material/snack-bar'; import format from 'date-fns/format'; import { TreeService } from '../../http-interceptors/tree.service' import { FileUploader, FileItem } from 'ng2-file-upload' -// import { House } from '../../interface' import { DomSanitizer } from '@angular/platform-browser' import { Injectable } from "@angular/core" import { filter } from 'rxjs/operators'; @@ -16,10 +15,11 @@ import { async } from '@angular/core/testing'; import { MatTableDataSource } from '@angular/material/table'; import { isNgTemplate } from '@angular/compiler'; import * as _ from 'lodash'; -// import Swiper from 'swiper'; +import Swiper from 'swiper'; import { LookMaster2 } from './lookmaster.component' -import { Router,ActivatedRoute } from '@angular/router' +import { ActivatedRoute } from '@angular/router'; declare var AMap: any; + @Component({ selector: 'app-basicinfo-look', templateUrl: './basicinfo.component.html', @@ -77,28 +77,46 @@ export class BasicinfoLookComponent implements OnInit { selectedorganization: any//所选的辖区中队 selectedorganizationid:any //所选的辖区中队的id highhouse = false//控制高层表单的显示 - houses: any = [] //存储当前单位的建筑信息 + defaultbuildingTypes :any //存储当前建筑的默认类型的id buildingTypesname:any//存储当前建筑的默认类型name buildingCustomData:any //存储当前建筑的自定义信息 allunittype: any //所有单位类型 allorganizing:any = [] //所有组织机构 - constructor(private elementRef: ElementRef,public renderer2: Renderer2,private router:Router,private route:ActivatedRoute,private http: HttpClient, private tree: TreeService, private sanitizer: DomSanitizer, public dialog: MatDialog,public snackBar: MatSnackBar) { } - + constructor(private route:ActivatedRoute,private elementRef: ElementRef,public renderer2: Renderer2,private http: HttpClient, private tree: TreeService, private sanitizer: DomSanitizer, public dialog: MatDialog,public snackBar: MatSnackBar) { } + houses: any = [] //存储当前单位的建筑信息 unitId : any //当前单位id ngOnInit(): void { this.getallunittype() this.getorganization() - // this.getunitinfo() - this.getunitallbuilding() + this.getUnitAllBuildings()//获得单位下所有建筑 this.unitId = this.route.snapshot.queryParams.id } + //获得单位下所有建筑 + getUnitAllBuildings(){ + this.unitId = this.route.snapshot.queryParams.id + this.http.get("/api/Buildings",{ + params:{ + companyId:this.unitId + } + }).subscribe(async (data:any)=>{ // 获得当前单位所有的建筑 + data.forEach(element => { + element.data = [] + }); + this.houses = data + this.getBuildingInfo() + }) + } + + + isMapLabel:boolean //地图标注位置 markerPosition:any = {x: 0, y: 0}//单位坐标 map:any //地图实例 isGisTopBox:boolean = false//点击位置按钮 + isGisTopBoxTwo:boolean = false//点击位置按钮 oldPositionMarker:any //旧位置marker实例 newPositionMarker:any //新位置marker实例 @@ -116,6 +134,23 @@ export class BasicinfoLookComponent implements OnInit { ' <img src="/assets/images/oldposition.png">' + '</div>' //初始化地图 + searchTitle:any//搜索内容 + placeSearch:any//地址搜索类 + search(){ + this.placeSearch.search(this.searchTitle, (status, result) => { + // 搜索成功时,result即是对应的匹配数据 + if(result.info == "OK"){ + this.newPositionMarker.setPosition([result.poiList.pois[0].location.lng,result.poiList.pois[0].location.lat]) + this.markerPosition2 = {x: result.poiList.pois[0].location.lng, y: result.poiList.pois[0].location.lat} + this.map.setCenter([result.poiList.pois[0].location.lng,result.poiList.pois[0].location.lat]); //设置地图中心点 + }else{ + alert('查询不到输入地址信息') + } + + }) + + } + //初始化地图 labelGis(){ this.map = new AMap.Map('container', { zoom:12 @@ -123,26 +158,45 @@ export class BasicinfoLookComponent implements OnInit { this.map.on('complete', () => { this.isGisTopBox = true }); - if(this.isMapLabel){//如果已经标注单位坐标 - console.log('已标注单位位置') - this.map.setCenter([this.unitinfo.location.x,this.unitinfo.location.y]); - this.oldPositionMarker = new AMap.Marker({ - position: [this.unitinfo.location.x,this.unitinfo.location.y], - content: this.newPositionMarkerContent, - offset: new AMap.Pixel(-15, -18) - }) - // 将 markers 添加到地图 - this.map.add(this.oldPositionMarker); - }else{ - console.log('未标注单位位置') - this.map.setCity('上海市'); - } + //输入提示 + var autoOptions = { + input: "tipinput" + }; + AMap.plugin(['AMap.PlaceSearch','AMap.AutoComplete'], ()=>{ + var auto = new AMap.AutoComplete(autoOptions); + this.placeSearch = new AMap.PlaceSearch(); //构造地点查询类 + auto.on("select", (e)=>{ + // console.log(e) + // console.log( this.newPositionMarker) + this.newPositionMarker.setPosition([e.poi.location.lng,e.poi.location.lat]) + this.markerPosition2 = {x: e.poi.location.lng, y: e.poi.location.lat} + this.map.setCenter([e.poi.location.lng,e.poi.location.lat]); //设置地图中心点 + });//注册监听,当选中某条记录时会触发 + + }); + + if(this.isMapLabel){//如果已经标注单位坐标 + // console.log('已标注单位位置') + this.map.setCenter([this.unitinfo.location.x,this.unitinfo.location.y]); + this.oldPositionMarker = new AMap.Marker({ + position: [this.unitinfo.location.x,this.unitinfo.location.y], + content: this.newPositionMarkerContent, + offset: new AMap.Pixel(-15, -18) + }) + // 将 markers 添加到地图 + this.map.add(this.oldPositionMarker); + }else{ + // console.log('未标注单位位置') + this.map.setCity('上海'); + } } + markerPosition2 //点击位置按钮 setPosition(){ this.isGisTopBox = false + this.isGisTopBoxTwo = true if(this.isMapLabel){//如果已经标注单位坐标 - console.log('已标注单位位置') + // console.log('已标注单位位置') if(this.oldPositionMarker){ this.oldPositionMarker.setContent(this.oldPositionMarkerContent) @@ -160,41 +214,43 @@ export class BasicinfoLookComponent implements OnInit { this.map.add(this.newPositionMarker); - let markerPosition if(this.markerPosition.x && this.markerPosition.x != 0){ - markerPosition = {x: this.markerPosition.x,y: this.markerPosition.y} + this.markerPosition2 = {x: this.markerPosition.x,y: this.markerPosition.y} }else{ - markerPosition = {x: this.map.getCenter().lng,y: this.map.getCenter().lat} //获取当前地图中心位置 + this.markerPosition2 = {x: this.map.getCenter().lng,y: this.map.getCenter().lat} //获取当前地图中心位置 } this.newPositionMarker.on('dragend', (e)=>{ - markerPosition = {x: e.lnglat.lng, y: e.lnglat.lat} + this.markerPosition2 = {x: e.lnglat.lng, y: e.lnglat.lat} }) //点击确定 this.renderer2.listen(this.elementRef.nativeElement.querySelector('#setPositionOk'),'click',(event)=>{ this.map.clearMap(); this.isGisTopBox = true + this.isGisTopBoxTwo = false this.newPositionMarker = new AMap.Marker({ - position: [markerPosition.x,markerPosition.y], + position: [this.markerPosition2.x,this.markerPosition2.y], content: this.newPositionMarkerContent, offset: new AMap.Pixel(-15, -18) }); - this.markerPosition = markerPosition + this.markerPosition = this.markerPosition2 this.map.add(this.newPositionMarker); }) //点击取消 this.renderer2.listen(this.elementRef.nativeElement.querySelector('#setPositionClose'),'click',(event)=>{ this.isGisTopBox = true + this.isGisTopBoxTwo = false this.map.clearMap(); this.newPositionMarker = new AMap.Marker({ position: [this.markerPosition.x,this.markerPosition.y], content: this.newPositionMarkerContent, offset: new AMap.Pixel(-15, -18) }); + this.map.setCenter([this.markerPosition.x,this.markerPosition.y]); //设置地图中心点 this.map.add(this.newPositionMarker); }) }else{ - console.log('未标注单位位置') + // console.log('未标注单位位置') if(this.newPositionMarker){ this.newPositionMarker.setContent(this.oldPositionMarkerContent) } @@ -214,19 +270,20 @@ export class BasicinfoLookComponent implements OnInit { }); this.map.add(this.newPositionMarker); - let markerPosition + // let markerPosition if(this.markerPosition.x && this.markerPosition.x != 0){ - markerPosition = {x: this.markerPosition.x,y: this.markerPosition.y} + this.markerPosition2 = {x: this.markerPosition.x,y: this.markerPosition.y} }else{ - markerPosition = {x: this.map.getCenter().lng,y: this.map.getCenter().lat} //获取当前地图中心位置 + this.markerPosition2 = {x: this.map.getCenter().lng,y: this.map.getCenter().lat} //获取当前地图中心位置 } this.newPositionMarker.on('dragend', (e)=>{ - markerPosition = {x: e.lnglat.lng, y: e.lnglat.lat} + this.markerPosition2 = {x: e.lnglat.lng, y: e.lnglat.lat} }) //点击确定 this.renderer2.listen(this.elementRef.nativeElement.querySelector('#setPositionOk'),'click',(event)=>{ this.isGisTopBox = true - this.markerPosition = markerPosition + this.isGisTopBoxTwo = false + this.markerPosition = this.markerPosition2 this.map.clearMap(); this.newPositionMarker = new AMap.Marker({ position: [this.markerPosition.x,this.markerPosition.y], @@ -238,19 +295,26 @@ export class BasicinfoLookComponent implements OnInit { this.renderer2.listen(this.elementRef.nativeElement.querySelector('#setPositionClose'),'click',(event)=>{ this.map.clearMap(); this.isGisTopBox = true + this.isGisTopBoxTwo = false if(this.markerPosition.x && this.markerPosition.x != 0){//说明之前标过点 this.newPositionMarker = new AMap.Marker({ position: [this.markerPosition.x,this.markerPosition.y], content: this.newPositionMarkerContent, offset: new AMap.Pixel(-15, -18) }); + this.map.setCenter([this.markerPosition.x,this.markerPosition.y]); //设置地图中心点 this.map.add(this.newPositionMarker); } })//取消 } + + + } + + //获得所有单位类型 getallunittype() { this.http.get("/api/BuildingTypes/Simple").subscribe(data => { @@ -261,7 +325,7 @@ export class BasicinfoLookComponent implements OnInit { getorganization() { this.http.get('/api/Organizations').subscribe( (data: any) => { - this.allorganizing = data; + this.allorganizing = data this.dataSource.data = this.tree.toTree(data); let _this = this this.getunitinfo().then((e)=>{ @@ -280,7 +344,6 @@ export class BasicinfoLookComponent implements OnInit { async getunitinfo(){ let result = await new Promise((resolve, reject) => { this.http.get(`/api/Companies/${this.unitId}`).subscribe((data:any)=>{ - // console.log(111,data) if(data.buildingTypes.length){ sessionStorage.setItem('buildingTypeId',data.buildingTypes[0].id) }else{ @@ -314,7 +377,6 @@ export class BasicinfoLookComponent implements OnInit { this.selectedorganization = str.substr(1) } } - this.unitinfo = data resolve(this.unitinfo) this.selectedorganizationid = data.organizationId @@ -329,433 +391,181 @@ export class BasicinfoLookComponent implements OnInit { }) } - unitallbuilding:any = []//用于存储当前单位所有的建筑 - buildinginfoId:any = []//用于存储当前单位所有具体建筑的id - presentbuildinfoId:any // 用于存储当前单位第一个建筑的id - bigfor:any//循环(储罐信息+罐区信息)大组 - npdata:any = [] - newnpdata:any //用于存储石油化工 储罐信息/罐区情况的 datasource - - basicCategoryId:any //当前单位所有建筑中位于第一个的建筑id - deviceinfodata:any=[];//用于存储石油化工装置信息的数组 - zhuangzhiinfodatasource:any = [] //用于存储石油化工装置信息表格的数据来源 - newzhuangzhiinfodatasource:any= []//存储石油化工装置信息表格的 datasource形式 - devicedataSourcebox:any = [] //存储多个石油化工建筑的不同装置信息表格datasource - - - //数据格式化函数 将原始数据映射转化为表格需要的datasource - formatHandle(list) { - const result = [{}]; // tag 是从1开始,因此预置索引为0的项 - list.forEach((item) => { - const { tag, propertyName, propertyValue } = item; - if (result[tag] === undefined) { // 初始化对象 - result[tag] = {}; - } - const fieldMap = { // 字段映射,实现自动映射 - '罐区': 'tank', - '储罐编号': 'tankid', - '储存介质': 'tankmedium', - '储罐类型': 'tanktype', - '容量': 'tankcapacity', - '直径': 'tankdiameter', - '高度': 'tankheight', - '顶盖形式': 'tanktectum', - '浮盘材质': 'tanktexture', - '浮盘类型': 'platetype', - '泡沫产生器型号': 'foamgeneratorid', - '泡沫产生器形式': 'foamgeneratortype', - '是否设置氮封惰化保护装置': 'isprotect', - '防护堤高度': 'fendinggroyneheight', - '半固定泡沫灭火接口数量': 'portnum', - '其它设施': 'else' - }; - result[tag][fieldMap[propertyName]] = propertyValue; - }); - result.shift(); // 移除预置的 索引为0 的值 - return result; - } - - //将模板信息加工成附带自定义属性的信息 - getunithouse(data,n,x){ //data是原始模板在此基础上加工 n是当前建筑名称和建筑id、 x是当前循环的item信息 - data[0].buildingtypeId = n.id - data[0].name = x.name - data[0].username =x.name - data[0].buildtype = n.name - data[0].tongyong = true - data[0].index = x.index - if(data[0].buildtype == "石油化工类" || data[0].buildtype.indexOf("化工") != -1 ){ - data[0].tongyong = false - data[0].isshiyou = true - this.deviceinfodata = data[0].buildingBasicGroups[1].propertyInfos //存储装置信息的初始数据,需要转换成datasource形式 - var map = [] - this.deviceinfodata.forEach((item,index) => { - if(item.tag == ""){ - item.tag = "1" - } - if(!(item.tag in map)){ - map[item.tag] = [] - } - map[item.tag].push(item) - }); - let zhuangzhiinfodatasource = [] - map.forEach((item,index)=>{ - zhuangzhiinfodatasource[index] = {} - item.forEach(i => { - if (i.propertyName == "装置区名称") { - zhuangzhiinfodatasource[index].name = i.propertyValue - } - if (i.propertyName == "工艺流程") { - zhuangzhiinfodatasource[index].flow = i.propertyValue - } - if (i.propertyName == "火灾危险性") { - zhuangzhiinfodatasource[index].danger = i.propertyValue - } - if (i.propertyName == "灭火注意事项") { - zhuangzhiinfodatasource[index].payattentionto = i.propertyValue - } - }); - }) - this.newzhuangzhiinfodatasource =[] //数据去空 - zhuangzhiinfodatasource.forEach(item=>{ - if(item !== "" && item != undefined){ - this.newzhuangzhiinfodatasource.push(item) - } - }) - this.devicedataSourcebox[data[0].buildingId] = new MatTableDataSource<any>(this.newzhuangzhiinfodatasource) - data[0].newzhuangzhiinfodatasource = this.newzhuangzhiinfodatasource - - - //把bigfor分组取出来 先大循环 (储罐信息---储罐信息/罐区情况)为一组 - let noemptybigfordata = data[0].buildingBasicGroups - // if(noemptybigfordata.length > 4){ - // noemptybigfordata.forEach((item,index) => { - // if(!item.submitted && item.name !="装置信息"){ - // noemptybigfordata.splice(index, 1) - // } - // }) - // } - let bigtankgroups = noemptybigfordata.slice(2) - // console.log("bigtankgroups",bigtankgroups) - let proportion = 2; //按照比例切割 - let num = 0; - let bigfor =[]; - for(let i=0;i<bigtankgroups.length;i++){ - if(i % proportion == 0 && i != 0){ - bigfor.push(bigtankgroups.slice(num,i)); - num = i; - } - if((i+1)==bigtankgroups.length){ - bigfor.push(bigtankgroups.slice(num,(i+1))); - } - } - var map2 = [] - let tankdetailindo = [] - let noemptyArr = [] - - //bigfor决定当前储罐分组有几个 - - bigfor.forEach(item=>{ - item[1].propertyInfos.forEach(item => { - if(item.tag == ""){ - item.tag = 1 - } - }); - item[1].propertyInfos = this.formatHandle(item[1].propertyInfos) - - }) - data[0].bigfor = bigfor - } - // if(data[0].buildtype == "地铁类"){ - // data[0].tongyong = true - // // data[0].ditie = true - // } - return data[0] - } - - //点击建筑自定义信息的checkbox - isCustomData = false - checkCustomData(e){ - this.isCustomData = e.checked - } - //增加自定义信息行数 - addCustomData(item){ - item.buildingCustomData.customProperties.push({ - name: "", - value: "" + //获得建筑自定义信息 + getbuildingCustomData(){ + this.http.get("/api/BuildingCustomData",{params:{ + buildingId:this.houses[this.selectedBuildingIndex].id + }}).subscribe(data=>{ + this.buildingCustomData = data }) } - //删除自定义信息行数 - deleteCustomData(item){ - item.buildingCustomData.customProperties.pop() - } - //得到建筑信息数据并进行处理 - allBuildings:any - getunitallbuilding(){ - this.houses = [] + + //获得建筑的全部信息放到对应houses数组的建筑中 + selectedBuildingIndex:number = 0 + getBuildingInfo(){ this.unitId = this.route.snapshot.queryParams.id - this.http.get("/api/Buildings",{ + this.http.get("/api/BuildingBasicInfos",{ // 循环请求当前单位建筑每一个建筑的信息保存到数组中 params:{ - companyId:this.unitId + companyId :this.unitId, + buildingId:this.houses[this.selectedBuildingIndex].id, + buildingType:this.houses[this.selectedBuildingIndex].buildingTypes[0].id } - }).subscribe(async (data:any)=>{ // 获得当前单位所有的建筑 - this.allBuildings = data - // console.log(data) - if(data.length != 0){ - this.basicCategoryId = data[0].buildingTypes[0].id - this.presentbuildinfoId = data[0].id // 用于存储当前单位第一个建筑的id - for (let i = 0, length = data.length; i < length; i++) {//循环所有建筑 - const n = data[i]; - const index = i; - this.buildinginfoId.push(n.id) - const result = await new Promise((resolve) => { - this.http.get("/api/BuildingBasicInfos",{ // 循环请求当前单位建筑每一个建筑的信息保存到数组中 - params:{ - companyId :this.unitId, - buildingId:n.id, - buildingType:n.buildingTypes[0].id - } - }).subscribe((data)=>{ - //获得当前建筑自定义信息并且添加到item自定义属性上 - let _data = data - this.http.get("/api/BuildingCustomData",{params:{ - buildingId:n.id - }}).subscribe((data:any)=>{ - _data[0].buildingCustomData = data - if(data && data.customProperties.length != 0){ - _data[0].isCustomData = true - }else{ - _data[0].isCustomData = false - _data[0].buildingCustomData ={ - id: "", - customProperties: [ - { - name: "", - value: "" - } - ], - buildingId: _data[0].buildingId - } - } - }) - //为每个建筑添加自定义属性 - data[0].buildingtypeId = n.buildingTypes[0].id - data[0].name = n.name - data[0].username = n.name - data[0].buildtype = n.buildingTypes[0].name - data[0].tongyong = true - data[0].index = index - - if(data[0].buildtype.indexOf("储罐") != -1 || data[0].buildtype.indexOf("化工") != -1 ){ - data[0].tongyong = false - data[0].isshiyou = true - let noemptydeviceArr = data[0].buildingBasicGroups[1].propertyInfos - noemptydeviceArr.forEach((item,index) => { - if(item.tag == ""){ - noemptydeviceArr.splice(index,1) - } - }); - this.deviceinfodata = noemptydeviceArr //存储装置信息的初始数据,需要转换成datasource形式 - var map = [] - this.deviceinfodata.forEach((item,index) => { - if(!data[0].buildingBasicGroups[1].submitted){ - if(item.tag == ""){ - item.tag = "1" - } - } - - if(!(item.tag in map)){ - map[item.tag] = [] - } - map[item.tag].push(item) - }); - let zhuangzhiinfodatasource = [] - map.forEach((item,index)=>{ - zhuangzhiinfodatasource[index] = {} - item.forEach(i => { - if (i.propertyName == "装置区名称") { - zhuangzhiinfodatasource[index].name = i.propertyValue - } - if (i.propertyName == "工艺流程") { - zhuangzhiinfodatasource[index].flow = i.propertyValue - } - if (i.propertyName == "火灾危险性") { - zhuangzhiinfodatasource[index].danger = i.propertyValue - } - if (i.propertyName == "灭火注意事项") { - zhuangzhiinfodatasource[index].payattentionto = i.propertyValue - } - }); - }) - this.newzhuangzhiinfodatasource =[] //数据去空 - zhuangzhiinfodatasource.forEach(item=>{ - if(item !== "" && item != undefined){ - this.newzhuangzhiinfodatasource.push(item) - } - }) - this.devicedataSourcebox[data[0].buildingId] = new MatTableDataSource<any>(this.newzhuangzhiinfodatasource) - data[0].newzhuangzhiinfodatasource = this.newzhuangzhiinfodatasource - - //把bigfor分组取出来 先大循环 (储罐信息---储罐信息/罐区情况)为一组 - let noemptybigfordata = data[0].buildingBasicGroups - - let bigtankgroups = noemptybigfordata.slice(2) - let proportion = 2; //按照比例切割 - let num = 0; - let bigfor =[]; - for(let i=0;i<bigtankgroups.length;i++){ - if(i % proportion == 0 && i != 0){ - bigfor.push(bigtankgroups.slice(num,i)); - num = i; - } - if((i+1)==bigtankgroups.length){ - bigfor.push(bigtankgroups.slice(num,(i+1))); - } + }).subscribe((data)=>{ + // console.log('当前选择建筑的基础信息',data) + //需要处理一下表格信息 + data[0].buildingBasicGroups.forEach(element => { + //需要处理一下表格信息 + if(element.type == 1){ + let afterData = [] + let tempArr = []; + for (let i = 0; i < element.propertyInfos.length; i++) { + element.propertyInfos[i].tag == '' ? element.propertyInfos[i].tag = 1 : null + if (tempArr.indexOf(element.propertyInfos[i].tag) === -1) { + afterData.push({ + tag: element.propertyInfos[i].tag, + origin: [element.propertyInfos[i]] + }); + tempArr.push(element.propertyInfos[i].tag); + } else { + for (let j = 0; j < afterData.length; j++) { + if (afterData[j].tag == element.propertyInfos[i].tag) { + afterData[j].origin.push(element.propertyInfos[i]); + break; } - - - - //bigfor决定当前储罐分组有几个 - bigfor.forEach((item,index)=>{ - - item[1].propertyInfos = this.formatHandle(item[1].propertyInfos) - - }) - data[0].bigfor = bigfor } - resolve(data[0]) //把数据传递出去 - }) + } + } + function compare(property){ + return function(a,b){ + var value1 = a[property]; + var value2 = b[property]; + return value1 - value2; + } + } + afterData.forEach(item =>{ + item.origin = item.origin.sort(compare('order')) }) - this.houses.push(result) // 并且把他添加到 tab 总体数组中 + element.propertyInfos = afterData.sort(compare('tag')) + // console.log(afterData,888); + } + }); + let guanquIndex = data[0].buildingBasicGroups.findIndex(item => item.name.indexOf('罐区')>=0); // 找到第一个灌区的索引 + function transferFn(arr) { + const guanquIndex = arr.findIndex(item => item.name.indexOf('罐区')>=0); // 找到第一个灌区的索引 + + const guanquList = arr.slice(guanquIndex); // 灌区的列表 + const baseList = arr.slice(0, guanquIndex); // 前面的数据 + const len = guanquList.length; + const num = len/2; // 计算一共有多少对,这里的前提是数据本身必须成对出现 + // 灌区切割出来的数据,分别存放,最后做一下合并 + const array1 = []; + const array2 = []; + for(let i = 0; i<num; i++) { + array1.push(guanquList[i]); // 灌区x + array2.push(guanquList[i + num]); // 灌区x/储罐信息 + } + // 拼接最后的数据 + const result = [...baseList]; + for(let i = 0, ll = array1.length; i < ll; i++){ + result.push(array1[i]); + if (array2[i]) { + result.push(array2[i]); + } } + return result; } - // console.log(666,this.houses) + if(guanquIndex != -1 && data[0].buildingBasicGroups[guanquIndex + 1].name.indexOf(data[0].buildingBasicGroups[guanquIndex].name) == -1){ + data[0].buildingBasicGroups = transferFn(data[0].buildingBasicGroups) + } + this.houses[this.selectedBuildingIndex].data = data + //获得自定义信息 + this.http.get("/api/BuildingCustomData",{params:{ //-----处理建筑自定义属性部分 + buildingId:this.houses[this.selectedBuildingIndex].id + }}).subscribe((data:any)=>{ + if(data && data.customProperties.length != 0){ + this.houses[this.selectedBuildingIndex].customData = data + this.houses[this.selectedBuildingIndex].isCustomData = true + }else{ + this.houses[this.selectedBuildingIndex].isCustomData = false + this.houses[this.selectedBuildingIndex].customData = { + id: "", + customProperties: [{name:'',value:''}], + buildingId: this.houses[this.selectedBuildingIndex].id + } + } + }) }) - } - - unitinfotemplate:any //存储选择不同单位类型时的模板信息 - displayedColumns: string[]=['name', 'flow','danger','payattentionto']; - displayedColumns2: string[]=['tank','tankid', 'tankmedium','tanktype','tankcapacity','tankdiameter', 'tankheight','tanktectum','tanktexture','platetype', 'foamgeneratorid','foamgeneratortype','isprotect','fendinggroyneheight', 'portnum','else']; - devicedataSource:any; //存储石油化工模板中的装置信息表格 - tankinfodatabox:any = [ - [] - ] - // dataSourceArr = [] - tankinfodata:any=[];//用于存储石油化工储罐信息的数组 - adddeviceinfo2(e,item){//点击加一行 视图上多一行 - item.bigfor[e][1].propertyInfos.push({ - tank:"", - tankid:"", - tankmedium:"", - tanktype:"", - tankcapacity:"", - tankdiameter:"", - tankheight:"", - tanktectum:"", - tanktexture:"", - platetype:"", - foamgeneratorid:"", - foamgeneratortype:"", - isprotect:"", - fendinggroyneheight:"", - portnum:"", - else:"" - }) - item.bigfor[e][1].propertyInfos = [...item.bigfor[e][1].propertyInfos] + //点击选项卡 + selectedTabChange(e){ + // console.log(e) + this.selectedBuildingIndex = e.index + if((this.houses[this.selectedBuildingIndex].data && !this.houses[this.selectedBuildingIndex].data.length) || !this.houses[this.selectedBuildingIndex].data){ + this.getBuildingInfo() + } } - removedeviceinfo3(e,item){//点击减一行 - var isdeleted = confirm("确定要删除末行吗?") - if(isdeleted){ - if(item.bigfor[e][1].propertyInfos.length > 1){ - item.bigfor[e][1].propertyInfos.pop() - }else{ - const config = new MatSnackBarConfig(); - config.verticalPosition = 'top'; - config.duration = 3000 - this.snackBar.open('只剩一行,无法删除','确定',config); - } - item.bigfor[e][1].propertyInfos = [...item.bigfor[e][1].propertyInfos] + //表格加一行 + addline(ele){ + let newObj = JSON.parse(JSON.stringify(ele[0])) + for (let index = 0; index < newObj.origin.length; index++) { + const element = newObj.origin[index]; + element.propertyValue = "" + element.tag = Number(ele[ele.length - 1].tag) + 1 } - + newObj.tag = Number(ele[ele.length - 1].tag) + 1 + ele.push(newObj) } - - - //增加储罐大分组 - //在石油化工模板种点击增加储罐信息 - //获得模板信息 - templateinfo:any - gettemplateinfo(typeid){ - + //表格减一行 + removeline(ele){ + if(ele.length>1){ + ele.pop() + }else{ + const config = new MatSnackBarConfig(); + config.verticalPosition = 'top'; + config.duration = 3000 + this.snackBar.open('只剩一行,无法删除','确定',config); + } } - - addtankbox(item,bigkey){ - this.http.get("/api/CompanyAccount/BasicInfos",{ - params:{ - companyId : this.unitId, - buildingType:item.buildingtypeId - } - }).subscribe((data:any)=>{ - // console.log(1314,data) - // console.log(777,data[0]) - item.bigfor.push([ - { - id: "", - name: "罐区"+ (item.bigfor.length+ 1), - type: 0, - addMode: 2, - basicGroupId:'', - basicCategoryId: item.basicCategoryId, - buildingBasicId: null, - buildingId: item.buildingId, - companyId: this.unitinfo.id, - enabled: true, - order: item.bigfor.length+2, - propertyInfos:data[0].buildingBasicGroups[2].propertyInfos - }, - { - addMode: 2, - basicCategoryId:item.basicCategoryId, - buildingBasicId:null, - buildingId: item.buildingId, - companyId: this.unitinfo.id, - enabled: true, - basicGroupId:'', - id: "", - name: "罐区" + (item.bigfor.length+ 1) +"/储罐信息", - order: item.bigfor.length+3, - propertyInfos: [ - { - else: "", - fendinggroyneheight: "", - foamgeneratorid: "", - foamgeneratortype: "", - isprotect: "", - platetype: "", - portnum: "", - tank: "", - tankcapacity: "", - tankdiameter: "", - tankheight: "", - tankid: "", - tankmedium: "", - tanktectum: "", - tanktexture: "", - tanktype: "" - } - ], - type: 1 - } - - ]) + //建筑自定义信息加一行 + addCustomData(item){ + item.customData.customProperties.push({ + name:'', + value:'' }) - } - //移除储罐大分组 - removetankbox(item,bigkey){ - if(item.bigfor.length > 1){ + //建筑自定义信息减一行 + popCustomData(item){ + item.customData.customProperties.pop() + } + //储罐加一组 + addTankBox(item,groupsIndex){ + //取出现在最后一个罐区的数字 + let num = (item.data[0].buildingBasicGroups[item.data[0].buildingBasicGroups.length - 1].name).replace(/[^0-9]/ig,"") + let obj1 = JSON.parse(JSON.stringify(item.data[0].buildingBasicGroups[groupsIndex])) + let obj2 = JSON.parse(JSON.stringify(item.data[0].buildingBasicGroups[groupsIndex + 1])) + obj1.name = '罐区' + (Number(num) + 1) + obj2.name = '罐区' + (Number(num) + 1) + '/储罐信息' + // console.log(obj2) + obj1.propertyInfos.forEach(element => { + element.propertyValue = '' + }); + let newArr = [obj2.propertyInfos[0]] + obj2.propertyInfos = newArr + obj2.propertyInfos[0].origin.forEach(element => { + element.propertyValue = '' + }); + item.data[0].buildingBasicGroups.push(obj1) + item.data[0].buildingBasicGroups.push(obj2) + // console.log(item.data[0].buildingBasicGroups) + } + //储罐减一组 + removeTankBox(item,groupsIndex){ + let num = (item.data[0].buildingBasicGroups[item.data[0].buildingBasicGroups.length - 1].name).replace(/[^0-9]/ig,"") + if(num != 1){ var isdeleted = confirm("确定要删除末尾储罐分组吗?") if(isdeleted){ - item.bigfor.pop() + item.data[0].buildingBasicGroups.pop() + item.data[0].buildingBasicGroups.pop() } }else{ const config = new MatSnackBarConfig(); @@ -764,135 +574,6 @@ export class BasicinfoLookComponent implements OnInit { this.snackBar.open('只剩唯一储罐,无法删除','确定',config); } } - - //新建建筑时把原始建筑数据放进来进行加工处理成可用数据 - async changebuildingdata(data){ - let n = data - let yyy - let result = await new Promise(resolve=>{ - this.http.get("/api/BuildingBasicInfos",{ // 需要请求建筑信息的模板 - params:{ - companyId : this.unitId, - buildingId:data.id, - buildingType:data.buildingTypes[0].id - } - }).subscribe((data)=>{//此时的data才是模板详细信息 - let _data = data - this.http.get("/api/BuildingCustomData",{params:{ //-----处理建筑自定义属性部分 - buildingId:n.id - }}).subscribe(data=>{ - if(data){ - _data[0].isCustomData = true //如果data存在则把自定义属性isCustomData设为true - _data[0].buildingCustomData = data //把建筑自定义信息赋给buildingCustomData自定义属性 - }else{ - _data[0].isCustomData = false - _data[0].buildingCustomData ={ //否则设为false,并且把自定义信息属性赋值为空 - id: "", - customProperties: [ - { - name: "", - value: "" - } - ], - buildingId: _data[0].buildingId - } - } - }) - data[0].buildingtypeId = n.buildingTypes[0].id - data[0].buildtype = n.buildingTypes[0].name - data[0].name = n.name - data[0].username = n.name - data[0].tongyong = true - data[0].index = this.houses.length ////////////////// - if(data[0].buildtype.indexOf("储罐") != -1 || data[0].buildtype.indexOf("化工") != -1 ){ - data[0].tongyong = false - data[0].isshiyou = true //如果是石油化工则启用石油化工的模板 - this.deviceinfodata = data[0].buildingBasicGroups[1].propertyInfos //存储装置信息表格的初始数据,需要转换成datasource形式 - var map = [] - this.deviceinfodata.forEach((item,index) => { - if(item.tag == ""){ - item.tag = "1" - } - if(!(item.tag in map)){ - map[item.tag] = [] - } - map[item.tag].push(item) - }); - let zhuangzhiinfodatasource = [] - map.forEach((item,index)=>{ - zhuangzhiinfodatasource[index] = {} - item.forEach(i => { - if (i.propertyName == "装置区名称") { - zhuangzhiinfodatasource[index].name = i.propertyValue - } - if (i.propertyName == "工艺流程") { - zhuangzhiinfodatasource[index].flow = i.propertyValue - } - if (i.propertyName == "火灾危险性") { - zhuangzhiinfodatasource[index].danger = i.propertyValue - } - if (i.propertyName == "灭火注意事项") { - zhuangzhiinfodatasource[index].payattentionto = i.propertyValue - } - }); - }) - this.newzhuangzhiinfodatasource =[] //数据去空 - zhuangzhiinfodatasource.forEach(item=>{ - if(item !== "" && item != undefined){ - this.newzhuangzhiinfodatasource.push(item) - } - }) - this.devicedataSourcebox[data[0].buildingId] = new MatTableDataSource<any>(this.newzhuangzhiinfodatasource) //强制渲染表格 - data[0].newzhuangzhiinfodatasource = this.newzhuangzhiinfodatasource - - - //把bigfor分组取出来 先大循环 (储罐信息---储罐信息/罐区情况)为一组 - let bigtankgroups = data[0].buildingBasicGroups.slice(2) - let proportion = 2; //按照比例切割 - let num = 0; - let bigfor =[]; - for(let i=0;i<bigtankgroups.length;i++){ - if(i % proportion == 0 && i != 0){ - bigfor.push(bigtankgroups.slice(num,i)); - num = i; - } - if((i+1)==bigtankgroups.length){ - bigfor.push(bigtankgroups.slice(num,(i+1))); - } - } - var map2 = [] - let tankdetailindo = [] - let noemptyArr = [] - - //bigfor决定当前储罐分组有几个 - - bigfor.forEach(item=>{ - item[1].propertyInfos.forEach(item => { - if(item.tag == ""){ - item.tag = 1 - } - }); - item[1].propertyInfos = this.formatHandle(item[1].propertyInfos) - }) - data[0].bigfor = bigfor - } - if(data[0].buildtype == "地铁类"){ - data[0].tongyong = true - // data[0].ditie = true - } - yyy = data[0] - resolve(yyy) - }) - }) - return result - } - - - - //点击不同的tab选项 - selecttab(e) { - } - FunData(e){//切割数组 let proportion = 2; //按照比例切割 let num = 0; @@ -912,7 +593,6 @@ export class BasicinfoLookComponent implements OnInit { //点击辖区中队树,将选择的辖区中队添加到变量 add(node) { - // console.log(node) this.selectedorganizationid = node.id this.isorganizationbox = false @@ -937,13 +617,11 @@ export class BasicinfoLookComponent implements OnInit { this.selectedorganization = str.substr(1) } -} - + } //关闭辖区中队隐藏框 closeorganizationbox() { this.isorganizationbox = false } - //打开辖区中队隐藏框 openorganizationbox() { this.isorganizationbox = true @@ -951,8 +629,8 @@ export class BasicinfoLookComponent implements OnInit { hasChild = (_: number, node: any) => node.expandable; - // imgsrc = "../../../assets/upload.jpg" //没有上传图片时显示的图片,当上传后就会被替换,即保存时需要传的图片地址参数 - imgsrc = "" + imgsrc = "" //没有上传图片时显示的图片,当上传后就会被替换,即保存时需要传的图片地址参数 + noImg = '../../../assets/images/upload.jpg' imgUrl = ""//返回来的图片地址后缀 file: any; //上传的文件 objectName: any; //上传对象名 @@ -979,7 +657,7 @@ export class BasicinfoLookComponent implements OnInit { this.startUploading() } } - + }, 500); } //查看单位大图 @@ -990,7 +668,7 @@ export class BasicinfoLookComponent implements OnInit { data: {img:this.imgsrc} }); dialogRef.afterClosed().subscribe( - + ); } //上传文件 @@ -1024,10 +702,7 @@ export class BasicinfoLookComponent implements OnInit { } } - - - - //小于5MB不需要分块上传 + //小于5MB不需要分块上传 upload(){ this.uploader.queue[0].upload();//开始上传 this.uploader.queue[0].onSuccess = (response, status, headers) => { @@ -1055,7 +730,7 @@ export class BasicinfoLookComponent implements OnInit { } }; } - + //开始分块上传 async subsectionUploading () { let file = this.file || null //获取上传的文件 @@ -1098,17 +773,22 @@ export class BasicinfoLookComponent implements OnInit { }) } //删除具体建筑 - deletedbuilding(item){ + selectedIndex + deletedbuilding(item,key){ + // console.log(item) var isdeleted = confirm("确定要删除此建筑吗?") if(isdeleted){ - //请求删除接口 - this.http.delete(`/api/Buildings/${item.buildingId}`).subscribe(data=>{ - + // console.log(key) + // 请求删除接口 + this.http.delete(`/api/Buildings/${item.id}`).subscribe(data=>{ const config = new MatSnackBarConfig(); config.verticalPosition = 'top'; config.duration = 3000 this.snackBar.open('删除成功','确定',config); this.houses.splice(this.houses.findIndex(items=>items==item),1) + + let obj ={index:key} + this.selectedTabChange(obj) }) } } @@ -1131,10 +811,7 @@ export class BasicinfoLookComponent implements OnInit { phone: value.linkphone, address: value.unitaddress, imageUrl: this.imgsrc, - location: { - x: 0, - y: 0 - }, + location: this.markerPosition, modifiedTime: time, organizationId: this.selectedorganizationid, organizationName: null, @@ -1145,45 +822,45 @@ export class BasicinfoLookComponent implements OnInit { } ] } - this.http.put(`/api/Companies/${this.unitId}`,body).subscribe((data:any)=>{ //修改单位基本信息 - this.getunitinfo() - if(!this.houses.length){ - const config = new MatSnackBarConfig(); - config.verticalPosition = 'top'; - config.duration = 3000 - this.snackBar.open('单位基本信息保存成功,请填写单位建筑模板信息','确定',config); - // alert("单位基本信息保存成功,请填写单位建筑模板信息") - let order = 0 - let addbody = { //请求创建单位基本信息成功后 直接创建出一个主体建筑模板 - id: "",//即将要生成具体建筑的id - name: "主体建筑", - order: order, - enabled: true, - companyId: this.unitinfo.id, - buildingTypes: [ - { - id: value.unittype, - name: "" - } - ] + this.http.put(`/api/Companies/${this.unitId}`,body).subscribe((data:any)=>{ //修改单位基本信息 + // this.getunitinfo() + if(!this.houses.length){ + const config = new MatSnackBarConfig(); + config.verticalPosition = 'top'; + config.duration = 3000 + this.snackBar.open('单位基本信息保存成功,请填写单位建筑模板信息','确定',config); + // alert("单位基本信息保存成功,请填写单位建筑模板信息") + let addbody = { //请求创建单位基本信息成功后 直接创建出一个主体建筑模板 + id: "",//即将要生成具体建筑的id + name: "主体建筑", + order: 0, + enabled: true, + companyId: this.unitinfo.id, + buildingTypes: [ + { + id: value.unittype, + name: "" + } + ] + } + this.http.post("/api/Buildings",addbody).subscribe(data=>{//首先创建建筑成功了,需要刷出当前建筑类型的模板 + // alert('创建主体建筑成功') + this.getUnitAllBuildings() + }) + }else{ + const config = new MatSnackBarConfig(); + config.verticalPosition = 'top'; + config.duration = 3000 + this.snackBar.open('保存成功','确定',config); + } + }), + err=>{ + const config = new MatSnackBarConfig(); + config.verticalPosition = 'top'; + config.duration = 3000 + this.snackBar.open('请填写正确信息','确定',config); } - this.http.post("/api/Buildings",addbody).subscribe(data=>{//首先创建建筑成功了,需要刷出当前建筑类型的模板 - this.getunitallbuilding() - }) - }else{ - const config = new MatSnackBarConfig(); - config.verticalPosition = 'top'; - config.duration = 3000 - this.snackBar.open('保存成功','确定',config); - } - }), - err=>{ - const config = new MatSnackBarConfig(); - config.verticalPosition = 'top'; - config.duration = 3000 - this.snackBar.open('请填写正确信息','确定',config); } - } } @@ -1192,8 +869,6 @@ export class BasicinfoLookComponent implements OnInit { isshowrule:boolean = false rulevalue:any inputchange(e,name,value,item){ - // console.log(e.target.value,name,value,item) - // console.log(item) if(name == "≥"){ if(Number(e.target.value)< Number(value)){ item.isshowrule = true @@ -1221,923 +896,217 @@ export class BasicinfoLookComponent implements OnInit { } } } + + //可选按钮 + checkboxChange(item,$event,buildingData){ + // console.log(item) + if(item.name == '罐区1'){ + // console.log(buildingData) + buildingData.data[0].buildingBasicGroups.forEach(element => { + if(element.name.indexOf('罐区') != -1){ + element.submitted = item.submitted + } + }); + } + } + + //建筑自定义信息按钮 + checkCustomData($event){ + + } + - //切换建筑类型 - templatebuildtype(n ,item,key){ - this.http.get("/api/Buildings",{ - params:{ - companyId:this.unitId - } - }).subscribe((data:any)=>{ - this.allBuildings = data - this.http.put(`/api/Buildings/${item.buildingId}`,{ //修改当前建筑类型 - id: item.buildingId, - name: item.housename, - order: this.allBuildings[key].order, + //提交建筑信息 + onSubmitBuildingInfo(value,item,key,invalid){ + // console.log(1,item) + // console.log(2,invalid) + // console.log(3,value) + // console.log(4,this.allunittype) + if(invalid){ + const config = new MatSnackBarConfig(); + config.verticalPosition = 'top'; + config.duration = 3000 + this.snackBar.open('请填写必填项','确定',config); + }else { + //先把名称和建筑类型单独修改 + let buildingTypeId + this.allunittype.forEach(element => { + element.name == item.buildingTypes[0].name ? buildingTypeId = element.id : null + }); + this.http.put(`/api/Buildings/${item.id}`,{ //(通用)只修改建筑名称和建筑类型 + id: item.id, + name: value.buildingName, + order: this.houses[key].order, enabled: true, companyId: this.unitinfo.id, buildingTypes: [ { - id: n.id, - name: n.name - } - ] - }).subscribe(data=>{ - this.http.get("/api/BuildingBasicInfos",{//请求当前建筑类型的模板信息保存到数组中 - params:{ - companyId :this.unitId, - buildingId:item.buildingId, - buildingType:n.id + id: buildingTypeId, + name: item.buildingTypes[0].name } - }).subscribe(data=>{ - this.getunithouse(data,n,item) - this.houses[item.index] = data[0] - - let _data = data - this.http.get("/api/BuildingCustomData",{params:{ - buildingId:item.buildingId - }}).subscribe((data:any)=>{ - _data[0].buildingCustomData = data - if(data && data.customProperties.length != 0){ - _data[0].isCustomData = true - }else{ - _data[0].isCustomData = false - _data[0].buildingCustomData ={ - id: "", - customProperties: [ - { - name: "", - value: "" - } - ], - buildingId: _data[0].buildingId - } - } - }) - }) + ] + },{ + params:{ + companyId : this.unitId + } + }).subscribe((data:any)=>{ + // alert("名称和类型保存成功") + }, + err=>{ + alert("名称和类型保存失败") }) - }) - - } - - deviceinfo=[] //用于存储石头化工的第一个表格 - //提交单位模板信息 - onSubmit2(value,item,key,invalid){ - this.http.get("/api/Buildings",{ - params:{ - companyId:this.unitId - } - }).subscribe((data:any)=>{ - this.allBuildings = data - if(invalid){ - const config = new MatSnackBarConfig(); - config.verticalPosition = 'top'; - config.duration = 3000 - this.snackBar.open('请填写必填项','确定',config); - }else{ - this.http.put(`/api/Buildings/${item.buildingId}`,{ //(通用)只修改建筑名称和建筑类型 - id: item.buildingId, - name: value.housename, - order: this.allBuildings[key].order, - enabled: true, - companyId: this.unitinfo.id, - buildingTypes: [ - { - id: item.buildingtypeId, - name: item.buildtype - } - ] - }).subscribe((data:any)=>{ - this.houses[item.index].username = item.name - }, - err=>{ - alert("名称和类型保存失败") - }) - - if(value.checkbuilding){//如果勾选了自定义信息的checkbox - var CustomDataval = [] - for (const key in value) { - if (key.indexOf("CustomData") != -1) { - CustomDataval.push(value[key]) - } + let newbody = JSON.parse(JSON.stringify(item.data)) //把数据深拷贝取出来进行操作 + for (let index = 0; index < newbody[0].buildingBasicGroups.length; index++) { + let element = newbody[0].buildingBasicGroups[index]; + element.propertyInfos.forEach(item => { + if(!element.isOptional){ + item.propertyValue ? element.submitted = true : null } - let newCustomData = this.FunData(CustomDataval) - let newCustomDataval = [] - newCustomData.forEach(n=>{ - newCustomDataval.push({ - name:n[0], - value:n[1] - }) - }) - let CustomDatabody = { - id: "", - customProperties: newCustomDataval, - buildingId: item.buildingId + //删除规则验证标识 + item.isshowrule ? delete item.isshowrule : null + item.rulevalue ? delete item.rulevalue : null + if(item.propertyValue || item.propertyValue == 0){ + item.propertyValue = String(item.propertyValue) } - this.http.post("/api/BuildingCustomData",CustomDatabody,{params:{ - buildingId:item.buildingId - }}).subscribe(data=>{ + }); + //如果是表格需要转换为一维数组 + if(element.type == 1){ + let arr = [] + for (let index = 0; index < element.propertyInfos.length; index++) { + const ele = element.propertyInfos[index]; - }, - err=>{ - alert("自定义信息保存失败") - }) - }else{ - let CustomDatabody = { - id: "", - customProperties: [], - buildingId: item.buildingId + for (let index = 0; index < ele.origin.length; index++) { + const i = ele.origin[index]; + i.tag = String(i.tag) + + if(!element.isOptional){ + i.propertyValue ? element.submitted = true : null + } + arr.push(i) + } } - this.http.post("/api/BuildingCustomData",CustomDatabody,{params:{ - buildingId:item.buildingId - }}).subscribe(data=>{ - - }, - err=>{ - alert("自定义信息保存失败") + for (let index = 0; index < arr.length; index++) { + const i = arr[index]; + i.order = index + } + element.propertyInfos = arr + } + //如果当前分组没勾选 则需先去重然后重置每一个value为空 + if(!element.submitted){ + const res = new Map(); + element.propertyInfos = element.propertyInfos.filter((a) => !res.has(a.propertyName) && res.set(a.propertyName, 1)) + element.propertyInfos.forEach(ele => { + ele.propertyValue = "" }) } - - - if(item.buildtype.indexOf("储罐") == -1 && item.buildtype != "地铁类" && item.buildtype.indexOf("化工") == -1 ){ - // console.log(this.houses[key]) - // console.log(value) - this.houses[key].buildingBasicGroups[0].propertyInfos.forEach(item => { - - if(item.propertyValue || item.propertyValue == 0){ - // item.propertyValue = "" + value[key] - item.propertyValue = String(item.propertyValue) - } - - }); - let newObj = _.cloneDeep(this.houses[key]) //把数据深拷贝取出来进行操作 - newObj.buildingBasicGroups[0].buildingId = item.buildingId - newObj.buildingBasicGroups[0].companyId = this.unitinfo.id - newObj.buildingBasicGroups[0].submitted = true //把是否提交过变为true - delete newObj.name - delete newObj.username - delete newObj.buildtype - delete newObj.tongyong - delete newObj.index - delete newObj.isCustomData - delete newObj.buildingCustomData - newObj.buildingBasicGroups[0].propertyInfos.forEach(item => { - delete item.isshowrule - delete item.rulevalue - }); - - let body = newObj - let newbody = [] - newbody.push(body) - if(newbody[0].buildingBasicGroups.length){ - this.http.post("/api/BuildingBasicInfos",newbody,{ - params:{ - companyId : this.unitId, - buildingId :newbody[0].buildingId - } - }).subscribe((data:any)=>{ - this.houses[key].id = data[0].id - const config = new MatSnackBarConfig(); - config.verticalPosition = 'top'; - config.duration = 3000 - this.snackBar.open('建筑信息保存成功','确定',config); - }, - err=>{ - const config = new MatSnackBarConfig(); - config.verticalPosition = 'top'; - config.duration = 3000 - this.snackBar.open('请检查输入数据是否有误','确定',config); - }) - } + //如果灌区没勾选 并且包含罐区且不包含罐区1的清除 需要把多余罐区2 3 4清除掉再提交 + if(!element.submitted && element.name.indexOf('罐区1') == -1 && element.name.indexOf('罐区') != -1){ + newbody[0].buildingBasicGroups.splice(index--, 1); } - if(item.buildtype.indexOf("储罐") != -1 || item.buildtype.indexOf("化工") != -1 ){ - // console.log(888,item) - let bodyObj = _.cloneDeep(item) - delete bodyObj.name - delete bodyObj.username - delete bodyObj.isshiyou - delete bodyObj.newzhuangzhiinfodatasource - delete bodyObj.tongyong - delete bodyObj.buildtype - delete bodyObj.buildingtypeId - delete bodyObj.bigfor - delete bodyObj.index - delete bodyObj.isCustomData - delete bodyObj.buildingCustomData - // console.log(456,bodyObj) - bodyObj.buildingBasicGroups[0].propertyInfos.forEach(item => { - delete item.isshowrule - delete item.rulevalue - }); - //修改基本信息 - bodyObj.buildingBasicGroups[0].propertyInfos.forEach(item => { - for (const key in value) { - if (item.propertyName == key) { - if(item.propertyValue || item.propertyValue == 0){ - // item.propertyValue = "" + value[key] - item.propertyValue = String(value[key]) - } - - } - } - }); - bodyObj.buildingBasicGroups[0].submitted = true - bodyObj.buildingBasicGroups[0].buildingId = item.buildingId - bodyObj.buildingBasicGroups[0].companyId = this.unitinfo.id - //石油化工类的 装置信息 就提交这个表单——————————————————————————————this.deviceinfo 记得清空 - // console.log(this.deviceinfodata) - if(bodyObj.buildingBasicGroups[1].submitted){ //如果用户点击了并填写了装置信息就提交这个表格数据 - this.deviceinfo = [] - item.newzhuangzhiinfodatasource.forEach((element,index) => { - this.deviceinfo.push({ - propertyName: "装置区名称", - propertyValue: element.name, - propertyType: 0, - required: true, - ruleName: "", - ruleValue: "", - physicalUnit: "", - order:0, - enabled: true, - visible: true, - tag: String(index + 1) - }, - { - propertyName: "工艺流程", - propertyValue: element.flow, - propertyType: 0, - required: true, - ruleName: "", - ruleValue: "", - physicalUnit: "", - order:1, - enabled: true, - visible: true, - tag: String(index + 1) - }, - { - propertyName: "火灾危险性", - propertyValue: element.danger, - propertyType: 0, - required: true, - ruleName: "", - ruleValue: "", - physicalUnit: "", - order:2, - enabled: true, - visible: true, - tag: String(index + 1) - }, - { - propertyName: "灭火注意事项", - propertyValue: element.payattentionto, - propertyType: 1, - required: false, - ruleName: "", - ruleValue: "", - physicalUnit: "", - order:3, - enabled: true, - visible: true, - tag: String(index + 1) - }) - }); - }else{//否则就传一个空的 - this.deviceinfo = [ - { - propertyName: "装置区名称", - propertyValue: "", - propertyType: 0, - required: true, - ruleName: "", - ruleValue: "", - physicalUnit: "", - order: 0, - enabled: true, - visible: true, - tag: "1" - }, - { - propertyName: "工艺流程", - propertyValue: "", - propertyType: 0, - required: true, - ruleName: "", - ruleValue: "", - physicalUnit: "", - order: 0, - enabled: true, - visible: true, - tag: "1" - }, - { - propertyName: "火灾危险性", - propertyValue: "", - propertyType: 0, - required: true, - ruleName: "", - ruleValue: "", - physicalUnit: "", - order: 0, - enabled: true, - visible: true, - tag: "1" - }, - { - propertyName: "灭火注意事项", - propertyValue: "", - propertyType: 1, - required: false, - ruleName: "", - ruleValue: "", - physicalUnit: "", - order: 0, - enabled: true, - visible: true, - tag: "1" - } - ] - } - bodyObj.buildingBasicGroups[1].propertyInfos = this.deviceinfo - bodyObj.buildingBasicGroups[1].buildingId = item.buildingId - bodyObj.buildingBasicGroups[1].companyId = this.unitinfo.id - - - if(bodyObj.buildingBasicGroups[2].submitted){ //如果勾选了储罐信息 则直接提交当前bodyObj - var map = {}; //用于存储石油化工要提交的储罐信息表单 - for (let key in value) { - if (key.indexOf('tanker') != -1) { - const list = key.split('-'); // 2,tanker,1 - const orderKey = list[0]; // 2 or 3 - if (!(orderKey in map)) { - map[orderKey] = []; // map[2] or map[3] = []; - } - map[orderKey][list[2]] = value[key]; // map[2][1] = xxxxx - } - } - - bodyObj.buildingBasicGroups.splice( 2 , bodyObj.buildingBasicGroups.length) - - // console.log(123, item) - - let basictankinfobody:any = {} - - for(let key in map){//------------------------------------------------------------石油化工 储罐信息 - - - basictankinfobody = { - id: null, - name: "罐区" + (Number(key)-1), - type: 0, - addMode: 2, - basicGroupId:'', - submitted:true, - isOptional:true, - order: Number(key), - enabled: true, - propertyInfos: item.bigfor[Number(key)-2][0].propertyInfos, - basicCategoryId: item.basicCategoryId, - buildingBasicId: null, - buildingId: item.buildingId,//当前建筑id - companyId: this.unitinfo.id//当前企业id - } - - bodyObj.buildingBasicGroups.push(basictankinfobody) - } - - - let basictankchildinfobody:any = []//-------------后续储罐信息以及储罐信息/罐区情况都push到这个数组中 - item.bigfor.forEach(item => { - basictankchildinfobody.push(item[1].propertyInfos) - }); - var _item = item - basictankchildinfobody.forEach((item,index) => { - let tankfieldArr = [] - item.forEach((element,key) => { - tankfieldArr.push( - { - propertyName: "罐区", - propertyValue: element.tank, - propertyType: 0, - required: false, - ruleName: "", - ruleValue: "", - physicalUnit: "", - order: 0, - enabled: true, - visible: true, - tag:String(key + 1) - }, - { - propertyName: "储罐编号", - propertyValue: element.tankid, - propertyType: 0, - required: true, - ruleName: "", - ruleValue: "", - physicalUnit: "", - order: 0, - enabled: true, - visible: true, - tag:String(key + 1) - }, - { - propertyName: "储存介质", - propertyValue: element.tankmedium, - propertyType: 0, - required: true, - ruleName: "", - ruleValue: "", - physicalUnit: "", - order: 0, - enabled: true, - visible: true, - tag:String(key + 1) - }, - { - propertyName: "储罐类型", - propertyValue: element.tanktype, - propertyType: 0, - required: true, - ruleName: "", - ruleValue: "", - physicalUnit: "", - order: 0, - enabled: true, - visible: true, - tag:String(key + 1) - }, - { - propertyName: "容量", - propertyValue: element.tankcapacity, - propertyType: 2, - required: true, - ruleName: "", - ruleValue: "", - physicalUnit: "㎡", - order: 0, - enabled: true, - visible: true, - tag:String(key + 1) - }, - { - propertyName: "直径", - propertyValue:element.tankdiameter, - propertyType: 2, - required: true, - ruleName: "", - ruleValue: "", - physicalUnit: "m", - order: 0, - enabled: true, - visible: true, - tag:String(key + 1) - }, - { - propertyName: "高度", - propertyValue: element.tankheight, - propertyType: 2, - required: true, - ruleName: "", - ruleValue: "", - physicalUnit: "m", - order: 0, - enabled: true, - visible: true, - tag:String(key + 1) - }, - { - propertyName: "顶盖形式", - propertyValue: element.tanktectum, - propertyType: 0, - required: false, - ruleName: "", - ruleValue: "", - physicalUnit: "", - order: 0, - enabled: true, - visible: true, - tag:String(key + 1) - }, - { - propertyName: "浮盘材质", - propertyValue: element.tanktexture, - propertyType: 0, - required: false, - ruleName: "", - ruleValue: "", - physicalUnit: "", - order: 0, - enabled: true, - visible: true, - tag:String(key + 1) - }, - { - propertyName: "浮盘类型", - propertyValue: element.platetype, - propertyType: 0, - required: false, - ruleName: "", - ruleValue: "", - physicalUnit: "", - order: 0, - enabled: true, - visible: true, - tag:String(key + 1) - }, - { - propertyName: "泡沫产生器型号", - propertyValue: element.foamgeneratorid, - propertyType: 0, - required: false, - ruleName: "", - ruleValue: "", - physicalUnit: "", - order: 0, - enabled: true, - visible: true, - tag:String(key + 1) - }, - { - propertyName: "泡沫产生器形式", - propertyValue: element.foamgeneratortype, - propertyType: 0, - required: false, - ruleName: "", - ruleValue: "", - physicalUnit: "", - order: 0, - enabled: true, - visible: true, - tag:String(key + 1) - }, - { - propertyName: "是否设置氮封惰化保护装置", - propertyValue: element.isprotect, - propertyType: 0, - required: false, - ruleName: "", - ruleValue: "", - physicalUnit: "", - order: 0, - enabled: true, - visible: true, - tag:String(key + 1) - }, - { - propertyName: "防护堤高度", - propertyValue: element.fendinggroyneheight, - propertyType: 2, - required: true, - ruleName: "", - ruleValue: "", - physicalUnit: "m", - order: 0, - enabled: true, - visible: true, - tag:String(key + 1) - }, - { - propertyName: "半固定泡沫灭火接口数量", - propertyValue: element.portnum, - propertyType: 2, - required: false, - ruleName: "", - ruleValue: "", - physicalUnit: "个", - order: 0, - enabled: true, - visible: true, - tag:String(key + 1) - }, - { - propertyName: "其它设施", - propertyValue: element.else, - propertyType: 0, - required: false, - ruleName: "", - ruleValue: "", - physicalUnit: "", - order: 0, - enabled: true, - visible: true, - tag:String(key + 1) - } - ) - }); - basictankchildinfobody={// - id: null, - name: "罐区" + Number(index+1) + "/储罐信息", - type: 1, - addMode: 2, - basicGroupId:'', - order: Number(index + 2), - enabled: true, - submitted:true, - isOptional:true, - propertyInfos: tankfieldArr, - basicCategoryId: _item.basicCategoryId, - buildingBasicId: null, - buildingId: _item.buildingId, - companyId: this.unitinfo.id - } - bodyObj.buildingBasicGroups.push(basictankchildinfobody) - }); - }else{ - - - bodyObj.buildingBasicGroups[2].buildingId = item.buildingId - bodyObj.buildingBasicGroups[2].companyId = this.unitinfo.id - bodyObj.buildingBasicGroups[2].propertyInfos.forEach(item=>{ - item.propertyValue = "" - }) - bodyObj.buildingBasicGroups[3].buildingId = item.buildingId - bodyObj.buildingBasicGroups[3].companyId = this.unitinfo.id - bodyObj.buildingBasicGroups[3].propertyInfos = [ - { - propertyName: "罐区", - propertyValue: "", - propertyType: 0, - required: false, - ruleName: "", - ruleValue: "", - physicalUnit: "", - order: 0, - enabled: true, - visible: true, - tag:"1" - }, - { - propertyName: "储罐编号", - propertyValue: "", - propertyType: 0, - required: true, - ruleName: "", - ruleValue: "", - physicalUnit: "", - order: 0, - enabled: true, - visible: true, - tag:"1" - }, - { - propertyName: "储存介质", - propertyValue: "", - propertyType: 0, - required: true, - ruleName: "", - ruleValue: "", - physicalUnit: "", - order: 0, - enabled: true, - visible: true, - tag:"1" - }, - { - propertyName: "储罐类型", - propertyValue:"", - propertyType: 0, - required: true, - ruleName: "", - ruleValue: "", - physicalUnit: "", - order: 0, - enabled: true, - visible: true, - tag:"1" - }, - { - propertyName: "容量", - propertyValue: "", - propertyType: 2, - required: true, - ruleName: "", - ruleValue: "", - physicalUnit: "㎡", - order: 0, - enabled: true, - visible: true, - tag:"1" - }, - { - propertyName: "直径", - propertyValue:"", - propertyType: 2, - required: true, - ruleName: "", - ruleValue: "", - physicalUnit: "m", - order: 0, - enabled: true, - visible: true, - tag:"1" - }, - { - propertyName: "高度", - propertyValue: "", - propertyType: 2, - required: true, - ruleName: "", - ruleValue: "", - physicalUnit: "m", - order: 0, - enabled: true, - visible: true, - tag:"1" - }, - { - propertyName: "顶盖形式", - propertyValue: "", - propertyType: 0, - required: false, - ruleName: "", - ruleValue: "", - physicalUnit: "", - order: 0, - enabled: true, - visible: true, - tag:"1" - }, - { - propertyName: "浮盘材质", - propertyValue:"", - propertyType: 0, - required: false, - ruleName: "", - ruleValue: "", - physicalUnit: "", - order: 0, - enabled: true, - visible: true, - tag:"1" - }, - { - propertyName: "浮盘类型", - propertyValue: "", - propertyType: 0, - required: false, - ruleName: "", - ruleValue: "", - physicalUnit: "", - order: 0, - enabled: true, - visible: true, - tag:"1" - }, - { - propertyName: "泡沫产生器型号", - propertyValue:"", - propertyType: 0, - required: false, - ruleName: "", - ruleValue: "", - physicalUnit: "", - order: 0, - enabled: true, - visible: true, - tag:"1" - }, - { - propertyName: "泡沫产生器形式", - propertyValue: "", - propertyType: 0, - required: false, - ruleName: "", - ruleValue: "", - physicalUnit: "", - order: 0, - enabled: true, - visible: true, - tag:"1" - }, - { - propertyName: "是否设置氮封惰化保护装置", - propertyValue:"", - propertyType: 0, - required: false, - ruleName: "", - ruleValue: "", - physicalUnit: "", - order: 0, - enabled: true, - visible: true, - tag:"1" - }, - { - propertyName: "防护堤高度", - propertyValue:"", - propertyType: 2, - required: true, - ruleName: "", - ruleValue: "", - physicalUnit: "m", - order: 0, - enabled: true, - visible: true, - tag:"1" - }, - { - propertyName: "半固定泡沫灭火接口数量", - propertyValue: "", - propertyType: 2, - required: false, - ruleName: "", - ruleValue: "", - physicalUnit: "个", - order: 0, - enabled: true, - visible: true, - tag:"1" - }, - { - propertyName: "其它设施", - propertyValue: "", - propertyType: 0, - required: false, - ruleName: "", - ruleValue: "", - physicalUnit: "", - order: 0, - enabled: true, - visible: true, - tag:"1" - } - ] - // console.log(888,bodyObj) - bodyObj.buildingBasicGroups.splice(4,bodyObj.buildingBasicGroups.length) + } + // console.log('newbody',newbody) + this.http.post("/api/BuildingBasicInfos",newbody,{ + params:{ + companyId : this.unitId, + buildingId :newbody[0].buildingId } - + }).subscribe((data:any)=>{ + // this.houses[key].id = data[0].id + const config = new MatSnackBarConfig(); + config.verticalPosition = 'top'; + config.duration = 3000 + this.snackBar.open('建筑信息保存成功','确定',config); + }, + err=>{ + const config = new MatSnackBarConfig(); + config.verticalPosition = 'top'; + config.duration = 3000 + this.snackBar.open('请检查输入数据是否有误','确定',config); + }) + + //保存建筑自定义信息 + if(item.isCustomData){ + this.http.post("/api/BuildingCustomData",item.customData,{params:{ + companyId :this.unitId, + buildingId:item.id + }}).subscribe(data=>{ - - let newbodyObj = [] - newbodyObj.push(bodyObj) - // console.log(1111,newbodyObj) - this.http.post("/api/BuildingBasicInfos",newbodyObj,{ - params:{ - companyId : this.unitId, - buildingId :item.buildingId - } - }).subscribe((data:any)=>{ - this.houses[key].id = data[0].id - const config = new MatSnackBarConfig(); - config.verticalPosition = 'top'; - config.duration = 3000 - this.snackBar.open('建筑信息保存成功','确定',config); - // alert("建筑信息保存成功") - }, - err=>{ - const config = new MatSnackBarConfig(); - config.verticalPosition = 'top'; - config.duration = 3000 - this.snackBar.open('请检查输入数据是否有误','确定',config); - }) + }) + }else{ + item.customData.customProperties = [] + this.http.post("/api/BuildingCustomData",item.customData,{params:{ + companyId :this.unitId, + buildingId:item.id + }}).subscribe(data=>{ + + }) + } + + } + } + //更改模板类型 + templateBuildtype(n,item,key){ + this.http.get("/api/BuildingBasicInfos",{//请求当前建筑类型的模板信息保存到数组中 + params:{ + companyId :this.unitId, + buildingId:item.id, + buildingType:n.id + } + }).subscribe(data=>{ + data[0].buildingBasicGroups.forEach(element => { + //需要处理一下表格信息 + if(element.type == 1){ + let afterData = [] + let tempArr = []; + for (let i = 0; i < element.propertyInfos.length; i++) { + element.propertyInfos[i].tag == '' ? element.propertyInfos[i].tag = 1 : null + if (tempArr.indexOf(element.propertyInfos[i].tag) === -1) { + afterData.push({ + tag: element.propertyInfos[i].tag, + origin: [element.propertyInfos[i]] + }); + tempArr.push(element.propertyInfos[i].tag); + } else { + for (let j = 0; j < afterData.length; j++) { + if (afterData[j].tag == element.propertyInfos[i].tag) { + afterData[j].origin.push(element.propertyInfos[i]); + break; + } + } + } + } + element.propertyInfos = afterData + } + }); + let guanquIndex = data[0].buildingBasicGroups.findIndex(item => item.name.indexOf('罐区')>=0); // 找到第一个灌区的索引 + function transferFn(arr) { + const guanquIndex = arr.findIndex(item => item.name.indexOf('罐区')>=0); // 找到第一个灌区的索引 + const guanquList = arr.slice(guanquIndex); // 灌区的列表 + const baseList = arr.slice(0, guanquIndex); // 前面的数据 + const len = guanquList.length; + const num = len/2; // 计算一共有多少对,这里的前提是数据本身必须成对出现 + // 灌区切割出来的数据,分别存放,最后做一下合并 + const array1 = []; + const array2 = []; + for(let i = 0; i<num; i++) { + array1.push(guanquList[i]); // 灌区x + array2.push(guanquList[i + num]); // 灌区x/储罐信息 } - if(item.buildtype == "地铁类"){ - let newObj = _.cloneDeep(item) - delete newObj.username - delete newObj.name - delete newObj.tongyong - delete newObj.ditie - delete newObj.buildtype - delete newObj.isCustomData - delete newObj.buildingCustomData - newObj.buildingBasicGroups.forEach(item => { - item.propertyInfos.forEach(element => { - delete element.isshowrule - delete element.rulevalue - if( element.propertyValue || element.propertyValue == 0){ - element.propertyValue = String(element.propertyValue) - } - }); - item.buildingId = newObj.buildingId - item.companyId = this.unitinfo.id - item.submitted = true - }); - let newbodyObj2 = [] - newbodyObj2.push(newObj) - this.http.post("/api/BuildingBasicInfos",newbodyObj2,{ - params:{ - companyId : this.unitId, - buildingId :newObj.buildingId + // 拼接最后的数据 + const result = [...baseList]; + for(let i = 0, ll = array1.length; i < ll; i++){ + result.push(array1[i]); + if (array2[i]) { + result.push(array2[i]); } - }).subscribe((data:any)=>{ - this.houses[key].id = data[0].id - const config = new MatSnackBarConfig(); - config.verticalPosition = 'top'; - config.duration = 3000 - this.snackBar.open('建筑信息保存成功','确定',config); - }, - err=>{ - const config = new MatSnackBarConfig(); - config.verticalPosition = 'top'; - config.duration = 3000 - this.snackBar.open('请检查输入数据是否有误','确定',config); - }) - } + return result; + } + if(guanquIndex != -1 && data[0].buildingBasicGroups[guanquIndex + 1].name.indexOf(data[0].buildingBasicGroups[guanquIndex].name) == -1){ + data[0].buildingBasicGroups = transferFn(data[0].buildingBasicGroups) } + this.houses[key].data = data }) - - - }} \ No newline at end of file + } +} \ No newline at end of file diff --git a/src/app/key-unit/basicinfo-look/lookmaster.component.html b/src/app/key-unit/basicinfo-look/lookmaster.component.html index 9cf352f..674e8f4 100644 --- a/src/app/key-unit/basicinfo-look/lookmaster.component.html +++ b/src/app/key-unit/basicinfo-look/lookmaster.component.html @@ -4,7 +4,7 @@ <ng-container *ngIf="isshowimg; else elseTemplate"> <div class="imgbox"> <img class="imgitemdefault" [src]="ImgUrl"> - + <!-- <img class="imgitemdefault" [src]="ImgUrl" [ngClass]="{'img1': rotateA==90,'img2': rotateA==180,'img3': rotateA==270,'img4': rotateB==10,'img5': rotateB==20,'img6': rotateB==30}" > --> </div> </ng-container> <ng-template #elseTemplate > @@ -14,4 +14,13 @@ </div> +<!-- + <div class="swiper-button-prev"></div> + <div class="swiper-button-next"></div> --> + + +<!-- <div class="previewImgBottom"> + <button type="button" mat-icon-button (click)='rotate()'><mat-icon>refresh</mat-icon></button> +</div> --> + diff --git a/src/app/key-unit/basicinfo/addhouseinfo.component.ts b/src/app/key-unit/basicinfo/addhouseinfo.component.ts index e888232..0207384 100644 --- a/src/app/key-unit/basicinfo/addhouseinfo.component.ts +++ b/src/app/key-unit/basicinfo/addhouseinfo.component.ts @@ -21,7 +21,6 @@ import { MatSnackBar } from '@angular/material/snack-bar'; this.dialogRef.close(); } ngOnInit(): void { - // console.log(this.data) this.getallunittype() } getallunittype(){ @@ -30,27 +29,24 @@ import { MatSnackBar } from '@angular/material/snack-bar'; }) } onSubmit(value){ - this.http.get("/api/Buildings",{ params:{ companyId:this.data.unitId } }).subscribe((data:any)=>{ - this.data.allBuildings = data + let allBuildings = data let order - if(data.length == 0){ + if(allBuildings.length == 0){ order = 0 }else{ - order = data[data.length - 1].order + 1 + order = allBuildings[allBuildings.length-1].order + 1 } - let buildingTypename = "" this.allunittype.forEach(item => { if(item.id == value.unittype){ buildingTypename = item.name } }); - this.http.post("/api/Buildings",{ id: "", name: value.name, @@ -68,10 +64,12 @@ import { MatSnackBar } from '@angular/material/snack-bar'; }}).subscribe(data=>{ this.dialogRef.close(data); }) + }) - + + } } \ No newline at end of file diff --git a/src/app/key-unit/basicinfo/basicinfo.component.html b/src/app/key-unit/basicinfo/basicinfo.component.html index 85224ea..bd4b66c 100644 --- a/src/app/key-unit/basicinfo/basicinfo.component.html +++ b/src/app/key-unit/basicinfo/basicinfo.component.html @@ -1,11 +1,10 @@ -<div style="height: 100%;display: flex; flex-direction: column;"> +<div style="height: 100%;display: flex; flex-direction: column;overflow: hidden;"> <!-- header --> <mat-accordion> - <mat-expansion-panel expanded hideToggle > + <mat-expansion-panel expanded> <mat-expansion-panel-header style="color: black;"> <mat-panel-title> 单位信息 - <mat-icon style="position: absolute;right:30px;">keyboard_arrow_down</mat-icon> </mat-panel-title> </mat-expansion-panel-header> <div class="topbox"> @@ -66,7 +65,7 @@ </div> <div class="inputbox" style="width: 700px;"> <span style="color: red;">*</span> - <span>消防救援站:</span> + <span>辖区中队:</span> <mat-form-field style="width: 538px;"> <input matInput id="organization" name="organization" type='text' required minlength="1" @@ -105,16 +104,15 @@ (focus)="closeorganizationbox()"> </mat-form-field> </div> - <div class="uploadimg" (click)="lookmaster()"> + <div class="uploadimg"> <span>单位照片:</span> - <div class="uploadingimg"> - <img *ngIf="imgsrc" [src]="imgsrc" alt="" style="width: 299px; height: 170px;"> - <img *ngIf="!imgsrc" [src]="noImgSrc" alt="" style="width: 299px; height: 170px;"> + <div class="uploadingimg" (click)="lookmaster()"> + <img [src]="imgsrc ? imgsrc : noImg" alt="" style="width: 299px; height: 170px;" > </div> <mat-spinner *ngIf="isspinner" diameter= 50></mat-spinner> </div> <div class="image" (click)="closeorganizationbox()"> - <input id="selectedfile" type="file" (change)="filechange($event)" name="imgFile" accept=".jpg,.png,.jpeg,.gif,.webp"> + <input id="selectedfile" type="file" ng2FileSelect [uploader]="uploader" (change)="filechange($event)" name="imgFile" accept=".jpg,.png,.jpeg,.gif,.webp"> </div> <div class="addbtn"> <button type="submit" color="primary" class="submit1" mat-button mat-raised-button>保存</button> @@ -124,6 +122,7 @@ <div style="width: 100%;height: 100%;" id="container"> </div> + <div class="gistopbox" *ngIf="isGisTopBox"> <div class="positionItem"> <span> @@ -160,61 +159,56 @@ </div> </mat-expansion-panel> </mat-accordion> - - <!-- body --> - <div class="bottombox" style="flex: 70%;overflow-y: auto;" > - <div class="houseinfobox" style="height: 100%; overflow-y: auto;box-sizing:border-box"> - <button type="button" mat-icon-button (click)="addhouseinfo()" class="addhouseinfo"><mat-icon style="font-size: 38px;">add_circle_outline</mat-icon></button> - <mat-tab-group style="height: 100%;;" (focusChange)="selecttab($event)" > - <mat-tab [label]="item.username" *ngFor="let item of houses;let key = index"> - <form style="height: 100%; overflow-y:auto; display: block;" (ngSubmit)="onSubmit2(form.value,item,key,form.invalid)" #form="ngForm" class="example-container"> - - <!-- 正常建筑 --> - <div class="highinfo" *ngIf="item.tongyong"> - <div class="houseinfoinput" > - <span>建筑名称:</span> - <mat-form-field> - <input matInput id="housename" name="housename" type='text' - minlength="1" [(ngModel)]="item.name" - > - </mat-form-field> - <span style="color: red;">*</span> - </div> - <div class="houseinfoinput"> - <span>建筑类型:</span> - <mat-form-field> - <mat-select name="unittype" [(ngModel)]="item.buildtype"> - <mat-option [value]="n.name" *ngFor="let n of allunittype" (click)="templatebuildtype(n,item,key)">{{n.name}}</mat-option> - </mat-select> - </mat-form-field> - <span style="color: red;">*</span> - </div> - - <div *ngFor="let item of item.buildingBasicGroups;let www = index" style="float: left;"> - <h1 style="font-size: 22px;">{{item.name}}</h1> - <div class="houseinfoinput" *ngFor="let i of item.propertyInfos" style="float: left;margin-left: 250px;position: relative;"> + <div class="bodyBox" id="basicInfoBody"> + <div> + <button type="button" mat-icon-button (click)="addhouseinfo()" class="addBuilding"><mat-icon>add_circle_outline</mat-icon></button> + </div> + <div style="height: 100%; box-sizing:border-box;overflow-y: auto;padding-left: 26px;"> + <mat-tab-group style="height: 100%;" [selectedIndex]="selectedIndex" (selectedTabChange)="selectedTabChange($event)"> + <mat-tab *ngFor="let item of houses;let key = index" label="{{item.name}}"> + <ng-template matTabContent> + <form *ngIf="item.data && item.data.length!=0" style="height: 100%; overflow-y:auto; display: block;" (ngSubmit)="onSubmitBuildingInfo(form.value,item,key,form.invalid)" #form="ngForm" class="example-container"> + <div class="buildInfoInput" > + <span>建筑名称:</span> + <mat-form-field> + <input required matInput name="buildingName" type='text' minlength="1" [(ngModel)]="item.name"> + </mat-form-field> + <span style="color: red;">*</span> + </div> + <div class="buildInfoInput"> + <span>建筑类型:</span> + <mat-form-field> + <mat-select name="buildingTypeName" [(ngModel)]="item.buildingTypes[0].name"> + <mat-option [value]="n.name" *ngFor="let n of allunittype" (click)="templateBuildtype(n,item,key)">{{n.name}}</mat-option> + </mat-select> + </mat-form-field> + <span style="color: red;">*</span> + </div> + <div *ngFor="let element of item.data[0].buildingBasicGroups;let groupsIndex = index "style="float: left;width:100%"> + <!-- 类型为表单并且不是 罐区 --> + <div *ngIf="element.type == 0 && element.name.indexOf('罐区') == -1"> + <p style="font-size: 22px;">{{element.name}}</p> + <div class="buildInfoInput" *ngFor="let i of element.propertyInfos;let inputIndex = index" style="float: left;margin-left: 250px;position: relative;"> <span>{{i.propertyName}}<span *ngIf="i.physicalUnit">({{i.physicalUnit}})</span>:</span> - <!-- 如果类型是文本 --> <mat-form-field *ngIf="i.propertyType == 0 && i.propertyName != '耐火等级'"> - <input matInput name="{{i.propertyName}}{{www}}" type='text' + <input matInput name="{{groupsIndex}}{{inputIndex}}" type='text' required="{{ i.required==true ? 'true' : 'false' }}" [(ngModel)]="i.propertyValue"> </mat-form-field> - + <!-- 如果类型是数字 --> <mat-form-field *ngIf="i.propertyType == 2 && i.propertyName != '耐火等级'"> - <input matInput name="{{i.propertyName}}{{www}}" type='number' + <input matInput name="{{groupsIndex}}{{inputIndex}}" type='number' required="{{ i.required==true ? 'true' : 'false' }}" [(ngModel)]="i.propertyValue" (change)="inputchange($event,i.ruleName,i.ruleValue,i)" > - <!-- <mat-error *ngIf="isshowrule">{{rulevalue}}</mat-error> --> </mat-form-field> <!-- 如果类型是耐火等级 --> <mat-form-field *ngIf="i.propertyName == '耐火等级'"> - <mat-select name="{{i.propertyName}}{{www}}" required="{{ i.required==true ? 'true' : 'false' }}" placeholder="请选择耐火等级" [(ngModel)]="i.propertyValue"> + <mat-select name="{{groupsIndex}}{{inputIndex}}" required="{{ i.required==true ? 'true' : 'false' }}" placeholder="请选择耐火等级" [(ngModel)]="i.propertyValue"> <mat-option value="0">1级</mat-option> <mat-option value="1">2级</mat-option> <mat-option value="2">3级</mat-option> @@ -222,352 +216,153 @@ </mat-select> </mat-form-field> <!-- 如果类型是多行文本 --> - <textarea *ngIf="i.propertyType == 1 && i.propertyName != '耐火等级'" style="width: 180px;height: 60px;" required="{{ i.required==true ? 'true' : 'false' }}" [(ngModel)]="i.propertyValue" name="{{i.propertyName}}{{key}}"></textarea> + <textarea *ngIf="i.propertyType == 1 && i.propertyName != '耐火等级'" style="width: 180px;height: 60px;" required="{{ i.required==true ? 'true' : 'false' }}" [(ngModel)]="i.propertyValue" name="{{groupsIndex}}{{inputIndex}}"></textarea> <span style="color: red;" *ngIf="i.required">*</span> - <div *ngIf="i.isshowrule" style="position: absolute; - left: 205px; - top: 45px; - font-size: 11px; - color: red;"> + <div *ngIf="i.isshowrule" style="position: absolute;left: 205px;top: 45px;font-size: 11px;color: red;"> <span>{{i.rulevalue}}</span> </div> </div> </div> - - <div class="CustomData" style="width: 200px;"> - <mat-checkbox color="primary" (change)="checkCustomData($event)" name="checkbuilding" [(ngModel)]="item.isCustomData" style="float: left;margin-right: 10px;"></mat-checkbox> - <h1 style="font-size: 22px;width: 200px;">自定义信息</h1> - </div> - <div *ngIf="item.isCustomData" style="position: relative;"> - <button style="position: absolute;left: 0;" type="button" mat-icon-button (click)="addCustomData(item)" class="addCustomData"><mat-icon style="font-size: 38px;">add_circle_outline</mat-icon></button> - <button style="position: absolute;left:60px;" type="button" mat-icon-button (click)="deleteCustomData(item)" class="deleteCustomData"><mat-icon style="font-size: 38px;">remove_circle_outline</mat-icon></button> - <div class="houseinfoinput" style="float: left;margin-left: 250px;" *ngFor="let i of item.buildingCustomData.customProperties;let key = index"> - <mat-form-field> - <input matInput type='text' name="{{key}}1CustomData" - required - [(ngModel)]="i.name"> - </mat-form-field> - <span>:</span> - <mat-form-field> - <input matInput type='text' name="{{key}}2CustomData" - required - [(ngModel)]="i.value"> - </mat-form-field> - <span style="color: red;" *ngIf="i.required">*</span> - </div> - </div> - </div> - - <!-- 石油化工 --> - <div class="highinfo" *ngIf="item.isshiyou;let bigkey = index"> - - <div class="basicinfobox"> - <div class="houseinfoinput"> - <span>建筑名称:</span> - <mat-form-field> - <input matInput id="housename" name="housename" type='text' - required minlength="1" [(ngModel)]="item.name" - > - </mat-form-field> - <span style="color: red;">*</span> - </div> - <div class="houseinfoinput" > - <span>建筑类型:</span> - <mat-form-field> - <mat-select required name="unittype" [(ngModel)]="item.buildtype"> - <mat-option [value]="n.name" *ngFor="let n of allunittype" (click)="templatebuildtype(n,item,key)">{{n.name}}</mat-option> - </mat-select> - </mat-form-field> - <span style="color: red;">*</span> - </div> - <h1 style="font-size: 22px;">{{item.buildingBasicGroups[0].name}}</h1> - <div class="houseinfoinput" *ngFor="let i of item.buildingBasicGroups[0].propertyInfos;let smkey = index" style="float: left;margin-left: 250px;position: relative;"> - <span>{{i.propertyName}} <span *ngIf="i.physicalUnit">({{i.physicalUnit}})</span> :</span> - - - <!-- 如果类型是文本 --> - <mat-form-field *ngIf="i.propertyType == 0 && i.propertyName != '耐火等级'"> - <input matInput name="{{i.propertyName}}" type='text' - required="{{ i.required==true ? 'true' : 'false' }}" - [(ngModel)]="i.propertyValue"> - </mat-form-field> - - <!-- 如果类型是数字 --> - <mat-form-field *ngIf="i.propertyType == 2 && i.propertyName != '耐火等级'"> - <input matInput name="{{i.propertyName}}" type='number' - required="{{ i.required==true ? 'true' : 'false' }}" - [(ngModel)]="i.propertyValue" - (change)="inputchange($event,i.ruleName,i.ruleValue,i)" - > - <!-- <mat-error *ngIf="isshowrule">{{rulevalue}}</mat-error> --> - </mat-form-field> - <!-- 如果类型是耐火等级 --> - <mat-form-field *ngIf="i.propertyName == '耐火等级'"> - <mat-select name="{{i.propertyName}}" required="{{ i.required==true ? 'true' : 'false' }}" placeholder="请选择耐火等级" [(ngModel)]="i.propertyValue"> - <mat-option value="0">1级</mat-option> - <mat-option value="1">2级</mat-option> - <mat-option value="2">3级</mat-option> - <mat-option value="3">其它</mat-option> - </mat-select> - </mat-form-field> - <!-- 如果类型是多行文本 --> - <textarea *ngIf="i.propertyType == 1 && i.propertyName != '耐火等级'" style="width: 180px;height: 60px;" required="{{ i.required==true ? 'true' : 'false' }}" [(ngModel)]="i.propertyValue" name="{{i.propertyName}}"></textarea> - <span style="color: red;" *ngIf="i.required">*</span> - <div *ngIf="i.isshowrule" style=" position: absolute; - left: 205px; - top: 45px; - font-size: 11px; - color: red;"> - <span>{{i.rulevalue}}</span> - </div> - </div> - </div> - - - <div class="deviceinfo"> - <div style="width: 200px;"> - <mat-checkbox color="primary" (change)="checkboxchange(item.buildingBasicGroups[1].submitted,$event)" name="item.buildingBasicGroups[1].name" *ngIf="item.buildingBasicGroups[1].isOptional" [(ngModel)]="item.buildingBasicGroups[1].submitted" style="float: left;margin-right: 10px;"></mat-checkbox> - <h1 style="font-size: 22px;width: 200px;">{{item.buildingBasicGroups[1].name}}</h1> - </div> - - <table mat-table [dataSource]="devicedataSourcebox[item.buildingId]" class="mat-elevation-z8" *ngIf="item.buildingBasicGroups[1].submitted"> - <ng-container matColumnDef="name"> - <th mat-header-cell *matHeaderCellDef> - <button style="width: 24px;" type="button" mat-icon-button class="adddeviceinfo2" (click)="adddeviceinfo(item)"><mat-icon>add_circle_outline</mat-icon></button> - <button style="width: 24px;" type="button" mat-icon-button class="removedeviceinfo" (click)="removedeviceinfo(item)"><mat-icon>remove_circle_outline</mat-icon></button> - 装置区名称<span style="color: red;">*</span></th> - <td mat-cell *matCellDef="let element;let key = index"> - <textarea style="width: 100px;" [(ngModel)]="element.name" name="{{key}}1" required></textarea> - </td> - </ng-container> - <ng-container matColumnDef="flow"> - <th mat-header-cell *matHeaderCellDef>工艺流程<span style="color: red;">*</span></th> - <td mat-cell *matCellDef="let element;let key = index"> - <textarea [(ngModel)]="element.flow" name="{{key}}2" required></textarea> - </td> - </ng-container> - <ng-container matColumnDef="danger"> - <th mat-header-cell *matHeaderCellDef>火灾危险性<span style="color: red;">*</span></th> - <td mat-cell *matCellDef="let element;let key = index"> - <textarea [(ngModel)]="element.danger" name="{{key}}3" required></textarea> - </td> - </ng-container> - <ng-container matColumnDef="payattentionto"> - <th mat-header-cell *matHeaderCellDef>灭火注意事项</th> - <td mat-cell *matCellDef="let element;let key = index"> - <textarea style="width: 100px;" [(ngModel)]="element.payattentionto" name="{{key}}4"></textarea> + <!-- 类型为表格 并且不是 罐区 --> + <div *ngIf="element.type == 1 && element.name.indexOf('罐区') == -1"> + <p style="font-size: 22px;"> + <mat-checkbox color="primary" (change)="checkboxChange(element,$event,item)" *ngIf="element.isOptional" [name]="element.name" [(ngModel)]="element.submitted" style="float: left;margin-right: 10px;"></mat-checkbox> + {{element.name}} + </p> + <table *ngIf="element.submitted"> + <tr> + <th *ngFor="let item of element.propertyInfos[0].origin;let index = index"> + <button *ngIf="index == 0" style="width: 24px;" type="button" mat-icon-button class="addline" (click)="addline(element.propertyInfos)"><mat-icon>add_circle_outline</mat-icon></button> + <button *ngIf="index == 0" style="width: 24px;" type="button" mat-icon-button class="removeline" (click)="removeline(element.propertyInfos)"><mat-icon>remove_circle_outline</mat-icon></button> + {{item.propertyName}} + <span style="color: red;" *ngIf="item.required">*</span> + </th> + </tr> + <tr *ngFor="let item of element.propertyInfos;let line = index"> + <td *ngFor="let i of item.origin;let list = index"> + <input *ngIf="i.propertyType != 1" style="height:45px" class="tankinfo" name="{{element.name}}{{line + 1}}-{{list + 1}}" type="{{i.propertyType == 0 ? 'text' : 'number'}}" + required="{{ i.required==true ? 'true' : 'false' }}" [(ngModel)]="i.propertyValue"> + <textarea class="tankinfo" *ngIf="i.propertyType == 1" required="{{ i.required==true ? 'true' : 'false' }}" [(ngModel)]="i.propertyValue" name="{{element.name}}{{line + 1}}{{list + 1}}"> + + </textarea> </td> - </ng-container> - <tr mat-header-row *matHeaderRowDef="displayedColumns"></tr> - <tr mat-row *matRowDef="let row; columns: displayedColumns;"></tr> + </tr> </table> </div> - - <div style="width: 200px;"> - <mat-checkbox color="primary" (change)="checkboxchange(item,$event)" *ngIf="item.buildingBasicGroups[2].isOptional" name="item.buildingBasicGroups[2].name" [(ngModel)]="item.buildingBasicGroups[2].submitted" style="float: left;margin-right: 10px;"></mat-checkbox> - <h1 style="font-size: 22px;width: 200px;">储罐信息</h1> - </div> - - <button *ngIf="item.buildingBasicGroups[2].submitted" type="button" mat-raised-button color="primary" (click)="addtankbox(item,bigkey)" style="margin-top: 30px;margin-right: 5px;">添加储罐</button> - <button *ngIf="item.buildingBasicGroups[2].submitted" type="button" mat-raised-button color="warn" (click)="removetankbox(item,bigkey)" style="margin-top: 30px;" matTooltip="会将此建筑处于末尾的储罐移除">移除末尾储罐</button> - - - <div *ngIf="item.buildingBasicGroups[2].submitted" style="margin-top: 30px;"> - <div class="tankinfo" *ngFor="let x of item.bigfor;let www = index"> - <p style="font-size: 22px; width: 200px;">{{x[0].name}}</p> - <div class="basicinfobox" > - <div class="houseinfoinput" *ngFor="let i of x[0].propertyInfos;let key = index" style="line-height: 65px;"> - <span>{{i.propertyName}} {{i.physicalUnit}}:</span> - <mat-form-field *ngIf="i.propertyType == 0"> - <input matInput name="{{www+2}}-tanker-{{key}}" type='text' - required="{{ i.required==true ? 'true' : 'false' }}" - [(ngModel)]="i.propertyValue" - > - </mat-form-field> - <textarea style="width: 180px;height: 45px;" *ngIf="i.propertyType == 1" [(ngModel)]="i.propertyValue" name="{{www+2}}-tanker-{{key}}"></textarea> - <span style="color: red;" *ngIf="i.required">*</span> - </div> - - </div> - <p style="font-size: 22px; width: 200px;">{{x[1].name}}</p> - <div class="tankdetailinfo"> - <table #table mat-table [dataSource]="x[1].propertyInfos" class="mat-elevation-z8" style="position: relative;"> - <ng-container matColumnDef="tank"> - <th mat-header-cell *matHeaderCellDef> - <button type="button" mat-icon-button class="adddeviceinfo" (click)="adddeviceinfo2(www,item)" style="position: absolute;left: 0;"><mat-icon>add_circle_outline</mat-icon></button> - <button type="button" mat-icon-button class="removedeviceinfo" (click)="removedeviceinfo3(www,item)"><mat-icon>remove_circle_outline</mat-icon></button> - 罐区 </th> - <td mat-cell *matCellDef="let element;let key = index"> - <input style="height:45px" class="tankinfo" name="{{www}}{{element.tank}}tank{{key}}" type='text' - [(ngModel)]="element.tank"> - </td> - </ng-container> - <ng-container matColumnDef="tankid"> - <th mat-header-cell *matHeaderCellDef>罐区编号<span style="color: red;">*</span></th> - <td mat-cell *matCellDef="let element;let key = index"> - <input style="height:45px" class="tankinfo" name="{{www}}{{element.tankid}}tank{{key}}" type='text' - required - [(ngModel)]="element.tankid"> - </td> - </ng-container> - <ng-container matColumnDef="tankmedium"> - <th mat-header-cell *matHeaderCellDef>储存介质<span style="color: red;">*</span></th> - <td mat-cell *matCellDef="let element;let key = index"> - <input style="height:45px" class="tankinfo" name="{{www}}{{element.tankmedium}}tank{{key}}" type='text' - required - [(ngModel)]="element.tankmedium"> - </td> - </ng-container> + <!-- 类型为表单 是罐区--> + <div *ngIf="element.type == 0 && element.name.indexOf('罐区') != -1"> + <p style="font-size: 22px;"> + <mat-checkbox color="primary" (change)="checkboxChange(element,$event,item)" *ngIf="element.isOptional && element.name == '罐区1'" [name]="element.name" [(ngModel)]="element.submitted" style="float: left;margin-right: 10px;"></mat-checkbox> - <ng-container matColumnDef="tanktype"> - <th mat-header-cell *matHeaderCellDef>储罐类型<span style="color: red;">*</span></th> - <td mat-cell *matCellDef="let element;let key = index"> - <input style="height:45px" class="tankinfo" name="{{www}}{{element.tanktype}}tank{{key}}" type='text' - required - [(ngModel)]="element.tanktype"> - </td> - </ng-container> - <ng-container matColumnDef="tankcapacity"> - <th mat-header-cell *matHeaderCellDef>容量(m³)<span style="color: red;">*</span></th> - <td mat-cell *matCellDef="let element;let key = index"> - <input style="height:45px" class="tankinfo" name="{{www}}{{element.tankcapacity}}tank{{key}}" type='text' - required - [(ngModel)]="element.tankcapacity"> - </td> - </ng-container> - <ng-container matColumnDef="tankdiameter"> - <th mat-header-cell *matHeaderCellDef>直径(m)<span style="color: red;">*</span></th> - <td mat-cell *matCellDef="let element;let key = index"> - <input style="height:45px" class="tankinfo" name="{{www}}{{element.tankdiameter}}tank{{key}}" type='text' - required - [(ngModel)]="element.tankdiameter"> - </td> - </ng-container> - <ng-container matColumnDef="tankheight"> - <th mat-header-cell *matHeaderCellDef>高度(m)<span style="color: red;">*</span></th> - <td mat-cell *matCellDef="let element;let key = index"> - <input style="height:45px" class="tankinfo" name="{{www}}{{element.tankheight}}tank{{key}}" type='text' - required - [(ngModel)]="element.tankheight"> - </td> - </ng-container> - <ng-container matColumnDef="tanktectum"> - <th mat-header-cell *matHeaderCellDef>顶盖形式</th> - <td mat-cell *matCellDef="let element;let key = index"> - <input style="height:45px" class="tankinfo" name="{{www}}{{element.tanktectum}}tank{{key}}" type='text' - [(ngModel)]="element.tanktectum"> - </td> - </ng-container> - <ng-container matColumnDef="tanktexture"> - <th mat-header-cell *matHeaderCellDef>浮盘材质</th> - <td mat-cell *matCellDef="let element;let key = index"> - <input style="height:45px" class="tankinfo" name="{{www}}{{element.tanktexture}}tank{{key}}" type='text' - [(ngModel)]="element.tanktexture"> - </td> - </ng-container> - <ng-container matColumnDef="platetype"> - <th mat-header-cell *matHeaderCellDef>浮盘类型</th> - <td mat-cell *matCellDef="let element;let key = index"> - <input style="height:45px" class="tankinfo" name="{{www}}{{element.platetype}}tank{{key}}" type='text' - [(ngModel)]="element.platetype"> - </td> - </ng-container> - <ng-container matColumnDef="foamgeneratorid"> - <th mat-header-cell *matHeaderCellDef>泡沫产生器型号</th> - <td mat-cell *matCellDef="let element;let key = index"> - <input style="height:45px" class="tankinfo" name="{{www}}{{element.foamgeneratorid}}tank{{key}}" type='text' - [(ngModel)]="element.foamgeneratorid"> - </td> - </ng-container> - <ng-container matColumnDef="foamgeneratortype"> - <th mat-header-cell *matHeaderCellDef>泡沫产生器形式</th> - <td mat-cell *matCellDef="let element;let key = index"> - <input style="height:45px" class="tankinfo" name="{{www}}{{element.foamgeneratortype}}tank{{key}}" type='text' - [(ngModel)]="element.foamgeneratortype"> - </td> - </ng-container> - <ng-container matColumnDef="isprotect"> - <th mat-header-cell *matHeaderCellDef>是否设置氮封惰化保护装置</th> - <td mat-cell *matCellDef="let element;let key = index"> - <input style="height:45px" class="tankinfo" name="{{www}}{{element.isprotect}}tank{{key}}" type='text' - [(ngModel)]="element.isprotect"> - </td> - </ng-container> - <ng-container matColumnDef="fendinggroyneheight"> - <th mat-header-cell *matHeaderCellDef>防护堤高度(m)<span style="color: red;">*</span></th> - <td mat-cell *matCellDef="let element;let key = index"> - <input style="height:45px" class="tankinfo" name="{{www}}{{element.fendinggroyneheight}}tank{{key}}" type='text' - required - [(ngModel)]="element.fendinggroyneheight"> - </td> - </ng-container> - <ng-container matColumnDef="portnum"> - <th mat-header-cell *matHeaderCellDef>半固定泡沫灭火接口数量</th> - <td mat-cell *matCellDef="let element;let key = index"> - <input style="height:45px" class="tankinfo" name="{{www}}{{element.portnum}}tank{{key}}" type='text' + <span *ngIf="element.name == '罐区1'">罐区信息</span> + </p> + <div *ngIf="element.submitted" > + <p *ngIf="element.name == '罐区1'" style="margin: 5px 0;"> + <button type="button" mat-raised-button color="primary" (click)="addTankBox(item,groupsIndex)" style="margin-right: 5px;">添加罐区</button> + <button type="button" mat-raised-button color="warn" (click)="removeTankBox(item,groupsIndex)" matTooltip="会将此建筑处于末尾的罐区移除">移除末尾罐区</button> + </p> + <p style="font-size: 22px;">{{element.name}}</p> - [(ngModel)]="element.portnum"> - </td> - </ng-container> - <ng-container matColumnDef="else"> - <th mat-header-cell *matHeaderCellDef>其它设施</th> - <td mat-cell *matCellDef="let element;let key = index"> - <input style="height:45px" class="tankinfo" name="{{www}}{{element.else}}tank{{key}}" type='text' - - [(ngModel)]="element.else"> - </td> - </ng-container> - - - <tr mat-header-row *matHeaderRowDef="displayedColumns2"></tr> - <tr mat-row *matRowDef="let row; columns: displayedColumns2;"></tr> - </table> + <div class="buildInfoInput" *ngFor="let i of element.propertyInfos;let inputIndex = index" style="float: left;margin-left: 250px;position: relative;"> + <span>{{i.propertyName}}<span *ngIf="i.physicalUnit">({{i.physicalUnit}})</span>:</span> + <!-- 如果类型是文本 --> + <mat-form-field *ngIf="i.propertyType == 0 && i.propertyName != '耐火等级'"> + <input matInput name="{{groupsIndex}}{{inputIndex}}" type='text' + required="{{ i.required==true ? 'true' : 'false' }}" + [(ngModel)]="i.propertyValue"> + </mat-form-field> + + <!-- 如果类型是数字 --> + <mat-form-field *ngIf="i.propertyType == 2 && i.propertyName != '耐火等级'"> + <input matInput name="{{groupsIndex}}{{inputIndex}}" type='number' + required="{{ i.required==true ? 'true' : 'false' }}" + [(ngModel)]="i.propertyValue" + (change)="inputchange($event,i.ruleName,i.ruleValue,i)" + > + </mat-form-field> + <!-- 如果类型是耐火等级 --> + <mat-form-field *ngIf="i.propertyName == '耐火等级'"> + <mat-select name="{{groupsIndex}}{{inputIndex}}" required="{{ i.required==true ? 'true' : 'false' }}" placeholder="请选择耐火等级" [(ngModel)]="i.propertyValue"> + <mat-option value="0">1级</mat-option> + <mat-option value="1">2级</mat-option> + <mat-option value="2">3级</mat-option> + <mat-option value="3">其它</mat-option> + </mat-select> + </mat-form-field> + <!-- 如果类型是多行文本 --> + <textarea *ngIf="i.propertyType == 1 && i.propertyName != '耐火等级'" style="width: 180px;height: 60px;" required="{{ i.required==true ? 'true' : 'false' }}" [(ngModel)]="i.propertyValue" name="{{groupsIndex}}{{inputIndex}}"></textarea> + + <span style="color: red;" *ngIf="i.required">*</span> + <div *ngIf="i.isshowrule" style="position: absolute;left: 205px;top: 45px;font-size: 11px;color: red;"> + <span>{{i.rulevalue}}</span> + </div> </div> </div> + </div> - - - <div class="CustomData" style="width: 200px;margin-top: 60px;"> - <mat-checkbox color="primary" (change)="checkCustomData($event)" name="checkbuilding" [(ngModel)]="item.isCustomData" style="float: left;margin-right: 10px;"></mat-checkbox> - <h1 style="font-size: 22px;width: 200px;">自定义信息</h1> - </div> - <div *ngIf="item.isCustomData" style="position: relative;"> - <button style="position: absolute;left: 0;font-size: 11px;" type="button" mat-icon-button (click)="addCustomData(item)" class="addCustomData"><mat-icon style="font-size: 38px;">add_circle_outline</mat-icon></button> - <button style="position: absolute;left:60px;" type="button" mat-icon-button (click)="deleteCustomData(item)" class="deleteCustomData"><mat-icon style="font-size: 38px;">remove_circle_outline</mat-icon></button> - <div class="houseinfoinput" style="float: left;margin-left: 250px;" *ngFor="let i of item.buildingCustomData.customProperties;let key = index"> - <mat-form-field> - <input matInput type='text' name="{{key}}1CustomData" - required - [(ngModel)]="i.name"> - </mat-form-field> - <span>:</span> - <mat-form-field> - <input matInput type='text' name="{{key}}2CustomData" - required - [(ngModel)]="i.value"> - </mat-form-field> - <span style="color: red;" *ngIf="i.required">*</span> - </div> + <!-- 类型为表格 是罐区 --> + <div *ngIf="element.type == 1 && element.name.indexOf('罐区') != -1"> + <p style="font-size: 22px;" *ngIf="element.submitted"> + {{element.name}} + </p> + <table *ngIf="element.submitted"> + <tr> + <th *ngFor="let item of element.propertyInfos[0].origin;let index = index"> + <button *ngIf="index == 0" style="width: 24px;" type="button" mat-icon-button class="addline" (click)="addline(element.propertyInfos)"><mat-icon>add_circle_outline</mat-icon></button> + <button *ngIf="index == 0" style="width: 24px;" type="button" mat-icon-button class="removeline" (click)="removeline(element.propertyInfos)"><mat-icon>remove_circle_outline</mat-icon></button> + {{item.propertyName}} + <span style="color: red;" *ngIf="item.required">*</span> + </th> + </tr> + <tr *ngFor="let item of element.propertyInfos;let line = index"> + <td *ngFor="let i of item.origin;let list = index"> + <input type="{{i.propertyType == 0 ? 'text' : 'number'}}" style="height:45px" class="tankinfo" name="{{element.name}}{{line + 1}}-{{list + 1}}" + required="{{ i.required==true ? 'true' : 'false' }}" [(ngModel)]="i.propertyValue"> + </td> + </tr> + </table> </div> - </div> - + <div class="CustomData" style="width: 200px;margin-top: 60px;"> + <mat-checkbox color="primary" (change)="checkCustomData($event)" name="checkbuilding" [(ngModel)]="item.isCustomData" style="float: left;margin-right: 10px;"></mat-checkbox> + <h1 style="font-size: 22px;width: 200px;">自定义信息</h1> + </div> + <div style="position: relative;" *ngIf="item.isCustomData"> + <button style="position: absolute;left: 100px;top: 5px;" type="button" mat-icon-button (click)="addCustomData(item)" class="addCustomData"> + <mat-icon>add_circle_outline</mat-icon> + </button> + <button style="position: absolute;left:150px;top: 5px;" type="button" mat-icon-button (click)="popCustomData(item)" class="deleteCustomData"> + <mat-icon>remove_circle_outline</mat-icon> + </button> + <div class="houseinfoinput" style="float: left;margin-left: 250px;" *ngFor="let i of item.customData.customProperties;let key = index"> + <mat-form-field> + <input matInput type='text' name="customData{{key}}Name" + required + [(ngModel)]="i.name"> + </mat-form-field> + <span>:</span> + <mat-form-field> + <input matInput type='text' name="customData{{key}}Value" + required + [(ngModel)]="i.value"> + </mat-form-field> + <span style="color: red;" *ngIf="i.required">*</span> + </div> + </div> <div class="infobtnbox"> - <button type="submit()" mat-button mat-raised-button color="primary" >保存</button> - <button type="button" mat-raised-button (click)="deletedbuilding(item)" color="warn">删除</button> + <button type="submit" mat-button mat-raised-button color="primary">保存</button> + <button type="button" mat-raised-button (click)="deletedbuilding(item,key)" color="warn">删除</button> </div> - </form> - </mat-tab> + </ng-template> - </mat-tab-group> - + + </mat-tab> + </mat-tab-group> </div> - </div> - </div> diff --git a/src/app/key-unit/basicinfo/basicinfo.component.scss b/src/app/key-unit/basicinfo/basicinfo.component.scss index 7ffed03..9c6800b 100644 --- a/src/app/key-unit/basicinfo/basicinfo.component.scss +++ b/src/app/key-unit/basicinfo/basicinfo.component.scss @@ -1,7 +1,7 @@ .topbox{ height: 485px; width: 100%; - // border-bottom: 1px solid black; + padding-bottom: 20px; .mainbox{ height: 100%; position: relative; @@ -40,7 +40,8 @@ } .addbtn{ width: 695px; - margin:9px 0; + margin:20px 0; + padding-bottom: 20px; } .uploadimg{ width: 400px; @@ -150,52 +151,34 @@ z-index: 1; } } - } } -.bottombox{ - // height:400px; - width: 100%; - // background-color: skyblue; - - .bottomtitle{ - height: 60px; - // background-color: orange; - line-height: 60px; - border-top: 1px solid black; - border-bottom: 1px solid black; +.bodyBox{ + flex: 70%;overflow-y: auto; + position: relative; + .addBuilding{ + position: absolute; + z-index: 999; + left: 0; + top: 3px; } - .houseinfobox{ - // height:340px; - overflow: auto; - .addhouseinfo{ - float: left; - } - .infobtnbox{ - margin-left: 800px; - position: absolute; - top: 30px; - right: 75px; - button{ - width: 80px; - height: 40px; - margin: 0 12px; - margin-top: 15px; - } - } - .infotitle{ - font-size: 28px; - font-weight: 900; - margin-left: 180px; - } - .houseinfoinput{ - width: 393px; - text-align: end; - margin-left:240px; + .buildInfoInput{ + width: 393px; + text-align: end; + margin-left:240px; + } + .infobtnbox{ + position: absolute; + top: 30px; + right: 75px; + button{ + width: 80px; + height: 40px; + margin: 0 12px; + margin-top: 15px; } } } - .btn{ width: 100%; text-align: center; @@ -207,37 +190,29 @@ margin-top: 58px; margin-left: 203px; } -.mat-table{ - width: 100%; -} + table{ - width: 1000px; - thead{ - tr{ - th{ - width: 60px; - display: block; - float: left; - - } + width: 99%; + tr{ + display: flex; + td,th{ + flex: 1; } - } - tbody{ - tr{ + th{ + display: flex; + align-items: center; + justify-content: center; - td{ - width: 60px; - display: block; - float: left; - text-align: center; - } + } + input{ + border: 0px ; } } } - +table,table tr th, table tr td { border: 0.1px solid gray; } +table { text-align: center; border-collapse: collapse; padding:2px;} .deviceinfo{ - // border-bottom: 1px solid black;; padding-bottom: 60px; } .tankdetailinfo{ @@ -251,14 +226,10 @@ table{ } .tankinfo{ display: block; - width: 100%; - // height: 45px; + width: 97.5%; text-align: center; + border: 0px; } -// .adddeviceinfo{ -// // position: absolute; -// // left: 0px; -// } .submit1{ margin-left: -66px !important; } @@ -270,31 +241,7 @@ textarea { height: 110px; resize: none; } - //预览图片旋转角度 - .img1{ - transform:rotate(90deg) scale(0.55); - height: 100%; -} -.img2{ - transform:rotate(180deg); - // height: 100%; -} -.img3{ - transform:rotate(270deg) scale(0.55); - // height: 100%; -} -.img4{ - transform:rotate(90deg) scale(1.3); - // height: 100%; -} -.img5{ - transform:rotate(180deg); - // height: 100%; -} -.img6{ - transform:rotate(270deg) scale(1.3); - // height: 100%; -} + .imgbox{ text-align: center; height: 750px; @@ -312,9 +259,4 @@ textarea { padding-left: 77px; font-size: 12px; color: red; - } -.mat-expansion-panel{ - span{ - color: black; - } -} \ No newline at end of file + } \ No newline at end of file diff --git a/src/app/key-unit/basicinfo/basicinfo.component.ts b/src/app/key-unit/basicinfo/basicinfo.component.ts index f390739..f3a523d 100644 --- a/src/app/key-unit/basicinfo/basicinfo.component.ts +++ b/src/app/key-unit/basicinfo/basicinfo.component.ts @@ -1,17 +1,24 @@ -import { Component, OnInit, Inject ,ViewChild, ElementRef, Renderer2} from '@angular/core'; +import { Component, OnInit, Inject ,ViewChild, Renderer2, ElementRef, Directive, forwardRef} from '@angular/core'; import { MatTreeFlatDataSource, MatTreeFlattener } from '@angular/material/tree'; import { FlatTreeControl } from '@angular/cdk/tree'; import { HttpClient,HttpHeaders, HttpEventType } from '@angular/common/http'; import { MatDialog, MatDialogRef, MAT_DIALOG_DATA } from '@angular/material/dialog'; -import { FormControl } from '@angular/forms'; +import { AbstractControl, FormControl, NG_VALIDATORS, Validator } from '@angular/forms'; import { MatSnackBar ,MatSnackBarConfig} from '@angular/material/snack-bar'; +import format from 'date-fns/format'; import { TreeService } from '../../http-interceptors/tree.service' +import { FileUploader, FileItem } from 'ng2-file-upload' import { AddHouseInfo } from './addhouseinfo.component' +import { DomSanitizer } from '@angular/platform-browser' +import { Injectable } from "@angular/core" +import { filter } from 'rxjs/operators'; +import { async } from '@angular/core/testing'; import { MatTableDataSource } from '@angular/material/table'; +import { isNgTemplate } from '@angular/compiler'; import * as _ from 'lodash'; +import Swiper from 'swiper'; import { LookMaster } from './lookmaster.component' -import { ActivatedRoute } from '@angular/router' -import { TabbarAndScoreService } from 'src/app/http-interceptors/tabbar-and-score.service'; +import { ActivatedRoute } from '@angular/router'; declare var AMap: any; @Component({ @@ -39,8 +46,15 @@ export class BasicinfoComponent implements OnInit { } ] } - - + + uploader:FileUploader = new FileUploader({ //初始化上传事件 ng2-upload + url: `/api/Objects/PlanPlatform/${sessionStorage.getItem('companyId')}`, + method: "POST", + itemAlias: "uploadedfile", + autoUpload: false, + removeAfterUpload:true //上传之后是否在队列中移除,如果不移除就会出现无法上传第二次的情况 + }); + private _transformer = (node, level: number) => { //初始化tree return { expandable: !!node.children && node.children.length > 0, @@ -60,25 +74,40 @@ export class BasicinfoComponent implements OnInit { isorganizationbox = false//控制辖区中队框的显示隐藏 selectedorganization: any//所选的辖区中队 selectedorganizationid:any //所选的辖区中队的id - highhouse = false//控制高层表单的显示 defaultbuildingTypes :any //存储当前建筑的默认类型的id buildingTypesname:any//存储当前建筑的默认类型name buildingCustomData:any //存储当前建筑的自定义信息 - - - constructor(private elementRef: ElementRef,public renderer2: Renderer2,private tabbarService: TabbarAndScoreService,private route:ActivatedRoute,private http: HttpClient, private tree: TreeService, public dialog: MatDialog,public snackBar: MatSnackBar) { } - + allunittype: any //所有单位类型 + allorganizing:any = [] //所有组织机构 + constructor(private route:ActivatedRoute,private elementRef: ElementRef,public renderer2: Renderer2,private http: HttpClient, private tree: TreeService, private sanitizer: DomSanitizer, public dialog: MatDialog,public snackBar: MatSnackBar) { } + houses: any = [] //存储当前单位的建筑信息 unitId : any //当前单位id ngOnInit(): void { - this.getallunittype()//获得所有单位类型 - this.getorganization()//获得所有组织机构 + 获得当前单位的基本信息 - this.getunitallbuilding()//获得当前单位所有建筑 + this.getallunittype() + this.getorganization() + this.getUnitAllBuildings()//获得单位下所有建筑 this.unitId = this.route.snapshot.queryParams.id - sessionStorage.setItem("companyId",this.route.snapshot.queryParams.id); } + //获得单位下所有建筑 + getUnitAllBuildings(){ + this.unitId = this.route.snapshot.queryParams.id + this.http.get("/api/Buildings",{ + params:{ + companyId:this.unitId + } + }).subscribe(async (data:any)=>{ // 获得当前单位所有的建筑 + data.forEach(element => { + element.data = [] + }); + this.houses = data + this.getBuildingInfo() + }) + } + + isMapLabel:boolean //地图标注位置 @@ -88,6 +117,7 @@ export class BasicinfoComponent implements OnInit { isGisTopBoxTwo:boolean = false//点击位置按钮 oldPositionMarker:any //旧位置marker实例 newPositionMarker:any //新位置marker实例 + newPositionMarkerContent:any = '<div class="custom-content-marker">' + ' <img src="/assets/images/newposition.png">' + @@ -118,46 +148,45 @@ export class BasicinfoComponent implements OnInit { }) } + //初始化地图 labelGis(){ this.map = new AMap.Map('container', { zoom:12 }) - - this.map.on('complete', () => { this.isGisTopBox = true }); - //输入提示 - var autoOptions = { - input: "tipinput" - }; - AMap.plugin(['AMap.PlaceSearch','AMap.AutoComplete'], ()=>{ - var auto = new AMap.AutoComplete(autoOptions); - this.placeSearch = new AMap.PlaceSearch(); //构造地点查询类 - auto.on("select", (e)=>{ - console.log(e) - console.log( this.newPositionMarker) - this.newPositionMarker.setPosition([e.poi.location.lng,e.poi.location.lat]) - this.markerPosition2 = {x: e.poi.location.lng, y: e.poi.location.lat} - this.map.setCenter([e.poi.location.lng,e.poi.location.lat]); //设置地图中心点 - });//注册监听,当选中某条记录时会触发 + //输入提示 + var autoOptions = { + input: "tipinput" + }; + AMap.plugin(['AMap.PlaceSearch','AMap.AutoComplete'], ()=>{ + var auto = new AMap.AutoComplete(autoOptions); + this.placeSearch = new AMap.PlaceSearch(); //构造地点查询类 + auto.on("select", (e)=>{ + // console.log(e) + // console.log( this.newPositionMarker) + this.newPositionMarker.setPosition([e.poi.location.lng,e.poi.location.lat]) + this.markerPosition2 = {x: e.poi.location.lng, y: e.poi.location.lat} + this.map.setCenter([e.poi.location.lng,e.poi.location.lat]); //设置地图中心点 + });//注册监听,当选中某条记录时会触发 - }); + }); - if(this.isMapLabel){//如果已经标注单位坐标 - console.log('已标注单位位置') - this.map.setCenter([this.unitinfo.location.x,this.unitinfo.location.y]); - this.oldPositionMarker = new AMap.Marker({ - position: [this.unitinfo.location.x,this.unitinfo.location.y], - content: this.newPositionMarkerContent, - offset: new AMap.Pixel(-15, -18) - }) - // 将 markers 添加到地图 - this.map.add(this.oldPositionMarker); - }else{ - console.log('未标注单位位置') - this.map.setCity('上海市'); - } + if(this.isMapLabel){//如果已经标注单位坐标 + // console.log('已标注单位位置') + this.map.setCenter([this.unitinfo.location.x,this.unitinfo.location.y]); + this.oldPositionMarker = new AMap.Marker({ + position: [this.unitinfo.location.x,this.unitinfo.location.y], + content: this.newPositionMarkerContent, + offset: new AMap.Pixel(-15, -18) + }) + // 将 markers 添加到地图 + this.map.add(this.oldPositionMarker); + }else{ + // console.log('未标注单位位置') + this.map.setCity('上海'); + } } markerPosition2 //点击位置按钮 @@ -165,7 +194,7 @@ export class BasicinfoComponent implements OnInit { this.isGisTopBox = false this.isGisTopBoxTwo = true if(this.isMapLabel){//如果已经标注单位坐标 - console.log('已标注单位位置') + // console.log('已标注单位位置') if(this.oldPositionMarker){ this.oldPositionMarker.setContent(this.oldPositionMarkerContent) @@ -219,7 +248,7 @@ export class BasicinfoComponent implements OnInit { }) }else{ - console.log('未标注单位位置') + // console.log('未标注单位位置') if(this.newPositionMarker){ this.newPositionMarker.setContent(this.oldPositionMarkerContent) } @@ -276,22 +305,25 @@ export class BasicinfoComponent implements OnInit { } })//取消 } + + + } + + //获得所有单位类型 - allunittype: any //所有单位类型 getallunittype() { this.http.get("/api/BuildingTypes/Simple").subscribe(data => { this.allunittype = data }) } //获得所有组织机构 - allorganizing:any = [] //所有组织机构 getorganization() { this.http.get('/api/Organizations').subscribe( (data: any) => { - this.allorganizing = data; + this.allorganizing = data this.dataSource.data = this.tree.toTree(data); let _this = this this.getunitinfo().then((e)=>{ @@ -342,7 +374,7 @@ export class BasicinfoComponent implements OnInit { }) this.selectedorganization = str.substr(1) } - } + } this.unitinfo = data resolve(this.unitinfo) this.selectedorganizationid = data.organizationId @@ -357,471 +389,196 @@ export class BasicinfoComponent implements OnInit { }) } - - //石油化工 装置信息 勾选框 - checkboxchange(item,e){ - if(item.buildingBasicGroups){ - item.buildingBasicGroups.forEach(item=>{ - if(item.name != "基本信息" && item.name != "装置信息"){ - item.submitted = e.checked - } - }) - } - } - - unitallbuilding:any = []//用于存储当前单位所有的建筑 - - - bigfor:any//循环(储罐信息+罐区信息)大组 - npdata:any = [] - newnpdata:any //用于存储石油化工 储罐信息/罐区情况的 datasource - - - deviceinfodata:any=[];//用于存储石油化工装置信息的数组 - zhuangzhiinfodatasource:any = [] //用于存储石油化工装置信息表格的数据来源 - newzhuangzhiinfodatasource:any= []//存储石油化工装置信息表格的 datasource形式 - devicedataSourcebox:any = [] //存储多个石油化工建筑的不同装置信息表格datasource - //在石油化工模板种点击增加装置信息 - adddeviceinfo(item){ - item.newzhuangzhiinfodatasource.push({ - name:"", - flow:"", - danger:"", - payattentionto:"" + //获得建筑自定义信息 + getbuildingCustomData(){ + this.http.get("/api/BuildingCustomData",{params:{ + buildingId:this.houses[this.selectedBuildingIndex].id + }}).subscribe(data=>{ + this.buildingCustomData = data }) - this.devicedataSourcebox[item.buildingId] = new MatTableDataSource<any>(item.newzhuangzhiinfodatasource) - } - //在石油化工模板种点击减少装置信息 - removedeviceinfo(item){ - if(item.newzhuangzhiinfodatasource.length>1){ - item.newzhuangzhiinfodatasource.pop() - }else{ - const config = new MatSnackBarConfig(); - config.verticalPosition = 'top'; - config.duration = 3000 - this.snackBar.open('只剩一行,无法删除','确定',config); - } - this.devicedataSourcebox[item.buildingId] = new MatTableDataSource<any>(item.newzhuangzhiinfodatasource) } - //数据格式化函数 将原始数据映射转化为表格需要的datasource - formatHandle(list) { - const result = [{}]; // tag 是从1开始,因此预置索引为0的项 - list.forEach((item) => { - const { tag, propertyName, propertyValue } = item; - if (result[tag] === undefined) { // 初始化对象 - result[tag] = {}; - } - const fieldMap = { // 字段映射,实现自动映射 - '罐区': 'tank', - '储罐编号': 'tankid', - '储存介质': 'tankmedium', - '储罐类型': 'tanktype', - '容量': 'tankcapacity', - '直径': 'tankdiameter', - '高度': 'tankheight', - '顶盖形式': 'tanktectum', - '浮盘材质': 'tanktexture', - '浮盘类型': 'platetype', - '泡沫产生器型号': 'foamgeneratorid', - '泡沫产生器形式': 'foamgeneratortype', - '是否设置氮封惰化保护装置': 'isprotect', - '防护堤高度': 'fendinggroyneheight', - '半固定泡沫灭火接口数量': 'portnum', - '其它设施': 'else' - }; - result[tag][fieldMap[propertyName]] = propertyValue; + //点击+号 增加建筑 + addhouseinfo() { + const dialogRef = this.dialog.open(AddHouseInfo, {//调用open方法打开对话框并且携带参数过去 + width: '260px', + data: {unitinfo:this.unitinfo,unitId:this.unitId} }); - result.shift(); // 移除预置的 索引为0 的值 - return result; - } - - //将模板信息加工成附带自定义属性的信息 - getunithouse(data,n,x){ //data是原始模板在此基础上加工 n是当前建筑名称和建筑id、 x是当前循环的item信息 - data[0].buildingtypeId = n.id - data[0].name = x.name - data[0].username =x.name - data[0].buildtype = n.name - data[0].tongyong = true - data[0].index = x.index - if(data[0].buildtype.indexOf('化工') != -1 || data[0].buildtype.indexOf('储罐') != -1){ - data[0].tongyong = false - data[0].isshiyou = true - this.deviceinfodata = data[0].buildingBasicGroups[1].propertyInfos //存储装置信息的初始数据,需要转换成datasource形式 - var map = [] - this.deviceinfodata.forEach((item,index) => { - if(item.tag == ""){ - item.tag = "1" - } - if(!(item.tag in map)){ - map[item.tag] = [] - } - map[item.tag].push(item) - }); - let zhuangzhiinfodatasource = [] - map.forEach((item,index)=>{ - zhuangzhiinfodatasource[index] = {} - item.forEach(i => { - if (i.propertyName == "装置区名称") { - zhuangzhiinfodatasource[index].name = i.propertyValue - } - if (i.propertyName == "工艺流程") { - zhuangzhiinfodatasource[index].flow = i.propertyValue - } - if (i.propertyName == "火灾危险性") { - zhuangzhiinfodatasource[index].danger = i.propertyValue - } - if (i.propertyName == "灭火注意事项") { - zhuangzhiinfodatasource[index].payattentionto = i.propertyValue - } - }); - }) - this.newzhuangzhiinfodatasource =[] //数据去空 - zhuangzhiinfodatasource.forEach(item=>{ - if(item !== "" && item != undefined){ - this.newzhuangzhiinfodatasource.push(item) + dialogRef.afterClosed().subscribe( + async data => { + if(data){ + this.houses.push(data) + // console.log('新增了',this.houses) } - }) - this.devicedataSourcebox[data[0].buildingId] = new MatTableDataSource<any>(this.newzhuangzhiinfodatasource) - data[0].newzhuangzhiinfodatasource = this.newzhuangzhiinfodatasource - - - //把bigfor分组取出来 先大循环 (储罐信息---储罐信息/罐区情况)为一组 - let noemptybigfordata = data[0].buildingBasicGroups - // if(noemptybigfordata.length > 4){ - // noemptybigfordata.forEach((item,index) => { - // if(!item.submitted && item.name !="装置信息"){ - // noemptybigfordata.splice(index, 1) - // } - // }) - // } - let bigtankgroups = noemptybigfordata.slice(2) - // console.log("bigtankgroups",bigtankgroups) - let proportion = 2; //按照比例切割 - let num = 0; - let bigfor =[]; - for(let i=0;i<bigtankgroups.length;i++){ - if(i % proportion == 0 && i != 0){ - bigfor.push(bigtankgroups.slice(num,i)); - num = i; - } - if((i+1)==bigtankgroups.length){ - bigfor.push(bigtankgroups.slice(num,(i+1))); - } } - var map2 = [] - let tankdetailindo = [] - let noemptyArr = [] - - //bigfor决定当前储罐分组有几个 - - bigfor.forEach(item=>{ - item[1].propertyInfos.forEach(item => { - if(item.tag == ""){ - item.tag = 1 - } - }); - item[1].propertyInfos = this.formatHandle(item[1].propertyInfos) - - }) - data[0].bigfor = bigfor - } - // if(data[0].buildtype == "地铁类"){ - // data[0].tongyong = true - // // data[0].ditie = true - // } - return data[0] - } - - //点击建筑自定义信息的checkbox - isCustomData = false - checkCustomData(e){ - this.isCustomData = e.checked - } - //增加自定义信息行数 - addCustomData(item){ - item.buildingCustomData.customProperties.push({ - name: "", - value: "" - }) - } - //删除自定义信息行数 - deleteCustomData(item){ - item.buildingCustomData.customProperties.pop() + ); } - //得到建筑信息数据并进行处理 - allBuildings:any //当前单位所有的建筑 - houses: any = [] //存储当前单位的建筑信息 - basicCategoryId:any //当前单位所有建筑中位于第一个的建筑类型id - presentbuildinfoId:any //用于存储当前单位第一个建筑的具体id - buildinginfoId:any = []//用于存储当前单位所有具体建筑的id - getunitallbuilding(){ - this.houses = [] + //获得建筑的全部信息放到对应houses数组的建筑中 + selectedBuildingIndex:number = 0 + getBuildingInfo(){ this.unitId = this.route.snapshot.queryParams.id - this.http.get("/api/Buildings",{ + this.http.get("/api/BuildingBasicInfos",{ // 循环请求当前单位建筑每一个建筑的信息保存到数组中 params:{ - companyId:this.unitId + companyId :this.unitId, + buildingId:this.houses[this.selectedBuildingIndex].id, + buildingType:this.houses[this.selectedBuildingIndex].buildingTypes[0].id } - }).subscribe(async (data:any)=>{ // 获得当前单位所有的建筑 - console.log('所有建筑',data) - this.allBuildings = data - if(data.length != 0){//如果存在建筑 - this.basicCategoryId = data[0].buildingTypes[0].id - this.presentbuildinfoId = data[0].id // 用于存储当前单位第一个建筑的id - for (let i = 0, length = data.length; i < length; i++) {//循环所有建筑 - const n = data[i]; - const index = i; - this.buildinginfoId.push(n.id) - const result = await new Promise((resolve) => { - this.http.get("/api/BuildingBasicInfos",{ // 循环请求当前单位建筑每一个建筑的信息保存到数组中 - params:{ - companyId :this.unitId, - buildingId:n.id, - buildingType:n.buildingTypes[0].id - } - }).subscribe((data)=>{ - //获得当前建筑自定义信息并且添加到建筑属性对象中 - let _data = data - console.log('当前建筑信息'+index,data) - this.http.get("/api/BuildingCustomData",{params:{ - buildingId:n.id - }}).subscribe((data:any)=>{ - console.log('当前建筑自定义信息'+index,data) - _data[0].buildingCustomData = data - if(data && data.customProperties.length != 0){ - _data[0].isCustomData = true - }else{ - _data[0].isCustomData = false - _data[0].buildingCustomData = { - id: "", - customProperties: [ - { - name: "", - value: "" - } - ], - buildingId: _data[0].buildingId - } - } - }) - //为每个建筑添加建筑名称等自定义属性 用于显示使用 - data[0].buildingtypeId = n.buildingTypes[0].id - data[0].name = n.name - data[0].username = n.name - data[0].buildtype = n.buildingTypes[0].name - data[0].tongyong = true - data[0].index = index - - if(data[0].buildtype.indexOf('化工') != -1 || data[0].buildtype.indexOf('储罐') != -1){ - data[0].tongyong = false - data[0].isshiyou = true - let noemptydeviceArr = data[0].buildingBasicGroups[1].propertyInfos - noemptydeviceArr.forEach((item,index) => { - if(item.tag == ""){ - noemptydeviceArr.splice(index,1) - } - }); - this.deviceinfodata = noemptydeviceArr //存储装置信息的初始数据,需要转换成datasource形式 - var map = [] - this.deviceinfodata.forEach((item,index) => { - if(!data[0].buildingBasicGroups[1].submitted){ - if(item.tag == ""){ - item.tag = "1" - } - } - - if(!(item.tag in map)){ - map[item.tag] = [] - } - map[item.tag].push(item) - }); - let zhuangzhiinfodatasource = [] - map.forEach((item,index)=>{ - zhuangzhiinfodatasource[index] = {} - item.forEach(i => { - if (i.propertyName == "装置区名称") { - zhuangzhiinfodatasource[index].name = i.propertyValue - } - if (i.propertyName == "工艺流程") { - zhuangzhiinfodatasource[index].flow = i.propertyValue - } - if (i.propertyName == "火灾危险性") { - zhuangzhiinfodatasource[index].danger = i.propertyValue - } - if (i.propertyName == "灭火注意事项") { - zhuangzhiinfodatasource[index].payattentionto = i.propertyValue - } - }); - }) - this.newzhuangzhiinfodatasource =[] //数据去空 - zhuangzhiinfodatasource.forEach(item=>{ - if(item !== "" && item != undefined){ - this.newzhuangzhiinfodatasource.push(item) - } - }) - this.devicedataSourcebox[data[0].buildingId] = new MatTableDataSource<any>(this.newzhuangzhiinfodatasource) - data[0].newzhuangzhiinfodatasource = this.newzhuangzhiinfodatasource - - //把bigfor分组取出来 先大循环 (储罐信息---储罐信息/罐区情况)为一组 - let noemptybigfordata = data[0].buildingBasicGroups - - let bigtankgroups = noemptybigfordata.slice(2) - let proportion = 2; //按照比例切割 - let num = 0; - let bigfor =[]; - for(let i=0;i<bigtankgroups.length;i++){ - if(i % proportion == 0 && i != 0){ - bigfor.push(bigtankgroups.slice(num,i)); - num = i; - } - if((i+1)==bigtankgroups.length){ - bigfor.push(bigtankgroups.slice(num,(i+1))); - } + }).subscribe((data)=>{ + // console.log('当前选择建筑的基础信息',data) + //需要处理一下表格信息 + data[0].buildingBasicGroups.forEach(element => { + //需要处理一下表格信息 + if(element.type == 1){ + let afterData = [] + let tempArr = []; + for (let i = 0; i < element.propertyInfos.length; i++) { + element.propertyInfos[i].tag == '' ? element.propertyInfos[i].tag = 1 : null + if (tempArr.indexOf(element.propertyInfos[i].tag) === -1) { + afterData.push({ + tag: element.propertyInfos[i].tag, + origin: [element.propertyInfos[i]] + }); + tempArr.push(element.propertyInfos[i].tag); + } else { + for (let j = 0; j < afterData.length; j++) { + if (afterData[j].tag == element.propertyInfos[i].tag) { + afterData[j].origin.push(element.propertyInfos[i]); + break; } - - - - //bigfor决定当前储罐分组有几个 - bigfor.forEach((item,index)=>{ - - item[1].propertyInfos = this.formatHandle(item[1].propertyInfos) - - }) - data[0].bigfor = bigfor } - resolve(data[0]) //把数据传递出去 - }) + } + } + function compare(property){ + return function(a,b){ + var value1 = a[property]; + var value2 = b[property]; + return value1 - value2; + } + } + afterData.forEach(item =>{ + item.origin = item.origin.sort(compare('order')) }) - this.houses.push(result) // 并且把他添加到 tab 总体数组中 + element.propertyInfos = afterData.sort(compare('tag')) + // console.log(afterData,888); } + }); + let guanquIndex = data[0].buildingBasicGroups.findIndex(item => item.name.indexOf('罐区')>=0); // 找到第一个灌区的索引 + function transferFn(arr) { + const guanquIndex = arr.findIndex(item => item.name.indexOf('罐区')>=0); // 找到第一个灌区的索引 + + const guanquList = arr.slice(guanquIndex); // 灌区的列表 + const baseList = arr.slice(0, guanquIndex); // 前面的数据 + const len = guanquList.length; + const num = len/2; // 计算一共有多少对,这里的前提是数据本身必须成对出现 + // 灌区切割出来的数据,分别存放,最后做一下合并 + const array1 = []; + const array2 = []; + for(let i = 0; i<num; i++) { + array1.push(guanquList[i]); // 灌区x + array2.push(guanquList[i + num]); // 灌区x/储罐信息 + } + // 拼接最后的数据 + const result = [...baseList]; + for(let i = 0, ll = array1.length; i < ll; i++){ + result.push(array1[i]); + if (array2[i]) { + result.push(array2[i]); + } + } + return result; } + if(guanquIndex != -1 && data[0].buildingBasicGroups[guanquIndex + 1].name.indexOf(data[0].buildingBasicGroups[guanquIndex].name) == -1){ + data[0].buildingBasicGroups = transferFn(data[0].buildingBasicGroups) + } + this.houses[this.selectedBuildingIndex].data = data + //获得自定义信息 + this.http.get("/api/BuildingCustomData",{params:{ //-----处理建筑自定义属性部分 + buildingId:this.houses[this.selectedBuildingIndex].id + }}).subscribe((data:any)=>{ + if(data && data.customProperties.length != 0){ + this.houses[this.selectedBuildingIndex].customData = data + this.houses[this.selectedBuildingIndex].isCustomData = true + }else{ + this.houses[this.selectedBuildingIndex].isCustomData = false + this.houses[this.selectedBuildingIndex].customData = { + id: "", + customProperties: [{name:'',value:''}], + buildingId: this.houses[this.selectedBuildingIndex].id + } + } + }) }) - } - - unitinfotemplate:any //存储选择不同单位类型时的模板信息 - displayedColumns: string[]=['name', 'flow','danger','payattentionto']; - displayedColumns2: string[]=['tank','tankid', 'tankmedium','tanktype','tankcapacity','tankdiameter', 'tankheight','tanktectum','tanktexture','platetype', 'foamgeneratorid','foamgeneratortype','isprotect','fendinggroyneheight', 'portnum','else']; - devicedataSource:any; //存储石油化工模板中的装置信息表格 - tankinfodatabox:any = [ - [] - ] - // dataSourceArr = [] - tankinfodata:any=[];//用于存储石油化工储罐信息的数组 - adddeviceinfo2(e,item){//点击加一行 视图上多一行 - item.bigfor[e][1].propertyInfos.push({ - tank:"", - tankid:"", - tankmedium:"", - tanktype:"", - tankcapacity:"", - tankdiameter:"", - tankheight:"", - tanktectum:"", - tanktexture:"", - platetype:"", - foamgeneratorid:"", - foamgeneratortype:"", - isprotect:"", - fendinggroyneheight:"", - portnum:"", - else:"" - }) - item.bigfor[e][1].propertyInfos = [...item.bigfor[e][1].propertyInfos] + //点击选项卡 + selectedTabChange(e){ + // console.log(e) + this.selectedBuildingIndex = e.index + if((this.houses[this.selectedBuildingIndex].data && !this.houses[this.selectedBuildingIndex].data.length) || !this.houses[this.selectedBuildingIndex].data){ + this.getBuildingInfo() + } } - removedeviceinfo3(e,item){//点击减一行 - var isdeleted = confirm("确定要删除末行吗?") - if(isdeleted){ - if(item.bigfor[e][1].propertyInfos.length > 1){ - item.bigfor[e][1].propertyInfos.pop() - }else{ - const config = new MatSnackBarConfig(); - config.verticalPosition = 'top'; - config.duration = 3000 - this.snackBar.open('只剩一行,无法删除','确定',config); - } - item.bigfor[e][1].propertyInfos = [...item.bigfor[e][1].propertyInfos] + //表格加一行 + addline(ele){ + let newObj = JSON.parse(JSON.stringify(ele[0])) + for (let index = 0; index < newObj.origin.length; index++) { + const element = newObj.origin[index]; + element.propertyValue = "" + element.tag = Number(ele[ele.length - 1].tag) + 1 } - + newObj.tag = Number(ele[ele.length - 1].tag) + 1 + ele.push(newObj) } - - - //增加储罐大分组 - //在石油化工模板种点击增加储罐信息 - //获得模板信息 - templateinfo:any - gettemplateinfo(typeid){ - + //表格减一行 + removeline(ele){ + if(ele.length>1){ + ele.pop() + }else{ + const config = new MatSnackBarConfig(); + config.verticalPosition = 'top'; + config.duration = 3000 + this.snackBar.open('只剩一行,无法删除','确定',config); + } } - - addtankbox(item,bigkey){ - this.http.get("/api/BuildingBasicInfos",{ - params:{ - companyId : this.unitId, - buildingType:item.buildingtypeId - } - }).subscribe((data:any)=>{ - // console.log(1314,data) - // console.log(777,data[0]) - item.bigfor.push([ - { - id: "", - name: "罐区"+ (item.bigfor.length+ 1), - type: 0, - addMode: 2, - basicGroupId:'', - basicCategoryId: item.basicCategoryId, - buildingBasicId: null, - buildingId: item.buildingId, - companyId: this.unitinfo.id, - enabled: true, - order: item.bigfor.length+2, - propertyInfos:data[0].buildingBasicGroups[2].propertyInfos - }, - { - addMode: 2, - basicCategoryId:item.basicCategoryId, - buildingBasicId:null, - buildingId: item.buildingId, - companyId: this.unitinfo.id, - enabled: true, - basicGroupId:'', - id: "", - name: "罐区" + (item.bigfor.length+ 1) +"/储罐信息", - order: item.bigfor.length+3, - propertyInfos: [ - { - else: "", - fendinggroyneheight: "", - foamgeneratorid: "", - foamgeneratortype: "", - isprotect: "", - platetype: "", - portnum: "", - tank: "", - tankcapacity: "", - tankdiameter: "", - tankheight: "", - tankid: "", - tankmedium: "", - tanktectum: "", - tanktexture: "", - tanktype: "" - } - ], - type: 1 - } - - ]) + //建筑自定义信息加一行 + addCustomData(item){ + item.customData.customProperties.push({ + name:'', + value:'' }) - } - //移除储罐大分组 - removetankbox(item,bigkey){ - if(item.bigfor.length > 1){ + //建筑自定义信息减一行 + popCustomData(item){ + item.customData.customProperties.pop() + } + //储罐加一组 + addTankBox(item,groupsIndex){ + //取出现在最后一个罐区的数字 + let num = (item.data[0].buildingBasicGroups[item.data[0].buildingBasicGroups.length - 1].name).replace(/[^0-9]/ig,"") + let obj1 = JSON.parse(JSON.stringify(item.data[0].buildingBasicGroups[groupsIndex])) + let obj2 = JSON.parse(JSON.stringify(item.data[0].buildingBasicGroups[groupsIndex + 1])) + obj1.name = '罐区' + (Number(num) + 1) + obj2.name = '罐区' + (Number(num) + 1) + '/储罐信息' + // console.log(obj2) + obj1.propertyInfos.forEach(element => { + element.propertyValue = '' + }); + let newArr = [obj2.propertyInfos[0]] + obj2.propertyInfos = newArr + obj2.propertyInfos[0].origin.forEach(element => { + element.propertyValue = '' + }); + item.data[0].buildingBasicGroups.push(obj1) + item.data[0].buildingBasicGroups.push(obj2) + // console.log(item.data[0].buildingBasicGroups) + } + //储罐减一组 + removeTankBox(item,groupsIndex){ + let num = (item.data[0].buildingBasicGroups[item.data[0].buildingBasicGroups.length - 1].name).replace(/[^0-9]/ig,"") + if(num != 1){ var isdeleted = confirm("确定要删除末尾储罐分组吗?") if(isdeleted){ - item.bigfor.pop() + item.data[0].buildingBasicGroups.pop() + item.data[0].buildingBasicGroups.pop() } }else{ const config = new MatSnackBarConfig(); @@ -830,150 +587,6 @@ export class BasicinfoComponent implements OnInit { this.snackBar.open('只剩唯一储罐,无法删除','确定',config); } } - - //新建建筑时把原始建筑数据放进来进行加工处理成可用数据 - async changebuildingdata(data){ - let n = data - let yyy - let result = await new Promise(resolve=>{ - this.http.get("/api/BuildingBasicInfos",{ // 需要请求建筑信息的模板 - params:{ - companyId : this.unitId, - buildingId:data.id, - buildingType:data.buildingTypes[0].id - } - }).subscribe((data)=>{//此时的data才是模板详细信息 - let _data = data - this.http.get("/api/BuildingCustomData",{params:{ //-----处理建筑自定义属性部分 - buildingId:n.id - }}).subscribe(data=>{ - if(data){ - _data[0].isCustomData = true //如果data存在则把自定义属性isCustomData设为true - _data[0].buildingCustomData = data //把建筑自定义信息赋给buildingCustomData自定义属性 - }else{ - _data[0].isCustomData = false - _data[0].buildingCustomData ={ //否则设为false,并且把自定义信息属性赋值为空 - id: "", - customProperties: [ - { - name: "", - value: "" - } - ], - buildingId: _data[0].buildingId - } - } - }) - data[0].buildingtypeId = n.buildingTypes[0].id - data[0].buildtype = n.buildingTypes[0].name - data[0].name = n.name - data[0].username = n.name - data[0].tongyong = true - data[0].index = this.houses.length ////////////////// - if(data[0].buildtype.indexOf('化工') != -1 || data[0].buildtype.indexOf('储罐') != -1){ - data[0].tongyong = false - data[0].isshiyou = true //如果是石油化工则启用石油化工的模板 - this.deviceinfodata = data[0].buildingBasicGroups[1].propertyInfos //存储装置信息表格的初始数据,需要转换成datasource形式 - var map = [] - this.deviceinfodata.forEach((item,index) => { - if(item.tag == ""){ - item.tag = "1" - } - if(!(item.tag in map)){ - map[item.tag] = [] - } - map[item.tag].push(item) - }); - let zhuangzhiinfodatasource = [] - map.forEach((item,index)=>{ - zhuangzhiinfodatasource[index] = {} - item.forEach(i => { - if (i.propertyName == "装置区名称") { - zhuangzhiinfodatasource[index].name = i.propertyValue - } - if (i.propertyName == "工艺流程") { - zhuangzhiinfodatasource[index].flow = i.propertyValue - } - if (i.propertyName == "火灾危险性") { - zhuangzhiinfodatasource[index].danger = i.propertyValue - } - if (i.propertyName == "灭火注意事项") { - zhuangzhiinfodatasource[index].payattentionto = i.propertyValue - } - }); - }) - this.newzhuangzhiinfodatasource =[] //数据去空 - zhuangzhiinfodatasource.forEach(item=>{ - if(item !== "" && item != undefined){ - this.newzhuangzhiinfodatasource.push(item) - } - }) - this.devicedataSourcebox[data[0].buildingId] = new MatTableDataSource<any>(this.newzhuangzhiinfodatasource) //强制渲染表格 - data[0].newzhuangzhiinfodatasource = this.newzhuangzhiinfodatasource - - - //把bigfor分组取出来 先大循环 (储罐信息---储罐信息/罐区情况)为一组 - let bigtankgroups = data[0].buildingBasicGroups.slice(2) - let proportion = 2; //按照比例切割 - let num = 0; - let bigfor =[]; - for(let i=0;i<bigtankgroups.length;i++){ - if(i % proportion == 0 && i != 0){ - bigfor.push(bigtankgroups.slice(num,i)); - num = i; - } - if((i+1)==bigtankgroups.length){ - bigfor.push(bigtankgroups.slice(num,(i+1))); - } - } - var map2 = [] - let tankdetailindo = [] - let noemptyArr = [] - - //bigfor决定当前储罐分组有几个 - - bigfor.forEach(item=>{ - item[1].propertyInfos.forEach(item => { - if(item.tag == ""){ - item.tag = 1 - } - }); - item[1].propertyInfos = this.formatHandle(item[1].propertyInfos) - }) - data[0].bigfor = bigfor - } - if(data[0].buildtype == "地铁类"){ - data[0].tongyong = true - // data[0].ditie = true - } - yyy = data[0] - resolve(yyy) - }) - }) - return result - } - - //点击+号 增加建筑 - addhouseinfo() { - const dialogRef = this.dialog.open(AddHouseInfo, {//调用open方法打开对话框并且携带参数过去 - width: '260px', - data: {unitinfo:this.unitinfo,allBuildings:this.allBuildings,unitId:this.unitId} - }); - dialogRef.afterClosed().subscribe( - async data => { - if(data){ - let newbuilding = await this.changebuildingdata(data) - this.houses.push(newbuilding) - this.tabbarService.sendMessage('changeScore');//通知服务改变分数 - } - } - ); - } - - //点击不同的tab选项 - selecttab(e) { - } - FunData(e){//切割数组 let proportion = 2; //按照比例切割 let num = 0; @@ -993,7 +606,6 @@ export class BasicinfoComponent implements OnInit { //点击辖区中队树,将选择的辖区中队添加到变量 add(node) { - // console.log(node) this.selectedorganizationid = node.id this.isorganizationbox = false @@ -1018,13 +630,11 @@ export class BasicinfoComponent implements OnInit { this.selectedorganization = str.substr(1) } -} - + } //关闭辖区中队隐藏框 closeorganizationbox() { this.isorganizationbox = false } - //打开辖区中队隐藏框 openorganizationbox() { this.isorganizationbox = true @@ -1033,8 +643,7 @@ export class BasicinfoComponent implements OnInit { hasChild = (_: number, node: any) => node.expandable; imgsrc = "" //没有上传图片时显示的图片,当上传后就会被替换,即保存时需要传的图片地址参数 - noImgSrc = '../../../assets/images/upload.jpg' - // imgsrc = "" + noImg = '../../../assets/images/upload.jpg' imgUrl = ""//返回来的图片地址后缀 file: any; //上传的文件 objectName: any; //上传对象名 @@ -1061,7 +670,7 @@ export class BasicinfoComponent implements OnInit { this.startUploading() } } - + }, 500); } //查看单位大图 @@ -1072,7 +681,7 @@ export class BasicinfoComponent implements OnInit { data: {img:this.imgsrc} }); dialogRef.afterClosed().subscribe( - + ); } //上传文件 @@ -1083,6 +692,7 @@ export class BasicinfoComponent implements OnInit { let shardSize = 5 * 1024 * 1024 //5MB一个分片 if (file && fileSize <= shardSize) { //上传文件<=5MB时 + // this.upload() let formData = new FormData() formData.append("file",file) this.http.post(`/api/Objects/PlanPlatform/${sessionStorage.getItem('companyId')}`,formData).subscribe((data:any)=>{ @@ -1104,7 +714,36 @@ export class BasicinfoComponent implements OnInit { }) } } - + + //小于5MB不需要分块上传 + upload(){ + this.uploader.queue[0].upload();//开始上传 + this.uploader.queue[0].onSuccess = (response, status, headers) => { + // 上传文件成功 + if (status == 201) { + // 上传文件后获取服务器返回的数据 + const config = new MatSnackBarConfig(); + config.verticalPosition = 'top'; + config.duration = 3000 + this.snackBar.open('上传成功','确定',config); + this.isspinner = false + let tempRes = JSON.parse(response); + this.imgUrl = tempRes.objectName + this.imgsrc = `/api/Objects/PlanPlatform/${this.imgUrl}?x-oss-process=image/resize,m_fill,h_170,w_299` + }else { + // 上传文件后获取服务器返回的数据错误 + } + }; + this.uploader.queue[0].onError = (response, status, headers) => { + if (status == 401) { + const config = new MatSnackBarConfig(); + config.verticalPosition = 'top'; + config.duration = 3000 + this.snackBar.open('上传失败','确定',config); + } + }; + } + //开始分块上传 async subsectionUploading () { let file = this.file || null //获取上传的文件 @@ -1117,6 +756,7 @@ export class BasicinfoComponent implements OnInit { let end = Math.min(fileSize, start + shardSize); //切割文件结束位置 let formData = new FormData() formData.append("file",file.slice(start, end)) + // 同步写法实现异步调用 let result = await new Promise((resolve, reject) => { // await 需要后面返回一个 promise 对象 @@ -1142,21 +782,26 @@ export class BasicinfoComponent implements OnInit { this.imgsrc = `/api/Objects/PlanPlatform/${this.objectName}?x-oss-process=image/resize,m_fill,h_170,w_299` this.isspinner = false this.PartNumberETag = [] + this.uploader.clearQueue(); //清空input控件文件 }) } //删除具体建筑 - deletedbuilding(item){ + selectedIndex + deletedbuilding(item,key){ + // console.log(item) var isdeleted = confirm("确定要删除此建筑吗?") if(isdeleted){ - //请求删除接口 - this.http.delete(`/api/Buildings/${item.buildingId}`).subscribe(data=>{ - + // console.log(key) + // 请求删除接口 + this.http.delete(`/api/Buildings/${item.id}`).subscribe(data=>{ const config = new MatSnackBarConfig(); config.verticalPosition = 'top'; config.duration = 3000 this.snackBar.open('删除成功','确定',config); this.houses.splice(this.houses.findIndex(items=>items==item),1) - this.tabbarService.sendMessage('changeScore');//通知服务改变分数 + + let obj ={index:key} + this.selectedTabChange(obj) }) } } @@ -1166,7 +811,7 @@ export class BasicinfoComponent implements OnInit { if(invalid){ const config = new MatSnackBarConfig(); config.verticalPosition = 'top'; - config.duration = 3000 + config.duration = 3000 this.snackBar.open('请填写必填项','确定',config); }else{ sessionStorage.setItem('buildingTypeId',value.unittype) @@ -1191,18 +836,17 @@ export class BasicinfoComponent implements OnInit { ] } this.http.put(`/api/Companies/${this.unitId}`,body).subscribe((data:any)=>{ //修改单位基本信息 - this.getunitinfo() + // this.getunitinfo() if(!this.houses.length){ const config = new MatSnackBarConfig(); config.verticalPosition = 'top'; config.duration = 3000 this.snackBar.open('单位基本信息保存成功,请填写单位建筑模板信息','确定',config); // alert("单位基本信息保存成功,请填写单位建筑模板信息") - let order = 0 let addbody = { //请求创建单位基本信息成功后 直接创建出一个主体建筑模板 id: "",//即将要生成具体建筑的id name: "主体建筑", - order: order, + order: 0, enabled: true, companyId: this.unitinfo.id, buildingTypes: [ @@ -1212,18 +856,15 @@ export class BasicinfoComponent implements OnInit { } ] } - this.http.post("/api/Buildings",addbody,{params:{ - companyId : this.unitId - }}).subscribe(data=>{//首先创建建筑成功了,需要刷出当前建筑类型的模板 - this.getunitallbuilding() + this.http.post("/api/Buildings",addbody).subscribe(data=>{//首先创建建筑成功了,需要刷出当前建筑类型的模板 + // alert('创建主体建筑成功') + this.getUnitAllBuildings() }) - this.tabbarService.sendMessage('changeScore');//通知服务改变分数 }else{ const config = new MatSnackBarConfig(); config.verticalPosition = 'top'; config.duration = 3000 this.snackBar.open('保存成功','确定',config); - this.tabbarService.sendMessage('changeScore');//通知服务改变分数 } }), err=>{ @@ -1241,8 +882,6 @@ export class BasicinfoComponent implements OnInit { isshowrule:boolean = false rulevalue:any inputchange(e,name,value,item){ - // console.log(e.target.value,name,value,item) - // console.log(item) if(name == "≥"){ if(Number(e.target.value)< Number(value)){ item.isshowrule = true @@ -1270,934 +909,217 @@ export class BasicinfoComponent implements OnInit { } } } + + //可选按钮 + checkboxChange(item,$event,buildingData){ + // console.log(item) + if(item.name == '罐区1'){ + // console.log(buildingData) + buildingData.data[0].buildingBasicGroups.forEach(element => { + if(element.name.indexOf('罐区') != -1){ + element.submitted = item.submitted + } + }); + } + } + + //建筑自定义信息按钮 + checkCustomData($event){ + + } + - //切换建筑类型 - templatebuildtype(n ,item,key){ - this.http.get("/api/Buildings",{ - params:{ - companyId:this.unitId - } - }).subscribe((data:any)=>{ - this.allBuildings = data - this.http.put(`/api/Buildings/${item.buildingId}`,{ //修改当前建筑类型 - id: item.buildingId, - name: item.housename, - order: this.allBuildings[key].order, + //提交建筑信息 + onSubmitBuildingInfo(value,item,key,invalid){ + // console.log(1,item) + // console.log(2,invalid) + // console.log(3,value) + // console.log(4,this.allunittype) + if(invalid){ + const config = new MatSnackBarConfig(); + config.verticalPosition = 'top'; + config.duration = 3000 + this.snackBar.open('请填写必填项','确定',config); + }else { + //先把名称和建筑类型单独修改 + let buildingTypeId + this.allunittype.forEach(element => { + element.name == item.buildingTypes[0].name ? buildingTypeId = element.id : null + }); + this.http.put(`/api/Buildings/${item.id}`,{ //(通用)只修改建筑名称和建筑类型 + id: item.id, + name: value.buildingName, + order: this.houses[key].order, enabled: true, companyId: this.unitinfo.id, buildingTypes: [ { - id: n.id, - name: n.name - } + id: buildingTypeId, + name: item.buildingTypes[0].name + } ] },{ params:{ companyId : this.unitId } - }).subscribe(data=>{ - this.http.get("/api/BuildingBasicInfos",{//请求当前建筑类型的模板信息保存到数组中 - params:{ - companyId :this.unitId, - buildingId:item.buildingId, - buildingType:n.id - } - }).subscribe(data=>{ - this.getunithouse(data,n,item) - this.houses[item.index] = data[0] - - let _data = data - this.http.get("/api/BuildingCustomData",{params:{ - buildingId:item.buildingId - }}).subscribe((data:any)=>{ - _data[0].buildingCustomData = data - if(data && data.customProperties.length != 0){ - _data[0].isCustomData = true - }else{ - _data[0].isCustomData = false - _data[0].buildingCustomData ={ - id: "", - customProperties: [ - { - name: "", - value: "" - } - ], - buildingId: _data[0].buildingId - } - } - }) - }) + }).subscribe((data:any)=>{ + // alert("名称和类型保存成功") + }, + err=>{ + alert("名称和类型保存失败") }) - }) - - } - - deviceinfo=[] //用于存储石头化工的第一个表格 - //提交单位模板信息 - onSubmit2(value,item,key,invalid){ - this.http.get("/api/Buildings",{ - params:{ - companyId:this.unitId - } - }).subscribe((data:any)=>{ - this.allBuildings = data - if(invalid){ - const config = new MatSnackBarConfig(); - config.verticalPosition = 'top'; - config.duration = 3000 - this.snackBar.open('请填写必填项','确定',config); - }else{ - this.http.put(`/api/Buildings/${item.buildingId}`,{ //(通用)只修改建筑名称和建筑类型 - id: item.buildingId, - name: value.housename, - order: this.allBuildings[key].order, - enabled: true, - companyId: this.unitinfo.id, - buildingTypes: [ - { - id: item.buildingtypeId, - name: item.buildtype - } - ] - },{params:{ - companyId : this.unitId - }}).subscribe((data:any)=>{ - this.houses[item.index].username = item.name - }, - err=>{ - alert("名称和类型保存失败") - }) - - if(value.checkbuilding){//如果勾选了自定义信息的checkbox - var CustomDataval = [] - for (const key in value) { - if (key.indexOf("CustomData") != -1) { - CustomDataval.push(value[key]) - } + let newbody = JSON.parse(JSON.stringify(item.data)) //把数据深拷贝取出来进行操作 + for (let index = 0; index < newbody[0].buildingBasicGroups.length; index++) { + let element = newbody[0].buildingBasicGroups[index]; + element.propertyInfos.forEach(item => { + if(!element.isOptional){ + item.propertyValue ? element.submitted = true : null } - let newCustomData = this.FunData(CustomDataval) - let newCustomDataval = [] - newCustomData.forEach(n=>{ - newCustomDataval.push({ - name:n[0], - value:n[1] - }) - }) - let CustomDatabody = { - id: "", - customProperties: newCustomDataval, - buildingId: item.buildingId + //删除规则验证标识 + item.isshowrule ? delete item.isshowrule : null + item.rulevalue ? delete item.rulevalue : null + if(item.propertyValue || item.propertyValue == 0){ + item.propertyValue = String(item.propertyValue) } - this.http.post("/api/BuildingCustomData",CustomDatabody,{params:{ - companyId :this.unitId, - buildingId:item.buildingId - }}).subscribe(data=>{ + }); + //如果是表格需要转换为一维数组 + if(element.type == 1){ + let arr = [] + for (let index = 0; index < element.propertyInfos.length; index++) { + const ele = element.propertyInfos[index]; - }, - err=>{ - alert("自定义信息保存失败") - }) - }else{ - let CustomDatabody = { - id: "", - customProperties: [], - buildingId: item.buildingId + for (let index = 0; index < ele.origin.length; index++) { + const i = ele.origin[index]; + i.tag = String(i.tag) + + if(!element.isOptional){ + i.propertyValue ? element.submitted = true : null + } + arr.push(i) + } } - this.http.post("/api/BuildingCustomData",CustomDatabody,{params:{ - companyId :this.unitId, - buildingId:item.buildingId - }}).subscribe(data=>{ - - }, - err=>{ - alert("自定义信息保存失败") + for (let index = 0; index < arr.length; index++) { + const i = arr[index]; + i.order = index + } + element.propertyInfos = arr + } + //如果当前分组没勾选 则需先去重然后重置每一个value为空 + if(!element.submitted){ + const res = new Map(); + element.propertyInfos = element.propertyInfos.filter((a) => !res.has(a.propertyName) && res.set(a.propertyName, 1)) + element.propertyInfos.forEach(ele => { + ele.propertyValue = "" }) } - - - if(item.buildtype.indexOf('化工') == -1 && item.buildtype != "地铁类" && item.buildtype.indexOf('储罐') == -1){ - // console.log(this.houses[key]) - // console.log(value) - this.houses[key].buildingBasicGroups[0].propertyInfos.forEach(item => { - - if(item.propertyValue || item.propertyValue == 0){ - // item.propertyValue = "" + value[key] - item.propertyValue = String(item.propertyValue) - } - - }); - let newObj = _.cloneDeep(this.houses[key]) //把数据深拷贝取出来进行操作 - newObj.buildingBasicGroups[0].buildingId = item.buildingId - newObj.buildingBasicGroups[0].companyId = this.unitinfo.id - newObj.buildingBasicGroups[0].submitted = true //把是否提交过变为true - delete newObj.name - delete newObj.username - delete newObj.buildtype - delete newObj.tongyong - delete newObj.index - delete newObj.isCustomData - delete newObj.buildingCustomData - newObj.buildingBasicGroups[0].propertyInfos.forEach(item => { - delete item.isshowrule - delete item.rulevalue - }); - - let body = newObj - let newbody = [] - newbody.push(body) - if(newbody[0].buildingBasicGroups.length){ - this.http.post("/api/BuildingBasicInfos",newbody,{ - params:{ - companyId : this.unitId, - buildingId :newbody[0].buildingId - } - }).subscribe((data:any)=>{ - this.houses[key].id = data[0].id - const config = new MatSnackBarConfig(); - config.verticalPosition = 'top'; - config.duration = 3000 - this.snackBar.open('建筑信息保存成功','确定',config); - this.tabbarService.sendMessage('changeScore');//通知服务改变分数 - }, - err=>{ - const config = new MatSnackBarConfig(); - config.verticalPosition = 'top'; - config.duration = 3000 - this.snackBar.open('请检查输入数据是否有误','确定',config); - }) - } + //如果灌区没勾选 并且包含罐区且不包含罐区1的清除 需要把多余罐区2 3 4清除掉再提交 + if(!element.submitted && element.name.indexOf('罐区1') == -1 && element.name.indexOf('罐区') != -1){ + newbody[0].buildingBasicGroups.splice(index--, 1); } - if(item.buildtype.indexOf('化工') != -1 || item.buildtype.indexOf('储罐') != -1){ - // console.log(888,item) - let bodyObj = _.cloneDeep(item) - delete bodyObj.name - delete bodyObj.username - delete bodyObj.isshiyou - delete bodyObj.newzhuangzhiinfodatasource - delete bodyObj.tongyong - delete bodyObj.buildtype - delete bodyObj.buildingtypeId - delete bodyObj.bigfor - delete bodyObj.index - delete bodyObj.isCustomData - delete bodyObj.buildingCustomData - // console.log(456,bodyObj) - bodyObj.buildingBasicGroups[0].propertyInfos.forEach(item => { - delete item.isshowrule - delete item.rulevalue - }); - //修改基本信息 - bodyObj.buildingBasicGroups[0].propertyInfos.forEach(item => { - for (const key in value) { - if (item.propertyName == key) { - if(item.propertyValue || item.propertyValue == 0){ - // item.propertyValue = "" + value[key] - item.propertyValue = String(value[key]) - } - - } - } - }); - bodyObj.buildingBasicGroups[0].submitted = true - bodyObj.buildingBasicGroups[0].buildingId = item.buildingId - bodyObj.buildingBasicGroups[0].companyId = this.unitinfo.id - //石油化工类的 装置信息 就提交这个表单——————————————————————————————this.deviceinfo 记得清空 - // console.log(this.deviceinfodata) - if(bodyObj.buildingBasicGroups[1].submitted){ //如果用户点击了并填写了装置信息就提交这个表格数据 - this.deviceinfo = [] - item.newzhuangzhiinfodatasource.forEach((element,index) => { - this.deviceinfo.push({ - propertyName: "装置区名称", - propertyValue: element.name, - propertyType: 0, - required: true, - ruleName: "", - ruleValue: "", - physicalUnit: "", - order:0, - enabled: true, - visible: true, - tag: String(index + 1) - }, - { - propertyName: "工艺流程", - propertyValue: element.flow, - propertyType: 0, - required: true, - ruleName: "", - ruleValue: "", - physicalUnit: "", - order:1, - enabled: true, - visible: true, - tag: String(index + 1) - }, - { - propertyName: "火灾危险性", - propertyValue: element.danger, - propertyType: 0, - required: true, - ruleName: "", - ruleValue: "", - physicalUnit: "", - order:2, - enabled: true, - visible: true, - tag: String(index + 1) - }, - { - propertyName: "灭火注意事项", - propertyValue: element.payattentionto, - propertyType: 1, - required: false, - ruleName: "", - ruleValue: "", - physicalUnit: "", - order:3, - enabled: true, - visible: true, - tag: String(index + 1) - }) - }); - }else{//否则就传一个空的 - this.deviceinfo = [ - { - propertyName: "装置区名称", - propertyValue: "", - propertyType: 0, - required: true, - ruleName: "", - ruleValue: "", - physicalUnit: "", - order: 0, - enabled: true, - visible: true, - tag: "1" - }, - { - propertyName: "工艺流程", - propertyValue: "", - propertyType: 0, - required: true, - ruleName: "", - ruleValue: "", - physicalUnit: "", - order: 0, - enabled: true, - visible: true, - tag: "1" - }, - { - propertyName: "火灾危险性", - propertyValue: "", - propertyType: 0, - required: true, - ruleName: "", - ruleValue: "", - physicalUnit: "", - order: 0, - enabled: true, - visible: true, - tag: "1" - }, - { - propertyName: "灭火注意事项", - propertyValue: "", - propertyType: 1, - required: false, - ruleName: "", - ruleValue: "", - physicalUnit: "", - order: 0, - enabled: true, - visible: true, - tag: "1" - } - ] - } - bodyObj.buildingBasicGroups[1].propertyInfos = this.deviceinfo - bodyObj.buildingBasicGroups[1].buildingId = item.buildingId - bodyObj.buildingBasicGroups[1].companyId = this.unitinfo.id - - - if(bodyObj.buildingBasicGroups[2].submitted){ //如果勾选了储罐信息 则直接提交当前bodyObj - var map = {}; //用于存储石油化工要提交的储罐信息表单 - for (let key in value) { - if (key.indexOf('tanker') != -1) { - const list = key.split('-'); // 2,tanker,1 - const orderKey = list[0]; // 2 or 3 - if (!(orderKey in map)) { - map[orderKey] = []; // map[2] or map[3] = []; - } - map[orderKey][list[2]] = value[key]; // map[2][1] = xxxxx - } - } - - bodyObj.buildingBasicGroups.splice( 2 , bodyObj.buildingBasicGroups.length) - - // console.log(123, item) - - let basictankinfobody:any = {} - - for(let key in map){//------------------------------------------------------------石油化工 储罐信息 - - - basictankinfobody = { - id: null, - name: "罐区" + (Number(key)-1), - type: 0, - addMode: 2, - basicGroupId:'', - submitted:true, - isOptional:true, - order: Number(key), - enabled: true, - propertyInfos: item.bigfor[Number(key)-2][0].propertyInfos, - basicCategoryId: item.basicCategoryId, - buildingBasicId: null, - buildingId: item.buildingId,//当前建筑id - companyId: this.unitinfo.id//当前企业id - } - - bodyObj.buildingBasicGroups.push(basictankinfobody) - } - - - let basictankchildinfobody:any = []//-------------后续储罐信息以及储罐信息/罐区情况都push到这个数组中 - item.bigfor.forEach(item => { - basictankchildinfobody.push(item[1].propertyInfos) - }); - var _item = item - basictankchildinfobody.forEach((item,index) => { - let tankfieldArr = [] - item.forEach((element,key) => { - tankfieldArr.push( - { - propertyName: "罐区", - propertyValue: element.tank, - propertyType: 0, - required: false, - ruleName: "", - ruleValue: "", - physicalUnit: "", - order: 0, - enabled: true, - visible: true, - tag:String(key + 1) - }, - { - propertyName: "储罐编号", - propertyValue: element.tankid, - propertyType: 0, - required: true, - ruleName: "", - ruleValue: "", - physicalUnit: "", - order: 0, - enabled: true, - visible: true, - tag:String(key + 1) - }, - { - propertyName: "储存介质", - propertyValue: element.tankmedium, - propertyType: 0, - required: true, - ruleName: "", - ruleValue: "", - physicalUnit: "", - order: 0, - enabled: true, - visible: true, - tag:String(key + 1) - }, - { - propertyName: "储罐类型", - propertyValue: element.tanktype, - propertyType: 0, - required: true, - ruleName: "", - ruleValue: "", - physicalUnit: "", - order: 0, - enabled: true, - visible: true, - tag:String(key + 1) - }, - { - propertyName: "容量", - propertyValue: element.tankcapacity, - propertyType: 2, - required: true, - ruleName: "", - ruleValue: "", - physicalUnit: "㎡", - order: 0, - enabled: true, - visible: true, - tag:String(key + 1) - }, - { - propertyName: "直径", - propertyValue:element.tankdiameter, - propertyType: 2, - required: true, - ruleName: "", - ruleValue: "", - physicalUnit: "m", - order: 0, - enabled: true, - visible: true, - tag:String(key + 1) - }, - { - propertyName: "高度", - propertyValue: element.tankheight, - propertyType: 2, - required: true, - ruleName: "", - ruleValue: "", - physicalUnit: "m", - order: 0, - enabled: true, - visible: true, - tag:String(key + 1) - }, - { - propertyName: "顶盖形式", - propertyValue: element.tanktectum, - propertyType: 0, - required: false, - ruleName: "", - ruleValue: "", - physicalUnit: "", - order: 0, - enabled: true, - visible: true, - tag:String(key + 1) - }, - { - propertyName: "浮盘材质", - propertyValue: element.tanktexture, - propertyType: 0, - required: false, - ruleName: "", - ruleValue: "", - physicalUnit: "", - order: 0, - enabled: true, - visible: true, - tag:String(key + 1) - }, - { - propertyName: "浮盘类型", - propertyValue: element.platetype, - propertyType: 0, - required: false, - ruleName: "", - ruleValue: "", - physicalUnit: "", - order: 0, - enabled: true, - visible: true, - tag:String(key + 1) - }, - { - propertyName: "泡沫产生器型号", - propertyValue: element.foamgeneratorid, - propertyType: 0, - required: false, - ruleName: "", - ruleValue: "", - physicalUnit: "", - order: 0, - enabled: true, - visible: true, - tag:String(key + 1) - }, - { - propertyName: "泡沫产生器形式", - propertyValue: element.foamgeneratortype, - propertyType: 0, - required: false, - ruleName: "", - ruleValue: "", - physicalUnit: "", - order: 0, - enabled: true, - visible: true, - tag:String(key + 1) - }, - { - propertyName: "是否设置氮封惰化保护装置", - propertyValue: element.isprotect, - propertyType: 0, - required: false, - ruleName: "", - ruleValue: "", - physicalUnit: "", - order: 0, - enabled: true, - visible: true, - tag:String(key + 1) - }, - { - propertyName: "防护堤高度", - propertyValue: element.fendinggroyneheight, - propertyType: 2, - required: true, - ruleName: "", - ruleValue: "", - physicalUnit: "m", - order: 0, - enabled: true, - visible: true, - tag:String(key + 1) - }, - { - propertyName: "半固定泡沫灭火接口数量", - propertyValue: element.portnum, - propertyType: 2, - required: false, - ruleName: "", - ruleValue: "", - physicalUnit: "个", - order: 0, - enabled: true, - visible: true, - tag:String(key + 1) - }, - { - propertyName: "其它设施", - propertyValue: element.else, - propertyType: 0, - required: false, - ruleName: "", - ruleValue: "", - physicalUnit: "", - order: 0, - enabled: true, - visible: true, - tag:String(key + 1) - } - ) - }); - basictankchildinfobody={// - id: null, - name: "罐区" + Number(index+1) + "/储罐信息", - type: 1, - addMode: 2, - basicGroupId:'', - order: Number(index + 2), - enabled: true, - submitted:true, - isOptional:true, - propertyInfos: tankfieldArr, - basicCategoryId: _item.basicCategoryId, - buildingBasicId: null, - buildingId: _item.buildingId, - companyId: this.unitinfo.id - } - bodyObj.buildingBasicGroups.push(basictankchildinfobody) - }); - }else{ - - - bodyObj.buildingBasicGroups[2].buildingId = item.buildingId - bodyObj.buildingBasicGroups[2].companyId = this.unitinfo.id - bodyObj.buildingBasicGroups[2].propertyInfos.forEach(item=>{ - item.propertyValue = "" - }) - bodyObj.buildingBasicGroups[3].buildingId = item.buildingId - bodyObj.buildingBasicGroups[3].companyId = this.unitinfo.id - bodyObj.buildingBasicGroups[3].propertyInfos = [ - { - propertyName: "罐区", - propertyValue: "", - propertyType: 0, - required: false, - ruleName: "", - ruleValue: "", - physicalUnit: "", - order: 0, - enabled: true, - visible: true, - tag:"1" - }, - { - propertyName: "储罐编号", - propertyValue: "", - propertyType: 0, - required: true, - ruleName: "", - ruleValue: "", - physicalUnit: "", - order: 0, - enabled: true, - visible: true, - tag:"1" - }, - { - propertyName: "储存介质", - propertyValue: "", - propertyType: 0, - required: true, - ruleName: "", - ruleValue: "", - physicalUnit: "", - order: 0, - enabled: true, - visible: true, - tag:"1" - }, - { - propertyName: "储罐类型", - propertyValue:"", - propertyType: 0, - required: true, - ruleName: "", - ruleValue: "", - physicalUnit: "", - order: 0, - enabled: true, - visible: true, - tag:"1" - }, - { - propertyName: "容量", - propertyValue: "", - propertyType: 2, - required: true, - ruleName: "", - ruleValue: "", - physicalUnit: "㎡", - order: 0, - enabled: true, - visible: true, - tag:"1" - }, - { - propertyName: "直径", - propertyValue:"", - propertyType: 2, - required: true, - ruleName: "", - ruleValue: "", - physicalUnit: "m", - order: 0, - enabled: true, - visible: true, - tag:"1" - }, - { - propertyName: "高度", - propertyValue: "", - propertyType: 2, - required: true, - ruleName: "", - ruleValue: "", - physicalUnit: "m", - order: 0, - enabled: true, - visible: true, - tag:"1" - }, - { - propertyName: "顶盖形式", - propertyValue: "", - propertyType: 0, - required: false, - ruleName: "", - ruleValue: "", - physicalUnit: "", - order: 0, - enabled: true, - visible: true, - tag:"1" - }, - { - propertyName: "浮盘材质", - propertyValue:"", - propertyType: 0, - required: false, - ruleName: "", - ruleValue: "", - physicalUnit: "", - order: 0, - enabled: true, - visible: true, - tag:"1" - }, - { - propertyName: "浮盘类型", - propertyValue: "", - propertyType: 0, - required: false, - ruleName: "", - ruleValue: "", - physicalUnit: "", - order: 0, - enabled: true, - visible: true, - tag:"1" - }, - { - propertyName: "泡沫产生器型号", - propertyValue:"", - propertyType: 0, - required: false, - ruleName: "", - ruleValue: "", - physicalUnit: "", - order: 0, - enabled: true, - visible: true, - tag:"1" - }, - { - propertyName: "泡沫产生器形式", - propertyValue: "", - propertyType: 0, - required: false, - ruleName: "", - ruleValue: "", - physicalUnit: "", - order: 0, - enabled: true, - visible: true, - tag:"1" - }, - { - propertyName: "是否设置氮封惰化保护装置", - propertyValue:"", - propertyType: 0, - required: false, - ruleName: "", - ruleValue: "", - physicalUnit: "", - order: 0, - enabled: true, - visible: true, - tag:"1" - }, - { - propertyName: "防护堤高度", - propertyValue:"", - propertyType: 2, - required: true, - ruleName: "", - ruleValue: "", - physicalUnit: "m", - order: 0, - enabled: true, - visible: true, - tag:"1" - }, - { - propertyName: "半固定泡沫灭火接口数量", - propertyValue: "", - propertyType: 2, - required: false, - ruleName: "", - ruleValue: "", - physicalUnit: "个", - order: 0, - enabled: true, - visible: true, - tag:"1" - }, - { - propertyName: "其它设施", - propertyValue: "", - propertyType: 0, - required: false, - ruleName: "", - ruleValue: "", - physicalUnit: "", - order: 0, - enabled: true, - visible: true, - tag:"1" - } - ] - // console.log(888,bodyObj) - bodyObj.buildingBasicGroups.splice(4,bodyObj.buildingBasicGroups.length) + } + // console.log('newbody',newbody) + this.http.post("/api/BuildingBasicInfos",newbody,{ + params:{ + companyId : this.unitId, + buildingId :newbody[0].buildingId } - + }).subscribe((data:any)=>{ + // this.houses[key].id = data[0].id + const config = new MatSnackBarConfig(); + config.verticalPosition = 'top'; + config.duration = 3000 + this.snackBar.open('建筑信息保存成功','确定',config); + }, + err=>{ + const config = new MatSnackBarConfig(); + config.verticalPosition = 'top'; + config.duration = 3000 + this.snackBar.open('请检查输入数据是否有误','确定',config); + }) + + //保存建筑自定义信息 + if(item.isCustomData){ + this.http.post("/api/BuildingCustomData",item.customData,{params:{ + companyId :this.unitId, + buildingId:item.id + }}).subscribe(data=>{ - - let newbodyObj = [] - newbodyObj.push(bodyObj) - // console.log(1111,newbodyObj) - this.http.post("/api/BuildingBasicInfos",newbodyObj,{ - params:{ - companyId : this.unitId, - buildingId :item.buildingId - } - }).subscribe((data:any)=>{ - this.houses[key].id = data[0].id - const config = new MatSnackBarConfig(); - config.verticalPosition = 'top'; - config.duration = 3000 - this.snackBar.open('建筑信息保存成功','确定',config); - // alert("建筑信息保存成功") - this.tabbarService.sendMessage('changeScore');//通知服务改变分数 - }, - err=>{ - const config = new MatSnackBarConfig(); - config.verticalPosition = 'top'; - config.duration = 3000 - this.snackBar.open('请检查输入数据是否有误','确定',config); - }) + }) + }else{ + item.customData.customProperties = [] + this.http.post("/api/BuildingCustomData",item.customData,{params:{ + companyId :this.unitId, + buildingId:item.id + }}).subscribe(data=>{ + + }) + } + + } + } + //更改模板类型 + templateBuildtype(n,item,key){ + this.http.get("/api/BuildingBasicInfos",{//请求当前建筑类型的模板信息保存到数组中 + params:{ + companyId :this.unitId, + buildingId:item.id, + buildingType:n.id + } + }).subscribe(data=>{ + data[0].buildingBasicGroups.forEach(element => { + //需要处理一下表格信息 + if(element.type == 1){ + let afterData = [] + let tempArr = []; + for (let i = 0; i < element.propertyInfos.length; i++) { + element.propertyInfos[i].tag == '' ? element.propertyInfos[i].tag = 1 : null + if (tempArr.indexOf(element.propertyInfos[i].tag) === -1) { + afterData.push({ + tag: element.propertyInfos[i].tag, + origin: [element.propertyInfos[i]] + }); + tempArr.push(element.propertyInfos[i].tag); + } else { + for (let j = 0; j < afterData.length; j++) { + if (afterData[j].tag == element.propertyInfos[i].tag) { + afterData[j].origin.push(element.propertyInfos[i]); + break; + } + } + } + } + element.propertyInfos = afterData + } + }); + let guanquIndex = data[0].buildingBasicGroups.findIndex(item => item.name.indexOf('罐区')>=0); // 找到第一个灌区的索引 + function transferFn(arr) { + const guanquIndex = arr.findIndex(item => item.name.indexOf('罐区')>=0); // 找到第一个灌区的索引 + const guanquList = arr.slice(guanquIndex); // 灌区的列表 + const baseList = arr.slice(0, guanquIndex); // 前面的数据 + const len = guanquList.length; + const num = len/2; // 计算一共有多少对,这里的前提是数据本身必须成对出现 + // 灌区切割出来的数据,分别存放,最后做一下合并 + const array1 = []; + const array2 = []; + for(let i = 0; i<num; i++) { + array1.push(guanquList[i]); // 灌区x + array2.push(guanquList[i + num]); // 灌区x/储罐信息 } - if(item.buildtype.indexOf('地铁') != -1){ - let newObj = _.cloneDeep(item) - delete newObj.username - delete newObj.name - delete newObj.tongyong - delete newObj.ditie - delete newObj.buildtype - delete newObj.isCustomData - delete newObj.buildingCustomData - newObj.buildingBasicGroups.forEach(item => { - item.propertyInfos.forEach(element => { - delete element.isshowrule - delete element.rulevalue - if( element.propertyValue || element.propertyValue == 0){ - element.propertyValue = String(element.propertyValue) - } - }); - item.buildingId = newObj.buildingId - item.companyId = this.unitinfo.id - item.submitted = true - }); - let newbodyObj2 = [] - newbodyObj2.push(newObj) - this.http.post("/api/BuildingBasicInfos",newbodyObj2,{ - params:{ - companyId : this.unitId, - buildingId :newObj.buildingId + // 拼接最后的数据 + const result = [...baseList]; + for(let i = 0, ll = array1.length; i < ll; i++){ + result.push(array1[i]); + if (array2[i]) { + result.push(array2[i]); } - }).subscribe((data:any)=>{ - this.houses[key].id = data[0].id - const config = new MatSnackBarConfig(); - config.verticalPosition = 'top'; - config.duration = 3000 - this.snackBar.open('建筑信息保存成功','确定',config); - this.tabbarService.sendMessage('changeScore');//通知服务改变分数 - }, - err=>{ - const config = new MatSnackBarConfig(); - config.verticalPosition = 'top'; - config.duration = 3000 - this.snackBar.open('请检查输入数据是否有误','确定',config); - }) - } + return result; + } + if(guanquIndex != -1 && data[0].buildingBasicGroups[guanquIndex + 1].name.indexOf(data[0].buildingBasicGroups[guanquIndex].name) == -1){ + data[0].buildingBasicGroups = transferFn(data[0].buildingBasicGroups) } + this.houses[key].data = data }) - - - }} \ No newline at end of file + } +} \ No newline at end of file