diff --git a/src/app/ui/collection-tools-plan/leftFunctionalDomain.ts b/src/app/ui/collection-tools-plan/leftFunctionalDomain.ts index c8e18ea..cc1bd01 100644 --- a/src/app/ui/collection-tools-plan/leftFunctionalDomain.ts +++ b/src/app/ui/collection-tools-plan/leftFunctionalDomain.ts @@ -17,7 +17,7 @@ export class leftFunctionalDomainComponentPlan implements OnInit { public dialog: MatDialog, public snackBar: MatSnackBar, public dialogRef: MatDialogRef, - @Inject(MAT_DIALOG_DATA) public data) { } + @Inject(MAT_DIALOG_DATA) public data,public canvasData: CanvasShareDataService,) { } ngOnInit(): void { @@ -30,7 +30,7 @@ export class leftFunctionalDomainComponentPlan implements OnInit { //选择文件 selectFile (e) { if (e.target.files.length) { - let maxSize = 5*1024*1024 + let maxSize = 10*1024*1024 //10MB限制 if (e.target.files[0].size <= maxSize) { this.file = e.target.files[0] } else { @@ -53,41 +53,96 @@ export class leftFunctionalDomainComponentPlan implements OnInit { //提交表单创建平面图 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 - if (!this.data.isBuilding) { //总平面图 创建平面图 - let data = { - companyId: sessionStorage.getItem('companyId'), - name: e.name, - order: this.data.order, - area:Number(e.area), - details:e.details, - enabled: true, - modifiedTime: new Date(), - imageUrl: imgURL, + if (this.file.size<=5*1024*1024) { //小于5MB + 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 + let that = this + let img = new Image() + img.src = imgURL + img.onload = function () { + if (!that.data.isBuilding) { //总平面图 创建平面图 + let data = { + companyId: sessionStorage.getItem('companyId'), + name: e.name, + order: that.data.order, + area:Number(e.area), + details:e.details, + enabled: true, + modifiedTime: new Date(), + imageUrl: imgURL, + imageWidth: img.width, + imageHeight: img.height + } + that.http.post('/api/SitePlans',data).subscribe(data=>{ + that.dialogRef.close('总平面图'); + }) + } else { //建筑 创建楼层/区域 + let data = { + isRefugeStorey: e.isRefugeStorey, + buildingId: that.data.Panel.id, + name: e.name, + order: that.data.order, + area:Number(e.area), + details:e.details, + enabled: true, + modifiedTime: new Date(), + imageUrl: imgURL, + imageWidth: img.width, + imageHeight: img.height + } + that.http.post('/api/BuildingAreas',data,{params:that.params}).subscribe(data=>{ + that.dialogRef.close('建筑'); + }) + } } - 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:Number(e.area), - details:e.details, - enabled: true, - modifiedTime: new Date(), - imageUrl: imgURL, + }) //post + } else if (this.file.size>5*1024*1024 && this.file.size<=10*1024*1024) { //大于5MB + let upload = this.canvasData.sectionUpload(sessionStorage.getItem('companyId'),this.file) + upload.then(res=>{ + let imgURL = '/api/Objects/PlanPlatform/' + res + let that = this + let img = new Image() + img.src = imgURL + img.onload = function () { + if (!that.data.isBuilding) { //总平面图 创建平面图 + let data = { + companyId: sessionStorage.getItem('companyId'), + name: e.name, + order: that.data.order, + area:Number(e.area), + details:e.details, + enabled: true, + modifiedTime: new Date(), + imageUrl: imgURL, + imageWidth: img.width, + imageHeight: img.height + } + that.http.post('/api/SitePlans',data).subscribe(data=>{ + that.dialogRef.close('总平面图'); + }) + } else { //建筑 创建楼层/区域 + let data = { + isRefugeStorey: e.isRefugeStorey, + buildingId: that.data.Panel.id, + name: e.name, + order: that.data.order, + area:Number(e.area), + details:e.details, + enabled: true, + modifiedTime: new Date(), + imageUrl: imgURL, + imageWidth: img.width, + imageHeight: img.height + } + that.http.post('/api/BuildingAreas',data,{params:that.params}).subscribe(data=>{ + that.dialogRef.close('建筑'); + }) + } } - this.http.post('/api/BuildingAreas',data,{params:this.params}).subscribe(data=>{ - this.dialogRef.close('建筑'); - }) - } - }) //post + }) + } } else { const config = new MatSnackBarConfig(); config.verticalPosition = 'top'; diff --git a/src/app/ui/collection-tools-plan/panel.scss b/src/app/ui/collection-tools-plan/panel.scss index 6cf4814..822d0e6 100644 --- a/src/app/ui/collection-tools-plan/panel.scss +++ b/src/app/ui/collection-tools-plan/panel.scss @@ -299,6 +299,7 @@ } } .image { + text-align: left; .mat-form-field { margin-right: 15px; width: 30%;