Browse Source

[完善]上传底图限制到100M

上海一张图
邵佳豪 4 years ago
parent
commit
f6c1985fde
  1. 6
      src/app/ui/collection-tools-building/collection-tools.component.ts
  2. 6
      src/app/ui/collection-tools-plan/collection-tools.component.ts
  3. 4
      src/app/ui/collection-tools-plan/leftFunctionalDomain.ts
  4. 6
      src/app/ui/collection-tools/collection-tools.component.ts
  5. 122
      src/app/ui/collection-tools/leftFunctionalDomain.ts

6
src/app/ui/collection-tools-building/collection-tools.component.ts

@ -2086,7 +2086,7 @@ export class CollectionToolsBuildingComponent implements OnInit {
let file = e.target.files[0] || null //获取上传的文件
let fileSize = file.size || null //上传文件的总大小
let maxSize = 5 * 1024 * 1024 //5MB一个分片
let tenSize = 10 * 1024 * 1024 //10MB限制
let tenSize = 100 * 1024 * 1024 //100MB限制
if (file && file.name.toLowerCase().indexOf('png') == -1 && file.name.toLowerCase().indexOf('jpg') == -1 && file.name.toLowerCase().indexOf('jpeg') == -1) {
const config = new MatSnackBarConfig();
config.verticalPosition = 'top';
@ -2101,14 +2101,14 @@ export class CollectionToolsBuildingComponent implements OnInit {
this.http.post(`/api/Objects/WebPlan2D/${sessionStorage.getItem('companyId')}`, formData).subscribe((data: any) => {
this.renovateBaseMap('/api/Objects/WebPlan2D/' + data.objectName, item)
})
} else if (file && fileSize > maxSize && fileSize < tenSize) { //上传文件>10MB时
} else if (file && fileSize > maxSize && fileSize < tenSize) { //上传文件>100MB时
let upload = this.canvasData.sectionUpload(sessionStorage.getItem('companyId'), file)
upload.then(res => { this.renovateBaseMap('/api/Objects/PlanPlatform/' + res, item) })
} else {
const config = new MatSnackBarConfig();
config.verticalPosition = 'top';
config.duration = 3000
this.snackBar.open('上传底图需小于10MB', '确定', config);
this.snackBar.open('上传底图需小于100MB', '确定', config);
}
}

6
src/app/ui/collection-tools-plan/collection-tools.component.ts

@ -2059,7 +2059,7 @@ export class CollectionToolsPlanComponent implements OnInit {
let file = e.target.files[0] || null //获取上传的文件
let fileSize = file.size || null //上传文件的总大小
let maxSize = 5 * 1024 * 1024 //5MB一个分片
let tenSize = 10 * 1024 * 1024 //10MB限制
let tenSize = 100 * 1024 * 1024 //100MB限制
if (file && file.name.toLowerCase().indexOf('png') == -1 && file.name.toLowerCase().indexOf('jpg') == -1 && file.name.toLowerCase().indexOf('jpeg') == -1) {
const config = new MatSnackBarConfig();
config.verticalPosition = 'top';
@ -2074,14 +2074,14 @@ export class CollectionToolsPlanComponent implements OnInit {
this.http.post(`/api/Objects/WebPlan2D/${sessionStorage.getItem('companyId')}`, formData).subscribe((data: any) => {
this.renovateBaseMap('/api/Objects/WebPlan2D/' + data.objectName, item)
})
} else if (file && fileSize > maxSize && fileSize < tenSize) { //上传文件>10MB时
} else if (file && fileSize > maxSize && fileSize < tenSize) { //上传文件5-100MB时
let upload = this.canvasData.sectionUpload(sessionStorage.getItem('companyId'), file)
upload.then(res => { this.renovateBaseMap('/api/Objects/PlanPlatform/' + res, item) })
} else {
const config = new MatSnackBarConfig();
config.verticalPosition = 'top';
config.duration = 3000
this.snackBar.open('上传底图需小于10MB', '确定', config);
this.snackBar.open('上传底图需小于100MB', '确定', config);
}
}

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

@ -31,7 +31,7 @@ export class leftFunctionalDomainComponentPlan implements OnInit {
//选择文件
selectFile (e) {
if (e.target.files.length) {
let maxSize = 10*1024*1024 //10MB限制
let maxSize = 100*1024*1024 //100MB限制
if (e.target.files[0].size <= maxSize) {
this.file = e.target.files[0]
this.selectedType = 'image'
@ -39,7 +39,7 @@ export class leftFunctionalDomainComponentPlan implements OnInit {
const config = new MatSnackBarConfig();
config.verticalPosition = 'top';
config.duration = 3000
this.snackBar.open('上传图片需小于10MB','确定',config);
this.snackBar.open('上传图片需小于100MB','确定',config);
}
}
}

6
src/app/ui/collection-tools/collection-tools.component.ts

@ -2155,7 +2155,7 @@ export class CollectionToolsComponent implements OnInit {
let file = e.target.files[0] || null //获取上传的文件
let fileSize = file.size || null //上传文件的总大小
let maxSize = 5 * 1024 * 1024 //5MB一个分片
let tenSize = 10 * 1024 * 1024 //10MB限制
let tenSize = 100 * 1024 * 1024 //100MB限制
if (file && file.name.toLowerCase().indexOf('png') == -1 && file.name.toLowerCase().indexOf('jpg') == -1 && file.name.toLowerCase().indexOf('jpeg') == -1) {
const config = new MatSnackBarConfig();
config.verticalPosition = 'top';
@ -2170,14 +2170,14 @@ export class CollectionToolsComponent implements OnInit {
this.http.post(`/api/Objects/WebPlan2D/${sessionStorage.getItem('companyId')}`, formData).subscribe((data: any) => {
this.renovateBaseMap('/api/Objects/WebPlan2D/' + data.objectName, item)
})
} else if (file && fileSize > maxSize && fileSize < tenSize) { //上传文件>10MB时
} else if (file && fileSize > maxSize && fileSize < tenSize) { //上传文件>100MB时
let upload = this.canvasData.sectionUpload(sessionStorage.getItem('companyId'), file)
upload.then(res => { this.renovateBaseMap('/api/Objects/PlanPlatform/' + res, item) })
} else {
const config = new MatSnackBarConfig();
config.verticalPosition = 'top';
config.duration = 3000
this.snackBar.open('上传底图需小于10MB', '确定', config);
this.snackBar.open('上传底图需小于100MB', '确定', config);
}
}

122
src/app/ui/collection-tools/leftFunctionalDomain.ts

@ -13,7 +13,7 @@ import { CanvasShareDataService } from 'src/app/canvas-share-data.service';
export class leftFunctionalDomainComponent implements OnInit {
constructor(
private http:HttpClient,
private http: HttpClient,
public dialog: MatDialog,
public snackBar: MatSnackBar,
public dialogRef: MatDialogRef<any>,
@ -23,22 +23,22 @@ export class leftFunctionalDomainComponent implements OnInit {
}
params = {companyId: sessionStorage.getItem('companyId')}
checked:boolean = false;//是否为避难层
params = { companyId: sessionStorage.getItem('companyId') }
checked: boolean = false;//是否为避难层
//提交表单创建平面图
onSubmit (e) {
onSubmit(e) {
if (!this.data.isBuilding) { //总平面图 创建平面图
let data = {
companyId: sessionStorage.getItem('companyId'),
name: e.name,
order: this.data.order,
area:Number(e.area),
details:e.details,
area: Number(e.area),
details: e.details,
enabled: true,
modifiedTime: new Date(),
}
this.http.post('/api/SitePlans',data).subscribe(data=>{
this.http.post('/api/SitePlans', data).subscribe(data => {
this.dialogRef.close('总平面图');
})
} else { //建筑 创建楼层/区域
@ -47,12 +47,12 @@ export class leftFunctionalDomainComponent implements OnInit {
buildingId: this.data.Panel.id,
name: e.name,
order: this.data.order,
area:Number(e.area),
details:e.details,
area: Number(e.area),
details: e.details,
enabled: true,
modifiedTime: new Date(),
}
this.http.post('/api/BuildingAreas',data,{params:this.params}).subscribe(data=>{
this.http.post('/api/BuildingAreas', data, { params: this.params }).subscribe(data => {
this.dialogRef.close('建筑');
})
}
@ -70,7 +70,7 @@ 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,public canvasData: CanvasShareDataService,private eventManager: EventManager,) { }
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 || ''
@ -81,17 +81,17 @@ export class editPlaneFigureComponent implements OnInit {
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) {
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))
that.imgScale = Number((that.imgWidth / that.imgHeight))
}
} else {
this.imgScale = Number((this.imgWidth/this.imgHeight))
this.imgScale = Number((this.imgWidth / this.imgHeight))
}
this.eventManager.addGlobalEventListener('window', 'keydown', (event: any) => {
@ -101,22 +101,22 @@ export class editPlaneFigureComponent implements OnInit {
});
}
oldWidth:number; //原图片宽
oldHeight:number; //原图片高
oldWidth: number; //原图片宽
oldHeight: number; //原图片高
params = {companyId: sessionStorage.getItem('companyId')}
name:any; //name
checked:boolean = false;//是否为避难层
area:number; //面积
details:string; //详情
params = { companyId: sessionStorage.getItem('companyId') }
name: any; //name
checked: boolean = false;//是否为避难层
area: number; //面积
details: string; //详情
imgWidth:number; //图片宽度
imgHeight:number; //图片高度
isItEqual:boolean = true; //是否等比
imgScale:number; //图片 宽高比例
imgWidth: number; //图片宽度
imgHeight: number; //图片高度
isItEqual: boolean = true; //是否等比
imgScale: number; //图片 宽高比例
//图片 宽高变化时
inputChange (e) {
inputChange(e) {
if (this.isItEqual) {
if (e == 0) { //需要改高度
this.imgHeight = Math.round(this.imgWidth / this.imgScale)
@ -134,12 +134,12 @@ export class editPlaneFigureComponent implements OnInit {
}
//重新计算 宽高比例
setImgScale (e) {
e.checked? this.imgScale = Number((this.imgWidth/this.imgHeight)) : null
setImgScale(e) {
e.checked ? this.imgScale = Number((this.imgWidth / this.imgHeight)) : null
}
//关闭
close () {
close() {
if (this.oldWidth === this.imgWidth && this.oldHeight === this.imgHeight) {
this.dialogRef.close()
} else {
@ -150,7 +150,7 @@ export class editPlaneFigureComponent implements OnInit {
}
//提交表单修改平面图
onSubmit (e) {
onSubmit(e) {
if (!this.data.isBuilding) { //总平面图 修改平面图
let data = {
companyId: sessionStorage.getItem('companyId'),
@ -162,12 +162,12 @@ export class editPlaneFigureComponent implements OnInit {
imageHeight: this.imgHeight,
imageAngle: this.data.buildingData.imageAngle,
order: this.data.buildingData.order,
area:e.area,
details:e.details,
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.http.put(`/api/SitePlans/${this.data.buildingData.id}`, data).subscribe(data => {
this.dialogRef.close('总平面图');
})
} else { //建筑 修改楼层/区域
@ -182,12 +182,12 @@ export class editPlaneFigureComponent implements OnInit {
imageHeight: this.imgHeight,
imageAngle: this.data.buildingData.imageAngle,
order: this.data.buildingData.order,
area:e.area,
details:e.details,
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.http.put(`/api/BuildingAreas/${this.data.buildingData.id}`, data, { params: this.params }).subscribe(data => {
this.dialogRef.close('建筑');
})
}
@ -207,43 +207,43 @@ export class editPlaneFigureComponent implements OnInit {
})
export class addBGCDisposalNodeComponent 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) { }
ngOnInit(): void { }
ngOnInit(): void { }
file:any = null; //文件
file: any = null; //文件
//上传图片
selectFile (e) {
selectFile(e) {
if (e.target.files.length) {
let maxSize = 10*1024*1024
let maxSize = 100 * 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('上传图片需小于10MB','确定',config);
this.snackBar.open('上传图片需小于100MB', '确定', config);
}
}
}
//提交表单
onSubmit (e) {
onSubmit(e) {
if (e.name && this.file) {
     if (this.file.name.toLowerCase().indexOf('png') == -1 && this.file.name.toLowerCase().indexOf('jpg') == -1 && this.file.name.toLowerCase().indexOf('jpeg') == -1) {
      const config = new MatSnackBarConfig();
      config.verticalPosition = 'top';
      config.duration = 3000
      this.snackBar.open('请上传图片后缀为png,jpg,jpeg的文件', '确定', config);
      return
    }
if (this.file.name.toLowerCase().indexOf('png') == -1 && this.file.name.toLowerCase().indexOf('jpg') == -1 && this.file.name.toLowerCase().indexOf('jpeg') == -1) {
const config = new MatSnackBarConfig();
config.verticalPosition = 'top';
config.duration = 3000
this.snackBar.open('请上传图片后缀为png,jpg,jpeg的文件', '确定', config);
return
}
e.file = this.file
this.dialogRef.close(e);
} else {
const config = new MatSnackBarConfig();
config.verticalPosition = 'top';
config.duration = 3000
this.snackBar.open('请上传图片','确定',config);
this.snackBar.open('请上传图片', '确定', config);
}
}
@ -259,15 +259,15 @@ export class addBGCDisposalNodeComponent implements OnInit {
})
export class addDisposalNodeComponent 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) { }
ngOnInit(): void {
}
//提交表单
onSubmit (e) {
onSubmit(e) {
this.data.name = e.name
this.http.post('/api/DisposalNodes',this.data).subscribe(data=>{
this.http.post('/api/DisposalNodes', this.data).subscribe(data => {
this.dialogRef.close('success');
})
}
@ -284,17 +284,17 @@ export class addDisposalNodeComponent implements OnInit {
})
export class editDisposalNodeComponent 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) { }
ngOnInit(): void {
this.nodeName = JSON.parse(JSON.stringify( this.data.name || '' ))
this.nodeName = JSON.parse(JSON.stringify(this.data.name || ''))
}
nodeName:string;
nodeName: string;
//提交表单
onSubmit (e) {
onSubmit(e) {
this.data.name = e.name
this.http.put(`/api/DisposalNodes/${this.data.id}`,this.data).subscribe(data=>{
this.http.put(`/api/DisposalNodes/${this.data.id}`, this.data).subscribe(data => {
this.dialogRef.close(e.name);
})
}

Loading…
Cancel
Save