From 38cabc485d1b99ced1b4b43d8d28a30ed8c3c678 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BE=90=E6=8C=AF=E5=8D=87?= <359059686@qq.com> Date: Fri, 29 Jan 2021 11:32:32 +0800 Subject: [PATCH 1/6] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E5=A4=9A=E9=80=89?= =?UTF-8?q?=E5=BC=80=E5=90=AF=E5=85=B3=E9=97=AD=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../working-area/working-area.component.ts | 43 +++++++++++-------- 1 file changed, 26 insertions(+), 17 deletions(-) diff --git a/src/app/working-area/working-area.component.ts b/src/app/working-area/working-area.component.ts index d07f88e..948efd4 100644 --- a/src/app/working-area/working-area.component.ts +++ b/src/app/working-area/working-area.component.ts @@ -159,24 +159,34 @@ export class WorkingAreaComponent extends EventEmitter implements OnInit, AfterV PIXI.utils.skipHello(); this.sayHello(); this.eventManager.addGlobalEventListener('window', 'keydown', (event: any) => { - event.stopPropagation(); - if (event.keyCode === 17) { - this.isCtrlKeyClicked = true; - } + // event.stopPropagation(); + // if (event.keyCode === 17) { + // this.isCtrlKeyClicked = true; + // } }); this.eventManager.addGlobalEventListener('window', 'keyup', (event: any) => { - event.stopPropagation(); - if (event.keyCode === 17) { - this.isCtrlKeyClicked = false; - this.rectToolGraphics.visible = false; - this.rectToolGraphics.clear(); - } + // event.stopPropagation(); + // if (event.keyCode === 17) { + // this.isCtrlKeyClicked = false; + // this.rectToolGraphics.visible = false; + // this.rectToolGraphics.clear(); + // } // 按Del键删除选中的图标 if (event.keyCode === 46) { this.deleteSelectedShape(); } }); } + + public setMulitSelect(b: boolean) { + if (b) { + this.isCtrlKeyClicked = true; + } else { + this.isCtrlKeyClicked = false; + this.rectToolGraphics.visible = false; + this.rectToolGraphics.clear(); + } + } /** * 删除选中的图标 */ @@ -877,7 +887,7 @@ export class WorkingAreaComponent extends EventEmitter implements OnInit, AfterV /** * 刷新背景图 */ - public async refreshBackgroundImage(imageUrl: string = this.canvasData.selectStorey.imageUrl, imageAngle: number = this.canvasData.selectStorey.imageAngle): Promise { + public async refreshBackgroundImage(imageUrl: string, imageAngle: number): Promise { if (imageUrl === undefined || imageUrl === null || imageUrl === '') { this.backgroundImage.visible = false; } else { @@ -911,9 +921,8 @@ export class WorkingAreaComponent extends EventEmitter implements OnInit, AfterV * @param imageUrl * @param imageAngle */ - public async refresh(imageUrl: string = this.canvasData.selectStorey.imageUrl, - imageAngle: number = this.canvasData.selectStorey.imageAngle): Promise { - await this.refreshBackgroundImage(); + public async refresh(): Promise { + await this.refreshBackgroundImage(this.canvasData.selectStorey.imageUrl, this.canvasData.selectStorey.imageAngle); // 清空所有图形 this.deselectAll(); const itemList = []; @@ -1319,7 +1328,7 @@ export class WorkingAreaComponent extends EventEmitter implements OnInit, AfterV * 考生点击楼层 */ public async onExamineeClickFloor() { - await this.refreshBackgroundImage(); + await this.refreshBackgroundImage(this.canvasData.selectStorey.imageUrl,this.canvasData.selectStorey.imageAngle); // 清空所有图形 this.deselectAll(); const itemList = []; @@ -1346,7 +1355,7 @@ export class WorkingAreaComponent extends EventEmitter implements OnInit, AfterV * 考官点击楼层-阅卷 */ public async onExaminerClickFloor() { - await this.refreshBackgroundImage(); + await this.refreshBackgroundImage(this.canvasData.selectStorey.imageUrl,this.canvasData.selectStorey.imageAngle); // 清空所有图形 this.deselectAll(); const itemList = []; @@ -1372,7 +1381,7 @@ export class WorkingAreaComponent extends EventEmitter implements OnInit, AfterV * 考官点击楼层-创建试卷 */ public async onExaminerClickFloor_CreateTestpaper() { - await this.refreshBackgroundImage(); + await this.refreshBackgroundImage(this.canvasData.selectStorey.imageUrl,this.canvasData.selectStorey.imageAngle); // 清空所有图形 this.deselectAll(); const itemList = []; From 3ef4a31df601c1763b565411b33194d48d9e4eaa Mon Sep 17 00:00:00 2001 From: cpf <1105965053@qq.com> Date: Fri, 29 Jan 2021 11:36:16 +0800 Subject: [PATCH 2/6] =?UTF-8?q?[=E5=AE=8C=E5=96=84]=20=E4=BF=AE=E6=AD=A3?= =?UTF-8?q?=E5=BA=95=E5=9B=BE=E9=99=90=E5=88=B610MB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../collection-tools-building/collection-tools.component.ts | 2 +- .../ui/collection-tools-plan/collection-tools.component.ts | 2 +- src/app/ui/collection-tools-plan/leftFunctionalDomain.ts | 2 +- src/app/ui/collection-tools/collection-tools.component.ts | 5 +++-- src/app/ui/collection-tools/leftFunctionalDomain.ts | 2 +- 5 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/app/ui/collection-tools-building/collection-tools.component.ts b/src/app/ui/collection-tools-building/collection-tools.component.ts index 4a50aa3..ddc4db5 100644 --- a/src/app/ui/collection-tools-building/collection-tools.component.ts +++ b/src/app/ui/collection-tools-building/collection-tools.component.ts @@ -1934,7 +1934,7 @@ export class CollectionToolsBuildingComponent implements OnInit { e.stopPropagation(); let file = e.target.files[0] || null //获取上传的文件 let fileSize = file.size || null //上传文件的总大小 - let maxSize = 5 * 1024 * 1024 //5MB一个分片 + let maxSize = 10 * 1024 * 1024 //5MB一个分片 if (file && fileSize<=maxSize) { //上传文件<=5MB时 let formData = new FormData() diff --git a/src/app/ui/collection-tools-plan/collection-tools.component.ts b/src/app/ui/collection-tools-plan/collection-tools.component.ts index f797fd0..833bfd9 100644 --- a/src/app/ui/collection-tools-plan/collection-tools.component.ts +++ b/src/app/ui/collection-tools-plan/collection-tools.component.ts @@ -1944,7 +1944,7 @@ export class CollectionToolsPlanComponent implements OnInit { e.stopPropagation(); let file = e.target.files[0] || null //获取上传的文件 let fileSize = file.size || null //上传文件的总大小 - let maxSize = 5 * 1024 * 1024 //5MB一个分片 + let maxSize = 10 * 1024 * 1024 //5MB一个分片 if (file && fileSize<=maxSize) { //上传文件<=5MB时 let formData = new FormData() diff --git a/src/app/ui/collection-tools-plan/leftFunctionalDomain.ts b/src/app/ui/collection-tools-plan/leftFunctionalDomain.ts index b010e94..06d9f09 100644 --- a/src/app/ui/collection-tools-plan/leftFunctionalDomain.ts +++ b/src/app/ui/collection-tools-plan/leftFunctionalDomain.ts @@ -28,7 +28,7 @@ export class leftFunctionalDomainComponentPlan implements OnInit { //选择文件 selectFile (e) { if (e.target.files.length) { - let maxSize = 5*1024*1024 + let maxSize = 10*1024*1024 if (e.target.files[0].size <= maxSize) { this.file = e.target.files[0] } else { diff --git a/src/app/ui/collection-tools/collection-tools.component.ts b/src/app/ui/collection-tools/collection-tools.component.ts index 3787df7..328b79e 100644 --- a/src/app/ui/collection-tools/collection-tools.component.ts +++ b/src/app/ui/collection-tools/collection-tools.component.ts @@ -1594,7 +1594,7 @@ export class CollectionToolsComponent implements OnInit { } sitePlanData:any = []; //总平面图 楼层/区域 数据 - selectingSitePlan:any; //选中的 平面图 楼层/区域 + selectingSitePlan:any = {id:null}; //选中的 平面图 楼层/区域 selectSitePlanIndex:number; //选中的 平面图 楼层/区域 index //获取总平面图 @@ -1970,7 +1970,7 @@ export class CollectionToolsComponent implements OnInit { e.stopPropagation(); let file = e.target.files[0] || null //获取上传的文件 let fileSize = file.size || null //上传文件的总大小 - let maxSize = 5 * 1024 * 1024 //5MB一个分片 + let maxSize = 10 * 1024 * 1024 //5MB一个分片 if (file && fileSize<=maxSize) { //上传文件<=5MB时 let formData = new FormData() @@ -2123,6 +2123,7 @@ export class CollectionToolsComponent implements OnInit { //获取所有处置节点 getDisposalNode () { this.selectDisposalNode = '' + this.canvasData.selectPanelPoint = new DisposalNodeData(); let params = {disasterId: this.allFirePlan[0].id || ''} this.http.get('/api/DisasterData/Markers',{params:params}).subscribe(data=>{ //灾情标签信息 this.canvasData.allNodeMarkers = data diff --git a/src/app/ui/collection-tools/leftFunctionalDomain.ts b/src/app/ui/collection-tools/leftFunctionalDomain.ts index 9703cd8..c73da68 100644 --- a/src/app/ui/collection-tools/leftFunctionalDomain.ts +++ b/src/app/ui/collection-tools/leftFunctionalDomain.ts @@ -145,7 +145,7 @@ export class addBGCDisposalNodeComponent implements OnInit { //上传图片 selectFile (e) { if (e.target.files.length) { - let maxSize = 5*1024*1024 + let maxSize = 10*1024*1024 if (e.target.files[0].size <= maxSize) { this.file = e.target.files[0] } else { From 315cbba5413609f92e19b3b9616020cf347dd28a Mon Sep 17 00:00:00 2001 From: cpf <1105965053@qq.com> Date: Fri, 29 Jan 2021 12:22:07 +0800 Subject: [PATCH 3/6] =?UTF-8?q?[=E5=AE=8C=E5=96=84]=20=E5=A4=9A=E9=80=89,?= =?UTF-8?q?=20=E8=87=AA=E5=AE=9A=E4=B9=89=E5=A4=84=E7=BD=AE=E9=A2=84?= =?UTF-8?q?=E6=A1=88=E5=BA=95=E5=9B=BE=E8=A7=92=E5=BA=A6=20=E5=AE=8C?= =?UTF-8?q?=E5=96=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/app/canvas-share-data.service.ts | 1 - .../collection-tools.component.ts | 8 ++++---- .../collection-tools.component.ts | 8 ++++---- .../collection-tools/collection-tools.component.html | 2 +- .../ui/collection-tools/collection-tools.component.ts | 11 +++++++---- 5 files changed, 16 insertions(+), 14 deletions(-) diff --git a/src/app/canvas-share-data.service.ts b/src/app/canvas-share-data.service.ts index afffbeb..8e15703 100644 --- a/src/app/canvas-share-data.service.ts +++ b/src/app/canvas-share-data.service.ts @@ -20,7 +20,6 @@ export class CanvasShareDataService { isChange:boolean = false; // 数据 是否改动 selectTemplateData:any; // 选择当前 模板数据 - isMultiSelect:boolean = false; // 单选/多选 模板图标 // 总平面图/建筑 楼层 selectStorey: any = {area: '', details: ''}; // 选择当前 楼层 数据 diff --git a/src/app/ui/collection-tools-building/collection-tools.component.ts b/src/app/ui/collection-tools-building/collection-tools.component.ts index ddc4db5..b7429e8 100644 --- a/src/app/ui/collection-tools-building/collection-tools.component.ts +++ b/src/app/ui/collection-tools-building/collection-tools.component.ts @@ -1806,14 +1806,14 @@ export class CollectionToolsBuildingComponent implements OnInit { this.http.put(`/api/SitePlans/${item.id}`,item).subscribe(data=>{ let isSuccess = this.renovateSitePlan() isSuccess.then(res=>{ - this.canvas.refreshBackgroundImage() + this.canvas.refreshBackgroundImage(item.imageUrl,item.imageAngle) }) }) } else { //楼层/区域 this.http.put(`/api/BuildingAreas/${item.id}`,item,{params:this.params}).subscribe(data=>{ let isSuccess = this.renovateBuilding() isSuccess.then(res=>{ - this.canvas.refreshBackgroundImage() + this.canvas.refreshBackgroundImage(item.imageUrl,item.imageAngle) }) }) } @@ -1957,7 +1957,7 @@ export class CollectionToolsBuildingComponent implements OnInit { this.http.put(`/api/SitePlans/${item.id}`,item).subscribe(data=>{ let isSuccess = this.renovateSitePlan() isSuccess.then(res=>{ - this.canvas.refreshBackgroundImage() + this.canvas.refreshBackgroundImage(item.imageUrl,item.imageAngle) }) const config = new MatSnackBarConfig(); config.verticalPosition = 'top'; @@ -1968,7 +1968,7 @@ export class CollectionToolsBuildingComponent implements OnInit { this.http.put(`/api/BuildingAreas/${item.id}`,item,{params:this.params}).subscribe(data=>{ let isSuccess = this.renovateBuilding() isSuccess.then(res=>{ - this.canvas.refreshBackgroundImage() + this.canvas.refreshBackgroundImage(item.imageUrl,item.imageAngle) }) const config = new MatSnackBarConfig(); config.verticalPosition = 'top'; diff --git a/src/app/ui/collection-tools-plan/collection-tools.component.ts b/src/app/ui/collection-tools-plan/collection-tools.component.ts index 833bfd9..7c307bf 100644 --- a/src/app/ui/collection-tools-plan/collection-tools.component.ts +++ b/src/app/ui/collection-tools-plan/collection-tools.component.ts @@ -1816,14 +1816,14 @@ export class CollectionToolsPlanComponent implements OnInit { this.http.put(`/api/SitePlans/${item.id}`,item).subscribe(data=>{ let isSuccess = this.renovateSitePlan() isSuccess.then(res=>{ - this.canvas.refreshBackgroundImage() + this.canvas.refreshBackgroundImage(item.imageUrl,item.imageAngle) }) }) } else { //楼层/区域 this.http.put(`/api/BuildingAreas/${item.id}`,item,{params:this.params}).subscribe(data=>{ let isSuccess = this.renovateBuilding() isSuccess.then(res=>{ - this.canvas.refreshBackgroundImage() + this.canvas.refreshBackgroundImage(item.imageUrl,item.imageAngle) }) }) } @@ -1967,7 +1967,7 @@ export class CollectionToolsPlanComponent implements OnInit { this.http.put(`/api/SitePlans/${item.id}`,item).subscribe(data=>{ let isSuccess = this.renovateSitePlan() isSuccess.then(res=>{ - this.canvas.refreshBackgroundImage() + this.canvas.refreshBackgroundImage(item.imageUrl,item.imageAngle) }) const config = new MatSnackBarConfig(); config.verticalPosition = 'top'; @@ -1978,7 +1978,7 @@ export class CollectionToolsPlanComponent implements OnInit { this.http.put(`/api/BuildingAreas/${item.id}`,item,{params:this.params}).subscribe(data=>{ let isSuccess = this.renovateBuilding() isSuccess.then(res=>{ - this.canvas.refreshBackgroundImage() + this.canvas.refreshBackgroundImage(item.imageUrl,item.imageAngle) }) const config = new MatSnackBarConfig(); config.verticalPosition = 'top'; diff --git a/src/app/ui/collection-tools/collection-tools.component.html b/src/app/ui/collection-tools/collection-tools.component.html index 176ca4d..9b2328c 100644 --- a/src/app/ui/collection-tools/collection-tools.component.html +++ b/src/app/ui/collection-tools/collection-tools.component.html @@ -15,7 +15,7 @@ - 多选 + 多选 显示图例 diff --git a/src/app/ui/collection-tools/collection-tools.component.ts b/src/app/ui/collection-tools/collection-tools.component.ts index 328b79e..fd7e1a4 100644 --- a/src/app/ui/collection-tools/collection-tools.component.ts +++ b/src/app/ui/collection-tools/collection-tools.component.ts @@ -1569,6 +1569,8 @@ export class CollectionToolsComponent implements OnInit { beforeOneCheckedBuildingIsShow:boolean = false; //想定作业下 建筑是否显示 togglebeforeOneCheckedBuilding () { this.beforeOneCheckedBuildingIsShow = !this.beforeOneCheckedBuildingIsShow } + isMultiSelect:boolean = false; // 多选/单选 切换 + changeMultiSelect (e) { this.canvas.setMulitSelect(this.isMultiSelect) } isShowLegend:boolean = true; //图例是否显示 changeLegend (e) { this.canvasData.selectPanelPoint.BackgroundImageUrl? null : this.canvas.setLegendVisible(this.isShowLegend) } @@ -1842,14 +1844,14 @@ export class CollectionToolsComponent implements OnInit { this.http.put(`/api/SitePlans/${item.id}`,item).subscribe(data=>{ let isSuccess = this.renovateSitePlan() isSuccess.then(res=>{ - this.canvas.refreshBackgroundImage() + this.canvas.refreshBackgroundImage(item.imageUrl,item.imageAngle) }) }) } else { //楼层/区域 this.http.put(`/api/BuildingAreas/${item.id}`,item,{params:this.params}).subscribe(data=>{ let isSuccess = this.renovateBuilding() isSuccess.then(res=>{ - this.canvas.refreshBackgroundImage() + this.canvas.refreshBackgroundImage(item.imageUrl,item.imageAngle) }) }) } @@ -1993,7 +1995,7 @@ export class CollectionToolsComponent implements OnInit { this.http.put(`/api/SitePlans/${item.id}`,item).subscribe(data=>{ let isSuccess = this.renovateSitePlan() isSuccess.then(res=>{ - this.canvas.refreshBackgroundImage() + this.canvas.refreshBackgroundImage(item.imageUrl,item.imageAngle) }) const config = new MatSnackBarConfig(); config.verticalPosition = 'top'; @@ -2004,7 +2006,7 @@ export class CollectionToolsComponent implements OnInit { this.http.put(`/api/BuildingAreas/${item.id}`,item,{params:this.params}).subscribe(data=>{ let isSuccess = this.renovateBuilding() isSuccess.then(res=>{ - this.canvas.refreshBackgroundImage() + this.canvas.refreshBackgroundImage(item.imageUrl,item.imageAngle) }) const config = new MatSnackBarConfig(); config.verticalPosition = 'top'; @@ -2399,6 +2401,7 @@ export class CollectionToolsComponent implements OnInit { //自定义数据节点 时 async customizeNodes() { + this.canvasData.selectPanelPoint.BackgroundImageAngle = 0 await this.canvas.loadNoRelevantInformationDisposalPlan(this.canvasData.selectPanelPoint) let other = { children: [], From e32e940c0db9efcec948e293aa8f7c9b1deacce8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BE=90=E6=8C=AF=E5=8D=87?= <359059686@qq.com> Date: Fri, 29 Jan 2021 14:10:58 +0800 Subject: [PATCH 4/6] =?UTF-8?q?=E4=BF=AE=E6=AD=A3imageAngle=20=3D=20undefi?= =?UTF-8?q?nd=20=E7=9A=84=E6=97=B6=E5=80=99=E4=B8=8D=E6=98=BE=E7=A4=BA?= =?UTF-8?q?=E7=9A=84=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../working-area/working-area.component.ts | 50 ++++++++++--------- 1 file changed, 26 insertions(+), 24 deletions(-) diff --git a/src/app/working-area/working-area.component.ts b/src/app/working-area/working-area.component.ts index 948efd4..263c66b 100644 --- a/src/app/working-area/working-area.component.ts +++ b/src/app/working-area/working-area.component.ts @@ -109,11 +109,11 @@ export class WorkingAreaComponent extends EventEmitter implements OnInit, AfterV * 确认绘制按钮 */ private enterPaintEndButton = PIXI.Sprite.from('assets/images/enterPaintButton.png'); - /** * 编辑点图片 */ editorPointTexture: PIXI.Texture = PIXI.Texture.from('assets/images/handle-main.png'); + backgroundTexture: PIXI.Texture = PIXI.Texture.from('assets/images/noImg.png'); /** * 框选工具图形 */ @@ -888,33 +888,35 @@ export class WorkingAreaComponent extends EventEmitter implements OnInit, AfterV * 刷新背景图 */ public async refreshBackgroundImage(imageUrl: string, imageAngle: number): Promise { + if (imageAngle === undefined || imageAngle === null) { + imageAngle = 0; + } + this.backgroundImage.scale.set(1); + this.backgroundImage.pivot.set(0); + this.backgroundImage.x = this.app.view.width / 2; + this.backgroundImage.y = this.app.view.height / 2; if (imageUrl === undefined || imageUrl === null || imageUrl === '') { - this.backgroundImage.visible = false; + this.backgroundImage.texture = this.backgroundTexture; } else { - this.backgroundImage.visible = false; - this.backgroundImage.scale.set(1); - this.backgroundImage.pivot.set(0); - this.backgroundImage.x = this.app.view.width / 2; - this.backgroundImage.y = this.app.view.height / 2; this.backgroundImage.texture = await PIXI.Texture.fromURL(imageUrl); - this.backgroundImage.angle = imageAngle; - // 等待图片加载完成 - const imageWidth = this.backgroundImage.texture.width; - const imageHeight = this.backgroundImage.texture.height; - const appWidth = this.app.view.width - 470; - const appHeight = this.app.view.height; - const wScale = appWidth / imageWidth; - const hScale = appHeight / imageHeight; - const scale = wScale < hScale ? wScale : hScale; - // 设置图片缩放 - this.backgroundImage.scale.set(scale); - this.backgroundImage.visible = true; - this.backgroundImage.children.forEach((item) => { - if (item instanceof AxShape) { - item.refresh(); - } - }); } + this.backgroundImage.angle = imageAngle; + // 等待图片加载完成 + const imageWidth = this.backgroundImage.texture.width; + const imageHeight = this.backgroundImage.texture.height; + const appWidth = this.app.view.width - 470; + const appHeight = this.app.view.height; + const wScale = appWidth / imageWidth; + const hScale = appHeight / imageHeight; + const scale = wScale < hScale ? wScale : hScale; + // 设置图片缩放 + this.backgroundImage.scale.set(scale); + // this.backgroundImage.visible = true; + this.backgroundImage.children.forEach((item) => { + if (item instanceof AxShape) { + item.refresh(); + } + }); } /** * 刷新 From 6ba066e79db16edf6acebfeab19d41ea8403b358 Mon Sep 17 00:00:00 2001 From: cpf <1105965053@qq.com> Date: Fri, 29 Jan 2021 15:09:23 +0800 Subject: [PATCH 5/6] =?UTF-8?q?[=E5=AE=8C=E5=96=84]=20=E8=87=AA=E5=AE=9A?= =?UTF-8?q?=E4=B9=89=E5=A4=84=E7=BD=AE=E9=A2=84=E6=A1=88=E5=BA=95=E5=9B=BE?= =?UTF-8?q?=E5=88=86=E5=9D=97=E4=B8=8A=E4=BC=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/app/canvas-share-data.service.ts | 46 ++++++++++++++++++- .../collection-tools.component.spec.ts | 25 ---------- .../collection-tools.component.ts | 2 +- .../collection-tools.component.spec.ts | 25 ---------- .../collection-tools.component.ts | 2 +- .../leftFunctionalDomain.ts | 3 +- .../collection-tools.component.spec.ts | 25 ---------- .../collection-tools.component.ts | 2 +- .../collection-tools/leftFunctionalDomain.ts | 2 +- src/app/ui/collection-tools/save.ts | 16 +++++-- 10 files changed, 61 insertions(+), 87 deletions(-) delete mode 100644 src/app/ui/collection-tools-building/collection-tools.component.spec.ts delete mode 100644 src/app/ui/collection-tools-plan/collection-tools.component.spec.ts delete mode 100644 src/app/ui/collection-tools/collection-tools.component.spec.ts diff --git a/src/app/canvas-share-data.service.ts b/src/app/canvas-share-data.service.ts index 8e15703..b489243 100644 --- a/src/app/canvas-share-data.service.ts +++ b/src/app/canvas-share-data.service.ts @@ -1,3 +1,4 @@ +import { HttpClient } from '@angular/common/http'; import { Injectable } from '@angular/core'; import {ReplaySubject} from 'rxjs'; import { Observable } from 'rxjs'; @@ -7,7 +8,7 @@ import { GameMode } from './working-area/model/gameMode'; providedIn: 'root' }) export class CanvasShareDataService { - constructor() { } + constructor(private http:HttpClient) { } private _sendMessage: ReplaySubject = new ReplaySubject(1); examDisposalNodesData; // 考生进入时获取当前试卷的处置节点 @@ -81,6 +82,49 @@ export class CanvasShareDataService { return this._sendMessage.asObservable(); } + //分段上传 + sectionUpload (companyId:string,file) { + let data = {filename: file.name} + return new Promise ((resolve, reject)=>{ + this.http.post(`/api/NewMultipartUpload/PlanPlatform/${companyId}/DisposalNode`,{},{params:data}).subscribe(async (data:any)=>{ //初始化分段上传 + let objectName = data.objectName + let uploadId = data.uploadId + let PartNumberETag = []; //每次返回需要保存的信息 + //分块 处理 + let fileSize = file.size || null //上传文件的总大小 + let shardSize = 5 * 1024 * 1024 //5MB一个分片 + let allSlice = Math.ceil(fileSize / shardSize) //总文件/5MB===共分多少段 + + for (let i = 0;i < allSlice;i++) { //循环分段上传 + let start = i * shardSize //切割文件开始位置 + let end = Math.min(fileSize, start + shardSize); //切割文件结束位置 + let formData = new FormData() + formData.append("file",file.slice(start, end)) + + //同步写法实现异步调用 + let result = await new Promise((resolve, reject) => { + // await 需要后面返回一个 promise 对象 + this.http.post(`/api/MultipartUpload/PlanPlatform/${objectName}?uploadId=${uploadId}&partNumber=${i+1}`,formData).subscribe((data:any)=>{ + let msg = { "partNumber":data.partNumber || null, "eTag": data.eTag || null } + resolve(msg) // 调用 promise 内置方法处理成功 + }) + }); + PartNumberETag.push(result) + + if (PartNumberETag.length === allSlice) { //分块上传完成 + let data = PartNumberETag + let paramsData = {uploadId:uploadId} + this.http.post(`/api/CompleteMultipartUpload/PlanPlatform/${objectName}`,data,{params:paramsData}).subscribe(data=>{ + resolve(objectName) + }) + } + }//for循环 + + //分块 处理 + }) + }) + } + // 处置节点 筛选出 匹配数据 匹配不到 return undefined findDisposalNode(parentId: string= null, name: string= null) { if (parentId && name) { // 匹配 父id, name diff --git a/src/app/ui/collection-tools-building/collection-tools.component.spec.ts b/src/app/ui/collection-tools-building/collection-tools.component.spec.ts deleted file mode 100644 index acc7d5e..0000000 --- a/src/app/ui/collection-tools-building/collection-tools.component.spec.ts +++ /dev/null @@ -1,25 +0,0 @@ -import { async, ComponentFixture, TestBed } from '@angular/core/testing'; - -import { CollectionToolsComponent } from './collection-tools.component'; - -describe('CollectionToolsComponent', () => { - let component: CollectionToolsComponent; - let fixture: ComponentFixture; - - beforeEach(async(() => { - TestBed.configureTestingModule({ - declarations: [ CollectionToolsComponent ] - }) - .compileComponents(); - })); - - beforeEach(() => { - fixture = TestBed.createComponent(CollectionToolsComponent); - component = fixture.componentInstance; - fixture.detectChanges(); - }); - - it('should create', () => { - expect(component).toBeTruthy(); - }); -}); diff --git a/src/app/ui/collection-tools-building/collection-tools.component.ts b/src/app/ui/collection-tools-building/collection-tools.component.ts index b7429e8..a0e3081 100644 --- a/src/app/ui/collection-tools-building/collection-tools.component.ts +++ b/src/app/ui/collection-tools-building/collection-tools.component.ts @@ -1934,7 +1934,7 @@ export class CollectionToolsBuildingComponent implements OnInit { e.stopPropagation(); let file = e.target.files[0] || null //获取上传的文件 let fileSize = file.size || null //上传文件的总大小 - let maxSize = 10 * 1024 * 1024 //5MB一个分片 + let maxSize = 5 * 1024 * 1024 //5MB一个分片 if (file && fileSize<=maxSize) { //上传文件<=5MB时 let formData = new FormData() diff --git a/src/app/ui/collection-tools-plan/collection-tools.component.spec.ts b/src/app/ui/collection-tools-plan/collection-tools.component.spec.ts deleted file mode 100644 index acc7d5e..0000000 --- a/src/app/ui/collection-tools-plan/collection-tools.component.spec.ts +++ /dev/null @@ -1,25 +0,0 @@ -import { async, ComponentFixture, TestBed } from '@angular/core/testing'; - -import { CollectionToolsComponent } from './collection-tools.component'; - -describe('CollectionToolsComponent', () => { - let component: CollectionToolsComponent; - let fixture: ComponentFixture; - - beforeEach(async(() => { - TestBed.configureTestingModule({ - declarations: [ CollectionToolsComponent ] - }) - .compileComponents(); - })); - - beforeEach(() => { - fixture = TestBed.createComponent(CollectionToolsComponent); - component = fixture.componentInstance; - fixture.detectChanges(); - }); - - it('should create', () => { - expect(component).toBeTruthy(); - }); -}); diff --git a/src/app/ui/collection-tools-plan/collection-tools.component.ts b/src/app/ui/collection-tools-plan/collection-tools.component.ts index 7c307bf..d4ed12f 100644 --- a/src/app/ui/collection-tools-plan/collection-tools.component.ts +++ b/src/app/ui/collection-tools-plan/collection-tools.component.ts @@ -1944,7 +1944,7 @@ export class CollectionToolsPlanComponent implements OnInit { e.stopPropagation(); let file = e.target.files[0] || null //获取上传的文件 let fileSize = file.size || null //上传文件的总大小 - let maxSize = 10 * 1024 * 1024 //5MB一个分片 + let maxSize = 5 * 1024 * 1024 //5MB一个分片 if (file && fileSize<=maxSize) { //上传文件<=5MB时 let formData = new FormData() diff --git a/src/app/ui/collection-tools-plan/leftFunctionalDomain.ts b/src/app/ui/collection-tools-plan/leftFunctionalDomain.ts index 06d9f09..49b60b7 100644 --- a/src/app/ui/collection-tools-plan/leftFunctionalDomain.ts +++ b/src/app/ui/collection-tools-plan/leftFunctionalDomain.ts @@ -28,7 +28,7 @@ export class leftFunctionalDomainComponentPlan implements OnInit { //选择文件 selectFile (e) { if (e.target.files.length) { - let maxSize = 10*1024*1024 + let maxSize = 5*1024*1024 if (e.target.files[0].size <= maxSize) { this.file = e.target.files[0] } else { @@ -55,7 +55,6 @@ export class leftFunctionalDomainComponentPlan implements OnInit { 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'), diff --git a/src/app/ui/collection-tools/collection-tools.component.spec.ts b/src/app/ui/collection-tools/collection-tools.component.spec.ts deleted file mode 100644 index acc7d5e..0000000 --- a/src/app/ui/collection-tools/collection-tools.component.spec.ts +++ /dev/null @@ -1,25 +0,0 @@ -import { async, ComponentFixture, TestBed } from '@angular/core/testing'; - -import { CollectionToolsComponent } from './collection-tools.component'; - -describe('CollectionToolsComponent', () => { - let component: CollectionToolsComponent; - let fixture: ComponentFixture; - - beforeEach(async(() => { - TestBed.configureTestingModule({ - declarations: [ CollectionToolsComponent ] - }) - .compileComponents(); - })); - - beforeEach(() => { - fixture = TestBed.createComponent(CollectionToolsComponent); - component = fixture.componentInstance; - fixture.detectChanges(); - }); - - it('should create', () => { - expect(component).toBeTruthy(); - }); -}); diff --git a/src/app/ui/collection-tools/collection-tools.component.ts b/src/app/ui/collection-tools/collection-tools.component.ts index fd7e1a4..5fe1722 100644 --- a/src/app/ui/collection-tools/collection-tools.component.ts +++ b/src/app/ui/collection-tools/collection-tools.component.ts @@ -1972,7 +1972,7 @@ export class CollectionToolsComponent implements OnInit { e.stopPropagation(); let file = e.target.files[0] || null //获取上传的文件 let fileSize = file.size || null //上传文件的总大小 - let maxSize = 10 * 1024 * 1024 //5MB一个分片 + let maxSize = 5 * 1024 * 1024 //5MB一个分片 if (file && fileSize<=maxSize) { //上传文件<=5MB时 let formData = new FormData() diff --git a/src/app/ui/collection-tools/leftFunctionalDomain.ts b/src/app/ui/collection-tools/leftFunctionalDomain.ts index c73da68..6323465 100644 --- a/src/app/ui/collection-tools/leftFunctionalDomain.ts +++ b/src/app/ui/collection-tools/leftFunctionalDomain.ts @@ -152,7 +152,7 @@ export class addBGCDisposalNodeComponent implements OnInit { const config = new MatSnackBarConfig(); config.verticalPosition = 'top'; config.duration = 3000 - this.snackBar.open('上传图片需小于5MB','确定',config); + this.snackBar.open('上传图片需小于10MB','确定',config); } } } diff --git a/src/app/ui/collection-tools/save.ts b/src/app/ui/collection-tools/save.ts index 8721c18..eb33b7b 100644 --- a/src/app/ui/collection-tools/save.ts +++ b/src/app/ui/collection-tools/save.ts @@ -332,11 +332,17 @@ export class saveOneDialog { return new Promise((resolve,reject)=>{ if (this.canvasData.selectPanelPoint.BackgroundImageUrl && !this.canvasData.selectPanelPoint.DisposalNodeId) { //新建逻辑 if (this.canvasData.customizeDisposalNode) { - let formData = new FormData() - formData.append("file",this.canvasData.customizeDisposalNode.file) - this.http.post(`/api/Objects/WebPlan2D/${sessionStorage.getItem('companyId')}/DisposalNode`,formData).subscribe((data:any)=>{ - resolve('/api/Objects/WebPlan2D/' + data.objectName) - }) + let fiveSize = 5*1024*1024 + if (this.canvasData.customizeDisposalNode.file.size <= fiveSize) { //小于5MB + let formData = new FormData() + formData.append("file",this.canvasData.customizeDisposalNode.file) + this.http.post(`/api/Objects/WebPlan2D/${sessionStorage.getItem('companyId')}/DisposalNode`,formData).subscribe((data:any)=>{ + resolve('/api/Objects/WebPlan2D/' + data.objectName) + }) + } else { //大于5MB + let upload = this.canvasData.sectionUpload(sessionStorage.getItem('companyId'),this.canvasData.customizeDisposalNode.file) + upload.then(res=>{ resolve('/api/Objects/PlanPlatform/' + res) }) + } //else } } else { resolve(null) From 42e2c516b52859463d1b235f77ca42a6e7cec90f Mon Sep 17 00:00:00 2001 From: cpf <1105965053@qq.com> Date: Fri, 29 Jan 2021 15:34:29 +0800 Subject: [PATCH 6/6] =?UTF-8?q?[=E4=BF=AE=E6=AD=A3]=20=E4=BF=AE=E6=AD=A3?= =?UTF-8?q?=E5=BA=95=E5=9B=BE=E4=B8=8D=E6=9B=B4=E6=96=B0BUG?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/app/ui/collection-tools-plan/collection-tools.component.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/app/ui/collection-tools-plan/collection-tools.component.ts b/src/app/ui/collection-tools-plan/collection-tools.component.ts index d4ed12f..0a7a1e4 100644 --- a/src/app/ui/collection-tools-plan/collection-tools.component.ts +++ b/src/app/ui/collection-tools-plan/collection-tools.component.ts @@ -1735,7 +1735,7 @@ export class CollectionToolsPlanComponent implements OnInit { let dialogRef = this.dialog.open(leftFunctionalDomainComponentPlan,{data}); dialogRef.afterClosed().subscribe(data=>{ if (data =='总平面图') { - this.renovateSitePlan() + this.sitePlanData.length? this.renovateSitePlan() : this.getSitePlan() } else if (data =='建筑') { this.renovateBuilding() }