|
|
|
@ -1,8 +1,9 @@
|
|
|
|
|
import { Component, OnInit, ViewChild, Inject } from '@angular/core'; |
|
|
|
|
import {HttpClient} from '@angular/common/http' |
|
|
|
|
import {HttpClient, HttpHeaders} from '@angular/common/http' |
|
|
|
|
import { MatDialogRef, MatDialog, MAT_DIALOG_DATA } from '@angular/material/dialog'; |
|
|
|
|
import { MatTableDataSource } from '@angular/material/table'; |
|
|
|
|
import { ImagesData } from './imagesdata.component' |
|
|
|
|
import { ImgsDataDetail } from './addGrouping.component' |
|
|
|
|
import { MatSnackBarConfig, MatSnackBar } from '@angular/material/snack-bar'; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -13,12 +14,12 @@ import { ImagesData } from './imagesdata.component'
|
|
|
|
|
}) |
|
|
|
|
export class FireFightingDeviceComponent implements OnInit { |
|
|
|
|
|
|
|
|
|
constructor(public http: HttpClient,public dialog: MatDialog) { } |
|
|
|
|
constructor(public http: HttpClient,public dialog: MatDialog,public snackBar: MatSnackBar) { } |
|
|
|
|
|
|
|
|
|
displayedColumns: string[] = ['checked','project', 'phone', 'mainmsg']; |
|
|
|
|
|
|
|
|
|
ngOnInit(): void { |
|
|
|
|
// this.getCompanyInformation()
|
|
|
|
|
this.getCompanyInformation() |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
companyBuiltInGrouping:any = []; //单位消防设施内置分组
|
|
|
|
@ -30,18 +31,85 @@ export class FireFightingDeviceComponent implements OnInit {
|
|
|
|
|
if (data.buildingTypes.length) { |
|
|
|
|
let newData = {buildingType: data.buildingTypes[0].id} |
|
|
|
|
this.http.get('/api/CompanyAccount/CompanyFacilities',{params:newData}).subscribe((data:any)=>{ //获得单位的消防设施
|
|
|
|
|
this.companyBuiltInGrouping = data[0].companyFacilityGroups |
|
|
|
|
this.companyOptionalGrouping = data[0].companyOptionalGroups |
|
|
|
|
this.companyBuiltInGrouping = data[0].summary.companyFacilityGroups |
|
|
|
|
this.companyOptionalGrouping = data[0].summary.companyOptionalGroups |
|
|
|
|
this.companyBuiltInGrouping.forEach(element => { //循环单位内置分组项
|
|
|
|
|
element.selectBuiltInGrouping = [] |
|
|
|
|
element.facilityItems.forEach(elements => { |
|
|
|
|
elements.expanded = false}); |
|
|
|
|
}); |
|
|
|
|
console.log(this.companyBuiltInGrouping,this.companyOptionalGrouping) |
|
|
|
|
console.log(this.companyBuiltInGrouping) |
|
|
|
|
console.log(this.companyOptionalGrouping) |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//创建单位消防设施内置分组项
|
|
|
|
|
addCompanyGrouping (e) { |
|
|
|
|
let data = e |
|
|
|
|
let dialogRef = this.dialog.open(ImgsDataDetail,{data}); |
|
|
|
|
dialogRef.afterClosed().subscribe(data=>{ |
|
|
|
|
if (data) {this.editCompanyGrouping(e)} });
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//保存单位消防设施内置分组项
|
|
|
|
|
editCompanyGrouping(e) { |
|
|
|
|
let header = {groupId:e.id} |
|
|
|
|
e.facilityItems.forEach((element,index) => { |
|
|
|
|
if (!element.isBuiltin) { |
|
|
|
|
let msg = { |
|
|
|
|
isBuiltin: element.isBuiltin, |
|
|
|
|
details: element.details, |
|
|
|
|
name: element.name, |
|
|
|
|
isEachFloor: element.isEachFloor, |
|
|
|
|
order: element.order} |
|
|
|
|
this.http.post('/api/CompanyAccount/CompanyFacilityItems',msg,{params:header}).subscribe(data=>{ |
|
|
|
|
if (index==e.facilityItems.length-1) { |
|
|
|
|
this.getCompanyInformation() |
|
|
|
|
const config = new MatSnackBarConfig(); |
|
|
|
|
config.verticalPosition = 'top'; |
|
|
|
|
config.duration = 3000 |
|
|
|
|
this.snackBar.open('数据更新成功','确定',config);} |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//checked单位消防设施内置分组项时
|
|
|
|
|
checkedCompany (e,item,items) { |
|
|
|
|
if (e.checked) { |
|
|
|
|
item.selectBuiltInGrouping.push(items) |
|
|
|
|
} else { |
|
|
|
|
item.selectBuiltInGrouping.splice(item.selectBuiltInGrouping.findIndex(oldItem => oldItem == items), 1) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//删除消防设施内置分组项时
|
|
|
|
|
deleteCompanyGrouping (e) { |
|
|
|
|
if (e.selectBuiltInGrouping.length) { |
|
|
|
|
let isDelete = confirm('您确定要删除吗') |
|
|
|
|
if (isDelete) { |
|
|
|
|
e.selectBuiltInGrouping.forEach((element,index) => { |
|
|
|
|
let msg = {groupId:e.id,name:element.name} |
|
|
|
|
this.http.delete('/api/CompanyAccount/CompanyFacilityItems',{params:msg}).subscribe(data=>{ |
|
|
|
|
if (index==e.selectBuiltInGrouping.length-1){this.getCompanyInformation()}}) |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
const config = new MatSnackBarConfig(); |
|
|
|
|
config.verticalPosition = 'top'; |
|
|
|
|
config.duration = 3000 |
|
|
|
|
this.snackBar.open('请选择内置分组项','确定',config); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//保存单位消防设施可选分组
|
|
|
|
|
editCompanyOptional (e,item) { |
|
|
|
|
e.stopPropagation() //阻止冒泡
|
|
|
|
|
console.log(item) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//切换展开面板
|
|
|
|
|
SwitchBoard (e) { |
|
|
|
|
e.expanded = !e.expanded |
|
|
|
|