From 389227474a7b48f63e668ac851bea474dfda29e1 Mon Sep 17 00:00:00 2001 From: cpf <1105965053@qq.com> Date: Fri, 22 Jan 2021 10:30:41 +0800 Subject: [PATCH 1/7] =?UTF-8?q?[=E5=AE=8C=E5=96=84]=20=E7=BC=96=E5=88=B6?= =?UTF-8?q?=E5=B7=A5=E5=85=B7UI=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/app/canvas-share-data.service.ts | 24 ++- .../collection-tools.component.html | 27 ++- .../collection-tools.component.scss | 16 +- .../collection-tools/addBGCDisposalNode.html | 24 +++ .../collection-tools.component.html | 163 ++++++++++-------- .../collection-tools.component.scss | 61 +++++-- .../collection-tools.component.ts | 19 +- .../collection-tools/leftFunctionalDomain.ts | 45 +++++ src/app/ui/collection-tools/panel.scss | 42 ++++- src/app/ui/ui.module.ts | 6 +- .../working-area/working-area.component.ts | 5 +- 11 files changed, 304 insertions(+), 128 deletions(-) create mode 100644 src/app/ui/collection-tools/addBGCDisposalNode.html diff --git a/src/app/canvas-share-data.service.ts b/src/app/canvas-share-data.service.ts index adf46a6..3b57938 100644 --- a/src/app/canvas-share-data.service.ts +++ b/src/app/canvas-share-data.service.ts @@ -2,6 +2,7 @@ import { Injectable } from '@angular/core'; import {ReplaySubject} from 'rxjs'; import { Observable } from 'rxjs'; import { GameMode } from './working-area/model/gameMode'; + @Injectable({ providedIn: 'root' }) @@ -10,33 +11,30 @@ export class CanvasShareDataService { private _sendMessage: ReplaySubject = new ReplaySubject(1); examDisposalNodesData; // 考生进入时获取当前试卷的处置节点 - examFacilityAssetsData; // 考生进入时获取当前试卷要考察的消防设施 + examFacilityAssetsData; // 考生进入时获取当前试卷要考察的消防设施 + examOriginaleveryStoreyData: any; // 考生答卷 总平面图/楼层/区域 楼层数据 + hiddenBasicInfoFacilities: any = []; // 考生答卷 当前楼层需要隐藏的基本信息素材 + - isChange = false; // 数据 是否改动 - selectTemplateData: any; // 选择当前 模板数据 + isChange:boolean = false; // 数据 是否改动 + + selectTemplateData:any; // 选择当前 模板数据 // 总平面图/建筑 楼层 selectStorey: any = {area: '', details: ''}; // 选择当前 楼层 数据 - originalcompanyBuildingData: any; // 单位/建筑 数据 - originaleveryStoreyData: any; // 总平面图/楼层/区域 楼层数据 - - - examOriginaleveryStoreyData: any; // 考生答卷 总平面图/楼层/区域 楼层数据 - - hiddenBasicInfoFacilities: any = []; // 考生答卷 当前楼层需要隐藏的基本信息素材 // 总平面图/建筑 楼层 // 处置 节点 allDisposalNode: any = []; // 所有 处置节点 allNodeMarkers: any; // 灾情 标签信息 - - selectPanelPoint: DisposalNodeData = new DisposalNodeData(); - + selectPanelPoint: DisposalNodeData = new DisposalNodeData(); // 当前数据节点 selectPanelPointBaseData: any = {description: '', notes: '', weather: '', airTemperature: '', windDirection: '', windScale: ''}; // 当前 数据节点 所对应的 天气,详情 数据节点 + customizeDisposalNode:any; // 新建 自定义数据节点 底图+名称 // 处置 节点 + /** * 游戏模式 */ diff --git a/src/app/ui/collection-tools-plan/collection-tools.component.html b/src/app/ui/collection-tools-plan/collection-tools.component.html index e461b35..b2bdb47 100644 --- a/src/app/ui/collection-tools-plan/collection-tools.component.html +++ b/src/app/ui/collection-tools-plan/collection-tools.component.html @@ -7,27 +7,20 @@ - - - - + 基本信息名称 visibility - - 想定作业名称 - visibility - -
- - 基本信息编辑 - -
+ + + + + tv create diff --git a/src/app/ui/collection-tools-plan/collection-tools.component.scss b/src/app/ui/collection-tools-plan/collection-tools.component.scss index 1ec5d7d..985cf7e 100644 --- a/src/app/ui/collection-tools-plan/collection-tools.component.scss +++ b/src/app/ui/collection-tools-plan/collection-tools.component.scss @@ -25,21 +25,19 @@ align-items:center; min-height: 40px; background-color: #fff; - .nameShow{ - cursor: pointer; + .marginLeftRight { + margin: 0 8px; + font-size: 16px; user-select: none; + cursor: pointer; + .mat-icon { vertical-align: middle; font-size: 24px; } } .copytobutn{ - width: 33px; - min-width: 33px; + width: 60px; + min-width: 60px; display: flex; justify-content: center; } - font-size: 18px; - mat-icon{ - font-size: 26px; - vertical-align: text-top; - } span{ height: 24px; line-height: 24px; diff --git a/src/app/ui/collection-tools/addBGCDisposalNode.html b/src/app/ui/collection-tools/addBGCDisposalNode.html new file mode 100644 index 0000000..f9f91af --- /dev/null +++ b/src/app/ui/collection-tools/addBGCDisposalNode.html @@ -0,0 +1,24 @@ +
+
+ +
+ +
+ +
+ + + +
+ + +
+ +
+ +
\ No newline at end of file diff --git a/src/app/ui/collection-tools/collection-tools.component.html b/src/app/ui/collection-tools/collection-tools.component.html index 3575416..701098a 100644 --- a/src/app/ui/collection-tools/collection-tools.component.html +++ b/src/app/ui/collection-tools/collection-tools.component.html @@ -7,22 +7,27 @@ - - - - 基本信息名称 - visibility - - - 想定作业名称 - visibility -
基本信息编辑 @@ -40,32 +45,18 @@
- - + @@ -112,10 +103,79 @@ + +
+
+
+ open_with + + + + + + + +
+
+ {{item.name}} + + + + + + +
+
+
+
+
总平面图
+
+ {{item.name}} +
+
+
+ +
+ +
+
+ keyboard_arrow_up + keyboard_arrow_down + + +
+
+ + + +
+ +
+ edit + add + library_books + delete_forever +
+
+
+ +
+
+ + -
+
+
diff --git a/src/app/ui/collection-tools/collection-tools.component.scss b/src/app/ui/collection-tools/collection-tools.component.scss index 19402a6..f01a7b7 100644 --- a/src/app/ui/collection-tools/collection-tools.component.scss +++ b/src/app/ui/collection-tools/collection-tools.component.scss @@ -25,21 +25,19 @@ align-items:center; min-height: 40px; background-color: #fff; - .nameShow{ - cursor: pointer; + .marginLeftRight { + margin: 0 8px; + font-size: 16px; user-select: none; + cursor: pointer; + .mat-icon { vertical-align: middle; font-size: 24px; } } .copytobutn{ - width: 33px; - min-width: 33px; + width: 60px; + min-width: 60px; display: flex; justify-content: center; } - font-size: 18px; - mat-icon{ - font-size: 26px; - vertical-align: text-top; - } span{ height: 24px; line-height: 24px; @@ -116,6 +114,14 @@ width: 100%; height: 100%; } + .centerBuildingDiv { + position: absolute; + max-width: 400px; + top: 40px; + left: 240px; + z-index: 150; + display: flex; + } .functionalDomainLeft { background-color: #fff; display: flex; @@ -137,7 +143,7 @@ } } .functionalDomainRight { - z-index: 1001; + z-index: 111; margin-right: 0px; transition: margin-right 0.5s; border: 1px solid #464646; @@ -158,6 +164,41 @@ } +//中间建筑/楼层 +.centerTotal { + width: 197px; + background-color: #fff; + box-shadow: 0px 0px 5px 3px rgb(165, 163, 163); + border-radius: 5px; + box-sizing: border-box; + padding: 5px 0; + .centerTotalHeader { + height: 30px; + line-height: 30px; + box-sizing: border-box; + padding-right: 5px; + font-size: 14px; + .centerTotalTitle { >label{ display: inline-block; vertical-align: middle; max-width: 90px; } } + .move{margin: 0 5px;} + .move:hover {cursor: move;} + .mat-icon { + font-size: 24px; + color: rgb(175, 164, 164); + } + } + .everyTotal { + width: 100%; + height: 30px; + line-height: 30px; + box-sizing: border-box; + padding: 0 5px; + margin: 3px 0; + cursor:pointer; + font-size: 16px; + } +} +//中间建筑/楼层 + //右边操作栏 .title{ width: 100%; diff --git a/src/app/ui/collection-tools/collection-tools.component.ts b/src/app/ui/collection-tools/collection-tools.component.ts index b101e13..c9da111 100644 --- a/src/app/ui/collection-tools/collection-tools.component.ts +++ b/src/app/ui/collection-tools/collection-tools.component.ts @@ -2,7 +2,7 @@ import { Component, OnInit, Inject, ViewChild,ElementRef,Renderer2, ViewContaine 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 {leftFunctionalDomainComponent,editPlaneFigureComponent,editDisposalNodeComponent,addDisposalNodeComponent} from './leftFunctionalDomain' +import {leftFunctionalDomainComponent,editPlaneFigureComponent,editDisposalNodeComponent,addDisposalNodeComponent, addBGCDisposalNodeComponent} from './leftFunctionalDomain' import {MatTreeFlatDataSource, MatTreeFlattener} from '@angular/material/tree'; import {FlatTreeControl} from '@angular/cdk/tree'; import {WorkingAreaComponent} from '../../working-area/working-area.component' @@ -1379,6 +1379,7 @@ export class CollectionToolsComponent implements OnInit { isRefresh? this.isShowProperty = true : null isRefresh? this.isShowAttribute = true : null !this.pattern? this.mateFireForce() : null //刷新 建筑楼层 火源/力量图标 + this.beforeOneCheckedBuildingIsShow = false let beforeOneId = this.selectingSitePlan.id || '' //当前 选中 平面图 楼层/区域 id let companyBuildingData = JSON.parse(JSON.stringify( this.canvasData.originalcompanyBuildingData || {} )) // 当前 单位/建筑 数据 @@ -1423,6 +1424,9 @@ export class CollectionToolsComponent implements OnInit { togglePlane:boolean = true; //可展开面板平面图 显隐 toggleMaterialBank:boolean = false; //可展开面板素材库 显隐 toggleHandlePlans:boolean = true; //可展开面板处置预案 显隐 + + beforeOneCheckedBuildingIsShow:boolean = false; //想定作业下 建筑是否显示 + togglebeforeOneCheckedBuilding () { this.beforeOneCheckedBuildingIsShow = !this.beforeOneCheckedBuildingIsShow } //可展开面板展开或关闭 toggle () { this.toggleExpandPanel = !this.toggleExpandPanel @@ -2126,6 +2130,19 @@ export class CollectionToolsComponent implements OnInit { }) } + //新建 底图数据节点 + addBGCPanelPoint (e) { + e.stopPropagation() + let dialogRef = this.dialog.open(addBGCDisposalNodeComponent); + dialogRef.afterClosed().subscribe(data=>{ + if (data) { + this.canvasData.customizeDisposalNode = data + let imgURL = window.URL.createObjectURL(data.file) //将图片生成 url地址 + console.log(imgURL,this.canvasData.customizeDisposalNode) + } + }) + } + //新建 处置预案 节点 addPanelPoint (e,item,treeData) { e.stopPropagation() diff --git a/src/app/ui/collection-tools/leftFunctionalDomain.ts b/src/app/ui/collection-tools/leftFunctionalDomain.ts index 519653d..3deb432 100644 --- a/src/app/ui/collection-tools/leftFunctionalDomain.ts +++ b/src/app/ui/collection-tools/leftFunctionalDomain.ts @@ -129,6 +129,51 @@ export class editPlaneFigureComponent implements OnInit { +//新建 底图数据节点 +@Component({ + selector: 'app-addBGCDisposalNode', + templateUrl: './addBGCDisposalNode.html', + styleUrls: ['./panel.scss'] +}) +export class addBGCDisposalNodeComponent implements OnInit { + + constructor(private http:HttpClient,public dialog: MatDialog,public snackBar: MatSnackBar,public dialogRef: MatDialogRef,@Inject(MAT_DIALOG_DATA) public data) { } + + ngOnInit(): void { } + + file:any = null; //文件 + //上传图片 + selectFile (e) { + if (e.target.files.length ) { + let maxSize = 5*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('上传图片需小于5MB','确定',config); + } + } + } + + //提交表单 + onSubmit (e) { + if (e.name && this.file) { + e.file = this.file + this.dialogRef.close(e); + } else { + const config = new MatSnackBarConfig(); + config.verticalPosition = 'top'; + config.duration = 3000 + this.snackBar.open('请上传图片','确定',config); + } + } + +} + + + //创建 处置预案 节点 @Component({ selector: 'app-addDisposalNode', diff --git a/src/app/ui/collection-tools/panel.scss b/src/app/ui/collection-tools/panel.scss index f0ae073..a127a5b 100644 --- a/src/app/ui/collection-tools/panel.scss +++ b/src/app/ui/collection-tools/panel.scss @@ -50,8 +50,8 @@ //火源/力量 图标 .fireForce { display: block; + margin-top: 5px; float: right; - margin: 8px 5px 0 0; width: 40px; height: 20px; line-height: 20px; @@ -261,6 +261,10 @@ .selectanelPoint { background-color: #F4C235; } +//选中 数据节点时 +.selectanelPointData { + background-color: #f8da88; +} @@ -289,3 +293,39 @@ resize:none; } } + +.leftAddBGC { + div{ text-align: center; } + input { + width: 190px; + height: 30px; + padding-left: 5px; + outline: none; + border: none; + border-radius: 5px; + background: #EEF1F5; + } +} +//上传CAD弹窗 inputfile +.uploadFile { + padding: 3px 10px; + height: 20px; + line-height: 20px; + position: relative; + cursor: pointer; + color: #0080FF; + font-size: 14px; + background: #fafafa; + border: 1px solid #0080FF; + border-radius: 3px; + overflow: hidden; + display: inline-block; + input { + position: absolute; + width: 100%; + right: 0; + top: 0; + opacity: 0; + cursor: pointer + } +} diff --git a/src/app/ui/ui.module.ts b/src/app/ui/ui.module.ts index eb9a555..d1129ac 100644 --- a/src/app/ui/ui.module.ts +++ b/src/app/ui/ui.module.ts @@ -67,7 +67,6 @@ import { UnittypeComponent,DialogOverviewExampleDialog,editorialUnit } from './u import { AuthorityComponent, CreateAuthority } from './authority/authority.component'; import { RoleComponent, CreateRole, EditRole } from './role/role.component'; import { UsermanagementComponent,CreateNewUser,EditNewUser,allRoles,seeInformation } from './usermanagement/usermanagement.component'; - import { IsnoPipe } from '../pipes/boolean.pipe'; import {ConfirmpswDirective} from './changepassword/equal-validator.directive' import { TimePipe } from '../pipes/time.pipe'; @@ -90,16 +89,15 @@ import { EditGroup } from './unit-information/editgroup.component'; import { EnterpriseuserComponent,seeenterpriseuser,editenterpriseuser } from './enterpriseuser/enterpriseuser.component'; import { AddEnterpriserUser } from './enterpriseuser/addenterpriseuser.component'; import { FireFightingFacilitiesFormworkComponent,addFireFightingFacilitiesFormworkComponent,editFireFightingFacilitiesFormworkComponent,addBuiltInComponent,addBuiltInAttributeComponent,addOptionalComponent,addOptionalAttributeComponent,editBuiltInAttributeComponent,editOptionalAttributeComponent } from './fire-fighting-facilities-formwork/fire-fighting-facilities-formwork.component'; - import { CollectionToolsComponent, CreateBuilding, EditBuilding, ViewDetails } from './collection-tools/collection-tools.component'; import { WorkingAreaComponent } from '../working-area/working-area.component'; -import {leftFunctionalDomainComponent,editPlaneFigureComponent,addDisposalNodeComponent,editDisposalNodeComponent} from './collection-tools/leftFunctionalDomain' +import {leftFunctionalDomainComponent,editPlaneFigureComponent,addDisposalNodeComponent,editDisposalNodeComponent,addBGCDisposalNodeComponent} from './collection-tools/leftFunctionalDomain' import { saveOneDialog, saveTwoDialog } from './collection-tools/save'; import { CollectionToolsPlanComponent, CreateBuildingPlan, EditBuildingPlan, ViewDetailsPlan } from './collection-tools-plan/collection-tools.component'; import { addDisposalNodeComponentPlan, editDisposalNodeComponentPlan, editPlaneFigureComponentPlan, leftFunctionalDomainComponentPlan } from './collection-tools-plan/leftFunctionalDomain'; import { saveOneDialogPlan, saveTwoDialogPlan } from './collection-tools-plan/save'; @NgModule({ - declarations: [UiComponent, DateselectComponent, MenuComponent, CardComponent, ListComponent, GridComponent, StepperComponent, TabgroupComponent, ButtonComponent, BadgeComponent, ProgressComponent, SnackbarComponent,PersonaldataComponent, FooterComponent, UserdataComponent, ChangepasswordComponent, OrganizationComponent, UnittypeComponent, AuthorityComponent, RoleComponent, UsermanagementComponent,IsnoPipe,ConfirmpswDirective,DialogOverviewExampleDialog,CreateAuthority,CreateRole,TimePipe,CreateNewUser,EditNewUser,allRoles,EditRole,CreateOrganization,EditOrganization,seeInformation,EditUser,editorialUnit,FireProtectionElementsComponent,Establish,EditingFireControl,FireFightingTemplateComponent, NavmenusComponent,CreateMenus,EditMenus,NewFireFighting,EditFireClassification, MaterialBankComponent, UnitInformationComponent,AddMatLibrary,EditMatLibrary,attributeComponent,AddOriginalCopy,addAttributeComponent,editAttribute,EditOriginalCopy,SelectOriginalCopy,EditUnitInfo,AddUnitInfo,AddGroups,EditGroup, EnterpriseuserComponent,AddEnterpriserUser,addUnitAttributeComponent,editUnitAttribute,seeenterpriseuser,editenterpriseuser, FireFightingFacilitiesFormworkComponent,addFireFightingFacilitiesFormworkComponent,editFireFightingFacilitiesFormworkComponent,addBuiltInComponent,addBuiltInAttributeComponent,addOptionalComponent,addOptionalAttributeComponent,editBuiltInAttributeComponent,editOptionalAttributeComponent, CollectionToolsComponent,WorkingAreaComponent,CreateBuilding,EditBuilding,leftFunctionalDomainComponent,editPlaneFigureComponent,ViewDetails,saveOneDialog,saveTwoDialog,addDisposalNodeComponent,editDisposalNodeComponent,CollectionToolsPlanComponent,CreateBuildingPlan,EditBuildingPlan,ViewDetailsPlan,leftFunctionalDomainComponentPlan,editPlaneFigureComponentPlan,addDisposalNodeComponentPlan,editDisposalNodeComponentPlan,saveOneDialogPlan,saveTwoDialogPlan,addOffices,editOffices], + declarations: [UiComponent, DateselectComponent, MenuComponent, CardComponent, ListComponent, GridComponent, StepperComponent, TabgroupComponent, ButtonComponent, BadgeComponent, ProgressComponent, SnackbarComponent,PersonaldataComponent, FooterComponent, UserdataComponent, ChangepasswordComponent, OrganizationComponent, UnittypeComponent, AuthorityComponent, RoleComponent, UsermanagementComponent,IsnoPipe,ConfirmpswDirective,DialogOverviewExampleDialog,CreateAuthority,CreateRole,TimePipe,CreateNewUser,EditNewUser,allRoles,EditRole,CreateOrganization,EditOrganization,seeInformation,EditUser,editorialUnit,FireProtectionElementsComponent,Establish,EditingFireControl,FireFightingTemplateComponent, NavmenusComponent,CreateMenus,EditMenus,NewFireFighting,EditFireClassification, MaterialBankComponent, UnitInformationComponent,AddMatLibrary,EditMatLibrary,attributeComponent,AddOriginalCopy,addAttributeComponent,editAttribute,EditOriginalCopy,SelectOriginalCopy,EditUnitInfo,AddUnitInfo,AddGroups,EditGroup, EnterpriseuserComponent,AddEnterpriserUser,addUnitAttributeComponent,editUnitAttribute,seeenterpriseuser,editenterpriseuser, FireFightingFacilitiesFormworkComponent,addFireFightingFacilitiesFormworkComponent,editFireFightingFacilitiesFormworkComponent,addBuiltInComponent,addBuiltInAttributeComponent,addOptionalComponent,addOptionalAttributeComponent,editBuiltInAttributeComponent,editOptionalAttributeComponent, CollectionToolsComponent,WorkingAreaComponent,CreateBuilding,EditBuilding,leftFunctionalDomainComponent,editPlaneFigureComponent,ViewDetails,saveOneDialog,saveTwoDialog,addDisposalNodeComponent,editDisposalNodeComponent,CollectionToolsPlanComponent,CreateBuildingPlan,EditBuildingPlan,ViewDetailsPlan,leftFunctionalDomainComponentPlan,editPlaneFigureComponentPlan,addDisposalNodeComponentPlan,editDisposalNodeComponentPlan,saveOneDialogPlan,saveTwoDialogPlan,addOffices,editOffices,addBGCDisposalNodeComponent], imports: [ CommonModule, diff --git a/src/app/working-area/working-area.component.ts b/src/app/working-area/working-area.component.ts index 04d2c17..add640d 100644 --- a/src/app/working-area/working-area.component.ts +++ b/src/app/working-area/working-area.component.ts @@ -276,7 +276,6 @@ export class WorkingAreaComponent extends EventEmitter implements OnInit, AfterV icon.assetData.Type === 3 || icon.assetData.Type === 4 )) { - console.log(this.backgroundImage.position); this.backgroundImage.pivot.set(icon.x, icon.y); this.backgroundImage.position.set(771, 404); clearTimeout(this.animationTime); @@ -315,7 +314,7 @@ export class WorkingAreaComponent extends EventEmitter implements OnInit, AfterV this.app.stage.addChild(this.grid); this.grid.drawGrid(); this.grid.onMousemove = (evt, gridCoord) => { - console.log(gridCoord); + }; this.createBackgroundImage(); @@ -504,7 +503,6 @@ export class WorkingAreaComponent extends EventEmitter implements OnInit, AfterV public setIconScale(value: number): void { this.backgroundImage.children.forEach(item => { if (item instanceof AxImageShape) { - console.log(item.image.scale); item.image.scale.set(value); } else if (item instanceof MultipointIcon) { @@ -630,7 +628,6 @@ export class WorkingAreaComponent extends EventEmitter implements OnInit, AfterV this.backgroundImage .on('pointerdown', event => { if (event.data.button !== 0) { return; } - console.log(this.backgroundImage.toLocal(this.mousePosition)); if (!event.currentTarget.dragging && this.selection.isMultiselection === false) { this.selection.deselectAll(); event.currentTarget.data = event.data; From dd3dc17622ab7b14e84e355149e642c5247fab32 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BE=90=E6=8C=AF=E5=8D=87?= <359059686@qq.com> Date: Sat, 23 Jan 2021 18:27:53 +0800 Subject: [PATCH 2/7] axSelection,axMessageSystem --- .../working-area/model/axImageShapeTest.ts | 11 - src/app/working-area/model/axLegend.ts | 1 - src/app/working-area/model/axMessageSystem.ts | 90 +++++ .../working-area/model/axRectangleShape.ts | 24 +- src/app/working-area/model/axSelection.ts | 48 +++ src/app/working-area/model/axShape.ts | 58 +-- src/app/working-area/model/messageSystem.ts | 37 -- .../working-area/working-area.component.ts | 347 +++++++----------- 8 files changed, 321 insertions(+), 295 deletions(-) delete mode 100644 src/app/working-area/model/axImageShapeTest.ts create mode 100644 src/app/working-area/model/axMessageSystem.ts create mode 100644 src/app/working-area/model/axSelection.ts delete mode 100644 src/app/working-area/model/messageSystem.ts diff --git a/src/app/working-area/model/axImageShapeTest.ts b/src/app/working-area/model/axImageShapeTest.ts deleted file mode 100644 index 81c141c..0000000 --- a/src/app/working-area/model/axImageShapeTest.ts +++ /dev/null @@ -1,11 +0,0 @@ -import { AxRectangleShape } from "./axRectangleShape"; - -export class AxImageShapeTest extends AxRectangleShape{ - /** - * - */ - constructor(x:number,y:number,width:number,height:number) { - super(x,y,width,height); - - } -} \ No newline at end of file diff --git a/src/app/working-area/model/axLegend.ts b/src/app/working-area/model/axLegend.ts index a886fd3..f2158ac 100644 --- a/src/app/working-area/model/axLegend.ts +++ b/src/app/working-area/model/axLegend.ts @@ -429,7 +429,6 @@ export class AxLegend extends AxShape { */ public drawBorder(scale: number) { const visible = this.upLeft.visible; - console.log(visible); this.setPointVisiable(false); super.drawBorder(scale); diff --git a/src/app/working-area/model/axMessageSystem.ts b/src/app/working-area/model/axMessageSystem.ts new file mode 100644 index 0000000..1451f9c --- /dev/null +++ b/src/app/working-area/model/axMessageSystem.ts @@ -0,0 +1,90 @@ +/** + * 事件系统 + */ +export class AxMessageSystem { + /** 监听数组 */ + private static listeners = {}; + + /** + * 注册事件 + * @param name 事件名称 + * @param callback 回调函数 + * @param context 上下文 + */ + public static addListener(name: string, callback: () => void, context: any) { + const observers: Observer[] = AxMessageSystem.listeners[name]; + if (!observers) { + AxMessageSystem.listeners[name] = []; + } + AxMessageSystem.listeners[name].push(new Observer(callback, context)); + } + + /** + * 移除事件 + * @param name 事件名称 + * @param callback 回调函数 + * @param context 上下文 + */ + public static removeListener(name: string, callback: () => void, context: any) { + const observers: Observer[] = AxMessageSystem.listeners[name]; + if (!observers) { return; } + const length = observers.length; + for (let i = 0; i < length; i++) { + const observer = observers[i]; + if (observer.compar(context)) { + observers.splice(i, 1); + break; + } + } + if (observers.length === 0) { + delete AxMessageSystem.listeners[name]; + } + } + + /** + * 发送事件 + * @param name 事件名称 + */ + public static send(name: string, ...args: any[]) { + const observers: Observer[] = AxMessageSystem.listeners[name]; + if (!observers) { return; } + const length = observers.length; + for (let i = 0; i < length; i++) { + const observer = observers[i]; + observer.notify(name, ...args); + } + } +} + +/** + * 观察者 + */ +class Observer { + /** 回调函数 */ + private callback: () => void; + /** 上下文 */ + private context: any = null; + + constructor(callback: () => void, context: any) { + const self = this; + self.callback = callback; + self.context = context; + } + + /** + * 发送通知 + * @param args 不定参数 + */ + notify(...args: any[]): void { + const self = this; + self.callback.call(self.context, ...args); + } + + /** + * 上下文比较 + * @param context 上下文 + */ + compar(context: any): boolean { + return context === this.context; + } +} diff --git a/src/app/working-area/model/axRectangleShape.ts b/src/app/working-area/model/axRectangleShape.ts index 297ffdb..cf61f6c 100644 --- a/src/app/working-area/model/axRectangleShape.ts +++ b/src/app/working-area/model/axRectangleShape.ts @@ -1,21 +1,21 @@ -import { Sprite } from "pixi.js"; -import { Graphics } from "pixi.js"; -import { WorkingAreaComponent } from "../working-area.component"; -import { AxShape } from "./axShape"; +import { Sprite } from 'pixi.js'; +import { Graphics } from 'pixi.js'; +import { WorkingAreaComponent } from '../working-area.component'; +import { AxShape } from './axShape'; -export class AxRectangleShape extends AxShape{ +export class AxRectangleShape extends AxShape { /** * */ - constructor(x:number,y:number,width:number,height:number,assetData: any, workingArea: WorkingAreaComponent) { - super(assetData,workingArea); - this.beginFill(0x0000ff,1); - this.lineStyle(1, 0xff0000,1); + constructor(x: number, y: number, width: number, height: number, assetData: any, workingArea: WorkingAreaComponent) { + super(assetData, workingArea); + this.beginFill(0x0000ff, 1); + this.lineStyle(1, 0xff0000, 1); this.drawRect(x, y, width, height); this.endFill(); - - + + } - + } diff --git a/src/app/working-area/model/axSelection.ts b/src/app/working-area/model/axSelection.ts new file mode 100644 index 0000000..e61cd78 --- /dev/null +++ b/src/app/working-area/model/axSelection.ts @@ -0,0 +1,48 @@ +/** + * 选择器 + */ +export class AxSelection { + constructor() { + } + private objects: Set = new Set(); + // 获得第一个对象 + public first(): any { + if (this.objects.size > 0) { + return this.objects[0]; + } else { + return null; + } + } + // 获得所有对象 + public all() { + return this.objects; + } + // 获取集合长度 + public size(): number { + return this.objects.size; + } + // 添加对象 + public add(obj: any) { + this.objects.add(obj); + } + // 添加集合 + public addArray(array: any[]) { + array.forEach(item => { + this.objects.add(item); + }); + } + // 移除对象 + public delete(obj: any) { + this.objects.delete(obj); + } + // 移除集合 + public deleteArray(array: any[]) { + array.forEach(item => { + this.objects.delete(item); + }); + } + // 清空所有对象 + public clear() { + this.objects.clear(); + } +} diff --git a/src/app/working-area/model/axShape.ts b/src/app/working-area/model/axShape.ts index 27c1773..2d032d5 100644 --- a/src/app/working-area/model/axShape.ts +++ b/src/app/working-area/model/axShape.ts @@ -8,7 +8,7 @@ import { WorkingAreaComponent } from '../working-area.component'; */ export class AxShape extends Graphics { assetData: any; - pointTexture: PIXI.Texture = PIXI.Texture.from('assets/images/handle-main.png') + pointTexture: PIXI.Texture = PIXI.Texture.from('assets/images/handle-main.png'); workingArea: WorkingAreaComponent; // 可以被移动的 moveable = true; @@ -20,7 +20,7 @@ export class AxShape extends Graphics { showName = true; // 边框 border: PIXI.Graphics = new PIXI.Graphics(); - + constructor(assetData: any, workingArea: WorkingAreaComponent) { super(); this.border.visible = false; @@ -35,7 +35,7 @@ export class AxShape extends Graphics { .on('pointerdown', event => { event.stopPropagation(); if (this.selectable) { - this.workingArea.selection.selectOne(this); + this.workingArea.selectSingle(this); } if (this.moveable) { event.currentTarget.data = event.data; @@ -86,14 +86,14 @@ export class AxShape extends Graphics { }); } redraw(): void { - + } - refresh(): void{ - + refresh(): void { + } public setItemScale(scale: number) { - + } public showBorder() { @@ -110,10 +110,10 @@ export class AxShape extends Graphics { * @param value 显示状态 */ public setPointVisiable(value: boolean) { - + } /** - * + * * @param rect 画边框 */ public drawBorder(scale: number) { @@ -127,14 +127,14 @@ export class AxShape extends Graphics { this.border.lineStyle(scale * 1, 0x00a8ff); - var spaceLength = scale * 1; - var lineLenght = rect.width + 0.5 + 0.5; - var dashLength = scale*( lineLenght +spaceLength - Math.floor((rect.width + rect.height)/2 / 4.1))/Math.floor((rect.width + rect.height)/2 / 4.1); - this.drawDash(this.border, p1.x -0.5*scale, p1.y, p2.x + 0.5*scale, p2.y,dashLength,spaceLength); - this.drawDash(this.border, p2.x, p2.y -0.5*scale, p3.x, p3.y + 0.5*scale, dashLength, spaceLength); - this.drawDash(this.border, p3.x+0.5*scale, p3.y, p4.x - 0.5*scale, p4.y, dashLength, spaceLength); - this.drawDash(this.border, p4.x, p4.y + 0.5*scale, p1.x, p1.y - 0.5*scale, dashLength, spaceLength); - + let spaceLength = scale * 1; + let lineLenght = rect.width + 0.5 + 0.5; + let dashLength = scale * ( lineLenght + spaceLength - Math.floor((rect.width + rect.height) / 2 / 4.1)) / Math.floor((rect.width + rect.height) / 2 / 4.1); + this.drawDash(this.border, p1.x - 0.5 * scale, p1.y, p2.x + 0.5 * scale, p2.y, dashLength, spaceLength); + this.drawDash(this.border, p2.x, p2.y - 0.5 * scale, p3.x, p3.y + 0.5 * scale, dashLength, spaceLength); + this.drawDash(this.border, p3.x + 0.5 * scale, p3.y, p4.x - 0.5 * scale, p4.y, dashLength, spaceLength); + this.drawDash(this.border, p4.x, p4.y + 0.5 * scale, p1.x, p1.y - 0.5 * scale, dashLength, spaceLength); + this.border.lineStyle(0, 0x0000ff); // this.border.beginFill(0x00ff00,0.1); this.border.moveTo(p1.x, p1.y); @@ -145,19 +145,19 @@ export class AxShape extends Graphics { // this.border.endFill(); } // 画虚线 - drawDash(target, x1, y1, x2, y2,dashLength = 5, spaceLength = 1) { - let x = x2 - x1; - let y = y2 - y1; + drawDash(target, x1, y1, x2, y2, dashLength = 5, spaceLength = 1) { + const x = x2 - x1; + const y = y2 - y1; let hyp = Math.sqrt((x) * (x) + (y) * (y)); - let units = hyp / (dashLength + spaceLength); - let dashSpaceRatio = dashLength / (dashLength + spaceLength); - let dashX = (x / units) * dashSpaceRatio; - let spaceX = (x / units) - dashX; - let dashY = (y / units) * dashSpaceRatio; - let spaceY = (y / units) - dashY; + const units = hyp / (dashLength + spaceLength); + const dashSpaceRatio = dashLength / (dashLength + spaceLength); + const dashX = (x / units) * dashSpaceRatio; + const spaceX = (x / units) - dashX; + const dashY = (y / units) * dashSpaceRatio; + const spaceY = (y / units) - dashY; target.moveTo(x1, y1); - + while (hyp > 0) { x1 += dashX; y1 += dashY; @@ -200,7 +200,7 @@ export class AxShape extends Graphics { return new PIXI.Point(gravityLat, gravityLng); } // 计算线段中点坐标 - public getLineCenter(point1:PIXI.Point,point2:PIXI.Point) { - return new PIXI.Point((point1.x+point2.x)/2,(point1.y+point2.y)/2) + public getLineCenter(point1: PIXI.Point, point2: PIXI.Point) { + return new PIXI.Point((point1.x + point2.x) / 2, (point1.y + point2.y) / 2); } } diff --git a/src/app/working-area/model/messageSystem.ts b/src/app/working-area/model/messageSystem.ts deleted file mode 100644 index 322eef4..0000000 --- a/src/app/working-area/model/messageSystem.ts +++ /dev/null @@ -1,37 +0,0 @@ -class MyEvent extends CustomEvent { - public static readonly CMD: string = "EVENT_NAME"; - public constructor($type: string , $data: T ) { - super( $type , { detail: $data, bubbles: true, cancelable: true, composed: true }); - } -} - -class MyDispatch extends EventTarget { - private static _instance: MyDispatch; - public static get Instance(): MyDispatch { - if (!MyDispatch._instance) MyDispatch._instance = new MyDispatch(); - return MyDispatch._instance; - } - public send($data: T, $type: string = MyEvent.CMD): void { - const $event: CustomEvent = new MyEvent($type, $data); - this.dispatchEvent($event); - } -} - -class Test { - - public constructor() { - MyDispatch.Instance.addEventListener(MyEvent.CMD, this.onEvent as EventListener); - } - private onEvent($e: MyEvent): void { - console.log(`target ${$e.target}`); - console.log(`name: ${$e.detail._name} , occupation: ${$e.detail._occupation}`); - } -} - -interface ITest { - _name: string; - _occupation: string; -} - -let $test: Test = new Test(); -MyDispatch.Instance.send({ _name: `Aonaufly`, _occupation: `it` }); diff --git a/src/app/working-area/working-area.component.ts b/src/app/working-area/working-area.component.ts index adaa4d7..1b05d4c 100644 --- a/src/app/working-area/working-area.component.ts +++ b/src/app/working-area/working-area.component.ts @@ -16,9 +16,9 @@ import { PropertyInfo } from './model/PropertyInfo'; import { AxPreviewImageShape } from './model/axPreviewImageShape'; import { AxArrowConnector } from './model/axArrowConnector'; import { AxLegend, Legend } from './model/axLegend'; -import { NullTemplateVisitor } from '@angular/compiler'; -import { AxRectangleShape } from './model/axRectangleShape'; import { AxGrid } from './model/axGrid'; +import { AxSelection } from './model/axSelection'; +import { AxMessageSystem } from './model/axMessageSystem'; @Component({ @@ -76,7 +76,7 @@ export class WorkingAreaComponent extends EventEmitter implements OnInit, AfterV /** * 选择器 */ - public selection: Selection = new Selection(this); + public readonly selection: AxSelection = new AxSelection(); /** * 当前鼠标的点 */ @@ -141,6 +141,9 @@ export class WorkingAreaComponent extends EventEmitter implements OnInit, AfterV * 网格 */ public grid: AxGrid = null; + // 是否按下Ctrl键 + isCtrlKeyClicked = false; + isMove = false; /** * 本软件版本号由四部分组成:<主版本号><次版本号><修订版本号><日期加希腊字母版本号> 例如:1.0.0.20210105_beta * Alpha版: 此版本表示该软件在此阶段主要是以实现软件功能为主,通常只在软件开发者内部交流,一般而言,该版本软件的Bug较多,需要继续修改。 @@ -157,12 +160,12 @@ export class WorkingAreaComponent extends EventEmitter implements OnInit, AfterV this.sayHello(); this.eventManager.addGlobalEventListener('window', 'keydown', (event: any) => { if (event.keyCode === 17) { - this.selection.isMultiselection = true; + this.isCtrlKeyClicked = true; } }); this.eventManager.addGlobalEventListener('window', 'keyup', (event: any) => { if (event.keyCode === 17) { - this.selection.isMultiselection = false; + this.isCtrlKeyClicked = false; this.rectToolGraphics.visible = false; this.rectToolGraphics.clear(); } @@ -171,23 +174,56 @@ export class WorkingAreaComponent extends EventEmitter implements OnInit, AfterV this.deleteSelectedShape(); } }); + // 消息系统事件监听 + AxMessageSystem.addListener(CanvasAction.selectionChanged, () => { + this.selection.all().forEach(item => { + item.showBorder(); + item.drawBorder(1 / this.backgroundImage.scale.x); + item.setPointVisiable(this.allowEdit); + }); + }, this); } /** * 删除选中的图标 */ public deleteSelectedShape() { - this.selection.objects.forEach(item => { - this.deleteShape(item); - }); - this.selection.deselectAll(); - } - /** - * - * @param obj 删除一个形状 - */ - public deleteShape(shape) { - if (this.allowEdit && this.canvasData.gameMode === shape.assetData.GameMode) { - this.emit('deleteIcon', shape); + if (this.selection.all().size > 0) { + this.selection.all().forEach(axShape => { + if (this.allowEdit && this.canvasData.gameMode === axShape.assetData.GameMode) { + // 删除图例对象 + const temp = this.backgroundImage.getChildByName('图例') as AxLegend; + if ( temp !== undefined + && temp !== null + && axShape.assetData.Name !== '图例') { + const itemLegend = new Legend(axShape.assetData.Name, axShape.assetData.ImageUrl, 1); + temp.deleteItem(itemLegend); + } + if (axShape.assetData.GameMode === GameMode.BasicInformation) { // 基本信息 + // 删除楼层数据 + delete this.canvasData.originaleveryStoreyData.data[axShape.assetData.Id]; + // 删除建筑数据 + delete this.canvasData.originalcompanyBuildingData.data[axShape.assetData.Id]; + } else if (axShape.assetData.GameMode === GameMode.Assignment) { // 处置预案 + delete this.canvasData.selectPanelPoint.Data.DefinedIncrement[axShape.assetData.Id]; + delete this.canvasData.selectPanelPoint.Data.Increment[axShape.assetData.Id]; + delete this.canvasData.selectPanelPoint.Data.Stock[axShape.assetData.Id]; + } else if (axShape.assetData.GameMode === GameMode.Examinee) { // 考生考试 + if (axShape.assetData.Tag === 1) { + // 删除楼层数据 + delete this.canvasData.examOriginaleveryStoreyData.data[axShape.assetData.Id]; + } else { + delete this.canvasData.selectPanelPoint.Data.DefinedIncrement[axShape.assetData.Id]; + delete this.canvasData.selectPanelPoint.Data.Increment[axShape.assetData.Id]; + delete this.canvasData.selectPanelPoint.Data.Stock[axShape.assetData.Id]; + } + } + this.backgroundImage.removeChild(axShape); + } + }); + this.selection.clear(); + this.emit('canvasDataChanged'); + this.canvasData.isChange = true; + AxMessageSystem.send(CanvasAction.selectionChanged); } } /** @@ -315,7 +351,7 @@ export class WorkingAreaComponent extends EventEmitter implements OnInit, AfterV this.app.stage.addChild(this.grid); this.grid.drawGrid(); this.grid.onMousemove = (evt, gridCoord) => { - console.log(gridCoord); + }; this.createBackgroundImage(); @@ -419,39 +455,7 @@ export class WorkingAreaComponent extends EventEmitter implements OnInit, AfterV * 删除图标事件(数据处理) */ this.on('deleteIcon', (axShape: AxShape) => { - // 删除图例对象 - const temp = this.backgroundImage.getChildByName('图例') as AxLegend; - if ( temp !== undefined - && temp !== null - && axShape.assetData.Name !== '图例') { - const itemLegend = new Legend(axShape.assetData.Name, axShape.assetData.ImageUrl, 1); - temp.deleteItem(itemLegend); - } - - if (axShape.assetData.GameMode === GameMode.BasicInformation) { // 基本信息 - // 删除楼层数据 - delete this.canvasData.originaleveryStoreyData.data[axShape.assetData.Id]; - // 删除建筑数据 - delete this.canvasData.originalcompanyBuildingData.data[axShape.assetData.Id]; - } else if (axShape.assetData.GameMode === GameMode.Assignment) { // 处置预案 - delete this.canvasData.selectPanelPoint.Data.DefinedIncrement[axShape.assetData.Id]; - delete this.canvasData.selectPanelPoint.Data.Increment[axShape.assetData.Id]; - delete this.canvasData.selectPanelPoint.Data.Stock[axShape.assetData.Id]; - } else if (axShape.assetData.GameMode === GameMode.Examinee) { // 考生考试 - if (axShape.assetData.Tag === 1) { - // 删除楼层数据 - delete this.canvasData.examOriginaleveryStoreyData.data[axShape.assetData.Id]; - } else { - delete this.canvasData.selectPanelPoint.Data.DefinedIncrement[axShape.assetData.Id]; - delete this.canvasData.selectPanelPoint.Data.Increment[axShape.assetData.Id]; - delete this.canvasData.selectPanelPoint.Data.Stock[axShape.assetData.Id]; - } - - } - this.backgroundImage.removeChild(axShape); - this.emit('canvasDataChanged'); - this.canvasData.isChange = true; }); } /** @@ -514,17 +518,16 @@ export class WorkingAreaComponent extends EventEmitter implements OnInit, AfterV }); } /** - * 设置高亮 + * 设置选中 + * 清空所有选择对象,选择ids集合元素 */ public setHighlight(ids: string[]): void { - this.selection.deselectAll(); + this.selection.clear(); ids.forEach(item => { - let obj = this.backgroundImage.getChildByName(item); - if (obj === null) { - obj = this.app.stage.getChildByName(item); - } - this.selection.select(obj); + const obj = this.backgroundImage.getChildByName(item); + this.selection.add(obj); }); + AxMessageSystem.send(''); } /** * 创建楼层图形 @@ -631,10 +634,9 @@ export class WorkingAreaComponent extends EventEmitter implements OnInit, AfterV .on('pointerdown', event => { if (event.data.button !== 0) { return; } console.log(this.backgroundImage.toLocal(this.mousePosition)); - if (!event.currentTarget.dragging && this.selection.isMultiselection === false) { - this.selection.deselectAll(); + if (!this.isMove && this.isCtrlKeyClicked === false) { event.currentTarget.data = event.data; - event.currentTarget.dragging = true; + this.isMove = true; event.currentTarget.dragPoint = event.data.getLocalPosition(event.currentTarget.parent); event.currentTarget.dragPoint.x -= event.currentTarget.x; event.currentTarget.dragPoint.y -= event.currentTarget.y; @@ -828,18 +830,17 @@ export class WorkingAreaComponent extends EventEmitter implements OnInit, AfterV // this.emit('backgroundScale', this.backgroundImage.scale.x); break; } - } else if (!event.currentTarget.dragging && this.selection.isMultiselection === true) { + } else if (!this.isMove && this.isCtrlKeyClicked === true) { this.rectToolGraphics.visible = true; - event.currentTarget.dragging = true; + this.isMove = true; this.initialScreenMousePos = this.backgroundImage.toLocal(this.mousePosition); this.finalScreenMousePos = this.backgroundImage.toLocal(this.mousePosition); } }) .on('pointerup', event => { - if (event.currentTarget.dragging) { - event.currentTarget.dragging = false; - event.currentTarget.data = null; - } + this.isMove = false; + event.currentTarget.data = null; + if (this.rectToolGraphics.visible === true) { this.backgroundImage.children.forEach(item => { if ( item instanceof AxImageShape @@ -850,26 +851,27 @@ export class WorkingAreaComponent extends EventEmitter implements OnInit, AfterV const rect1 = this.rectToolGraphics.getBounds(); const rect2 = item.getBounds(); if (this.isOverlap(rect1, rect2)) { - this.selection.select(item); + this.selection.add(item); } } }); this.rectToolGraphics.clear(); this.rectToolGraphics.visible = false; + AxMessageSystem.send(CanvasAction.selectionChanged); } }) .on('pointerupoutside', event => { - if (event.currentTarget.dragging) { - event.currentTarget.dragging = false; + if (this.isMove) { + this.isMove = false; event.currentTarget.data = null; } }) .on('pointermove', event => { - if (event.currentTarget.dragging && this.selection.isMultiselection === false) { + if (this.isMove && this.isCtrlKeyClicked === false) { const newPosition = event.currentTarget.data.getLocalPosition(event.currentTarget.parent); event.currentTarget.x = newPosition.x - event.currentTarget.dragPoint.x; event.currentTarget.y = newPosition.y - event.currentTarget.dragPoint.y; - } else if (event.currentTarget.dragging && this.selection.isMultiselection === true) { + } else if (this.isMove && this.isCtrlKeyClicked === true) { if (this.rectToolGraphics.visible === true) { this.finalScreenMousePos = this.backgroundImage.toLocal(this.mousePosition); } @@ -877,7 +879,7 @@ export class WorkingAreaComponent extends EventEmitter implements OnInit, AfterV }) .on('rightclick', event => { event.stopPropagation(); - this.selection.deselectAll(); + this.deselectAll(); this.setPaintMode(PaintMode.endPaint); }) .on('pointerover', (event) => { @@ -951,11 +953,11 @@ 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 { + public async refresh(imageUrl: string = this.canvasData.selectStorey.imageUrl, + imageAngle: number = this.canvasData.selectStorey.imageAngle): Promise { await this.refreshBackgroundImage(); - // 清空所有图形 - this.selection.deselectAll(); + this.deselectAll(); const itemList = []; this.backgroundImage.children.forEach(item => { if (item instanceof AxShape && item instanceof AxPreviewImageShape === false) { @@ -978,10 +980,10 @@ export class WorkingAreaComponent extends EventEmitter implements OnInit, AfterV * 加载无关联信息处置预案 * @data 处置预案数据 */ - public async loadNoRelevantInformationDisposalPlan(data:DisposalNodeData): Promise { - await this.refreshBackgroundImage(data.BackgroundImageUrl,data.BackgroundImageAngle); + public async loadNoRelevantInformationDisposalPlan(data: DisposalNodeData): Promise { + await this.refreshBackgroundImage(data.BackgroundImageUrl, data.BackgroundImageAngle); // 清空所有图形 - this.selection.deselectAll(); + this.deselectAll(); const itemList = []; this.backgroundImage.children.forEach(item => { if (item instanceof AxShape && item instanceof AxPreviewImageShape === false) { @@ -1142,7 +1144,7 @@ export class WorkingAreaComponent extends EventEmitter implements OnInit, AfterV */ public beginPaint() { console.log(this.canvasData.selectTemplateData); - this.selection.deselectAll(); + this.deselectAll(); this.setPaintMode(PaintMode.endPaint); this.setPaintMode(this.canvasData.selectTemplateData.interactiveMode); } @@ -1291,49 +1293,52 @@ export class WorkingAreaComponent extends EventEmitter implements OnInit, AfterV * 复制 */ public copy(): void { - this.copyData = []; - this.selection.objects.forEach(item => { - const newData = JSON.parse(JSON.stringify(item.assetData)); - this.copyData.push(newData); - }); + this.copyData = []; + this.selection.all().forEach(item => { + const newData = JSON.parse(JSON.stringify(item.assetData)); + this.copyData.push(newData); + }); } /** * 粘贴 */ public paste(companyId: string, buildingId: string, floorId: string): void { - this.copyData.forEach(item => { - item.Point = new PIXI.Point(item.Point.x + 5, item.Point.y + 5); - const newData = JSON.parse(JSON.stringify(item)); - newData.Id = ObjectID.default.generate(), - newData.CompanyId = companyId; - newData.BuildingId = buildingId; - newData.FloorId = floorId; - newData.Point = new PIXI.Point(item.Point.x + 5, item.Point.y + 5); - switch (item.InteractiveMode) { - case PaintMode.singlePointIcon: - const singleIcon = new AxImageShape(newData, this); - this.emit('createIcon', singleIcon); - break; - case PaintMode.lineIcon: - const lineIcon = new MultipointIcon(newData, this); - this.emit('createIcon', lineIcon); - break; - case PaintMode.polygonIcon: - const polygonIcon = new PolygonIcon(newData, this); - this.emit('createIcon', polygonIcon); - break; - case PaintMode.Pipeline: - if (item.Name === '距离') { - const wall = new AxArrowConnector(newData, this, true, true); - this.emit('createIcon', wall); - } else if (item.Name === '普通墙' || item.Name === '承重墙') { - const wall = new AxArrowConnector(newData, this, false, false); - this.emit('createIcon', wall); - } - break; - } - this.selection.select(this.backgroundImage.getChildByName(newData.Id)); - }); + if (this.copyData.length > 0) { + this.copyData.forEach(item => { + item.Point = new PIXI.Point(item.Point.x + 5, item.Point.y + 5); + const newData = JSON.parse(JSON.stringify(item)); + newData.Id = ObjectID.default.generate(), + newData.CompanyId = companyId; + newData.BuildingId = buildingId; + newData.FloorId = floorId; + newData.Point = new PIXI.Point(item.Point.x + 5, item.Point.y + 5); + switch (item.InteractiveMode) { + case PaintMode.singlePointIcon: + const singleIcon = new AxImageShape(newData, this); + this.emit('createIcon', singleIcon); + break; + case PaintMode.lineIcon: + const lineIcon = new MultipointIcon(newData, this); + this.emit('createIcon', lineIcon); + break; + case PaintMode.polygonIcon: + const polygonIcon = new PolygonIcon(newData, this); + this.emit('createIcon', polygonIcon); + break; + case PaintMode.Pipeline: + if (item.Name === '距离') { + const wall = new AxArrowConnector(newData, this, true, true); + this.emit('createIcon', wall); + } else if (item.Name === '普通墙' || item.Name === '承重墙') { + const wall = new AxArrowConnector(newData, this, false, false); + this.emit('createIcon', wall); + } + break; + } + this.selection.add(this.backgroundImage.getChildByName(newData.Id)); + }); + AxMessageSystem.send(CanvasAction.selectionChanged); + } } //////////////////////////////////////////////////////////////////////// 通用///////////////////////////////////////////////////////////////////////////// /** @@ -1357,7 +1362,7 @@ export class WorkingAreaComponent extends EventEmitter implements OnInit, AfterV public async onExamineeClickFloor() { await this.refreshBackgroundImage(); // 清空所有图形 - this.selection.deselectAll(); + this.deselectAll(); const itemList = []; this.backgroundImage.children.forEach(item => { if (item instanceof AxShape && item instanceof AxPreviewImageShape === false) { @@ -1384,7 +1389,7 @@ export class WorkingAreaComponent extends EventEmitter implements OnInit, AfterV public async onExaminerClickFloor() { await this.refreshBackgroundImage(); // 清空所有图形 - this.selection.deselectAll(); + this.deselectAll(); const itemList = []; this.backgroundImage.children.forEach(item => { if (item instanceof AxShape && item instanceof AxPreviewImageShape === false) { @@ -1410,7 +1415,7 @@ export class WorkingAreaComponent extends EventEmitter implements OnInit, AfterV public async onExaminerClickFloor_CreateTestpaper() { await this.refreshBackgroundImage(); // 清空所有图形 - this.selection.deselectAll(); + this.deselectAll(); const itemList = []; this.backgroundImage.children.forEach(item => { if (item instanceof AxShape && item instanceof AxPreviewImageShape === false) { @@ -1428,94 +1433,26 @@ export class WorkingAreaComponent extends EventEmitter implements OnInit, AfterV // 隐藏图标 this.setNameVisible(false, 0); } -} - -/** - * 选择器 - */ -export class Selection { - constructor(private workingArea: WorkingAreaComponent) {} - public objects: any[] = []; - public isMultiselection = false; - /** - * 返回选择器中是否包含对象 - * @param obj 对象 - */ - public contains(obj: any): boolean { - return this.objects.includes(obj); - } - /** - * 选定对象 - * @param obj 对象 - */ - public select(obj: any) { - if (!this.contains(obj)) { - this.workingArea.emit('select', obj); - this.objects.push(obj); - } - } - /** - * 取消选定对象 - * @param obj 对象 - */ - public deselect(obj: any) { - if (this.contains(obj)) { - this.workingArea.emit('deselect', obj); - const idx = this.objects.findIndex(x => x === obj); - this.objects.splice(idx, 1); - } - } - /** - * 选定或取消选定对象 - * @param obj 对象 - */ - public selectOrDeselect(obj: any) { - if (this.contains(obj)) { - this.deselect(obj); - } else { - this.select(obj); - } - } - /** - * 取消选定所有已选定对象 - */ + //////////////////////////////////////////////////////////////////// 选择逻辑 + // 取消所有选择 public deselectAll() { - this.objects.forEach(item => { - this.workingArea.emit('deselect', item); - }); - this.objects.splice(0, this.objects.length); - } - /** - * 取消选定所有对象后选定一个对象 - * @param obj 对象 - */ - public selectOne(obj: any) { - if (this.isMultiselection) { - this.selectOrDeselect(obj); - } else { - this.deselectAll(); - this.select(obj); + if (this.selection.first() !== null) { + this.selection.all().forEach(item => { + item.hideBorder(); + item.setPointVisiable(false); + }); + this.selection.clear(); + AxMessageSystem.send(CanvasAction.selectionChanged); } } - /** - * 选定对象集合中所有对象 - * @param objects 对象集合 - */ - public selectAll(objects: any[]) { - this.objects.forEach(item => { - this.select(item); - }); + // 选择单个 + public selectSingle(obj: any) { + this.deselectAll(); + this.selection.add(obj); + AxMessageSystem.send(CanvasAction.selectionChanged); } } - - -/** - * 车辆类型 - */ -export enum Type { - 水源 = 0, - 举高喷射消防车 = 1, - 泡沫消防车 = 2, - 水罐消防车 = 3, - 压缩空气泡沫消防车 = 4 +enum CanvasAction { + selectionChanged = 'selectionChanged', + copyDataChanged = 'copyDataChanged' } From e6c0c6c8b889935ee97c9df45dcb03fa2106acbf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BE=90=E6=8C=AF=E5=8D=87?= <359059686@qq.com> Date: Mon, 25 Jan 2021 09:11:03 +0800 Subject: [PATCH 3/7] =?UTF-8?q?=E5=88=A0=E9=99=A4debug.log?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- debug.log | 3 --- 1 file changed, 3 deletions(-) delete mode 100644 debug.log diff --git a/debug.log b/debug.log deleted file mode 100644 index c4638ef..0000000 --- a/debug.log +++ /dev/null @@ -1,3 +0,0 @@ -[1229/141605.754:ERROR:directory_reader_win.cc(43)] FindFirstFile: ϵͳҲָ· (0x3) -[0104/100053.968:ERROR:directory_reader_win.cc(43)] FindFirstFile: ϵͳҲָ· (0x3) -[0122/085819.900:ERROR:directory_reader_win.cc(43)] FindFirstFile: ϵͳҲָ· (0x3) From 45ffea975865fcafe9fc7d1e378c1ef09ad64355 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BE=90=E6=8C=AF=E5=8D=87?= <359059686@qq.com> Date: Mon, 25 Jan 2021 11:47:35 +0800 Subject: [PATCH 4/7] 1.0.12.20210125b --- .gitignore | 1 + src/app/working-area/model/axSelection.ts | 4 + src/app/working-area/model/axShape.ts | 60 +++--- .../working-area/working-area.component.ts | 171 +++++++++++------- 4 files changed, 132 insertions(+), 104 deletions(-) diff --git a/.gitignore b/.gitignore index 86d943a..a80a6b3 100644 --- a/.gitignore +++ b/.gitignore @@ -44,3 +44,4 @@ testem.log # System Files .DS_Store Thumbs.db +debug.log diff --git a/src/app/working-area/model/axSelection.ts b/src/app/working-area/model/axSelection.ts index e61cd78..ce7a6e0 100644 --- a/src/app/working-area/model/axSelection.ts +++ b/src/app/working-area/model/axSelection.ts @@ -13,6 +13,10 @@ export class AxSelection { return null; } } + // 是否已经选择了对象 + public has(obj: any): boolean { + return this.objects.has(obj); + } // 获得所有对象 public all() { return this.objects; diff --git a/src/app/working-area/model/axShape.ts b/src/app/working-area/model/axShape.ts index 2d032d5..3a5dae7 100644 --- a/src/app/working-area/model/axShape.ts +++ b/src/app/working-area/model/axShape.ts @@ -20,6 +20,10 @@ export class AxShape extends Graphics { showName = true; // 边框 border: PIXI.Graphics = new PIXI.Graphics(); + // 鼠标位置 + mousePosition: PIXI.Point; + // 鼠标拖动 + mouseDragging: boolean; constructor(assetData: any, workingArea: WorkingAreaComponent) { super(); @@ -35,50 +39,30 @@ export class AxShape extends Graphics { .on('pointerdown', event => { event.stopPropagation(); if (this.selectable) { - this.workingArea.selectSingle(this); + this.workingArea.select(this); } if (this.moveable) { - event.currentTarget.data = event.data; - event.currentTarget.alpha = 0.5; - event.currentTarget.dragging = true; - - event.currentTarget.dragPoint = event.data.getLocalPosition(event.currentTarget.parent); - event.currentTarget.dragPoint.x -= event.currentTarget.x; - event.currentTarget.dragPoint.y -= event.currentTarget.y; + this.mouseDragging = true; + this.mousePosition = new PIXI.Point(event.data.global.x, event.data.global.y); } }) .on('pointerup', event => { - if (event.currentTarget.dragging) { - event.currentTarget.alpha = 1; - event.currentTarget.dragging = false; - event.currentTarget.data = null; - } + this.mouseDragging = false; }) .on('pointerupoutside', event => { - if (event.currentTarget.dragging) { - event.currentTarget.alpha = 1; - event.currentTarget.dragging = false; - event.currentTarget.data = null; - } + this.mouseDragging = false; }) .on('pointermove', event => { - if (event.currentTarget.dragging) { - const newPosition = event.currentTarget.data.getLocalPosition(event.currentTarget.parent); - - // const offsetX = newPosition.x - event.currentTarget.dragPoint.x; - // const offsetY = newPosition.y - event.currentTarget.dragPoint.y; - // const offset = this.workingArea.backgroundImage.toLocal(new Point(offsetX, offsetY)); - // event.currentTarget.position += offset; - // // this.workingArea.selection.objects.forEach(shpae => { - // // shpae.x = newPosition.x - event.currentTarget.dragPoint.x; - // // shpae.y = newPosition.y - event.currentTarget.dragPoint.y; - // // shpae.assetData.Point = new PIXI.Point(this.x, this.y); - // // this.workingArea.canvasData.isChange = true; - // // }) - event.currentTarget.x = newPosition.x - event.currentTarget.dragPoint.x; - event.currentTarget.y = newPosition.y - event.currentTarget.dragPoint.y; - this.assetData.Point = new PIXI.Point(this.x, this.y); - this.workingArea.canvasData.isChange = true; + if (this.mouseDragging) { + this.workingArea.selection.all().forEach(item => { + const x = event.data.global.x - this.mousePosition.x; + const y = event.data.global.y - this.mousePosition.y; + item.x += x * (1 / this.workingArea.backgroundImage.scale.x); + item.y += y * (1 / this.workingArea.backgroundImage.scale.y); + item.assetData.Point = new PIXI.Point(item.x, item.y); + this.workingArea.canvasData.isChange = true; + }); + this.mousePosition = new PIXI.Point(event.data.global.x, event.data.global.y); } }) .on('rightclick', event => { @@ -127,9 +111,9 @@ export class AxShape extends Graphics { this.border.lineStyle(scale * 1, 0x00a8ff); - let spaceLength = scale * 1; - let lineLenght = rect.width + 0.5 + 0.5; - let dashLength = scale * ( lineLenght + spaceLength - Math.floor((rect.width + rect.height) / 2 / 4.1)) / Math.floor((rect.width + rect.height) / 2 / 4.1); + const spaceLength = scale * 1; + const lineLenght = rect.width + 0.5 + 0.5; + const dashLength = scale * ( lineLenght + spaceLength - Math.floor((rect.width + rect.height) / 2 / 4.1)) / Math.floor((rect.width + rect.height) / 2 / 4.1); this.drawDash(this.border, p1.x - 0.5 * scale, p1.y, p2.x + 0.5 * scale, p2.y, dashLength, spaceLength); this.drawDash(this.border, p2.x, p2.y - 0.5 * scale, p3.x, p3.y + 0.5 * scale, dashLength, spaceLength); this.drawDash(this.border, p3.x + 0.5 * scale, p3.y, p4.x - 0.5 * scale, p4.y, dashLength, spaceLength); diff --git a/src/app/working-area/working-area.component.ts b/src/app/working-area/working-area.component.ts index 1b05d4c..851b75d 100644 --- a/src/app/working-area/working-area.component.ts +++ b/src/app/working-area/working-area.component.ts @@ -151,7 +151,7 @@ export class WorkingAreaComponent extends EventEmitter implements OnInit, AfterV * RC版: 该版本已经相当成熟了,基本上不存在导致错误的BUG,与即将发行的正式版相差无几。 * Release版: 该版本意味“最终版本”,在前面版本的一系列测试版之后,终归会有一个正式版本,是最终交付用户使用的一个版本。该版本有时也称为标准版。一般情况下,Release不会以单词形式出现在软件封面上,取而代之的是符号®。 */ - public VERSION = '1.0.11.20210122_beta'; + public VERSION = '1.0.12.20210125_beta'; /** * 数据初始化 */ @@ -174,14 +174,6 @@ export class WorkingAreaComponent extends EventEmitter implements OnInit, AfterV this.deleteSelectedShape(); } }); - // 消息系统事件监听 - AxMessageSystem.addListener(CanvasAction.selectionChanged, () => { - this.selection.all().forEach(item => { - item.showBorder(); - item.drawBorder(1 / this.backgroundImage.scale.x); - item.setPointVisiable(this.allowEdit); - }); - }, this); } /** * 删除选中的图标 @@ -391,28 +383,6 @@ export class WorkingAreaComponent extends EventEmitter implements OnInit, AfterV this.rectToolGraphics.endFill(); } }); - /** - * 选中事件 - */ - this.on('select', (axShape: AxShape) => { - // if (axShape instanceof AxRectangleShape) { - // let upLeft: PIXI.Sprite= new PIXI.Sprite(this.editorPointTexture); - // let upRight: PIXI.Sprite= new PIXI.Sprite(this.editorPointTexture); - // let downLeft: PIXI.Sprite= new PIXI.Sprite(this.editorPointTexture); - // let downRight: PIXI.Sprite = new PIXI.Sprite(this.editorPointTexture); - // } else { - axShape.showBorder(); - axShape.drawBorder(1 / this.backgroundImage.scale.x); - axShape.setPointVisiable(this.allowEdit); - // } - }); - /** - * 取消选中事件 - */ - this.on('deselect', (axShape: AxShape) => { - axShape.hideBorder(); - axShape.setPointVisiable(false); - }); /** * 创建图标事件(数据处理) */ @@ -451,12 +421,6 @@ export class WorkingAreaComponent extends EventEmitter implements OnInit, AfterV this.emit('canvasDataChanged'); this.canvasData.isChange = true; }); - /** - * 删除图标事件(数据处理) - */ - this.on('deleteIcon', (axShape: AxShape) => { - - }); } /** * 重置画布 @@ -517,18 +481,6 @@ export class WorkingAreaComponent extends EventEmitter implements OnInit, AfterV } }); } - /** - * 设置选中 - * 清空所有选择对象,选择ids集合元素 - */ - public setHighlight(ids: string[]): void { - this.selection.clear(); - ids.forEach(item => { - const obj = this.backgroundImage.getChildByName(item); - this.selection.add(obj); - }); - AxMessageSystem.send(''); - } /** * 创建楼层图形 */ @@ -842,22 +794,21 @@ export class WorkingAreaComponent extends EventEmitter implements OnInit, AfterV event.currentTarget.data = null; if (this.rectToolGraphics.visible === true) { + const shapes: AxShape[] = []; this.backgroundImage.children.forEach(item => { - if ( item instanceof AxImageShape - || item instanceof MultipointIcon - || item instanceof PolygonIcon - || item instanceof AxArrowConnector) { + if ( item instanceof AxShape + && item instanceof AxPreviewImageShape === false) { // 判断2个矩形是否相交 const rect1 = this.rectToolGraphics.getBounds(); const rect2 = item.getBounds(); if (this.isOverlap(rect1, rect2)) { - this.selection.add(item); + shapes.push(item); } } }); this.rectToolGraphics.clear(); this.rectToolGraphics.visible = false; - AxMessageSystem.send(CanvasAction.selectionChanged); + this.selectAll(shapes); } }) .on('pointerupoutside', event => { @@ -1303,12 +1254,13 @@ export class WorkingAreaComponent extends EventEmitter implements OnInit, AfterV * 粘贴 */ public paste(companyId: string, buildingId: string, floorId: string): void { + const ids: string[] = []; if (this.copyData.length > 0) { this.copyData.forEach(item => { item.Point = new PIXI.Point(item.Point.x + 5, item.Point.y + 5); const newData = JSON.parse(JSON.stringify(item)); newData.Id = ObjectID.default.generate(), - newData.CompanyId = companyId; + newData.CompanyId = companyId; newData.BuildingId = buildingId; newData.FloorId = floorId; newData.Point = new PIXI.Point(item.Point.x + 5, item.Point.y + 5); @@ -1335,9 +1287,9 @@ export class WorkingAreaComponent extends EventEmitter implements OnInit, AfterV } break; } - this.selection.add(this.backgroundImage.getChildByName(newData.Id)); + ids.push(newData.Id); }); - AxMessageSystem.send(CanvasAction.selectionChanged); + this.setHighlight(ids); } } //////////////////////////////////////////////////////////////////////// 通用///////////////////////////////////////////////////////////////////////////// @@ -1434,22 +1386,109 @@ export class WorkingAreaComponent extends EventEmitter implements OnInit, AfterV this.setNameVisible(false, 0); } //////////////////////////////////////////////////////////////////// 选择逻辑 - // 取消所有选择 + /** + * 清空选择,选择单个形状 + * @param shape 形状 + */ + public selectSingle(shape: AxShape) { + if (this.selection.first() !== null) { + this.selection.all().forEach(item => { + this.clearSelectEffect(item); + }); + this.selection.clear(); + } + this.selection.add(shape); + this.setSelectEffect(shape); + AxMessageSystem.send(CanvasAction.selectionChanged); + } + /** + * 选择 + * @param shape 形状 + */ + public select(shape: AxShape) { + if (this.selection.first() !== null + && !this.isCtrlKeyClicked + && !this.selection.has(shape)) { + this.selection.all().forEach(item => { + this.clearSelectEffect(item); + }); + this.selection.clear(); + } + this.selection.add(shape); + this.setSelectEffect(shape); + AxMessageSystem.send(CanvasAction.selectionChanged); + } + /** + * 选择集合中的形状 + * @param shape 形状集合 + */ + public selectAll(shape: AxShape[]) { + this.selection.addArray(shape); + this.selection.all().forEach(item => { + this.setSelectEffect(item); + }); + AxMessageSystem.send(CanvasAction.selectionChanged); + } + /** + * 先清空再选择全部 + * @param shape 形状集合 + */ + public selectAllWithClear(shape: AxShape[]) { + if (this.selection.first() !== null) { + this.selection.all().forEach(item => { + this.clearSelectEffect(item); + }); + this.selection.clear(); + } + this.selection.addArray(shape); + this.selection.all().forEach(item => { + this.setSelectEffect(item); + }); + AxMessageSystem.send(CanvasAction.selectionChanged); + } + /** + * 选择集合中所有id的形状 + * @param ids 形状id集合 + */ + public setHighlight(ids: string[]): void { + const shapes: AxShape[] = []; + // 重新选择 + ids.forEach(item => { + const obj = this.backgroundImage.getChildByName(item); + shapes.push(obj as AxShape); + }); + this.selectAllWithClear(shapes); + } + /** + * 取消所有选择 + */ public deselectAll() { if (this.selection.first() !== null) { this.selection.all().forEach(item => { - item.hideBorder(); - item.setPointVisiable(false); + this.clearSelectEffect(item); }); this.selection.clear(); AxMessageSystem.send(CanvasAction.selectionChanged); } } - // 选择单个 - public selectSingle(obj: any) { - this.deselectAll(); - this.selection.add(obj); - AxMessageSystem.send(CanvasAction.selectionChanged); + /** + * 设置选中效果 + * @param shape 形状 + */ + public setSelectEffect(shape: AxShape) { + shape.hideBorder(); + shape.setPointVisiable(false); + shape.showBorder(); + shape.drawBorder(1 / this.backgroundImage.scale.x); + shape.setPointVisiable(this.allowEdit); + } + /** + * 设置形状选中效果 + * @param shape 形状 + */ + public clearSelectEffect(shape: AxShape) { + shape.hideBorder(); + shape.setPointVisiable(false); } } enum CanvasAction { From 34177788a2f5d512463f430361ba355064d5f941 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BE=90=E6=8C=AF=E5=8D=87?= <359059686@qq.com> Date: Mon, 25 Jan 2021 12:02:24 +0800 Subject: [PATCH 5/7] =?UTF-8?q?=E8=AE=BE=E7=BD=AE=E5=9B=BE=E4=BE=8B?= =?UTF-8?q?=E6=98=BE=E7=A4=BA=E9=9A=90=E8=97=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/app/working-area/working-area.component.ts | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/app/working-area/working-area.component.ts b/src/app/working-area/working-area.component.ts index 851b75d..0d407f3 100644 --- a/src/app/working-area/working-area.component.ts +++ b/src/app/working-area/working-area.component.ts @@ -1490,6 +1490,15 @@ export class WorkingAreaComponent extends EventEmitter implements OnInit, AfterV shape.hideBorder(); shape.setPointVisiable(false); } + ////////////////////////////////////////////////////////////////////////////////////////////////图例 + /** + * 设置图例显示隐藏 + * @param b true 显示,false隐藏 + */ + public setLegendVisible(b: boolean): void { + const legend = this.backgroundImage.getChildByName('图例') as AxLegend; + legend.visible = b; + } } enum CanvasAction { selectionChanged = 'selectionChanged', From b5e615c00686e7d9b800139c20dc675d65fd8b0d Mon Sep 17 00:00:00 2001 From: cpf <1105965053@qq.com> Date: Mon, 25 Jan 2021 13:46:22 +0800 Subject: [PATCH 6/7] =?UTF-8?q?[=E5=AE=8C=E5=96=84]=20=E9=87=87=E9=9B=86?= =?UTF-8?q?=E5=B7=A5=E5=85=B7,=E7=BC=96=E5=88=B6=E5=B7=A5=E5=85=B7?= =?UTF-8?q?=E6=8C=89=E5=8E=9F=E5=9E=8B=E5=9B=BE=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/app/canvas-share-data.service.ts | 2 +- .../edit-plan-info.component.html | 39 +- .../view-unit-details.component.html | 25 +- .../addDisposalNode.html | 24 + .../addPlaneFigure.html | 38 + .../collection-tools.component.html | 384 +++ .../collection-tools.component.scss | 450 ++++ .../collection-tools.component.spec.ts | 25 + .../collection-tools.component.ts | 2391 +++++++++++++++++ .../createBuilding.html | 28 + .../editBuilding.html | 23 + .../editDisposalNode.html | 23 + .../editPlaneFigure.html | 39 + .../leftFunctionalDomain.ts | 180 ++ .../ui/collection-tools-building/panel.scss | 291 ++ src/app/ui/collection-tools-building/save.ts | 300 +++ .../ui/collection-tools-building/saveOne.html | 5 + .../ui/collection-tools-building/saveTwo.html | 53 + .../viewdetails.html | 24 + .../collection-tools-plan/addPlaneFigure.html | 11 + .../collection-tools.component.html | 152 +- .../collection-tools.component.scss | 37 +- .../collection-tools.component.ts | 49 +- .../leftFunctionalDomain.ts | 95 +- src/app/ui/collection-tools-plan/panel.scss | 25 + .../collection-tools.component.html | 20 +- .../collection-tools.component.scss | 6 + .../collection-tools.component.ts | 52 +- .../collection-tools/leftFunctionalDomain.ts | 2 +- src/app/ui/collection-tools/save.ts | 147 +- src/app/ui/ui.module.ts | 6 +- 31 files changed, 4626 insertions(+), 320 deletions(-) create mode 100644 src/app/ui/collection-tools-building/addDisposalNode.html create mode 100644 src/app/ui/collection-tools-building/addPlaneFigure.html create mode 100644 src/app/ui/collection-tools-building/collection-tools.component.html create mode 100644 src/app/ui/collection-tools-building/collection-tools.component.scss create mode 100644 src/app/ui/collection-tools-building/collection-tools.component.spec.ts create mode 100644 src/app/ui/collection-tools-building/collection-tools.component.ts create mode 100644 src/app/ui/collection-tools-building/createBuilding.html create mode 100644 src/app/ui/collection-tools-building/editBuilding.html create mode 100644 src/app/ui/collection-tools-building/editDisposalNode.html create mode 100644 src/app/ui/collection-tools-building/editPlaneFigure.html create mode 100644 src/app/ui/collection-tools-building/leftFunctionalDomain.ts create mode 100644 src/app/ui/collection-tools-building/panel.scss create mode 100644 src/app/ui/collection-tools-building/save.ts create mode 100644 src/app/ui/collection-tools-building/saveOne.html create mode 100644 src/app/ui/collection-tools-building/saveTwo.html create mode 100644 src/app/ui/collection-tools-building/viewdetails.html diff --git a/src/app/canvas-share-data.service.ts b/src/app/canvas-share-data.service.ts index 16298ba..56daf18 100644 --- a/src/app/canvas-share-data.service.ts +++ b/src/app/canvas-share-data.service.ts @@ -31,7 +31,7 @@ export class CanvasShareDataService { allDisposalNode: any = []; // 所有 处置节点 allNodeMarkers: any; // 灾情 标签信息 selectPanelPoint: DisposalNodeData = new DisposalNodeData(); // 当前数据节点 - selectPanelPointBaseData: any = {description: '', notes: '', weather: '', airTemperature: '', windDirection: '', windScale: ''}; // 当前 数据节点 所对应的 天气,详情 数据节点 + selectPanelPointBaseData: any = {description: '', notes: '', weather: '', airTemperature: '', windDirection: '', windScale: ''}; // 当前 数据节点 对应 父级节点 customizeDisposalNode:any; // 新建 自定义数据节点 底图+名称 // 处置 节点 diff --git a/src/app/key-unit/edit-plan-info/edit-plan-info.component.html b/src/app/key-unit/edit-plan-info/edit-plan-info.component.html index c46fef7..cc729aa 100644 --- a/src/app/key-unit/edit-plan-info/edit-plan-info.component.html +++ b/src/app/key-unit/edit-plan-info/edit-plan-info.component.html @@ -7,52 +7,57 @@ - + - + - - - - + + + + - - - - + + + + + + + + + - + - + - + - + - + - + - +
+ + + + + 基本信息名称 + visibility + + + + + + + + + + +
+ + +
+ + +
+ + +
+
+ + + + +
+
+ +
+
+ keyboard_arrow_up + keyboard_arrow_down + + +
+
+
+ + + + + + + + + + photo_size_select_actual + + + + + + +
+

+ keyboard_arrow_up +

+

+ edit + delete +

+

+ cached + library_books +

+

+ keyboard_arrow_down +

+
+ +
+
+
+ + +
+
+ keyboard_arrow_up + keyboard_arrow_down + +
+
+ + + + + + +
+
+ +

{{items.name}}

+
+
+ +
+
+
+
+ + +
+
+ keyboard_arrow_up + keyboard_arrow_down + + +
+
+ + + +
+ +
+ edit + add + library_books + delete_forever +
+
+
+ +
+
+ + +
+ +
+ +
+ +
+
+
+ 属性 +
+
+ +
+

面积(平方米)

+
{{canvasData.selectStorey.area}}
+

详情

+
+ {{canvasData.selectStorey.details}} +
+
+ +
+

{{assetName}}

+ +
+

宽度(像素)

+ +

高度(像素)

+ +

角度

+
+ + +
+
+ +
+

厚度

+
+ + +
+
+ +

是否高亮

+
+ + 选中高亮 +
+
+
+ 颜色 +
+ +
+
+
+
    +
  • +
+
+ 透明度 + + {{colorDivSliderValue}}% +
+
+ +
+

{{item.PropertyName}}({{item.PhysicalUnit}})

+ +
+ +
+

{{item.PropertyName}}({{item.PhysicalUnit}})

+ +
+ +
+

{{item.PropertyName}}({{item.PhysicalUnit}})

+ +
+ +
+
+

{{item.PropertyName}}

+ {{imagesArr.length ? imagesArr.length : 0}} / {{item.PropertyValue}} + +
添加
+ + +
+
+
+
+ +
+
+ + delete + +
+
+
+ +
+

{{item.PropertyName}}

+ +
+ +
+

{{item.PropertyName}}

+ + +
+ +
+

{{item.PropertyName}}

+ +
+ +
+

{{item.PropertyName}}

+ +
+
+
+ +
+ +
+ +
+ +
+
+ 消防要素 +
+
+ +
+ + + + + + + {{node.name}} + + ({{node.children.length}}) + visibility + + + + + + + {{node.name}} + + ({{node.children.length}}) + visibility + + + +
+
+
+ +
+
+
+
+ 节点详情 +
+
+ 注意事项 +
+
+
+ + +
+
+
+
+ +
\ No newline at end of file diff --git a/src/app/ui/collection-tools-building/collection-tools.component.scss b/src/app/ui/collection-tools-building/collection-tools.component.scss new file mode 100644 index 0000000..02c4e97 --- /dev/null +++ b/src/app/ui/collection-tools-building/collection-tools.component.scss @@ -0,0 +1,450 @@ +@import './panel.scss'; +.icongray{ + color: #D9D0DC; +} +.content { + width: 100%; + height: 100%; + overflow: hidden; + box-sizing: border-box; + padding: 1px; + display: flex; + flex-direction: column; + + .buildingbtnchecked{ + background-color: #34A6FD; + color: white; + } +} + +//header头部 +.header { + position: relative; + flex: 5%; + display: flex; + align-items:center; + min-height: 40px; + background-color: #fff; + .marginLeftRight { + margin: 0 8px; + font-size: 16px; + user-select: none; + cursor: pointer; + .mat-icon { vertical-align: middle; font-size: 24px; } + } + .copytobutn{ + width: 60px; + min-width: 60px; + display: flex; + justify-content: center; + } + span{ + height: 24px; + line-height: 24px; + } + .patternSwitch{ + position: absolute; + right: 140px; + span{ + font-size: 18px; + cursor: pointer; + margin: 0 3px; + display: inline-block; + border: 1px solid gray; + border-radius: 3px; + padding: 0 5px; + } + .selectedPattern{ + background-color: #2196f3; + color: white; + } + } + .rightSave { + cursor: pointer; + position: absolute; + right: 60px; + label { vertical-align: middle; color: #279FFF; } + } +} + +//头部操作栏 +.headerOperate { + img { + width: 24px; + height: 24px; + vertical-align: middle; + margin-left: 1px; + } + span{ + font-size: 18px; + } + flex: 5%; + display: flex; + align-items:center; + min-height: 40px; + box-sizing: border-box; + margin: 3px 0; + background-color: white; + button{ + border: 0.5px solid rgb(208, 211, 214); + margin: 0 2px; + } + .editdeletebtn{ + display: none; + } + .bigeditdeletebtn:hover{ + .editdeletebtn{ + display: inline-block; + } + } +} + +//功能区 +// icon统一样式 +.mat-icon { + cursor:pointer; + vertical-align: middle; +} +//左右两侧功能栏 统一样式 +.publicCss { + border-radius: 5px; + position: absolute; + height: 100%; + top: 0; +} +.functionalDomain { + flex: 90%; + overflow: hidden; + .functionalDomainContent { + position: relative; + width: 100%; + height: 100%; + } + .functionalDomainLeft { + background-color: #fff; + display: flex; + flex-direction: column; + margin-left: 0px; + transition: margin-left 0.5s; + min-width: 235px; + border: 1px solid #E6EAEE; + width: 235px; + left: 0; + z-index: 111; + .leftDragDiv{ + position: absolute; + right: 0; + height: 100%; + width: 3px; + z-index: 1000; + cursor: e-resize; + } + } + .functionalDomainRight { + z-index: 1001; + margin-right: 0px; + transition: margin-right 0.5s; + border: 1px solid #464646; + width: 235px; + right: 0; + + } + //右边导航栏显示隐藏 + .togglePanel2 { + margin-right: -2000px; + transition: margin-right 1s; + } + //左侧导航栏显示隐藏 + .togglePanel { + margin-left: -2000px; + transition: margin-left 1s; + } + +} + +//右边操作栏 +.title{ + width: 100%; + height: 35px; + background-color: #464646; + div{ + width: 50%; + height: 35px; + line-height: 35px; + background-color: #595959; + border-radius: 5px; + span{ + color: white; + font-size: 14px; + font-weight: 400; + padding-left: 5px; + } + } +} + + +//右侧属性 +.property{ + display: flex; + flex-flow: column; + .siteproperty{ + height: 100%; + overflow-y: auto; + p{ + color: #9c9fa5; + padding-left: 5px; + } + .siteproperty_size{ + background-color: #e3e3e3; + width: 93%; + margin: 0 auto; + border-radius: 3px; + min-height: 21px; + } + .rightAttribute{ + width: 12%; + height: 99.5%; + position: absolute; + top: 0; + right: 0; + bottom: 0; + border: 2px solid #464646; + } + } + .assetsproperty{ + overflow-y: auto; + height: 100%; + p{ + color: #9c9fa5; + margin:1px 0 3px 8px; + font-size: 14px; + } + span{ + font-size: 15px; + } + input{ + height: 18px; + } + .biginput{ + display: block; + width: 88%; + margin: 0 auto; + } + .smallinput{ + display: block; + width: 19%; + margin-left: 8px; + } + .textarea{ + display: block; + width: 88%; + height: 50px; + margin: 0 auto; + } + .swiper-button-next{ + right: 6px; + } + .swiper-button-prev{ + left: 6px; + } + .swiper-container{ + // --swiper-theme-color: #ff6600;/* 设置Swiper风格 */ + // --swiper-navigation-color: #00ff33;/* 单独设置按钮颜色 */ + --swiper-navigation-size:20px;/* 设置按钮大小 */ + } + .hoverred:hover{ + color: rgb(187, 28, 28); + } + .selectDiv{ + height: 21px; + position: relative; + margin-bottom: 5px; + select{ + width: 98px; + height: 22px; + vertical-align: middle; + position: absolute; + right: 10px; + top: 1px; + border: 1px solid rgb(208, 211, 214); + border-radius: 2px; + } + } + .colorBigDiv{ + width: 88%; + margin-left: 8px; + .colorBigTemplateDiv{ + span{ + color: #9c9fa5; + font-size: 14px; + height: 26px; + line-height: 26px; + } + .colorTemplateDiv{ + width: 65%; + height: 22px; + display: inline-block; + vertical-align: middle; + margin-left: 26px; + } + } + + .colorDiv{ + .colorLi{ + width: 24px; + height: 24px; + list-style: none; + float: left; + border: 2px solid white; + } + .coloractive{ + border: 2px solid black; + } + } + } + + } +} +//右侧消防要素 +.firecategories{ + background-color: #fff; + position: relative; + display: flex; + flex-flow: column; + .firecategoriesTree{ + overflow-y: auto; + height: 100%; + mat-tree-node{ + position: relative; + } + .isLookCss{ + position: absolute; + right: 6px; + } + } +} + +// 解决轮播图蓝框问题 +div:focus { + outline: none; +} + +//没有图片时显示无图片背景图 +.noImgCss{ + background: url(../../../assets/images/noImg.png) no-repeat center center; + background-size: 88% 100%;/*按比例缩放*/ +} +.input{ + width: 18px; + height: 18px; + vertical-align: middle; + margin-left: 9px; + margin-right: 3px; +} + + +// tree +.mat-tree-node{ + min-height: 0; + height: 32px; + line-height: 32px; + font-size: 13px; + cursor: pointer; +} +.treeNode:hover{ + background-color: #ccebf8; +} +.isLookPattern{ + display: none; +} +.treeText{ + overflow: hidden; + white-space: nowrap; + text-overflow: ellipsis; + display: inline-block; + width: 65px; +} + +.bigBox{ + width: 700px; + height: 40px; + position: absolute; + overflow: hidden; + right: 0; +} +.weatherBox{ + height: 40px; + width: 700px; + line-height: 40px; + position: absolute; + right: 0; + transition: right linear .5s; + .openbtn{ + font-size: 45px; + height: 45px; + width: 40px; + } + .name{ + font-size: 16px; + vertical-align: middle; + margin-left: 3px; + } + input{ + width: 140px; + height: 22px; + margin-left: 3px; + } + select{ + width: 96px; + height: 25px; + margin-left: 3px; + vertical-align: middle; + } +} +.open{ + right: 0px; +} +.close{ + right:-622px; +} +.bottomCss{ + position: absolute; + left: 232px; + right: 0px; + bottom: 0; + height: 158px; + width: auto; + z-index: 100; + background-color: white; + border: 1px solid #464646; + .dragDiv{ + width: 100%; + height: 3px; + position: absolute; + top: 0; + z-index: 1000; + cursor: n-resize; + } + .title{ + height: 35px; + background-color: #464646; + div{ + background-color: #464646; + float: left; + width: 80px; + color: white; + font-size: 13px; + padding-left: 5px; + cursor: pointer; + } + .detailsAndattentBtn{ + background-color: #595959; + } + } + .body{ + textarea{ + width: 100%; + border-radius: 0px; + } + } +} \ No newline at end of file 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 new file mode 100644 index 0000000..acc7d5e --- /dev/null +++ b/src/app/ui/collection-tools-building/collection-tools.component.spec.ts @@ -0,0 +1,25 @@ +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 new file mode 100644 index 0000000..fb2e03b --- /dev/null +++ b/src/app/ui/collection-tools-building/collection-tools.component.ts @@ -0,0 +1,2391 @@ +import { Component, OnInit, Inject, ViewChild,ElementRef,Renderer2, ViewContainerRef } 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 {leftFunctionalDomainBuildingComponent,editPlaneFigureBuildingComponent,addDisposalNodeBuildingComponent,editDisposalNodeBuildingComponent} from './leftFunctionalDomain' +import {MatTreeFlatDataSource, MatTreeFlattener} from '@angular/material/tree'; +import {FlatTreeControl} from '@angular/cdk/tree'; +import {WorkingAreaComponent} from '../../working-area/working-area.component' +import {CanvasShareDataService, DisposalNodeData} from '../../canvas-share-data.service' //引入服务 +import Viewer from 'viewerjs'; +import Swiper from 'swiper'; +import { saveOneDialogBuilding } from './save'; +import { NzFormatBeforeDropEvent, NzFormatEmitEvent,NzTreeComponent } from 'ng-zorro-antd/tree'; +import { Observable, of } from 'rxjs'; +import { GameMode } from 'src/app/working-area/model/gameMode'; +import { ActivatedRoute, Router } from '@angular/router'; +import { TabbarAndScoreService } from 'src/app/http-interceptors/tabbar-and-score.service'; +import { MaskLayerService } from 'src/app/mask-layer.service'; +import * as ObjectID from 'bson-objectid'; + +@Component({ + selector: 'app-collection-tools-building', + templateUrl: './collection-tools.component.html', + styleUrls: ['./collection-tools.component.scss'] +}) +export class CollectionToolsBuildingComponent implements OnInit { + + @ViewChild('canvas',{static: true}) canvas:WorkingAreaComponent; //父组件中获得子组件的引用 + + constructor(private maskLayerService:MaskLayerService,private tabbarService: TabbarAndScoreService,private http:HttpClient,public dialog: MatDialog,public snackBar: MatSnackBar,private element: ElementRef,public canvasData: CanvasShareDataService,private router:Router,private route:ActivatedRoute) { } + @ViewChild('nzTreeComponent', { static: false }) nzTreeComponent!: NzTreeComponent; + // tree配置 + private _transformer = (node, level: number) => {//要给渲染节点传那些属性参数 + return { + expandable: !!node.children && node.children.length > 0, + name: node.name || node.Name, + level: level, + id: node.id || node.Id, + children:node.children, + isTemplate:node.isTemplate, + isNewElement:node.isNewElement, + isLook:node.isLook, + isLookPattern:node.isLookPattern || null + }; + } + treeControl = new FlatTreeControl(node => node.level, node => node.expandable); + + treeFlattener = new MatTreeFlattener(this._transformer, node => node.level, node => node.expandable, node => node.children); + dataSource = new MatTreeFlatDataSource(this.treeControl, this.treeFlattener); + hasChild = (_: number, node: any) => node.expandable; + + colors = ['#076eec','#4dd0e1','#00ee76','#ffff00','#eeb422', + '#FF6A6A','#ff0000','#ff6eb4','#00bfff','#54ff9f', + '#009688','#836fff','#ff8c00','#ee00ee','#ffa07a', + '#00C500','#00ffff','#6495ed','#ffdAb9','#AA00FF'] + selected = "1" //图标大小选择框 + + allBuildings //该单位所有建筑 + beforeOneCheckedBuilding:any; //当前点击选择的建筑 + checkedBuildingIndex:number = 0; //当前点击选择的建筑index + isEditPat:boolean = true; //当前是否是编辑模式 + + assetName:String//素材名称 + assetWidth:number//素材宽度 + assetHeight:number//素材高度 + sliderValue:number = 0//角度滑竿的值 + sliderValueThickness:number = 0//厚度滑竿的值 + isHighLight:boolean = false//是否高亮选择框 + PropertyInfos = [] //去除图片链接真正用于循环的内容 + imagesArrNum //素材属性图片数量上限 + imagesArr = [] //属性中的图片链接集合 + clickedIndex //点击图片时的索引值 + + //传入素材对象,设置右侧属性栏内容 + canvasAssetObj //传入的素材属性对象 + isImgNumCss = false //控制上传文件input显隐 + mySwiper:any //轮播图实例 + + gallery//viewerJs实例 + //设置属性框 + setAssetsProperty(obj){ + //初始化viewerJs实例 + setTimeout(() => { + obj.PropertyInfos.forEach(item => { + if(item.PropertyType == 4){ + this.gallery = new Viewer(document.getElementById('viewerjs'),{ + url: 'data-original' + }); + } + }) + }, 0); + + //从颜色中取出透明度 + let color = obj.Color + let strh = color.substring(color.length -2,color.length) + let opacity = Math.round(parseInt(strh,16)/255 * 100) + this.colorDivSliderValue = opacity + + this.isShowProperty = true + this.isShowAttribute = false + let _this = this + this.imagesArr = [] + this.imagesArrNum = "" + + this.canvasAssetObj = obj //将选中素材对象存到本地变量 + + this.assetName = obj.Name + this.assetWidth = obj.Width + this.assetHeight = obj.Height + this.sliderValue = obj.Angle + this.selectedcolor = obj.Color + this.PropertyInfos = obj.PropertyInfos + this.sliderValueThickness = obj.Thickness + this.PropertyInfos.forEach(item => { + if(item.PropertyType == 3){ //如果是图片链接类型 + this.imagesArr.push(item) + } + if(item.PropertyType == 4){//图片数值上线 + this.imagesArrNum = item.PropertyValue + } + }) + + //如果存在图片则加载轮播图 + if(this.imagesArr.length){ + setTimeout(() => { + this.mySwiper = new Swiper('.swiper-container',{ + loop: false, + // grabCursor: true, + // 如果需要前进后退按钮 + navigation: { + nextEl: '.swiper-button-next', + prevEl: '.swiper-button-prev', + }, + on:{ + click: function(){ + _this.clickedIndex = this.clickedIndex + }, + } + }); + }, 0); + } + //判断此时图片数量是否达到上限 + if(this.imagesArr.length < this.imagesArrNum){//如果不超出 + this.isImgNumCss = true + }else{ + this.isImgNumCss = false + } + } + pattern:boolean = true//默认为基本信息编辑 + + //基本信息编辑模式 + baseInfo(){ + if (!this.pattern) { + this.pattern = true + this.canvasData.gameMode = GameMode.BasicInformation + this.canvasData.selectPanelPoint = new DisposalNodeData(); + this.mateDeleteCustomize() + this.getAllLibrary() + this.checkedBuildingIndex = -1 + this.getSitePlan() //总平面图一层 + } + } + + //想定作业编辑模式 + wantWork(){ + if (this.pattern) { + this.pattern = false + this.canvasData.gameMode = GameMode.Assignment + this.getAllLibrary('plan') + this.getDisposalNode() + } + } + + //ngzorro tree 拖拽 + nzEvent(event: NzFormatEmitEvent): void { + if(this.isDrag){ + let parentId + if(this.pos == 0){ + parentId = event.node.key + }else{ + if(event.node.level == 0){ + parentId = null + }else{ + parentId = event.node.origin.parentId + } + } + + + let orders = {} + let originalData = JSON.parse(JSON.stringify( this.canvasData.allDisposalNode || [] )) //tree原始数据 + let targetNodeData = []//拖动移入节点的数据,用于遍历求出放在该数组的第几位 + + //找到需要重新排序的数组 + if(this.pos == 0){ + originalData.forEach(item => { + if(item.parentId == event.node.key){ + targetNodeData.push(item) + } + }) + }else{ + if(event.node.origin.parentId){//如果拖动目标为非一级节点 + originalData.forEach(item => { + if(item.parentId == event.node.origin.parentId){ + targetNodeData.push(item) + } + }) + }else{//如果拖动目标为一级节点 + originalData.forEach(item => { + if(!item.parentId){ + targetNodeData.push(item) + } + }) + } + } + + + let idArr = [] + targetNodeData.forEach(i => { + idArr.push(i.id) + }) + if(this.pos == 0 && event.node.origin.children.length == 1){ + let key = event.dragNode.key + orders[key] = 0 + parentId = event.node.key + }else{ + let array = [] + targetNodeData.forEach(item => { + if(item.id != event.dragNode.key){ //将拖动项先移除掉 + array.push(item) + } + }) + if(event.dragNode.isEnd[event.dragNode.isEnd.length - 1]){ //如果移入到最后一个 + array.push(event.dragNode.origin) + }else if(event.dragNode.isStart[event.dragNode.isStart.length - 1]){//如果移入到第一个 + array.unshift(event.dragNode.origin) + }else{//如果移入中间位置 + array.splice(event.node.origin.order, 0, event.dragNode.origin) + } + array.forEach((item,key) => { + orders[item.id] = key + }) + } + + let obj ={ + id : event.dragNode.origin.id, + parentId : parentId, + orders : orders + } + + this.http.put("/api/DisposalNodes/Sort",obj).subscribe(data => { + const config = new MatSnackBarConfig(); + config.verticalPosition = 'top'; + config.duration = 3000 + this.snackBar.open('排序成功','确定',config) + this.refurbishTreeData() + }) + } + } + + isDrag //是否可以拖动 + pos//放置位置 + beforeDrop = (arg: NzFormatBeforeDropEvent) => { + if(arg.dragNode.origin.isDataNode && arg.node.level === 0){//如果为数据节点则不允许拖到一级节点 + const config = new MatSnackBarConfig(); + config.verticalPosition = 'top'; + config.duration = 3000 + this.snackBar.open('数据节点不允许拖拽到一级节点','确定',config) + this.isDrag = false + return of(false); + }else if(!arg.dragNode.origin.isDataNode && arg.node.level === 2){ + const config = new MatSnackBarConfig(); + config.verticalPosition = 'top'; + config.duration = 3000 + this.snackBar.open('处置节点不允许拖拽到三级节点','确定',config) + this.isDrag = false + return of(false); + }else{ + this.isDrag = true + this.pos = arg.pos + return of(true) + } + } + //ngzorro tree 拖拽 + + //天气栏目 + weatherBtn = true + weatherBtnShow(){ + this.weatherBtn = !this.weatherBtn + } + weatherBtnHidden(){ + this.weatherBtn = !this.weatherBtn + } + + //底部切换按钮div + detailsAndattentBtn = true + //节点详情 + details(){ + this.detailsAndattentBtn = true + } + //注意事项 + attent(){ + this.detailsAndattentBtn = false + } + + //消防要素div边框高度调节 + firecategoriesDivMouseDown(e){ + document.onmousemove = (ev) => { + let bodyHeight = document.body.clientHeight //网页宽度 + let maxHeight = this.element.nativeElement.querySelector('#rightDiv').clientHeight - 35 //最大宽度 + if(bodyHeight - ev.clientY >= maxHeight){ + this.element.nativeElement.querySelector('#firecategories').style.height = maxHeight+ 'px' + this.element.nativeElement.querySelector('#property').style.height = 35+ 'px' + }else{ + this.element.nativeElement.querySelector('#firecategories').style.height = (bodyHeight - ev.clientY) + 'px' ; + this.element.nativeElement.querySelector('#property').style.height = (this.element.nativeElement.querySelector('#rightDiv').clientHeight - this.element.nativeElement.querySelector('#firecategories').clientHeight) + 'px' + } + } + document.onmouseup = () => { + document.onmousemove = null; + document.onmouseup = null; + } + } + + //左侧div边框宽度调节 + leftDivMouseDown(e){ + document.onmousemove = (ev) => { + let bodyWidth = document.body.clientWidth //网页宽度 + let maxWidth = bodyWidth - 260 - this.element.nativeElement.querySelector('#rightDiv').clientWidth //最大宽度 + if(ev.clientX - 240 >= maxWidth){ + this.element.nativeElement.querySelector('#leftDiv').style.width = maxWidth + 'px' + }else{ + this.element.nativeElement.querySelector('#leftDiv').style.width = ev.clientX - 260 + 'px'; + } + } + document.onmouseup = () => { + document.onmousemove = null; + document.onmouseup = null; + } + } + + //底部div高度调节 + bottomDivMouseDown(e){ + document.onmousemove = (ev) => { + let bodyHeight = document.body.clientHeight //网页高度 + let maxHeight = this.element.nativeElement.querySelector('#rightDiv').clientHeight //最大高度 + if(bodyHeight - ev.clientY >= maxHeight){ + this.element.nativeElement.querySelector('#bottomDiv').style.height = maxHeight + 'px' + }else{ + this.element.nativeElement.querySelector('#bottomDiv').style.height = (bodyHeight - ev.clientY) + 'px' ; + } + } + document.onmouseup = () => { + document.onmousemove = null; + document.onmouseup = null; + } + } + + //右侧div边框宽度调节 + rightDivMouseDown(e){ + document.onmousemove = (ev) => { + let bodyWidth = document.body.clientWidth //网页宽度 + let maxWidth = bodyWidth - 240 - this.element.nativeElement.querySelector('#leftDiv').clientWidth //最大宽度 + if(bodyWidth - ev.clientX >= maxWidth){ + this.element.nativeElement.querySelector('#rightDiv').style.width = maxWidth + 'px' + }else{ + this.element.nativeElement.querySelector('#rightDiv').style.width = bodyWidth - ev.clientX + 'px'; + } + } + document.onmouseup = () => { + document.onmousemove = null; + document.onmouseup = null; + } + } + + //放大图标 + iconScale(){ + let number = Number(this.selected) + this.canvas.setIconScale(number) + } + + //素材宽度输入框改变 + assetWidthIunput(){ + this.canvasAssetObj.Width = this.assetWidth + this.canvasData.isChange = true + this.canvas.refreshIcon(this.canvasAssetObj.Id) + } + + //素材高度输入框改变 + assetHeightIunput(){ + this.canvasAssetObj.Height = this.assetHeight + this.canvasData.isChange = true + this.canvas.refreshIcon(this.canvasAssetObj.Id) + } + + //素材角度输入框改变 + assetAngleIunput(){ + this.canvasAssetObj.Angle = this.sliderValue + this.canvasData.isChange = true + this.canvas.refreshIcon(this.canvasAssetObj.Id) + } + + //素材厚度输入框改变 + assetThicknessIunput(){ + this.canvasAssetObj.Thickness = this.sliderValueThickness + this.canvasData.isChange = true + this.canvas.refreshIcon(this.canvasAssetObj.Id) + } + + //素材是否高亮改变----->本地操作行为 + assetHighLightIunput(){ + + } + + //动态属性素材input框值改变 + assetInputChange(i,e){ + let index = this.canvasAssetObj.PropertyInfos.findIndex((item)=>{ + return i.PropertyName == item.PropertyName + }) + this.canvasAssetObj.PropertyInfos[index].PropertyValue = e.target.value + this.canvasData.isChange = true + this.canvas.refreshIcon(this.canvasAssetObj.Id) + } + + //动态属性素材布尔值框改变radio + assetRadioChange(i,boolean){ + let index = this.canvasAssetObj.PropertyInfos.findIndex((item)=>{ + return i.PropertyName == item.PropertyName + }) + this.canvasAssetObj.PropertyInfos[index].PropertyValue = boolean + this.canvasData.isChange = true + } + + colorIndex//默认素材颜色 + selectedcolor//点击选择的颜色 + //选择素材颜色 + selectcolor(item,key){ + //在当前透明度基础上改变颜色 + this.selectedcolor = item + this.selectedcolor.substring(this.selectedcolor.length-2) + this.canvasAssetObj.Color = this.selectedcolor + this.canvasData.isChange = true + this.canvas.refreshIcon(this.canvasAssetObj.Id) + } + //颜色选择滑竿的值 + colorDivSliderValue + colorDivSliderChange(){ + let colorOpacity = Math.round(255 * this.colorDivSliderValue * 0.01) + //根据滑竿值改变16进制颜色后两位 + function replacepos(text,start,stop,replacetext){ + let mystr = text.substring(0,stop-1)+replacetext+text.substring(stop+1); + return mystr; + } + this.selectedcolor = replacepos(this.selectedcolor,7,8,colorOpacity.toString(16)) + this.canvasAssetObj.Color = this.selectedcolor + this.canvasData.isChange = true + this.canvas.refreshIcon(this.canvasAssetObj.Id) + } + + //查看图片详情 + lookImg(){ + const dialogRef = this.dialog.open(ViewDetailsBuilding, {//调用open方法打开对话框并且携带参数过去 + data: {imagesArr:this.imagesArr,index:this.clickedIndex} + }); + dialogRef.afterClosed().subscribe(data=>{ }); + } + + //上传素材图片 + selectFile(e){ + let imgFile = e.target.files[0] || null //上传的文件 + this.startUploading(imgFile) + } + objectName:any //上传对象名 + startUploading (imgFile) { + let _this = this + let file = imgFile || null //获取上传的文件 + let fileSize = file.size || null //上传文件的总大小 + let shardSize = 5 * 1024 * 1024 //5MB一个分片 + let companyId = sessionStorage.getItem("companyId") + if (file && fileSize <= shardSize) { //上传文件<=5MB时 + let formData = new FormData() + formData.append("file",file) + this.http.post(`api/Objects/WebPlan2D/${companyId}`,formData).subscribe((data:any)=>{ + this.objectName = data.objectName + const config = new MatSnackBarConfig(); + config.verticalPosition = 'top'; + config.duration = 3000 + this.snackBar.open('上传成功','确定',config) + + //在原始素材对象和需要循环图片的对象中分别push最新上传的图片 + let imgObj = { + "Tag": null, + "Order": 0, + "Enabled": false, + "Visible": false, + "Required": false, + "RuleName": null, + "RuleValue": null, + "PhysicalUnit": null, + "PropertyName": "图片", + "PropertyType": 3, + "PropertyValue": "/api/Objects/WebPlan2D/" + this.objectName + } + + this.imagesArr.push(imgObj) + this.canvasAssetObj.PropertyInfos.push(imgObj) + + setTimeout(() => { + this.mySwiper = new Swiper('.swiper-container',{ + loop: false, + // grabCursor: true, + // 如果需要前进后退按钮 + navigation: { + nextEl: '.swiper-button-next', + prevEl: '.swiper-button-prev', + }, + on:{ + click: function(){ + _this.clickedIndex = this.clickedIndex + }, + } + }); + + this.mySwiper.slideTo(this.imagesArr.length - 1) + this.gallery.update() + }, 0); + + //判断上传素材属性图片是否超出数量 超出数量则隐藏input框 + if(this.imagesArr.length < this.imagesArrNum){//不超出input才会显示 + this.isImgNumCss = true + }else{ + this.isImgNumCss = false + } + + this.canvasData.isChange = true + }) + } else if (file && fileSize>shardSize) { //上传文件>5MB时,分块上传 + let config = new MatSnackBarConfig(); + config.verticalPosition = 'top'; + config.duration = 3000 + this.snackBar.open('上传图片文件不允许大于5mb','确定',config); + } + + } + + //不能上传图片提示 + imgNumBeyond(){ + const config = new MatSnackBarConfig(); + config.verticalPosition = 'top'; + config.duration = 3000 + this.snackBar.open('图片数量已达上限','确定',config); + } + + //删除素材属性图片 + deleteImg(){ + if(this.imagesArr.length == 0){ + const config = new MatSnackBarConfig(); + config.verticalPosition = 'top'; + config.duration = 3000 + this.snackBar.open('没有可删除的图片,请先上传','确定',config) + }else{ + // 在素材原始对象中将删除的图片去掉 + this.canvasAssetObj.PropertyInfos = [...this.canvasAssetObj.PropertyInfos.filter((item)=>{ + return item.PropertyValue != this.imagesArr[this.mySwiper.activeIndex].PropertyValue + })] + //在图片循环数组中将图片去掉 + this.imagesArr.splice(this.mySwiper.activeIndex, 1); + //更新swiper视图 + setTimeout(() => { + this.mySwiper.update(); + this.gallery.update() + }, 0); + + //将上传的input框显示出来 + this.isImgNumCss = true; + //清除图片缓存 + if((document.getElementById('inputimg'))){ + (document.getElementById('inputimg')).value = null //清空input框缓存 + } + + this.canvasData.isChange = true + } + } + + //动态属性方向select选择框 + direction(i,e){ + let index = this.canvasAssetObj.PropertyInfos.findIndex((item)=>{ + return i.PropertyName == item.PropertyName + }) + this.canvasAssetObj.PropertyInfos[index].PropertyValue = e.target.value + this.canvasData.isChange = true + } + + //动态属性供给区域select选择框 + supplyArea(i,e){ + let index = this.canvasAssetObj.PropertyInfos.findIndex((item)=>{ + return i.PropertyName == item.PropertyName + }) + this.canvasAssetObj.PropertyInfos[index].PropertyValue = e.target.value + this.canvasData.isChange = true + } + + //动态属性供给类型select选择框 + supplyType(i,e){ + let index = this.canvasAssetObj.PropertyInfos.findIndex((item)=>{ + return i.PropertyName == item.PropertyName + }) + this.canvasAssetObj.PropertyInfos[index].PropertyValue = e.target.value + this.canvasData.isChange = true + } + + + isSixShow = true + isSixbtn = true //控制想定作业编辑按钮 + isediticon = true //控制查看编辑模式的编辑模式小笔按钮 + ngOnInit(): void { + + if(this.router.url.indexOf("keyUnit/viewunitinfo") != -1 || this.router.url.indexOf("keyUnit/editplaninfo")!= -1){ + this.isSixbtn = false + } + + if(!this.isSixbtn && sessionStorage.getItem("six") == "edit"){ + this.isSixShow = true + } + if(!this.isSixbtn && sessionStorage.getItem("six") == "look"){ + this.isEditPattern = false + this.isediticon = false + } + //gis模块平面图 + if(this.router.url.indexOf("gis") != -1 && sessionStorage.getItem("gisplan") == "look"){ + this.isEditPattern = false + this.isediticon = false + this.canvasData.gameMode = GameMode.Assignment + } else { + this.getAllLibrary() //获取素材库 + } + + let that = this + window.setTimeout(()=>{ + document.getElementById("functionalDomainContent").oncontextmenu = function (event) { + // that.canvas.cancelPaint() + that.selectImageIndex = -1 + event.preventDefault(); + }; + }) + + this.canvasData.getMessage().subscribe((message: any)=>{ + if(message == "send a message"){ + this.refurbishTreeData() + } + }) + } + + + + ngAfterViewInit(): void { + //gis模块平面图 + if(this.router.url.indexOf("gis") == -1) { + this.getAllBuildings(true) //获取所有建筑 + } + // 监听canvas组件选中素材事件 + this.canvas.on("select",obj=>{ + //选中素材属性注入函数 + this.setAssetsProperty(obj.assetData) + }) + // 监听canvas组件取消选中素材事件 + this.canvas.on("deselect",obj=>{ + this.isShowProperty = false + }) + //监听数据变化后 + this.canvas.on('canvasDataChanged',()=>{ + // 收到数据表示共享数据发生变化 + this.renovateTreeData(false) + }); + } + + copyAssetData:any //存储用于复制的素材 + //复制素材 + copyAsset(){ + this.canvas.copy() + } + //粘贴素材 + pasteAsset(){ + let companyId = sessionStorage.getItem("companyId") + let buildingId = this.beforeOneCheckedBuilding.id + let floorId = this.selectingSitePlan.id + this.canvas.paste(companyId,buildingId,floorId) + this.renovateTreeData(false) + } + + basicInfo:boolean = true //基本信息名称显隐 + wantToWork:boolean = true //想定作业名称显隐 + //点击基本信息名称 + basicInfoClick(){ + this.basicInfo = !this.basicInfo + this.canvas.setNameVisible(this.basicInfo,0) + } + + //点击想定作业名称 + wantToWorkClick(){ + this.wantToWork = !this.wantToWork + this.canvas.setNameVisible(this.wantToWork,1) + } + + isEditPattern:boolean = true //是否为编辑模式 + //进入编辑模式 + editpat(){ + let config = new MatSnackBarConfig(); + config.verticalPosition = 'top'; + config.duration = 3000 + this.snackBar.open('进入编辑模式','确定',config); + this.isEditPattern = true + } + + //进入查看模式 + lookpat(){ + let config = new MatSnackBarConfig(); + config.verticalPosition = 'top'; + config.duration = 3000 + this.snackBar.open('进入查看模式','确定',config); + this.isEditPattern = false + } + + //保存平面图 + saveNum :any = [] + saveSite(){ + //更新用于统计的数据 + this.canvasData.updateBuildingData() + + + if (this.selectingSitePlan && this.selectingSitePlan.id) { + //打开遮罩层 + this.maskLayerService.sendMessage(true) + this.saveNum = [] + let SitePlanData = JSON.parse(JSON.stringify(this.canvasData.originaleveryStoreyData)); + SitePlanData.data = JSON.stringify(SitePlanData.data) + let CompanyData = JSON.parse(JSON.stringify(this.canvasData.originalcompanyBuildingData)); + CompanyData.data = JSON.stringify(CompanyData.data) + + let object = this.canvasData.originalcompanyBuildingData.data + let adjoinArr = [] //毗邻数组 + + if(this.pattern){//如果是基本信息编辑模式 + for (const key in object) { + if (object[key].Name == "毗邻") {//如果是相同楼层,则筛选出毗邻 + + object[key].PropertyInfos.forEach(element => { + if(element.PropertyName == "方向"){ + adjoinArr.push(element.PropertyValue) + } + }); + } + } + + if((new Set(adjoinArr)).size != adjoinArr.length){ + this.maskLayerService.sendMessage(false) + let config = new MatSnackBarConfig(); + config.verticalPosition = 'top'; + config.duration = 3000 + this.snackBar.open('保存失败,毗邻存在相同方向','确定',config); + return false + }else{ + //如果是单位 总平面图 + if(this.checkedBuildingIndex==-1){ + // console.log(111,SitePlanData) + //保存平面图数据 + this.http.post("/api/SitePlanData",SitePlanData,{ + params:{ + companyId:this.params.companyId + } + }).subscribe(data => { + this.saveNum.push("1") + if(this.saveNum.length == 5){ + this.maskLayerService.sendMessage(false) + this.canvasData.isChange = false + let config = new MatSnackBarConfig(); + config.verticalPosition = 'top'; + config.duration = 3000 + this.snackBar.open('保存成功','确定',config); + this.tabbarService.sendMessage('changeScore'); + } + },err=>{ + this.maskLayerService.sendMessage(false) + let config = new MatSnackBarConfig(); + config.verticalPosition = 'top'; + config.duration = 3000 + this.canvasData.isChange = true + this.snackBar.open('平面图数据保存失败','确定',config); + }) + + //保存建筑数据 + this.http.post("/api/CompanyData",CompanyData,{ + params:{ + companyId:this.params.companyId + } + }).subscribe(data => { + this.saveNum.push("1") + if(this.saveNum.length == 5){ + this.maskLayerService.sendMessage(false) + this.canvasData.isChange = false + let config = new MatSnackBarConfig(); + config.verticalPosition = 'top'; + config.duration = 3000 + this.snackBar.open('保存成功','确定',config); + this.tabbarService.sendMessage('changeScore'); + } + },err=>{ + this.maskLayerService.sendMessage(false) + let config = new MatSnackBarConfig(); + config.verticalPosition = 'top'; + config.duration = 3000 + this.canvasData.isChange = true + this.snackBar.open('单位数据保存失败','确定',config); + }) + + //批量保存单位毗邻 + let CompanyAdjoins = this.canvasData.getCompanyAdjoinInfo() + this.http.post("/api/CompanyAdjoins/Batch",CompanyAdjoins,{ + params:{ + companyId:this.params.companyId + } + }).subscribe(data => { + this.saveNum.push("1") + if(this.saveNum.length == 5){ + this.maskLayerService.sendMessage(false) + this.canvasData.isChange = false + let config = new MatSnackBarConfig(); + config.verticalPosition = 'top'; + config.duration = 3000 + this.snackBar.open('保存成功','确定',config); + this.tabbarService.sendMessage('changeScore'); + } + },err=>{ + this.maskLayerService.sendMessage(false) + let config = new MatSnackBarConfig(); + config.verticalPosition = 'top'; + config.duration = 3000 + this.canvasData.isChange = true + if(err == 'infos 有重复方向!'){ + this.snackBar.open('单位毗邻同步失败,存在相同方向','确定',config); + }else{ + this.snackBar.open('单位毗邻同步失败','确定',config); + } + }) + + //批量保存单位重点部位 + let CompanyImportantLocations = this.canvasData.getCompanyImportantLocations() + this.http.post("/api/CompanyImportantLocations/Batch",CompanyImportantLocations,{ + params:{ + companyId:this.params.companyId + } + }).subscribe(data => { + this.saveNum.push("1") + if(this.saveNum.length == 5){ + this.maskLayerService.sendMessage(false) + this.canvasData.isChange = false + let config = new MatSnackBarConfig(); + config.verticalPosition = 'top'; + config.duration = 3000 + this.snackBar.open('保存成功','确定',config); + this.tabbarService.sendMessage('changeScore'); + } + },err=>{ + this.maskLayerService.sendMessage(false) + let config = new MatSnackBarConfig(); + config.verticalPosition = 'top'; + config.duration = 3000 + this.canvasData.isChange = true + this.snackBar.open('单位重点部位同步失败','确定',config); + }) + + //批量保存单位消防设施素材 + let CompanyFacilityAssets = this.canvasData.getAllCompanyFacilityAssetInfo() + this.http.post("/api/CompanyFacilityAssets/Batch",CompanyFacilityAssets,{ + params:{ + companyId:this.params.companyId + } + }).subscribe(data => { + this.saveNum.push("1") + if(this.saveNum.length == 5){ + this.maskLayerService.sendMessage(false) + this.maskLayerService.sendMessage(false) + this.canvasData.isChange = false + let config = new MatSnackBarConfig(); + config.verticalPosition = 'top'; + config.duration = 3000 + this.snackBar.open('保存成功','确定',config); + this.tabbarService.sendMessage('changeScore'); + } + },err=>{ + this.maskLayerService.sendMessage(false) + let config = new MatSnackBarConfig(); + config.verticalPosition = 'top'; + config.duration = 3000 + this.canvasData.isChange = true + this.snackBar.open('单位消防设施素材同步失败','确定',config); + }) + + }else{ //如果是建筑 + + //建筑平面图数据 + this.http.post("/api/BuildingAreaData",SitePlanData,{ + params:{ + companyId:this.params.companyId + } + }).subscribe(data => { + this.saveNum.push("1") + if(this.saveNum.length == 5){ + this.maskLayerService.sendMessage(false) + this.maskLayerService.sendMessage(false) + this.canvasData.isChange = false + let config = new MatSnackBarConfig(); + config.verticalPosition = 'top'; + config.duration = 3000 + this.snackBar.open('保存成功','确定',config); + this.tabbarService.sendMessage('changeScore'); + } + },err=>{ + this.maskLayerService.sendMessage(false) + let config = new MatSnackBarConfig(); + config.verticalPosition = 'top'; + config.duration = 3000 + this.canvasData.isChange = true + this.snackBar.open('平面图数据保存失败','确定',config); + }) + + //建筑数据 + this.http.post("/api/BuildingData",CompanyData,{ + params:{ + companyId:this.params.companyId + } + }).subscribe(data => { + this.saveNum.push("1") + if(this.saveNum.length == 5){ + this.maskLayerService.sendMessage(false) + this.canvasData.isChange = false + this.maskLayerService.sendMessage(false) + let config = new MatSnackBarConfig(); + config.verticalPosition = 'top'; + config.duration = 3000 + this.snackBar.open('保存成功','确定',config); + this.tabbarService.sendMessage('changeScore'); + } + },err=>{ + this.maskLayerService.sendMessage(false) + let config = new MatSnackBarConfig(); + config.verticalPosition = 'top'; + config.duration = 3000 + this.canvasData.isChange = true + this.snackBar.open('单位数据保存失败','确定',config); + }) + + //批量保存建筑毗邻 + let buildingAdjoins = this.canvasData.getBuildingAdjoinInfo() + this.http.post(`/api/BuildingAdjoins/Batch?companyId=${this.params.companyId}&buildingId=${this.canvasData.selectStorey.buildingId}`,buildingAdjoins).subscribe(data => { + this.saveNum.push("1") + if(this.saveNum.length == 5){ + this.maskLayerService.sendMessage(false) + this.canvasData.isChange = false + let config = new MatSnackBarConfig(); + config.verticalPosition = 'top'; + config.duration = 3000 + this.snackBar.open('保存成功','确定',config); + this.tabbarService.sendMessage('changeScore'); + } + },err=>{ + this.maskLayerService.sendMessage(false) + let config = new MatSnackBarConfig(); + config.verticalPosition = 'top'; + config.duration = 3000 + this.canvasData.isChange = true + if(err == 'infos 有重复方向!'){ + this.snackBar.open('建筑毗邻同步失败,存在相同方向','确定',config); + }else{ + this.snackBar.open('建筑毗邻同步失败','确定',config); + } + }) + + //批量保存建筑重点部位 + let buildingImportantLocations = this.canvasData.getBuildingImportantLocations() + this.http.post(`/api/BuildingImportantLocations/Batch?companyId=${this.params.companyId}&buildingId=${this.canvasData.selectStorey.buildingId}`,buildingImportantLocations).subscribe(data => { + this.saveNum.push("1") + if(this.saveNum.length == 5){ + this.maskLayerService.sendMessage(false) + this.canvasData.isChange = false + let config = new MatSnackBarConfig(); + config.verticalPosition = 'top'; + config.duration = 3000 + this.snackBar.open('保存成功','确定',config); + this.tabbarService.sendMessage('changeScore'); + } + },err=>{ + this.maskLayerService.sendMessage(false) + let config = new MatSnackBarConfig(); + config.verticalPosition = 'top'; + config.duration = 3000 + this.canvasData.isChange = true + this.snackBar.open('建筑重点部位同步失败','确定',config); + }) + + //批量保存建筑消防设施素材 + let buildingFacilityAssets = this.canvasData.getAllBuildingFacilityAssetInfo() + this.http.post(`/api/BuildingFacilityAssets/Batch?companyId=${this.params.companyId}&buildingId=${this.canvasData.selectStorey.buildingId}`,buildingFacilityAssets).subscribe(data => { + this.saveNum.push("1") + if(this.saveNum.length == 5){ + this.maskLayerService.sendMessage(false) + this.canvasData.isChange = false + let config = new MatSnackBarConfig(); + config.verticalPosition = 'top'; + config.duration = 3000 + this.snackBar.open('保存成功','确定',config); + this.tabbarService.sendMessage('changeScore'); + } + },err=>{ + this.maskLayerService.sendMessage(false) + let config = new MatSnackBarConfig(); + config.verticalPosition = 'top'; + config.duration = 3000 + this.canvasData.isChange = true + this.snackBar.open('建筑消防设施素材同步失败','确定',config); + }) + + } + } + }else{//如果是想定作业编辑模式 + const dialogRef = this.dialog.open(saveOneDialogBuilding, { + data: {allDisposalNode: this.canvasData.allDisposalNode, + selectedBuildingData:this.beforeOneCheckedBuilding, + selectedSiteData:this.selectingSitePlan, + siteOrbuilding:this.checkedBuildingIndex, + disasterId: this.allFirePlan[0].id || '' + } + }); + + dialogRef.afterClosed().subscribe(result => { + // console.log('The dialog was closed'); + }); + } + + } else { //if + const config = new MatSnackBarConfig(); + config.verticalPosition = 'top'; + config.duration = 3000 + this.snackBar.open('暂无楼层数据','确定',config); + } + } + + //获得所有的建筑物 + getAllBuildings(init:boolean = false){ + this.http.get("/api/Buildings",{ params:{companyId : this.params.companyId}}).subscribe((data:any)=>{ + this.allBuildings = data + if (init) { + this.checkedBuildingIndex = 0 + data && data.length? this.beforeOneCheckedBuilding = data[0] : this.beforeOneCheckedBuilding = {id:null, buildingTypes:[{id:null}]} + this.getBuildingSitePlan(this.beforeOneCheckedBuilding) + } //if + }) + } + + //拖拽tree + drop(e){ + // console.log(1111,e) + } + drop2(e){ + // console.log(222,e) + } + + //创建建筑 + createBuilding(){ + let data = { + allBuildings:this.allBuildings, + companyId :this.params.companyId + } + let dialogRef = this.dialog.open(CreateBuildingBuilding,{data}); + dialogRef.afterClosed().subscribe(data=>{ + if (data == "创建成功") { + const config = new MatSnackBarConfig(); + config.verticalPosition = 'top'; + config.duration = 3000 + this.snackBar.open('创建成功','确定',config); + this.allBuildings.length? this.getAllBuildings() : this.getAllBuildings(true) + }else if (data == "创建失败") { + const config = new MatSnackBarConfig(); + config.verticalPosition = 'top'; + config.duration = 3000 + this.snackBar.open('创建失败','确定',config); + } + }); + } + + //选择建筑 + checkedBuilding(item,index){ + if (this.checkedBuildingIndex!=index) { + + if (this.canvasData.isChange) { //true 数据被改动 + let isTrue = confirm('是否保存当前编辑数据') + if (isTrue) { //先保存数据 在切换 + let isSuccess = this.saveSite()//true的时候 先保存数据 + if (isSuccess != false) { + this.beforeOneCheckedBuilding = item + this.checkedBuildingIndex = index + if (index==-1) { //总平面图数据 + this.getSitePlan() + } else { //建筑楼层/区域数据 + this.getBuildingSitePlan(item) + } + } + } else { + this.beforeOneCheckedBuilding = item + this.checkedBuildingIndex = index + if (index==-1) { //总平面图数据 + this.getSitePlan() + } else { //建筑楼层/区域数据 + this.getBuildingSitePlan(item) + } + } + } else { //flase 数据未被改动 + this.beforeOneCheckedBuilding = item + this.checkedBuildingIndex = index + if (index==-1) { //总平面图数据 + this.getSitePlan() + } else { //建筑楼层/区域数据 + this.getBuildingSitePlan(item) + } + } //if + + } //if + } + + //编辑建筑 + editBuilding(e,item){ + e.stopPropagation(); + let dialogRef = this.dialog.open(EditBuildingBuilding,{data: {item:item}}); + dialogRef.afterClosed().subscribe(data=>{ + if (data == "修改成功") { + const config = new MatSnackBarConfig(); + config.verticalPosition = 'top'; + config.duration = 3000 + this.snackBar.open('修改成功','确定',config); + this.getAllBuildings() + }else if (data == "修改失败") { + const config = new MatSnackBarConfig(); + config.verticalPosition = 'top'; + config.duration = 3000 + this.snackBar.open('修改失败','确定',config); + } + }); + } + + //删除建筑 + deleteBuilding(e,item){ + e.stopPropagation(); + if(confirm("是否删除该建筑") == true){ + let isHave = this.canvasData.allDisposalNode.find(items=>{ return items.buildingId === item.id }) + if (isHave == undefined) { + this.http.delete(`/api/Buildings/${item.id}`).subscribe(data=>{ + const config = new MatSnackBarConfig(); + config.verticalPosition = 'top'; + config.duration = 3000 + this.snackBar.open('删除成功','确定',config); + this.getAllBuildings(true) + },err=>{ + const config = new MatSnackBarConfig(); + config.verticalPosition = 'top'; + config.duration = 3000 + this.snackBar.open('删除失败','确定',config); + this.getAllBuildings(true) + }) + } else { //建筑 含有数据节点时 + const config = new MatSnackBarConfig(); + config.verticalPosition = 'top'; + config.duration = 3000 + this.snackBar.open('含有数据节点的建筑不允许删除','确定',config); + } + } + } + + storeyData //将建筑素材和当前楼层素材合二为一 + + //处理 tree 数据结构 + handleTreeData (storeyData) { + + this.storeyData = storeyData + let data = this.allFireElements //所有消防要素模板 + let treeData = [] //tree型 处理完成后的数据 + data.forEach(element => { + element.isTemplate = true //添加模板标识 + element.isLook = true //添加是否可见标识 + element.name!='其他'? element.children = [] : null + + if(storeyData){ + for(let key in storeyData.data){ + storeyData.data[key].isLookPattern = true + if(element.id == storeyData.data[key].FireElementId){ + storeyData.data[key].isTemplate = false + storeyData.data[key].isLook = true + + element.isNewElement = true //该节点children是否存在新添加的真实素材 标识 + + //定义查看模式下能看到的元素 + element.isLookPattern = true + if(element.parentId){ + data.forEach(i => { + if(i.id == element.parentId){ + i.isLookPattern = true + } + }) + } + // + + element.children.push(storeyData.data[key]) + } + } + } + data.forEach(item => { if (item.parentId == element.id) {element.children.push(item)} }); + }); + data.forEach(element => { + if (!element.parentId) { treeData.push(element) } + }); + this.dataSource.data = treeData + this.treeControl.expandAll() + + } + + //点击树节点 + clickTreeNode(node){ + if(this.canvasData.originalcompanyBuildingData.data[node.id]){ + this.setAssetsProperty(this.canvasData.originalcompanyBuildingData.data[node.id]) + }else if(this.canvasData.originaleveryStoreyData.data[node.id]){ + this.setAssetsProperty(this.canvasData.originaleveryStoreyData.data[node.id]) + } + + //canvas上的素材高亮 + let iconHighLightArr:any = [] + if(node.isTemplate){//如果是模板,则开始向下找 + node.children.forEach(item => { + if(item.isTemplate){//如果子节点依旧是模板,则继续开始向下找 + item.children.forEach(i => { + iconHighLightArr.push(i.Id) + }) + }else{ + iconHighLightArr.push(item.Id) + } + }) + }else{ + iconHighLightArr.push(node.id) + } + this.canvas.setHighlight(iconHighLightArr) + } + + //点击数节点的显示隐藏icon + clickLookItem(node){ + + //修改真实素材islook属性 + for(let key in this.storeyData.data){ + if(key == node.id){ + this.storeyData.data[key].isLook = !this.storeyData.data[key].isLook + } + } + + //所有消防要素模板变化islook值 + if(node.isTemplate){ + this.allFireElements.forEach(item=>{ + if(item.id == node.id || item.name == "其他"){ + item.isLook = !item.isLook + } + }) + } + + + //子节点跟随父节点的islook变化 +   if(node.children && node.children.length != 0){ +      node.children.forEach(item=>{ +        item.isLook = !node.isLook  +        if(item.children && item.children.length != 0){ +          item.children.forEach(i=>{ +            i.isLook =  !node.isLook  +          }) +        } +      }) +     } + + + const nodes = this.treeControl.dataNodes; + const expandNodes = []; + nodes.forEach((item) => { + if(item.expandable && this.treeControl.isExpanded(item)){ + expandNodes.push(item.id); + } + }); + + this.dataSource.data = [...this.dataSource.data] + + let newNodes = this.treeControl.dataNodes; + newNodes = newNodes.filter(n => { + return expandNodes.indexOf(n.id) >= 0; + }); + newNodes.forEach(item => { + this.treeControl.expand(item); + }); + + //canvas上的素材显隐 + let iconVisibleArr:any = [] + if(node.isTemplate){//如果是模板,则开始向下找 + node.children.forEach(item => { + if(item.isTemplate){//如果子节点依旧是模板,则继续开始向下找 + item.children.forEach(i => { + iconVisibleArr.push(i.Id) + }) + }else{ + iconVisibleArr.push(item.Id) + } + }) + }else{ + iconVisibleArr.push(node.id) + } + this.canvas.setIconVisible(iconVisibleArr,!node.isLook) + } + + //计算 可视区域内宽度, 是否缩放背景图 + backGroundScale () { + // let that = this + // let dad = this.element.nativeElement.querySelector('.functionalDomainContent').clientWidth + // let dadHeight = this.element.nativeElement.querySelector('.functionalDomainContent').clientHeight + // let left = this.element.nativeElement.querySelector('.functionalDomainLeft').clientWidth + // let right = this.element.nativeElement.querySelector('.functionalDomainRight').clientWidth + // let imgWidth = dad - left - right//可视区域内 宽度 + // let img = new Image() + // img.src = this.selectingSitePlan.imageUrl; + // img.onload = function(){ + // if (img.height > dadHeight && img.width > imgWidth) { + // let width = imgWidth/img.width + // let height = dadHeight/img.height + // that.canvas.setBackgroundScale((width>height? height : width)-0.005) + // return + // } else if (img.height > dadHeight) { + // that.canvas.setBackgroundScale((dadHeight/img.height)-0.005) + // return + // } else if (img.width > imgWidth) { + // that.canvas.setBackgroundScale((imgWidth/img.width)-0.005) + // return + // } + // }; + } + + //封装 刷新 tree 数据 + async renovateTreeData (isRefresh:boolean = true) { + this.allFireElements[this.allFireElements.length-1].children = [] + isRefresh? await this.canvas.refresh() : null + this.canvas.setNameVisible(this.basicInfo,0) + this.canvas.setNameVisible(this.wantToWork,1) + isRefresh? this.canvasData.isChange = false : null //服务中 数据是否改动 改为false + isRefresh? this.isShowProperty = true : null + isRefresh? this.isShowAttribute = true : null + !this.pattern? this.mateFireForce() : null //刷新 建筑楼层 火源/力量图标 + + let beforeOneId = this.selectingSitePlan.id || '' //当前 选中 平面图 楼层/区域 id + let companyBuildingData = JSON.parse(JSON.stringify( this.canvasData.originalcompanyBuildingData || {} )) // 当前 单位/建筑 数据 + let storeyData = JSON.parse(JSON.stringify( this.canvasData.originaleveryStoreyData || {} )) //当前 楼层 数据 + + for(let key in companyBuildingData.data){ + if (companyBuildingData.data[key].FloorId === beforeOneId) { //处理 单位/建筑 数据是否归于当前楼层下 + storeyData.data[key] = companyBuildingData.data[key] + } + } + for(let key in storeyData.data){ //筛选数据 没有匹配全部放入到 其他 数组 + let noMatch = this.allFireElements.find( every=> every.id===storeyData.data[key].FireElementId ) + if (!noMatch) { + this.allFireElements[this.allFireElements.length-1].children.push(storeyData.data[key]) + } + } + this.handleTreeData(storeyData) //处理tree数据结构 + } + + + + //陈鹏飞↓↓↓ + //陈鹏飞↓↓↓ + //陈鹏飞↓↓↓ + params = {companyId: sessionStorage.getItem('companyId')} + // params = {companyId: this.route.snapshot.queryParams.id} + allFireElements:any = []; //当前 单位/建筑 下的消防要素 + + isShowAttribute:boolean = true; //属性栏 是否显示 默认数据 + isShowProperty:boolean = false //属性栏 是否有东西 + + toggleExpandPanel:boolean = false; //左侧可展开面板展开或关闭 + toggleExpandPanelRight:boolean = false; //右侧可展开面板展开或关闭 + togglePlane:boolean = true; //可展开面板平面图 显隐 + toggleMaterialBank:boolean = false; //可展开面板素材库 显隐 + toggleHandlePlans:boolean = true; //可展开面板处置预案 显隐 + //可展开面板展开或关闭 + toggle () { + this.toggleExpandPanel = !this.toggleExpandPanel + } + //可展开面板展开或关闭 + toggle2 () { + this.toggleExpandPanelRight = !this.toggleExpandPanelRight + } + //可展开面板 平面图 展开或关闭 + togglePlanarGraph () { + this.togglePlane = !this.togglePlane + } + //可展开面板 素材库 展开或关闭 + toggleMaterial () { + this.toggleMaterialBank = !this.toggleMaterialBank + } + //可展开面板 处置预案 展开或关闭 + toggleHandlePlan () { + this.toggleHandlePlans = !this.toggleHandlePlans + } + + sitePlanData:any = []; //总平面图 楼层/区域 数据 + selectingSitePlan:any; //选中的 平面图 楼层/区域 + selectSitePlanIndex:number; //选中的 平面图 楼层/区域 index + + //获取总平面图 + getSitePlan () { + let fireData = this.getFireElements(sessionStorage.getItem('buildingTypeId')) //获取单位下 消防要素 + let planData = this.getSitePlanCompanyData() //获取 单位 数据 + this.http.get('/api/SitePlans',{params:this.params}).subscribe(data=>{ + this.sitePlanData = data + this.selectingSitePlan = this.sitePlanData[0] || {} + this.canvasData.selectStorey = this.sitePlanData[0] || {} //服务中 存一份数据 + this.selectSitePlanIndex = 0 + + Promise.all([fireData,planData]).then((res)=>{ + this.getSitePlanStorey(this.selectingSitePlan) //获取 平面图 楼层数据 + }) + + }) + } + + //获取建筑 楼层/区域 + getBuildingSitePlan (item) { + let params = { buildingId: item.id } + let fireData = this.getFireElements(item.buildingTypes[0].id || '') //获取建筑下 消防要素 + let planData = this.getBuildingData(params) //获取 建筑 数据 + this.http.get('/api/BuildingAreas',{params}).subscribe(data=>{ + this.sitePlanData = data + this.selectingSitePlan = this.sitePlanData[0] || {} + this.canvasData.selectStorey = this.sitePlanData[0] || {} //服务中 存一份数据 + this.selectSitePlanIndex = 0 + + Promise.all([fireData,planData]).then((res)=>{ + this.getBuildingStorey(this.selectingSitePlan) //获取 建筑 楼层数据 + }) + + }) + } + + //根据单位类型获得所有的消防要素 + getFireElements (e) { + let params = {ids:e} + return new Promise ((resolve,reject)=>{ + this.http.get('/api/Companies/FireElements',{params}).subscribe((data:any)=>{ + this.allFireElements = data //所有消防要素 + let other = { + children: [], + computed: true, + id: '', + name: '其他', + order: 999, + parentId: null, + tag: "INPUT", + isLookPattern : true + } + this.allFireElements.push(other) + resolve('success') + }) + }) + } + + //获取 单位 数据 + getSitePlanCompanyData () { + return new Promise ((resolve,reject)=>{ + this.http.get('/api/CompanyData',{params:this.params}).subscribe((data:any)=>{ + this.canvasData.originalcompanyBuildingData = data || {} // 单位原数据 + this.canvasData.originalcompanyBuildingData.data? this.canvasData.originalcompanyBuildingData.data = JSON.parse(this.canvasData.originalcompanyBuildingData.data) : this.canvasData.originalcompanyBuildingData.data = {} + this.canvasData.originalcompanyBuildingData.version = "2.0" + this.canvasData.originalcompanyBuildingData.companyId? null : this.canvasData.originalcompanyBuildingData.companyId = sessionStorage.getItem('companyId') + resolve('success') + }) + }) + } + + //获取 平面图 楼层数据 + getSitePlanStorey (e) { + let params = {sitePlanId: e.id} + this.http.get(`/api/SitePlanData`,{params}).subscribe((data:any)=>{ + this.canvasData.originaleveryStoreyData = data || {} // 楼层原数据 + this.canvasData.originaleveryStoreyData.data? this.canvasData.originaleveryStoreyData.data = JSON.parse(this.canvasData.originaleveryStoreyData.data) : this.canvasData.originaleveryStoreyData.data = {} + this.canvasData.originaleveryStoreyData.version = "2.0" + this.canvasData.originaleveryStoreyData.sitePlanId? null : this.canvasData.originaleveryStoreyData.sitePlanId = e.id || null + this.renovateTreeData() + }) + } + + //获取 建筑 数据 + getBuildingData (e) { + return new Promise ((resolve,reject)=>{ + this.http.get(`/api/BuildingData`,{params:e}).subscribe((data:any)=>{ + this.canvasData.originalcompanyBuildingData = data || {} // 建筑原数据 + this.canvasData.originalcompanyBuildingData.data? this.canvasData.originalcompanyBuildingData.data = JSON.parse(this.canvasData.originalcompanyBuildingData.data) : this.canvasData.originalcompanyBuildingData.data = {} + this.canvasData.originalcompanyBuildingData.version = "2.0" + this.canvasData.originalcompanyBuildingData.buildingId? null : this.canvasData.originalcompanyBuildingData.buildingId = e.buildingId + resolve('success') + }) + }) + } + + //获取 建筑 楼层数据 + getBuildingStorey (e) { + let params = {buildingAreaId: e.id} + this.http.get(`/api/BuildingAreaData`,{params}).subscribe((data:any)=>{ + this.canvasData.originaleveryStoreyData = data || {} // 楼层原数据 + this.canvasData.originaleveryStoreyData.data? this.canvasData.originaleveryStoreyData.data = JSON.parse(this.canvasData.originaleveryStoreyData.data) : this.canvasData.originaleveryStoreyData.data = {} + this.canvasData.originaleveryStoreyData.version = "2.0" + this.canvasData.originaleveryStoreyData.buildingAreaId? null : this.canvasData.originaleveryStoreyData.buildingAreaId = e.id || null + this.renovateTreeData() + }) + } + + //点击选中 平面图 楼层/区域 时 + selectSitePlan (item,index) { + if (this.selectSitePlanIndex != index) { + this.canvasData.selectPanelPoint = new DisposalNodeData(); + if (this.canvasData.isChange) { //true 数据被改动 + let isTrue = confirm('是否保存当前编辑数据') + if (isTrue) { //先保存数据 在切换 + let isSuccess = this.saveSite()//true的时候 先保存数据 + if (isSuccess != false) { + this.selectingSitePlan = item + this.selectSitePlanIndex = index + this.canvasData.selectStorey = item //服务中 存一份数据 + if (this.checkedBuildingIndex==-1) { //总平面图时 + this.getSitePlanStorey(item) //获取 平面图 楼层数据 + } else { //楼层/区域时 + this.getBuildingStorey(item) //获取 建筑 楼层数据 + } + } + } else { //不保存数据 直接切换 + this.selectingSitePlan = item + this.selectSitePlanIndex = index + this.canvasData.selectStorey = item //服务中 存一份数据 + if (this.checkedBuildingIndex==-1) { //总平面图时 + this.getSitePlanStorey(item) //获取 平面图 楼层数据 + this.getSitePlanCompanyData() + } else { //楼层/区域时 + this.getBuildingStorey(item) //获取 建筑 楼层数据 + let params = { buildingId: this.beforeOneCheckedBuilding.id } + this.getBuildingData(params) + } + } + + } else { //false 数据没被改动 + this.selectingSitePlan = item + this.selectSitePlanIndex = index + this.canvasData.selectStorey = item //服务中 存一份数据 + if (this.checkedBuildingIndex==-1) { //总平面图时 + this.getSitePlanStorey(item) //获取 平面图 楼层数据 + } else { //楼层/区域时 + this.getBuildingStorey(item) //获取 建筑 楼层数据 + } + } //if + + } + } + + //新增平面图 楼层/区域 + foundPanel (e) { + e.stopPropagation() + let data = { + isBuilding: this.checkedBuildingIndex==-1? false:true, + Panel: this.beforeOneCheckedBuilding, + order: this.sitePlanData.length? this.sitePlanData[this.sitePlanData.length-1].order+1:0, + } + let dialogRef = this.dialog.open(leftFunctionalDomainBuildingComponent,{data}); + dialogRef.afterClosed().subscribe(data=>{ + if (data =='总平面图') { + this.renovateSitePlan() + } else if (data =='建筑') { + this.renovateBuilding() + } + }) + } + + //编辑平面图 楼层/区域 + editPlaneData (e) { + let data = { + isBuilding: this.checkedBuildingIndex==-1? false:true, + Panel: this.beforeOneCheckedBuilding, + buildingData: e, + } + let dialogRef = this.dialog.open(editPlaneFigureBuildingComponent,{data}); + dialogRef.afterClosed().subscribe(data=>{ + if (data =='总平面图') { + this.renovateSitePlan() + } else if (data =='建筑') { + this.renovateBuilding() + } + }) + } + + //平面图 楼层/区域 上移 + moveUp (item,index) { + if (index != 0) { + let replaceIndex = this.sitePlanData[index].order + this.sitePlanData[index].order = this.sitePlanData[index-1].order + this.sitePlanData[index-1].order = replaceIndex + if (this.checkedBuildingIndex==-1) { //总平面图 + this.http.put(`/api/SitePlans/${this.sitePlanData[index-1].id}`,this.sitePlanData[index-1]).subscribe(data=>{ + this.http.put(`/api/SitePlans/${this.sitePlanData[index].id}`,this.sitePlanData[index]).subscribe(data=>{ + this.selectSitePlanIndex = this.selectSitePlanIndex-1 + this.renovateSitePlan() + }) + }) + } else { //楼层/区域 + this.http.put(`/api/BuildingAreas/${this.sitePlanData[index-1].id}`,this.sitePlanData[index-1],{params:this.params}).subscribe(data=>{ + this.http.put(`/api/BuildingAreas/${this.sitePlanData[index].id}`,this.sitePlanData[index],{params:this.params}).subscribe(data=>{ + this.selectSitePlanIndex = this.selectSitePlanIndex-1 + this.renovateBuilding() + }) + }) + } + + } //if index + } + + //平面图 楼层/区域 下移 + moveDown (item,index) { + if (index != this.sitePlanData.length-1) { + let replaceIndex = this.sitePlanData[index].order + this.sitePlanData[index].order = this.sitePlanData[index+1].order + this.sitePlanData[index+1].order = replaceIndex + if (this.checkedBuildingIndex==-1) { //总平面图 + this.http.put(`/api/SitePlans/${this.sitePlanData[index+1].id}`,this.sitePlanData[index+1]).subscribe(data=>{ + this.http.put(`/api/SitePlans/${this.sitePlanData[index].id}`,this.sitePlanData[index]).subscribe(data=>{ + this.selectSitePlanIndex = this.selectSitePlanIndex+1 + this.renovateSitePlan() + }) + }) + } else { //楼层/区域 + this.http.put(`/api/BuildingAreas/${this.sitePlanData[index+1].id}`,this.sitePlanData[index+1],{params:this.params}).subscribe(data=>{ + this.http.put(`/api/BuildingAreas/${this.sitePlanData[index].id}`,this.sitePlanData[index],{params:this.params}).subscribe(data=>{ + this.selectSitePlanIndex = this.selectSitePlanIndex+1 + this.renovateBuilding() + }) + }) + } + + } //if index + } + + //旋转底图 + revolveImg (item) { + item.imageAngle==270? item.imageAngle = 0 : item.imageAngle = item.imageAngle+90 + if (this.checkedBuildingIndex==-1) { //总平面图 + this.http.put(`/api/SitePlans/${item.id}`,item).subscribe(data=>{ + let isSuccess = this.renovateSitePlan() + isSuccess.then(res=>{ + this.canvas.refreshBackgroundImage() + }) + }) + } else { //楼层/区域 + this.http.put(`/api/BuildingAreas/${item.id}`,item,{params:this.params}).subscribe(data=>{ + let isSuccess = this.renovateBuilding() + isSuccess.then(res=>{ + this.canvas.refreshBackgroundImage() + }) + }) + } + + } + + //删除 平面图 楼层/区域 + deletePlaneData (item) { + const isDelete = confirm('您确定要删除吗'); + if (isDelete) { + if (this.checkedBuildingIndex==-1) { //总平面图 + let isHave = this.canvasData.allDisposalNode.find(items=>{ return items.sitePlanId === item.id }) + if (isHave == undefined) { + this.http.delete(`/api/SitePlans/${item.id}`).subscribe(data=>{ + this.deleteShareData(item,-1) + }) + } else { + const config = new MatSnackBarConfig(); + config.verticalPosition = 'top'; + config.duration = 3000 + this.snackBar.open('含有数据节点的楼层不允许删除','确定',config); + } + } else { //楼层/区域 + let isHave = this.canvasData.allDisposalNode.find(items=>{ return items.buildingAreaId === item.id }) + if (isHave == undefined) { + this.http.delete(`/api/BuildingAreas/${item.id}`).subscribe(data=>{ + this.deleteShareData(item,1) + }) + } else { + const config = new MatSnackBarConfig(); + config.verticalPosition = 'top'; + config.duration = 3000 + this.snackBar.open('含有数据节点的楼层不允许删除','确定',config); + } + } + } + } + + //删除当前 单位/建筑的 共享数据中 已删除data + deleteShareData (e,isCompany) { + this.sitePlanData.forEach((element,index) => { + if (element.id===e.id) { + this.sitePlanData.splice(index,1) + return + } + }); + let data = this.canvasData.originalcompanyBuildingData; + for(let key in data.data){ + if (data.data[key].FloorId === e.id) { //处理 单位/建筑 数据是否归于当前楼层下 + delete data.data[key] + } + } + let newData = JSON.parse(JSON.stringify(this.canvasData.originalcompanyBuildingData)); + newData.data = JSON.stringify(newData.data) // 转换JSON 数据格式 + this.selectingSitePlan = this.sitePlanData[0] || {} + this.canvasData.selectStorey = this.sitePlanData[0] || {} //服务中 存一份数据 + this.selectSitePlanIndex = 0 + this.canvasData.isChange = false + if (isCompany===-1) { + this.http.post("/api/CompanyData",newData).subscribe(data => {}) + this.getSitePlanStorey(this.selectingSitePlan) //获取 平面图 楼层数据 + } else { + this.http.post("/api/BuildingData",newData,{params:this.params}).subscribe(data => {}) + this.getBuildingStorey(this.selectingSitePlan) //获取 建筑 楼层数据 + } + } + + //复制图层 平面图 楼层/区域 + duplicateLayer (item) { + let paramsData = JSON.parse(JSON.stringify( this.canvasData.originaleveryStoreyData.data || {} )) + Object.keys(paramsData).forEach((key)=>{ + if (key != '图例') { + let ID = ObjectID.default.generate() + paramsData[key].Id = ID + paramsData[ID] = paramsData[key] + delete paramsData[key] + } + }) //图标Id重新赋值 + if (this.checkedBuildingIndex==-1) { //总平面图 + item.id = "" + item.modifiedTime = new Date() + item.name = item.name + '(副本)' + item.order = this.sitePlanData[this.sitePlanData.length-1].order+1 + this.http.post('/api/SitePlans',item).subscribe((data:any)=>{ + let newData = { + version: "2.0", + id: "", + data: JSON.stringify( paramsData ) || null, + sitePlanId: data.id + } + this.http.post('/api/SitePlanData',newData,{params:this.params}).subscribe(data=>{ + this.renovateSitePlan() + }) + + }) + } else { //楼层/区域 + item.id = "" + item.modifiedTime = new Date() + item.name = item.name + '(副本)' + item.order = this.sitePlanData[this.sitePlanData.length-1].order+1 + this.http.post('/api/BuildingAreas',item,{params:this.params}).subscribe((data:any)=>{ + let newData = { + version: "2.0", + id: "", + data: JSON.stringify( paramsData ) || null, + buildingAreaId: data.id + } + this.http.post('/api/BuildingAreaData',newData,{params:this.params}).subscribe(data=>{ + this.renovateBuilding() + }) + + }) + } + } + + //平面图 楼层/区域 替换底图 + replaceBaseMap (e,item) { + e.stopPropagation(); + let file = e.target.files[0] || null //获取上传的文件 + let fileSize = file.size || null //上传文件的总大小 + let maxSize = 5 * 1024 * 1024 //5MB一个分片 + + if (file && fileSize<=maxSize) { //上传文件<=5MB时 + let formData = new FormData() + formData.append("file",file) + this.http.post(`/api/Objects/WebPlan2D/${sessionStorage.getItem('companyId')}`,formData).subscribe((data:any)=>{ + this.renovateBaseMap(data.objectName,item) + }) + } else { + const config = new MatSnackBarConfig(); + config.verticalPosition = 'top'; + config.duration = 3000 + this.snackBar.open('上传底图需小于5MB','确定',config); + } + } + + //封装 替换底图 function + renovateBaseMap (e,item) { + item.imageUrl = '/api/Objects/WebPlan2D/' + e + if (this.checkedBuildingIndex ==-1) { //总平面图 + this.http.put(`/api/SitePlans/${item.id}`,item).subscribe(data=>{ + let isSuccess = this.renovateSitePlan() + isSuccess.then(res=>{ + this.canvas.refreshBackgroundImage() + }) + const config = new MatSnackBarConfig(); + config.verticalPosition = 'top'; + config.duration = 3000 + this.snackBar.open('上传底图成功','确定',config); + }) + } else { //楼层/区域 + this.http.put(`/api/BuildingAreas/${item.id}`,item,{params:this.params}).subscribe(data=>{ + let isSuccess = this.renovateBuilding() + isSuccess.then(res=>{ + this.canvas.refreshBackgroundImage() + }) + const config = new MatSnackBarConfig(); + config.verticalPosition = 'top'; + config.duration = 3000 + this.snackBar.open('上传底图成功','确定',config); + }) + } + } + + //封装 刷新总平面图 数据 + renovateSitePlan () { + return new Promise ((resolve,reject)=>{ + this.http.get('/api/SitePlans',{params:this.params}).subscribe(data=>{ + this.sitePlanData = data + this.selectingSitePlan = this.sitePlanData[this.selectSitePlanIndex] + this.canvasData.selectStorey = this.sitePlanData[this.selectSitePlanIndex] //服务中 存一份数据 + this.canvasData.originaleveryStoreyData.sitePlanId? null : this.canvasData.originaleveryStoreyData.sitePlanId = this.selectingSitePlan.id || null + const config = new MatSnackBarConfig(); + config.verticalPosition = 'top'; + config.duration = 3000 + this.snackBar.open('数据更新成功','确定',config); + resolve('success') + }) + }) + } + + //封装 刷新 楼层/区域 数据 + renovateBuilding () { + let params = { + buildingId: this.beforeOneCheckedBuilding.id + } + return new Promise ((resolve,reject)=>{ + this.http.get('/api/BuildingAreas',{params}).subscribe(data=>{ + this.sitePlanData = data + this.selectingSitePlan = this.sitePlanData[this.selectSitePlanIndex] + this.canvasData.selectStorey = this.sitePlanData[this.selectSitePlanIndex] //服务中 存一份数据 + this.canvasData.originaleveryStoreyData.buildingAreaId? null : this.canvasData.originaleveryStoreyData.buildingAreaId = this.selectingSitePlan.id || null + const config = new MatSnackBarConfig(); + config.verticalPosition = 'top'; + config.duration = 3000 + this.snackBar.open('数据更新成功','确定',config); + resolve('success') + }) + }) + } + + allLibrary:any = []; //所有素材库 + 素材 + selectLibrary:any; //选中的素材库 + selectImage:any; //选中的素材库图片 + selectImageIndex:number; //选中的素材库图片index + + //获取素材库 + getAllLibrary (type:string='input') { + this.http.get(`/api/AssetLibraries?tag=${type}`).subscribe((data:any)=>{ + data.forEach(element => { + element.images = [] + }); + this.allLibrary = data + this.selectImageIndex = -1 + }) + } + + //素材库展开面板展开时 + opened (e) { + if (!e.images.length) { //当前素材库没加载素材时 + this.http.get(`/api/Assets?libraryId=${e.id}`).subscribe((data:any)=>{ + e.images = data + }) + } + } + + //点击选中素材库图片时 + selectImg (item,items,index) { + this.selectLibrary = item.name + this.selectImage = items + this.selectImageIndex = index + this.canvasData.selectTemplateData = items + this.canvas.beginPaint() + } + + + + //处置预案 + allFirePlan:any = []; //所有灾情 + selectDisposalNode:string = ''; //当前点击tree节点 css选中样式 + + //获取所有灾情 + getAllFirePlan () { + let params = {componentId: sessionStorage.getItem('planId')} + this.http.get('/api/Disasters',{params:params}).subscribe((data:any)=>{ + if (!data.length) { //该 单位没有灾情时 + let msg = { + name: '灾情', + modifiedTime: new Date(), + planComponentId: sessionStorage.getItem('planId') + } + this.http.post('/api/Disasters',msg).subscribe(data=>{ + this.allFirePlan.push(data) + let params = {disasterId: this.allFirePlan[0].id || ''} + this.http.get('/api/DisposalNodes',{params:params}).subscribe(data=>{ //所有处置节点 + this.canvasData.allDisposalNode = data + }) + }) + } else { //单位 有灾情时 + this.allFirePlan = data + let params = {disasterId: this.allFirePlan[0].id || ''} + this.http.get('/api/DisposalNodes',{params:params}).subscribe(data=>{ //所有处置节点 + this.canvasData.allDisposalNode = data + }) + } + }) + } + + //获取所有处置节点 + getDisposalNode () { + this.selectDisposalNode = '' + let params = {disasterId: this.allFirePlan[0].id || ''} + this.http.get('/api/DisasterData/Markers',{params:params}).subscribe(data=>{ //灾情标签信息 + this.canvasData.allNodeMarkers = data + this.mateFireForce() + }) + this.http.get('/api/DisposalNodes',{params:params}).subscribe(data=>{ //处置节点 + this.canvasData.allDisposalNode = data + this.handleHybridTree() + }) + } + + treeData:any = []; //渲染tree处理完成数据 + defaultExpandedKeys:any = []; //首次渲染 tree展开状态 + //处理 节点 Tree数据 + handleHybridTree () { + this.defaultExpandedKeys = [] + let treeData = [] + let data = JSON.parse(JSON.stringify( this.canvasData.allDisposalNode || [] )) + data.forEach(element => { + this.defaultExpandedKeys.push(element.id) + element.title = element.name //name + element.key = element.id //id + element.children = [] //children + if (element.sitePlanId || element.buildingAreaId) { //是数据节点 + element.isLeaf = true + element.isDataNode = true + } else { //不是数据节点 + element.isLeaf = false + element.isDataNode = false + } + data.forEach(item=>{ + item.parentId === element.id? element.children.push(item) : null + }) + }); + data.forEach(element=>{ + !element.parentId? treeData.push(element) : null + }) + this.treeData = [...treeData] + this.defaultExpandedKeys = [...this.defaultExpandedKeys] + } + + //刷新 treeData 保存已展开节点 + refurbishTreeData () { + this.defaultExpandedKeys = [] + let params = {disasterId: this.allFirePlan[0].id || ''} + this.http.get('/api/DisposalNodes',{params:params}).subscribe(nodeData=>{ //处置节点 + this.canvasData.allDisposalNode = nodeData + let oldTreeData = this.nzTreeComponent.getExpandedNodeList() + oldTreeData.forEach(item=>{ + this.defaultExpandedKeys.push(item.key) + }) + let treeData = [] + let data = JSON.parse(JSON.stringify( this.canvasData.allDisposalNode || [] )) + data.forEach(element => { + element.title = element.name //name + element.key = element.id //id + element.children = [] //children + if (element.sitePlanId || element.buildingAreaId) { //是数据节点 + element.isLeaf = true + element.isDataNode = true + } else { //不是数据节点 + element.isLeaf = false + element.isDataNode = false + } + data.forEach(item=>{ + item.parentId === element.id? element.children.push(item) : null + }) + }); + data.forEach(element=>{ + !element.parentId? treeData.push(element) : null + }) + this.treeData = [...treeData] + this.defaultExpandedKeys = [...this.defaultExpandedKeys] + }) + } + + sitePlanIcon = {fire:0,force:0} // 总平面图 火源/力量 图标 是否展示 + + //刷新 建筑楼层 匹配 火源/力量 图标 + mateFireForce () { + let data = this.canvasData.allNodeMarkers.markers || {} + for(let key in data){ //遍历 火/力量 图标 + this.sitePlanData.forEach(element => { //楼层 + if (element.id==key) { // 相匹配时 + data[key].fireCount != 0? element.fire=1 : element.fire=0 + data[key].forceCount != 0? element.force=1 : element.force=0 + } + }); + this.allBuildings.forEach(element => { //建筑 + if (element.id==key) { // 相匹配时 + data[key].fireCount != 0? element.fire=1 : element.fire=0 + data[key].forceCount != 0? element.force=1 : element.force=0 + } + }); + if (this.params.companyId==key) { //总平面图时 + data[key].fireCount != 0? this.sitePlanIcon.fire=1 : this.sitePlanIcon.fire=0 + data[key].forceCount != 0? this.sitePlanIcon.force=1 : this.sitePlanIcon.force=0 + } + } + + let buildingMSG = this.canvasData.allNodeMarkers.highlightMarkers || {} + for (let key in buildingMSG) { + if (key === this.canvasData.selectPanelPoint.DisposalNodeId) { + for (let keys in buildingMSG[key]) { + this.sitePlanData.forEach(element => { //楼层 + if (element.id === keys) { + buildingMSG[key][keys].fireCount != 0? element.fire=2 : null + buildingMSG[key][keys].forceCount != 0? element.force=2 : null + } + }); + this.allBuildings.forEach(element => { //建筑 + if (element.id === keys) { // 相匹配时 + buildingMSG[key][keys].fireCount != 0? element.fire=2 : null + buildingMSG[key][keys].forceCount != 0? element.force=2 : null + } + }); + if (this.params.companyId === keys) { //总平面图时 + buildingMSG[key][keys].fireCount != 0? this.sitePlanIcon.fire=2 : null + buildingMSG[key][keys].forceCount != 0? this.sitePlanIcon.force=2 : null + } + } + } + } + } + + // 切换 基本信息时 刷新 删除 建筑楼层 自定义属性 + mateDeleteCustomize () { + this.canvasData.selectPanelPointBaseData = {description: '', notes: '', weather: '', airTemperature: '', windDirection: '', windScale: ''} + this.defaultExpandedKeys = [] + this.sitePlanIcon = {fire:0,force:0} + this.sitePlanData.forEach(element => { //楼层 + delete element.fire + delete element.force + }); + this.allBuildings.forEach(element => { //建筑 + delete element.fire + delete element.force + }); + } + + //计算差异 + countValue (e) { + e.stopPropagation() + let params = {disasterId: this.allFirePlan[0].id || ''} + this.http.get('/api/DisasterData/Diffs',{params:params}).subscribe(data=>{ + this.canvasData.allNodeMarkers = data + this.mateFireForce() + const config = new MatSnackBarConfig(); + config.verticalPosition = 'top'; + config.duration = 3000 + this.snackBar.open('计算差异完成','确定',config); + }) + } + + //新建 处置预案 节点 + addPanelPoint (e,item,treeData) { + e.stopPropagation() + let order + if (item) { + item.children.length? order = item.children[item.children.length-1].order+1 : order = 0 + } else { + treeData.length? order = treeData[treeData.length-1].order+1 : order = 0 + } + let data = { + name: '', + level: item? 1 : 0, + order: order, + description: '', + disasterId: this.allFirePlan[0].id || '', + parentId: item? item.id : null, + planComponentId: sessionStorage.getItem('planId') || '', + } + let dialogRef = this.dialog.open(addDisposalNodeBuildingComponent,{data}); + dialogRef.afterClosed().subscribe(data=>{ + if (data) { this.refurbishTreeData() } + }) + } + + //编辑 处置预案 节点 + editPanelPoint (e,item) { + e.stopPropagation() + let data = item.origin + let dialogRef = this.dialog.open(editDisposalNodeBuildingComponent,{data}); + dialogRef.afterClosed().subscribe(data=>{ + if (data) { + item.title = data + this.canvasData.allDisposalNode.forEach(element => { element.id === item.key? element.name=data : null }); + } + }) + } + + //复制 处置预案 节点 + copyPanelPoint (e,item,treeData) { + e.stopPropagation() + if (confirm(`确定要复制 ${item.title} ?`)) { + let params = {id: item.origin.id} + let order + if (item.level==0) { + treeData.length? order = treeData[treeData.length-1].order+1 : order = 0 + } else { + let parent = item.getParentNode() //获取父节点 + parent.origin.children.length? order = parent.origin.children[parent.origin.children.length-1].order+1 : order = 0 + } + let data = { + name: item.title + '(副本)', + level: item.level, + order: order, + description: '', + disasterId: item.origin.disasterId || '', + parentId: item.origin.parentId || null, + planComponentId: item.origin.planComponentId || '', + } + this.http.post('/api/DisposalNodes/Clone',data,{params:params}).subscribe(data=>{ + this.refurbishTreeData() + }) + } //isTrue + } + + //删除 处置预案 节点 + deletePanelPoint (e,item) { + e.stopPropagation() + if (confirm(`确定要删除 ${item.name} ?`)) { + this.http.delete(`/api/DisposalNodes/${item.id}`).subscribe(data=>{ + this.refurbishTreeData() + }) + } + } + + //点击 处置Tree节点 + selectanelPoint (e) { + if (!e.buildingAreaId && !e.sitePlanId) { //当前节点 不是 数据节点 时 + let msg = this.canvasData.findDisposalNode(e.id) + this.canvasData.selectPanelPointBaseData = msg + this.selectDisposalNode == msg.id? this.selectDisposalNode = '' : this.selectDisposalNode = msg.id //选中 节点 + + } else if (e.buildingAreaId || e.sitePlanId) { //当前节点 是 数据节点 时 + let msg = this.canvasData.findDisposalNode(e.parentId) + this.canvasData.selectPanelPointBaseData = msg + this.selectDisposalNode = e.parentId //选中 节点 + + if (this.canvasData.selectPanelPoint.DisposalNodeId != e.id) { //选择节点 不是当前节点时 + let params = {nodeId: e.id} + let parameter = { //查询 节点 对应 建筑/楼层 index,id + buildingIndex: e.sitePlanId? -1 : this.allBuildings.findIndex(item=>{ return item.id===e.buildingId }), //总平面图/建筑 index + storeyId: e.sitePlanId? e.sitePlanId : e.buildingAreaId, //楼层id + } + this.http.get('/api/DisposalNodeData',{params:params}).subscribe(data=>{ + this.canvasData.selectPanelPoint = this.canvasData.deserialize(JSON.stringify(data || new DisposalNodeData())) //选择 当前 节点 + this.canvasData.selectPanelPoint.Data = this.canvasData.deserialize(this.canvasData.selectPanelPoint.Data) + this.seekPanelPoint(parameter) + }) + } //if + + } //else if + } + + //查找 数据节点 对应 建筑/楼层 + seekPanelPoint (paramsData) { + this.checkedBuildingIndex = paramsData.buildingIndex + if (paramsData.buildingIndex ==-1) { //总平面图时 + this.beforeOneCheckedBuilding={name:"总平面图"} + let fireData = this.getFireElements(sessionStorage.getItem('buildingTypeId')) //获取单位下 消防要素 + let planData = this.getSitePlanCompanyData() //获取 单位 数据 + this.http.get('/api/SitePlans',{params:this.params}).subscribe(data=>{ + this.sitePlanData = data + let index = this.sitePlanData.findIndex(item=>{ return item.id===paramsData.storeyId }) + this.selectingSitePlan = this.sitePlanData[index] || {} + this.canvasData.selectStorey = this.sitePlanData[index] || {} //服务中 存一份数据 + this.selectSitePlanIndex = index + + Promise.all([fireData,planData]).then((res)=>{ + this.getSitePlanStorey(this.selectingSitePlan) //获取 平面图 楼层数据 + }) + }) //get + } else { //建筑时 + this.beforeOneCheckedBuilding=this.allBuildings[paramsData.buildingIndex] + let params = { buildingId: this.beforeOneCheckedBuilding.id } + let fireData = this.getFireElements(this.beforeOneCheckedBuilding.buildingTypes[0].id || '') //获取建筑下 消防要素 + let planData = this.getBuildingData(params) //获取 建筑 数据 + this.http.get('/api/BuildingAreas',{params}).subscribe(data=>{ + this.sitePlanData = data + let index = this.sitePlanData.findIndex(item=>{ return item.id===paramsData.storeyId }) + this.selectingSitePlan = this.sitePlanData[index] || {} + this.canvasData.selectStorey = this.sitePlanData[index] || {} //服务中 存一份数据 + this.selectSitePlanIndex = index + + Promise.all([fireData,planData]).then((res)=>{ + this.getBuildingStorey(this.selectingSitePlan) //获取 建筑 楼层数据 + }) + }) //get + } + } + + + +} + + + +//创建建筑 +@Component({ + selector: 'app-createBuilding-building', + templateUrl: './createBuilding.html', + styleUrls: ['./collection-tools.component.scss'] +}) +export class CreateBuildingBuilding { + + constructor(private http:HttpClient,public dialog: MatDialog,public dialogRef: MatDialogRef,@Inject(MAT_DIALOG_DATA) public data) { } + + allBuildingType:any//所有的建筑类型 + selected:any; //选中的建筑 + ngOnInit(): void { + this.getAllBuildingType() + } + + //获得所有单位类型 + getAllBuildingType(){ + this.http.get("/api/BuildingTypes/Simple").subscribe(data=>{ + this.allBuildingType = data + }) + } + + //创建建筑功能分区 + onSubmit (e) { + let companyId = sessionStorage.getItem("companyId") + let lastBuildingOrder = this.data.allBuildings.length != 0 ? this.data.allBuildings[this.data.allBuildings.length - 1].order + 1 : 0 + let data = + { + id: "", + name: e.propertyName, + order: lastBuildingOrder , + enabled: true, + companyId: companyId, + buildingTypes: [ + { + id: e.buildingId, + name: "" + } + ] + } + this.http.post("/api/Buildings",data,{ + params:{ + companyId : this.data.companyId + } + }).subscribe(data=>{ + this.dialogRef.close("创建成功"); + },err=>{ + this.dialogRef.close("创建失败"); + }) + } +} + +//编辑建筑 +@Component({ + selector: 'app-editBuilding-building', + templateUrl: './editBuilding.html', + styleUrls: ['./collection-tools.component.scss'] +}) +export class EditBuildingBuilding { + + constructor(private http:HttpClient,public dialog: MatDialog,public dialogRef: MatDialogRef,@Inject(MAT_DIALOG_DATA) public data) { } + + defaultName:String = this.data.item.name//默认建筑名称 + defaultBuildingType:String = this.data.item.buildingTypes[0].id//默认建筑类型 + allBuildingType:any//所有的建筑类型 + + ngOnInit(): void { + this.getAllBuildingType() + } + + getAllBuildingType(){ + this.http.get("/api/BuildingTypes/Simple").subscribe(data=>{ + this.allBuildingType = data + }) + } + + //编辑建筑信息 + onSubmit (e) { + let companyId = sessionStorage.getItem("companyId") + let data = + { + id: this.data.item.id, + name: e.propertyName, + order: this.data.item.order, + enabled: true, + companyId: companyId, + buildingTypes: [ + { + id: e.buildingId, + name: "" + } + ] + } + this.http.put(`/api/Buildings/${this.data.item.id}`,data,{ + params:{ + id:this.data.item.id, + companyId:companyId + } + }).subscribe(data=>{ + this.dialogRef.close("修改成功"); + },err=>{ + this.dialogRef.close("修改失败"); + }) + } +} + +//查看图片大图 +@Component({ + selector: 'viewdetails-building', + templateUrl: './viewdetails.html', + styleUrls: ['./collection-tools.component.scss'] +}) +export class ViewDetailsBuilding { + // myControl = new FormControl(); + //注入MatDialogRef,可以用来关闭对话框 + //要访问对话框组件中的数据,必须使用MAT_DIALOG_DATA注入令牌 + constructor(private http: HttpClient,public dialogRef: MatDialogRef,@Inject(MAT_DIALOG_DATA) public data,private element: ElementRef) {} + imagesArr = this.data.imagesArr + onNoClick(): void { + this.dialogRef.close(); + } + ngOnInit(): void { + setTimeout(() => { + var mySwiper = new Swiper('.swiper-container',{ + loop: false, + initialSlide :this.data.index,//默认索引 + // 如果需要前进后退按钮 + navigation: { + nextEl: '.swiper-button-next', + prevEl: '.swiper-button-prev', + } + //其他设置 + }); + }, 0); + } + closeDialog(){ + this.dialogRef.close(); + } + count = 10 + zoomimg(e) { + if(this.count != 1 || e.wheelDelta >= 120){ + if(e.wheelDelta >= 120){ + this.count++ + }else{ + this.count-- + } + } + e.srcElement.style.zoom = this.count + '0%' + e.srcElement.style.maxWidth = null + e.srcElement.style.maxHeight = null + } + +} diff --git a/src/app/ui/collection-tools-building/createBuilding.html b/src/app/ui/collection-tools-building/createBuilding.html new file mode 100644 index 0000000..16fdd7b --- /dev/null +++ b/src/app/ui/collection-tools-building/createBuilding.html @@ -0,0 +1,28 @@ +
新增建筑
+
+
+ +
+ + + +
+
+ + + + {{item.name}} + + + +
+
+ + +
+
+
\ No newline at end of file diff --git a/src/app/ui/collection-tools-building/editBuilding.html b/src/app/ui/collection-tools-building/editBuilding.html new file mode 100644 index 0000000..433316d --- /dev/null +++ b/src/app/ui/collection-tools-building/editBuilding.html @@ -0,0 +1,23 @@ +
编辑建筑
+
+
+
+ + + +
+
+ + + + {{item.name}} + + + +
+
+ + +
+
+
\ No newline at end of file diff --git a/src/app/ui/collection-tools-building/editDisposalNode.html b/src/app/ui/collection-tools-building/editDisposalNode.html new file mode 100644 index 0000000..40b2270 --- /dev/null +++ b/src/app/ui/collection-tools-building/editDisposalNode.html @@ -0,0 +1,23 @@ +
+
+ +
+ +
+ +
+ + + +
+ +
+ + +
+ +
+ +
\ No newline at end of file diff --git a/src/app/ui/collection-tools-building/editPlaneFigure.html b/src/app/ui/collection-tools-building/editPlaneFigure.html new file mode 100644 index 0000000..a0f8016 --- /dev/null +++ b/src/app/ui/collection-tools-building/editPlaneFigure.html @@ -0,0 +1,39 @@ +
+ +
+ + +
+ +
+ +
+ + + +
+ +
+ 是否为避难层 +
+ +
+ + + +
+ +
+ +
+ +
+ + +
+ +
+ +
\ No newline at end of file diff --git a/src/app/ui/collection-tools-building/leftFunctionalDomain.ts b/src/app/ui/collection-tools-building/leftFunctionalDomain.ts new file mode 100644 index 0000000..e60ca32 --- /dev/null +++ b/src/app/ui/collection-tools-building/leftFunctionalDomain.ts @@ -0,0 +1,180 @@ +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'; + +@Component({ + selector: 'app-leftFunctionalDomain-building', + templateUrl: './addPlaneFigure.html', + styleUrls: ['./panel.scss'] +}) +export class leftFunctionalDomainBuildingComponent implements OnInit { + + constructor( + private http:HttpClient, + public dialog: MatDialog, + public snackBar: MatSnackBar, + public dialogRef: MatDialogRef, + @Inject(MAT_DIALOG_DATA) public data) { } + + ngOnInit(): void { + + } + + params = {companyId: sessionStorage.getItem('companyId')} + checked:boolean = false;//是否为避难层 + + //提交表单创建平面图 + onSubmit (e) { + if (!this.data.isBuilding) { //总平面图 创建平面图 + let data = { + companyId: sessionStorage.getItem('companyId'), + name: e.name, + order: this.data.order, + area:e.area, + details:e.details, + enabled: true, + modifiedTime: new Date(), + } + 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:e.area, + details:e.details, + enabled: true, + modifiedTime: new Date(), + } + this.http.post('/api/BuildingAreas',data,{params:this.params}).subscribe(data=>{ + this.dialogRef.close('建筑'); + }) + } + } + + + +} + +//编辑平面图 楼层/区域 +@Component({ + selector: 'app-editPlaneFigure-building', + templateUrl: './editPlaneFigure.html', + styleUrls: ['./panel.scss'] +}) +export class editPlaneFigureBuildingComponent implements OnInit { + + constructor(private http:HttpClient,public dialog: MatDialog,public snackBar: MatSnackBar,public dialogRef: MatDialogRef,@Inject(MAT_DIALOG_DATA) public data) { } + + 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 || '' + } + + params = {companyId: sessionStorage.getItem('companyId')} + name:any; //name + checked:boolean = false;//是否为避难层 + area:number; //面积 + details:string; //详情 + + //提交表单修改平面图 + onSubmit (e) { + if (!this.data.isBuilding) { //总平面图 修改平面图 + let data = { + companyId: sessionStorage.getItem('companyId'), + id: this.data.buildingData.id, + name: e.name, + cadUrl: this.data.buildingData.cadUrl, + imageUrl: this.data.buildingData.imageUrl, + imageAngle: this.data.buildingData.imageAngle, + order: this.data.buildingData.order, + 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.dialogRef.close('总平面图'); + }) + } else { //建筑 修改楼层/区域 + let data = { + isRefugeStorey: e.isRefugeStorey, + buildingId: this.data.Panel.id, + id: this.data.buildingData.id, + name: e.name, + cadUrl: this.data.buildingData.cadUrl, + imageUrl: this.data.buildingData.imageUrl, + imageAngle: this.data.buildingData.imageAngle, + order: this.data.buildingData.order, + 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.dialogRef.close('建筑'); + }) + } + } + + + +} + + + +//创建 处置预案 节点 +@Component({ + selector: 'app-addDisposalNode-building', + templateUrl: './addDisposalNode.html', + styleUrls: ['./panel.scss'] +}) +export class addDisposalNodeBuildingComponent implements OnInit { + + constructor(private http:HttpClient,public dialog: MatDialog,public snackBar: MatSnackBar,public dialogRef: MatDialogRef,@Inject(MAT_DIALOG_DATA) public data) { } + + ngOnInit(): void { + } + + //提交表单 + onSubmit (e) { + this.data.name = e.name + this.http.post('/api/DisposalNodes',this.data).subscribe(data=>{ + this.dialogRef.close('success'); + }) + } + +} + + + +//编辑 处置预案 节点 +@Component({ + selector: 'app-editDisposalNode-building', + templateUrl: './editDisposalNode.html', + styleUrls: ['./panel.scss'] +}) +export class editDisposalNodeBuildingComponent implements OnInit { + + constructor(private http:HttpClient,public dialog: MatDialog,public snackBar: MatSnackBar,public dialogRef: MatDialogRef,@Inject(MAT_DIALOG_DATA) public data) { } + + ngOnInit(): void { + this.nodeName = JSON.parse(JSON.stringify( this.data.name || '' )) + } + nodeName:string; + + //提交表单 + onSubmit (e) { + this.data.name = e.name + this.http.put(`/api/DisposalNodes/${this.data.id}`,this.data).subscribe(data=>{ + this.dialogRef.close(e.name); + }) + } + +} \ No newline at end of file diff --git a/src/app/ui/collection-tools-building/panel.scss b/src/app/ui/collection-tools-building/panel.scss new file mode 100644 index 0000000..f0ae073 --- /dev/null +++ b/src/app/ui/collection-tools-building/panel.scss @@ -0,0 +1,291 @@ +.matIcons { + color: #8E909F; +} + + + +//平面图 素材库 公共样式 头部 +.planarGraphHeader{ + height: 35px; + min-height: 35px; + cursor: pointer; + display: flex; + flex-direction: row; + align-items: center; + padding: 0 24px; + border-radius: 5px; + font-family: Roboto, "Helvetica Neue", sans-serif; + font-size: 15px; + font-weight: 400; + color: #000; + background: linear-gradient(to top,#cdced1,#FFF); +} +//平面图头部字体图标样式 +.hover { + width: 18px; + height: 18px; + margin-left: 90px; + border: 1px solid #999; + border-radius: 3px; + .mat-icon {font-size: 18px; color: #999;} +} +.hover:hover { + background-color: #4DA5FA; + .mat-icon {color: #fff;} +} + +//平面图 +.sitePlanContent { + position: relative; + width: 100%; + height: 35px; + line-height: 35px; + box-sizing: border-box; + padding: 0 10px 0 25px; + .mat-icon { + font-size: 20px; + } +} + +//火源/力量 图标 +.fireForce { + display: block; + float: right; + margin: 8px 5px 0 0; + width: 40px; + height: 20px; + line-height: 20px; + text-align: center; + position: relative; + overflow: hidden; + img{ + width: 20px; + height: 20px; + } +} +//替换底图 inputfile +.a-upload { + display: block; + float: right; + margin: 8px 18px 0 0; + width: 20px; + height: 20px; + line-height: 20px; + text-align: center; + position: relative; + overflow: hidden; + input { + position: absolute; + width: 20px; + height: 20px; + left: 0; + top: 0; + opacity: 0; + } +} +.a-upload:hover { + .mat-icon { + color: #fff; + } +} +//上传底图 inputfile +#a-uploadImg { + display: block; + width: 300px; + height: 170px; + position: fixed; + top: 40%; + left: 48%; + overflow: hidden; + border-radius: 5px; + border: 1px solid #999; + z-index: 999; + input { + position: absolute; + width: 300px; + height: 170px; + left: 0; + top: 0; + opacity: 0; + } + img { + width: 100%; + height: auto; + } +} +#a-uploadImg:hover { + border: 5px solid skyblue; +} + +//hover时显示右边操作栏 +.sitePlanContent:hover { + #rightOperate { + display: block; + } +} +//右边操作栏 +#rightOperate{ + width: 50px; + height: 100px; + position: absolute; + top: -32px; + right: -48px; + z-index: 99999; + border-radius: 0 100px 100px 0; + background-color: #F0F4F7; + // #F0F4F7 cdced1 + display: none; + .functionButton { + height: 25%; + line-height: 25px; + } + .bigFunctionIcon { + font-size: 24px; + } + .functionIcon { + color: #999; + } + .functionIcon:hover { + color: #4DA5FA; + } +} + +//处置预案 素材库 公用div +.publiclBankPlan { + flex: 1; + display: flex; + flex-direction: column; + overflow: hidden; + padding-bottom: 10px; + // border-top: 1px dashed #999; +} + + + +// 基本信息/想定作业 切换 +.scenarioAssignment { + overflow-y: auto; +} +.selectEditMode { + flex: 1; + display: flex; + flex-direction: column; + overflow: hidden; +} +.materialBankDIV{ + flex: 1; + overflow-x: hidden; + overflow-y: auto; +} +// 基本信息/想定作业 切换 +//处置预案 +#terrNodePublic { + height: 35px; + line-height: 35px; + display: flex; + .textNode {flex: 1;} +} +//字体图标 +.planIconDiv { + display: inline-block; + .mat-icon{ + font-size: 20px; + width: 20px; + height: 20px; + color: #666; + margin-right: 3px; + } +} + + + +.mat-expansion-panel-header { + height: 40px !important; +} +//素材库溢出隐藏 +#materialBank { + margin: 1px 0; +} +//素材库图片flex +#panelLibrary .text{ + box-sizing: border-box; + margin-left: 10px; +} +.panelLibraryFlex { + display: flex; + flex-direction: row; + flex-wrap: wrap; + justify-content: space-between; /* 水平居中 */ + .imgBox { + width: 70px; + height: 100px; + display: inline-block; + text-align: center; + border-radius: 3px; + margin: 5px 0; + img { + width: 70px; + height: auto; + max-height: 70px; + cursor:pointer; + } + p { + font-size: 12px; + cursor:pointer; + } + } +} + +//文本溢出 +.overflowText { + overflow: hidden; + text-overflow:ellipsis; + white-space: nowrap; +} +// 楼层/区域 是避难层时 +.isRefugeStorey { + color: #fff; + background-color: rgb(238, 186, 186); +} +//选中平面图时 +.selectSitePlan { + color: #fff; + background-color: #6BC2FF; +} +//选中素材库图片时 +.selectImg { + color: #fff; + background-color: #4DA5FA; +} +//选中 处置节点时 +.selectanelPoint { + background-color: #F4C235; +} + + + +//左侧功能区弹出框样式 +.keyMargin { + width: 100%; + margin: 5px 0; + .mat-form-field { + width: 100%; + } +} +.submitBottom { + display: flex; + flex-direction: row; + flex-wrap: wrap; + justify-content: space-between; /* 水平居中 */ +} +.functionalDomainContent { + width: 300px; + height: 100%; + textarea { + border-radius: 5px; + border: 1px solid #999; + width: 100%; + height: 120px; + resize:none; + } +} diff --git a/src/app/ui/collection-tools-building/save.ts b/src/app/ui/collection-tools-building/save.ts new file mode 100644 index 0000000..03b5abd --- /dev/null +++ b/src/app/ui/collection-tools-building/save.ts @@ -0,0 +1,300 @@ +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,DisposalNodeData} from '../../canvas-share-data.service' //引入服务 +// 保存想定作业第一个弹窗 +@Component({ + selector: 'dialog-overview-example-dialog-building', + templateUrl: 'saveOne.html', + styleUrls: ['./collection-tools.component.scss'] +}) +export class saveOneDialogBuilding { + + constructor( + private http:HttpClient, + public dialog: MatDialog, + public snackBar: MatSnackBar, + public dialogRef: MatDialogRef, + @Inject(MAT_DIALOG_DATA) public data) {} + + onNoClick(): void { + this.dialogRef.close() + } + allDisposalNode = this.data.allDisposalNode + + saveType(type){ + this.dialogRef.close() + const dialogRef = this.dialog.open(saveTwoDialogBuilding, { + data: {type: type, + allDisposalNode: this.data.allDisposalNode, + selectedBuildingData:this.data.selectedBuildingData, + selectedSiteData:this.data.selectedSiteData, + siteOrbuilding:this.data.siteOrbuilding, + disasterId:this.data.disasterId} + }); + dialogRef.afterClosed().subscribe(result => { + }); + } + +} + + // 保存想定作业第二个弹窗 +@Component({ + selector: 'dialog-overview-example-dialog-building', + templateUrl: 'saveTwo.html', + styleUrls: ['./collection-tools.component.scss'] +}) +export class saveTwoDialogBuilding { + + constructor( + private http:HttpClient, + public dialogRef: MatDialogRef, + public canvasData: CanvasShareDataService, + public snackBar: MatSnackBar, + @Inject(MAT_DIALOG_DATA) public data) {} + + type = this.data.type + allDisposalNode = this.data.allDisposalNode + allPlanDisposalNode = [] + allRootDisposalNode = [{name:"根节点",id:null}] + allDisposalNodeChild = [] + ngOnInit(): void { + //所有非数据节点 + this.allDisposalNode.forEach(item => { + if(!item.sitePlanId && !item.buildingAreaId){ + this.allPlanDisposalNode.push(item) + } + }) + + //所有一级节点 + this.allDisposalNode.forEach(item => { + if(!item.parentId){ + this.allRootDisposalNode.push(item) + } + }) + this.allDisposalNodeChild = JSON.parse(JSON.stringify(this.allDisposalNode)) + this.allDisposalNodeChild.forEach(item => { + item.children = [] + this.allDisposalNodeChild.forEach(i => { + if(i.parentId == item.id){ + item.children.push(i) + } + }) + }) + // console.log(this.nodeItem.id) + } + onNoClick(): void { + this.dialogRef.close(); + } + nodeItem + itemChildNum = 0 //点击处置节点子数据节点的数量 + clickNode(item){ + // console.log(item) + this.nodeItem = item + this.allDisposalNodeChild.forEach(item => { + if(item.id == this.nodeItem.id){ + this.itemChildNum = item.children.length + } + }) + } + + selectedBuildingData = this.data.selectedBuildingData + selectedSiteData = this.data.selectedSiteData + onSubmit(value,type){ + // console.log(type) + let name = this.selectedBuildingData.name + '-' + this.selectedSiteData.name + //如果保存到已有节点 + var postdata = { + id: "", + name: name, + level: 0, + order: this.itemChildNum, + description: "", + notes: "", + weather: null, + airTemperature: null, + windDirection: null, + windScale: null, + imageNames: null, + imageUrls: null, + parentId: this.nodeItem ? this.nodeItem.id : null, + disasterId: this.data.disasterId, + planComponentId: sessionStorage.getItem('planId') || '', + companyId: this.data.siteOrbuilding == -1 ? sessionStorage.getItem('companyId') : null, + sitePlanId: this.data.siteOrbuilding==-1 ? this.selectedSiteData.id : null, + buildingId: this.selectedBuildingData.id || null, + buildingAreaId: this.data.siteOrbuilding!=-1 ? this.selectedSiteData.id : null + } + if(type == 'old'){ + let istrue = this.canvasData.findDisposalNode(this.nodeItem.id,name) + let putdata = this.nodeItem + putdata.weather = this.canvasData.selectPanelPointBaseData.weather + putdata.airTemperature = Number(this.canvasData.selectPanelPointBaseData.airTemperature) + putdata.windScale = Number(this.canvasData.selectPanelPointBaseData.windScale) + putdata.windDirection = Number(this.canvasData.selectPanelPointBaseData.windDirection) + putdata.description = this.canvasData.selectPanelPointBaseData.description + putdata.notes = this.canvasData.selectPanelPointBaseData.notes + + + if(istrue){//如果该处置节点下已有同名数据节点 则只修改 2个接口 + new Promise((resolve,reject)=>{ + this.http.put(`/api/DisposalNodes/${value.nodeId}`,putdata).subscribe(data => { + resolve("更新处置节点成功,将天气 节点详情等信息保存到点击的节点") + }) + }).then((values)=>{ + this.canvasData.sendMessage('send a message');//发布一条消息 + // 保存平面图数据到当前节点 + let postdata =JSON.parse(JSON.stringify(this.canvasData.selectPanelPoint)) + postdata.Data = JSON.stringify(postdata.Data) + this.http.post(`/api/DisposalNodeData`,postdata).subscribe(data => { + const config = new MatSnackBarConfig(); + config.verticalPosition = 'top'; + config.duration = 3000 + this.snackBar.open('保存成功','确定',config) + },err=>{ + const config = new MatSnackBarConfig(); + config.verticalPosition = 'top'; + config.duration = 3000 + this.snackBar.open('保存失败','确定',config) + }) + this.dialogRef.close(); + this.canvasData.sendMessage('send a message');//发布一条消息 + }) + + }else{//需要3个接口 + new Promise((resolve,reject)=>{ + this.http.put(`/api/DisposalNodes/${value.nodeId}`,putdata).subscribe(data => { + resolve("更新处置节点成功,将天气 节点详情等信息保存到点击的节点") + }) + }).then((values)=>{ + // console.log(values) + postdata.level = putdata.level + 1 + new Promise((resolve,reject) => { + this.http.post(`/api/DisposalNodes`,postdata).subscribe(data => { + resolve(data) + }) + }).then((data:any)=>{ + // console.log(7788,data) + let objData = { + id: "", + data: JSON.stringify(this.canvasData.selectPanelPoint.Data) || null, + version: this.canvasData.selectPanelPoint.Version || "2.0", + disposalNodeId: data.id, + planComponentId: sessionStorage.getItem("planId"), + } + this.http.post(`/api/DisposalNodeData`,objData).subscribe(data => { + const config = new MatSnackBarConfig(); + config.verticalPosition = 'top'; + config.duration = 3000 + this.snackBar.open('保存成功','确定',config) + },err=>{ + const config = new MatSnackBarConfig(); + config.verticalPosition = 'top'; + config.duration = 3000 + this.snackBar.open('保存失败','确定',config) + }) + this.dialogRef.close(); + this.canvasData.sendMessage('send a message');//发布一条消息 + }) + }) + } + + }else{//如果保存到新建节点 + let dispositionNodeData //处置节点data + let order + let oneLevelNum = [] + //将order赋值为所有一级节点最后一个+1 + this.allDisposalNode.forEach(item => { + if(!item.parentId){ + oneLevelNum.push(item) + } + }) + if(oneLevelNum.length == 0){ + order = 0 + }else{ + order = oneLevelNum[oneLevelNum.length - 1].order + 1 + } + + if(this.nodeItem){//如果点击了下拉选择框 + if(this.nodeItem.id != null){ + this.allDisposalNodeChild.forEach(item => { + if(item.id == this.nodeItem.id){ + order = item.children.length + } + }) + } + } + dispositionNodeData = { + id: "", + name: value.name, + level: this.nodeItem && this.nodeItem.id != null ? this.nodeItem.level + 1 : 0, + order: order, + description: "", + notes: "", + weather: null, + airTemperature: 0, + windDirection: 0, + windScale: 0, + imageNames: null, + imageUrls: null, + parentId: this.nodeItem ? this.nodeItem.id : null, + disasterId: this.data.disasterId, + planComponentId: sessionStorage.getItem('planId') || '', + companyId: null, + sitePlanId: null, + buildingId: null, + buildingAreaId: null + } + + dispositionNodeData.weather = this.canvasData.selectPanelPointBaseData.weather + dispositionNodeData.airTemperature = Number(this.canvasData.selectPanelPointBaseData.airTemperature) + dispositionNodeData.windScale = Number(this.canvasData.selectPanelPointBaseData.windScale) + dispositionNodeData.windDirection = Number(this.canvasData.selectPanelPointBaseData.windDirection) + dispositionNodeData.description = this.canvasData.selectPanelPointBaseData.description + dispositionNodeData.notes = this.canvasData.selectPanelPointBaseData.notes + //1.先创建一个处置节点 然后 .then 2.创建数据节点到刚创建的处置节点 3.然后拿着创建好的数据节点的id 将平面图data保存 + new Promise((resolve,reject) => { + this.http.post("/api/DisposalNodes",dispositionNodeData).subscribe((data:any) => { + resolve(data.id) + }) + }).then((id) => { + let dataNodeData + new Promise((resolve,reject) => { + postdata.parentId = id + postdata.level = dispositionNodeData.level + 1 + this.http.post("/api/DisposalNodes",postdata).subscribe((data:any) => { + resolve(data) + }) + }).then((data:any) => { + // 保存平面图数据到当前节点 + // console.log(6666,data) + // let postdata =JSON.parse(JSON.stringify(this.canvasData.selectPanelPoint)) + // postdata.Data = JSON.stringify(postdata.Data) + let objData = { + id: "", + data: JSON.stringify(this.canvasData.selectPanelPoint.Data) || null, + version: this.canvasData.selectPanelPoint.Version || "2.0", + disposalNodeId: data.id, + planComponentId: sessionStorage.getItem("planId"), + } + + this.http.post(`/api/DisposalNodeData`,objData).subscribe(data => { + const config = new MatSnackBarConfig(); + config.verticalPosition = 'top'; + config.duration = 3000 + this.snackBar.open('保存成功','确定',config) + + },err=>{ + const config = new MatSnackBarConfig(); + config.verticalPosition = 'top'; + config.duration = 3000 + this.snackBar.open('保存失败','确定',config) + }) + this.dialogRef.close(); + this.canvasData.sendMessage("send a message") + }) + }) + } + } +} \ No newline at end of file diff --git a/src/app/ui/collection-tools-building/saveOne.html b/src/app/ui/collection-tools-building/saveOne.html new file mode 100644 index 0000000..a6b0b32 --- /dev/null +++ b/src/app/ui/collection-tools-building/saveOne.html @@ -0,0 +1,5 @@ +
处置节点保存
+
+ + +
\ No newline at end of file diff --git a/src/app/ui/collection-tools-building/saveTwo.html b/src/app/ui/collection-tools-building/saveTwo.html new file mode 100644 index 0000000..fec97ff --- /dev/null +++ b/src/app/ui/collection-tools-building/saveTwo.html @@ -0,0 +1,53 @@ +
+
新增节点
+
+
+ +
+ + + +
+
+ + + + {{item.name}} + + + +
+
+ + +
+
+
+
+
+
保存到已有节点
+
+
+
+ + + + {{item.name}} + + + +
+
+ + +
+
+
+
\ No newline at end of file diff --git a/src/app/ui/collection-tools-building/viewdetails.html b/src/app/ui/collection-tools-building/viewdetails.html new file mode 100644 index 0000000..76638c2 --- /dev/null +++ b/src/app/ui/collection-tools-building/viewdetails.html @@ -0,0 +1,24 @@ +
+
+ clear +
+ +
+
+ +
+
+ +
+
+
\ No newline at end of file diff --git a/src/app/ui/collection-tools-plan/addPlaneFigure.html b/src/app/ui/collection-tools-plan/addPlaneFigure.html index 930bf81..605e5e5 100644 --- a/src/app/ui/collection-tools-plan/addPlaneFigure.html +++ b/src/app/ui/collection-tools-plan/addPlaneFigure.html @@ -12,6 +12,17 @@
+ + +
+ + 上传本地图片 + +

选择文件: {{file.name}}

+
+
是否为避难层
diff --git a/src/app/ui/collection-tools-plan/collection-tools.component.html b/src/app/ui/collection-tools-plan/collection-tools.component.html index b2bdb47..4f411b2 100644 --- a/src/app/ui/collection-tools-plan/collection-tools.component.html +++ b/src/app/ui/collection-tools-plan/collection-tools.component.html @@ -2,16 +2,16 @@
- + - - tv - create - description + + +
- -
- - - - -
-
- keyboard_arrow_right - keyboard_arrow_left - 天气 - - 气温 -
- - -
- 风力 - - 风向 - -
-
-
-
@@ -218,12 +150,8 @@
-
-
-
- 属性 -
-
+
+
属性

面积(平方米)

@@ -366,69 +294,11 @@
-
- -
- -
- -
- -
-
- 消防要素 -
-
- -
- - - - - - - {{node.name}} - - ({{node.children.length}}) - visibility - - - - - - - {{node.name}} - - ({{node.children.length}}) - visibility - - -
+
-
-
-
-
- 节点详情 -
-
- 注意事项 -
-
-
- - -
-
diff --git a/src/app/ui/collection-tools-plan/collection-tools.component.scss b/src/app/ui/collection-tools-plan/collection-tools.component.scss index 985cf7e..acae429 100644 --- a/src/app/ui/collection-tools-plan/collection-tools.component.scss +++ b/src/app/ui/collection-tools-plan/collection-tools.component.scss @@ -59,6 +59,12 @@ color: white; } } + .rightSave { + cursor: pointer; + position: absolute; + right: 60px; + label { vertical-align: middle; color: #279FFF; } + } } //头部操作栏 @@ -107,7 +113,7 @@ top: 0; } .functionalDomain { - flex: 90%; + flex: 95%; overflow: hidden; .functionalDomainContent { position: relative; @@ -138,10 +144,9 @@ z-index: 1001; margin-right: 0px; transition: margin-right 0.5s; - border: 1px solid #464646; + border: 1px solid #E6EAEE; width: 235px; right: 0; - } //右边导航栏显示隐藏 .togglePanel2 { @@ -153,27 +158,17 @@ margin-left: -2000px; transition: margin-left 1s; } - } //右边操作栏 -.title{ - width: 100%; - height: 35px; - background-color: #464646; - div{ - width: 50%; - height: 35px; - line-height: 35px; - background-color: #595959; - border-radius: 5px; - span{ - color: white; - font-size: 14px; - font-weight: 400; - padding-left: 5px; - } - } +.rightTitle{ + height: 35x; + line-height: 35px; + text-align: center; + border-top-left-radius: 10px; + border-top-right-radius: 10px; + background-color: #2196F3; + color: #fff; } 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 b776406..17f69c5 100644 --- a/src/app/ui/collection-tools-plan/collection-tools.component.ts +++ b/src/app/ui/collection-tools-plan/collection-tools.component.ts @@ -607,7 +607,6 @@ export class CollectionToolsPlanComponent implements OnInit { this.canvasData.isChange = true } - isSixShow = true isSixbtn = true //控制想定作业编辑按钮 isediticon = true //控制查看编辑模式的编辑模式小笔按钮 @@ -631,7 +630,6 @@ export class CollectionToolsPlanComponent implements OnInit { this.canvasData.gameMode = GameMode.Assignment } else { this.getAllLibrary() //获取素材库 - this.getAllBuildings() //获取所有建筑 } let that = this @@ -645,7 +643,7 @@ export class CollectionToolsPlanComponent implements OnInit { this.canvasData.getMessage().subscribe((message: any)=>{ if(message == "send a message"){ - this.refurbishTreeData() + // this.refurbishTreeData() } }) } @@ -669,7 +667,7 @@ export class CollectionToolsPlanComponent implements OnInit { //监听数据变化后 this.canvas.on('canvasDataChanged',()=>{ // 收到数据表示共享数据发生变化 - this.renovateTreeData(false) + // this.renovateTreeData(false) }); } @@ -684,7 +682,7 @@ export class CollectionToolsPlanComponent implements OnInit { let buildingId = this.beforeOneCheckedBuilding.id let floorId = this.selectingSitePlan.id this.canvas.paste(companyId,buildingId,floorId) - this.renovateTreeData(false) + // this.renovateTreeData(false) } basicInfo:boolean = true //基本信息名称显隐 @@ -1352,31 +1350,30 @@ export class CollectionToolsPlanComponent implements OnInit { //封装 刷新 tree 数据 async renovateTreeData (isRefresh:boolean = true) { - this.allFireElements[this.allFireElements.length-1].children = [] + // this.allFireElements[this.allFireElements.length-1].children = [] isRefresh? await this.canvas.refresh() : null this.canvas.setNameVisible(this.basicInfo,0) this.canvas.setNameVisible(this.wantToWork,1) isRefresh? this.canvasData.isChange = false : null //服务中 数据是否改动 改为false isRefresh? this.isShowProperty = true : null isRefresh? this.isShowAttribute = true : null - !this.pattern? this.mateFireForce() : null //刷新 建筑楼层 火源/力量图标 - let beforeOneId = this.selectingSitePlan.id || '' //当前 选中 平面图 楼层/区域 id - let companyBuildingData = JSON.parse(JSON.stringify( this.canvasData.originalcompanyBuildingData || {} )) // 当前 单位/建筑 数据 - let storeyData = JSON.parse(JSON.stringify( this.canvasData.originaleveryStoreyData || {} )) //当前 楼层 数据 + // let beforeOneId = this.selectingSitePlan.id || '' //当前 选中 平面图 楼层/区域 id + // let companyBuildingData = JSON.parse(JSON.stringify( this.canvasData.originalcompanyBuildingData || {} )) // 当前 单位/建筑 数据 + // let storeyData = JSON.parse(JSON.stringify( this.canvasData.originaleveryStoreyData || {} )) //当前 楼层 数据 - for(let key in companyBuildingData.data){ - if (companyBuildingData.data[key].FloorId === beforeOneId) { //处理 单位/建筑 数据是否归于当前楼层下 - storeyData.data[key] = companyBuildingData.data[key] - } - } - for(let key in storeyData.data){ //筛选数据 没有匹配全部放入到 其他 数组 - let noMatch = this.allFireElements.find( every=> every.id===storeyData.data[key].FireElementId ) - if (!noMatch) { - this.allFireElements[this.allFireElements.length-1].children.push(storeyData.data[key]) - } - } - this.handleTreeData(storeyData) //处理tree数据结构 + // for(let key in companyBuildingData.data){ + // if (companyBuildingData.data[key].FloorId === beforeOneId) { //处理 单位/建筑 数据是否归于当前楼层下 + // storeyData.data[key] = companyBuildingData.data[key] + // } + // } + // for(let key in storeyData.data){ //筛选数据 没有匹配全部放入到 其他 数组 + // let noMatch = this.allFireElements.find( every=> every.id===storeyData.data[key].FireElementId ) + // if (!noMatch) { + // this.allFireElements[this.allFireElements.length-1].children.push(storeyData.data[key]) + // } + // } + // this.handleTreeData(storeyData) //处理tree数据结构 } @@ -1423,7 +1420,7 @@ export class CollectionToolsPlanComponent implements OnInit { //获取总平面图 getSitePlan () { - let fireData = this.getFireElements(sessionStorage.getItem('buildingTypeId')) //获取单位下 消防要素 + // let fireData = this.getFireElements(sessionStorage.getItem('buildingTypeId')) //获取单位下 消防要素 let planData = this.getSitePlanCompanyData() //获取 单位 数据 this.http.get('/api/SitePlans',{params:this.params}).subscribe(data=>{ this.sitePlanData = data @@ -1431,7 +1428,7 @@ export class CollectionToolsPlanComponent implements OnInit { this.canvasData.selectStorey = this.sitePlanData[0] || {} //服务中 存一份数据 this.selectSitePlanIndex = 0 - Promise.all([fireData,planData]).then((res)=>{ + Promise.all([planData]).then((res)=>{ this.getSitePlanStorey(this.selectingSitePlan) //获取 平面图 楼层数据 }) @@ -1441,7 +1438,7 @@ export class CollectionToolsPlanComponent implements OnInit { //获取建筑 楼层/区域 getBuildingSitePlan (item) { let params = { buildingId: item.id } - let fireData = this.getFireElements(item.buildingTypes[0].id || '') //获取建筑下 消防要素 + // let fireData = this.getFireElements(item.buildingTypes[0].id || '') //获取建筑下 消防要素 let planData = this.getBuildingData(params) //获取 建筑 数据 this.http.get('/api/BuildingAreas',{params}).subscribe(data=>{ this.sitePlanData = data @@ -1449,7 +1446,7 @@ export class CollectionToolsPlanComponent implements OnInit { this.canvasData.selectStorey = this.sitePlanData[0] || {} //服务中 存一份数据 this.selectSitePlanIndex = 0 - Promise.all([fireData,planData]).then((res)=>{ + Promise.all([planData]).then((res)=>{ this.getBuildingStorey(this.selectingSitePlan) //获取 建筑 楼层数据 }) diff --git a/src/app/ui/collection-tools-plan/leftFunctionalDomain.ts b/src/app/ui/collection-tools-plan/leftFunctionalDomain.ts index 598e178..b010e94 100644 --- a/src/app/ui/collection-tools-plan/leftFunctionalDomain.ts +++ b/src/app/ui/collection-tools-plan/leftFunctionalDomain.ts @@ -23,36 +23,75 @@ export class leftFunctionalDomainComponentPlan implements OnInit { params = {companyId: sessionStorage.getItem('companyId')} checked:boolean = false;//是否为避难层 - + file:any = null; //上传的文件 + + //选择文件 + selectFile (e) { + if (e.target.files.length) { + let maxSize = 5*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('上传图片需小于5MB','确定',config); + } + } + } + + //导入GIS + toGIS () { + const config = new MatSnackBarConfig(); + config.verticalPosition = 'top'; + config.duration = 3000 + this.snackBar.open('功能开发测试中,即将上线','确定',config); + } + //提交表单创建平面图 onSubmit (e) { - if (!this.data.isBuilding) { //总平面图 创建平面图 - let data = { - companyId: sessionStorage.getItem('companyId'), - name: e.name, - order: this.data.order, - area:e.area, - details:e.details, - enabled: true, - modifiedTime: new Date(), - } - 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:e.area, - details:e.details, - enabled: true, - modifiedTime: new Date(), - } - this.http.post('/api/BuildingAreas',data,{params:this.params}).subscribe(data=>{ - this.dialogRef.close('建筑'); - }) + 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 + console.log(imgURL) + if (!this.data.isBuilding) { //总平面图 创建平面图 + let data = { + companyId: sessionStorage.getItem('companyId'), + name: e.name, + order: this.data.order, + area:e.area, + details:e.details, + enabled: true, + modifiedTime: new Date(), + imageUrl: imgURL, + } + 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:e.area, + details:e.details, + enabled: true, + modifiedTime: new Date(), + imageUrl: imgURL, + } + this.http.post('/api/BuildingAreas',data,{params:this.params}).subscribe(data=>{ + this.dialogRef.close('建筑'); + }) + } + }) //post + } else { + const config = new MatSnackBarConfig(); + config.verticalPosition = 'top'; + config.duration = 3000 + this.snackBar.open('请上传图片','确定',config); } } diff --git a/src/app/ui/collection-tools-plan/panel.scss b/src/app/ui/collection-tools-plan/panel.scss index f0ae073..11200e8 100644 --- a/src/app/ui/collection-tools-plan/panel.scss +++ b/src/app/ui/collection-tools-plan/panel.scss @@ -268,9 +268,34 @@ .keyMargin { width: 100%; margin: 5px 0; + text-align: center; .mat-form-field { width: 100%; } + //上传CAD弹窗 inputfile + .uploadBackGround { + width: 80%; + padding: 0 25px; + height: 30px; + line-height: 30px; + position: relative; + cursor: pointer; + color: #000; + font-size: 14px; + background: #fafafa; + border: 1px solid #ddd; + border-radius: 5px; + overflow: hidden; + display: inline-block; + } + .uploadBackGround input { + position: absolute; + width: 100%; + right: 0; + top: 0; + opacity: 0; + cursor: pointer + } } .submitBottom { display: flex; diff --git a/src/app/ui/collection-tools/collection-tools.component.html b/src/app/ui/collection-tools/collection-tools.component.html index dfc085f..b6a073f 100644 --- a/src/app/ui/collection-tools/collection-tools.component.html +++ b/src/app/ui/collection-tools/collection-tools.component.html @@ -2,21 +2,21 @@
- + 基本信息名称visibility 想定作业名称visibility - + 显示图例 @@ -36,10 +36,10 @@ 想定作业编辑
- - tv - create - description + + +
@@ -404,7 +404,7 @@
-
+
diff --git a/src/app/ui/collection-tools/collection-tools.component.scss b/src/app/ui/collection-tools/collection-tools.component.scss index f01a7b7..9f00105 100644 --- a/src/app/ui/collection-tools/collection-tools.component.scss +++ b/src/app/ui/collection-tools/collection-tools.component.scss @@ -59,6 +59,12 @@ color: white; } } + .rightSave { + cursor: pointer; + position: absolute; + right: 60px; + label { vertical-align: middle; color: #279FFF; } + } } //头部操作栏 diff --git a/src/app/ui/collection-tools/collection-tools.component.ts b/src/app/ui/collection-tools/collection-tools.component.ts index c9da111..e3ce60c 100644 --- a/src/app/ui/collection-tools/collection-tools.component.ts +++ b/src/app/ui/collection-tools/collection-tools.component.ts @@ -1025,12 +1025,7 @@ export class CollectionToolsComponent implements OnInit { disasterId: this.allFirePlan[0].id || '' } }); - - dialogRef.afterClosed().subscribe(result => { - // console.log('The dialog was closed'); - }); - } - + } //else } else { //if const config = new MatSnackBarConfig(); config.verticalPosition = 'top'; @@ -1276,7 +1271,6 @@ export class CollectionToolsComponent implements OnInit { //点击数节点的显示隐藏icon clickLookItem(node){ - //修改真实素材islook属性 for(let key in this.storeyData.data){ if(key == node.id){ @@ -1563,7 +1557,7 @@ export class CollectionToolsComponent implements OnInit { selectSitePlan (item,index) { if (this.selectSitePlanIndex != index) { this.canvasData.selectPanelPoint = new DisposalNodeData(); - if (this.canvasData.isChange) { //true 数据被改动 + if (this.pattern && this.canvasData.isChange) { //true 数据被改动 let isTrue = confirm('是否保存当前编辑数据') if (isTrue) { //先保存数据 在切换 let isSuccess = this.saveSite()//true的时候 先保存数据 @@ -2136,9 +2130,13 @@ export class CollectionToolsComponent implements OnInit { let dialogRef = this.dialog.open(addBGCDisposalNodeComponent); dialogRef.afterClosed().subscribe(data=>{ if (data) { - this.canvasData.customizeDisposalNode = data + this.canvasData.customizeDisposalNode = data //自定义数据节点 let imgURL = window.URL.createObjectURL(data.file) //将图片生成 url地址 - console.log(imgURL,this.canvasData.customizeDisposalNode) + this.canvasData.selectPanelPointBaseData = {description: '', notes: '', weather: '', airTemperature: '', windDirection: '', windScale: ''} //更新 当前数据节点对应父级节点 + this.selectDisposalNode = '' + this.canvasData.selectPanelPoint = new DisposalNodeData() //更新 当前数据节点 + this.canvasData.selectPanelPoint.BackgroundImageUrl = imgURL + this.customizeNodes() } }) } @@ -2235,16 +2233,46 @@ export class CollectionToolsComponent implements OnInit { buildingIndex: e.sitePlanId? -1 : this.allBuildings.findIndex(item=>{ return item.id===e.buildingId }), //总平面图/建筑 index storeyId: e.sitePlanId? e.sitePlanId : e.buildingAreaId, //楼层id } - this.http.get('/api/DisposalNodeData',{params:params}).subscribe(data=>{ + this.http.get('/api/DisposalNodeData',{params:params}).subscribe((data:any)=>{ this.canvasData.selectPanelPoint = this.canvasData.deserialize(JSON.stringify(data || new DisposalNodeData())) //选择 当前 节点 this.canvasData.selectPanelPoint.Data = this.canvasData.deserialize(this.canvasData.selectPanelPoint.Data) - this.seekPanelPoint(parameter) + data.backgroundImageUrl? this.customizeNodes() : this.seekPanelPoint(parameter) }) } //if } //else if } + //自定义数据节点 时 + async customizeNodes() { + await this.canvas.loadNoRelevantInformationDisposalPlan(this.canvasData.selectPanelPoint) + let other = { + children: [], + computed: true, + id: '', + name: '其他', + order: 999, + parentId: null, + tag: "INPUT", + isLookPattern : true + } + this.allFireElements = [other] + this.canvas.setNameVisible(this.basicInfo,0) + this.canvas.setNameVisible(this.wantToWork,1) + this.beforeOneCheckedBuildingIsShow = false + + let selectPanelPoint = JSON.parse(JSON.stringify(this.canvasData.selectPanelPoint || {} )) //当前 节点 数据 + if(selectPanelPoint.Data){ + for(let key in selectPanelPoint.Data.Stock){ //筛选数据 没有匹配全部放入到 其他 数组 + let noMatch = this.allFireElements.find( every=> every.id===selectPanelPoint.Data.Stock[key].FireElementId ) + if (!noMatch) { + this.allFireElements[this.allFireElements.length-1].children.push(selectPanelPoint.Data.Stock[key]) + } + } + } + this.handleTreeData({data:{}},selectPanelPoint) //处理tree数据结构 + } + //查找 数据节点 对应 建筑/楼层 seekPanelPoint (paramsData) { this.checkedBuildingIndex = paramsData.buildingIndex diff --git a/src/app/ui/collection-tools/leftFunctionalDomain.ts b/src/app/ui/collection-tools/leftFunctionalDomain.ts index 3deb432..9703cd8 100644 --- a/src/app/ui/collection-tools/leftFunctionalDomain.ts +++ b/src/app/ui/collection-tools/leftFunctionalDomain.ts @@ -144,7 +144,7 @@ export class addBGCDisposalNodeComponent implements OnInit { file:any = null; //文件 //上传图片 selectFile (e) { - if (e.target.files.length ) { + if (e.target.files.length) { let maxSize = 5*1024*1024 if (e.target.files[0].size <= maxSize) { this.file = e.target.files[0] diff --git a/src/app/ui/collection-tools/save.ts b/src/app/ui/collection-tools/save.ts index 1657b66..4be3e0b 100644 --- a/src/app/ui/collection-tools/save.ts +++ b/src/app/ui/collection-tools/save.ts @@ -92,7 +92,6 @@ export class saveOneDialog { nodeItem itemChildNum = 0 //点击处置节点子数据节点的数量 clickNode(item){ - // console.log(item) this.nodeItem = item this.allDisposalNodeChild.forEach(item => { if(item.id == this.nodeItem.id){ @@ -105,8 +104,17 @@ export class saveOneDialog { selectedSiteData = this.data.selectedSiteData onSubmit(value,type){ this.maskLayerService.sendMessage(true) - - let name = this.selectedBuildingData.name + '-' + this.selectedSiteData.name + let name + if (this.canvasData.selectPanelPoint.BackgroundImageUrl) { //当前 为自定义处置节点 + if (this.canvasData.selectPanelPoint.DisposalNodeId) { // 保存逻辑 + let node = this.canvasData.findDisposalNode(this.canvasData.selectPanelPoint.DisposalNodeId,null) + node? name = node.name : null + } else { //新建逻辑 + name = this.canvasData.customizeDisposalNode.name + } + } else { + name = this.selectedBuildingData.name + '-' + this.selectedSiteData.name + } //如果保存到已有节点 var postdata = { id: "", @@ -138,8 +146,7 @@ export class saveOneDialog { putdata.windDirection = Number(this.canvasData.selectPanelPointBaseData.windDirection) putdata.description = this.canvasData.selectPanelPointBaseData.description putdata.notes = this.canvasData.selectPanelPointBaseData.notes - - + if(istrue){//如果该处置节点下已有同名数据节点 则只修改 2个接口 new Promise((resolve,reject)=>{ this.http.put(`/api/DisposalNodes/${value.nodeId}`,putdata).subscribe(data => { @@ -150,21 +157,30 @@ export class saveOneDialog { // 保存平面图数据到当前节点 let postdata =JSON.parse(JSON.stringify(this.canvasData.selectPanelPoint)) postdata.Data = JSON.stringify(postdata.Data) - this.http.post(`/api/DisposalNodeData`,postdata).subscribe(data => { - this.maskLayerService.sendMessage(false) - const config = new MatSnackBarConfig(); - config.verticalPosition = 'top'; - config.duration = 3000 - this.snackBar.open('保存成功','确定',config) - },err=>{ - this.maskLayerService.sendMessage(false) - const config = new MatSnackBarConfig(); - config.verticalPosition = 'top'; - config.duration = 3000 - this.snackBar.open('保存失败','确定',config) - }) - this.dialogRef.close(); - this.canvasData.sendMessage('send a message');//发布一条消息 + postdata.Version = "2.0" + postdata.DisposalNodeId ? null : postdata.DisposalNodeId = istrue.id + postdata.PlanComponentId ? null : postdata.PlanComponentId = sessionStorage.getItem("planId") + postdata.Id ? null : postdata.Id = '' + postdata.BackgroundImageUrl? null : postdata.BackgroundImageUrl = null + let imgURL = this.uploadBGC() //更新 背景图 + imgURL.then(url=>{ + url? postdata.BackgroundImageUrl = url.toString() : null + this.http.post(`/api/DisposalNodeData`,postdata).subscribe(data => { + this.maskLayerService.sendMessage(false) + const config = new MatSnackBarConfig(); + config.verticalPosition = 'top'; + config.duration = 3000 + this.snackBar.open('保存成功','确定',config) + },err=>{ + this.maskLayerService.sendMessage(false) + const config = new MatSnackBarConfig(); + config.verticalPosition = 'top'; + config.duration = 3000 + this.snackBar.open('保存失败','确定',config) + }) + this.dialogRef.close(); + this.canvasData.sendMessage('send a message');//发布一条消息 + }) //imgURL }) }else{//需要3个接口 @@ -186,22 +202,27 @@ export class saveOneDialog { version: this.canvasData.selectPanelPoint.Version || "2.0", disposalNodeId: data.id, planComponentId: sessionStorage.getItem("planId"), + backgroundImageUrl: this.canvasData.selectPanelPoint.BackgroundImageUrl, } - this.http.post(`/api/DisposalNodeData`,objData).subscribe(data => { - this.maskLayerService.sendMessage(false) - const config = new MatSnackBarConfig(); - config.verticalPosition = 'top'; - config.duration = 3000 - this.snackBar.open('保存成功','确定',config) - },err=>{ - this.maskLayerService.sendMessage(false) - const config = new MatSnackBarConfig(); - config.verticalPosition = 'top'; - config.duration = 3000 - this.snackBar.open('保存失败','确定',config) - }) - this.dialogRef.close(); - this.canvasData.sendMessage('send a message');//发布一条消息 + let imgURL = this.uploadBGC() //更新 背景图 + imgURL.then(url=>{ + url? objData.backgroundImageUrl = url.toString() : null + this.http.post(`/api/DisposalNodeData`,objData).subscribe(data => { + this.maskLayerService.sendMessage(false) + const config = new MatSnackBarConfig(); + config.verticalPosition = 'top'; + config.duration = 3000 + this.snackBar.open('保存成功','确定',config) + },err=>{ + this.maskLayerService.sendMessage(false) + const config = new MatSnackBarConfig(); + config.verticalPosition = 'top'; + config.duration = 3000 + this.snackBar.open('保存失败','确定',config) + }) + this.dialogRef.close(); + this.canvasData.sendMessage('send a message');//发布一条消息 + }) //imgURL }) }) } @@ -280,26 +301,48 @@ export class saveOneDialog { version: this.canvasData.selectPanelPoint.Version || "2.0", disposalNodeId: data.id, planComponentId: sessionStorage.getItem("planId"), + backgroundImageUrl: this.canvasData.selectPanelPoint.BackgroundImageUrl, } - - this.http.post(`/api/DisposalNodeData`,objData).subscribe(data => { - this.maskLayerService.sendMessage(false) - const config = new MatSnackBarConfig(); - config.verticalPosition = 'top'; - config.duration = 3000 - this.snackBar.open('保存成功','确定',config) - - },err=>{ - this.maskLayerService.sendMessage(false) - const config = new MatSnackBarConfig(); - config.verticalPosition = 'top'; - config.duration = 3000 - this.snackBar.open('保存失败','确定',config) - }) - this.dialogRef.close(); - this.canvasData.sendMessage("send a message") + let imgURL = this.uploadBGC() //更新 背景图 + imgURL.then(url=>{ + url? objData.backgroundImageUrl = url.toString() : null + this.http.post(`/api/DisposalNodeData`,objData).subscribe(data => { + this.maskLayerService.sendMessage(false) + const config = new MatSnackBarConfig(); + config.verticalPosition = 'top'; + config.duration = 3000 + this.snackBar.open('保存成功','确定',config) + + },err=>{ + this.maskLayerService.sendMessage(false) + const config = new MatSnackBarConfig(); + config.verticalPosition = 'top'; + config.duration = 3000 + this.snackBar.open('保存失败','确定',config) + }) + this.dialogRef.close(); + this.canvasData.sendMessage("send a message") + }) //imgURL }) }) } } + + //封装方法 上传 自定义底图 + uploadBGC () { + 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) + }) + } + } else { + resolve(null) + } //else + }) + } + } \ No newline at end of file diff --git a/src/app/ui/ui.module.ts b/src/app/ui/ui.module.ts index d1129ac..81265f8 100644 --- a/src/app/ui/ui.module.ts +++ b/src/app/ui/ui.module.ts @@ -96,8 +96,11 @@ import { saveOneDialog, saveTwoDialog } from './collection-tools/save'; import { CollectionToolsPlanComponent, CreateBuildingPlan, EditBuildingPlan, ViewDetailsPlan } from './collection-tools-plan/collection-tools.component'; import { addDisposalNodeComponentPlan, editDisposalNodeComponentPlan, editPlaneFigureComponentPlan, leftFunctionalDomainComponentPlan } from './collection-tools-plan/leftFunctionalDomain'; import { saveOneDialogPlan, saveTwoDialogPlan } from './collection-tools-plan/save'; +import {CollectionToolsBuildingComponent,CreateBuildingBuilding,EditBuildingBuilding,ViewDetailsBuilding} from './collection-tools-building/collection-tools.component' +import {leftFunctionalDomainBuildingComponent,editPlaneFigureBuildingComponent,addDisposalNodeBuildingComponent,editDisposalNodeBuildingComponent} from './collection-tools-building/leftFunctionalDomain' +import {saveOneDialogBuilding,saveTwoDialogBuilding} from './collection-tools-building/save' @NgModule({ - declarations: [UiComponent, DateselectComponent, MenuComponent, CardComponent, ListComponent, GridComponent, StepperComponent, TabgroupComponent, ButtonComponent, BadgeComponent, ProgressComponent, SnackbarComponent,PersonaldataComponent, FooterComponent, UserdataComponent, ChangepasswordComponent, OrganizationComponent, UnittypeComponent, AuthorityComponent, RoleComponent, UsermanagementComponent,IsnoPipe,ConfirmpswDirective,DialogOverviewExampleDialog,CreateAuthority,CreateRole,TimePipe,CreateNewUser,EditNewUser,allRoles,EditRole,CreateOrganization,EditOrganization,seeInformation,EditUser,editorialUnit,FireProtectionElementsComponent,Establish,EditingFireControl,FireFightingTemplateComponent, NavmenusComponent,CreateMenus,EditMenus,NewFireFighting,EditFireClassification, MaterialBankComponent, UnitInformationComponent,AddMatLibrary,EditMatLibrary,attributeComponent,AddOriginalCopy,addAttributeComponent,editAttribute,EditOriginalCopy,SelectOriginalCopy,EditUnitInfo,AddUnitInfo,AddGroups,EditGroup, EnterpriseuserComponent,AddEnterpriserUser,addUnitAttributeComponent,editUnitAttribute,seeenterpriseuser,editenterpriseuser, FireFightingFacilitiesFormworkComponent,addFireFightingFacilitiesFormworkComponent,editFireFightingFacilitiesFormworkComponent,addBuiltInComponent,addBuiltInAttributeComponent,addOptionalComponent,addOptionalAttributeComponent,editBuiltInAttributeComponent,editOptionalAttributeComponent, CollectionToolsComponent,WorkingAreaComponent,CreateBuilding,EditBuilding,leftFunctionalDomainComponent,editPlaneFigureComponent,ViewDetails,saveOneDialog,saveTwoDialog,addDisposalNodeComponent,editDisposalNodeComponent,CollectionToolsPlanComponent,CreateBuildingPlan,EditBuildingPlan,ViewDetailsPlan,leftFunctionalDomainComponentPlan,editPlaneFigureComponentPlan,addDisposalNodeComponentPlan,editDisposalNodeComponentPlan,saveOneDialogPlan,saveTwoDialogPlan,addOffices,editOffices,addBGCDisposalNodeComponent], + declarations: [UiComponent, DateselectComponent, MenuComponent, CardComponent, ListComponent, GridComponent, StepperComponent, TabgroupComponent, ButtonComponent, BadgeComponent, ProgressComponent, SnackbarComponent,PersonaldataComponent, FooterComponent, UserdataComponent, ChangepasswordComponent, OrganizationComponent, UnittypeComponent, AuthorityComponent, RoleComponent, UsermanagementComponent,IsnoPipe,ConfirmpswDirective,DialogOverviewExampleDialog,CreateAuthority,CreateRole,TimePipe,CreateNewUser,EditNewUser,allRoles,EditRole,CreateOrganization,EditOrganization,seeInformation,EditUser,editorialUnit,FireProtectionElementsComponent,Establish,EditingFireControl,FireFightingTemplateComponent, NavmenusComponent,CreateMenus,EditMenus,NewFireFighting,EditFireClassification, MaterialBankComponent, UnitInformationComponent,AddMatLibrary,EditMatLibrary,attributeComponent,AddOriginalCopy,addAttributeComponent,editAttribute,EditOriginalCopy,SelectOriginalCopy,EditUnitInfo,AddUnitInfo,AddGroups,EditGroup, EnterpriseuserComponent,AddEnterpriserUser,addUnitAttributeComponent,editUnitAttribute,seeenterpriseuser,editenterpriseuser, FireFightingFacilitiesFormworkComponent,addFireFightingFacilitiesFormworkComponent,editFireFightingFacilitiesFormworkComponent,addBuiltInComponent,addBuiltInAttributeComponent,addOptionalComponent,addOptionalAttributeComponent,editBuiltInAttributeComponent,editOptionalAttributeComponent, CollectionToolsComponent,WorkingAreaComponent,CreateBuilding,EditBuilding,leftFunctionalDomainComponent,editPlaneFigureComponent,ViewDetails,saveOneDialog,saveTwoDialog,addDisposalNodeComponent,editDisposalNodeComponent,CollectionToolsPlanComponent,CreateBuildingPlan,EditBuildingPlan,ViewDetailsPlan,leftFunctionalDomainComponentPlan,editPlaneFigureComponentPlan,addDisposalNodeComponentPlan,editDisposalNodeComponentPlan,saveOneDialogPlan,saveTwoDialogPlan,addOffices,editOffices,addBGCDisposalNodeComponent,CollectionToolsBuildingComponent,CreateBuildingBuilding,EditBuildingBuilding,ViewDetailsBuilding,leftFunctionalDomainBuildingComponent,editPlaneFigureBuildingComponent,addDisposalNodeBuildingComponent,editDisposalNodeBuildingComponent,saveOneDialogBuilding,saveTwoDialogBuilding], imports: [ CommonModule, @@ -155,6 +158,7 @@ import { saveOneDialogPlan, saveTwoDialogPlan } from './collection-tools-plan/sa exports:[ FooterComponent, CollectionToolsComponent, + CollectionToolsBuildingComponent, CollectionToolsPlanComponent ] }) From deca37772c8b92aae8b2d5c612ef0a74d2aa73d5 Mon Sep 17 00:00:00 2001 From: cpf <1105965053@qq.com> Date: Tue, 26 Jan 2021 11:02:05 +0800 Subject: [PATCH 7/7] =?UTF-8?q?[=E5=88=A0=E9=99=A4]=20=E4=BD=9C=E6=88=98?= =?UTF-8?q?=E9=83=A8=E7=BD=B2=E5=88=A0=E9=99=A4=20=E5=9F=BA=E6=9C=AC?= =?UTF-8?q?=E4=BF=A1=E6=81=AF=E6=A8=A1=E5=9D=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../collection-tools.component.ts | 2 - .../collection-tools.component.html | 44 +++---------------- .../collection-tools.component.scss | 19 ++++---- .../collection-tools.component.ts | 26 ++++++----- 4 files changed, 30 insertions(+), 61 deletions(-) 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 0fe2b71..d4b9d0b 100644 --- a/src/app/ui/collection-tools-plan/collection-tools.component.ts +++ b/src/app/ui/collection-tools-plan/collection-tools.component.ts @@ -659,7 +659,6 @@ export class CollectionToolsPlanComponent implements OnInit { this.canvas.on("select",obj=>{ //选中素材属性注入函数 this.setAssetsProperty(obj.assetData) - console.log(obj.assetData) }) // 监听canvas组件取消选中素材事件 this.canvas.on("deselect",obj=>{ @@ -760,7 +759,6 @@ export class CollectionToolsPlanComponent implements OnInit { }else{ //如果是单位 总平面图 if(this.checkedBuildingIndex==-1){ - // console.log(111,SitePlanData) //保存平面图数据 this.http.post("/api/SitePlanData",SitePlanData,{ params:{ diff --git a/src/app/ui/collection-tools/collection-tools.component.html b/src/app/ui/collection-tools/collection-tools.component.html index ac990f4..be34123 100644 --- a/src/app/ui/collection-tools/collection-tools.component.html +++ b/src/app/ui/collection-tools/collection-tools.component.html @@ -18,7 +18,7 @@ 多选 --> - 显示图例 + 显示图例 -
- - 基本信息编辑 - - - 想定作业编辑 - -
- - - - -
- - -
- - - - - -
+
- keyboard_arrow_right - keyboard_arrow_left 天气 气温
- - + +
风力 +
+
diff --git a/src/app/ui/collection-tools/collection-tools.component.scss b/src/app/ui/collection-tools/collection-tools.component.scss index af88cc7..1d5a3de 100644 --- a/src/app/ui/collection-tools/collection-tools.component.scss +++ b/src/app/ui/collection-tools/collection-tools.component.scss @@ -60,10 +60,10 @@ } } .rightSave { + margin: 0 10px; cursor: pointer; - position: absolute; - right: 60px; - label { vertical-align: middle; color: #279FFF; } + vertical-align: middle; + color: #279FFF; } } @@ -113,7 +113,7 @@ top: 0; } .functionalDomain { - flex: 90%; + flex: 95%; overflow: hidden; .functionalDomainContent { position: relative; @@ -409,19 +409,16 @@ div:focus { } .bigBox{ - width: 700px; + width: 650px; height: 40px; + line-height: 40px; position: absolute; overflow: hidden; right: 0; + top: 0; } .weatherBox{ - height: 40px; - width: 700px; - line-height: 40px; - position: absolute; - right: 0; - transition: right linear .5s; + width: 100%; .openbtn{ font-size: 45px; height: 45px; diff --git a/src/app/ui/collection-tools/collection-tools.component.ts b/src/app/ui/collection-tools/collection-tools.component.ts index ec74a0b..db6d785 100644 --- a/src/app/ui/collection-tools/collection-tools.component.ts +++ b/src/app/ui/collection-tools/collection-tools.component.ts @@ -145,7 +145,7 @@ export class CollectionToolsComponent implements OnInit { this.isImgNumCss = false } } - pattern:boolean = true//默认为基本信息编辑 + pattern:boolean = false//默认为基本信息编辑 //基本信息编辑模式 @@ -625,7 +625,7 @@ export class CollectionToolsComponent implements OnInit { isxxx = true //控制查看编辑模式的编辑模式按钮 ngOnInit(): void { - + this.canvasData.gameMode = GameMode.Assignment if(this.router.url.indexOf("keyUnit/viewunitinfoplan") == -1 && this.router.url.indexOf("keyUnit/viewunitinfo") != -1 || this.router.url.indexOf("keyUnit/editplaninfo")!= -1){ this.isSixbtn = false } @@ -643,7 +643,7 @@ export class CollectionToolsComponent implements OnInit { this.isxxx = false } - this.getAllLibrary() //获取素材库 + this.getAllLibrary('plan') //获取素材库 this.getAllBuildings() //获取所有建筑 this.getAllFirePlan() //获取当前单位灾情 @@ -666,7 +666,7 @@ export class CollectionToolsComponent implements OnInit { ngAfterViewInit(): void { - + this.getSitePlan() // 监听canvas组件选中素材事件 this.canvas.on("select",obj=>{ @@ -680,7 +680,7 @@ export class CollectionToolsComponent implements OnInit { //监听数据变化后 this.canvas.on('canvasDataChanged',()=>{ // 收到数据表示共享数据发生变化 - this.renovateTreeData(false) + this.canvasData.selectPanelPoint.BackgroundImageUrl? this.customizeNodes() : this.renovateTreeData(false) }); } @@ -695,10 +695,10 @@ export class CollectionToolsComponent implements OnInit { let buildingId = this.beforeOneCheckedBuilding.id let floorId = this.selectingSitePlan.id this.canvas.paste(companyId,buildingId,floorId) - this.renovateTreeData(false) + this.canvasData.selectPanelPoint.BackgroundImageUrl? this.customizeNodes() : this.renovateTreeData(false) } - basicInfo:boolean = true //基本信息名称显隐 + basicInfo:boolean = false //基本信息名称显隐 wantToWork:boolean = true //想定作业名称显隐 //点击基本信息名称 basicInfoClick(){ @@ -1239,7 +1239,6 @@ export class CollectionToolsComponent implements OnInit { }); this.dataSource.data = treeData this.treeControl.expandAll() - } //点击树节点 @@ -1375,6 +1374,7 @@ export class CollectionToolsComponent implements OnInit { isRefresh? await this.canvas.refresh() : null this.canvas.setNameVisible(this.basicInfo,0) this.canvas.setNameVisible(this.wantToWork,1) + this.canvas.setLegendVisible(this.isShowLegend) //图例显隐 isRefresh? this.canvasData.isChange = false : null //服务中 数据是否改动 改为false isRefresh? this.isShowProperty = true : null isRefresh? this.isShowAttribute = true : null @@ -1392,7 +1392,7 @@ export class CollectionToolsComponent implements OnInit { } for(let key in storeyData.data){ //筛选数据 没有匹配全部放入到 其他 数组 let noMatch = this.allFireElements.find( every=> every.id===storeyData.data[key].FireElementId ) - if (!noMatch) { + if (!noMatch && storeyData.data[key].Id != "图例") { this.allFireElements[this.allFireElements.length-1].children.push(storeyData.data[key]) } } @@ -1400,7 +1400,7 @@ export class CollectionToolsComponent implements OnInit { if(selectPanelPoint.Data){ for(let key in selectPanelPoint.Data.Stock){ //筛选数据 没有匹配全部放入到 其他 数组 let noMatch = this.allFireElements.find( every=> every.id===selectPanelPoint.Data.Stock[key].FireElementId ) - if (!noMatch) { + if (!noMatch && selectPanelPoint.Data.Stock[key].Id != "图例") { this.allFireElements[this.allFireElements.length-1].children.push(selectPanelPoint.Data.Stock[key]) } } @@ -1427,6 +1427,9 @@ export class CollectionToolsComponent implements OnInit { beforeOneCheckedBuildingIsShow:boolean = false; //想定作业下 建筑是否显示 togglebeforeOneCheckedBuilding () { this.beforeOneCheckedBuildingIsShow = !this.beforeOneCheckedBuildingIsShow } + isShowLegend:boolean = true; //图例是否显示 + changeLegend (e) { this.canvasData.selectPanelPoint.BackgroundImageUrl? null : this.canvas.setLegendVisible(this.isShowLegend) } + //可展开面板展开或关闭 toggle () { this.toggleExpandPanel = !this.toggleExpandPanel @@ -1961,6 +1964,7 @@ export class CollectionToolsComponent implements OnInit { let params = {disasterId: this.allFirePlan[0].id || ''} this.http.get('/api/DisposalNodes',{params:params}).subscribe(data=>{ //所有处置节点 this.canvasData.allDisposalNode = data + this.getDisposalNode() }) }) } else { //单位 有灾情时 @@ -1968,6 +1972,7 @@ export class CollectionToolsComponent implements OnInit { let params = {disasterId: this.allFirePlan[0].id || ''} this.http.get('/api/DisposalNodes',{params:params}).subscribe(data=>{ //所有处置节点 this.canvasData.allDisposalNode = data + this.getDisposalNode() }) } }) @@ -2265,6 +2270,7 @@ export class CollectionToolsComponent implements OnInit { this.allFireElements = [other] this.canvas.setNameVisible(this.basicInfo,0) this.canvas.setNameVisible(this.wantToWork,1) + // this.canvas.setLegendVisible(this.isShowLegend) //图例显隐 this.beforeOneCheckedBuildingIsShow = false let selectPanelPoint = JSON.parse(JSON.stringify(this.canvasData.selectPanelPoint || {} )) //当前 节点 数据