diff --git a/src/app/ui/collection-tools-building/collection-tools.component.html b/src/app/ui/collection-tools-building/collection-tools.component.html index b2d0bbf..cb25215 100644 --- a/src/app/ui/collection-tools-building/collection-tools.component.html +++ b/src/app/ui/collection-tools-building/collection-tools.component.html @@ -35,6 +35,7 @@ 重置缩放 + diff --git a/src/app/ui/collection-tools-building/collection-tools.component.ts b/src/app/ui/collection-tools-building/collection-tools.component.ts index fc5c389..99717c6 100644 --- a/src/app/ui/collection-tools-building/collection-tools.component.ts +++ b/src/app/ui/collection-tools-building/collection-tools.component.ts @@ -1,15 +1,15 @@ -import { Component, OnInit, Inject, ViewChild,ElementRef,Renderer2, ViewContainerRef } from '@angular/core'; +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} 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 { leftFunctionalDomainBuildingComponent, editPlaneFigureBuildingComponent } 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 { NzFormatBeforeDropEvent, NzFormatEmitEvent,NzTreeComponent } from 'ng-zorro-antd/tree'; +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'; @@ -24,9 +24,9 @@ import { AxMessageSystem } from 'src/app/working-area/model/axMessageSystem'; }) export class CollectionToolsBuildingComponent implements OnInit { - @ViewChild('canvas',{static: true}) canvas:WorkingAreaComponent; //父组件中获得子组件的引用 + @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) { } + 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) => {//要给渲染节点传那些属性参数 @@ -35,36 +35,36 @@ export class CollectionToolsBuildingComponent implements OnInit { 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 + 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'] + 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//是否高亮选择框 + 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 = [] //属性中的图片链接集合 @@ -73,28 +73,28 @@ export class CollectionToolsBuildingComponent implements OnInit { //传入素材对象,设置右侧属性栏内容 canvasAssetObj //传入的素材属性对象 isImgNumCss = false //控制上传文件input显隐 - mySwiper:any //轮播图实例 + mySwiper: any //轮播图实例 gallery//viewerJs实例 //设置属性框 - setAssetsProperty(obj){ + setAssetsProperty(obj) { //初始化viewerJs实例 setTimeout(() => { obj.PropertyInfos.forEach(item => { - if(item.PropertyType == 4){ - if(document.getElementById('viewerjs')){ - this.gallery = new Viewer(document.getElementById('viewerjs'),{ + if (item.PropertyType == 4) { + if (document.getElementById('viewerjs')) { + 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) + let strh = color.substring(color.length - 2, color.length) + let opacity = Math.round(parseInt(strh, 16) / 255 * 100) this.colorDivSliderValue = opacity this.isShowProperty = true @@ -113,18 +113,18 @@ export class CollectionToolsBuildingComponent implements OnInit { this.PropertyInfos = obj.PropertyInfos this.sliderValueThickness = obj.Thickness this.PropertyInfos.forEach(item => { - if(item.PropertyType == 3){ //如果是图片链接类型 + if (item.PropertyType == 3) { //如果是图片链接类型 this.imagesArr.push(item) } - if(item.PropertyType == 4){//图片数值上线 + if (item.PropertyType == 4) {//图片数值上线 this.imagesArrNum = item.PropertyValue } }) //如果存在图片则加载轮播图 - if(this.imagesArr.length){ + if (this.imagesArr.length) { setTimeout(() => { - this.mySwiper = new Swiper('.swiper-container',{ + this.mySwiper = new Swiper('.swiper-container', { loop: false, // grabCursor: true, // 如果需要前进后退按钮 @@ -132,8 +132,8 @@ export class CollectionToolsBuildingComponent implements OnInit { nextEl: '.swiper-button-next', prevEl: '.swiper-button-prev', }, - on:{ - click: function(){ + on: { + click: function () { _this.clickedIndex = this.clickedIndex }, } @@ -141,16 +141,16 @@ export class CollectionToolsBuildingComponent implements OnInit { }, 0); } //判断此时图片数量是否达到上限 - if(this.imagesArr.length < this.imagesArrNum){//如果不超出 + if (this.imagesArr.length < this.imagesArrNum) {//如果不超出 this.isImgNumCss = true - }else{ + } else { this.isImgNumCss = false } } - pattern:boolean = true//默认为基本信息编辑 - + pattern: boolean = true//默认为基本信息编辑 + //基本信息编辑模式 - baseInfo(){ + baseInfo() { if (!this.pattern) { this.pattern = true this.canvasData.gameMode = GameMode.BasicInformation @@ -163,7 +163,7 @@ export class CollectionToolsBuildingComponent implements OnInit { } //想定作业编辑模式 - wantWork(){ + wantWork() { if (this.pattern) { this.pattern = false this.canvasData.gameMode = GameMode.Assignment @@ -172,117 +172,117 @@ export class CollectionToolsBuildingComponent implements OnInit { } } //适应缩放 - adaptZoom(){ + adaptZoom() { this.canvas.zoomFit() } //重置缩放 - resetZoom(){ + resetZoom() { this.canvas.resetCamera2D() } //ngzorro tree 拖拽 nzEvent(event: NzFormatEmitEvent): void { - if(this.isDrag){ - let parentId - if(this.pos == 0){ + if (this.isDrag) { + let parentId + if (this.pos == 0) { parentId = event.node.key - }else{ - if(event.node.level == 0){ + } else { + if (event.node.level == 0) { parentId = null - }else{ + } else { parentId = event.node.origin.parentId } } - + let orders = {} - let originalData = JSON.parse(JSON.stringify( this.canvasData.allDisposalNode || [] )) //tree原始数据 + let originalData = JSON.parse(JSON.stringify(this.canvasData.allDisposalNode || [])) //tree原始数据 let targetNodeData = []//拖动移入节点的数据,用于遍历求出放在该数组的第几位 //找到需要重新排序的数组 - if(this.pos == 0){ + if (this.pos == 0) { originalData.forEach(item => { - if(item.parentId == event.node.key){ + if (item.parentId == event.node.key) { targetNodeData.push(item) } }) - }else{ - if(event.node.origin.parentId){//如果拖动目标为非一级节点 + } else { + if (event.node.origin.parentId) {//如果拖动目标为非一级节点 originalData.forEach(item => { - if(item.parentId == event.node.origin.parentId){ + if (item.parentId == event.node.origin.parentId) { targetNodeData.push(item) } }) - }else{//如果拖动目标为一级节点 + } else {//如果拖动目标为一级节点 originalData.forEach(item => { - if(!item.parentId){ + 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 + if (this.pos == 0 && event.node.origin.children.length == 1) { + let key = event.dragNode.key orders[key] = 0 parentId = event.node.key - }else{ + } else { let array = [] targetNodeData.forEach(item => { - if(item.id != event.dragNode.key){ //将拖动项先移除掉 + if (item.id != event.dragNode.key) { //将拖动项先移除掉 array.push(item) } }) - if(event.dragNode.isEnd[event.dragNode.isEnd.length - 1]){ //如果移入到最后一个 + if (event.dragNode.isEnd[event.dragNode.isEnd.length - 1]) { //如果移入到最后一个 array.push(event.dragNode.origin) - }else if(event.dragNode.isStart[event.dragNode.isStart.length - 1]){//如果移入到第一个 + } else if (event.dragNode.isStart[event.dragNode.isStart.length - 1]) {//如果移入到第一个 array.unshift(event.dragNode.origin) - }else{//如果移入中间位置 + } else {//如果移入中间位置 array.splice(event.node.origin.order, 0, event.dragNode.origin) } - array.forEach((item,key) => { + array.forEach((item, key) => { orders[item.id] = key }) } - - let obj ={ - id : event.dragNode.origin.id, - parentId : parentId, - orders : orders + + let obj = { + id: event.dragNode.origin.id, + parentId: parentId, + orders: orders } - - this.http.put("/api/DisposalNodes/Sort",obj).subscribe(data => { + + this.http.put("/api/DisposalNodes/Sort", obj).subscribe(data => { const config = new MatSnackBarConfig(); config.verticalPosition = 'top'; config.duration = 3000 - this.snackBar.open('排序成功','确定',config) + this.snackBar.open('排序成功', '确定', config) this.refurbishTreeData() }) } } - + isDrag //是否可以拖动 pos//放置位置 beforeDrop = (arg: NzFormatBeforeDropEvent) => { - if(arg.dragNode.origin.isDataNode && arg.node.level === 0){//如果为数据节点则不允许拖到一级节点 + if (arg.dragNode.origin.isDataNode && arg.node.level === 0) {//如果为数据节点则不允许拖到一级节点 const config = new MatSnackBarConfig(); config.verticalPosition = 'top'; config.duration = 3000 - this.snackBar.open('数据节点不允许拖拽到一级节点','确定',config) + this.snackBar.open('数据节点不允许拖拽到一级节点', '确定', config) this.isDrag = false return of(false); - }else if(!arg.dragNode.origin.isDataNode && arg.node.level === 2){ + } 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.snackBar.open('处置节点不允许拖拽到三级节点', '确定', config) this.isDrag = false return of(false); - }else{ + } else { this.isDrag = true this.pos = arg.pos return of(true) @@ -292,35 +292,35 @@ export class CollectionToolsBuildingComponent implements OnInit { //天气栏目 weatherBtn = true - weatherBtnShow(){ + weatherBtnShow() { this.weatherBtn = !this.weatherBtn } - weatherBtnHidden(){ + weatherBtnHidden() { this.weatherBtn = !this.weatherBtn } //底部切换按钮div detailsAndattentBtn = true //节点详情 - details(){ + details() { this.detailsAndattentBtn = true } //注意事项 - attent(){ + attent() { this.detailsAndattentBtn = false } //消防要素div边框高度调节 - firecategoriesDivMouseDown(e){ + 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' + 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 = () => { @@ -330,13 +330,13 @@ export class CollectionToolsBuildingComponent implements OnInit { } //左侧div边框宽度调节 - leftDivMouseDown(e){ + 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){ + if (ev.clientX - 240 >= maxWidth) { this.element.nativeElement.querySelector('#leftDiv').style.width = maxWidth + 'px' - }else{ + } else { this.element.nativeElement.querySelector('#leftDiv').style.width = ev.clientX - 260 + 'px'; } } @@ -347,14 +347,14 @@ export class CollectionToolsBuildingComponent implements OnInit { } //底部div高度调节 - bottomDivMouseDown(e){ + 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' ; + 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 = () => { @@ -364,13 +364,13 @@ export class CollectionToolsBuildingComponent implements OnInit { } //右侧div边框宽度调节 - rightDivMouseDown(e){ + 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){ + if (bodyWidth - ev.clientX >= maxWidth) { this.element.nativeElement.querySelector('#rightDiv').style.width = maxWidth + 'px' - }else{ + } else { this.element.nativeElement.querySelector('#rightDiv').style.width = bodyWidth - ev.clientX + 'px'; } } @@ -381,50 +381,50 @@ export class CollectionToolsBuildingComponent implements OnInit { } //放大图标 - iconScale(){ + iconScale() { let number = Number(this.selected) this.canvas.setIconScale(number) } //素材宽度输入框改变 - assetWidthIunput(){ + assetWidthIunput() { this.canvasAssetObj.Width = this.assetWidth this.canvasData.isChange = true this.canvas.refreshIcon(this.canvasAssetObj.Id) } //素材高度输入框改变 - assetHeightIunput(){ + assetHeightIunput() { this.canvasAssetObj.Height = this.assetHeight this.canvasData.isChange = true this.canvas.refreshIcon(this.canvasAssetObj.Id) } //素材角度输入框改变 - assetAngleIunput(){ + assetAngleIunput() { this.canvasAssetObj.Angle = this.sliderValue this.canvasData.isChange = true this.canvas.refreshIcon(this.canvasAssetObj.Id) } //素材厚度输入框改变 - assetThicknessIunput(){ + assetThicknessIunput() { this.canvasAssetObj.Thickness = this.sliderValueThickness this.canvasData.isChange = true this.canvas.refreshIcon(this.canvasAssetObj.Id) } //素材是否高亮改变----->本地操作行为 - assetHighLightIunput(){ + assetHighLightIunput() { } //动态属性素材input框值改变 - assetInputChange(i,e){ - let index = this.canvasAssetObj.PropertyInfos.findIndex((item)=>{ + assetInputChange(i, e) { + let index = this.canvasAssetObj.PropertyInfos.findIndex((item) => { return i.PropertyName == item.PropertyName }) - if(this.myIsNaN(e.target.value)){ + if (this.myIsNaN(e.target.value)) { e.target.value = String(e.target.value) } this.canvasAssetObj.PropertyInfos[index].PropertyValue = e.target.value @@ -436,8 +436,8 @@ export class CollectionToolsBuildingComponent implements OnInit { return typeof value === 'number' && !isNaN(value); } //动态属性素材布尔值框改变radio - assetRadioChange(i,boolean){ - let index = this.canvasAssetObj.PropertyInfos.findIndex((item)=>{ + assetRadioChange(i, boolean) { + let index = this.canvasAssetObj.PropertyInfos.findIndex((item) => { return i.PropertyName == item.PropertyName }) this.canvasAssetObj.PropertyInfos[index].PropertyValue = boolean @@ -447,35 +447,35 @@ export class CollectionToolsBuildingComponent implements OnInit { colorIndex//默认素材颜色 selectedcolor//点击选择的颜色 //选择素材颜色 - selectcolor(item,key){ + selectcolor(item, key) { //在当前透明度基础上改变颜色 - this.selectedcolor = item + this.selectedcolor.substring(this.selectedcolor.length-2) + 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) + 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; + 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.selectedcolor = replacepos(this.selectedcolor, 7, 8, colorOpacity.toString(16)) this.canvasAssetObj.Color = this.selectedcolor this.canvasData.isChange = true this.canvas.refreshIcon(this.canvasAssetObj.Id) } //上传素材图片 - selectFile(e){ + selectFile(e) { let imgFile = e.target.files[0] || null //上传的文件 this.startUploading(imgFile) } - objectName:any //上传对象名 - startUploading (imgFile) { + objectName: any //上传对象名 + startUploading(imgFile) { let _this = this let file = imgFile || null //获取上传的文件 let fileSize = file.size || null //上传文件的总大小 @@ -483,13 +483,13 @@ export class CollectionToolsBuildingComponent implements OnInit { 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)=>{ + 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) + this.snackBar.open('上传成功', '确定', config) //在原始素材对象和需要循环图片的对象中分别push最新上传的图片 let imgObj = { @@ -505,12 +505,12 @@ export class CollectionToolsBuildingComponent implements OnInit { "PropertyType": 3, "PropertyValue": "/api/Objects/WebPlan2D/" + this.objectName } - + this.imagesArr.push(imgObj) this.canvasAssetObj.PropertyInfos.push(imgObj) setTimeout(() => { - this.mySwiper = new Swiper('.swiper-container',{ + this.mySwiper = new Swiper('.swiper-container', { loop: false, // grabCursor: true, // 如果需要前进后退按钮 @@ -518,8 +518,8 @@ export class CollectionToolsBuildingComponent implements OnInit { nextEl: '.swiper-button-next', prevEl: '.swiper-button-prev', }, - on:{ - click: function(){ + on: { + click: function () { _this.clickedIndex = this.clickedIndex }, } @@ -528,44 +528,44 @@ export class CollectionToolsBuildingComponent implements OnInit { this.mySwiper.slideTo(this.imagesArr.length - 1) this.gallery.update() }, 0); - + //判断上传素材属性图片是否超出数量 超出数量则隐藏input框 - if(this.imagesArr.length < this.imagesArrNum){//不超出input才会显示 + if (this.imagesArr.length < this.imagesArrNum) {//不超出input才会显示 this.isImgNumCss = true - }else{ + } else { this.isImgNumCss = false } - + this.canvasData.isChange = true }) - } else if (file && fileSize>shardSize) { //上传文件>5MB时,分块上传 + } else if (file && fileSize > shardSize) { //上传文件>5MB时,分块上传 let config = new MatSnackBarConfig(); config.verticalPosition = 'top'; config.duration = 3000 - this.snackBar.open('上传图片文件不允许大于5mb','确定',config); + this.snackBar.open('上传图片文件不允许大于5mb', '确定', config); } } //不能上传图片提示 - imgNumBeyond(){ + imgNumBeyond() { const config = new MatSnackBarConfig(); config.verticalPosition = 'top'; config.duration = 3000 - this.snackBar.open('图片数量已达上限','确定',config); + this.snackBar.open('图片数量已达上限', '确定', config); } //删除素材属性图片 - deleteImg(){ - if(this.imagesArr.length == 0){ + deleteImg() { + if (this.imagesArr.length == 0) { const config = new MatSnackBarConfig(); config.verticalPosition = 'top'; config.duration = 3000 - this.snackBar.open('没有可删除的图片,请先上传','确定',config) - }else{ + this.snackBar.open('没有可删除的图片,请先上传', '确定', config) + } else { // 在素材原始对象中将删除的图片去掉 - this.canvasAssetObj.PropertyInfos = [...this.canvasAssetObj.PropertyInfos.filter((item)=>{ - return item.PropertyValue != this.imagesArr[this.mySwiper.activeIndex].PropertyValue + this.canvasAssetObj.PropertyInfos = [...this.canvasAssetObj.PropertyInfos.filter((item) => { + return item.PropertyValue != this.imagesArr[this.mySwiper.activeIndex].PropertyValue })] //在图片循环数组中将图片去掉 this.imagesArr.splice(this.mySwiper.activeIndex, 1); @@ -578,7 +578,7 @@ export class CollectionToolsBuildingComponent implements OnInit { //将上传的input框显示出来 this.isImgNumCss = true; //清除图片缓存 - if((document.getElementById('inputimg'))){ + if ((document.getElementById('inputimg'))) { (document.getElementById('inputimg')).value = null //清空input框缓存 } @@ -587,8 +587,8 @@ export class CollectionToolsBuildingComponent implements OnInit { } //动态属性方向select选择框 - direction(i,e){ - let index = this.canvasAssetObj.PropertyInfos.findIndex((item)=>{ + direction(i, e) { + let index = this.canvasAssetObj.PropertyInfos.findIndex((item) => { return i.PropertyName == item.PropertyName }) this.canvasAssetObj.PropertyInfos[index].PropertyValue = e.target.value @@ -596,8 +596,8 @@ export class CollectionToolsBuildingComponent implements OnInit { } //动态属性供给区域select选择框 - supplyArea(i,e){ - let index = this.canvasAssetObj.PropertyInfos.findIndex((item)=>{ + supplyArea(i, e) { + let index = this.canvasAssetObj.PropertyInfos.findIndex((item) => { return i.PropertyName == item.PropertyName }) this.canvasAssetObj.PropertyInfos[index].PropertyValue = e.target.value @@ -605,8 +605,8 @@ export class CollectionToolsBuildingComponent implements OnInit { } //动态属性供给类型select选择框 - supplyType(i,e){ - let index = this.canvasAssetObj.PropertyInfos.findIndex((item)=>{ + supplyType(i, e) { + let index = this.canvasAssetObj.PropertyInfos.findIndex((item) => { return i.PropertyName == item.PropertyName }) this.canvasAssetObj.PropertyInfos[index].PropertyValue = e.target.value @@ -616,62 +616,62 @@ export class CollectionToolsBuildingComponent implements OnInit { isediticon = true //控制查看编辑模式的编辑模式小笔按钮 - isMultipleAsset:boolean = false//框选多个素材属性显隐 - multipleAsset:any = { - Width:null, - Height:null, - Angle:null, - Thickness:null, - Color:null, - PropertyInfos:[] + isMultipleAsset: boolean = false//框选多个素材属性显隐 + multipleAsset: any = { + Width: null, + Height: null, + Angle: null, + Thickness: null, + Color: null, + PropertyInfos: [] }//多个素材共同属性 - multipleAssetData:any//当前多选的素材 - firstMultipleAssetData:any//当前多选的第一个素材 + multipleAssetData: any//当前多选的素材 + firstMultipleAssetData: any//当前多选的第一个素材 ngOnInit(): void { let _this = this - AxMessageSystem.addListener('selectionChanged', ()=>{ - if(this.canvas.selection.size() == 1){//如果是单选 + AxMessageSystem.addListener('selectionChanged', () => { + if (this.canvas.selection.size() == 1) {//如果是单选 this.isMultipleAsset = false this.setAssetsProperty(this.canvas.selection.first().assetData) - }else if(this.canvas.selection.size()){ + } else if (this.canvas.selection.size()) { this.isShowProperty = true this.multipleAssetData = this.canvas.selection.all() this.firstMultipleAssetData = this.canvas.selection.first() this.multipleAsset = { - Width:null, - Height:null, - Angle:null, - Thickness:null, - Color:null, - PropertyInfos:[] + Width: null, + Height: null, + Angle: null, + Thickness: null, + Color: null, + PropertyInfos: [] } this.isMultipleAsset = true let firstAssetData = this.canvas.selection.first().assetData;//拿出第一个素材作为例子与其他素材进行对比 let InteractiveMode = firstAssetData.InteractiveMode //素材连接方式 let isInteractiveMode = this.canvas.selection.all().every(item => item.assetData.InteractiveMode === InteractiveMode) - if(isInteractiveMode){ + if (isInteractiveMode) { this.multipleAsset.InteractiveMode = InteractiveMode } let isFillMode = this.canvas.selection.all().every(item => item.assetData.FillMode === 0) //素材填充方式都为0 - if(isFillMode){ + if (isFillMode) { this.multipleAsset.FillMode = 0 } this.canvas.selection.first().assetData.PropertyInfos.forEach(i => { let index = 0 this.canvas.selection.all().forEach(item => { item.assetData.PropertyInfos.forEach(element => { - if(element.PropertyName == i.PropertyName && element.PropertyType == i.PropertyType && element.PropertyType != 3 && element.PropertyType != 4){ + if (element.PropertyName == i.PropertyName && element.PropertyType == i.PropertyType && element.PropertyType != 3 && element.PropertyType != 4) { index++ - if(index == this.canvas.selection.size()){ + if (index == this.canvas.selection.size()) { let newElement = JSON.parse(JSON.stringify(element)) newElement.PropertyValue = '' this.multipleAsset.PropertyInfos.push(newElement) } } }); - }) + }) }) - }else if(this.canvas.selection.size() == 0){ + } else if (this.canvas.selection.size() == 0) { this.isShowProperty = false } }, this) @@ -679,16 +679,16 @@ export class CollectionToolsBuildingComponent implements OnInit { this.assetWidth = args1.Width this.assetHeight = args1.Height }, this) - if(this.router.url.indexOf("keyUnit/viewunitinfo") != -1){ //查看模式 + if (this.router.url.indexOf("keyUnit/viewunitinfo") != -1) { //查看模式 this.isEditPattern = false this.isediticon = false this.canvasData.gameMode = GameMode.Assignment - } else if (this.router.url.indexOf("keyUnit/editplaninfo")!= -1) { //编辑模式 + } else if (this.router.url.indexOf("keyUnit/editplaninfo") != -1) { //编辑模式 this.canvasData.gameMode = GameMode.BasicInformation } //gis模块平面图 - if(this.router.url.indexOf("gis") != -1 && sessionStorage.getItem("gisplan") == "look"){ + if (this.router.url.indexOf("gis") != -1 && sessionStorage.getItem("gisplan") == "look") { this.isEditPattern = false this.isediticon = false this.canvasData.gameMode = GameMode.Assignment @@ -697,7 +697,7 @@ export class CollectionToolsBuildingComponent implements OnInit { } let that = this - window.setTimeout(()=>{ + window.setTimeout(() => { document.getElementById("functionalDomainContentTwo").oncontextmenu = function (event) { // that.canvas.cancelPaint() that.selectImageIndex = -1 @@ -705,78 +705,78 @@ export class CollectionToolsBuildingComponent implements OnInit { }; }) - this.canvasData.getMessage().subscribe((message: any)=>{ - if(message == "send a message"){ + this.canvasData.getMessage().subscribe((message: any) => { + if (message == "send a message") { this.refurbishTreeData() } }) } //多选宽度共同改变 - multipleAssetWidthInput(){ - this.multipleAssetData.forEach(item=>{ + multipleAssetWidthInput() { + this.multipleAssetData.forEach(item => { item.assetData.Width = this.multipleAsset.Width this.canvas.refreshIcon(item.assetData.Id) this.canvasData.isChange = true }) } //多选高度共同改变 - multipleAssetHeightInput(){ - this.multipleAssetData.forEach(item=>{ + multipleAssetHeightInput() { + this.multipleAssetData.forEach(item => { item.assetData.Height = this.multipleAsset.Height this.canvas.refreshIcon(item.assetData.Id) this.canvasData.isChange = true }) } //多选角度共同改变 - multipleAssetAngleInput(){ - this.multipleAssetData.forEach(item=>{ + multipleAssetAngleInput() { + this.multipleAssetData.forEach(item => { item.assetData.Angle = this.multipleAsset.Angle this.canvas.refreshIcon(item.assetData.Id) this.canvasData.isChange = true }) } //多选厚度共同改变 - multipleAssetThicknessInput(){ - this.multipleAssetData.forEach(item=>{ + multipleAssetThicknessInput() { + this.multipleAssetData.forEach(item => { item.assetData.Thickness = this.multipleAsset.Thickness this.canvas.refreshIcon(item.assetData.Id) this.canvasData.isChange = true }) } //多选颜色共同改变 - multipleSelectedcolor:any - multipleAssetSelectcolor(item,key){ + multipleSelectedcolor: any + multipleAssetSelectcolor(item, key) { //在当前透明度基础上改变颜色 this.multipleSelectedcolor = item - this.multipleAssetData.forEach(item=>{ + this.multipleAssetData.forEach(item => { item.assetData.Color = this.multipleSelectedcolor this.canvasData.isChange = true this.canvas.refreshIcon(item.assetData.Id) }) } //多选颜色滑竿改变 - multipleColorDivSliderChange(){ - let colorOpacity = Math.round(255 * this.colorDivSliderValue * 0.01) + multipleColorDivSliderChange() { + 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); + function replacepos(text, start, stop, replacetext) { + let mystr = text.substring(0, stop - 1) + replacetext + text.substring(stop + 1); return mystr; } - this.multipleAssetData.forEach(item=>{ - this.multipleSelectedcolor = replacepos(this.multipleSelectedcolor,7,8,colorOpacity.toString(16)) + this.multipleAssetData.forEach(item => { + this.multipleSelectedcolor = replacepos(this.multipleSelectedcolor, 7, 8, colorOpacity.toString(16)) item.assetData.Color = this.multipleSelectedcolor this.canvasData.isChange = true this.canvas.refreshIcon(item.assetData.Id) }) } //多选状态动态属性素材input框值改变 - multipleAssetInputChange(i,e){ + multipleAssetInputChange(i, e) { e.stopPropagation() - this.multipleAssetData.forEach(item=>{ + this.multipleAssetData.forEach(item => { // console.log(item) item.assetData.PropertyInfos.forEach(element => { - if(element.PropertyName == i.PropertyName){ - if(this.myIsNaN(i.PropertyValue)){ + if (element.PropertyName == i.PropertyName) { + if (this.myIsNaN(i.PropertyValue)) { i.PropertyValue = String(i.PropertyValue) } element.PropertyValue = i.PropertyValue @@ -787,12 +787,12 @@ export class CollectionToolsBuildingComponent implements OnInit { }) } //多选状态动态属性素材radio框值改变 - multipleAssetRadioChange(i,value){ + multipleAssetRadioChange(i, value) { // e.stopPropagation() - this.multipleAssetData.forEach(item=>{ + this.multipleAssetData.forEach(item => { // console.log(item) item.assetData.PropertyInfos.forEach(element => { - if(element.PropertyName == i.PropertyName){ + if (element.PropertyName == i.PropertyName) { element.PropertyValue = value this.canvas.refreshIcon(item.assetData.Id) this.canvasData.isChange = true @@ -801,12 +801,12 @@ export class CollectionToolsBuildingComponent implements OnInit { }) } //多选状态动态属性素材下拉框值改变 - multipleSupplyArea(i,e){ + multipleSupplyArea(i, e) { e.stopPropagation() - this.multipleAssetData.forEach(item=>{ + this.multipleAssetData.forEach(item => { // console.log(item) item.assetData.PropertyInfos.forEach(element => { - if(element.PropertyName == i.PropertyName){ + if (element.PropertyName == i.PropertyName) { element.PropertyValue = i.PropertyValue this.canvas.refreshIcon(item.assetData.Id) this.canvasData.isChange = true @@ -819,76 +819,79 @@ export class CollectionToolsBuildingComponent implements OnInit { ngAfterViewInit(): void { //不是gis模块平面图 - if(this.router.url.indexOf("gis") == -1) { + if (this.router.url.indexOf("gis") == -1) { this.getAllBuildings(true) //获取所有建筑 } //监听数据变化后 - this.canvas.on('canvasDataChanged',()=>{ + this.canvas.on('canvasDataChanged', () => { // 收到数据表示共享数据发生变化 this.renovateTreeData(false) }); } - copyAssetData:any //存储用于复制的素材 + copyAssetData: any //存储用于复制的素材 //复制素材 - copyAsset(){ + copyAsset() { this.canvas.copy() } //粘贴素材 - pasteAsset(){ + pasteAsset() { let companyId = sessionStorage.getItem("companyId") let buildingId = this.beforeOneCheckedBuilding.id let floorId = this.selectingSitePlan.id - this.canvas.paste(companyId,buildingId,floorId) + this.canvas.paste(companyId, buildingId, floorId) this.renovateTreeData(false) } + //截图 + takeScreenshot() { + this.canvas.takeScreenshot(); + } + isMultiSelect: boolean = false; // 多选/单选 切换 + changeMultiSelect(e) { this.canvas.setMulitSelect(this.isMultiSelect) } + isShowLegend: boolean = true; //图例是否显示 + changeLegend(e) { this.canvasData.selectPanelPoint.BackgroundImageUrl ? null : this.canvas.setLegendVisible(this.isShowLegend) } - isMultiSelect:boolean = false; // 多选/单选 切换 - changeMultiSelect (e) { this.canvas.setMulitSelect(this.isMultiSelect) } - isShowLegend:boolean = true; //图例是否显示 - changeLegend (e) { this.canvasData.selectPanelPoint.BackgroundImageUrl? null : this.canvas.setLegendVisible(this.isShowLegend) } - - basicInfo:boolean = true //基本信息名称显隐 - wantToWork:boolean = true //想定作业名称显隐 + basicInfo: boolean = true //基本信息名称显隐 + wantToWork: boolean = true //想定作业名称显隐 //点击基本信息名称 - basicInfoClick(){ + basicInfoClick() { this.basicInfo = !this.basicInfo - this.canvas.setNameVisible(this.basicInfo,0) + this.canvas.setNameVisible(this.basicInfo, 0) } //点击想定作业名称 - wantToWorkClick(){ + wantToWorkClick() { this.wantToWork = !this.wantToWork - this.canvas.setNameVisible(this.wantToWork,1) + this.canvas.setNameVisible(this.wantToWork, 1) } - isEditPattern:boolean = true //是否为编辑模式 + isEditPattern: boolean = true //是否为编辑模式 //进入编辑模式 - editpat(){ + editpat() { let config = new MatSnackBarConfig(); config.verticalPosition = 'top'; config.duration = 3000 - this.snackBar.open('进入编辑模式','确定',config); + this.snackBar.open('进入编辑模式', '确定', config); this.isEditPattern = true } //进入查看模式 - lookpat(){ + lookpat() { let config = new MatSnackBarConfig(); config.verticalPosition = 'top'; config.duration = 3000 - this.snackBar.open('进入查看模式','确定',config); + this.snackBar.open('进入查看模式', '确定', config); this.isEditPattern = false } //保存平面图 - saveNum :any = [] - saveSite(){ + saveNum: any = [] + saveSite() { //更新用于统计的数据 this.canvasData.updateBuildingData() - - if (this.selectingSitePlan && this.selectingSitePlan.id) { + + if (this.selectingSitePlan && this.selectingSitePlan.id) { //打开遮罩层 this.maskLayerService.sendMessage(true) this.saveNum = [] @@ -896,290 +899,290 @@ export class CollectionToolsBuildingComponent implements OnInit { 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){//如果是基本信息编辑模式 + + if (this.pattern) {//如果是基本信息编辑模式 for (const key in object) { if (object[key].Name == "毗邻") {//如果是相同楼层,则筛选出毗邻 - + object[key].PropertyInfos.forEach(element => { - if(element.PropertyName == "方向"){ + if (element.PropertyName == "方向") { adjoinArr.push(element.PropertyValue) } }); } } - - if((new Set(adjoinArr)).size != adjoinArr.length){ + + 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); + this.snackBar.open('保存失败,毗邻存在相同方向', '确定', config); return false - }else{ + } else { //如果是单位 总平面图 - if(this.checkedBuildingIndex==-1){ + if (this.checkedBuildingIndex == -1) { // console.log(111,SitePlanData) //保存平面图数据 - this.http.post("/api/SitePlanData",SitePlanData,{ - params:{ - companyId:this.params.companyId + this.http.post("/api/SitePlanData", SitePlanData, { + params: { + companyId: this.params.companyId } }).subscribe(data => { this.saveNum.push("1") - if(this.saveNum.length == 5){ + 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.snackBar.open('保存成功', '确定', config); this.tabbarService.sendMessage('changeScore'); } - },err=>{ + }, err => { this.maskLayerService.sendMessage(false) let config = new MatSnackBarConfig(); config.verticalPosition = 'top'; config.duration = 3000 this.canvasData.isChange = true - this.snackBar.open('平面图数据保存失败','确定',config); + this.snackBar.open('平面图数据保存失败', '确定', config); }) - + //保存建筑数据 - this.http.post("/api/CompanyData",CompanyData,{ - params:{ - companyId:this.params.companyId + this.http.post("/api/CompanyData", CompanyData, { + params: { + companyId: this.params.companyId } }).subscribe(data => { this.saveNum.push("1") - if(this.saveNum.length == 5){ + 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.snackBar.open('保存成功', '确定', config); this.tabbarService.sendMessage('changeScore'); } - },err=>{ + }, err => { this.maskLayerService.sendMessage(false) let config = new MatSnackBarConfig(); config.verticalPosition = 'top'; config.duration = 3000 this.canvasData.isChange = true - this.snackBar.open('单位数据保存失败','确定',config); + this.snackBar.open('单位数据保存失败', '确定', config); }) - + //批量保存单位毗邻 let CompanyAdjoins = this.canvasData.getCompanyAdjoinInfo() - this.http.post("/api/CompanyAdjoins/Batch",CompanyAdjoins,{ - params:{ - companyId:this.params.companyId + this.http.post("/api/CompanyAdjoins/Batch", CompanyAdjoins, { + params: { + companyId: this.params.companyId } }).subscribe(data => { this.saveNum.push("1") - if(this.saveNum.length == 5){ + 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.snackBar.open('保存成功', '确定', config); this.tabbarService.sendMessage('changeScore'); } - },err=>{ + }, 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); + 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 + this.http.post("/api/CompanyImportantLocations/Batch", CompanyImportantLocations, { + params: { + companyId: this.params.companyId } }).subscribe(data => { this.saveNum.push("1") - if(this.saveNum.length == 5){ + 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.snackBar.open('保存成功', '确定', config); this.tabbarService.sendMessage('changeScore'); } - },err=>{ + }, err => { this.maskLayerService.sendMessage(false) let config = new MatSnackBarConfig(); config.verticalPosition = 'top'; config.duration = 3000 this.canvasData.isChange = true - this.snackBar.open('单位重点部位同步失败','确定',config); + this.snackBar.open('单位重点部位同步失败', '确定', config); }) - + //批量保存单位消防设施素材 let CompanyFacilityAssets = this.canvasData.getAllCompanyFacilityAssetInfo() - this.http.post("/api/CompanyFacilityAssets/Batch",CompanyFacilityAssets,{ - params:{ - companyId:this.params.companyId + this.http.post("/api/CompanyFacilityAssets/Batch", CompanyFacilityAssets, { + params: { + companyId: this.params.companyId } }).subscribe(data => { this.saveNum.push("1") - if(this.saveNum.length == 5){ + 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.snackBar.open('保存成功', '确定', config); this.tabbarService.sendMessage('changeScore'); } - },err=>{ + }, err => { this.maskLayerService.sendMessage(false) let config = new MatSnackBarConfig(); config.verticalPosition = 'top'; config.duration = 3000 this.canvasData.isChange = true - this.snackBar.open('单位消防设施素材同步失败','确定',config); + this.snackBar.open('单位消防设施素材同步失败', '确定', config); }) - - }else{ //如果是建筑 - + + } else { //如果是建筑 + //建筑平面图数据 - this.http.post("/api/BuildingAreaData",SitePlanData,{ - params:{ - companyId:this.params.companyId + this.http.post("/api/BuildingAreaData", SitePlanData, { + params: { + companyId: this.params.companyId } }).subscribe(data => { this.saveNum.push("1") - if(this.saveNum.length == 5){ + 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.snackBar.open('保存成功', '确定', config); this.tabbarService.sendMessage('changeScore'); } - },err=>{ + }, err => { this.maskLayerService.sendMessage(false) let config = new MatSnackBarConfig(); config.verticalPosition = 'top'; config.duration = 3000 this.canvasData.isChange = true - this.snackBar.open('平面图数据保存失败','确定',config); + this.snackBar.open('平面图数据保存失败', '确定', config); }) - + //建筑数据 - this.http.post("/api/BuildingData",CompanyData,{ - params:{ - companyId:this.params.companyId + this.http.post("/api/BuildingData", CompanyData, { + params: { + companyId: this.params.companyId } }).subscribe(data => { this.saveNum.push("1") - if(this.saveNum.length == 5){ + 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.snackBar.open('保存成功', '确定', config); this.tabbarService.sendMessage('changeScore'); } - },err=>{ + }, err => { this.maskLayerService.sendMessage(false) let config = new MatSnackBarConfig(); config.verticalPosition = 'top'; config.duration = 3000 this.canvasData.isChange = true - this.snackBar.open('单位数据保存失败','确定',config); + 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.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){ + 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.snackBar.open('保存成功', '确定', config); this.tabbarService.sendMessage('changeScore'); } - },err=>{ + }, 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); + 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.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){ + 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.snackBar.open('保存成功', '确定', config); this.tabbarService.sendMessage('changeScore'); } - },err=>{ + }, err => { this.maskLayerService.sendMessage(false) let config = new MatSnackBarConfig(); config.verticalPosition = 'top'; config.duration = 3000 this.canvasData.isChange = true - this.snackBar.open('建筑重点部位同步失败','确定',config); + 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.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){ + 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.snackBar.open('保存成功', '确定', config); this.tabbarService.sendMessage('changeScore'); } - },err=>{ + }, err => { this.maskLayerService.sendMessage(false) let config = new MatSnackBarConfig(); config.verticalPosition = 'top'; config.duration = 3000 this.canvasData.isChange = true - this.snackBar.open('建筑消防设施素材同步失败','确定',config); + this.snackBar.open('建筑消防设施素材同步失败', '确定', config); }) - + } } } @@ -1187,56 +1190,56 @@ export class CollectionToolsBuildingComponent implements OnInit { const config = new MatSnackBarConfig(); config.verticalPosition = 'top'; config.duration = 3000 - this.snackBar.open('暂无楼层数据','确定',config); + this.snackBar.open('暂无楼层数据', '确定', config); } } //获得所有的建筑物 - getAllBuildings(init:boolean = false){ - this.http.get("/api/Buildings",{ params:{companyId : this.params.companyId}}).subscribe((data:any)=>{ + 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}]} + data && data.length ? this.beforeOneCheckedBuilding = data[0] : this.beforeOneCheckedBuilding = { id: null, buildingTypes: [{ id: null }] } this.getBuildingSitePlan(this.beforeOneCheckedBuilding) } //if }) } //拖拽tree - drop(e){ + drop(e) { // console.log(1111,e) } - drop2(e){ + drop2(e) { // console.log(222,e) } //创建建筑 - createBuilding(){ + createBuilding() { let data = { - allBuildings:this.allBuildings, - companyId :this.params.companyId + allBuildings: this.allBuildings, + companyId: this.params.companyId } - let dialogRef = this.dialog.open(CreateBuildingBuilding,{data}); - dialogRef.afterClosed().subscribe(data=>{ + 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 == "创建失败") { + 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); + this.snackBar.open('创建失败', '确定', config); } - }); + }); } //选择建筑 - checkedBuilding(item,index){ - if (this.checkedBuildingIndex!=index) { + checkedBuilding(item, index) { + if (this.checkedBuildingIndex != index) { this.canvasData.selectPanelPoint = new DisposalNodeData(); if (this.canvasData.isChange) { //true 数据被改动 let isTrue = confirm('是否保存当前编辑数据') @@ -1245,7 +1248,7 @@ export class CollectionToolsBuildingComponent implements OnInit { if (isSuccess != false) { this.beforeOneCheckedBuilding = item this.checkedBuildingIndex = index - if (index==-1) { //总平面图数据 + if (index == -1) { //总平面图数据 this.getSitePlan() } else { //建筑楼层/区域数据 this.getBuildingSitePlan(item) @@ -1254,7 +1257,7 @@ export class CollectionToolsBuildingComponent implements OnInit { } else { this.beforeOneCheckedBuilding = item this.checkedBuildingIndex = index - if (index==-1) { //总平面图数据 + if (index == -1) { //总平面图数据 this.getSitePlan() } else { //建筑楼层/区域数据 this.getBuildingSitePlan(item) @@ -1263,7 +1266,7 @@ export class CollectionToolsBuildingComponent implements OnInit { } else { //flase 数据未被改动 this.beforeOneCheckedBuilding = item this.checkedBuildingIndex = index - if (index==-1) { //总平面图数据 + if (index == -1) { //总平面图数据 this.getSitePlan() } else { //建筑楼层/区域数据 this.getBuildingSitePlan(item) @@ -1274,49 +1277,49 @@ export class CollectionToolsBuildingComponent implements OnInit { } //编辑建筑 - editBuilding(e,item){ + editBuilding(e, item) { e.stopPropagation(); - let dialogRef = this.dialog.open(EditBuildingBuilding,{data: {item:item}}); - dialogRef.afterClosed().subscribe(data=>{ + 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.snackBar.open('修改成功', '确定', config); this.getAllBuildings() - }else if (data == "修改失败") { + } else if (data == "修改失败") { const config = new MatSnackBarConfig(); config.verticalPosition = 'top'; config.duration = 3000 - this.snackBar.open('修改失败','确定',config); + this.snackBar.open('修改失败', '确定', config); } - }); + }); } //删除建筑 - deleteBuilding(e,item){ + deleteBuilding(e, item) { e.stopPropagation(); - if(confirm("是否删除该建筑") == true){ - let isHave = this.canvasData.allDisposalNode.find(items=>{ return items.buildingId === item.id }) + 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=>{ + this.http.delete(`/api/Buildings/${item.id}`).subscribe(data => { const config = new MatSnackBarConfig(); config.verticalPosition = 'top'; config.duration = 3000 - this.snackBar.open('删除成功','确定',config); + this.snackBar.open('删除成功', '确定', config); this.getAllBuildings(true) - },err=>{ + }, err => { const config = new MatSnackBarConfig(); config.verticalPosition = 'top'; config.duration = 3000 - this.snackBar.open('删除失败','确定',config); + this.snackBar.open('删除失败', '确定', config); this.getAllBuildings(true) }) } else { //建筑 含有数据节点时 const config = new MatSnackBarConfig(); config.verticalPosition = 'top'; config.duration = 3000 - this.snackBar.open('含有数据节点的建筑不允许删除','确定',config); + this.snackBar.open('含有数据节点的建筑不允许删除', '确定', config); } } } @@ -1324,7 +1327,7 @@ export class CollectionToolsBuildingComponent implements OnInit { storeyData //将建筑素材和当前楼层素材合二为一 //处理 tree 数据结构 - handleTreeData (storeyData) { + handleTreeData(storeyData) { this.hideAllTreenode = true this.storeyData = storeyData let data = this.allFireElements //所有消防要素模板 @@ -1332,22 +1335,22 @@ export class CollectionToolsBuildingComponent implements OnInit { data.forEach(element => { element.isTemplate = true //添加模板标识 element.isLook = true //添加是否可见标识 - element.name!='其他'? element.children = [] : null + element.name != '其他' ? element.children = [] : null - if(storeyData){ - for(let key in storeyData.data){ + if (storeyData) { + for (let key in storeyData.data) { storeyData.data[key].isLookPattern = true - if(element.id == storeyData.data[key].FireElementId){ + 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){ + if (element.parentId) { data.forEach(i => { - if(i.id == element.parentId){ + if (i.id == element.parentId) { i.isLookPattern = true } }) @@ -1358,7 +1361,7 @@ export class CollectionToolsBuildingComponent implements OnInit { } } } - data.forEach(item => { if (item.parentId == element.id) {element.children.push(item)} }); + data.forEach(item => { if (item.parentId == element.id) { element.children.push(item) } }); }); data.forEach(element => { if (!element.parentId) { treeData.push(element) } @@ -1368,89 +1371,89 @@ export class CollectionToolsBuildingComponent implements OnInit { } //点击树节点 - clickTreeNode(node){ - if(this.canvasData.originalcompanyBuildingData.data[node.id]){ + 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]){ + } else if (this.canvasData.originaleveryStoreyData.data[node.id]) { this.setAssetsProperty(this.canvasData.originaleveryStoreyData.data[node.id]) } //canvas上的素材高亮 - let iconHighLightArr:any = [] - if(node.isTemplate){//如果是模板,则开始向下找 + let iconHighLightArr: any = [] + if (node.isTemplate) {//如果是模板,则开始向下找 node.children.forEach(item => { - if(item.isTemplate){//如果子节点依旧是模板,则继续开始向下找 + if (item.isTemplate) {//如果子节点依旧是模板,则继续开始向下找 item.children.forEach(i => { iconHighLightArr.push(i.Id) }) - }else{ + } else { iconHighLightArr.push(item.Id) } }) - }else{ + } else { iconHighLightArr.push(node.id) } this.canvas.setHighlight(iconHighLightArr) } - hideAllTreenode:boolean = true; //全部显示/隐藏tree节点 - toggoleAllTreenode () { + hideAllTreenode: boolean = true; //全部显示/隐藏tree节点 + toggoleAllTreenode() { this.hideAllTreenode = !this.hideAllTreenode let list = [] - this.allFireElements.forEach(element=>{ - if (element.isTemplate) { this.hideAllTreenode? element.isLook = false : element.isLook = true } + this.allFireElements.forEach(element => { + if (element.isTemplate) { this.hideAllTreenode ? element.isLook = false : element.isLook = true } }) - this.treeControl.dataNodes.forEach(item=>{ - this.hideAllTreenode? item.isLook = false : item.isLook = true + this.treeControl.dataNodes.forEach(item => { + this.hideAllTreenode ? item.isLook = false : item.isLook = true item.level === 0 ? list.push(item) : null }) - list.forEach(item=>{ + list.forEach(item => { this.clickLookItem(item) }) } //点击数节点的显示隐藏icon - clickLookItem(node){ + clickLookItem(node) { //修改真实素材islook属性 - for(let key in this.storeyData.data){ - if(key == node.id){ + for (let key in this.storeyData.data) { + if (key == node.id) { this.storeyData.data[key].isLook = !this.storeyData.data[key].isLook } } - + //所有消防要素模板变化islook值 console.log(node) - if(node.isTemplate){ - this.allFireElements.forEach(item=>{ - if(item.id == node.id){ item.isLook = !item.isLook } + if (node.isTemplate) { + this.allFireElements.forEach(item => { + if (item.id == node.id) { item.isLook = !item.isLook } if (item.name == '其他' && node.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  -          }) -        } -      }) -     } + 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)){ + 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; @@ -1460,25 +1463,25 @@ export class CollectionToolsBuildingComponent implements OnInit { }); //canvas上的素材显隐 - let iconVisibleArr:any = [] - if(node.isTemplate){//如果是模板,则开始向下找 + let iconVisibleArr: any = [] + if (node.isTemplate) {//如果是模板,则开始向下找 node.children.forEach(item => { - if(item.isTemplate){//如果子节点依旧是模板,则继续开始向下找 + if (item.isTemplate) {//如果子节点依旧是模板,则继续开始向下找 item.children.forEach(i => { iconVisibleArr.push(i.Id) }) - }else{ + } else { iconVisibleArr.push(item.Id) } }) - }else{ + } else { iconVisibleArr.push(node.id) } - this.canvas.setIconVisible(iconVisibleArr,!node.isLook) + this.canvas.setIconVisible(iconVisibleArr, !node.isLook) } //计算 可视区域内宽度, 是否缩放背景图 - backGroundScale () { + backGroundScale() { // let that = this // let dad = this.element.nativeElement.querySelector('.functionalDomainContent').clientWidth // let dadHeight = this.element.nativeElement.querySelector('.functionalDomainContent').clientHeight @@ -1504,30 +1507,30 @@ export class CollectionToolsBuildingComponent implements OnInit { } //封装 刷新 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) + 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) this.canvas.setLegendVisible(this.isShowLegend) //图例显隐 - isRefresh? this.canvasData.isChange = false : null //服务中 数据是否改动 改为false - isRefresh? this.isShowProperty = true : null - isRefresh? this.isShowAttribute = true : null - !this.pattern? this.mateFireForce() : null //刷新 建筑楼层 火源/力量图标 + 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 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 ) + for (let key in storeyData.data) { //筛选数据 没有匹配全部放入到 其他 数组 + let noMatch = this.allFireElements.find(every => every.id === storeyData.data[key].FireElementId) if (!noMatch && storeyData.data[key].Id != "图例") { - this.allFireElements[this.allFireElements.length-1].children.push(storeyData.data[key]) + this.allFireElements[this.allFireElements.length - 1].children.push(storeyData.data[key]) } } this.handleTreeData(storeyData) //处理tree数据结构 @@ -1538,53 +1541,53 @@ export class CollectionToolsBuildingComponent implements OnInit { //陈鹏飞↓↓↓ //陈鹏飞↓↓↓ //陈鹏飞↓↓↓ - params = {companyId: sessionStorage.getItem('companyId')} - allFireElements:any = []; //当前 单位/建筑 下的消防要素 + params = { companyId: sessionStorage.getItem('companyId') } + allFireElements: any = []; //当前 单位/建筑 下的消防要素 - isShowAttribute:boolean = true; //属性栏 是否显示 默认数据 - isShowProperty:boolean = false //属性栏 是否有东西 + isShowAttribute: boolean = true; //属性栏 是否显示 默认数据 + isShowProperty: boolean = false //属性栏 是否有东西 - toggleExpandPanel:boolean = false; //左侧可展开面板展开或关闭 - toggleExpandPanelRight:boolean = false; //右侧可展开面板展开或关闭 - togglePlane:boolean = true; //可展开面板平面图 显隐 - toggleMaterialBank:boolean = false; //可展开面板素材库 显隐 - toggleHandlePlans:boolean = true; //可展开面板处置预案 显隐 + toggleExpandPanel: boolean = false; //左侧可展开面板展开或关闭 + toggleExpandPanelRight: boolean = false; //右侧可展开面板展开或关闭 + togglePlane: boolean = true; //可展开面板平面图 显隐 + toggleMaterialBank: boolean = false; //可展开面板素材库 显隐 + toggleHandlePlans: boolean = true; //可展开面板处置预案 显隐 //可展开面板展开或关闭 - toggle () { + toggle() { this.toggleExpandPanel = !this.toggleExpandPanel } //可展开面板展开或关闭 - toggle2 () { + toggle2() { this.toggleExpandPanelRight = !this.toggleExpandPanelRight } //可展开面板 平面图 展开或关闭 - togglePlanarGraph () { + togglePlanarGraph() { this.togglePlane = !this.togglePlane } //可展开面板 素材库 展开或关闭 - toggleMaterial () { + toggleMaterial() { this.toggleMaterialBank = !this.toggleMaterialBank } //可展开面板 处置预案 展开或关闭 - toggleHandlePlan () { + toggleHandlePlan() { this.toggleHandlePlans = !this.toggleHandlePlans } - sitePlanData:any = []; //总平面图 楼层/区域 数据 - selectingSitePlan:any; //选中的 平面图 楼层/区域 - selectSitePlanIndex:number; //选中的 平面图 楼层/区域 index + sitePlanData: any = []; //总平面图 楼层/区域 数据 + selectingSitePlan: any; //选中的 平面图 楼层/区域 + selectSitePlanIndex: number; //选中的 平面图 楼层/区域 index //获取总平面图 - getSitePlan () { + getSitePlan() { let fireData = this.getFireElements(sessionStorage.getItem('buildingTypeId')) //获取单位下 消防要素 let planData = this.getSitePlanCompanyData() //获取 单位 数据 - this.http.get('/api/SitePlans',{params:this.params}).subscribe(data=>{ + 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)=>{ + Promise.all([fireData, planData]).then((res) => { this.getSitePlanStorey(this.selectingSitePlan) //获取 平面图 楼层数据 }) @@ -1592,17 +1595,17 @@ export class CollectionToolsBuildingComponent implements OnInit { } //获取建筑 楼层/区域 - getBuildingSitePlan (item) { + 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.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)=>{ + Promise.all([fireData, planData]).then((res) => { this.getBuildingStorey(this.selectingSitePlan) //获取 建筑 楼层数据 }) @@ -1610,10 +1613,10 @@ export class CollectionToolsBuildingComponent implements OnInit { } //根据单位类型获得所有的消防要素 - getFireElements (e) { - let params = {ids:e} - return new Promise ((resolve,reject)=>{ - this.http.get('/api/Companies/FireElements',{params}).subscribe((data:any)=>{ + 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: [], @@ -1623,7 +1626,7 @@ export class CollectionToolsBuildingComponent implements OnInit { order: 999, parentId: null, tag: "INPUT", - isLookPattern : true + isLookPattern: true } this.allFireElements.push(other) resolve('success') @@ -1632,57 +1635,57 @@ export class CollectionToolsBuildingComponent implements OnInit { } //获取 单位 数据 - getSitePlanCompanyData () { - return new Promise ((resolve,reject)=>{ - this.http.get('/api/CompanyData',{params:this.params}).subscribe((data:any)=>{ + 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.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') + 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)=>{ + 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.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.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)=>{ + 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.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 + 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)=>{ + 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.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.canvasData.originaleveryStoreyData.buildingAreaId ? null : this.canvasData.originaleveryStoreyData.buildingAreaId = e.id || null this.renovateTreeData() }) } //点击选中 平面图 楼层/区域 时 - selectSitePlan (item,index) { + selectSitePlan(item, index) { if (this.selectSitePlanIndex != index) { this.canvasData.selectPanelPoint = new DisposalNodeData(); if (this.canvasData.isChange) { //true 数据被改动 @@ -1693,7 +1696,7 @@ export class CollectionToolsBuildingComponent implements OnInit { this.selectingSitePlan = item this.selectSitePlanIndex = index this.canvasData.selectStorey = item //服务中 存一份数据 - if (this.checkedBuildingIndex==-1) { //总平面图时 + if (this.checkedBuildingIndex == -1) { //总平面图时 this.getSitePlanStorey(item) //获取 平面图 楼层数据 } else { //楼层/区域时 this.getBuildingStorey(item) //获取 建筑 楼层数据 @@ -1703,7 +1706,7 @@ export class CollectionToolsBuildingComponent implements OnInit { this.selectingSitePlan = item this.selectSitePlanIndex = index this.canvasData.selectStorey = item //服务中 存一份数据 - if (this.checkedBuildingIndex==-1) { //总平面图时 + if (this.checkedBuildingIndex == -1) { //总平面图时 this.getSitePlanStorey(item) //获取 平面图 楼层数据 this.getSitePlanCompanyData() } else { //楼层/区域时 @@ -1712,12 +1715,12 @@ export class CollectionToolsBuildingComponent implements OnInit { this.getBuildingData(params) } } - + } else { //false 数据没被改动 this.selectingSitePlan = item this.selectSitePlanIndex = index this.canvasData.selectStorey = item //服务中 存一份数据 - if (this.checkedBuildingIndex==-1) { //总平面图时 + if (this.checkedBuildingIndex == -1) { //总平面图时 this.getSitePlanStorey(item) //获取 平面图 楼层数据 } else { //楼层/区域时 this.getBuildingStorey(item) //获取 建筑 楼层数据 @@ -1728,19 +1731,19 @@ export class CollectionToolsBuildingComponent implements OnInit { } //新增平面图 楼层/区域 - foundPanel (e) { + foundPanel(e) { e.stopPropagation() if (this.beforeOneCheckedBuilding.id) { let data = { - isBuilding: this.checkedBuildingIndex==-1? false:true, + isBuilding: this.checkedBuildingIndex == -1 ? false : true, Panel: this.beforeOneCheckedBuilding, - order: this.sitePlanData.length? this.sitePlanData[this.sitePlanData.length-1].order+1:0, + 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 =='总平面图') { + let dialogRef = this.dialog.open(leftFunctionalDomainBuildingComponent, { data }); + dialogRef.afterClosed().subscribe(data => { + if (data == '总平面图') { this.renovateSitePlan() - } else if (data =='建筑') { + } else if (data == '建筑') { this.renovateBuilding() } }) @@ -1748,32 +1751,32 @@ export class CollectionToolsBuildingComponent implements OnInit { const config = new MatSnackBarConfig(); config.verticalPosition = 'top'; config.duration = 3000 - this.snackBar.open('请选择建筑','确定',config); + this.snackBar.open('请选择建筑', '确定', config); } } //编辑平面图 楼层/区域 - editPlaneData (e) { + editPlaneData(e) { let data = { - isBuilding: this.checkedBuildingIndex==-1? false:true, + isBuilding: this.checkedBuildingIndex == -1 ? false : true, Panel: this.beforeOneCheckedBuilding, buildingData: e, } - let dialogRef = this.dialog.open(editPlaneFigureBuildingComponent,{disableClose: true,hasBackdrop: false,position: {left:'150px',top:'200px'},data}); - dialogRef.keydownEvents().subscribe(data=>{ + let dialogRef = this.dialog.open(editPlaneFigureBuildingComponent, { disableClose: true, hasBackdrop: false, position: { left: '150px', top: '200px' }, data }); + dialogRef.keydownEvents().subscribe(data => { if (data.key === 'Enter') { this.canvas.refreshBackgroundImage() } }) - dialogRef.afterClosed().subscribe(data=>{ - if (data =='总平面图') { + dialogRef.afterClosed().subscribe(data => { + if (data == '总平面图') { let isSuccess = this.renovateSitePlan() - isSuccess.then(res=>{ + isSuccess.then(res => { this.canvas.refreshBackgroundImage() }) - } else if (data =='建筑') { - let isSuccess= this.renovateBuilding() - isSuccess.then(res=>{ + } else if (data == '建筑') { + let isSuccess = this.renovateBuilding() + isSuccess.then(res => { this.canvas.refreshBackgroundImage() }) } else if (data == '更新背景图') { @@ -1783,22 +1786,22 @@ export class CollectionToolsBuildingComponent implements OnInit { } //平面图 楼层/区域 上移 - moveUp (item,index) { + 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.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.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() }) }) @@ -1808,22 +1811,22 @@ export class CollectionToolsBuildingComponent implements OnInit { } //平面图 楼层/区域 下移 - moveDown (item,index) { - if (index != this.sitePlanData.length-1) { + 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.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.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() }) }) @@ -1833,20 +1836,20 @@ export class CollectionToolsBuildingComponent implements OnInit { } //旋转底图 - 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=>{ + 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(item.imageUrl,item.imageAngle) + isSuccess.then(res => { + this.canvas.refreshBackgroundImage(item.imageUrl, item.imageAngle) }) }) } else { //楼层/区域 - this.http.put(`/api/BuildingAreas/${item.id}`,item,{params:this.params}).subscribe(data=>{ + this.http.put(`/api/BuildingAreas/${item.id}`, item, { params: this.params }).subscribe(data => { let isSuccess = this.renovateBuilding() - isSuccess.then(res=>{ - this.canvas.refreshBackgroundImage(item.imageUrl,item.imageAngle) + isSuccess.then(res => { + this.canvas.refreshBackgroundImage(item.imageUrl, item.imageAngle) }) }) } @@ -1854,47 +1857,47 @@ export class CollectionToolsBuildingComponent implements OnInit { } //删除 平面图 楼层/区域 - deletePlaneData (item) { + deletePlaneData(item) { const isDelete = confirm('您确定要删除吗'); if (isDelete) { - if (this.checkedBuildingIndex==-1) { //总平面图 - let isHave = this.canvasData.allDisposalNode.find(items=>{ return items.sitePlanId === item.id }) + 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) + 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); + this.snackBar.open('含有数据节点的楼层不允许删除', '确定', config); } } else { //楼层/区域 - let isHave = this.canvasData.allDisposalNode.find(items=>{ return items.buildingAreaId === item.id }) + 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) + 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); + this.snackBar.open('含有数据节点的楼层不允许删除', '确定', config); } } } } //删除当前 单位/建筑的 共享数据中 已删除data - deleteShareData (e,isCompany) { - this.sitePlanData.forEach((element,index) => { - if (element.id===e.id) { - this.sitePlanData.splice(index,1) + 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){ + for (let key in data.data) { if (data.data[key].FloorId === e.id) { //处理 单位/建筑 数据是否归于当前楼层下 delete data.data[key] } @@ -1905,19 +1908,19 @@ export class CollectionToolsBuildingComponent implements OnInit { this.canvasData.selectStorey = this.sitePlanData[0] || {} //服务中 存一份数据 this.selectSitePlanIndex = 0 this.canvasData.isChange = false - if (isCompany===-1) { - this.http.post("/api/CompanyData",newData).subscribe(data => {}) + 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.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)=>{ + 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 @@ -1925,19 +1928,19 @@ export class CollectionToolsBuildingComponent implements OnInit { delete paramsData[key] } }) //图标Id重新赋值 - if (this.checkedBuildingIndex==-1) { //总平面图 + 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)=>{ + 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, + data: JSON.stringify(paramsData) || null, sitePlanId: data.id } - this.http.post('/api/SitePlanData',newData,{params:this.params}).subscribe(data=>{ + this.http.post('/api/SitePlanData', newData, { params: this.params }).subscribe(data => { this.renovateSitePlan() }) @@ -1946,15 +1949,15 @@ export class CollectionToolsBuildingComponent implements OnInit { 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)=>{ + 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, + data: JSON.stringify(paramsData) || null, buildingAreaId: data.id } - this.http.post('/api/BuildingAreaData',newData,{params:this.params}).subscribe(data=>{ + this.http.post('/api/BuildingAreaData', newData, { params: this.params }).subscribe(data => { this.renovateBuilding() }) @@ -1963,32 +1966,32 @@ export class CollectionToolsBuildingComponent implements OnInit { } //平面图 楼层/区域 替换底图 - replaceBaseMap (e,item) { + replaceBaseMap(e, item) { e.stopPropagation(); let file = e.target.files[0] || null //获取上传的文件 let fileSize = file.size || null //上传文件的总大小 let maxSize = 5 * 1024 * 1024 //5MB一个分片 let tenSize = 10 * 1024 * 1024 //10MB限制 - if (file && fileSize<=maxSize) { //上传文件<=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('/api/Objects/WebPlan2D/' + data.objectName,item) + formData.append("file", file) + this.http.post(`/api/Objects/WebPlan2D/${sessionStorage.getItem('companyId')}`, formData).subscribe((data: any) => { + this.renovateBaseMap('/api/Objects/WebPlan2D/' + data.objectName, item) }) - } else if (file && fileSize>maxSize && fileSize10MB时 - let upload = this.canvasData.sectionUpload(sessionStorage.getItem('companyId'),file) - upload.then(res=>{ this.renovateBaseMap('/api/Objects/PlanPlatform/' + res,item) }) + } else if (file && fileSize > maxSize && fileSize < tenSize) { //上传文件>10MB时 + let upload = this.canvasData.sectionUpload(sessionStorage.getItem('companyId'), file) + upload.then(res => { this.renovateBaseMap('/api/Objects/PlanPlatform/' + res, item) }) } else { const config = new MatSnackBarConfig(); config.verticalPosition = 'top'; config.duration = 3000 - this.snackBar.open('上传底图需小于10MB','确定',config); + this.snackBar.open('上传底图需小于10MB', '确定', config); } } //封装 替换底图 function - renovateBaseMap (e,item) { + renovateBaseMap(e, item) { let that = this let img = new Image() img.src = e @@ -1996,94 +1999,94 @@ export class CollectionToolsBuildingComponent implements OnInit { item.imageUrl = e item.imageWidth = img.width item.imageHeight = img.height - if (that.checkedBuildingIndex ==-1) { //总平面图 - that.http.put(`/api/SitePlans/${item.id}`,item).subscribe(data=>{ + if (that.checkedBuildingIndex == -1) { //总平面图 + that.http.put(`/api/SitePlans/${item.id}`, item).subscribe(data => { let isSuccess = that.renovateSitePlan() - isSuccess.then(res=>{ + isSuccess.then(res => { that.canvas.refreshBackgroundImage() }) const config = new MatSnackBarConfig(); config.verticalPosition = 'top'; config.duration = 3000 - that.snackBar.open('上传底图成功','确定',config); + that.snackBar.open('上传底图成功', '确定', config); }) } else { //楼层/区域 - that.http.put(`/api/BuildingAreas/${item.id}`,item,{params:that.params}).subscribe(data=>{ + that.http.put(`/api/BuildingAreas/${item.id}`, item, { params: that.params }).subscribe(data => { let isSuccess = that.renovateBuilding() - isSuccess.then(res=>{ + isSuccess.then(res => { that.canvas.refreshBackgroundImage() }) const config = new MatSnackBarConfig(); config.verticalPosition = 'top'; config.duration = 3000 - that.snackBar.open('上传底图成功','确定',config); + that.snackBar.open('上传底图成功', '确定', config); }) } //else } //onload } //封装 刷新总平面图 数据 - renovateSitePlan () { - return new Promise ((resolve,reject)=>{ - this.http.get('/api/SitePlans',{params:this.params}).subscribe(data=>{ + 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 + 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); + this.snackBar.open('数据更新成功', '确定', config); resolve('success') }) }) } //封装 刷新 楼层/区域 数据 - renovateBuilding () { + renovateBuilding() { let params = { buildingId: this.beforeOneCheckedBuilding.id } - return new Promise ((resolve,reject)=>{ - this.http.get('/api/BuildingAreas',{params}).subscribe(data=>{ + 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 + 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); + this.snackBar.open('数据更新成功', '确定', config); resolve('success') }) }) } - allLibrary:any = []; //所有素材库 + 素材 - selectLibrary:any; //选中的素材库 - selectImage:any; //选中的素材库图片 - selectImageIndex:number; //选中的素材库图片index - searchSettimeout:any; //延时器 - searchInput:string = null; //模糊搜索 input - searchLibrary:any = []; //模糊搜索 素材 + allLibrary: any = []; //所有素材库 + 素材 + selectLibrary: any; //选中的素材库 + selectImage: any; //选中的素材库图片 + selectImageIndex: number; //选中的素材库图片index + searchSettimeout: any; //延时器 + searchInput: string = null; //模糊搜索 input + searchLibrary: any = []; //模糊搜索 素材 //输入框 输入事件 - libraryChange () { + libraryChange() { window.clearTimeout(this.searchSettimeout) - this.searchSettimeout = window.setTimeout(()=>{ + this.searchSettimeout = window.setTimeout(() => { if (this.searchInput === "") { this.searchLibrary = [] } else { - this.http.get(`/api/Assets?assetName=${this.searchInput}`).subscribe((data:any)=>{ + this.http.get(`/api/Assets?assetName=${this.searchInput}`).subscribe((data: any) => { this.searchLibrary = data }) } - },500) + }, 500) } //获取素材库 - getAllLibrary (type:string='input') { - this.http.get(`/api/AssetLibraries?tag=${type}`).subscribe((data:any)=>{ + getAllLibrary(type: string = 'input') { + this.http.get(`/api/AssetLibraries?tag=${type}`).subscribe((data: any) => { data.forEach(element => { element.images = [] }); @@ -2093,16 +2096,16 @@ export class CollectionToolsBuildingComponent implements OnInit { } //素材库展开面板展开时 - opened (e) { + opened(e) { if (!e.images.length) { //当前素材库没加载素材时 - this.http.get(`/api/Assets?libraryId=${e.id}`).subscribe((data:any)=>{ + this.http.get(`/api/Assets?libraryId=${e.id}`).subscribe((data: any) => { e.images = data }) } } //点击选中素材库图片时 - selectImg (item,items,index) { + selectImg(item, items, index) { this.selectLibrary = item.name this.selectImage = items this.selectImageIndex = index @@ -2113,30 +2116,30 @@ export class CollectionToolsBuildingComponent implements OnInit { //处置预案 - allFirePlan:any = []; //所有灾情 - selectDisposalNode:string = ''; //当前点击tree节点 css选中样式 + allFirePlan: any = []; //所有灾情 + selectDisposalNode: string = ''; //当前点击tree节点 css选中样式 //获取所有灾情 - getAllFirePlan () { - let params = {componentId: sessionStorage.getItem('planId')} - this.http.get('/api/Disasters',{params:params}).subscribe((data:any)=>{ + 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.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=>{ //所有处置节点 + 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=>{ //所有处置节点 + let params = { disasterId: this.allFirePlan[0].id || '' } + this.http.get('/api/DisposalNodes', { params: params }).subscribe(data => { //所有处置节点 this.canvasData.allDisposalNode = data }) } @@ -2144,26 +2147,26 @@ export class CollectionToolsBuildingComponent implements OnInit { } //获取所有处置节点 - getDisposalNode () { + getDisposalNode() { this.selectDisposalNode = '' - let params = {disasterId: this.allFirePlan[0].id || ''} - this.http.get('/api/DisasterData/Markers',{params:params}).subscribe(data=>{ //灾情标签信息 + 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.http.get('/api/DisposalNodes', { params: params }).subscribe(data => { //处置节点 this.canvasData.allDisposalNode = data this.handleHybridTree() }) } - treeData:any = []; //渲染tree处理完成数据 - defaultExpandedKeys:any = []; //首次渲染 tree展开状态 + treeData: any = []; //渲染tree处理完成数据 + defaultExpandedKeys: any = []; //首次渲染 tree展开状态 //处理 节点 Tree数据 - handleHybridTree () { + handleHybridTree() { this.defaultExpandedKeys = [] let treeData = [] - let data = JSON.parse(JSON.stringify( this.canvasData.allDisposalNode || [] )) + let data = JSON.parse(JSON.stringify(this.canvasData.allDisposalNode || [])) data.forEach(element => { this.defaultExpandedKeys.push(element.id) element.title = element.name //name @@ -2176,29 +2179,29 @@ export class CollectionToolsBuildingComponent implements OnInit { element.isLeaf = false element.isDataNode = false } - data.forEach(item=>{ - item.parentId === element.id? element.children.push(item) : null + data.forEach(item => { + item.parentId === element.id ? element.children.push(item) : null }) }); - data.forEach(element=>{ - !element.parentId? treeData.push(element) : null + data.forEach(element => { + !element.parentId ? treeData.push(element) : null }) this.treeData = [...treeData] this.defaultExpandedKeys = [...this.defaultExpandedKeys] } //刷新 treeData 保存已展开节点 - refurbishTreeData () { + refurbishTreeData() { this.defaultExpandedKeys = [] - let params = {disasterId: this.allFirePlan[0].id || ''} - this.http.get('/api/DisposalNodes',{params:params}).subscribe(nodeData=>{ //处置节点 + 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=>{ + oldTreeData.forEach(item => { this.defaultExpandedKeys.push(item.key) }) let treeData = [] - let data = JSON.parse(JSON.stringify( this.canvasData.allDisposalNode || [] )) + let data = JSON.parse(JSON.stringify(this.canvasData.allDisposalNode || [])) data.forEach(element => { element.title = element.name //name element.key = element.id //id @@ -2210,39 +2213,39 @@ export class CollectionToolsBuildingComponent implements OnInit { element.isLeaf = false element.isDataNode = false } - data.forEach(item=>{ - item.parentId === element.id? element.children.push(item) : null + data.forEach(item => { + item.parentId === element.id ? element.children.push(item) : null }) }); - data.forEach(element=>{ - !element.parentId? treeData.push(element) : null + data.forEach(element => { + !element.parentId ? treeData.push(element) : null }) this.treeData = [...treeData] this.defaultExpandedKeys = [...this.defaultExpandedKeys] }) } - sitePlanIcon = {fire:0,force:0} // 总平面图 火源/力量 图标 是否展示 + sitePlanIcon = { fire: 0, force: 0 } // 总平面图 火源/力量 图标 是否展示 //刷新 建筑楼层 匹配 火源/力量 图标 - mateFireForce () { + mateFireForce() { let data = this.canvasData.allNodeMarkers.markers || {} - for(let key in data){ //遍历 火/力量 图标 + 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 + 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 (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 + 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 } } @@ -2252,19 +2255,19 @@ export class CollectionToolsBuildingComponent implements OnInit { 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 + 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 + 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 + buildingMSG[key][keys].fireCount != 0 ? this.sitePlanIcon.fire = 2 : null + buildingMSG[key][keys].forceCount != 0 ? this.sitePlanIcon.force = 2 : null } } } @@ -2272,10 +2275,10 @@ export class CollectionToolsBuildingComponent implements OnInit { } // 切换 基本信息时 刷新 删除 建筑楼层 自定义属性 - mateDeleteCustomize () { - this.canvasData.selectPanelPointBaseData = {description: '', notes: '', weather: '', airTemperature: '', windDirection: '', windScale: ''} + mateDeleteCustomize() { + this.canvasData.selectPanelPointBaseData = { description: '', notes: '', weather: '', airTemperature: '', windDirection: '', windScale: '' } this.defaultExpandedKeys = [] - this.sitePlanIcon = {fire:0,force:0} + this.sitePlanIcon = { fire: 0, force: 0 } this.sitePlanData.forEach(element => { //楼层 delete element.fire delete element.force @@ -2287,30 +2290,30 @@ export class CollectionToolsBuildingComponent implements OnInit { } //计算差异 - countValue (e) { + countValue(e) { e.stopPropagation() - let params = {disasterId: this.allFirePlan[0].id || ''} - this.http.get('/api/DisasterData/Diffs',{params:params}).subscribe(data=>{ + 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); + this.snackBar.open('计算差异完成', '确定', config); }) } //复制 处置预案 节点 - copyPanelPoint (e,item,treeData) { + copyPanelPoint(e, item, treeData) { e.stopPropagation() if (confirm(`确定要复制 ${item.title} ?`)) { - let params = {id: item.origin.id} + let params = { id: item.origin.id } let order - if (item.level==0) { - treeData.length? order = treeData[treeData.length-1].order+1 : order = 0 + 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 + parent.origin.children.length ? order = parent.origin.children[parent.origin.children.length - 1].order + 1 : order = 0 } let data = { name: item.title + '(副本)', @@ -2321,41 +2324,41 @@ export class CollectionToolsBuildingComponent implements OnInit { parentId: item.origin.parentId || null, planComponentId: item.origin.planComponentId || '', } - this.http.post('/api/DisposalNodes/Clone',data,{params:params}).subscribe(data=>{ + this.http.post('/api/DisposalNodes/Clone', data, { params: params }).subscribe(data => { this.refurbishTreeData() }) } //isTrue } //删除 处置预案 节点 - deletePanelPoint (e,item) { + deletePanelPoint(e, item) { e.stopPropagation() if (confirm(`确定要删除 ${item.name} ?`)) { - this.http.delete(`/api/DisposalNodes/${item.id}`).subscribe(data=>{ + this.http.delete(`/api/DisposalNodes/${item.id}`).subscribe(data => { this.refurbishTreeData() }) } } //点击 处置Tree节点 - selectanelPoint (e) { + 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 //选中 节点 + 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 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 + 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 => { 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) @@ -2366,36 +2369,36 @@ export class CollectionToolsBuildingComponent implements OnInit { } //查找 数据节点 对应 建筑/楼层 - seekPanelPoint (paramsData) { + seekPanelPoint(paramsData) { this.checkedBuildingIndex = paramsData.buildingIndex - if (paramsData.buildingIndex ==-1) { //总平面图时 - this.beforeOneCheckedBuilding={name:"总平面图"} + 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.http.get('/api/SitePlans', { params: this.params }).subscribe(data => { this.sitePlanData = data - let index = this.sitePlanData.findIndex(item=>{ return item.id===paramsData.storeyId }) + 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)=>{ + + Promise.all([fireData, planData]).then((res) => { this.getSitePlanStorey(this.selectingSitePlan) //获取 平面图 楼层数据 }) }) //get } else { //建筑时 - this.beforeOneCheckedBuilding=this.allBuildings[paramsData.buildingIndex] + 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.http.get('/api/BuildingAreas', { params }).subscribe(data => { this.sitePlanData = data - let index = this.sitePlanData.findIndex(item=>{ return item.id===paramsData.storeyId }) + 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)=>{ + + Promise.all([fireData, planData]).then((res) => { this.getBuildingStorey(this.selectingSitePlan) //获取 建筑 楼层数据 }) }) //get @@ -2416,30 +2419,30 @@ export class CollectionToolsBuildingComponent implements OnInit { }) export class CreateBuildingBuilding { - constructor(private http:HttpClient,public dialog: MatDialog,public dialogRef: MatDialogRef,@Inject(MAT_DIALOG_DATA) public data) { } + constructor(private http: HttpClient, public dialog: MatDialog, public dialogRef: MatDialogRef, @Inject(MAT_DIALOG_DATA) public data) { } - allBuildingType:any//所有的建筑类型 - selected:any; //选中的建筑 + allBuildingType: any//所有的建筑类型 + selected: any; //选中的建筑 ngOnInit(): void { this.getAllBuildingType() } //获得所有单位类型 - getAllBuildingType(){ - this.http.get("/api/BuildingTypes/Simple").subscribe(data=>{ + getAllBuildingType() { + this.http.get("/api/BuildingTypes/Simple").subscribe(data => { this.allBuildingType = data }) } //创建建筑功能分区 - onSubmit (e) { + 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 = + let data = { id: "", name: e.propertyName, - order: lastBuildingOrder , + order: lastBuildingOrder, enabled: true, companyId: companyId, buildingTypes: [ @@ -2449,13 +2452,13 @@ export class CreateBuildingBuilding { } ] } - this.http.post("/api/Buildings",data,{ - params:{ - companyId : this.data.companyId + this.http.post("/api/Buildings", data, { + params: { + companyId: this.data.companyId } - }).subscribe(data=>{ + }).subscribe(data => { this.dialogRef.close("创建成功"); - },err=>{ + }, err => { this.dialogRef.close("创建失败"); }) } @@ -2469,26 +2472,26 @@ export class CreateBuildingBuilding { }) 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//所有的建筑类型 + 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=>{ + getAllBuildingType() { + this.http.get("/api/BuildingTypes/Simple").subscribe(data => { this.allBuildingType = data }) } //编辑建筑信息 - onSubmit (e) { + onSubmit(e) { let companyId = sessionStorage.getItem("companyId") - let data = + let data = { id: this.data.item.id, name: e.propertyName, @@ -2502,14 +2505,14 @@ export class EditBuildingBuilding { } ] } - this.http.put(`/api/Buildings/${this.data.item.id}`,data,{ - params:{ - id:this.data.item.id, - companyId:companyId + this.http.put(`/api/Buildings/${this.data.item.id}`, data, { + params: { + id: this.data.item.id, + companyId: companyId } - }).subscribe(data=>{ + }).subscribe(data => { this.dialogRef.close("修改成功"); - },err=>{ + }, err => { this.dialogRef.close("修改失败"); }) } 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 761775a..b9f8423 100644 --- a/src/app/ui/collection-tools-plan/collection-tools.component.html +++ b/src/app/ui/collection-tools-plan/collection-tools.component.html @@ -30,6 +30,7 @@ 重置缩放 + 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 22c666e..285f5b4 100644 --- a/src/app/ui/collection-tools-plan/collection-tools.component.ts +++ b/src/app/ui/collection-tools-plan/collection-tools.component.ts @@ -1,15 +1,15 @@ -import { Component, OnInit, Inject, ViewChild,ElementRef,Renderer2, ViewContainerRef, NgZone } from '@angular/core'; +import { Component, OnInit, Inject, ViewChild, ElementRef, Renderer2, ViewContainerRef, NgZone } 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 {leftFunctionalDomainComponentPlan,editPlaneFigureComponentPlan} 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 { leftFunctionalDomainComponentPlan, editPlaneFigureComponentPlan } 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 { NzFormatBeforeDropEvent, NzFormatEmitEvent,NzTreeComponent } from 'ng-zorro-antd/tree'; +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'; @@ -24,9 +24,9 @@ import { AxMessageSystem } from 'src/app/working-area/model/axMessageSystem'; }) export class CollectionToolsPlanComponent implements OnInit { - @ViewChild('canvas',{static: true}) canvas:WorkingAreaComponent; //父组件中获得子组件的引用 + @ViewChild('canvas', { static: true }) canvas: WorkingAreaComponent; //父组件中获得子组件的引用 - constructor(public _ngZone:NgZone,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) { } + constructor(public _ngZone: NgZone, 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) => {//要给渲染节点传那些属性参数 @@ -35,36 +35,36 @@ export class CollectionToolsPlanComponent implements OnInit { 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 + 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'] + 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 = {name:"总平面图"}; //当前点击选择的建筑 - checkedBuildingIndex:number = -1 //当前点击选择的建筑index - isEditPat:boolean = true //当前是否是编辑模式 - - assetName:String//素材名称 - assetWidth:number//素材宽度 - assetHeight:number//素材高度 - sliderValue:number = 0//角度滑竿的值 - sliderValueThickness:number = 0//厚度滑竿的值 - isHighLight:boolean = false//是否高亮选择框 + beforeOneCheckedBuilding: any = { name: "总平面图" }; //当前点击选择的建筑 + checkedBuildingIndex: number = -1 //当前点击选择的建筑index + isEditPat: boolean = true //当前是否是编辑模式 + + assetName: String//素材名称 + assetWidth: number//素材宽度 + assetHeight: number//素材高度 + sliderValue: number = 0//角度滑竿的值 + sliderValueThickness: number = 0//厚度滑竿的值 + isHighLight: boolean = false//是否高亮选择框 PropertyInfos = [] //去除图片链接真正用于循环的内容 imagesArrNum //素材属性图片数量上限 imagesArr = [] //属性中的图片链接集合 @@ -73,28 +73,28 @@ export class CollectionToolsPlanComponent implements OnInit { //传入素材对象,设置右侧属性栏内容 canvasAssetObj //传入的素材属性对象 isImgNumCss = false //控制上传文件input显隐 - mySwiper:any //轮播图实例 + mySwiper: any //轮播图实例 gallery//viewerJs实例 //设置属性框 - setAssetsProperty(obj){ + setAssetsProperty(obj) { //初始化viewerJs实例 setTimeout(() => { obj.PropertyInfos.forEach(item => { - if(item.PropertyType == 4){ - if(document.getElementById('viewerjs')){ - this.gallery = new Viewer(document.getElementById('viewerjs'),{ + if (item.PropertyType == 4) { + if (document.getElementById('viewerjs')) { + 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) + let strh = color.substring(color.length - 2, color.length) + let opacity = Math.round(parseInt(strh, 16) / 255 * 100) this.colorDivSliderValue = opacity this.isShowProperty = true @@ -113,18 +113,18 @@ export class CollectionToolsPlanComponent implements OnInit { this.PropertyInfos = obj.PropertyInfos this.sliderValueThickness = obj.Thickness this.PropertyInfos.forEach(item => { - if(item.PropertyType == 3){ //如果是图片链接类型 + if (item.PropertyType == 3) { //如果是图片链接类型 this.imagesArr.push(item) } - if(item.PropertyType == 4){//图片数值上线 + if (item.PropertyType == 4) {//图片数值上线 this.imagesArrNum = item.PropertyValue } }) //如果存在图片则加载轮播图 - if(this.imagesArr.length){ + if (this.imagesArr.length) { setTimeout(() => { - this.mySwiper = new Swiper('.swiper-container',{ + this.mySwiper = new Swiper('.swiper-container', { loop: false, // grabCursor: true, // 如果需要前进后退按钮 @@ -132,8 +132,8 @@ export class CollectionToolsPlanComponent implements OnInit { nextEl: '.swiper-button-next', prevEl: '.swiper-button-prev', }, - on:{ - click: function(){ + on: { + click: function () { _this.clickedIndex = this.clickedIndex }, } @@ -141,16 +141,16 @@ export class CollectionToolsPlanComponent implements OnInit { }, 0); } //判断此时图片数量是否达到上限 - if(this.imagesArr.length < this.imagesArrNum){//如果不超出 + if (this.imagesArr.length < this.imagesArrNum) {//如果不超出 this.isImgNumCss = true - }else{ + } else { this.isImgNumCss = false } } - pattern:boolean = true//默认为基本信息编辑 - + pattern: boolean = true//默认为基本信息编辑 + //基本信息编辑模式 - baseInfo(){ + baseInfo() { if (!this.pattern) { this.pattern = true this.canvasData.gameMode = GameMode.BasicInformation @@ -163,7 +163,7 @@ export class CollectionToolsPlanComponent implements OnInit { } //想定作业编辑模式 - wantWork(){ + wantWork() { if (this.pattern) { this.pattern = false this.canvasData.gameMode = GameMode.Assignment @@ -173,117 +173,117 @@ export class CollectionToolsPlanComponent implements OnInit { } //适应缩放 - adaptZoom(){ + adaptZoom() { this.canvas.zoomFit() } //重置缩放 - resetZoom(){ + resetZoom() { this.canvas.resetCamera2D() } //ngzorro tree 拖拽 nzEvent(event: NzFormatEmitEvent): void { - if(this.isDrag){ - let parentId - if(this.pos == 0){ + if (this.isDrag) { + let parentId + if (this.pos == 0) { parentId = event.node.key - }else{ - if(event.node.level == 0){ + } else { + if (event.node.level == 0) { parentId = null - }else{ + } else { parentId = event.node.origin.parentId } } - + let orders = {} - let originalData = JSON.parse(JSON.stringify( this.canvasData.allDisposalNode || [] )) //tree原始数据 + let originalData = JSON.parse(JSON.stringify(this.canvasData.allDisposalNode || [])) //tree原始数据 let targetNodeData = []//拖动移入节点的数据,用于遍历求出放在该数组的第几位 //找到需要重新排序的数组 - if(this.pos == 0){ + if (this.pos == 0) { originalData.forEach(item => { - if(item.parentId == event.node.key){ + if (item.parentId == event.node.key) { targetNodeData.push(item) } }) - }else{ - if(event.node.origin.parentId){//如果拖动目标为非一级节点 + } else { + if (event.node.origin.parentId) {//如果拖动目标为非一级节点 originalData.forEach(item => { - if(item.parentId == event.node.origin.parentId){ + if (item.parentId == event.node.origin.parentId) { targetNodeData.push(item) } }) - }else{//如果拖动目标为一级节点 + } else {//如果拖动目标为一级节点 originalData.forEach(item => { - if(!item.parentId){ + 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 + if (this.pos == 0 && event.node.origin.children.length == 1) { + let key = event.dragNode.key orders[key] = 0 parentId = event.node.key - }else{ + } else { let array = [] targetNodeData.forEach(item => { - if(item.id != event.dragNode.key){ //将拖动项先移除掉 + if (item.id != event.dragNode.key) { //将拖动项先移除掉 array.push(item) } }) - if(event.dragNode.isEnd[event.dragNode.isEnd.length - 1]){ //如果移入到最后一个 + if (event.dragNode.isEnd[event.dragNode.isEnd.length - 1]) { //如果移入到最后一个 array.push(event.dragNode.origin) - }else if(event.dragNode.isStart[event.dragNode.isStart.length - 1]){//如果移入到第一个 + } else if (event.dragNode.isStart[event.dragNode.isStart.length - 1]) {//如果移入到第一个 array.unshift(event.dragNode.origin) - }else{//如果移入中间位置 + } else {//如果移入中间位置 array.splice(event.node.origin.order, 0, event.dragNode.origin) } - array.forEach((item,key) => { + array.forEach((item, key) => { orders[item.id] = key }) } - - let obj ={ - id : event.dragNode.origin.id, - parentId : parentId, - orders : orders + + let obj = { + id: event.dragNode.origin.id, + parentId: parentId, + orders: orders } - - this.http.put("/api/DisposalNodes/Sort",obj).subscribe(data => { + + this.http.put("/api/DisposalNodes/Sort", obj).subscribe(data => { const config = new MatSnackBarConfig(); config.verticalPosition = 'top'; config.duration = 3000 - this.snackBar.open('排序成功','确定',config) + this.snackBar.open('排序成功', '确定', config) this.refurbishTreeData() }) } } - + isDrag //是否可以拖动 pos//放置位置 beforeDrop = (arg: NzFormatBeforeDropEvent) => { - if(arg.dragNode.origin.isDataNode && arg.node.level === 0){//如果为数据节点则不允许拖到一级节点 + if (arg.dragNode.origin.isDataNode && arg.node.level === 0) {//如果为数据节点则不允许拖到一级节点 const config = new MatSnackBarConfig(); config.verticalPosition = 'top'; config.duration = 3000 - this.snackBar.open('数据节点不允许拖拽到一级节点','确定',config) + this.snackBar.open('数据节点不允许拖拽到一级节点', '确定', config) this.isDrag = false return of(false); - }else if(!arg.dragNode.origin.isDataNode && arg.node.level === 2){ + } 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.snackBar.open('处置节点不允许拖拽到三级节点', '确定', config) this.isDrag = false return of(false); - }else{ + } else { this.isDrag = true this.pos = arg.pos return of(true) @@ -293,35 +293,35 @@ export class CollectionToolsPlanComponent implements OnInit { //天气栏目 weatherBtn = true - weatherBtnShow(){ + weatherBtnShow() { this.weatherBtn = !this.weatherBtn } - weatherBtnHidden(){ + weatherBtnHidden() { this.weatherBtn = !this.weatherBtn } //底部切换按钮div detailsAndattentBtn = true //节点详情 - details(){ + details() { this.detailsAndattentBtn = true } //注意事项 - attent(){ + attent() { this.detailsAndattentBtn = false } //消防要素div边框高度调节 - firecategoriesDivMouseDown(e){ + 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' + 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 = () => { @@ -331,13 +331,13 @@ export class CollectionToolsPlanComponent implements OnInit { } //左侧div边框宽度调节 - leftDivMouseDown(e){ + 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){ + if (ev.clientX - 240 >= maxWidth) { this.element.nativeElement.querySelector('#leftDiv').style.width = maxWidth + 'px' - }else{ + } else { this.element.nativeElement.querySelector('#leftDiv').style.width = ev.clientX - 260 + 'px'; } } @@ -348,14 +348,14 @@ export class CollectionToolsPlanComponent implements OnInit { } //底部div高度调节 - bottomDivMouseDown(e){ + 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' ; + 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 = () => { @@ -365,13 +365,13 @@ export class CollectionToolsPlanComponent implements OnInit { } //右侧div边框宽度调节 - rightDivMouseDown(e){ + 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){ + if (bodyWidth - ev.clientX >= maxWidth) { this.element.nativeElement.querySelector('#rightDiv').style.width = maxWidth + 'px' - }else{ + } else { this.element.nativeElement.querySelector('#rightDiv').style.width = bodyWidth - ev.clientX + 'px'; } } @@ -382,41 +382,41 @@ export class CollectionToolsPlanComponent implements OnInit { } //放大图标 - iconScale(){ + iconScale() { let number = Number(this.selected) this.canvas.setIconScale(number) } //素材宽度输入框改变 - assetWidthIunput(){ + assetWidthIunput() { this.canvasAssetObj.Width = this.assetWidth this.canvasData.isChange = true this.canvas.refreshIcon(this.canvasAssetObj.Id) } //素材高度输入框改变 - assetHeightIunput(){ + assetHeightIunput() { this.canvasAssetObj.Height = this.assetHeight this.canvasData.isChange = true this.canvas.refreshIcon(this.canvasAssetObj.Id) } //素材角度输入框改变 - assetAngleIunput(){ + assetAngleIunput() { this.canvasAssetObj.Angle = this.sliderValue this.canvasData.isChange = true this.canvas.refreshIcon(this.canvasAssetObj.Id) } //素材厚度输入框改变 - assetThicknessIunput(){ + assetThicknessIunput() { this.canvasAssetObj.Thickness = this.sliderValueThickness this.canvasData.isChange = true this.canvas.refreshIcon(this.canvasAssetObj.Id) } //素材是否高亮改变----->本地操作行为 - assetHighLightIunput(){ + assetHighLightIunput() { // console.log(this.isHighLight,this.canvasAssetObj) // let arr = [] // arr.push(this.canvasAssetObj.Id) @@ -428,11 +428,11 @@ export class CollectionToolsPlanComponent implements OnInit { return typeof value === 'number' && !isNaN(value); } //动态属性素材input框值改变 - assetInputChange(i,e){ - let index = this.canvasAssetObj.PropertyInfos.findIndex((item)=>{ + assetInputChange(i, e) { + let index = this.canvasAssetObj.PropertyInfos.findIndex((item) => { return i.PropertyName == item.PropertyName }) - if(this.myIsNaN(e.target.value)){ + if (this.myIsNaN(e.target.value)) { e.target.value = String(e.target.value) } this.canvasAssetObj.PropertyInfos[index].PropertyValue = e.target.value @@ -441,8 +441,8 @@ export class CollectionToolsPlanComponent implements OnInit { } //动态属性素材布尔值框改变radio - assetRadioChange(i,boolean){ - let index = this.canvasAssetObj.PropertyInfos.findIndex((item)=>{ + assetRadioChange(i, boolean) { + let index = this.canvasAssetObj.PropertyInfos.findIndex((item) => { return i.PropertyName == item.PropertyName }) this.canvasAssetObj.PropertyInfos[index].PropertyValue = boolean @@ -452,35 +452,35 @@ export class CollectionToolsPlanComponent implements OnInit { colorIndex//默认素材颜色 selectedcolor//点击选择的颜色 //选择素材颜色 - selectcolor(item,key){ + selectcolor(item, key) { //在当前透明度基础上改变颜色 - this.selectedcolor = item + this.selectedcolor.substring(this.selectedcolor.length-2) + 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) + 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; + 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.selectedcolor = replacepos(this.selectedcolor, 7, 8, colorOpacity.toString(16)) this.canvasAssetObj.Color = this.selectedcolor this.canvasData.isChange = true this.canvas.refreshIcon(this.canvasAssetObj.Id) } //上传素材图片 - selectFile(e){ + selectFile(e) { let imgFile = e.target.files[0] || null //上传的文件 this.startUploading(imgFile) } - objectName:any //上传对象名 - startUploading (imgFile) { + objectName: any //上传对象名 + startUploading(imgFile) { let _this = this let file = imgFile || null //获取上传的文件 let fileSize = file.size || null //上传文件的总大小 @@ -488,13 +488,13 @@ export class CollectionToolsPlanComponent implements OnInit { 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)=>{ + 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) + this.snackBar.open('上传成功', '确定', config) //在原始素材对象和需要循环图片的对象中分别push最新上传的图片 let imgObj = { @@ -510,12 +510,12 @@ export class CollectionToolsPlanComponent implements OnInit { "PropertyType": 3, "PropertyValue": "/api/Objects/WebPlan2D/" + this.objectName } - + this.imagesArr.push(imgObj) this.canvasAssetObj.PropertyInfos.push(imgObj) setTimeout(() => { - this.mySwiper = new Swiper('.swiper-container',{ + this.mySwiper = new Swiper('.swiper-container', { loop: false, // grabCursor: true, // 如果需要前进后退按钮 @@ -523,8 +523,8 @@ export class CollectionToolsPlanComponent implements OnInit { nextEl: '.swiper-button-next', prevEl: '.swiper-button-prev', }, - on:{ - click: function(){ + on: { + click: function () { _this.clickedIndex = this.clickedIndex }, } @@ -533,44 +533,44 @@ export class CollectionToolsPlanComponent implements OnInit { this.mySwiper.slideTo(this.imagesArr.length - 1) this.gallery.update() }, 0); - + //判断上传素材属性图片是否超出数量 超出数量则隐藏input框 - if(this.imagesArr.length < this.imagesArrNum){//不超出input才会显示 + if (this.imagesArr.length < this.imagesArrNum) {//不超出input才会显示 this.isImgNumCss = true - }else{ + } else { this.isImgNumCss = false } - + this.canvasData.isChange = true }) - } else if (file && fileSize>shardSize) { //上传文件>5MB时,分块上传 + } else if (file && fileSize > shardSize) { //上传文件>5MB时,分块上传 let config = new MatSnackBarConfig(); config.verticalPosition = 'top'; config.duration = 3000 - this.snackBar.open('上传图片文件不允许大于5mb','确定',config); + this.snackBar.open('上传图片文件不允许大于5mb', '确定', config); } } //不能上传图片提示 - imgNumBeyond(){ + imgNumBeyond() { const config = new MatSnackBarConfig(); config.verticalPosition = 'top'; config.duration = 3000 - this.snackBar.open('图片数量已达上限','确定',config); + this.snackBar.open('图片数量已达上限', '确定', config); } //删除素材属性图片 - deleteImg(){ - if(this.imagesArr.length == 0){ + deleteImg() { + if (this.imagesArr.length == 0) { const config = new MatSnackBarConfig(); config.verticalPosition = 'top'; config.duration = 3000 - this.snackBar.open('没有可删除的图片,请先上传','确定',config) - }else{ + this.snackBar.open('没有可删除的图片,请先上传', '确定', config) + } else { // 在素材原始对象中将删除的图片去掉 - this.canvasAssetObj.PropertyInfos = [...this.canvasAssetObj.PropertyInfos.filter((item)=>{ - return item.PropertyValue != this.imagesArr[this.mySwiper.activeIndex].PropertyValue + this.canvasAssetObj.PropertyInfos = [...this.canvasAssetObj.PropertyInfos.filter((item) => { + return item.PropertyValue != this.imagesArr[this.mySwiper.activeIndex].PropertyValue })] //在图片循环数组中将图片去掉 this.imagesArr.splice(this.mySwiper.activeIndex, 1); @@ -583,7 +583,7 @@ export class CollectionToolsPlanComponent implements OnInit { //将上传的input框显示出来 this.isImgNumCss = true; //清除图片缓存 - if((document.getElementById('inputimg'))){ + if ((document.getElementById('inputimg'))) { (document.getElementById('inputimg')).value = null //清空input框缓存 } @@ -592,8 +592,8 @@ export class CollectionToolsPlanComponent implements OnInit { } //动态属性方向select选择框 - direction(i,e){ - let index = this.canvasAssetObj.PropertyInfos.findIndex((item)=>{ + direction(i, e) { + let index = this.canvasAssetObj.PropertyInfos.findIndex((item) => { return i.PropertyName == item.PropertyName }) this.canvasAssetObj.PropertyInfos[index].PropertyValue = e.target.value @@ -601,8 +601,8 @@ export class CollectionToolsPlanComponent implements OnInit { } //动态属性供给区域select选择框 - supplyArea(i,e){ - let index = this.canvasAssetObj.PropertyInfos.findIndex((item)=>{ + supplyArea(i, e) { + let index = this.canvasAssetObj.PropertyInfos.findIndex((item) => { return i.PropertyName == item.PropertyName }) this.canvasAssetObj.PropertyInfos[index].PropertyValue = e.target.value @@ -610,8 +610,8 @@ export class CollectionToolsPlanComponent implements OnInit { } //动态属性供给类型select选择框 - supplyType(i,e){ - let index = this.canvasAssetObj.PropertyInfos.findIndex((item)=>{ + supplyType(i, e) { + let index = this.canvasAssetObj.PropertyInfos.findIndex((item) => { return i.PropertyName == item.PropertyName }) this.canvasAssetObj.PropertyInfos[index].PropertyValue = e.target.value @@ -620,64 +620,64 @@ export class CollectionToolsPlanComponent implements OnInit { isediticon = true //控制查看编辑模式的编辑模式小笔按钮 - isMultipleAsset:boolean = false//框选多个素材属性显隐 - multipleAsset:any = { - Width:null, - Height:null, - Angle:null, - Thickness:null, - Color:null, - PropertyInfos:[] + isMultipleAsset: boolean = false//框选多个素材属性显隐 + multipleAsset: any = { + Width: null, + Height: null, + Angle: null, + Thickness: null, + Color: null, + PropertyInfos: [] }//多个素材共同属性 - multipleAssetData:any//当前多选的素材 - firstMultipleAssetData:any//当前多选的第一个素材 + multipleAssetData: any//当前多选的素材 + firstMultipleAssetData: any//当前多选的第一个素材 ngOnInit(): void { let _this = this - AxMessageSystem.addListener('selectionChanged', ()=>{ - if(this.canvas.selection.size() == 1){//如果是单选 + AxMessageSystem.addListener('selectionChanged', () => { + if (this.canvas.selection.size() == 1) {//如果是单选 this.isMultipleAsset = false // console.log('单选',this.canvas.selection.first().assetData) this.setAssetsProperty(this.canvas.selection.first().assetData) - }else if(this.canvas.selection.size()){ + } else if (this.canvas.selection.size()) { this.isShowProperty = true this.multipleAssetData = this.canvas.selection.all() this.firstMultipleAssetData = this.canvas.selection.first() this.multipleAsset = { - Width:null, - Height:null, - Angle:null, - Thickness:null, - Color:null, - PropertyInfos:[] + Width: null, + Height: null, + Angle: null, + Thickness: null, + Color: null, + PropertyInfos: [] } this.isMultipleAsset = true let firstAssetData = this.canvas.selection.first().assetData;//拿出第一个素材作为例子与其他素材进行对比 let InteractiveMode = firstAssetData.InteractiveMode //素材连接方式 let isInteractiveMode = this.canvas.selection.all().every(item => item.assetData.InteractiveMode === InteractiveMode) - if(isInteractiveMode){ + if (isInteractiveMode) { this.multipleAsset.InteractiveMode = InteractiveMode } let isFillMode = this.canvas.selection.all().every(item => item.assetData.FillMode === 0) //素材填充方式都为0 - if(isFillMode){ + if (isFillMode) { this.multipleAsset.FillMode = 0 } this.canvas.selection.first().assetData.PropertyInfos.forEach(i => { let index = 0 this.canvas.selection.all().forEach(item => { item.assetData.PropertyInfos.forEach(element => { - if(element.PropertyName == i.PropertyName && element.PropertyType == i.PropertyType && element.PropertyType != 3 && element.PropertyType != 4){ + if (element.PropertyName == i.PropertyName && element.PropertyType == i.PropertyType && element.PropertyType != 3 && element.PropertyType != 4) { index++ - if(index == this.canvas.selection.size()){ + if (index == this.canvas.selection.size()) { let newElement = JSON.parse(JSON.stringify(element)) newElement.PropertyValue = '' this.multipleAsset.PropertyInfos.push(newElement) } } }); - }) + }) }) // console.log(666,_this.multipleAsset.PropertyInfos) - }else if(this.canvas.selection.size() == 0){ + } else if (this.canvas.selection.size() == 0) { this.isShowProperty = false } }, this) @@ -685,16 +685,16 @@ export class CollectionToolsPlanComponent implements OnInit { this.assetWidth = args1.Width this.assetHeight = args1.Height }, this) - if(this.router.url.indexOf("keyUnit/viewunitinfo") != -1){ //查看模式 + if (this.router.url.indexOf("keyUnit/viewunitinfo") != -1) { //查看模式 this.isEditPattern = false this.isediticon = false this.canvasData.gameMode = GameMode.Assignment - } else if (this.router.url.indexOf("keyUnit/editplaninfo")!= -1) { //编辑模式 + } else if (this.router.url.indexOf("keyUnit/editplaninfo") != -1) { //编辑模式 this.canvasData.gameMode = GameMode.BasicInformation } //gis模块平面图 - if((this.router.url.indexOf("gis") != -1 || this.router.url.indexOf("waitexamineergis") != -1) && sessionStorage.getItem("gisplan") == "look"){ + if ((this.router.url.indexOf("gis") != -1 || this.router.url.indexOf("waitexamineergis") != -1) && sessionStorage.getItem("gisplan") == "look") { this.isEditPattern = false this.isediticon = false this.canvasData.gameMode = GameMode.Assignment @@ -703,86 +703,86 @@ export class CollectionToolsPlanComponent implements OnInit { } let that = this - window.setTimeout(()=>{ + 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.canvasData.getMessage().subscribe((message: any) => { + if (message == "send a message") { // this.refurbishTreeData() } }) } //多选宽度共同改变 - multipleAssetWidthInput(){ - this.multipleAssetData.forEach(item=>{ + multipleAssetWidthInput() { + this.multipleAssetData.forEach(item => { item.assetData.Width = this.multipleAsset.Width this.canvas.refreshIcon(item.assetData.Id) this.canvasData.isChange = true }) } //多选高度共同改变 - multipleAssetHeightInput(){ - this.multipleAssetData.forEach(item=>{ + multipleAssetHeightInput() { + this.multipleAssetData.forEach(item => { item.assetData.Height = this.multipleAsset.Height this.canvas.refreshIcon(item.assetData.Id) this.canvasData.isChange = true }) } //多选角度共同改变 - multipleAssetAngleInput(){ - this.multipleAssetData.forEach(item=>{ + multipleAssetAngleInput() { + this.multipleAssetData.forEach(item => { item.assetData.Angle = this.multipleAsset.Angle this.canvas.refreshIcon(item.assetData.Id) this.canvasData.isChange = true }) } //多选厚度共同改变 - multipleAssetThicknessInput(){ - this.multipleAssetData.forEach(item=>{ + multipleAssetThicknessInput() { + this.multipleAssetData.forEach(item => { item.assetData.Thickness = this.multipleAsset.Thickness this.canvas.refreshIcon(item.assetData.Id) this.canvasData.isChange = true }) } //多选颜色共同改变 - multipleSelectedcolor:any - multipleAssetSelectcolor(item,key){ + multipleSelectedcolor: any + multipleAssetSelectcolor(item, key) { //在当前透明度基础上改变颜色 this.multipleSelectedcolor = item - this.multipleAssetData.forEach(item=>{ + this.multipleAssetData.forEach(item => { item.assetData.Color = this.multipleSelectedcolor this.canvasData.isChange = true this.canvas.refreshIcon(item.assetData.Id) }) } //多选颜色滑竿改变 - multipleColorDivSliderChange(){ - let colorOpacity = Math.round(255 * this.colorDivSliderValue * 0.01) + multipleColorDivSliderChange() { + 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; + function replacepos(text, start, stop, replacetext) { + let mystr = text.substring(0, stop - 1) + replacetext + text.substring(stop + 1); + return mystr; } - this.multipleAssetData.forEach(item=>{ - this.multipleSelectedcolor = replacepos(this.multipleSelectedcolor,7,8,colorOpacity.toString(16)) + this.multipleAssetData.forEach(item => { + this.multipleSelectedcolor = replacepos(this.multipleSelectedcolor, 7, 8, colorOpacity.toString(16)) item.assetData.Color = this.multipleSelectedcolor this.canvasData.isChange = true this.canvas.refreshIcon(item.assetData.Id) }) } //多选状态动态属性素材input框值改变 - multipleAssetInputChange(i,e){ + multipleAssetInputChange(i, e) { e.stopPropagation() setTimeout(() => { - this.multipleAssetData.forEach(item=>{ + this.multipleAssetData.forEach(item => { item.assetData.PropertyInfos.forEach(element => { - if(element.PropertyName == i.PropertyName){ - if(this.myIsNaN(i.PropertyValue)){ + if (element.PropertyName == i.PropertyName) { + if (this.myIsNaN(i.PropertyValue)) { i.PropertyValue = String(i.PropertyValue) } element.PropertyValue = i.PropertyValue @@ -794,12 +794,12 @@ export class CollectionToolsPlanComponent implements OnInit { }, 0); } //多选状态动态属性素材radio框值改变 - multipleAssetRadioChange(i,value){ + multipleAssetRadioChange(i, value) { // e.stopPropagation() - this.multipleAssetData.forEach(item=>{ + this.multipleAssetData.forEach(item => { // console.log(item) item.assetData.PropertyInfos.forEach(element => { - if(element.PropertyName == i.PropertyName){ + if (element.PropertyName == i.PropertyName) { element.PropertyValue = value this.canvas.refreshIcon(item.assetData.Id) this.canvasData.isChange = true @@ -808,11 +808,11 @@ export class CollectionToolsPlanComponent implements OnInit { }) } //多选状态动态属性素材下拉框值改变 - multipleSupplyArea(i,e){ + multipleSupplyArea(i, e) { e.stopPropagation() - this.multipleAssetData.forEach(item=>{ + this.multipleAssetData.forEach(item => { item.assetData.PropertyInfos.forEach(element => { - if(element.PropertyName == i.PropertyName){ + if (element.PropertyName == i.PropertyName) { element.PropertyValue = i.PropertyValue this.canvas.refreshIcon(item.assetData.Id) this.canvasData.isChange = true @@ -823,76 +823,80 @@ export class CollectionToolsPlanComponent implements OnInit { ngAfterViewInit(): void { //不是gis模块平面图 - if(this.router.url.indexOf("gis") == -1) { + if (this.router.url.indexOf("gis") == -1) { this.getSitePlan() } //监听数据变化后 - this.canvas.on('canvasDataChanged',()=>{ + this.canvas.on('canvasDataChanged', () => { // 收到数据表示共享数据发生变化 // this.renovateTreeData(false) }); } - copyAssetData:any //存储用于复制的素材 + copyAssetData: any //存储用于复制的素材 //复制素材 - copyAsset(){ + copyAsset() { this.canvas.copy() } //粘贴素材 - pasteAsset(){ + pasteAsset() { let companyId = sessionStorage.getItem("companyId") let buildingId = this.beforeOneCheckedBuilding.id let floorId = this.selectingSitePlan.id - this.canvas.paste(companyId,buildingId,floorId) + this.canvas.paste(companyId, buildingId, floorId) // this.renovateTreeData(false) } + //截图 + takeScreenshot() { + this.canvas.takeScreenshot(); + } - isMultiSelect:boolean = false; // 多选/单选 切换 - changeMultiSelect (e) { this.canvas.setMulitSelect(this.isMultiSelect) } - isShowLegend:boolean = true; //图例是否显示 - changeLegend (e) { this.canvasData.selectPanelPoint.BackgroundImageUrl? null : this.canvas.setLegendVisible(this.isShowLegend) } + isMultiSelect: boolean = false; // 多选/单选 切换 + changeMultiSelect(e) { this.canvas.setMulitSelect(this.isMultiSelect) } + isShowLegend: boolean = true; //图例是否显示 + changeLegend(e) { this.canvasData.selectPanelPoint.BackgroundImageUrl ? null : this.canvas.setLegendVisible(this.isShowLegend) } - basicInfo:boolean = true //基本信息名称显隐 - wantToWork:boolean = true //想定作业名称显隐 + basicInfo: boolean = true //基本信息名称显隐 + wantToWork: boolean = true //想定作业名称显隐 //点击基本信息名称 - basicInfoClick(){ + basicInfoClick() { this.basicInfo = !this.basicInfo - this.canvas.setNameVisible(this.basicInfo,0) + this.canvas.setNameVisible(this.basicInfo, 0) } //点击想定作业名称 - wantToWorkClick(){ + wantToWorkClick() { this.wantToWork = !this.wantToWork - this.canvas.setNameVisible(this.wantToWork,1) + this.canvas.setNameVisible(this.wantToWork, 1) } - isEditPattern:boolean = true //是否为编辑模式 + isEditPattern: boolean = true //是否为编辑模式 //进入编辑模式 - editpat(){ + editpat() { let config = new MatSnackBarConfig(); config.verticalPosition = 'top'; config.duration = 3000 - this.snackBar.open('进入编辑模式','确定',config); + this.snackBar.open('进入编辑模式', '确定', config); this.isEditPattern = true } //进入查看模式 - lookpat(){ + lookpat() { let config = new MatSnackBarConfig(); config.verticalPosition = 'top'; config.duration = 3000 - this.snackBar.open('进入查看模式','确定',config); + this.snackBar.open('进入查看模式', '确定', config); this.isEditPattern = false } //保存平面图 - saveNum :any = [] - saveSite(){ + saveNum: any = [] + saveSite() { //更新用于统计的数据 this.canvasData.updateBuildingData() - - if (this.selectingSitePlan && this.selectingSitePlan.id) { + + if (this.selectingSitePlan && this.selectingSitePlan.id) { //打开遮罩层 this.maskLayerService.sendMessage(true) this.saveNum = [] @@ -900,289 +904,289 @@ export class CollectionToolsPlanComponent implements OnInit { 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){//如果是基本信息编辑模式 + + if (this.pattern) {//如果是基本信息编辑模式 for (const key in object) { if (object[key].Name == "毗邻") {//如果是相同楼层,则筛选出毗邻 - + object[key].PropertyInfos.forEach(element => { - if(element.PropertyName == "方向"){ + if (element.PropertyName == "方向") { adjoinArr.push(element.PropertyValue) } }); } } - - if((new Set(adjoinArr)).size != adjoinArr.length){ + + 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); + this.snackBar.open('保存失败,毗邻存在相同方向', '确定', config); return false - }else{ + } else { //如果是单位 总平面图 - if(this.checkedBuildingIndex==-1){ + if (this.checkedBuildingIndex == -1) { //保存平面图数据 - this.http.post("/api/SitePlanData",SitePlanData,{ - params:{ - companyId:this.params.companyId + this.http.post("/api/SitePlanData", SitePlanData, { + params: { + companyId: this.params.companyId } }).subscribe(data => { this.saveNum.push("1") - if(this.saveNum.length == 5){ + 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.snackBar.open('保存成功', '确定', config); this.tabbarService.sendMessage('changeScore'); } - },err=>{ + }, err => { this.maskLayerService.sendMessage(false) let config = new MatSnackBarConfig(); config.verticalPosition = 'top'; config.duration = 3000 this.canvasData.isChange = true - this.snackBar.open('平面图数据保存失败','确定',config); + this.snackBar.open('平面图数据保存失败', '确定', config); }) - + //保存建筑数据 - this.http.post("/api/CompanyData",CompanyData,{ - params:{ - companyId:this.params.companyId + this.http.post("/api/CompanyData", CompanyData, { + params: { + companyId: this.params.companyId } }).subscribe(data => { this.saveNum.push("1") - if(this.saveNum.length == 5){ + 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.snackBar.open('保存成功', '确定', config); this.tabbarService.sendMessage('changeScore'); } - },err=>{ + }, err => { this.maskLayerService.sendMessage(false) let config = new MatSnackBarConfig(); config.verticalPosition = 'top'; config.duration = 3000 this.canvasData.isChange = true - this.snackBar.open('单位数据保存失败','确定',config); + this.snackBar.open('单位数据保存失败', '确定', config); }) - + //批量保存单位毗邻 let CompanyAdjoins = this.canvasData.getCompanyAdjoinInfo() - this.http.post("/api/CompanyAdjoins/Batch",CompanyAdjoins,{ - params:{ - companyId:this.params.companyId + this.http.post("/api/CompanyAdjoins/Batch", CompanyAdjoins, { + params: { + companyId: this.params.companyId } }).subscribe(data => { this.saveNum.push("1") - if(this.saveNum.length == 5){ + 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.snackBar.open('保存成功', '确定', config); this.tabbarService.sendMessage('changeScore'); } - },err=>{ + }, 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); + 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 + this.http.post("/api/CompanyImportantLocations/Batch", CompanyImportantLocations, { + params: { + companyId: this.params.companyId } }).subscribe(data => { this.saveNum.push("1") - if(this.saveNum.length == 5){ + 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.snackBar.open('保存成功', '确定', config); this.tabbarService.sendMessage('changeScore'); } - },err=>{ + }, err => { this.maskLayerService.sendMessage(false) let config = new MatSnackBarConfig(); config.verticalPosition = 'top'; config.duration = 3000 this.canvasData.isChange = true - this.snackBar.open('单位重点部位同步失败','确定',config); + this.snackBar.open('单位重点部位同步失败', '确定', config); }) - + //批量保存单位消防设施素材 let CompanyFacilityAssets = this.canvasData.getAllCompanyFacilityAssetInfo() - this.http.post("/api/CompanyFacilityAssets/Batch",CompanyFacilityAssets,{ - params:{ - companyId:this.params.companyId + this.http.post("/api/CompanyFacilityAssets/Batch", CompanyFacilityAssets, { + params: { + companyId: this.params.companyId } }).subscribe(data => { this.saveNum.push("1") - if(this.saveNum.length == 5){ + 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.snackBar.open('保存成功', '确定', config); this.tabbarService.sendMessage('changeScore'); } - },err=>{ + }, err => { this.maskLayerService.sendMessage(false) let config = new MatSnackBarConfig(); config.verticalPosition = 'top'; config.duration = 3000 this.canvasData.isChange = true - this.snackBar.open('单位消防设施素材同步失败','确定',config); + this.snackBar.open('单位消防设施素材同步失败', '确定', config); }) - - }else{ //如果是建筑 - + + } else { //如果是建筑 + //建筑平面图数据 - this.http.post("/api/BuildingAreaData",SitePlanData,{ - params:{ - companyId:this.params.companyId + this.http.post("/api/BuildingAreaData", SitePlanData, { + params: { + companyId: this.params.companyId } }).subscribe(data => { this.saveNum.push("1") - if(this.saveNum.length == 5){ + 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.snackBar.open('保存成功', '确定', config); this.tabbarService.sendMessage('changeScore'); } - },err=>{ + }, err => { this.maskLayerService.sendMessage(false) let config = new MatSnackBarConfig(); config.verticalPosition = 'top'; config.duration = 3000 this.canvasData.isChange = true - this.snackBar.open('平面图数据保存失败','确定',config); + this.snackBar.open('平面图数据保存失败', '确定', config); }) - + //建筑数据 - this.http.post("/api/BuildingData",CompanyData,{ - params:{ - companyId:this.params.companyId + this.http.post("/api/BuildingData", CompanyData, { + params: { + companyId: this.params.companyId } }).subscribe(data => { this.saveNum.push("1") - if(this.saveNum.length == 5){ + 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.snackBar.open('保存成功', '确定', config); this.tabbarService.sendMessage('changeScore'); } - },err=>{ + }, err => { this.maskLayerService.sendMessage(false) let config = new MatSnackBarConfig(); config.verticalPosition = 'top'; config.duration = 3000 this.canvasData.isChange = true - this.snackBar.open('单位数据保存失败','确定',config); + 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.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){ + 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.snackBar.open('保存成功', '确定', config); this.tabbarService.sendMessage('changeScore'); } - },err=>{ + }, 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); + 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.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){ + 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.snackBar.open('保存成功', '确定', config); this.tabbarService.sendMessage('changeScore'); } - },err=>{ + }, err => { this.maskLayerService.sendMessage(false) let config = new MatSnackBarConfig(); config.verticalPosition = 'top'; config.duration = 3000 this.canvasData.isChange = true - this.snackBar.open('建筑重点部位同步失败','确定',config); + 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.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){ + 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.snackBar.open('保存成功', '确定', config); this.tabbarService.sendMessage('changeScore'); } - },err=>{ + }, err => { this.maskLayerService.sendMessage(false) let config = new MatSnackBarConfig(); config.verticalPosition = 'top'; config.duration = 3000 this.canvasData.isChange = true - this.snackBar.open('建筑消防设施素材同步失败','确定',config); + this.snackBar.open('建筑消防设施素材同步失败', '确定', config); }) - + } } } @@ -1190,55 +1194,55 @@ export class CollectionToolsPlanComponent implements OnInit { const config = new MatSnackBarConfig(); config.verticalPosition = 'top'; config.duration = 3000 - this.snackBar.open('暂无楼层数据','确定',config); + this.snackBar.open('暂无楼层数据', '确定', config); } } //获得所有的建筑物 - getAllBuildings(){ - this.http.get("/api/Buildings",{ - params:{ - companyId : this.params.companyId + getAllBuildings() { + this.http.get("/api/Buildings", { + params: { + companyId: this.params.companyId } - }).subscribe(data=>{ + }).subscribe(data => { this.allBuildings = data }) } //拖拽tree - drop(e){ + drop(e) { // console.log(1111,e) } - drop2(e){ + drop2(e) { // console.log(222,e) } //创建建筑 - createBuilding(){ + createBuilding() { let data = { - allBuildings:this.allBuildings, - companyId :this.params.companyId + allBuildings: this.allBuildings, + companyId: this.params.companyId } - let dialogRef = this.dialog.open(CreateBuildingPlan,{data}); - dialogRef.afterClosed().subscribe(data=>{ + let dialogRef = this.dialog.open(CreateBuildingPlan, { data }); + dialogRef.afterClosed().subscribe(data => { if (data == "创建成功") { const config = new MatSnackBarConfig(); config.verticalPosition = 'top'; config.duration = 3000 - this.snackBar.open('创建成功','确定',config); + this.snackBar.open('创建成功', '确定', config); this.getAllBuildings() - }else if (data == "创建失败") { + } else if (data == "创建失败") { const config = new MatSnackBarConfig(); config.verticalPosition = 'top'; config.duration = 3000 - this.snackBar.open('创建失败','确定',config); + this.snackBar.open('创建失败', '确定', config); } - }); + }); } //选择建筑 - checkedBuilding(item,index){ - if (this.checkedBuildingIndex!=index) { + checkedBuilding(item, index) { + if (this.checkedBuildingIndex != index) { this.canvasData.selectPanelPoint = new DisposalNodeData(); if (this.canvasData.isChange) { //true 数据被改动 let isTrue = confirm('是否保存当前编辑数据') @@ -1247,7 +1251,7 @@ export class CollectionToolsPlanComponent implements OnInit { if (isSuccess != false) { this.beforeOneCheckedBuilding = item this.checkedBuildingIndex = index - if (index==-1) { //总平面图数据 + if (index == -1) { //总平面图数据 this.getSitePlan() } else { //建筑楼层/区域数据 this.getBuildingSitePlan(item) @@ -1256,7 +1260,7 @@ export class CollectionToolsPlanComponent implements OnInit { } else { this.beforeOneCheckedBuilding = item this.checkedBuildingIndex = index - if (index==-1) { //总平面图数据 + if (index == -1) { //总平面图数据 this.getSitePlan() } else { //建筑楼层/区域数据 this.getBuildingSitePlan(item) @@ -1265,7 +1269,7 @@ export class CollectionToolsPlanComponent implements OnInit { } else { //flase 数据未被改动 this.beforeOneCheckedBuilding = item this.checkedBuildingIndex = index - if (index==-1) { //总平面图数据 + if (index == -1) { //总平面图数据 this.getSitePlan() } else { //建筑楼层/区域数据 this.getBuildingSitePlan(item) @@ -1276,58 +1280,58 @@ export class CollectionToolsPlanComponent implements OnInit { } //编辑建筑 - editBuilding(e,item){ + editBuilding(e, item) { e.stopPropagation(); - let dialogRef = this.dialog.open(EditBuildingPlan,{data: {item:item}}); - dialogRef.afterClosed().subscribe(data=>{ + let dialogRef = this.dialog.open(EditBuildingPlan, { data: { item: item } }); + dialogRef.afterClosed().subscribe(data => { if (data == "修改成功") { const config = new MatSnackBarConfig(); config.verticalPosition = 'top'; config.duration = 3000 - this.snackBar.open('修改成功','确定',config); + this.snackBar.open('修改成功', '确定', config); this.getAllBuildings() - }else if (data == "修改失败") { + } else if (data == "修改失败") { const config = new MatSnackBarConfig(); config.verticalPosition = 'top'; config.duration = 3000 - this.snackBar.open('修改失败','确定',config); + this.snackBar.open('修改失败', '确定', config); } - }); + }); } //删除建筑 - deleteBuilding(e,item){ + deleteBuilding(e, item) { e.stopPropagation(); - if(confirm("是否删除该建筑") == true){ - let isHave = this.canvasData.allDisposalNode.find(items=>{ return items.buildingId === item.id }) + 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=>{ + this.http.delete(`/api/Buildings/${item.id}`).subscribe(data => { const config = new MatSnackBarConfig(); config.verticalPosition = 'top'; config.duration = 3000 - this.snackBar.open('删除成功','确定',config); - this.http.get("/api/Buildings",{ - params:{ - companyId :this.params.companyId + this.snackBar.open('删除成功', '确定', config); + this.http.get("/api/Buildings", { + params: { + companyId: this.params.companyId } - }).subscribe(data=>{ + }).subscribe(data => { this.allBuildings = data - this.beforeOneCheckedBuilding = {name:"总平面图"} + this.beforeOneCheckedBuilding = { name: "总平面图" } this.checkedBuildingIndex = -1 this.getSitePlan() }) - },err=>{ + }, err => { const config = new MatSnackBarConfig(); config.verticalPosition = 'top'; config.duration = 3000 - this.snackBar.open('删除失败','确定',config); + this.snackBar.open('删除失败', '确定', config); this.getAllBuildings() }) } else { //建筑 含有数据节点时 const config = new MatSnackBarConfig(); config.verticalPosition = 'top'; config.duration = 3000 - this.snackBar.open('含有数据节点的建筑不允许删除','确定',config); + this.snackBar.open('含有数据节点的建筑不允许删除', '确定', config); } } } @@ -1335,7 +1339,7 @@ export class CollectionToolsPlanComponent implements OnInit { storeyData //将建筑素材和当前楼层素材合二为一 //处理 tree 数据结构 - handleTreeData (storeyData) { + handleTreeData(storeyData) { this.storeyData = storeyData let data = this.allFireElements //所有消防要素模板 @@ -1343,22 +1347,22 @@ export class CollectionToolsPlanComponent implements OnInit { data.forEach(element => { element.isTemplate = true //添加模板标识 element.isLook = true //添加是否可见标识 - element.name!='其他'? element.children = [] : null + element.name != '其他' ? element.children = [] : null - if(storeyData){ - for(let key in storeyData.data){ + if (storeyData) { + for (let key in storeyData.data) { storeyData.data[key].isLookPattern = true - if(element.id == storeyData.data[key].FireElementId){ + 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){ + if (element.parentId) { data.forEach(i => { - if(i.id == element.parentId){ + if (i.id == element.parentId) { i.isLookPattern = true } }) @@ -1369,85 +1373,85 @@ export class CollectionToolsPlanComponent implements OnInit { } } } - data.forEach(item => { if (item.parentId == element.id) {element.children.push(item)} }); + 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]){ + 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]){ + } else if (this.canvasData.originaleveryStoreyData.data[node.id]) { this.setAssetsProperty(this.canvasData.originaleveryStoreyData.data[node.id]) } //canvas上的素材高亮 - let iconHighLightArr:any = [] - if(node.isTemplate){//如果是模板,则开始向下找 + let iconHighLightArr: any = [] + if (node.isTemplate) {//如果是模板,则开始向下找 node.children.forEach(item => { - if(item.isTemplate){//如果子节点依旧是模板,则继续开始向下找 + if (item.isTemplate) {//如果子节点依旧是模板,则继续开始向下找 item.children.forEach(i => { iconHighLightArr.push(i.Id) }) - }else{ + } else { iconHighLightArr.push(item.Id) } }) - }else{ + } else { iconHighLightArr.push(node.id) } this.canvas.setHighlight(iconHighLightArr) } //点击数节点的显示隐藏icon - clickLookItem(node){ + clickLookItem(node) { + - //修改真实素材islook属性 - for(let key in this.storeyData.data){ - if(key == node.id){ + 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.isLook = !item.isLook } + if (node.isTemplate) { + this.allFireElements.forEach(item => { + if (item.id == node.id) { item.isLook = !item.isLook } if (item.name == '其他' && node.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  -          }) -        } -      }) -     } + 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)){ + 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; @@ -1457,25 +1461,25 @@ export class CollectionToolsPlanComponent implements OnInit { }); //canvas上的素材显隐 - let iconVisibleArr:any = [] - if(node.isTemplate){//如果是模板,则开始向下找 + let iconVisibleArr: any = [] + if (node.isTemplate) {//如果是模板,则开始向下找 node.children.forEach(item => { - if(item.isTemplate){//如果子节点依旧是模板,则继续开始向下找 + if (item.isTemplate) {//如果子节点依旧是模板,则继续开始向下找 item.children.forEach(i => { iconVisibleArr.push(i.Id) }) - }else{ + } else { iconVisibleArr.push(item.Id) } }) - }else{ + } else { iconVisibleArr.push(node.id) } - this.canvas.setIconVisible(iconVisibleArr,!node.isLook) + this.canvas.setIconVisible(iconVisibleArr, !node.isLook) } //计算 可视区域内宽度, 是否缩放背景图 - backGroundScale () { + backGroundScale() { // let that = this // let dad = this.element.nativeElement.querySelector('.functionalDomainContent').clientWidth // let dadHeight = this.element.nativeElement.querySelector('.functionalDomainContent').clientHeight @@ -1501,15 +1505,15 @@ export class CollectionToolsPlanComponent implements OnInit { } //封装 刷新 tree 数据 - async renovateTreeData (isRefresh:boolean = true) { + 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 ? 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 + isRefresh ? this.canvasData.isChange = false : null //服务中 数据是否改动 改为false + isRefresh ? this.isShowProperty = true : null + isRefresh ? this.isShowAttribute = true : null // let beforeOneId = this.selectingSitePlan.id || '' //当前 选中 平面图 楼层/区域 id // let companyBuildingData = JSON.parse(JSON.stringify( this.canvasData.originalcompanyBuildingData || {} )) // 当前 单位/建筑 数据 @@ -1534,53 +1538,53 @@ export class CollectionToolsPlanComponent implements OnInit { //陈鹏飞↓↓↓ //陈鹏飞↓↓↓ //陈鹏飞↓↓↓ - params = {companyId: sessionStorage.getItem('companyId')} - allFireElements:any = []; //当前 单位/建筑 下的消防要素 + params = { companyId: sessionStorage.getItem('companyId') } + allFireElements: any = []; //当前 单位/建筑 下的消防要素 - isShowAttribute:boolean = true; //属性栏 是否显示 默认数据 - isShowProperty:boolean = false //属性栏 是否有东西 + isShowAttribute: boolean = true; //属性栏 是否显示 默认数据 + isShowProperty: boolean = false //属性栏 是否有东西 - toggleExpandPanel:boolean = false; //左侧可展开面板展开或关闭 - toggleExpandPanelRight:boolean = false; //右侧可展开面板展开或关闭 - togglePlane:boolean = true; //可展开面板平面图 显隐 - toggleMaterialBank:boolean = false; //可展开面板素材库 显隐 - toggleHandlePlans:boolean = true; //可展开面板处置预案 显隐 + toggleExpandPanel: boolean = false; //左侧可展开面板展开或关闭 + toggleExpandPanelRight: boolean = false; //右侧可展开面板展开或关闭 + togglePlane: boolean = true; //可展开面板平面图 显隐 + toggleMaterialBank: boolean = false; //可展开面板素材库 显隐 + toggleHandlePlans: boolean = true; //可展开面板处置预案 显隐 //可展开面板展开或关闭 - toggle () { + toggle() { this.toggleExpandPanel = !this.toggleExpandPanel } //可展开面板展开或关闭 - toggle2 () { + toggle2() { this.toggleExpandPanelRight = !this.toggleExpandPanelRight } //可展开面板 平面图 展开或关闭 - togglePlanarGraph () { + togglePlanarGraph() { this.togglePlane = !this.togglePlane } //可展开面板 素材库 展开或关闭 - toggleMaterial () { + toggleMaterial() { this.toggleMaterialBank = !this.toggleMaterialBank } //可展开面板 处置预案 展开或关闭 - toggleHandlePlan () { + toggleHandlePlan() { this.toggleHandlePlans = !this.toggleHandlePlans } - sitePlanData:any = []; //总平面图 楼层/区域 数据 - selectingSitePlan:any; //选中的 平面图 楼层/区域 - selectSitePlanIndex:number; //选中的 平面图 楼层/区域 index + sitePlanData: any = []; //总平面图 楼层/区域 数据 + selectingSitePlan: any; //选中的 平面图 楼层/区域 + selectSitePlanIndex: number; //选中的 平面图 楼层/区域 index //获取总平面图 - getSitePlan () { + getSitePlan() { // let fireData = this.getFireElements(sessionStorage.getItem('buildingTypeId')) //获取单位下 消防要素 let planData = this.getSitePlanCompanyData() //获取 单位 数据 - this.http.get('/api/SitePlans',{params:this.params}).subscribe(data=>{ + 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([planData]).then((res)=>{ + Promise.all([planData]).then((res) => { this.getSitePlanStorey(this.selectingSitePlan) //获取 平面图 楼层数据 }) @@ -1588,17 +1592,17 @@ export class CollectionToolsPlanComponent implements OnInit { } //获取建筑 楼层/区域 - getBuildingSitePlan (item) { + 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.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([planData]).then((res)=>{ + Promise.all([planData]).then((res) => { this.getBuildingStorey(this.selectingSitePlan) //获取 建筑 楼层数据 }) @@ -1606,10 +1610,10 @@ export class CollectionToolsPlanComponent implements OnInit { } //根据单位类型获得所有的消防要素 - getFireElements (e) { - let params = {ids:e} - return new Promise ((resolve,reject)=>{ - this.http.get('/api/Companies/FireElements',{params}).subscribe((data:any)=>{ + 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: [], @@ -1619,7 +1623,7 @@ export class CollectionToolsPlanComponent implements OnInit { order: 999, parentId: null, tag: "INPUT", - isLookPattern : true + isLookPattern: true } this.allFireElements.push(other) resolve('success') @@ -1628,57 +1632,57 @@ export class CollectionToolsPlanComponent implements OnInit { } //获取 单位 数据 - getSitePlanCompanyData () { - return new Promise ((resolve,reject)=>{ - this.http.get('/api/CompanyData',{params:this.params}).subscribe((data:any)=>{ + 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.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') + 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)=>{ + 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.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.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)=>{ + 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.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 + 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)=>{ + 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.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.canvasData.originaleveryStoreyData.buildingAreaId ? null : this.canvasData.originaleveryStoreyData.buildingAreaId = e.id || null this.renovateTreeData() }) } //点击选中 平面图 楼层/区域 时 - selectSitePlan (item,index) { + selectSitePlan(item, index) { if (this.selectSitePlanIndex != index) { this.canvasData.selectPanelPoint = new DisposalNodeData(); if (this.canvasData.isChange) { //true 数据被改动 @@ -1689,7 +1693,7 @@ export class CollectionToolsPlanComponent implements OnInit { this.selectingSitePlan = item this.selectSitePlanIndex = index this.canvasData.selectStorey = item //服务中 存一份数据 - if (this.checkedBuildingIndex==-1) { //总平面图时 + if (this.checkedBuildingIndex == -1) { //总平面图时 this.getSitePlanStorey(item) //获取 平面图 楼层数据 } else { //楼层/区域时 this.getBuildingStorey(item) //获取 建筑 楼层数据 @@ -1699,7 +1703,7 @@ export class CollectionToolsPlanComponent implements OnInit { this.selectingSitePlan = item this.selectSitePlanIndex = index this.canvasData.selectStorey = item //服务中 存一份数据 - if (this.checkedBuildingIndex==-1) { //总平面图时 + if (this.checkedBuildingIndex == -1) { //总平面图时 this.getSitePlanStorey(item) //获取 平面图 楼层数据 this.getSitePlanCompanyData() } else { //楼层/区域时 @@ -1708,12 +1712,12 @@ export class CollectionToolsPlanComponent implements OnInit { this.getBuildingData(params) } } - + } else { //false 数据没被改动 this.selectingSitePlan = item this.selectSitePlanIndex = index this.canvasData.selectStorey = item //服务中 存一份数据 - if (this.checkedBuildingIndex==-1) { //总平面图时 + if (this.checkedBuildingIndex == -1) { //总平面图时 this.getSitePlanStorey(item) //获取 平面图 楼层数据 } else { //楼层/区域时 this.getBuildingStorey(item) //获取 建筑 楼层数据 @@ -1724,19 +1728,19 @@ export class CollectionToolsPlanComponent implements OnInit { } //新增平面图 楼层/区域 - foundPanel (e) { + foundPanel(e) { e.stopPropagation() let data = { - isBuilding: this.checkedBuildingIndex==-1? false:true, + isBuilding: this.checkedBuildingIndex == -1 ? false : true, Panel: this.beforeOneCheckedBuilding, - order: this.sitePlanData.length? this.sitePlanData[this.sitePlanData.length-1].order+1:0, + order: this.sitePlanData.length ? this.sitePlanData[this.sitePlanData.length - 1].order + 1 : 0, } - let dialogRef = this.dialog.open(leftFunctionalDomainComponentPlan,{data}); - dialogRef.afterClosed().subscribe(data=>{ - if (data =='总平面图') { - this.sitePlanData.length? this.renovateSitePlan() : this.getSitePlan() + let dialogRef = this.dialog.open(leftFunctionalDomainComponentPlan, { data }); + dialogRef.afterClosed().subscribe(data => { + if (data == '总平面图') { + this.sitePlanData.length ? this.renovateSitePlan() : this.getSitePlan() this.maskLayerService.sendMessage(false) - } else if (data =='建筑') { + } else if (data == '建筑') { this.renovateBuilding() this.maskLayerService.sendMessage(false) } @@ -1744,27 +1748,27 @@ export class CollectionToolsPlanComponent implements OnInit { } //编辑平面图 楼层/区域 - editPlaneData (e) { + editPlaneData(e) { let data = { - isBuilding: this.checkedBuildingIndex==-1? false:true, + isBuilding: this.checkedBuildingIndex == -1 ? false : true, Panel: this.beforeOneCheckedBuilding, buildingData: e, } - let dialogRef = this.dialog.open(editPlaneFigureComponentPlan,{disableClose: true,hasBackdrop: false,position: {left:'150px',top:'200px'},data}); - dialogRef.keydownEvents().subscribe(data=>{ + let dialogRef = this.dialog.open(editPlaneFigureComponentPlan, { disableClose: true, hasBackdrop: false, position: { left: '150px', top: '200px' }, data }); + dialogRef.keydownEvents().subscribe(data => { if (data.key === 'Enter') { this.canvas.refreshBackgroundImage() } }) - dialogRef.afterClosed().subscribe(data=>{ - if (data =='总平面图') { + dialogRef.afterClosed().subscribe(data => { + if (data == '总平面图') { let isSuccess = this.renovateSitePlan() - isSuccess.then(res=>{ + isSuccess.then(res => { this.canvas.refreshBackgroundImage() }) - } else if (data =='建筑') { - let isSuccess= this.renovateBuilding() - isSuccess.then(res=>{ + } else if (data == '建筑') { + let isSuccess = this.renovateBuilding() + isSuccess.then(res => { this.canvas.refreshBackgroundImage() }) } else if (data == '更新背景图') { @@ -1774,22 +1778,22 @@ export class CollectionToolsPlanComponent implements OnInit { } //平面图 楼层/区域 上移 - moveUp (item,index) { + 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.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.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() }) }) @@ -1799,22 +1803,22 @@ export class CollectionToolsPlanComponent implements OnInit { } //平面图 楼层/区域 下移 - moveDown (item,index) { - if (index != this.sitePlanData.length-1) { + 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.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.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() }) }) @@ -1824,20 +1828,20 @@ export class CollectionToolsPlanComponent implements OnInit { } //旋转底图 - 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=>{ + 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(item.imageUrl,item.imageAngle) + isSuccess.then(res => { + this.canvas.refreshBackgroundImage(item.imageUrl, item.imageAngle) }) }) } else { //楼层/区域 - this.http.put(`/api/BuildingAreas/${item.id}`,item,{params:this.params}).subscribe(data=>{ + this.http.put(`/api/BuildingAreas/${item.id}`, item, { params: this.params }).subscribe(data => { let isSuccess = this.renovateBuilding() - isSuccess.then(res=>{ - this.canvas.refreshBackgroundImage(item.imageUrl,item.imageAngle) + isSuccess.then(res => { + this.canvas.refreshBackgroundImage(item.imageUrl, item.imageAngle) }) }) } @@ -1845,47 +1849,47 @@ export class CollectionToolsPlanComponent implements OnInit { } //删除 平面图 楼层/区域 - deletePlaneData (item) { + deletePlaneData(item) { const isDelete = confirm('您确定要删除吗'); if (isDelete) { - if (this.checkedBuildingIndex==-1) { //总平面图 - let isHave = this.canvasData.allDisposalNode.find(items=>{ return items.sitePlanId === item.id }) + 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) + 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); + this.snackBar.open('含有数据节点的楼层不允许删除', '确定', config); } } else { //楼层/区域 - let isHave = this.canvasData.allDisposalNode.find(items=>{ return items.buildingAreaId === item.id }) + 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) + 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); + this.snackBar.open('含有数据节点的楼层不允许删除', '确定', config); } } } } //删除当前 单位/建筑的 共享数据中 已删除data - deleteShareData (e,isCompany) { - this.sitePlanData.forEach((element,index) => { - if (element.id===e.id) { - this.sitePlanData.splice(index,1) + 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){ + for (let key in data.data) { if (data.data[key].FloorId === e.id) { //处理 单位/建筑 数据是否归于当前楼层下 delete data.data[key] } @@ -1896,19 +1900,19 @@ export class CollectionToolsPlanComponent implements OnInit { this.canvasData.selectStorey = this.sitePlanData[0] || {} //服务中 存一份数据 this.selectSitePlanIndex = 0 this.canvasData.isChange = false - if (isCompany===-1) { - this.http.post("/api/CompanyData",newData).subscribe(data => {}) + 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.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)=>{ + 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 @@ -1916,19 +1920,19 @@ export class CollectionToolsPlanComponent implements OnInit { delete paramsData[key] } }) //图标Id重新赋值 - if (this.checkedBuildingIndex==-1) { //总平面图 + 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)=>{ + 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, + data: JSON.stringify(paramsData) || null, sitePlanId: data.id } - this.http.post('/api/SitePlanData',newData,{params:this.params}).subscribe(data=>{ + this.http.post('/api/SitePlanData', newData, { params: this.params }).subscribe(data => { this.renovateSitePlan() }) @@ -1937,15 +1941,15 @@ export class CollectionToolsPlanComponent implements OnInit { 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)=>{ + 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, + data: JSON.stringify(paramsData) || null, buildingAreaId: data.id } - this.http.post('/api/BuildingAreaData',newData,{params:this.params}).subscribe(data=>{ + this.http.post('/api/BuildingAreaData', newData, { params: this.params }).subscribe(data => { this.renovateBuilding() }) @@ -1954,32 +1958,32 @@ export class CollectionToolsPlanComponent implements OnInit { } //平面图 楼层/区域 替换底图 - replaceBaseMap (e,item) { + replaceBaseMap(e, item) { e.stopPropagation(); let file = e.target.files[0] || null //获取上传的文件 let fileSize = file.size || null //上传文件的总大小 let maxSize = 5 * 1024 * 1024 //5MB一个分片 let tenSize = 10 * 1024 * 1024 //10MB限制 - if (file && fileSize<=maxSize) { //上传文件<=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('/api/Objects/WebPlan2D/' + data.objectName,item) + formData.append("file", file) + this.http.post(`/api/Objects/WebPlan2D/${sessionStorage.getItem('companyId')}`, formData).subscribe((data: any) => { + this.renovateBaseMap('/api/Objects/WebPlan2D/' + data.objectName, item) }) - } else if (file && fileSize>maxSize && fileSize10MB时 - let upload = this.canvasData.sectionUpload(sessionStorage.getItem('companyId'),file) - upload.then(res=>{ this.renovateBaseMap('/api/Objects/PlanPlatform/' + res,item) }) + } else if (file && fileSize > maxSize && fileSize < tenSize) { //上传文件>10MB时 + let upload = this.canvasData.sectionUpload(sessionStorage.getItem('companyId'), file) + upload.then(res => { this.renovateBaseMap('/api/Objects/PlanPlatform/' + res, item) }) } else { const config = new MatSnackBarConfig(); config.verticalPosition = 'top'; config.duration = 3000 - this.snackBar.open('上传底图需小于10MB','确定',config); + this.snackBar.open('上传底图需小于10MB', '确定', config); } } //封装 替换底图 function - renovateBaseMap (e,item) { + renovateBaseMap(e, item) { let that = this let img = new Image() img.src = e @@ -1987,94 +1991,94 @@ export class CollectionToolsPlanComponent implements OnInit { item.imageUrl = e item.imageWidth = img.width item.imageHeight = img.height - if (that.checkedBuildingIndex ==-1) { //总平面图 - that.http.put(`/api/SitePlans/${item.id}`,item).subscribe(data=>{ + if (that.checkedBuildingIndex == -1) { //总平面图 + that.http.put(`/api/SitePlans/${item.id}`, item).subscribe(data => { let isSuccess = that.renovateSitePlan() - isSuccess.then(res=>{ + isSuccess.then(res => { that.canvas.refreshBackgroundImage() }) const config = new MatSnackBarConfig(); config.verticalPosition = 'top'; config.duration = 3000 - that.snackBar.open('上传底图成功','确定',config); + that.snackBar.open('上传底图成功', '确定', config); }) } else { //楼层/区域 - that.http.put(`/api/BuildingAreas/${item.id}`,item,{params:that.params}).subscribe(data=>{ + that.http.put(`/api/BuildingAreas/${item.id}`, item, { params: that.params }).subscribe(data => { let isSuccess = that.renovateBuilding() - isSuccess.then(res=>{ + isSuccess.then(res => { that.canvas.refreshBackgroundImage() }) const config = new MatSnackBarConfig(); config.verticalPosition = 'top'; config.duration = 3000 - that.snackBar.open('上传底图成功','确定',config); + that.snackBar.open('上传底图成功', '确定', config); }) } //else } //onload } //封装 刷新总平面图 数据 - renovateSitePlan () { - return new Promise ((resolve,reject)=>{ - this.http.get('/api/SitePlans',{params:this.params}).subscribe(data=>{ + 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 + 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); + this.snackBar.open('数据更新成功', '确定', config); resolve('success') }) }) } //封装 刷新 楼层/区域 数据 - renovateBuilding () { + renovateBuilding() { let params = { buildingId: this.beforeOneCheckedBuilding.id } - return new Promise ((resolve,reject)=>{ - this.http.get('/api/BuildingAreas',{params}).subscribe(data=>{ + 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 + 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); + this.snackBar.open('数据更新成功', '确定', config); resolve('success') }) }) } - allLibrary:any = []; //所有素材库 + 素材 - selectLibrary:any; //选中的素材库 - selectImage:any; //选中的素材库图片 - selectImageIndex:number; //选中的素材库图片index - searchSettimeout:any; //延时器 - searchInput:string = null; //模糊搜索 input - searchLibrary:any = []; //模糊搜索 素材 + allLibrary: any = []; //所有素材库 + 素材 + selectLibrary: any; //选中的素材库 + selectImage: any; //选中的素材库图片 + selectImageIndex: number; //选中的素材库图片index + searchSettimeout: any; //延时器 + searchInput: string = null; //模糊搜索 input + searchLibrary: any = []; //模糊搜索 素材 //输入框 输入事件 - libraryChange () { + libraryChange() { window.clearTimeout(this.searchSettimeout) - this.searchSettimeout = window.setTimeout(()=>{ + this.searchSettimeout = window.setTimeout(() => { if (this.searchInput === "") { this.searchLibrary = [] } else { - this.http.get(`/api/Assets?assetName=${this.searchInput}`).subscribe((data:any)=>{ + this.http.get(`/api/Assets?assetName=${this.searchInput}`).subscribe((data: any) => { this.searchLibrary = data }) } - },500) + }, 500) } //获取素材库 - getAllLibrary (type:string='input') { - this.http.get(`/api/AssetLibraries?tag=${type}`).subscribe((data:any)=>{ + getAllLibrary(type: string = 'input') { + this.http.get(`/api/AssetLibraries?tag=${type}`).subscribe((data: any) => { data.forEach(element => { element.images = [] }); @@ -2084,16 +2088,16 @@ export class CollectionToolsPlanComponent implements OnInit { } //素材库展开面板展开时 - opened (e) { + opened(e) { if (!e.images.length) { //当前素材库没加载素材时 - this.http.get(`/api/Assets?libraryId=${e.id}`).subscribe((data:any)=>{ + this.http.get(`/api/Assets?libraryId=${e.id}`).subscribe((data: any) => { e.images = data }) } } //点击选中素材库图片时 - selectImg (item,items,index) { + selectImg(item, items, index) { this.selectLibrary = item.name this.selectImage = items this.selectImageIndex = index @@ -2104,30 +2108,30 @@ export class CollectionToolsPlanComponent implements OnInit { //处置预案 - allFirePlan:any = []; //所有灾情 - selectDisposalNode:string = ''; //当前点击tree节点 css选中样式 + allFirePlan: any = []; //所有灾情 + selectDisposalNode: string = ''; //当前点击tree节点 css选中样式 //获取所有灾情 - getAllFirePlan () { - let params = {componentId: sessionStorage.getItem('planId')} - this.http.get('/api/Disasters',{params:params}).subscribe((data:any)=>{ + 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.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=>{ //所有处置节点 + 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=>{ //所有处置节点 + let params = { disasterId: this.allFirePlan[0].id || '' } + this.http.get('/api/DisposalNodes', { params: params }).subscribe(data => { //所有处置节点 this.canvasData.allDisposalNode = data }) } @@ -2135,26 +2139,26 @@ export class CollectionToolsPlanComponent implements OnInit { } //获取所有处置节点 - getDisposalNode () { + getDisposalNode() { this.selectDisposalNode = '' - let params = {disasterId: this.allFirePlan[0].id || ''} - this.http.get('/api/DisasterData/Markers',{params:params}).subscribe(data=>{ //灾情标签信息 + 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.http.get('/api/DisposalNodes', { params: params }).subscribe(data => { //处置节点 this.canvasData.allDisposalNode = data this.handleHybridTree() }) } - treeData:any = []; //渲染tree处理完成数据 - defaultExpandedKeys:any = []; //首次渲染 tree展开状态 + treeData: any = []; //渲染tree处理完成数据 + defaultExpandedKeys: any = []; //首次渲染 tree展开状态 //处理 节点 Tree数据 - handleHybridTree () { + handleHybridTree() { this.defaultExpandedKeys = [] let treeData = [] - let data = JSON.parse(JSON.stringify( this.canvasData.allDisposalNode || [] )) + let data = JSON.parse(JSON.stringify(this.canvasData.allDisposalNode || [])) data.forEach(element => { this.defaultExpandedKeys.push(element.id) element.title = element.name //name @@ -2167,29 +2171,29 @@ export class CollectionToolsPlanComponent implements OnInit { element.isLeaf = false element.isDataNode = false } - data.forEach(item=>{ - item.parentId === element.id? element.children.push(item) : null + data.forEach(item => { + item.parentId === element.id ? element.children.push(item) : null }) }); - data.forEach(element=>{ - !element.parentId? treeData.push(element) : null + data.forEach(element => { + !element.parentId ? treeData.push(element) : null }) this.treeData = [...treeData] this.defaultExpandedKeys = [...this.defaultExpandedKeys] } //刷新 treeData 保存已展开节点 - refurbishTreeData () { + refurbishTreeData() { this.defaultExpandedKeys = [] - let params = {disasterId: this.allFirePlan[0].id || ''} - this.http.get('/api/DisposalNodes',{params:params}).subscribe(nodeData=>{ //处置节点 + 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=>{ + oldTreeData.forEach(item => { this.defaultExpandedKeys.push(item.key) }) let treeData = [] - let data = JSON.parse(JSON.stringify( this.canvasData.allDisposalNode || [] )) + let data = JSON.parse(JSON.stringify(this.canvasData.allDisposalNode || [])) data.forEach(element => { element.title = element.name //name element.key = element.id //id @@ -2201,39 +2205,39 @@ export class CollectionToolsPlanComponent implements OnInit { element.isLeaf = false element.isDataNode = false } - data.forEach(item=>{ - item.parentId === element.id? element.children.push(item) : null + data.forEach(item => { + item.parentId === element.id ? element.children.push(item) : null }) }); - data.forEach(element=>{ - !element.parentId? treeData.push(element) : null + data.forEach(element => { + !element.parentId ? treeData.push(element) : null }) this.treeData = [...treeData] this.defaultExpandedKeys = [...this.defaultExpandedKeys] }) } - sitePlanIcon = {fire:0,force:0} // 总平面图 火源/力量 图标 是否展示 + sitePlanIcon = { fire: 0, force: 0 } // 总平面图 火源/力量 图标 是否展示 //刷新 建筑楼层 匹配 火源/力量 图标 - mateFireForce () { + mateFireForce() { let data = this.canvasData.allNodeMarkers.markers || {} - for(let key in data){ //遍历 火/力量 图标 + 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 + 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 (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 + 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 } } @@ -2243,19 +2247,19 @@ export class CollectionToolsPlanComponent implements OnInit { 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 + 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 + 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 + buildingMSG[key][keys].fireCount != 0 ? this.sitePlanIcon.fire = 2 : null + buildingMSG[key][keys].forceCount != 0 ? this.sitePlanIcon.force = 2 : null } } } @@ -2263,10 +2267,10 @@ export class CollectionToolsPlanComponent implements OnInit { } // 切换 基本信息时 刷新 删除 建筑楼层 自定义属性 - mateDeleteCustomize () { - this.canvasData.selectPanelPointBaseData = {description: '', notes: '', weather: '', airTemperature: '', windDirection: '', windScale: ''} + mateDeleteCustomize() { + this.canvasData.selectPanelPointBaseData = { description: '', notes: '', weather: '', airTemperature: '', windDirection: '', windScale: '' } this.defaultExpandedKeys = [] - this.sitePlanIcon = {fire:0,force:0} + this.sitePlanIcon = { fire: 0, force: 0 } this.sitePlanData.forEach(element => { //楼层 delete element.fire delete element.force @@ -2278,30 +2282,30 @@ export class CollectionToolsPlanComponent implements OnInit { } //计算差异 - countValue (e) { + countValue(e) { e.stopPropagation() - let params = {disasterId: this.allFirePlan[0].id || ''} - this.http.get('/api/DisasterData/Diffs',{params:params}).subscribe(data=>{ + 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); + this.snackBar.open('计算差异完成', '确定', config); }) } //复制 处置预案 节点 - copyPanelPoint (e,item,treeData) { + copyPanelPoint(e, item, treeData) { e.stopPropagation() if (confirm(`确定要复制 ${item.title} ?`)) { - let params = {id: item.origin.id} + let params = { id: item.origin.id } let order - if (item.level==0) { - treeData.length? order = treeData[treeData.length-1].order+1 : order = 0 + 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 + parent.origin.children.length ? order = parent.origin.children[parent.origin.children.length - 1].order + 1 : order = 0 } let data = { name: item.title + '(副本)', @@ -2312,41 +2316,41 @@ export class CollectionToolsPlanComponent implements OnInit { parentId: item.origin.parentId || null, planComponentId: item.origin.planComponentId || '', } - this.http.post('/api/DisposalNodes/Clone',data,{params:params}).subscribe(data=>{ + this.http.post('/api/DisposalNodes/Clone', data, { params: params }).subscribe(data => { this.refurbishTreeData() }) } //isTrue } //删除 处置预案 节点 - deletePanelPoint (e,item) { + deletePanelPoint(e, item) { e.stopPropagation() if (confirm(`确定要删除 ${item.name} ?`)) { - this.http.delete(`/api/DisposalNodes/${item.id}`).subscribe(data=>{ + this.http.delete(`/api/DisposalNodes/${item.id}`).subscribe(data => { this.refurbishTreeData() }) } } //点击 处置Tree节点 - selectanelPoint (e) { + 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 //选中 节点 + 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 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 + 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 => { 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) @@ -2357,36 +2361,36 @@ export class CollectionToolsPlanComponent implements OnInit { } //查找 数据节点 对应 建筑/楼层 - seekPanelPoint (paramsData) { + seekPanelPoint(paramsData) { this.checkedBuildingIndex = paramsData.buildingIndex - if (paramsData.buildingIndex ==-1) { //总平面图时 - this.beforeOneCheckedBuilding={name:"总平面图"} + 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.http.get('/api/SitePlans', { params: this.params }).subscribe(data => { this.sitePlanData = data - let index = this.sitePlanData.findIndex(item=>{ return item.id===paramsData.storeyId }) + 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)=>{ + + Promise.all([fireData, planData]).then((res) => { this.getSitePlanStorey(this.selectingSitePlan) //获取 平面图 楼层数据 }) }) //get } else { //建筑时 - this.beforeOneCheckedBuilding=this.allBuildings[paramsData.buildingIndex] + 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.http.get('/api/BuildingAreas', { params }).subscribe(data => { this.sitePlanData = data - let index = this.sitePlanData.findIndex(item=>{ return item.id===paramsData.storeyId }) + 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)=>{ + + Promise.all([fireData, planData]).then((res) => { this.getBuildingStorey(this.selectingSitePlan) //获取 建筑 楼层数据 }) }) //get @@ -2407,30 +2411,30 @@ export class CollectionToolsPlanComponent implements OnInit { }) export class CreateBuildingPlan { - constructor(private http:HttpClient,public dialog: MatDialog,public dialogRef: MatDialogRef,@Inject(MAT_DIALOG_DATA) public data) { } + constructor(private http: HttpClient, public dialog: MatDialog, public dialogRef: MatDialogRef, @Inject(MAT_DIALOG_DATA) public data) { } - allBuildingType:any//所有的建筑类型 - selected:any; //选中的建筑 + allBuildingType: any//所有的建筑类型 + selected: any; //选中的建筑 ngOnInit(): void { this.getAllBuildingType() } //获得所有单位类型 - getAllBuildingType(){ - this.http.get("/api/BuildingTypes/Simple").subscribe(data=>{ + getAllBuildingType() { + this.http.get("/api/BuildingTypes/Simple").subscribe(data => { this.allBuildingType = data }) } //创建建筑功能分区 - onSubmit (e) { + 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 = + let data = { id: "", name: e.propertyName, - order: lastBuildingOrder , + order: lastBuildingOrder, enabled: true, companyId: companyId, buildingTypes: [ @@ -2440,13 +2444,13 @@ export class CreateBuildingPlan { } ] } - this.http.post("/api/Buildings",data,{ - params:{ - companyId : this.data.companyId + this.http.post("/api/Buildings", data, { + params: { + companyId: this.data.companyId } - }).subscribe(data=>{ + }).subscribe(data => { this.dialogRef.close("创建成功"); - },err=>{ + }, err => { this.dialogRef.close("创建失败"); }) } @@ -2460,26 +2464,26 @@ export class CreateBuildingPlan { }) export class EditBuildingPlan { - 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//所有的建筑类型 + 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=>{ + getAllBuildingType() { + this.http.get("/api/BuildingTypes/Simple").subscribe(data => { this.allBuildingType = data }) } //编辑建筑信息 - onSubmit (e) { + onSubmit(e) { let companyId = sessionStorage.getItem("companyId") - let data = + let data = { id: this.data.item.id, name: e.propertyName, @@ -2493,14 +2497,14 @@ export class EditBuildingPlan { } ] } - this.http.put(`/api/Buildings/${this.data.item.id}`,data,{ - params:{ - id:this.data.item.id, - companyId:companyId + this.http.put(`/api/Buildings/${this.data.item.id}`, data, { + params: { + id: this.data.item.id, + companyId: companyId } - }).subscribe(data=>{ + }).subscribe(data => { this.dialogRef.close("修改成功"); - },err=>{ + }, err => { this.dialogRef.close("修改失败"); }) } diff --git a/src/app/working-area/model/axLegend.ts b/src/app/working-area/model/axLegend.ts index dffc4a8..fd47146 100644 --- a/src/app/working-area/model/axLegend.ts +++ b/src/app/working-area/model/axLegend.ts @@ -1,6 +1,3 @@ -import { Constructor } from '@angular/material/core/common-behaviors/constructor'; -import { MatGridTileHeaderCssMatStyler } from '@angular/material/grid-list'; -import { DefaultProxy } from 'cesium'; import { Sprite, Texture, Text, Graphics, Point } from 'pixi.js'; import { WorkingAreaComponent } from '../working-area.component'; import { AxShape } from './axShape'; diff --git a/src/app/working-area/model/configuration.ts b/src/app/working-area/model/configuration.ts index f26898b..7a8ec8a 100644 --- a/src/app/working-area/model/configuration.ts +++ b/src/app/working-area/model/configuration.ts @@ -77,7 +77,7 @@ export var config = { directionalDrag: true, boundsX: 500, boundsY: 500, - viewBounds: 60000 + viewBounds: 100000 }; export var wallInformation = { exterior: false, interior: false, midline: true, labels: true, exteriorlabel: 'e:', interiorlabel: 'i:', midlinelabel: 'm:' }; diff --git a/src/app/working-area/working-area.component.ts b/src/app/working-area/working-area.component.ts index 52628f2..76e673a 100644 --- a/src/app/working-area/working-area.component.ts +++ b/src/app/working-area/working-area.component.ts @@ -64,6 +64,10 @@ export class WorkingAreaComponent extends EventEmitter implements OnInit, AfterV * 资源加载器 */ public loader = PIXI.Loader.shared; + /** + * 背景容器 + */ + public backgroundContainer = new PIXI.Container(); /** * 背景图 */ @@ -171,7 +175,7 @@ export class WorkingAreaComponent extends EventEmitter implements OnInit, AfterV * 重大调整-主版本号增加 * 日期变更-日期版本号增加 */ - public VERSION = '1.4.3.20210415_rc'; + public VERSION = '1.5.0.20210507_rc'; /** * 数据初始化 */ @@ -223,6 +227,7 @@ export class WorkingAreaComponent extends EventEmitter implements OnInit, AfterV this.camera2D.drag(); } } + /** * 删除选中的图标 */ @@ -478,7 +483,6 @@ export class WorkingAreaComponent extends EventEmitter implements OnInit, AfterV this.deselectAll(); this.setPaintMode(PaintMode.endPaint); }); - } /** * 更新2D相机 @@ -614,12 +618,31 @@ export class WorkingAreaComponent extends EventEmitter implements OnInit, AfterV this.canvasData.isChange = true; this.updateCamera2D(); }); + + + } + + /** + * 截屏 + */ + takeScreenshot() { + this.backgroundContainer.setParent(this.app.stage); + this.app.renderer.extract.canvas(this.backgroundContainer).toBlob((b) => { + const a = document.createElement('a'); + document.body.append(a); + a.download = 'screenshot'; + a.href = URL.createObjectURL(b); + a.click(); + a.remove(); + }, 'image/png'); + this.backgroundContainer.setParent(this.camera2D); } /** * 重置画布 */ public resetCanvas() { this.app.renderer.resize(this.content.nativeElement.clientWidth, this.content.nativeElement.clientHeight); + } /** * 设置名称显示 @@ -785,6 +808,7 @@ export class WorkingAreaComponent extends EventEmitter implements OnInit, AfterV TemplateId: this.canvasData.selectTemplateData.id, CanConnect: this.canvasData.selectTemplateData.canConnect, Pipelines: new Array(), + BuildingId: this.canvasData.selectStorey.buildingId, FloorId: this.canvasData.selectStorey.id, Angle: this.canvasData.selectTemplateData.angle, Color: this.canvasData.selectTemplateData.color, @@ -808,6 +832,7 @@ export class WorkingAreaComponent extends EventEmitter implements OnInit, AfterV GameMode: this.canvasData.gameMode, Tag: this.canvasData.selectTemplateData.tag }; + const singleIcon = new AxImageShape(assetData, this); this.emit('createIcon', singleIcon); break; @@ -1035,7 +1060,8 @@ export class WorkingAreaComponent extends EventEmitter implements OnInit, AfterV this.previewImage.visible = false; } }); - this.camera2D.addChild(this.backgroundImage); + this.backgroundContainer.addChild(this.backgroundImage); + this.camera2D.addChild(this.backgroundContainer); this.createPreviewImage(); this.createPreviewLineSegment(); this.createCircleShadow(); @@ -1449,7 +1475,7 @@ export class WorkingAreaComponent extends EventEmitter implements OnInit, AfterV const property = new PropertyInfo(element); propertyList.push(property); }); - const assetData = { + const assetData: AssetData = { TemplateId: this.canvasData.selectTemplateData.id, FloorId: this.canvasData.selectStorey.id, Angle: this.canvasData.selectTemplateData.angle, @@ -1460,6 +1486,9 @@ export class WorkingAreaComponent extends EventEmitter implements OnInit, AfterV FixedSize: this.canvasData.selectTemplateData.fixedSize, Height: 32, Width: 32, + BuildingId: this.canvasData.selectStorey.buildingId, + CompanyId: "", + FloorName: "", Id: ObjectID.default.generate(), ImageUrl: this.canvasData.selectTemplateData.imageUrl, InteractiveMode: this.canvasData.selectTemplateData.interactiveMode, @@ -1708,6 +1737,7 @@ export class WorkingAreaComponent extends EventEmitter implements OnInit, AfterV ids.forEach(item => { const obj = this.backgroundImage.getChildByName(item); shapes.push(obj as AxShape); + console.log((obj as AxShape).assetData); }); this.selectAllWithClear(shapes); }