You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
69 lines
2.4 KiB
69 lines
2.4 KiB
import { Component, OnInit, Inject } from '@angular/core'; |
|
import { HttpClient } from '@angular/common/http'; |
|
import {MatDialog, MatDialogRef, MAT_DIALOG_DATA} from '@angular/material/dialog'; |
|
import { MatSnackBar, MatSnackBarConfig } from '@angular/material/snack-bar'; |
|
|
|
|
|
|
|
@Component({ |
|
selector: 'imgsdatadetail', |
|
templateUrl: './addGrouping.html', |
|
styleUrls: ['./fire-fighting-device.component.scss'] |
|
}) |
|
export class ImgsDataDetail2 { |
|
|
|
constructor(private http: HttpClient,public dialogRef: MatDialogRef<ImgsDataDetail2>,@Inject(MAT_DIALOG_DATA) public data,public snackBar: MatSnackBar) {} |
|
|
|
ngOnInit(): void { |
|
|
|
} |
|
|
|
ngAfterViewInit(): void{ |
|
|
|
} |
|
|
|
//提交表单 |
|
onSubmit (e) { |
|
if (this.data.buildingId) { //建筑新建内置项 |
|
let repeat = this.data.item.facilityItems.find(items=>items.name==e.name) |
|
if (repeat==undefined) { |
|
let header = {buildingId:this.data.buildingId, groupId:this.data.item.id} |
|
let msg = { |
|
isBuiltin: false, |
|
details: '', |
|
name: e.name, |
|
isEachFloor: false, |
|
order: this.data.item.facilityItems.length? this.data.item.facilityItems[this.data.item.facilityItems.length-1].order+1 : 0} |
|
this.http.post('/api/CompanyAccount/BuildingFacilityItems',msg,{params:header}).subscribe(data=>{ |
|
this.dialogRef.close(data); }) |
|
} else { |
|
const config = new MatSnackBarConfig(); |
|
config.verticalPosition = 'top'; |
|
config.duration = 3000 |
|
this.snackBar.open('当前分组下禁止创建名称相同内置项','确定',config); |
|
} |
|
} else { //单位新建内置项 |
|
let repeat = this.data.facilityItems.find(item=>item.name==e.name) |
|
if (repeat==undefined) { |
|
let header = {groupId:this.data.id} |
|
let msg = { |
|
isBuiltin: false, |
|
details: '', |
|
name: e.name, |
|
isEachFloor: false, |
|
order: this.data.facilityItems.length? this.data.facilityItems[this.data.facilityItems.length-1].order+1 : 0} |
|
this.http.post('/api/CompanyAccount/CompanyFacilityItems',msg,{params:header}).subscribe(data=>{ |
|
this.dialogRef.close(data); }) |
|
} else { |
|
const config = new MatSnackBarConfig(); |
|
config.verticalPosition = 'top'; |
|
config.duration = 3000 |
|
this.snackBar.open('当前分组下禁止创建名称相同内置项','确定',config); |
|
} |
|
} //else |
|
} |
|
|
|
|
|
|
|
} |
|
|