From a29982e204d9033cc5d3b2ee63969cf45eeada0d Mon Sep 17 00:00:00 2001 From: SHAOJIAHAO <55341701@qq.com> Date: Thu, 20 Oct 2022 10:13:12 +0800 Subject: [PATCH] =?UTF-8?q?[=E5=AE=8C=E5=96=84]=E6=B6=88=E9=98=B2=E8=AE=BE?= =?UTF-8?q?=E6=96=BD=E7=BD=91=E7=BB=9C=E8=8E=B7=E5=8F=96=E5=A4=B1=E8=B4=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/app/http-interceptors/base-interceptor.ts | 22 +- .../fire-fighting-device.component.ts | 841 ++++++++++-------- 2 files changed, 456 insertions(+), 407 deletions(-) diff --git a/src/app/http-interceptors/base-interceptor.ts b/src/app/http-interceptors/base-interceptor.ts index 4b14ae9..ff44222 100644 --- a/src/app/http-interceptors/base-interceptor.ts +++ b/src/app/http-interceptors/base-interceptor.ts @@ -5,8 +5,8 @@ import { } from '@angular/common/http'; import { throwError } from 'rxjs' import { catchError, retry } from 'rxjs/operators'; -import { Router,ActivatedRoute } from '@angular/router' -import {CacheTokenService} from './cache-token.service' +import { Router, ActivatedRoute } from '@angular/router' +import { CacheTokenService } from './cache-token.service' import { MatSnackBar, MatSnackBarConfig } from '@angular/material/snack-bar'; //baseurl @@ -15,19 +15,19 @@ import { MatSnackBar, MatSnackBarConfig } from '@angular/material/snack-bar'; @Injectable() export class BaseInterceptor implements HttpInterceptor { - constructor(private http:HttpClient,private router:Router,private route:ActivatedRoute,public token:CacheTokenService,public snackBar: MatSnackBar) {} + constructor(private http: HttpClient, private router: Router, private route: ActivatedRoute, public token: CacheTokenService, public snackBar: MatSnackBar) { } intercept(req, next: HttpHandler) { let newReq = req.clone({ url: req.hadBaseurl ? `${req.url}` : `${req.url}`, }); - if(!req.cancelToken) { + if (!req.cancelToken) { /*获取token*/ let token = sessionStorage.getItem("token") /*此处设置额外请求头,token令牌*/ newReq.headers = - newReq.headers.set('Authorization', `Bearer ${token}`) + newReq.headers.set('Authorization', `Bearer ${token}`) } // 携带请求头发送下一次请求 @@ -43,7 +43,7 @@ export class BaseInterceptor implements HttpInterceptor { private handleError(error: HttpErrorResponse) { // 用户认证失败返回登录页 - if (error.status === 401||error.status === 614) { + if (error.status === 401 || error.status === 614) { this.token.delete() sessionStorage.clear() window.localStorage.clear() @@ -51,19 +51,19 @@ export class BaseInterceptor implements HttpInterceptor { const config = new MatSnackBarConfig(); config.verticalPosition = 'top'; config.duration = 3000 - this.snackBar.open('用户认证信息过期,请重新登录','确定',config); + this.snackBar.open('用户认证信息过期,请重新登录', '确定', config); } if (error.status === 403) { const config = new MatSnackBarConfig(); config.verticalPosition = 'top'; config.duration = 3000 - this.snackBar.open('对不起,您无此权限','确定',config); + this.snackBar.open('对不起,您无此权限', '确定', config); } if (error.status === 400) { const config = new MatSnackBarConfig(); config.verticalPosition = 'top'; config.duration = 3000 - this.snackBar.open('请核对您的输入格式是否正确','确定',config); + this.snackBar.open('请核对您的输入格式是否正确', '确定', config); } if (error.error instanceof ErrorEvent) { @@ -72,9 +72,7 @@ export class BaseInterceptor implements HttpInterceptor { } else { // 服务端返回http状态码 // 服务端返回错误信息 - console.error( - `Backend returned code ${error.status}, ` + - `body was: ${error.error}`); + console.error(error); } // 返回带有面向用户的错误信息 return throwError( diff --git a/src/app/key-unit/fire-fighting-device/fire-fighting-device.component.ts b/src/app/key-unit/fire-fighting-device/fire-fighting-device.component.ts index 4189176..2661785 100644 --- a/src/app/key-unit/fire-fighting-device/fire-fighting-device.component.ts +++ b/src/app/key-unit/fire-fighting-device/fire-fighting-device.component.ts @@ -1,10 +1,10 @@ import { Component, OnInit, ViewChild, Inject } from '@angular/core'; -import {HttpClient, HttpHeaders} from '@angular/common/http' +import { HttpClient, HttpHeaders } from '@angular/common/http' import { MatDialogRef, MatDialog, MAT_DIALOG_DATA } from '@angular/material/dialog'; import { ImgsDataDetail } from './addGrouping.component' import { MatSnackBarConfig, MatSnackBar } from '@angular/material/snack-bar'; import { ImagesData } from './imagesdata.component' -import { Router,ActivatedRoute } from '@angular/router' +import { Router, ActivatedRoute } from '@angular/router' import { TabbarAndScoreService } from 'src/app/http-interceptors/tabbar-and-score.service'; @@ -19,7 +19,7 @@ export interface Food { }) export class FireFightingDeviceComponent implements OnInit { - constructor(private tabbarService: TabbarAndScoreService,private router:Router,private route:ActivatedRoute,public http: HttpClient,public dialog: MatDialog,public snackBar: MatSnackBar) { } + constructor(private tabbarService: TabbarAndScoreService, private router: Router, private route: ActivatedRoute, public http: HttpClient, public dialog: MatDialog, public snackBar: MatSnackBar) { } ngOnInit(): void { this.getCompanyInformation() @@ -27,31 +27,32 @@ export class FireFightingDeviceComponent implements OnInit { } //定义属性数据 - singleElection:Food[]=[ - {value:'true', name: '有'}, - {value:'false', name: '无'}] + singleElection: Food[] = [ + { value: 'true', name: '有' }, + { value: 'false', name: '无' }] - companyBuiltInGrouping:any = []; //单位消防设施内置分组 - companyDetails:any = []; //单位详情 - companyEachDetails:any = [] //单位每层详情 - companyOptionalGrouping:any = []; //单位消防设施可选分组 + companyBuiltInGrouping: any = []; //单位消防设施内置分组 + companyDetails: any = []; //单位详情 + companyEachDetails: any = [] //单位每层详情 + companyOptionalGrouping: any = []; //单位消防设施可选分组 //获得单位基本信息 - getCompanyInformation () { - let companyId = this.route.snapshot.queryParams.id - this.http.get(`/api/Companies/${companyId}`).subscribe((data:any)=>{ + getCompanyInformation() { + let companyId = this.route.snapshot.queryParams.id + this.http.get(`/api/Companies/${companyId}`).subscribe((data: any) => { if (data.buildingTypes.length) { - let newData = {buildingType: data.buildingTypes[0].id,companyId : companyId} - this.http.get('/api/CompanyFacilities',{params:newData}).subscribe((data:any)=>{ //获得单位的消防设施 + let newData = { buildingType: data.buildingTypes[0].id, companyId: companyId } + this.http.get('/api/CompanyFacilities', { params: newData }).subscribe((data: any) => { //获得单位的消防设施 this.companyBuiltInGrouping = data[0].summary.companyFacilityGroups this.companyOptionalGrouping = data[0].summary.companyOptionalGroups this.companyDetails = data[0].details this.companyEachDetails = data[0].eachDetails this.companyBuiltInGrouping.forEach(element => { //循环单位内置分组项 element.selectBuiltInGrouping = [] - element.facilityItems.forEach((elements,index) => { + element.facilityItems.forEach((elements, index) => { elements.total = element.facilityCount[index] - elements.expanded = false}); + elements.expanded = false + }); }); }) //http } //if @@ -60,42 +61,45 @@ export class FireFightingDeviceComponent implements OnInit { } //创建单位消防设施内置分组项 - addCompanyGrouping (e) { + addCompanyGrouping(e) { let data = e - let dialogRef = this.dialog.open(ImgsDataDetail,{data}); - dialogRef.afterClosed().subscribe(data=>{ - if (data) { - e.facilityItems.push(data) + let dialogRef = this.dialog.open(ImgsDataDetail, { data }); + dialogRef.afterClosed().subscribe(data => { + if (data) { + e.facilityItems.push(data) this.tabbarService.sendMessage('changeScore');//通知服务改变分数 - } }); + } + }); } //保存单位消防设施内置分组项 editCompanyGrouping(e) { - let header = {groupId:e.id} + let header = { groupId: e.id } let data = [] - e.facilityItems.forEach((element,index) => { + e.facilityItems.forEach((element, index) => { let msg = { isBuiltin: element.isBuiltin, details: element.details, name: element.name, isEachFloor: element.isEachFloor, - order: element.order} + order: element.order + } data.push(msg) - if (index==e.facilityItems.length-1) { - this.http.post('/api/CompanyFacilityItems/Batch',data,{params:header}).subscribe(data=>{ + if (index == e.facilityItems.length - 1) { + this.http.post('/api/CompanyFacilityItems/Batch', data, { params: header }).subscribe(data => { const config = new MatSnackBarConfig(); config.verticalPosition = 'top'; config.duration = 3000 - this.snackBar.open('数据更新成功','确定',config); + this.snackBar.open('数据更新成功', '确定', config); this.tabbarService.sendMessage('changeScore');//通知服务改变分数 - }) } + }) + } }); //forEach - + } //checked单位消防设施内置分组项时 - checkedCompany (e,item,items) { + checkedCompany(e, item, items) { if (e.checked) { item.selectBuiltInGrouping.push(items) } else { @@ -104,53 +108,53 @@ export class FireFightingDeviceComponent implements OnInit { } //删除消防设施内置分组项 - deleteCompanyGrouping (e) { + deleteCompanyGrouping(e) { if (e.selectBuiltInGrouping.length) { - let isDelete = confirm('您确定要删除吗') - if (isDelete) { - let msg:any = `?groupId=${e.id}` - e.selectBuiltInGrouping.forEach((element,index) => { - let data = `&name=${element.name}` - msg = msg + data - if (index === e.selectBuiltInGrouping.length-1) { - this.http.delete('/api/CompanyFacilityItems/Batch' + msg).subscribe(data=>{ - let deleteMsg = e.selectBuiltInGrouping - deleteMsg.forEach(deleteElement => { - e.facilityItems.splice(e.facilityItems.findIndex(item=>item.name==deleteElement.name),1) - }); - e.selectBuiltInGrouping = [] - this.tabbarService.sendMessage('changeScore');//通知服务改变分数 - }) //http - } //if - }); //forEach - } + let isDelete = confirm('您确定要删除吗') + if (isDelete) { + let msg: any = `?groupId=${e.id}` + e.selectBuiltInGrouping.forEach((element, index) => { + let data = `&name=${element.name}` + msg = msg + data + if (index === e.selectBuiltInGrouping.length - 1) { + this.http.delete('/api/CompanyFacilityItems/Batch' + msg).subscribe(data => { + let deleteMsg = e.selectBuiltInGrouping + deleteMsg.forEach(deleteElement => { + e.facilityItems.splice(e.facilityItems.findIndex(item => item.name == deleteElement.name), 1) + }); + e.selectBuiltInGrouping = [] + this.tabbarService.sendMessage('changeScore');//通知服务改变分数 + }) //http + } //if + }); //forEach + } } else { const config = new MatSnackBarConfig(); config.verticalPosition = 'top'; config.duration = 3000 - this.snackBar.open('请选择内置分组项','确定',config); + this.snackBar.open('请选择内置分组项', '确定', config); } } //保存单位消防设施可选分组 - editCompanyOptional (e,item) { + editCompanyOptional(e, item) { e.stopPropagation() //阻止冒泡 - item.propertyInfos.forEach((element,index) => { + item.propertyInfos.forEach((element, index) => { element.propertyValue = String(element.propertyValue) - if (index == item.propertyInfos.length-1 ) { - this.http.post('/api/CompanyOptionalGroups',item).subscribe(data=>{ + if (index == item.propertyInfos.length - 1) { + this.http.post('/api/CompanyOptionalGroups', item).subscribe(data => { const config = new MatSnackBarConfig(); config.verticalPosition = 'top'; config.duration = 3000 - this.snackBar.open('数据更新成功','确定',config); + this.snackBar.open('数据更新成功', '确定', config); this.tabbarService.sendMessage('changeScore');//通知服务改变分数 }) } //if - }); + }); } //单位消防设施切换展开面板 - SwitchBoard (e) { + SwitchBoard(e) { e.expanded = !e.expanded if (e.expanded) { //展开面板展开时 if (e.isEachFloor) { //逐层统计时 @@ -158,26 +162,30 @@ export class FireFightingDeviceComponent implements OnInit { if (data) { e.loopTable = [] data.forEach(item => { - let tableMsg = {name:item.name, header:[], body:[]} + let tableMsg = { name: item.name, header: [], body: [] } item.assets[0].propertyInfos.forEach(element => { //表头 - if (element.propertyType!=3) { - let unit = element.physicalUnit? '('+ element.physicalUnit +')' : '' //单位 - tableMsg.header.push(element.propertyName+unit)} + if (element.propertyType != 3) { + let unit = element.physicalUnit ? '(' + element.physicalUnit + ')' : '' //单位 + tableMsg.header.push(element.propertyName + unit) + } }); item.assets.forEach(element => { //表格内容 let everyBody = {} - element.propertyInfos.forEach((elements,index) => { - if (elements.propertyType!=3 && elements.propertyName!='图片' && elements.propertyType!=6) { - let unit = elements.physicalUnit? '('+ elements.physicalUnit +')' : '' //单位 - everyBody[elements.propertyName+unit] = elements.propertyValue } - if (elements.propertyType==6) { - let unit = elements.physicalUnit? '('+ elements.physicalUnit +')' : '' //单位 - everyBody[elements.propertyName+unit] = elements.propertyValue=='1'?'是':'否' } - if (elements.propertyType!=3 && elements.propertyName=='图片') { + element.propertyInfos.forEach((elements, index) => { + if (elements.propertyType != 3 && elements.propertyName != '图片' && elements.propertyType != 6) { + let unit = elements.physicalUnit ? '(' + elements.physicalUnit + ')' : '' //单位 + everyBody[elements.propertyName + unit] = elements.propertyValue + } + if (elements.propertyType == 6) { + let unit = elements.physicalUnit ? '(' + elements.physicalUnit + ')' : '' //单位 + everyBody[elements.propertyName + unit] = elements.propertyValue == '1' ? '是' : '否' + } + if (elements.propertyType != 3 && elements.propertyName == '图片') { let imgLength = [] - element.propertyInfos.find(item=>{ if(item.propertyType==3){imgLength.push(item)} }) - let unit = elements.physicalUnit? '('+ elements.physicalUnit +')' : '' //单位 - everyBody[elements.propertyName+unit] = String(imgLength.length) } + element.propertyInfos.find(item => { if (item.propertyType == 3) { imgLength.push(item) } }) + let unit = elements.physicalUnit ? '(' + elements.physicalUnit + ')' : '' //单位 + everyBody[elements.propertyName + unit] = String(imgLength.length) + } }); //propertyInfos tableMsg.body.push(everyBody) @@ -188,28 +196,32 @@ export class FireFightingDeviceComponent implements OnInit { } //data有数据时 } else { //非逐层统计时 let data = this.companyDetails[e.name] - if (data) { + if (data) { e.header = [] e.body = [] data[0].propertyInfos.forEach(element => { //表头 - if (element.propertyType!=3) { - let unit = element.physicalUnit? '('+ element.physicalUnit +')' : '' //单位 - e.header.push(element.propertyName+unit)} + if (element.propertyType != 3) { + let unit = element.physicalUnit ? '(' + element.physicalUnit + ')' : '' //单位 + e.header.push(element.propertyName + unit) + } }); data.forEach(element => { //表格内容 let everyBody = {} - element.propertyInfos.forEach((elements,index) => { - if (elements.propertyType!=3 && elements.propertyName!='图片' && elements.propertyType!=6) { - let unit = elements.physicalUnit? '('+ elements.physicalUnit +')' : '' //单位 - everyBody[elements.propertyName+unit] = elements.propertyValue } - if (elements.propertyType==6) { - let unit = elements.physicalUnit? '('+ elements.physicalUnit +')' : '' //单位 - everyBody[elements.propertyName+unit] = elements.propertyValue=='1'?'是':'否' } - if (elements.propertyType!=3 && elements.propertyName=='图片') { + element.propertyInfos.forEach((elements, index) => { + if (elements.propertyType != 3 && elements.propertyName != '图片' && elements.propertyType != 6) { + let unit = elements.physicalUnit ? '(' + elements.physicalUnit + ')' : '' //单位 + everyBody[elements.propertyName + unit] = elements.propertyValue + } + if (elements.propertyType == 6) { + let unit = elements.physicalUnit ? '(' + elements.physicalUnit + ')' : '' //单位 + everyBody[elements.propertyName + unit] = elements.propertyValue == '1' ? '是' : '否' + } + if (elements.propertyType != 3 && elements.propertyName == '图片') { let imgLength = [] - element.propertyInfos.find(item=>{ if(item.propertyType==3){imgLength.push(item)} }) - let unit = elements.physicalUnit? '('+ elements.physicalUnit +')' : '' //单位 - everyBody[elements.propertyName+unit] = String(imgLength.length) } + element.propertyInfos.find(item => { if (item.propertyType == 3) { imgLength.push(item) } }) + let unit = elements.physicalUnit ? '(' + elements.physicalUnit + ')' : '' //单位 + everyBody[elements.propertyName + unit] = String(imgLength.length) + } }); e.body.push(everyBody) @@ -225,255 +237,272 @@ export class FireFightingDeviceComponent implements OnInit { - allBuildingGrouping:any; //所有建筑的消防设施 内置分组+可选分组 + allBuildingGrouping: any; //所有建筑的消防设施 内置分组+可选分组 //获取所有建筑 - getAllBuilding () { - let companyId = this.route.snapshot.queryParams.id - this.http.get('/api/Buildings',{params:{ - companyId:companyId - }}).subscribe((data:any)=>{ + getAllBuilding() { + let companyId = this.route.snapshot.queryParams.id + this.http.get('/api/Buildings', { + params: { + companyId: companyId + } + }).subscribe((data: any) => { this.allBuildingGrouping = data // console.log(888,data) - if (this.allBuildingGrouping.length) { - this.getAllBuildingFacilities() + if (this.allBuildingGrouping.length) { + this.getAllBuildingFacilities() } else { const config = new MatSnackBarConfig(); config.verticalPosition = 'top'; config.duration = 3000 - this.snackBar.open('暂无建筑数据','确定',config); + this.snackBar.open('暂无建筑数据', '确定', config); } }) } //消防水系统 fireProtectionWaterSystem = { - waterSupplyNetwork:{name:'供水管网',total:'',details:''},//供水管网 - sprinklerSystem:{name:'自动喷水灭火系统',total:'',details:''}//自动喷水灭火系统 + waterSupplyNetwork: { name: '供水管网', total: '', details: '' },//供水管网 + sprinklerSystem: { name: '自动喷水灭火系统', total: '', details: '' }//自动喷水灭火系统 } //消防灭火给水系统 FireExtinguishingWaterSupplySystem = { - sprinklerSystem:{name:'自动喷水灭火系统',total:'',details:''},//自动喷水灭火系统 - AutomaticGasFireExtinguishingSystem:{name:'气体自动灭火系统',total:'',details:''},//气体自动灭火系统 - firePumpRoom:{name:'消防泵房',total:'',details:''}//消防泵房 + sprinklerSystem: { name: '自动喷水灭火系统', total: '', details: '' },//自动喷水灭火系统 + AutomaticGasFireExtinguishingSystem: { name: '气体自动灭火系统', total: '', details: '' },//气体自动灭火系统 + firePumpRoom: { name: '消防泵房', total: '', details: '' }//消防泵房 } //其它 other = { - purgingSystem:{name:'排烟系统',total:'',details:''},//排烟系统 - fireExtinguisher:{name:'灭火器',total:'',details:''},//灭火器 - extinctionUsingGas:{name:'气体灭火',total:'',details:''},//气体灭火 - fireControlCommunication:{name:'消防通信',total:'',details:''}//消防通信 + purgingSystem: { name: '排烟系统', total: '', details: '' },//排烟系统 + fireExtinguisher: { name: '灭火器', total: '', details: '' },//灭火器 + extinctionUsingGas: { name: '气体灭火', total: '', details: '' },//气体灭火 + fireControlCommunication: { name: '消防通信', total: '', details: '' }//消防通信 } //消防设施 fireFightingEquipment = { - automaticAlarmSystem:{name:'自动报警系统',total:'',details:''},//自动报警系统 - firePump:{name:'消防泵',total:'',details:''}//消防泵 + automaticAlarmSystem: { name: '自动报警系统', total: '', details: '' },//自动报警系统 + firePump: { name: '消防泵', total: '', details: '' }//消防泵 } //消火栓系统 hydrantSystem = { - fireExtinguishingAgent:{name:'灭火剂',total:'',details:''},//灭火剂 - AlarmFacilities:{name:'报警设施',total:'',details:''},//报警设施 - FireControlPipeNetwork:{name:'消防管网',total:'',details:''}//消防管网 + fireExtinguishingAgent: { name: '灭火剂', total: '', details: '' },//灭火剂 + AlarmFacilities: { name: '报警设施', total: '', details: '' },//报警设施 + FireControlPipeNetwork: { name: '消防管网', total: '', details: '' }//消防管网 } //其它设施 otherFacilities = { - givePriorityToBroadcast:{name:'优先广播',total:'',details:''},//优先广播 - VIdetector:{name:'VI检测仪',total:'',details:''},//VI检测仪 - foamWaterSpraySystem:{name:'泡沫水喷雾系统',total:'',details:''},//泡沫水喷雾系统 + givePriorityToBroadcast: { name: '优先广播', total: '', details: '' },//优先广播 + VIdetector: { name: 'VI检测仪', total: '', details: '' },//VI检测仪 + foamWaterSpraySystem: { name: '泡沫水喷雾系统', total: '', details: '' },//泡沫水喷雾系统 } //自动消防设施 automaticFireProtectionFacility = { - fireSprinklingSystem:{name:'喷水灭火系统',total:'',details:''},//喷水灭火系统 - automaticAlarmSystem:{name:'自动报警系统',total:'',details:''},//自动报警系统 - smokeControlAndExhaustSystem:{name:'防排烟系统',total:'',details:''},//防排烟系统 - waterCurtainSystem:{name:'水幕系统',total:'',details:''},//水幕系统 - firePump:{name:'消防泵',total:'',details:''}//消防泵 + fireSprinklingSystem: { name: '喷水灭火系统', total: '', details: '' },//喷水灭火系统 + automaticAlarmSystem: { name: '自动报警系统', total: '', details: '' },//自动报警系统 + smokeControlAndExhaustSystem: { name: '防排烟系统', total: '', details: '' },//防排烟系统 + waterCurtainSystem: { name: '水幕系统', total: '', details: '' },//水幕系统 + firePump: { name: '消防泵', total: '', details: '' }//消防泵 } //消防水源 fireWaterSupply = { - firePool:{name:'消防水池',total:'',details:''}//消防水池 + firePool: { name: '消防水池', total: '', details: '' }//消防水池 } //获得当前建筑的手动输入值 - FacilityStat:any//存放当前建筑手动输入的值 - selectedChange($event){ + FacilityStat: any//存放当前建筑手动输入的值 + selectedChange($event) { //获得手动输入的值 - this.http.get('/api/BuildingFacilities/FacilityStat',{params:{ - buildingId : this.allBuildingGrouping[$event].id - }}).subscribe(data=>{ + this.http.get('/api/BuildingFacilities/FacilityStat', { + params: { + buildingId: this.allBuildingGrouping[$event].id + } + }).subscribe(data => { this.FacilityStat = data this.changeData() }) } //获取所有建筑的消防设施 - getAllBuildingFacilities () { - let companyId = this.route.snapshot.queryParams.id + async getAllBuildingFacilities() { + let companyId = this.route.snapshot.queryParams.id let index = 0 - this.allBuildingGrouping.forEach(element => { - let header = {buildingId: element.id, buildingType: element.buildingTypes[0].id,companyId:companyId} - this.http.get('/api/BuildingFacilities',{params:header}).subscribe(data=>{ - element.buildingFacilityGroups = data[0].summary.buildingFacilityGroups - element.buildingOptionalGroups = data[0].summary.buildingOptionalGroups - element.buildingDetails = data[0].details - element.buildingEachDetails = data[0].eachDetails - element.buildingFacilityGroups.forEach((elements) => { //循环每个建筑内置分组项 - elements.selectBuiltInGrouping = [] - elements.facilityItems.forEach((newElement,index) => { - newElement.total = elements.facilityCount[index] - newElement.expanded = false }); - }); + + for (let index = 0; index < this.allBuildingGrouping.length; index++) { + const element = this.allBuildingGrouping[index]; + let header = { buildingId: element.id, buildingType: element.buildingTypes[0].id, companyId: companyId } + + await new Promise((resolve, reject) => { + this.http.get('/api/BuildingFacilities', { params: header }).subscribe(data => { + element.buildingFacilityGroups = data[0].summary.buildingFacilityGroups + element.buildingOptionalGroups = data[0].summary.buildingOptionalGroups + element.buildingDetails = data[0].details + element.buildingEachDetails = data[0].eachDetails + element.buildingFacilityGroups.forEach((elements) => { //循环每个建筑内置分组项 + elements.selectBuiltInGrouping = [] + elements.facilityItems.forEach((newElement, index) => { + newElement.total = elements.facilityCount[index] + newElement.expanded = false + }); + }); + // console.log(element.name, data) + resolve() + }, err => { + console.log(element.name + '消防设施网络获取失败', err) + }) }) - }); + + + } + } //清空手动输入的值 - emptyData(){ + emptyData() { this.fireProtectionWaterSystem = { - waterSupplyNetwork:{name:'供水管网',total:'',details:''},//供水管网 - sprinklerSystem:{name:'自动喷水灭火系统',total:'',details:''}//自动喷水灭火系统 + waterSupplyNetwork: { name: '供水管网', total: '', details: '' },//供水管网 + sprinklerSystem: { name: '自动喷水灭火系统', total: '', details: '' }//自动喷水灭火系统 } this.FireExtinguishingWaterSupplySystem = { - sprinklerSystem:{name:'自动喷水灭火系统',total:'',details:''},//自动喷水灭火系统 - AutomaticGasFireExtinguishingSystem:{name:'气体自动灭火系统',total:'',details:''},//气体自动灭火系统 - firePumpRoom:{name:'消防泵房',total:'',details:''}//消防泵房 + sprinklerSystem: { name: '自动喷水灭火系统', total: '', details: '' },//自动喷水灭火系统 + AutomaticGasFireExtinguishingSystem: { name: '气体自动灭火系统', total: '', details: '' },//气体自动灭火系统 + firePumpRoom: { name: '消防泵房', total: '', details: '' }//消防泵房 } this.other = { - purgingSystem:{name:'排烟系统',total:'',details:''},//排烟系统 - fireExtinguisher:{name:'灭火器',total:'',details:''},//灭火器 - extinctionUsingGas:{name:'气体灭火',total:'',details:''},//气体灭火 - fireControlCommunication:{name:'消防通信',total:'',details:''}//消防通信 + purgingSystem: { name: '排烟系统', total: '', details: '' },//排烟系统 + fireExtinguisher: { name: '灭火器', total: '', details: '' },//灭火器 + extinctionUsingGas: { name: '气体灭火', total: '', details: '' },//气体灭火 + fireControlCommunication: { name: '消防通信', total: '', details: '' }//消防通信 } this.fireFightingEquipment = { - automaticAlarmSystem:{name:'自动报警系统',total:'',details:''},//自动报警系统 - firePump:{name:'消防泵',total:'',details:''}//消防泵 + automaticAlarmSystem: { name: '自动报警系统', total: '', details: '' },//自动报警系统 + firePump: { name: '消防泵', total: '', details: '' }//消防泵 } this.hydrantSystem = { - fireExtinguishingAgent:{name:'灭火剂',total:'',details:''},//灭火剂 - AlarmFacilities:{name:'报警设施',total:'',details:''},//报警设施 - FireControlPipeNetwork:{name:'消防管网',total:'',details:''}//消防管网 + fireExtinguishingAgent: { name: '灭火剂', total: '', details: '' },//灭火剂 + AlarmFacilities: { name: '报警设施', total: '', details: '' },//报警设施 + FireControlPipeNetwork: { name: '消防管网', total: '', details: '' }//消防管网 } this.otherFacilities = { - givePriorityToBroadcast:{name:'优先广播',total:'',details:''},//优先广播 - VIdetector:{name:'VI检测仪',total:'',details:''},//VI检测仪 - foamWaterSpraySystem:{name:'泡沫水喷雾系统',total:'',details:''},//泡沫水喷雾系统 + givePriorityToBroadcast: { name: '优先广播', total: '', details: '' },//优先广播 + VIdetector: { name: 'VI检测仪', total: '', details: '' },//VI检测仪 + foamWaterSpraySystem: { name: '泡沫水喷雾系统', total: '', details: '' },//泡沫水喷雾系统 } this.automaticFireProtectionFacility = { - fireSprinklingSystem:{name:'喷水灭火系统',total:'',details:''},//喷水灭火系统 - automaticAlarmSystem:{name:'自动报警系统',total:'',details:''},//自动报警系统 - smokeControlAndExhaustSystem:{name:'防排烟系统',total:'',details:''},//防排烟系统 - waterCurtainSystem:{name:'水幕系统',total:'',details:''},//水幕系统 - firePump:{name:'消防泵',total:'',details:''}//消防泵 + fireSprinklingSystem: { name: '喷水灭火系统', total: '', details: '' },//喷水灭火系统 + automaticAlarmSystem: { name: '自动报警系统', total: '', details: '' },//自动报警系统 + smokeControlAndExhaustSystem: { name: '防排烟系统', total: '', details: '' },//防排烟系统 + waterCurtainSystem: { name: '水幕系统', total: '', details: '' },//水幕系统 + firePump: { name: '消防泵', total: '', details: '' }//消防泵 } this.fireWaterSupply = { - firePool:{name:'消防水池',total:'',details:''}//消防水池 + firePool: { name: '消防水池', total: '', details: '' }//消防水池 } } //将数据库获取的手动输入的值变成指定形式 - changeData(){ + changeData() { this.emptyData(); - this.FacilityStat.length != 0 ? - this.FacilityStat.forEach(element => { - if(element.groupName == '消防水系统'){ - if(element.facilityName == '供水管网'){ - this.fireProtectionWaterSystem.waterSupplyNetwork.total = element.count - this.fireProtectionWaterSystem.waterSupplyNetwork.details = element.description - }else if(element.facilityName == '自动喷水灭火系统'){ - this.fireProtectionWaterSystem.sprinklerSystem.total = element.count - this.fireProtectionWaterSystem.sprinklerSystem.details = element.description - } - }else if(element.groupName == '消防灭火给水系统'){ - if(element.facilityName == '自动喷水灭火系统'){ - this.FireExtinguishingWaterSupplySystem.sprinklerSystem.total = element.count - this.FireExtinguishingWaterSupplySystem.sprinklerSystem.details = element.description - }else if(element.facilityName == '气体自动灭火系统'){ - this.FireExtinguishingWaterSupplySystem.AutomaticGasFireExtinguishingSystem.total = element.count - this.FireExtinguishingWaterSupplySystem.AutomaticGasFireExtinguishingSystem.details = element.description - }else if(element.facilityName == '消防泵房'){ - this.FireExtinguishingWaterSupplySystem.firePumpRoom.total = element.count - this.FireExtinguishingWaterSupplySystem.firePumpRoom.details = element.description - } - }else if(element.groupName == '其它'){ - if(element.facilityName == '排烟系统'){ - this.other.purgingSystem.total = element.count - this.other.purgingSystem.details = element.description - }else if(element.facilityName == '灭火器'){ - this.other.fireExtinguisher.total = element.count - this.other.fireExtinguisher.details = element.description - }else if(element.facilityName == '气体灭火'){ - this.other.extinctionUsingGas.total = element.count - this.other.extinctionUsingGas.details = element.description - }else if(element.facilityName == '消防通信'){ - this.other.fireControlCommunication.total = element.count - this.other.fireControlCommunication.details = element.description - } - }else if(element.groupName == '消防设施'){ - if(element.facilityName == '自动报警系统'){ - this.fireFightingEquipment.automaticAlarmSystem.total = element.count - this.fireFightingEquipment.automaticAlarmSystem.details = element.description - }else if(element.facilityName == '消防泵'){ - this.fireFightingEquipment.firePump.total = element.count - this.fireFightingEquipment.firePump.details = element.description - } - }else if(element.groupName == '消火栓系统'){ - if(element.facilityName == '灭火剂'){ - this.hydrantSystem.fireExtinguishingAgent.total = element.count - this.hydrantSystem.fireExtinguishingAgent.details = element.description - }else if(element.facilityName == '报警设施'){ - this.hydrantSystem.AlarmFacilities.total = element.count - this.hydrantSystem.AlarmFacilities.details = element.description - }else if(element.facilityName == '消防管网'){ - this.hydrantSystem.FireControlPipeNetwork.total = element.count - this.hydrantSystem.FireControlPipeNetwork.details = element.description - } - }else if(element.groupName == '其它设施'){ - if(element.facilityName == '优先广播'){ - this.otherFacilities.givePriorityToBroadcast.total = element.count - this.otherFacilities.givePriorityToBroadcast.details = element.description - }else if(element.facilityName == 'VI检测仪'){ - this.otherFacilities.VIdetector.total = element.count - this.otherFacilities.VIdetector.details = element.description - }else if(element.facilityName == '泡沫水喷雾系统'){ - this.otherFacilities.foamWaterSpraySystem.total = element.count - this.otherFacilities.foamWaterSpraySystem.details = element.description - } - }else if(element.groupName == '自动消防设施'){ - if(element.facilityName == '喷水灭火系统'){ - this.automaticFireProtectionFacility.fireSprinklingSystem.total = element.count - this.automaticFireProtectionFacility.fireSprinklingSystem.details = element.description - }else if(element.facilityName == '自动报警系统'){ - this.automaticFireProtectionFacility.automaticAlarmSystem.total = element.count - this.automaticFireProtectionFacility.automaticAlarmSystem.details = element.description - }else if(element.facilityName == '防排烟系统'){ - this.automaticFireProtectionFacility.smokeControlAndExhaustSystem.total = element.count - this.automaticFireProtectionFacility.smokeControlAndExhaustSystem.details = element.description - }else if(element.facilityName == '水幕系统'){ - this.automaticFireProtectionFacility.waterCurtainSystem.total = element.count - this.automaticFireProtectionFacility.waterCurtainSystem.details = element.description - }else if(element.facilityName == '消防泵'){ - this.automaticFireProtectionFacility.firePump.total = element.count - this.automaticFireProtectionFacility.firePump.details = element.description - } - }else if(element.groupName == '消防水源'){ - if(element.facilityName == '消防水池'){ - this.fireWaterSupply.firePool.total = element.count - this.fireWaterSupply.firePool.details = element.description + this.FacilityStat.length != 0 ? + this.FacilityStat.forEach(element => { + if (element.groupName == '消防水系统') { + if (element.facilityName == '供水管网') { + this.fireProtectionWaterSystem.waterSupplyNetwork.total = element.count + this.fireProtectionWaterSystem.waterSupplyNetwork.details = element.description + } else if (element.facilityName == '自动喷水灭火系统') { + this.fireProtectionWaterSystem.sprinklerSystem.total = element.count + this.fireProtectionWaterSystem.sprinklerSystem.details = element.description + } + } else if (element.groupName == '消防灭火给水系统') { + if (element.facilityName == '自动喷水灭火系统') { + this.FireExtinguishingWaterSupplySystem.sprinklerSystem.total = element.count + this.FireExtinguishingWaterSupplySystem.sprinklerSystem.details = element.description + } else if (element.facilityName == '气体自动灭火系统') { + this.FireExtinguishingWaterSupplySystem.AutomaticGasFireExtinguishingSystem.total = element.count + this.FireExtinguishingWaterSupplySystem.AutomaticGasFireExtinguishingSystem.details = element.description + } else if (element.facilityName == '消防泵房') { + this.FireExtinguishingWaterSupplySystem.firePumpRoom.total = element.count + this.FireExtinguishingWaterSupplySystem.firePumpRoom.details = element.description + } + } else if (element.groupName == '其它') { + if (element.facilityName == '排烟系统') { + this.other.purgingSystem.total = element.count + this.other.purgingSystem.details = element.description + } else if (element.facilityName == '灭火器') { + this.other.fireExtinguisher.total = element.count + this.other.fireExtinguisher.details = element.description + } else if (element.facilityName == '气体灭火') { + this.other.extinctionUsingGas.total = element.count + this.other.extinctionUsingGas.details = element.description + } else if (element.facilityName == '消防通信') { + this.other.fireControlCommunication.total = element.count + this.other.fireControlCommunication.details = element.description + } + } else if (element.groupName == '消防设施') { + if (element.facilityName == '自动报警系统') { + this.fireFightingEquipment.automaticAlarmSystem.total = element.count + this.fireFightingEquipment.automaticAlarmSystem.details = element.description + } else if (element.facilityName == '消防泵') { + this.fireFightingEquipment.firePump.total = element.count + this.fireFightingEquipment.firePump.details = element.description + } + } else if (element.groupName == '消火栓系统') { + if (element.facilityName == '灭火剂') { + this.hydrantSystem.fireExtinguishingAgent.total = element.count + this.hydrantSystem.fireExtinguishingAgent.details = element.description + } else if (element.facilityName == '报警设施') { + this.hydrantSystem.AlarmFacilities.total = element.count + this.hydrantSystem.AlarmFacilities.details = element.description + } else if (element.facilityName == '消防管网') { + this.hydrantSystem.FireControlPipeNetwork.total = element.count + this.hydrantSystem.FireControlPipeNetwork.details = element.description + } + } else if (element.groupName == '其它设施') { + if (element.facilityName == '优先广播') { + this.otherFacilities.givePriorityToBroadcast.total = element.count + this.otherFacilities.givePriorityToBroadcast.details = element.description + } else if (element.facilityName == 'VI检测仪') { + this.otherFacilities.VIdetector.total = element.count + this.otherFacilities.VIdetector.details = element.description + } else if (element.facilityName == '泡沫水喷雾系统') { + this.otherFacilities.foamWaterSpraySystem.total = element.count + this.otherFacilities.foamWaterSpraySystem.details = element.description + } + } else if (element.groupName == '自动消防设施') { + if (element.facilityName == '喷水灭火系统') { + this.automaticFireProtectionFacility.fireSprinklingSystem.total = element.count + this.automaticFireProtectionFacility.fireSprinklingSystem.details = element.description + } else if (element.facilityName == '自动报警系统') { + this.automaticFireProtectionFacility.automaticAlarmSystem.total = element.count + this.automaticFireProtectionFacility.automaticAlarmSystem.details = element.description + } else if (element.facilityName == '防排烟系统') { + this.automaticFireProtectionFacility.smokeControlAndExhaustSystem.total = element.count + this.automaticFireProtectionFacility.smokeControlAndExhaustSystem.details = element.description + } else if (element.facilityName == '水幕系统') { + this.automaticFireProtectionFacility.waterCurtainSystem.total = element.count + this.automaticFireProtectionFacility.waterCurtainSystem.details = element.description + } else if (element.facilityName == '消防泵') { + this.automaticFireProtectionFacility.firePump.total = element.count + this.automaticFireProtectionFacility.firePump.details = element.description + } + } else if (element.groupName == '消防水源') { + if (element.facilityName == '消防水池') { + this.fireWaterSupply.firePool.total = element.count + this.fireWaterSupply.firePool.details = element.description + } } - } - }) : null + }) : null } //创建建筑消防设施内置分组项 - addBuildingGrouping (e,item) { - let data = {buildingId: e.id, item} - let dialogRef = this.dialog.open(ImgsDataDetail,{data}); - dialogRef.afterClosed().subscribe(data=>{ - if (data) { item.facilityItems.push(data) } - }); + addBuildingGrouping(e, item) { + let data = { buildingId: e.id, item } + let dialogRef = this.dialog.open(ImgsDataDetail, { data }); + dialogRef.afterClosed().subscribe(data => { + if (data) { item.facilityItems.push(data) } + }); } //保存建筑消防设施内置分组项 - editBuildingGrouping (e,item) { - function returnBody(object,groupName){ + editBuildingGrouping(e, item) { + function returnBody(object, groupName) { let body = [] for (const key in object) { if (Object.prototype.hasOwnProperty.call(object, key)) { @@ -489,85 +518,86 @@ export class FireFightingDeviceComponent implements OnInit { } return body } - let companyId = this.route.snapshot.queryParams.id - let header = {companyId:companyId,buildingId:e.id, groupId:item.id} - let data = [] - item.facilityItems.forEach((element,index) => { + let companyId = this.route.snapshot.queryParams.id + let header = { companyId: companyId, buildingId: e.id, groupId: item.id } + let data = [] + item.facilityItems.forEach((element, index) => { let msg = { isBuiltin: element.isBuiltin, details: element.details, name: element.name, isEachFloor: element.isEachFloor, - order: element.order} + order: element.order + } data.push(msg) - if (index==item.facilityItems.length-1) { - this.http.post('/api/BuildingFacilityItems/Batch',data,{params:header}).subscribe(data=>{ + if (index == item.facilityItems.length - 1) { + this.http.post('/api/BuildingFacilityItems/Batch', data, { params: header }).subscribe(data => { let putBody - if(item.name == '消防水源'){ - putBody = returnBody(this.fireWaterSupply,'消防水源') - }else if(item.name == '消防水系统'){ - putBody = returnBody(this.fireProtectionWaterSystem,'消防水系统') - }else if(item.name == '消防灭火给水系统'){ - putBody = returnBody(this.FireExtinguishingWaterSupplySystem,'消防灭火给水系统') - }else if(item.name == '其它'){ - putBody = returnBody(this.other,'其它') - }else if(item.name == '消防设施'){ - putBody = returnBody(this.fireFightingEquipment,'消防设施') - }else if(item.name == '消火栓系统'){ - putBody = returnBody(this.hydrantSystem,'消火栓系统') - }else if(item.name == '其它设施'){ - putBody = returnBody(this.otherFacilities,'其它设施') - }else if(item.name == '自动消防设施'){ - putBody = returnBody(this.automaticFireProtectionFacility,'自动消防设施') + if (item.name == '消防水源') { + putBody = returnBody(this.fireWaterSupply, '消防水源') + } else if (item.name == '消防水系统') { + putBody = returnBody(this.fireProtectionWaterSystem, '消防水系统') + } else if (item.name == '消防灭火给水系统') { + putBody = returnBody(this.FireExtinguishingWaterSupplySystem, '消防灭火给水系统') + } else if (item.name == '其它') { + putBody = returnBody(this.other, '其它') + } else if (item.name == '消防设施') { + putBody = returnBody(this.fireFightingEquipment, '消防设施') + } else if (item.name == '消火栓系统') { + putBody = returnBody(this.hydrantSystem, '消火栓系统') + } else if (item.name == '其它设施') { + putBody = returnBody(this.otherFacilities, '其它设施') + } else if (item.name == '自动消防设施') { + putBody = returnBody(this.automaticFireProtectionFacility, '自动消防设施') } - if(putBody.length != 0){ - this.http.put('/api/BuildingFacilities/FacilityStatUpdate',putBody,{ - params:{ - buildingId : item.buildingId + if (putBody.length != 0) { + this.http.put('/api/BuildingFacilities/FacilityStatUpdate', putBody, { + params: { + buildingId: item.buildingId } }).subscribe(data => { const config = new MatSnackBarConfig(); config.verticalPosition = 'top'; config.duration = 3000 - this.snackBar.open('数据更新成功','确定',config); + this.snackBar.open('数据更新成功', '确定', config); this.tabbarService.sendMessage('changeScore');//通知服务改变分数 - },err => { + }, err => { const config = new MatSnackBarConfig(); config.verticalPosition = 'top'; config.duration = 3000 - this.snackBar.open('更新失败','确定',config); + this.snackBar.open('更新失败', '确定', config); }) - }else{ + } else { const config = new MatSnackBarConfig(); config.verticalPosition = 'top'; config.duration = 3000 - this.snackBar.open('数据更新成功','确定',config); + this.snackBar.open('数据更新成功', '确定', config); this.tabbarService.sendMessage('changeScore');//通知服务改变分数 } - },err => { + }, err => { const config = new MatSnackBarConfig(); config.verticalPosition = 'top'; config.duration = 3000 - this.snackBar.open('更新失败','确定',config); - }) + this.snackBar.open('更新失败', '确定', config); + }) } }); //forEach } //删除建筑消防设施内置分组项 - deleteBuildingGrouping (e,item) { + deleteBuildingGrouping(e, item) { if (item.selectBuiltInGrouping.length) { let isDelete = confirm('您确定要删除吗') if (isDelete) { - let msg:any = `?buildingId=${e.id}&groupId=${item.id}` - item.selectBuiltInGrouping.forEach((element,index) => { + let msg: any = `?buildingId=${e.id}&groupId=${item.id}` + item.selectBuiltInGrouping.forEach((element, index) => { let data = `&name=${element.name}` msg = msg + data - if (index === item.selectBuiltInGrouping.length-1) { - this.http.delete('/api/BuildingFacilityItems/Batch'+msg).subscribe(data=>{ + if (index === item.selectBuiltInGrouping.length - 1) { + this.http.delete('/api/BuildingFacilityItems/Batch' + msg).subscribe(data => { let deleteMsg = item.selectBuiltInGrouping deleteMsg.forEach(deleteElement => { - item.facilityItems.splice(item.facilityItems.findIndex(items=>items.name==deleteElement.name),1) + item.facilityItems.splice(item.facilityItems.findIndex(items => items.name == deleteElement.name), 1) }); item.selectBuiltInGrouping = [] this.tabbarService.sendMessage('changeScore');//通知服务改变分数 @@ -575,36 +605,38 @@ export class FireFightingDeviceComponent implements OnInit { } //if }) //forEach } - } else { - const config = new MatSnackBarConfig(); - config.verticalPosition = 'top'; - config.duration = 3000 - this.snackBar.open('请选择内置分组项','确定',config); + } else { + const config = new MatSnackBarConfig(); + config.verticalPosition = 'top'; + config.duration = 3000 + this.snackBar.open('请选择内置分组项', '确定', config); } } //保存建筑消防设施可选分组 - editBuildingOptional (e,item) { - let companyId = this.route.snapshot.queryParams.id + editBuildingOptional(e, item) { + let companyId = this.route.snapshot.queryParams.id e.stopPropagation() //阻止冒泡 - item.propertyInfos.forEach((element,index) => { + item.propertyInfos.forEach((element, index) => { element.propertyValue = String(element.propertyValue) - if (index == item.propertyInfos.length-1 ) { - this.http.post('/api/BuildingOptionalGroups',item,{params:{ - companyId :companyId - }}).subscribe(data=>{ + if (index == item.propertyInfos.length - 1) { + this.http.post('/api/BuildingOptionalGroups', item, { + params: { + companyId: companyId + } + }).subscribe(data => { const config = new MatSnackBarConfig(); config.verticalPosition = 'top'; config.duration = 3000 - this.snackBar.open('数据更新成功','确定',config); + this.snackBar.open('数据更新成功', '确定', config); this.tabbarService.sendMessage('changeScore');//通知服务改变分数 }) } //if - }); + }); } //建筑消防设施切换展开面板 - SwitchBuildingBoard (item,e) { + SwitchBuildingBoard(item, e) { e.expanded = !e.expanded if (e.expanded) { //展开面板展开时 if (e.isEachFloor) { //逐层统计时 @@ -612,58 +644,66 @@ export class FireFightingDeviceComponent implements OnInit { if (data) { e.loopTable = [] data.forEach(item => { - let tableMsg = {name:item.name, header:[], body:[]} + let tableMsg = { name: item.name, header: [], body: [] } item.assets[0].propertyInfos.forEach(element => { //表头 - if (element.propertyType!=3) { - let unit = element.physicalUnit? '('+ element.physicalUnit +')' : '' //单位 - tableMsg.header.push(element.propertyName+unit)} + if (element.propertyType != 3) { + let unit = element.physicalUnit ? '(' + element.physicalUnit + ')' : '' //单位 + tableMsg.header.push(element.propertyName + unit) + } }); item.assets.forEach(element => { //表格内容 let everyBody = {} - element.propertyInfos.forEach((elements,index) => { - if (elements.propertyType!=3 && elements.propertyName!='图片' && elements.propertyType!=6) { - let unit = elements.physicalUnit? '('+ elements.physicalUnit +')' : '' //单位 - everyBody[elements.propertyName+unit] = elements.propertyValue } - if (elements.propertyType==6) { - let unit = elements.physicalUnit? '('+ elements.physicalUnit +')' : '' //单位 - everyBody[elements.propertyName+unit] = elements.propertyValue=='1'?'是':'否' } - if (elements.propertyType!=3 && elements.propertyName=='图片') { + element.propertyInfos.forEach((elements, index) => { + if (elements.propertyType != 3 && elements.propertyName != '图片' && elements.propertyType != 6) { + let unit = elements.physicalUnit ? '(' + elements.physicalUnit + ')' : '' //单位 + everyBody[elements.propertyName + unit] = elements.propertyValue + } + if (elements.propertyType == 6) { + let unit = elements.physicalUnit ? '(' + elements.physicalUnit + ')' : '' //单位 + everyBody[elements.propertyName + unit] = elements.propertyValue == '1' ? '是' : '否' + } + if (elements.propertyType != 3 && elements.propertyName == '图片') { let imgLength = [] - element.propertyInfos.find(item=>{ if(item.propertyType==3){imgLength.push(item)} }) - let unit = elements.physicalUnit? '('+ elements.physicalUnit +')' : '' //单位 - everyBody[elements.propertyName+unit] = String(imgLength.length) } + element.propertyInfos.find(item => { if (item.propertyType == 3) { imgLength.push(item) } }) + let unit = elements.physicalUnit ? '(' + elements.physicalUnit + ')' : '' //单位 + everyBody[elements.propertyName + unit] = String(imgLength.length) + } }); //propertyInfos tableMsg.body.push(everyBody) }); //assets e.loopTable.push(tableMsg) }); - + } //data有数据时 } else { //非逐层统计时 let data = item.buildingDetails[e.name] - if (data) { + if (data) { e.header = [] e.body = [] data[0].propertyInfos.forEach(element => { //表头 - if (element.propertyType!=3) { - let unit = element.physicalUnit? '('+ element.physicalUnit +')' : '' //单位 - e.header.push(element.propertyName+unit)} + if (element.propertyType != 3) { + let unit = element.physicalUnit ? '(' + element.physicalUnit + ')' : '' //单位 + e.header.push(element.propertyName + unit) + } }); data.forEach(element => { //表格内容 let everyBody = {} - element.propertyInfos.forEach((elements,index) => { - if (elements.propertyType!=3 && elements.propertyName!='图片' && elements.propertyType!=6) { - let unit = elements.physicalUnit? '('+ elements.physicalUnit +')' : '' //单位 - everyBody[elements.propertyName+unit] = elements.propertyValue } - if (elements.propertyType==6) { - let unit = elements.physicalUnit? '('+ elements.physicalUnit +')' : '' //单位 - everyBody[elements.propertyName+unit] = elements.propertyValue=='1'?'是':'否' } - if (elements.propertyType!=3 && elements.propertyName=='图片') { + element.propertyInfos.forEach((elements, index) => { + if (elements.propertyType != 3 && elements.propertyName != '图片' && elements.propertyType != 6) { + let unit = elements.physicalUnit ? '(' + elements.physicalUnit + ')' : '' //单位 + everyBody[elements.propertyName + unit] = elements.propertyValue + } + if (elements.propertyType == 6) { + let unit = elements.physicalUnit ? '(' + elements.physicalUnit + ')' : '' //单位 + everyBody[elements.propertyName + unit] = elements.propertyValue == '1' ? '是' : '否' + } + if (elements.propertyType != 3 && elements.propertyName == '图片') { let imgLength = [] - element.propertyInfos.find(item=>{ if(item.propertyType==3){imgLength.push(item)} }) - let unit = elements.physicalUnit? '('+ elements.physicalUnit +')' : '' //单位 - everyBody[elements.propertyName+unit] = String(imgLength.length) } + element.propertyInfos.find(item => { if (item.propertyType == 3) { imgLength.push(item) } }) + let unit = elements.physicalUnit ? '(' + elements.physicalUnit + ')' : '' //单位 + everyBody[elements.propertyName + unit] = String(imgLength.length) + } }); e.body.push(everyBody) @@ -678,124 +718,135 @@ export class FireFightingDeviceComponent implements OnInit { } //单位消防设施预览图片 - previewImg (e) { + previewImg(e) { if (e.isEachFloor) { //逐层统计时 let newData = this.companyEachDetails[e.name] if (newData) { - let data = {name:e.name, images:[]} - let imgName + let data = { name: e.name, images: [] } + let imgName newData.forEach(item => { item.assets.forEach(element => { - element.propertyInfos.forEach( elements => { - if (elements.propertyName.includes('名称')) {imgName = elements.propertyValue} - if (elements.propertyType===3) { - elements.propertyName = imgName - data.images.push(elements)} }); + element.propertyInfos.forEach(elements => { + if (elements.propertyName.includes('名称')) { imgName = elements.propertyValue } + if (elements.propertyType === 3) { + elements.propertyName = imgName + data.images.push(elements) + } + }); }); }); //newDate if (data.images.length) { - let dialogRef = this.dialog.open(ImagesData,{data}); //打开图片弹窗 + let dialogRef = this.dialog.open(ImagesData, { data }); //打开图片弹窗 } else { const config = new MatSnackBarConfig(); config.verticalPosition = 'top'; config.duration = 3000 - this.snackBar.open('暂无图片数据','确定',config); + this.snackBar.open('暂无图片数据', '确定', config); } - } else{ + } else { const config = new MatSnackBarConfig(); config.verticalPosition = 'top'; config.duration = 3000 - this.snackBar.open('暂无图片数据','确定',config); } + this.snackBar.open('暂无图片数据', '确定', config); + } } else { //非逐层统计时 let newData = this.companyDetails[e.name] - let imgName + let imgName if (newData) { - let data = {name:e.name, images:[]} + let data = { name: e.name, images: [] } newData.forEach(element => { - element.propertyInfos.forEach(elements => { - if (elements.propertyName.includes('名称')) {imgName = elements.propertyValue} - if (elements.propertyType===3) { + element.propertyInfos.forEach(elements => { + if (elements.propertyName.includes('名称')) { imgName = elements.propertyValue } + if (elements.propertyType === 3) { elements.propertyName = imgName - data.images.push(elements)} }); + data.images.push(elements) + } + }); }); if (data.images.length) { - let dialogRef = this.dialog.open(ImagesData,{data}); //打开图片弹窗 + let dialogRef = this.dialog.open(ImagesData, { data }); //打开图片弹窗 } else { const config = new MatSnackBarConfig(); config.verticalPosition = 'top'; config.duration = 3000 - this.snackBar.open('暂无图片数据','确定',config); + this.snackBar.open('暂无图片数据', '确定', config); } - + } else { const config = new MatSnackBarConfig(); config.verticalPosition = 'top'; config.duration = 3000 - this.snackBar.open('暂无图片数据','确定',config); } + this.snackBar.open('暂无图片数据', '确定', config); + } } } //建筑消防设施预览图片 - previewBuildingImg (item,e) { + previewBuildingImg(item, e) { if (e.isEachFloor) { //逐层统计时 let newData = item.buildingEachDetails[e.name] if (newData) { - let data = {name:e.name, images:[]} + let data = { name: e.name, images: [] } let imgName newData.forEach(item => { item.assets.forEach(element => { - element.propertyInfos.forEach( elements => { - if (elements.propertyName.includes('名称')) {imgName = elements.propertyValue} - if (elements.propertyType===3) { - elements.propertyName = imgName - data.images.push(elements)} }); + element.propertyInfos.forEach(elements => { + if (elements.propertyName.includes('名称')) { imgName = elements.propertyValue } + if (elements.propertyType === 3) { + elements.propertyName = imgName + data.images.push(elements) + } + }); }); }); //newDate - + if (data.images.length) { - let dialogRef = this.dialog.open(ImagesData,{data}); //打开图片弹窗 + let dialogRef = this.dialog.open(ImagesData, { data }); //打开图片弹窗 } else { const config = new MatSnackBarConfig(); config.verticalPosition = 'top'; config.duration = 3000 - this.snackBar.open('暂无图片数据','确定',config); + this.snackBar.open('暂无图片数据', '确定', config); } - } else{ + } else { const config = new MatSnackBarConfig(); config.verticalPosition = 'top'; config.duration = 3000 - this.snackBar.open('暂无图片数据','确定',config); } + this.snackBar.open('暂无图片数据', '确定', config); + } } else { //非逐层统计时 let newData = item.buildingDetails[e.name] - let imgName + let imgName if (newData) { - let data = {name:e.name, images:[]} + let data = { name: e.name, images: [] } newData.forEach(element => { - element.propertyInfos.forEach(elements => { - if (elements.propertyName.includes('名称')) {imgName = elements.propertyValue} - if (elements.propertyType===3) { + element.propertyInfos.forEach(elements => { + if (elements.propertyName.includes('名称')) { imgName = elements.propertyValue } + if (elements.propertyType === 3) { elements.propertyName = imgName - data.images.push(elements)} - }); + data.images.push(elements) + } + }); }); if (data.images.length) { - let dialogRef = this.dialog.open(ImagesData,{data}); //打开图片弹窗 + let dialogRef = this.dialog.open(ImagesData, { data }); //打开图片弹窗 } else { const config = new MatSnackBarConfig(); config.verticalPosition = 'top'; config.duration = 3000 - this.snackBar.open('暂无图片数据','确定',config); + this.snackBar.open('暂无图片数据', '确定', config); } - + } else { const config = new MatSnackBarConfig(); config.verticalPosition = 'top'; config.duration = 3000 - this.snackBar.open('暂无图片数据','确定',config); } + this.snackBar.open('暂无图片数据', '确定', config); + } } }