|
|
|
@ -7,6 +7,10 @@ import { MatSnackBarConfig, MatSnackBar } from '@angular/material/snack-bar';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
export interface Food { |
|
|
|
|
value: string; |
|
|
|
|
name: string; |
|
|
|
|
} |
|
|
|
|
@Component({ |
|
|
|
|
selector: 'app-fire-fighting-device', |
|
|
|
|
templateUrl: './fire-fighting-device.component.html', |
|
|
|
@ -16,12 +20,16 @@ export class FireFightingDeviceComponent implements OnInit {
|
|
|
|
|
|
|
|
|
|
constructor(public http: HttpClient,public dialog: MatDialog,public snackBar: MatSnackBar) { } |
|
|
|
|
|
|
|
|
|
displayedColumns: string[] = ['checked','project', 'phone', 'mainmsg']; |
|
|
|
|
|
|
|
|
|
ngOnInit(): void { |
|
|
|
|
this.getCompanyInformation() |
|
|
|
|
this.getAllBuilding() |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//定义属性数据
|
|
|
|
|
singleElection:Food[]=[ |
|
|
|
|
{value:'true', name: '有'}, |
|
|
|
|
{value:'false', name: '无'}] |
|
|
|
|
|
|
|
|
|
companyBuiltInGrouping:any = []; //单位消防设施内置分组
|
|
|
|
|
companyOptionalGrouping:any = []; //单位消防设施可选分组
|
|
|
|
|
|
|
|
|
@ -38,10 +46,8 @@ export class FireFightingDeviceComponent implements OnInit {
|
|
|
|
|
element.facilityItems.forEach(elements => { |
|
|
|
|
elements.expanded = false}); |
|
|
|
|
}); |
|
|
|
|
console.log(this.companyBuiltInGrouping) |
|
|
|
|
console.log(this.companyOptionalGrouping) |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
}) //http
|
|
|
|
|
} //if
|
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -50,30 +56,36 @@ export class FireFightingDeviceComponent implements OnInit {
|
|
|
|
|
let data = e |
|
|
|
|
let dialogRef = this.dialog.open(ImgsDataDetail,{data}); |
|
|
|
|
dialogRef.afterClosed().subscribe(data=>{ |
|
|
|
|
if (data) {this.editCompanyGrouping(e)} });
|
|
|
|
|
if (data && (e.facilityItems.find(item=>item.name==data.name))===undefined) { e.facilityItems.push(data) } });
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//保存单位消防设施内置分组项
|
|
|
|
|
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);} |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
if (e.facilityItems[e.facilityItems.length-1].isBuiltin) { |
|
|
|
|
this.getCompanyInformation() |
|
|
|
|
const config = new MatSnackBarConfig(); |
|
|
|
|
config.verticalPosition = 'top'; |
|
|
|
|
config.duration = 3000 |
|
|
|
|
this.snackBar.open('数据更新成功','确定',config); |
|
|
|
|
} else { |
|
|
|
|
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) { |
|
|
|
|
const config = new MatSnackBarConfig(); |
|
|
|
|
config.verticalPosition = 'top'; |
|
|
|
|
config.duration = 3000 |
|
|
|
|
this.snackBar.open('数据更新成功','确定',config);} }) |
|
|
|
|
} //if
|
|
|
|
|
}); //forEach
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//checked单位消防设施内置分组项时
|
|
|
|
@ -93,7 +105,8 @@ export class FireFightingDeviceComponent implements OnInit {
|
|
|
|
|
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()}}) |
|
|
|
|
e.selectBuiltInGrouping.splice(e.selectBuiltInGrouping.findIndex(old=>old===element),1) |
|
|
|
|
e.facilityItems.splice(e.facilityItems.findIndex(old=>old===element),1) }) |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
@ -107,7 +120,17 @@ export class FireFightingDeviceComponent implements OnInit {
|
|
|
|
|
//保存单位消防设施可选分组
|
|
|
|
|
editCompanyOptional (e,item) { |
|
|
|
|
e.stopPropagation() //阻止冒泡
|
|
|
|
|
console.log(item) |
|
|
|
|
item.propertyInfos.forEach((element,index) => {
|
|
|
|
|
element.propertyValue = String(element.propertyValue) |
|
|
|
|
if (index == item.propertyInfos.length-1 ) { |
|
|
|
|
this.http.post('/api/CompanyAccount/CompanyOptionalGroups',item).subscribe(data=>{ |
|
|
|
|
const config = new MatSnackBarConfig(); |
|
|
|
|
config.verticalPosition = 'top'; |
|
|
|
|
config.duration = 3000 |
|
|
|
|
this.snackBar.open('数据更新成功','确定',config); |
|
|
|
|
}) |
|
|
|
|
} //if
|
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//切换展开面板
|
|
|
|
@ -120,8 +143,33 @@ export class FireFightingDeviceComponent implements OnInit {
|
|
|
|
|
console.log('IMG') |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
allBuildingGrouping:any; //所有建筑的消防设施 内置分组+可选分组
|
|
|
|
|
//获取所有建筑
|
|
|
|
|
getAllBuilding () { |
|
|
|
|
this.http.get('/api/CompanyAccount/Buildings').subscribe((data:any)=>{ |
|
|
|
|
this.allBuildingGrouping = data |
|
|
|
|
if (this.allBuildingGrouping.length) { this.getAllBuildingFacilities() } |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//获取所有建筑的消防设施
|
|
|
|
|
getAllBuildingFacilities () { |
|
|
|
|
this.allBuildingGrouping.forEach(element => { |
|
|
|
|
let header = {buildingId: element.id, buildingType: element.buildingTypes[0].id} |
|
|
|
|
this.http.get('/api/CompanyAccount/BuildingFacilities',{params:header}).subscribe(data=>{ |
|
|
|
|
element.buildingFacilityGroups = data[0].summary.buildingFacilityGroups |
|
|
|
|
element.buildingOptionalGroups = data[0].summary.buildingOptionalGroups |
|
|
|
|
element.buildingFacilityGroups.forEach(elements => { //循环每个建筑内置分组项
|
|
|
|
|
elements.selectBuiltInGrouping = [] |
|
|
|
|
elements.facilityItems.forEach(newElement => { newElement.expanded = false }); |
|
|
|
|
}); |
|
|
|
|
}) |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|