|
|
|
@ -2,6 +2,8 @@ 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'; |
|
|
|
|
import { CanvasShareDataService } from 'src/app/canvas-share-data.service'; |
|
|
|
|
import { EventManager } from '@angular/platform-browser'; |
|
|
|
|
|
|
|
|
|
@Component({ |
|
|
|
|
selector: 'app-leftFunctionalDomain', |
|
|
|
@ -25,7 +27,7 @@ export class leftFunctionalDomainComponent implements OnInit {
|
|
|
|
|
companyId: sessionStorage.getItem('companyId'), |
|
|
|
|
name: e.name, |
|
|
|
|
order: this.data.order, |
|
|
|
|
area:e.area, |
|
|
|
|
area:Number(e.area), |
|
|
|
|
details:e.details, |
|
|
|
|
enabled: true, |
|
|
|
|
modifiedTime: new Date(), |
|
|
|
@ -39,7 +41,7 @@ export class leftFunctionalDomainComponent implements OnInit {
|
|
|
|
|
buildingId: this.data.Panel.id, |
|
|
|
|
name: e.name, |
|
|
|
|
order: this.data.order, |
|
|
|
|
area:e.area, |
|
|
|
|
area:Number(e.area), |
|
|
|
|
details:e.details, |
|
|
|
|
enabled: true, |
|
|
|
|
modifiedTime: new Date(), |
|
|
|
@ -62,20 +64,84 @@ export class leftFunctionalDomainComponent implements OnInit {
|
|
|
|
|
}) |
|
|
|
|
export class editPlaneFigureComponent implements OnInit { |
|
|
|
|
|
|
|
|
|
constructor(private http:HttpClient,public dialog: MatDialog,public snackBar: MatSnackBar,public dialogRef: MatDialogRef<any>,@Inject(MAT_DIALOG_DATA) public data) { } |
|
|
|
|
constructor(private http:HttpClient,public dialog: MatDialog,public snackBar: MatSnackBar,public dialogRef: MatDialogRef<any>,@Inject(MAT_DIALOG_DATA) public data,public canvasData: CanvasShareDataService,private eventManager: EventManager,) { } |
|
|
|
|
|
|
|
|
|
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 || '' |
|
|
|
|
this.imgWidth = this.data.buildingData.imageWidth || 0 |
|
|
|
|
this.imgHeight = this.data.buildingData.imageHeight || 0 |
|
|
|
|
this.oldWidth = JSON.parse(JSON.stringify(this.data.buildingData.imageWidth || 0)) |
|
|
|
|
this.oldHeight = JSON.parse(JSON.stringify(this.data.buildingData.imageHeight || 0)) |
|
|
|
|
if (this.imgWidth==0 && this.imgHeight==0 && this.data.buildingData.imageUrl) { |
|
|
|
|
let that = this |
|
|
|
|
let img = new Image() |
|
|
|
|
img.src = this.data.buildingData.imageUrl |
|
|
|
|
img.onload = function () { |
|
|
|
|
that.imgWidth = img.width |
|
|
|
|
that.imgHeight = img.height |
|
|
|
|
that.imgScale = Number((that.imgWidth/that.imgHeight)) |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
this.imgScale = Number((this.imgWidth/this.imgHeight)) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
this.eventManager.addGlobalEventListener('window', 'keydown', (event: any) => { |
|
|
|
|
if (event.keyCode === 13) { |
|
|
|
|
event.preventDefault(); |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
oldWidth:number; //原图片宽
|
|
|
|
|
oldHeight:number; //原图片高
|
|
|
|
|
|
|
|
|
|
name:any; //name
|
|
|
|
|
checked:boolean = false;//是否为避难层
|
|
|
|
|
area:number; //面积
|
|
|
|
|
details:string; //详情
|
|
|
|
|
|
|
|
|
|
imgWidth:number; //图片宽度
|
|
|
|
|
imgHeight:number; //图片高度
|
|
|
|
|
isItEqual:boolean = true; //是否等比
|
|
|
|
|
imgScale:number; //图片 宽高比例
|
|
|
|
|
|
|
|
|
|
//图片 宽高变化时
|
|
|
|
|
inputChange (e) { |
|
|
|
|
if (this.isItEqual) { |
|
|
|
|
if (e == 0) { //需要改高度
|
|
|
|
|
this.imgHeight = Math.round(this.imgWidth / this.imgScale) |
|
|
|
|
this.canvasData.selectStorey.imageWidth = this.imgWidth |
|
|
|
|
this.canvasData.selectStorey.imageHeight = this.imgHeight |
|
|
|
|
} else { //需要改宽度
|
|
|
|
|
this.imgWidth = Math.round(this.imgHeight * this.imgScale) |
|
|
|
|
this.canvasData.selectStorey.imageWidth = this.imgWidth |
|
|
|
|
this.canvasData.selectStorey.imageHeight = this.imgHeight |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
this.canvasData.selectStorey.imageWidth = this.imgWidth |
|
|
|
|
this.canvasData.selectStorey.imageHeight = this.imgHeight |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//重新计算 宽高比例
|
|
|
|
|
setImgScale (e) { |
|
|
|
|
e.checked? this.imgScale = Number((this.imgWidth/this.imgHeight)) : null |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//关闭
|
|
|
|
|
close () { |
|
|
|
|
if (this.oldWidth === this.imgWidth && this.oldHeight === this.imgHeight) { |
|
|
|
|
this.dialogRef.close() |
|
|
|
|
} else { |
|
|
|
|
this.canvasData.selectStorey.imageWidth = this.oldWidth |
|
|
|
|
this.canvasData.selectStorey.imageHeight = this.oldHeight |
|
|
|
|
this.dialogRef.close('更新背景图'); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//提交表单修改平面图
|
|
|
|
|
onSubmit (e) { |
|
|
|
|
if (!this.data.isBuilding) { //总平面图 修改平面图
|
|
|
|
@ -85,6 +151,8 @@ export class editPlaneFigureComponent implements OnInit {
|
|
|
|
|
name: e.name, |
|
|
|
|
cadUrl: this.data.buildingData.cadUrl, |
|
|
|
|
imageUrl: this.data.buildingData.imageUrl, |
|
|
|
|
imageWidth: this.imgWidth, |
|
|
|
|
imageHeight: this.imgHeight, |
|
|
|
|
imageAngle: this.data.buildingData.imageAngle, |
|
|
|
|
order: this.data.buildingData.order, |
|
|
|
|
area:e.area, |
|
|
|
@ -103,6 +171,8 @@ export class editPlaneFigureComponent implements OnInit {
|
|
|
|
|
name: e.name, |
|
|
|
|
cadUrl: this.data.buildingData.cadUrl, |
|
|
|
|
imageUrl: this.data.buildingData.imageUrl, |
|
|
|
|
imageWidth: this.imgWidth, |
|
|
|
|
imageHeight: this.imgHeight, |
|
|
|
|
imageAngle: this.data.buildingData.imageAngle, |
|
|
|
|
order: this.data.buildingData.order, |
|
|
|
|
area:e.area, |
|
|
|
|