chenjingyu 4 years ago
parent
commit
93a8c0a80a
  1. 125
      src/app/ui/collection-tools-plan/leftFunctionalDomain.ts
  2. 1
      src/app/ui/collection-tools-plan/panel.scss

125
src/app/ui/collection-tools-plan/leftFunctionalDomain.ts

@ -17,7 +17,7 @@ export class leftFunctionalDomainComponentPlan implements OnInit {
public dialog: MatDialog, public dialog: MatDialog,
public snackBar: MatSnackBar, public snackBar: MatSnackBar,
public dialogRef: MatDialogRef<any>, public dialogRef: MatDialogRef<any>,
@Inject(MAT_DIALOG_DATA) public data) { } @Inject(MAT_DIALOG_DATA) public data,public canvasData: CanvasShareDataService,) { }
ngOnInit(): void { ngOnInit(): void {
@ -30,7 +30,7 @@ export class leftFunctionalDomainComponentPlan implements OnInit {
//选择文件 //选择文件
selectFile (e) { selectFile (e) {
if (e.target.files.length) { if (e.target.files.length) {
let maxSize = 5*1024*1024 let maxSize = 10*1024*1024 //10MB限制
if (e.target.files[0].size <= maxSize) { if (e.target.files[0].size <= maxSize) {
this.file = e.target.files[0] this.file = e.target.files[0]
} else { } else {
@ -53,41 +53,96 @@ export class leftFunctionalDomainComponentPlan implements OnInit {
//提交表单创建平面图 //提交表单创建平面图
onSubmit (e) { onSubmit (e) {
if (this.file) { if (this.file) {
let formData = new FormData() if (this.file.size<=5*1024*1024) { //小于5MB
formData.append("file",this.file) let formData = new FormData()
this.http.post(`/api/Objects/WebPlan2D/${sessionStorage.getItem('companyId')}`,formData).subscribe((data:any)=>{ formData.append("file",this.file)
let imgURL = '/api/Objects/WebPlan2D/' + data.objectName this.http.post(`/api/Objects/WebPlan2D/${sessionStorage.getItem('companyId')}`,formData).subscribe((data:any)=>{
if (!this.data.isBuilding) { //总平面图 创建平面图 let imgURL = '/api/Objects/WebPlan2D/' + data.objectName
let data = { let that = this
companyId: sessionStorage.getItem('companyId'), let img = new Image()
name: e.name, img.src = imgURL
order: this.data.order, img.onload = function () {
area:Number(e.area), if (!that.data.isBuilding) { //总平面图 创建平面图
details:e.details, let data = {
enabled: true, companyId: sessionStorage.getItem('companyId'),
modifiedTime: new Date(), name: e.name,
imageUrl: imgURL, 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=>{ }) //post
this.dialogRef.close('总平面图'); } 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)
} else { //建筑 创建楼层/区域 upload.then(res=>{
let data = { let imgURL = '/api/Objects/PlanPlatform/' + res
isRefugeStorey: e.isRefugeStorey, let that = this
buildingId: this.data.Panel.id, let img = new Image()
name: e.name, img.src = imgURL
order: this.data.order, img.onload = function () {
area:Number(e.area), if (!that.data.isBuilding) { //总平面图 创建平面图
details:e.details, let data = {
enabled: true, companyId: sessionStorage.getItem('companyId'),
modifiedTime: new Date(), name: e.name,
imageUrl: imgURL, 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 { } else {
const config = new MatSnackBarConfig(); const config = new MatSnackBarConfig();
config.verticalPosition = 'top'; config.verticalPosition = 'top';

1
src/app/ui/collection-tools-plan/panel.scss

@ -299,6 +299,7 @@
} }
} }
.image { .image {
text-align: left;
.mat-form-field { .mat-form-field {
margin-right: 15px; margin-right: 15px;
width: 30%; width: 30%;

Loading…
Cancel
Save