上海预案管理平台
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.
 
 
 
 
 

219 lines
6.5 KiB

import { Component, OnInit, Inject } from '@angular/core';
import { HttpClient, HttpHeaders } from '@angular/common/http';
import { MatDialog, MatDialogRef, MAT_DIALOG_DATA } from '@angular/material/dialog';
import { MatSnackBar, MatSnackBarConfig } from '@angular/material/snack-bar';
@Component({
selector: 'app-leftFunctionalDomain-plan',
templateUrl: './addPlaneFigure.html',
styleUrls: ['./panel.scss']
})
export class leftFunctionalDomainComponentPlan implements OnInit {
constructor(
private http:HttpClient,
public dialog: MatDialog,
public snackBar: MatSnackBar,
public dialogRef: MatDialogRef<any>,
@Inject(MAT_DIALOG_DATA) public data) { }
ngOnInit(): void {
}
params = {companyId: sessionStorage.getItem('companyId')}
checked:boolean = false;//是否为避难层
file:any = null; //上传的文件
//选择文件
selectFile (e) {
if (e.target.files.length) {
let maxSize = 5*1024*1024
if (e.target.files[0].size <= maxSize) {
this.file = e.target.files[0]
} else {
const config = new MatSnackBarConfig();
config.verticalPosition = 'top';
config.duration = 3000
this.snackBar.open('上传图片需小于5MB','确定',config);
}
}
}
//导入GIS
toGIS () {
const config = new MatSnackBarConfig();
config.verticalPosition = 'top';
config.duration = 3000
this.snackBar.open('功能开发测试中,即将上线','确定',config);
}
//提交表单创建平面图
onSubmit (e) {
if (this.file) {
let formData = new FormData()
formData.append("file",this.file)
this.http.post(`/api/Objects/WebPlan2D/${sessionStorage.getItem('companyId')}`,formData).subscribe((data:any)=>{
let imgURL = '/api/Objects/WebPlan2D/' + data.objectName
console.log(imgURL)
if (!this.data.isBuilding) { //总平面图 创建平面图
let data = {
companyId: sessionStorage.getItem('companyId'),
name: e.name,
order: this.data.order,
area:e.area,
details:e.details,
enabled: true,
modifiedTime: new Date(),
imageUrl: imgURL,
}
this.http.post('/api/SitePlans',data).subscribe(data=>{
this.dialogRef.close('总平面图');
})
} else { //建筑 创建楼层/区域
let data = {
isRefugeStorey: e.isRefugeStorey,
buildingId: this.data.Panel.id,
name: e.name,
order: this.data.order,
area:e.area,
details:e.details,
enabled: true,
modifiedTime: new Date(),
imageUrl: imgURL,
}
this.http.post('/api/BuildingAreas',data,{params:this.params}).subscribe(data=>{
this.dialogRef.close('建筑');
})
}
}) //post
} else {
const config = new MatSnackBarConfig();
config.verticalPosition = 'top';
config.duration = 3000
this.snackBar.open('请上传图片','确定',config);
}
}
}
//编辑平面图 楼层/区域
@Component({
selector: 'app-editPlaneFigure-plan',
templateUrl: './editPlaneFigure.html',
styleUrls: ['./panel.scss']
})
export class editPlaneFigureComponentPlan implements OnInit {
constructor(private http:HttpClient,public dialog: MatDialog,public snackBar: MatSnackBar,public dialogRef: MatDialogRef<any>,@Inject(MAT_DIALOG_DATA) public data) { }
ngOnInit(): void {
this.name = this.data.buildingData.name || ''
this.checked = this.data.buildingData.isRefugeStorey || false
this.area = this.data.buildingData.area || 0
this.details = this.data.buildingData.details || ''
}
params = {companyId: sessionStorage.getItem('companyId')}
name:any; //name
checked:boolean = false;//是否为避难层
area:number; //面积
details:string; //详情
//提交表单修改平面图
onSubmit (e) {
if (!this.data.isBuilding) { //总平面图 修改平面图
let data = {
companyId: sessionStorage.getItem('companyId'),
id: this.data.buildingData.id,
name: e.name,
cadUrl: this.data.buildingData.cadUrl,
imageUrl: this.data.buildingData.imageUrl,
imageAngle: this.data.buildingData.imageAngle,
order: this.data.buildingData.order,
area:e.area,
details:e.details,
enabled: this.data.buildingData.enabled,
modifiedTime: new Date(),
}
this.http.put(`/api/SitePlans/${this.data.buildingData.id}`,data).subscribe(data=>{
this.dialogRef.close('总平面图');
})
} else { //建筑 修改楼层/区域
let data = {
isRefugeStorey: e.isRefugeStorey,
buildingId: this.data.Panel.id,
id: this.data.buildingData.id,
name: e.name,
cadUrl: this.data.buildingData.cadUrl,
imageUrl: this.data.buildingData.imageUrl,
imageAngle: this.data.buildingData.imageAngle,
order: this.data.buildingData.order,
area:e.area,
details:e.details,
enabled: this.data.buildingData.enabled,
modifiedTime: new Date(),
}
this.http.put(`/api/BuildingAreas/${this.data.buildingData.id}`,data,{params:this.params}).subscribe(data=>{
this.dialogRef.close('建筑');
})
}
}
}
//创建 处置预案 节点
@Component({
selector: 'app-addDisposalNode-plan',
templateUrl: './addDisposalNode.html',
styleUrls: ['./panel.scss']
})
export class addDisposalNodeComponentPlan implements OnInit {
constructor(private http:HttpClient,public dialog: MatDialog,public snackBar: MatSnackBar,public dialogRef: MatDialogRef<any>,@Inject(MAT_DIALOG_DATA) public data) { }
ngOnInit(): void {
}
//提交表单
onSubmit (e) {
this.data.name = e.name
this.http.post('/api/DisposalNodes',this.data).subscribe(data=>{
this.dialogRef.close('success');
})
}
}
//编辑 处置预案 节点
@Component({
selector: 'app-editDisposalNode-plan',
templateUrl: './editDisposalNode.html',
styleUrls: ['./panel.scss']
})
export class editDisposalNodeComponentPlan implements OnInit {
constructor(private http:HttpClient,public dialog: MatDialog,public snackBar: MatSnackBar,public dialogRef: MatDialogRef<any>,@Inject(MAT_DIALOG_DATA) public data) { }
ngOnInit(): void {
this.nodeName = JSON.parse(JSON.stringify( this.data.name || '' ))
}
nodeName:string;
//提交表单
onSubmit (e) {
this.data.name = e.name
this.http.put(`/api/DisposalNodes/${this.data.id}`,this.data).subscribe(data=>{
this.dialogRef.close(e.name);
})
}
}