From 103fc95a2949f55647bcf9d4503abe6708198a02 Mon Sep 17 00:00:00 2001 From: zhaoxu <493734247@qq.com> Date: Fri, 18 Jun 2021 20:18:57 +0800 Subject: [PATCH] =?UTF-8?q?=E5=9C=B0=E5=9B=BE=E5=AF=B9=E6=8E=A5.=20?= =?UTF-8?q?=E6=A1=86=E6=9E=B6=E6=9E=84=E5=BB=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../gis-labeling/gis-labeling.component.ts | 3173 +++++----- .../collection-tools-plan/addPlaneFigure.html | 4 +- .../collection-tools.component.ts | 5096 +++++++++-------- src/modules/map/declare/factory.ts | 24 + src/modules/map/declare/gaode-map.ts | 33 + src/modules/map/declare/keda-map.ts | 45 + src/modules/map/declare/map.d.ts | 29 + tsconfig.json | 5 +- 8 files changed, 4278 insertions(+), 4131 deletions(-) create mode 100644 src/modules/map/declare/factory.ts create mode 100644 src/modules/map/declare/gaode-map.ts create mode 100644 src/modules/map/declare/keda-map.ts create mode 100644 src/modules/map/declare/map.d.ts diff --git a/src/app/gis-management/gis-labeling/gis-labeling.component.ts b/src/app/gis-management/gis-labeling/gis-labeling.component.ts index 1318c34..7d16b7b 100644 --- a/src/app/gis-management/gis-labeling/gis-labeling.component.ts +++ b/src/app/gis-management/gis-labeling/gis-labeling.component.ts @@ -1,410 +1,413 @@ import { HttpClient } from '@angular/common/http'; -import { Component, OnInit ,Renderer2,ElementRef, Inject, NgZone, ViewChild } from '@angular/core'; -import { FormBuilder,FormGroup, FormControl } from '@angular/forms'; +import { Component, OnInit, Renderer2, ElementRef, Inject, NgZone, ViewChild } from '@angular/core'; +import { FormBuilder, FormGroup, FormControl } from '@angular/forms'; import { MatDialog, MatDialogRef, MAT_DIALOG_DATA } from '@angular/material/dialog'; import { MatSnackBar, MatSnackBarConfig } from '@angular/material/snack-bar'; declare var AMap: any; declare var QRCode: any; +import { MapFactory } from '../../../modules/map/declare/factory' + + @Component({ - selector: 'app-gis-labeling', - templateUrl: './gis-labeling.component.html', - styleUrls: ['./gis-labeling.component.scss'] + selector: 'app-gis-labeling', + templateUrl: './gis-labeling.component.html', + styleUrls: ['./gis-labeling.component.scss'] }) export class GisLabelingComponent implements OnInit { - constructor(private elementRef: ElementRef,public renderer2: Renderer2,private http:HttpClient,public snackBar: MatSnackBar,public dialog: MatDialog,public _ngZone:NgZone,private fb: FormBuilder) { } - - //右上角div - selectedTitle:number - titleList = [ {name:'重点单位',iconImg:'/assets/images/uniticon.png'}, - {name:'水源',iconImg:'/assets/images/watericon.png'}, - {name:'消防力量',iconImg:'/assets/images/xfll.png'}, - {name:'联动力量',iconImg:'/assets/images/ldll.png'}, - {name:'测量工具',iconImg:'/assets/images/distanceicon.png'}, - {name:'图层选择',iconImg:'/assets/images/coverageicon.png'} - ] - keyUnitList:any = [] - waterList = [ - {id:'0',name:'消火栓',selected:false}, - {id:'1',name:'消防水池',selected:false}, - {id:'2',name:'天然水源',selected:false}, - ] - fireForceList = [ - {id:'0',name:'总队',selected:false}, - {id:'1',name:'支队',selected:false}, - {id:'2',name:'大队',selected:false}, - {id:'3',name:'中队(消防站)',selected:false}, - {id:'4',name:'其他消防队伍',selected:false} - ] - linkageForcesList = [ - {id:'0',name:'安监',selected:false}, - {id:'1',name:'电力局',selected:false}, - {id:'2',name:'公安',selected:false}, - {id:'3',name:'海事',selected:false}, - {id:'4',name:'环保局',selected:false}, - {id:'5',name:'交通',selected:false}, - {id:'6',name:'民政',selected:false}, - {id:'7',name:'气象局',selected:false}, - {id:'8',name:'燃气局',selected:false}, - {id:'9',name:'市政',selected:false}, - {id:'10',name:'水利',selected:false}, - {id:'11',name:'通信',selected:false}, - {id:'12',name:'医疗',selected:false}, - {id:'13',name:'应急管理',selected:false}, - {id:'14',name:'住建',selected:false} - ] - keyUnitForm : FormGroup//gis右上角重点单位表单 - watertForm : FormGroup//gis右上角水源表单 - fireForceForm : FormGroup//gis右上角消防力量表单 - linkageForcesForm : FormGroup//gis右上角联动力量表单 - - selectedUnitList:any = []//选择提交的单位 - selectedWaterList:any = []//选择提交的水源 - selectedFireForceList:any = []//选择提交的消防力量 - selectedLinkageForcesList:any = []//选择提交的联动力量 - - unitAreaDefault:any = '-1'//默认单位范围 - waterAreaDefault:any = '-1'//默认水源范围 - fireForceAreaDefault:any = '-1'//默认消防力量范围 - linkageForcesAreaDefault:any = '-1'//默认联动力量范围 - - - //获得单位循环出来的checkbox列表(formControl实例) - get units():any{ - return this.keyUnitForm.get('units') - } - get waters():any{ - return this.watertForm.get('waters') - } - get fireForce():any{ - return this.fireForceForm.get('fireForce') - } - get linkageForces():any{ - return this.linkageForcesForm.get('linkageForces') - } - - async getAllBuildingType(){ - let result = await new Promise((result,reject)=>{ - this.http.get('/api/BuildingTypes/Simple').subscribe((data:any) => { - data.forEach(item => { - item.selected = false + constructor(private elementRef: ElementRef, public renderer2: Renderer2, private http: HttpClient, public snackBar: MatSnackBar, public dialog: MatDialog, public _ngZone: NgZone, private fb: FormBuilder) { } + + //右上角div + selectedTitle: number + titleList = [{ name: '重点单位', iconImg: '/assets/images/uniticon.png' }, + { name: '水源', iconImg: '/assets/images/watericon.png' }, + { name: '消防力量', iconImg: '/assets/images/xfll.png' }, + { name: '联动力量', iconImg: '/assets/images/ldll.png' }, + { name: '测量工具', iconImg: '/assets/images/distanceicon.png' }, + { name: '图层选择', iconImg: '/assets/images/coverageicon.png' } + ] + keyUnitList: any = [] + waterList = [ + { id: '0', name: '消火栓', selected: false }, + { id: '1', name: '消防水池', selected: false }, + { id: '2', name: '天然水源', selected: false }, + ] + fireForceList = [ + { id: '0', name: '总队', selected: false }, + { id: '1', name: '支队', selected: false }, + { id: '2', name: '大队', selected: false }, + { id: '3', name: '中队(消防站)', selected: false }, + { id: '4', name: '其他消防队伍', selected: false } + ] + linkageForcesList = [ + { id: '0', name: '安监', selected: false }, + { id: '1', name: '电力局', selected: false }, + { id: '2', name: '公安', selected: false }, + { id: '3', name: '海事', selected: false }, + { id: '4', name: '环保局', selected: false }, + { id: '5', name: '交通', selected: false }, + { id: '6', name: '民政', selected: false }, + { id: '7', name: '气象局', selected: false }, + { id: '8', name: '燃气局', selected: false }, + { id: '9', name: '市政', selected: false }, + { id: '10', name: '水利', selected: false }, + { id: '11', name: '通信', selected: false }, + { id: '12', name: '医疗', selected: false }, + { id: '13', name: '应急管理', selected: false }, + { id: '14', name: '住建', selected: false } + ] + keyUnitForm: FormGroup//gis右上角重点单位表单 + watertForm: FormGroup//gis右上角水源表单 + fireForceForm: FormGroup//gis右上角消防力量表单 + linkageForcesForm: FormGroup//gis右上角联动力量表单 + + selectedUnitList: any = []//选择提交的单位 + selectedWaterList: any = []//选择提交的水源 + selectedFireForceList: any = []//选择提交的消防力量 + selectedLinkageForcesList: any = []//选择提交的联动力量 + + unitAreaDefault: any = '-1'//默认单位范围 + waterAreaDefault: any = '-1'//默认水源范围 + fireForceAreaDefault: any = '-1'//默认消防力量范围 + linkageForcesAreaDefault: any = '-1'//默认联动力量范围 + + + //获得单位循环出来的checkbox列表(formControl实例) + get units(): any { + return this.keyUnitForm.get('units') + } + get waters(): any { + return this.watertForm.get('waters') + } + get fireForce(): any { + return this.fireForceForm.get('fireForce') + } + get linkageForces(): any { + return this.linkageForcesForm.get('linkageForces') + } + + async getAllBuildingType() { + let result = await new Promise((result, reject) => { + this.http.get('/api/BuildingTypes/Simple').subscribe((data: any) => { + data.forEach(item => { + item.selected = false + }) + this.keyUnitList = data + result('获取单位类型') + }) }) - this.keyUnitList = data - result('获取单位类型') - }) - }) - } - ngOnInit(): void { - window.setTimeout(()=>{ - this.mapInit() - },0) - let buildingType = this.getAllBuildingType()//获取建筑类型 - Promise.all([buildingType]).then(()=>{ - this.keyUnitForm = this.fb.group({ - units:this.buildUnits(), - allSelectedUnit:new FormControl(), - areaUnit:new FormControl() - }) - this.watertForm = this.fb.group({ - waters:this.waterUnits(), - allSelectedWater:new FormControl(), - areaWater:new FormControl() - }) - this.fireForceForm = this.fb.group({ - fireForce:this.fireForceController(), - allSelectedFireForce:new FormControl(), - areaFireForce:new FormControl() - }) - this.linkageForcesForm = this.fb.group({ - linkageForces:this.linkageForcesController(), - allSelectedLinkageForces:new FormControl(), - areaLinkageForces:new FormControl() - }) - - //将选中的push到数组 - this.units.valueChanges.subscribe(values => { - let selects:string[] = [] - values.forEach((selected:boolean,i:number) => { - selected === true && selects.push(this.keyUnitList[i].id) + } + ngOnInit(): void { + window.setTimeout(() => { + this.mapInit() + }, 0) + let buildingType = this.getAllBuildingType()//获取建筑类型 + Promise.all([buildingType]).then(() => { + this.keyUnitForm = this.fb.group({ + units: this.buildUnits(), + allSelectedUnit: new FormControl(), + areaUnit: new FormControl() + }) + this.watertForm = this.fb.group({ + waters: this.waterUnits(), + allSelectedWater: new FormControl(), + areaWater: new FormControl() + }) + this.fireForceForm = this.fb.group({ + fireForce: this.fireForceController(), + allSelectedFireForce: new FormControl(), + areaFireForce: new FormControl() + }) + this.linkageForcesForm = this.fb.group({ + linkageForces: this.linkageForcesController(), + allSelectedLinkageForces: new FormControl(), + areaLinkageForces: new FormControl() + }) + + //将选中的push到数组 + this.units.valueChanges.subscribe(values => { + let selects: string[] = [] + values.forEach((selected: boolean, i: number) => { + selected === true && selects.push(this.keyUnitList[i].id) + }); + this.selectedUnitList = selects + }) + this.waters.valueChanges.subscribe(values => { + let selects: string[] = [] + values.forEach((selected: boolean, i: number) => { + selected === true && selects.push(this.waterList[i].id) + }); + this.selectedWaterList = selects + }) + + this.fireForce.valueChanges.subscribe(values => { + let selects: string[] = [] + values.forEach((selected: boolean, i: number) => { + selected === true && selects.push(this.fireForceList[i].id) + }); + this.selectedFireForceList = selects + }) + this.linkageForces.valueChanges.subscribe(values => { + let selects: string[] = [] + values.forEach((selected: boolean, i: number) => { + selected === true && selects.push(this.linkageForcesList[i].id) + }); + this.selectedLinkageForcesList = selects + }) + this.unitSelected() + }) + } + + //构造重点单位checkbox控制器 + buildUnits() { + const arr = this.keyUnitList.map(item => { + return this.fb.control(item.selected); }); - this.selectedUnitList = selects - }) - this.waters.valueChanges.subscribe(values => { - let selects:string[] = [] - values.forEach((selected:boolean,i:number) => { - selected === true && selects.push(this.waterList[i].id) + return this.fb.array(arr); + } + //构造水源checkbox控制器 + waterUnits() { + const arr = this.waterList.map(item => { + return this.fb.control(item.selected); }); - this.selectedWaterList = selects - }) - - this.fireForce.valueChanges.subscribe(values => { - let selects:string[] = [] - values.forEach((selected:boolean,i:number) => { - selected === true && selects.push(this.fireForceList[i].id) + return this.fb.array(arr); + } + //构造消防力量checkbox控制器 + fireForceController() { + const arr = this.fireForceList.map(item => { + return this.fb.control(item.selected); }); - this.selectedFireForceList = selects - }) - this.linkageForces.valueChanges.subscribe(values => { - let selects:string[] = [] - values.forEach((selected:boolean,i:number) => { - selected === true && selects.push(this.linkageForcesList[i].id) + return this.fb.array(arr); + } + //构造联动力量checkbox控制器 + linkageForcesController() { + const arr = this.linkageForcesList.map(item => { + return this.fb.control(item.selected); }); - this.selectedLinkageForcesList = selects - }) - this.unitSelected() - }) - } - - //构造重点单位checkbox控制器 - buildUnits() { - const arr = this.keyUnitList.map(item => { - return this.fb.control(item.selected); - }); - return this.fb.array(arr); - } - //构造水源checkbox控制器 - waterUnits() { - const arr = this.waterList.map(item => { - return this.fb.control(item.selected); - }); - return this.fb.array(arr); - } - //构造消防力量checkbox控制器 - fireForceController() { - const arr = this.fireForceList.map(item => { - return this.fb.control(item.selected); - }); - return this.fb.array(arr); - } - //构造联动力量checkbox控制器 - linkageForcesController() { - const arr = this.linkageForcesList.map(item => { - return this.fb.control(item.selected); - }); - return this.fb.array(arr); - } - - //初始化获取勾选项 - unitSelected(){ - this.keyUnitList.forEach(item => { - if(item.selected){ - this.selectedUnitList.push(item.name) - } + return this.fb.array(arr); + } + + //初始化获取勾选项 + unitSelected() { + this.keyUnitList.forEach(item => { + if (item.selected) { + this.selectedUnitList.push(item.name) + } + }) + this.waterList.forEach(item => { + if (item.selected) { + this.selectedWaterList.push(item.name) + } + }) + this.fireForceList.forEach(item => { + if (item.selected) { + this.selectedFireForceList.push(item.name) + } + }) + this.linkageForcesList.forEach(item => { + if (item.selected) { + this.selectedLinkageForcesList.push(item.name) + } + }) + } + //地图范围圆圈---重点单位 + circle = new AMap.Circle({ + center: null, + radius: 0, //半径 + strokeOpacity: 1, + fillOpacity: 0.4, + strokeStyle: 'dashed', + strokeDasharray: [10, 10], + // 线样式还支持 'dashed' + fillColor: '#1791fc', + zIndex: 50, }) - this.waterList.forEach(item => { - if(item.selected){ - this.selectedWaterList.push(item.name) - } + //地图范围圆圈---水源 + circleofwater = new AMap.Circle({ + center: null, + radius: 0, //半径 + strokeOpacity: 1, + fillOpacity: 0.4, + strokeStyle: 'dashed', + strokeDasharray: [10, 10], + // 线样式还支持 'dashed' + fillColor: '#ee2200', + zIndex: 50, }) - this.fireForceList.forEach(item => { - if(item.selected){ - this.selectedFireForceList.push(item.name) - } + //地图范围圆圈---消防力量 + circleoffireForce = new AMap.Circle({ + center: null, + radius: 0, //半径 + strokeOpacity: 1, + fillOpacity: 0.4, + strokeStyle: 'dashed', + strokeDasharray: [10, 10], + // 线样式还支持 'dashed' + fillColor: '#e830cc', + zIndex: 50, }) - this.linkageForcesList.forEach(item => { - if(item.selected){ - this.selectedLinkageForcesList.push(item.name) - } + //地图范围圆圈---联动力量 + circleoflinkageForces = new AMap.Circle({ + center: null, + radius: 0, //半径 + strokeOpacity: 1, + fillOpacity: 0.4, + strokeStyle: 'dashed', + strokeDasharray: [10, 10], + // 线样式还支持 'dashed' + fillColor: '#f6a317', + zIndex: 50, }) - } - //地图范围圆圈---重点单位 - circle = new AMap.Circle({ - center: null, - radius: 0, //半径 - strokeOpacity: 1, - fillOpacity: 0.4, - strokeStyle: 'dashed', - strokeDasharray: [10, 10], - // 线样式还支持 'dashed' - fillColor: '#1791fc', - zIndex: 50, - }) - //地图范围圆圈---水源 - circleofwater = new AMap.Circle({ - center: null, - radius: 0, //半径 - strokeOpacity: 1, - fillOpacity: 0.4, - strokeStyle: 'dashed', - strokeDasharray: [10, 10], - // 线样式还支持 'dashed' - fillColor: '#ee2200', - zIndex: 50, - }) - //地图范围圆圈---消防力量 - circleoffireForce = new AMap.Circle({ - center: null, - radius: 0, //半径 - strokeOpacity: 1, - fillOpacity: 0.4, - strokeStyle: 'dashed', - strokeDasharray: [10, 10], - // 线样式还支持 'dashed' - fillColor: '#e830cc', - zIndex: 50, - }) - //地图范围圆圈---联动力量 - circleoflinkageForces = new AMap.Circle({ - center: null, - radius: 0, //半径 - strokeOpacity: 1, - fillOpacity: 0.4, - strokeStyle: 'dashed', - strokeDasharray: [10, 10], - // 线样式还支持 'dashed' - fillColor: '#f6a317', - zIndex: 50, - }) - - - //重点单位提交 - ketUnitSubmit(value){ - if(this.markers.length == 0){ - let paramsdata:any = { - PageSize:99999, - BuildingTypeIdList : this.selectedUnitList.length != 0 ? this.selectedUnitList : ['123'] - } - this.http.get("/api/Companies",{params:paramsdata}).subscribe((data:any) => { - this.createUnitMarker(data.items) - }) - }else{ - this.circle.setRadius(Number(this.unitAreaDefault)) - this.circle.setCenter(this.markers[0]._position) - this.circle.setMap(this.map) - let Distance - let lnglat = new AMap.LngLat(this.selectedUnit.location.x, this.selectedUnit.location.y) // lng, lat 替换成传入的坐标 - if(this.unitAreaDefault == '0'){ - this.circle.setRadius(this.Calculationofdistance(this.map.getBounds())/2) - Distance = Math.abs(lnglat.offset(0, this.Calculationofdistance(this.map.getBounds())/2).lat - this.selectedUnit.location.y) - }else{ - Distance = Math.abs(lnglat.offset(0, this.unitAreaDefault).lat - this.selectedUnit.location.y) - } - if(this.unitAreaDefault == '-1'){//如果勾选全部 - let paramsdata:any = { - PageSize:99999, - BuildingTypeIdList : this.selectedUnitList.length != 0 ? this.selectedUnitList : ['123'] - } - this.http.get("/api/Companies",{params:paramsdata}).subscribe((data:any) => { - data.items.forEach((i,index) => { - if(i.id == this.selectedUnit.id){ - data.items.splice(index,1) + + + //重点单位提交 + ketUnitSubmit(value) { + if (this.markers.length == 0) { + let paramsdata: any = { + PageSize: 99999, + BuildingTypeIdList: this.selectedUnitList.length != 0 ? this.selectedUnitList : ['123'] + } + this.http.get("/api/Companies", { params: paramsdata }).subscribe((data: any) => { + this.createUnitMarker(data.items) + }) + } else { + this.circle.setRadius(Number(this.unitAreaDefault)) + this.circle.setCenter(this.markers[0]._position) + this.circle.setMap(this.map) + let Distance + let lnglat = new AMap.LngLat(this.selectedUnit.location.x, this.selectedUnit.location.y) // lng, lat 替换成传入的坐标 + if (this.unitAreaDefault == '0') { + this.circle.setRadius(this.Calculationofdistance(this.map.getBounds()) / 2) + Distance = Math.abs(lnglat.offset(0, this.Calculationofdistance(this.map.getBounds()) / 2).lat - this.selectedUnit.location.y) + } else { + Distance = Math.abs(lnglat.offset(0, this.unitAreaDefault).lat - this.selectedUnit.location.y) + } + if (this.unitAreaDefault == '-1') {//如果勾选全部 + let paramsdata: any = { + PageSize: 99999, + BuildingTypeIdList: this.selectedUnitList.length != 0 ? this.selectedUnitList : ['123'] + } + this.http.get("/api/Companies", { params: paramsdata }).subscribe((data: any) => { + data.items.forEach((i, index) => { + if (i.id == this.selectedUnit.id) { + data.items.splice(index, 1) + } + }) + this.createUnitMarker(data.items) + }) + } else { + let paramsdata: any = { + PageSize: 99999, + Lon: this.selectedUnit.location.x, + Lat: this.selectedUnit.location.y, + Distance: Distance, + BuildingTypeIdList: this.selectedUnitList.length != 0 ? this.selectedUnitList : ['123'] + } + this.http.get("/api/Companies", { params: paramsdata }).subscribe((data: any) => { + data.items.forEach((i, index) => { + if (i.id == this.selectedUnit.id) { + data.items.splice(index, 1) + } + }) + this.createUnitMarker(data.items) + }) } - }) - this.createUnitMarker(data.items) - }) - }else{ - let paramsdata:any = { - PageSize:99999, - Lon : this.selectedUnit.location.x, - Lat : this.selectedUnit.location.y, - Distance : Distance, - BuildingTypeIdList : this.selectedUnitList.length != 0 ? this.selectedUnitList : ['123'] } - this.http.get("/api/Companies",{params:paramsdata}).subscribe((data:any) => { - data.items.forEach((i,index) => { - if(i.id == this.selectedUnit.id){ - data.items.splice(index,1) + } + //创建单位markers + unitCluster: any //重点单位点聚合实例 + createUnitMarker(list) { + let unitMarkerArrcluster = [] + this.unitCluster ? this.unitCluster.setData([]) : null + list.forEach((item) => { + let image + if (item.buildingTypes[0].name.indexOf('高层') != -1) { + image = '/assets/images/Highbuilding.png' + } else if (item.buildingTypes[0].name.indexOf('化工') != -1) { + image = '/assets/images/Chemicalindustry.png' + } else if (item.buildingTypes[0].name.indexOf('餐饮') != -1) { + image = '/assets/images/canyin.png' + } else if (item.buildingTypes[0].name.indexOf('厂房') != -1) { + image = '/assets/images/changfang.png' + } else if (item.buildingTypes[0].name.indexOf('储罐') != -1) { + image = '/assets/images/chuguanlei.png' + } else if (item.buildingTypes[0].name.indexOf('地下') != -1) { + image = '/assets/images/dixia.png' + } else if (item.buildingTypes[0].name.indexOf('古建筑') != -1) { + image = '/assets/images/gujianzhu.png' + } else if (item.buildingTypes[0].name.indexOf('轨道' || '地铁' || '交通') != -1) { + image = '/assets/images/guidaojiaotong.png' + } else if (item.buildingTypes[0].name.indexOf('商场' || '超市') != -1) { + image = '/assets/images/shangchangchaoshi.png' + } else if (item.buildingTypes[0].name.indexOf('隧道') != -1) { + image = '/assets/images/suidao.png' + } else if (item.buildingTypes[0].name.indexOf('危化品') != -1) { + image = '/assets/images/weihuapin.png' + } else if (item.buildingTypes[0].name.indexOf('学校' || '教育') != -1) { + image = '/assets/images/xuexiao.png' + } else if (item.buildingTypes[0].name.indexOf('医院' || '医疗') != -1) { + image = '/assets/images/yiyuan.png' + } else if (item.buildingTypes[0].name.indexOf('影' || '剧') != -1) { + image = '/assets/images/yingjuyuan.png' + } else if (item.buildingTypes[0].name.indexOf('娱乐') != -1) { + image = '/assets/images/yule.png' + } else if (item.buildingTypes[0].name.indexOf('展览' || '景点' || '景区') != -1) { + image = '/assets/images/zhanlanjianzhu.png' + } else { + image = '/assets/images/qita.png' } - }) - this.createUnitMarker(data.items) + // 用于点集合的数组 + unitMarkerArrcluster.push({ + lnglat: [item.location.x, item.location.y], + image: image, + data: item + }) }) - } - } - } - //创建单位markers - unitCluster:any //重点单位点聚合实例 - createUnitMarker(list){ - let unitMarkerArrcluster = [] - this.unitCluster ? this.unitCluster.setData([]) : null - list.forEach((item) => { - let image - if(item.buildingTypes[0].name.indexOf('高层') != -1){ - image = '/assets/images/Highbuilding.png' - }else if(item.buildingTypes[0].name.indexOf('化工') != -1){ - image = '/assets/images/Chemicalindustry.png' - }else if(item.buildingTypes[0].name.indexOf('餐饮') != -1){ - image = '/assets/images/canyin.png' - }else if(item.buildingTypes[0].name.indexOf('厂房') != -1){ - image = '/assets/images/changfang.png' - }else if(item.buildingTypes[0].name.indexOf('储罐') != -1){ - image = '/assets/images/chuguanlei.png' - }else if(item.buildingTypes[0].name.indexOf('地下') != -1){ - image = '/assets/images/dixia.png' - }else if(item.buildingTypes[0].name.indexOf('古建筑') != -1){ - image = '/assets/images/gujianzhu.png' - }else if(item.buildingTypes[0].name.indexOf('轨道' || '地铁' || '交通') != -1){ - image = '/assets/images/guidaojiaotong.png' - }else if(item.buildingTypes[0].name.indexOf('商场' || '超市') != -1){ - image = '/assets/images/shangchangchaoshi.png' - }else if(item.buildingTypes[0].name.indexOf('隧道') != -1){ - image = '/assets/images/suidao.png' - }else if(item.buildingTypes[0].name.indexOf('危化品') != -1){ - image = '/assets/images/weihuapin.png' - }else if(item.buildingTypes[0].name.indexOf('学校' || '教育') != -1){ - image = '/assets/images/xuexiao.png' - }else if(item.buildingTypes[0].name.indexOf('医院' || '医疗') != -1){ - image = '/assets/images/yiyuan.png' - }else if(item.buildingTypes[0].name.indexOf('影' || '剧') != -1){ - image = '/assets/images/yingjuyuan.png' - }else if(item.buildingTypes[0].name.indexOf('娱乐') != -1){ - image = '/assets/images/yule.png' - }else if(item.buildingTypes[0].name.indexOf('展览' || '景点' || '景区') != -1){ - image = '/assets/images/zhanlanjianzhu.png' - }else{ - image = '/assets/images/qita.png' - } - // 用于点集合的数组 - unitMarkerArrcluster.push({ - lnglat : [item.location.x,item.location.y], - image : image, - data : item - }) - }) - this.map.plugin(["AMap.MarkerClusterer"],() => { - var gridSize = 60 - var count = unitMarkerArrcluster.length; - var _renderClusterMarker = function (context) { - var factor = Math.pow(context.count / count, 1 / 18); - var div = document.createElement('div'); - var Hue = 180 - factor * 180; - var bgColor = 'hsla(' + Hue + ',100%,40%,0.7)'; - var fontColor = 'hsla(' + Hue + ',100%,90%,1)'; - var borderColor = 'hsla(' + Hue + ',100%,40%,1)'; - var shadowColor = 'hsla(' + Hue + ',100%,90%,1)'; - div.style.backgroundColor = bgColor; - var size = Math.round(30 + Math.pow(context.count / count, 1 / 5) * 20); - div.style.width = div.style.height = size + 'px'; - div.style.border = 'solid 1px ' + borderColor; - div.style.borderRadius = size / 2 + 'px'; - div.style.boxShadow = '0 0 5px ' + shadowColor; - div.innerHTML = context.count; - div.style.lineHeight = size + 'px'; - div.style.color = fontColor; - div.style.fontSize = '14px'; - div.style.textAlign = 'center'; - context.marker.setOffset(new AMap.Pixel(-size / 2, -size / 2)); - context.marker.setContent(div) - }; - var _renderMarker = (context)=> { - var content = ``; - var offset = new AMap.Pixel(-15, -15); - context.marker.setContent(content) - context.marker.setOffset(offset) - } - this.unitCluster = new AMap.MarkerCluster(this.map, unitMarkerArrcluster, { - gridSize: gridSize, // 设置网格像素大小 - renderClusterMarker: _renderClusterMarker, // 自定义聚合点样式 - renderMarker: _renderMarker, // 自定义非聚合点样式 - }); - this.unitCluster.on('click',(e)=>{ - if(e.clusterData.length == 1){ - let item = e.clusterData[0].data - let markerContent = - `
+ this.map.plugin(["AMap.MarkerClusterer"], () => { + var gridSize = 60 + var count = unitMarkerArrcluster.length; + var _renderClusterMarker = function (context) { + var factor = Math.pow(context.count / count, 1 / 18); + var div = document.createElement('div'); + var Hue = 180 - factor * 180; + var bgColor = 'hsla(' + Hue + ',100%,40%,0.7)'; + var fontColor = 'hsla(' + Hue + ',100%,90%,1)'; + var borderColor = 'hsla(' + Hue + ',100%,40%,1)'; + var shadowColor = 'hsla(' + Hue + ',100%,90%,1)'; + div.style.backgroundColor = bgColor; + var size = Math.round(30 + Math.pow(context.count / count, 1 / 5) * 20); + div.style.width = div.style.height = size + 'px'; + div.style.border = 'solid 1px ' + borderColor; + div.style.borderRadius = size / 2 + 'px'; + div.style.boxShadow = '0 0 5px ' + shadowColor; + div.innerHTML = context.count; + div.style.lineHeight = size + 'px'; + div.style.color = fontColor; + div.style.fontSize = '14px'; + div.style.textAlign = 'center'; + context.marker.setOffset(new AMap.Pixel(-size / 2, -size / 2)); + context.marker.setContent(div) + }; + var _renderMarker = (context) => { + var content = ``; + var offset = new AMap.Pixel(-15, -15); + context.marker.setContent(content) + context.marker.setOffset(offset) + } + this.unitCluster = new AMap.MarkerCluster(this.map, unitMarkerArrcluster, { + gridSize: gridSize, // 设置网格像素大小 + renderClusterMarker: _renderClusterMarker, // 自定义聚合点样式 + renderMarker: _renderMarker, // 自定义非聚合点样式 + }); + this.unitCluster.on('click', (e) => { + if (e.clusterData.length == 1) { + let item = e.clusterData[0].data + let markerContent = + `
${item.name}
-
单位性质:
+
单位性质:
消防负责人:
@@ -435,716 +438,720 @@ export class GisLabelingComponent implements OnInit {
分享
` - // 创建一个自定义内容的 infowindow 实例 - this.infoWindow = new AMap.InfoWindow({ - position: [item.location.x,item.location.y], - offset: new AMap.Pixel(0, -30), - content: markerContent, - }); - this.infoWindow.open(this.map); - this.renderer2.listen(this.elementRef.nativeElement.querySelector('#baseInformation'),'click',(event)=>{ this.baseInformation(item) })//基本信息点击事件 - this.renderer2.listen(this.elementRef.nativeElement.querySelector('#route'),'click',(event)=>{ this.route(item) })//导航点击事件 - this.renderer2.listen(this.elementRef.nativeElement.querySelector('#fullViewNavigation'),'click',(event)=>{ this.fullViewNavigation(item) })//全景漫游点击事件 - this.renderer2.listen(this.elementRef.nativeElement.querySelector('#threeeScene'),'click',(event)=>{ this.threeeScene(item) })//三维场景点击事件 - this.renderer2.listen(this.elementRef.nativeElement.querySelector('#seePlan'),'click',(event)=>{ this.seePlan(item) })//查看预案点击事件 - this.renderer2.listen(this.elementRef.nativeElement.querySelector('#share'),'click',(event)=>{ this.share(item) })//分享点击事件 - } - }) - }); - - } - //取消显示单位 - resetUnit(){ - this.keyUnitForm.reset() - this.keyUnitForm.controls.areaUnit.setValue('-1') - this.map.remove(this.circle) - this.unitCluster.setData([]) - } - - - //消防力量提交 - fireForceSubmit(value){ - if(this.markers.length == 0){ - let paramsdata:any = { - PageSize:99999, - Levels : this.selectedFireForceList.length != 0 ? this.selectedFireForceList : -1 - } - this.http.get("/api/CustomFireForce",{params:paramsdata}).subscribe((data:any) => { - this.createFireForceMarker(data) - }) - }else{ - this.circleoffireForce.setRadius(Number(this.fireForceAreaDefault)) - this.circleoffireForce.setCenter(this.markers[0]._position) - this.circleoffireForce.setMap(this.map) - let Distance - let lnglat = new AMap.LngLat(this.selectedUnit.location.x, this.selectedUnit.location.y) // lng, lat 替换成传入的坐标 - if(this.fireForceAreaDefault == '0'){ - this.circleoffireForce.setRadius(this.Calculationofdistance(this.map.getBounds())/2) - Distance = Math.abs(lnglat.offset(0, this.Calculationofdistance(this.map.getBounds())/2).lat - this.selectedUnit.location.y) - }else{ - Distance = Math.abs(lnglat.offset(0, this.fireForceAreaDefault).lat - this.selectedUnit.location.y) - } - if(this.fireForceAreaDefault == '-1'){//如果勾选全部 - let paramsdata:any = { - PageSize:99999, - Levels : this.selectedFireForceList.length != 0 ? this.selectedFireForceList : -1 + // 创建一个自定义内容的 infowindow 实例 + this.infoWindow = new AMap.InfoWindow({ + position: [item.location.x, item.location.y], + offset: new AMap.Pixel(0, -30), + content: markerContent, + }); + this.infoWindow.open(this.map); + this.renderer2.listen(this.elementRef.nativeElement.querySelector('#baseInformation'), 'click', (event) => { this.baseInformation(item) })//基本信息点击事件 + this.renderer2.listen(this.elementRef.nativeElement.querySelector('#route'), 'click', (event) => { this.route(item) })//导航点击事件 + this.renderer2.listen(this.elementRef.nativeElement.querySelector('#fullViewNavigation'), 'click', (event) => { this.fullViewNavigation(item) })//全景漫游点击事件 + this.renderer2.listen(this.elementRef.nativeElement.querySelector('#threeeScene'), 'click', (event) => { this.threeeScene(item) })//三维场景点击事件 + this.renderer2.listen(this.elementRef.nativeElement.querySelector('#seePlan'), 'click', (event) => { this.seePlan(item) })//查看预案点击事件 + this.renderer2.listen(this.elementRef.nativeElement.querySelector('#share'), 'click', (event) => { this.share(item) })//分享点击事件 + } + }) + }); + + } + //取消显示单位 + resetUnit() { + this.keyUnitForm.reset() + this.keyUnitForm.controls.areaUnit.setValue('-1') + this.map.remove(this.circle) + this.unitCluster.setData([]) + } + + + //消防力量提交 + fireForceSubmit(value) { + if (this.markers.length == 0) { + let paramsdata: any = { + PageSize: 99999, + Levels: this.selectedFireForceList.length != 0 ? this.selectedFireForceList : -1 + } + this.http.get("/api/CustomFireForce", { params: paramsdata }).subscribe((data: any) => { + this.createFireForceMarker(data) + }) + } else { + this.circleoffireForce.setRadius(Number(this.fireForceAreaDefault)) + this.circleoffireForce.setCenter(this.markers[0]._position) + this.circleoffireForce.setMap(this.map) + let Distance + let lnglat = new AMap.LngLat(this.selectedUnit.location.x, this.selectedUnit.location.y) // lng, lat 替换成传入的坐标 + if (this.fireForceAreaDefault == '0') { + this.circleoffireForce.setRadius(this.Calculationofdistance(this.map.getBounds()) / 2) + Distance = Math.abs(lnglat.offset(0, this.Calculationofdistance(this.map.getBounds()) / 2).lat - this.selectedUnit.location.y) + } else { + Distance = Math.abs(lnglat.offset(0, this.fireForceAreaDefault).lat - this.selectedUnit.location.y) + } + if (this.fireForceAreaDefault == '-1') {//如果勾选全部 + let paramsdata: any = { + PageSize: 99999, + Levels: this.selectedFireForceList.length != 0 ? this.selectedFireForceList : -1 + } + this.http.get("/api/CustomFireForce", { params: paramsdata }).subscribe((data: any) => { + this.createFireForceMarker(data) + }) + } else { + let paramsdata: any = { + PageSize: 99999, + Lon: this.selectedUnit.location.x, + Lat: this.selectedUnit.location.y, + Distance: Distance, + Levels: this.selectedFireForceList.length != 0 ? this.selectedFireForceList : -1 + } + this.http.get("/api/CustomFireForce", { params: paramsdata }).subscribe((data: any) => { + this.createFireForceMarker(data) + }) + } } - this.http.get("/api/CustomFireForce",{params:paramsdata}).subscribe((data:any) => { - this.createFireForceMarker(data) + } + //创建消防力量markers + fireForceCluster: any //消防力量点聚合实例 + createFireForceMarker(list) { + let fireForceMarkerArrcluster = [] + this.fireForceCluster ? this.fireForceCluster.setData([]) : null + list.forEach((item) => { + let image + if (item.forceType == 2) { + image = '/assets/fireForcesMarkers/qita.png' + } else if (item.level == 0) { + image = '/assets/fireForcesMarkers/zongdui.png' + } else if (item.level == 1) { + image = '/assets/fireForcesMarkers/zhidui.png' + } else if (item.level == 2) { + image = '/assets/fireForcesMarkers/dadui.png' + } else if (item.level == 3) { + image = '/assets/fireForcesMarkers/zhongdui.png' + } + // 用于点集合的数组 + item.fireForceDetailInfo.location ? + fireForceMarkerArrcluster.push({ + lnglat: [item.fireForceDetailInfo.location.x, item.fireForceDetailInfo.location.y], + image: image, + data: item + }) : null }) - }else{ - let paramsdata:any = { - PageSize:99999, - Lon : this.selectedUnit.location.x, - Lat : this.selectedUnit.location.y, - Distance : Distance, - Levels : this.selectedFireForceList.length != 0 ? this.selectedFireForceList : -1 + this.map.plugin(["AMap.MarkerClusterer"], () => { + var gridSize = 60 + var count = fireForceMarkerArrcluster.length; + var _renderClusterMarker = function (context) { + var factor = Math.pow(context.count / count, 1 / 18); + var div = document.createElement('div'); + var Hue = 180 - factor * 180; + var bgColor = 'hsla(' + Hue + ',100%,40%,0.7)'; + var fontColor = 'hsla(' + Hue + ',100%,90%,1)'; + var borderColor = 'hsla(' + Hue + ',100%,40%,1)'; + var shadowColor = 'hsla(' + Hue + ',100%,90%,1)'; + div.style.backgroundColor = bgColor; + var size = Math.round(30 + Math.pow(context.count / count, 1 / 5) * 20); + div.style.width = div.style.height = size + 'px'; + div.style.border = 'solid 1px ' + borderColor; + div.style.borderRadius = size / 2 + 'px'; + div.style.boxShadow = '0 0 5px ' + shadowColor; + div.innerHTML = context.count; + div.style.lineHeight = size + 'px'; + div.style.color = fontColor; + div.style.fontSize = '14px'; + div.style.textAlign = 'center'; + context.marker.setOffset(new AMap.Pixel(-size / 2, -size / 2)); + context.marker.setContent(div) + }; + var _renderMarker = (context) => { + var content = ``; + var offset = new AMap.Pixel(-15, -15); + context.marker.setContent(content) + context.marker.setOffset(offset) + } + this.fireForceCluster = new AMap.MarkerCluster(this.map, fireForceMarkerArrcluster, { + gridSize: gridSize, // 设置网格像素大小 + renderClusterMarker: _renderClusterMarker, // 自定义聚合点样式 + renderMarker: _renderMarker, // 自定义非聚合点样式 + }); + }); + } + //取消消防力量 + resetFireForce() { + this.fireForceForm.reset() + this.fireForceForm.controls.areaFireForce.setValue('-1') + this.map.remove(this.circleoffireForce) + this.fireForceCluster.setData([]) + } + + + + + //联动力量提交 + linkageForcesSubmit(value) { + console.log(this.selectedLinkageForcesList) + if (this.markers.length == 0) { + let paramsdata: any = { + PageSize: 999999, + LinkageForceTypes: this.selectedLinkageForcesList.length != 0 ? this.selectedLinkageForcesList : -1 + } + this.http.get("/api/LinkageForces", { params: paramsdata }).subscribe((data: any) => { + console.log(data) + this.createLinkageForcesMarker(data.items) + }) + } else { + this.circleoflinkageForces.setRadius(Number(this.linkageForcesAreaDefault)) + this.circleoflinkageForces.setCenter(this.markers[0]._position) + this.circleoflinkageForces.setMap(this.map) + let Distance + let lnglat = new AMap.LngLat(this.selectedUnit.location.x, this.selectedUnit.location.y) // lng, lat 替换成传入的坐标 + if (this.linkageForcesAreaDefault == '0') { + this.circleoflinkageForces.setRadius(this.Calculationofdistance(this.map.getBounds()) / 2) + Distance = Math.abs(lnglat.offset(0, this.Calculationofdistance(this.map.getBounds()) / 2).lat - this.selectedUnit.location.y) + } else { + Distance = Math.abs(lnglat.offset(0, this.linkageForcesAreaDefault).lat - this.selectedUnit.location.y) + } + if (this.linkageForcesAreaDefault == '-1') {//如果勾选全部 + let paramsdata: any = { + PageSize: 999999, + LinkageForceTypes: this.selectedLinkageForcesList.length != 0 ? this.selectedLinkageForcesList : -1 + } + this.http.get("/api/LinkageForces", { params: paramsdata }).subscribe((data: any) => { + this.createLinkageForcesMarker(data.items) + }) + } else { + let paramsdata: any = { + PageSize: 99999, + Lon: this.selectedUnit.location.x, + Lat: this.selectedUnit.location.y, + Distance: Distance, + LinkageForceTypes: this.selectedLinkageForcesList.length != 0 ? this.selectedLinkageForcesList : -1 + } + this.http.get("/api/LinkageForces", { params: paramsdata }).subscribe((data: any) => { + this.createLinkageForcesMarker(data.items) + }) + } } - this.http.get("/api/CustomFireForce",{params:paramsdata}).subscribe((data:any) => { - this.createFireForceMarker(data) + } + //创建联动力量markers + linkageForcesCluster: any //联动力量点聚合实例 + createLinkageForcesMarker(list) { + let linkageForcesMarkerArrcluster = [] + this.linkageForcesCluster ? this.linkageForcesCluster.setData([]) : null + list.forEach((item) => { + let image + if (item.linkageForceType == 0) {//消火栓 + image = '/assets/linkageForcesMarkers/anjian.png' + } else if (item.linkageForceType == 1) {//消防水池 + image = '/assets/linkageForcesMarkers/dianliju.png' + } else if (item.linkageForceType == 2) {//天然联动力量 + image = '/assets/linkageForcesMarkers/gongan.png' + } else if (item.linkageForceType == 3) {//天然水源 + image = '/assets/linkageForcesMarkers/haishi.png' + } else if (item.linkageForceType == 4) {//天然水源 + image = '/assets/linkageForcesMarkers/huanbaoju.png' + } else if (item.linkageForceType == 5) {//天然水源 + image = '/assets/linkageForcesMarkers/jiaotong.png' + } else if (item.linkageForceType == 6) {//天然水源 + image = '/assets/linkageForcesMarkers/minzheng.png' + } else if (item.linkageForceType == 7) {//天然水源 + image = '/assets/linkageForcesMarkers/qixiangju.png' + } else if (item.linkageForceType == 8) {//天然水源 + image = '/assets/linkageForcesMarkers/ranqiju.png' + } else if (item.linkageForceType == 9) {//天然水源 + image = '/assets/linkageForcesMarkers/shizheng.png' + } else if (item.linkageForceType == 10) {//天然水源 + image = '/assets/linkageForcesMarkers/shuili.png' + } else if (item.linkageForceType == 11) {//天然水源 + image = '/assets/linkageForcesMarkers/tongxin.png' + } else if (item.linkageForceType == 12) {//天然水源 + image = '/assets/linkageForcesMarkers/yiliao.png' + } else if (item.linkageForceType == 13) {//天然水源 + image = '/assets/linkageForcesMarkers/yingjiguanli.png' + } else if (item.linkageForceType == 14) {//天然水源 + image = '/assets/linkageForcesMarkers/zhujian.png' + } + // 用于点集合的数组 + if (item.location && item.location.x) { + linkageForcesMarkerArrcluster.push({ + lnglat: [item.location.x, item.location.y], + image: image, + data: item + }) + } + // 用于点集合的数组 }) - } - } - } - //创建消防力量markers - fireForceCluster:any //消防力量点聚合实例 - createFireForceMarker(list){ - let fireForceMarkerArrcluster = [] - this.fireForceCluster ? this.fireForceCluster.setData([]) : null - list.forEach((item) => { - let image - if(item.forceType == 2){ - image = '/assets/fireForcesMarkers/qita.png' - }else if(item.level == 0){ - image = '/assets/fireForcesMarkers/zongdui.png' - }else if(item.level == 1){ - image = '/assets/fireForcesMarkers/zhidui.png' - }else if(item.level == 2){ - image = '/assets/fireForcesMarkers/dadui.png' - }else if(item.level == 3){ - image = '/assets/fireForcesMarkers/zhongdui.png' - } - // 用于点集合的数组 - item.fireForceDetailInfo.location ? - fireForceMarkerArrcluster.push({ - lnglat : [item.fireForceDetailInfo.location.x,item.fireForceDetailInfo.location.y], - image : image, - data : item - }) : null - }) - this.map.plugin(["AMap.MarkerClusterer"],() => { - var gridSize = 60 - var count = fireForceMarkerArrcluster.length; - var _renderClusterMarker = function (context) { - var factor = Math.pow(context.count / count, 1 / 18); - var div = document.createElement('div'); - var Hue = 180 - factor * 180; - var bgColor = 'hsla(' + Hue + ',100%,40%,0.7)'; - var fontColor = 'hsla(' + Hue + ',100%,90%,1)'; - var borderColor = 'hsla(' + Hue + ',100%,40%,1)'; - var shadowColor = 'hsla(' + Hue + ',100%,90%,1)'; - div.style.backgroundColor = bgColor; - var size = Math.round(30 + Math.pow(context.count / count, 1 / 5) * 20); - div.style.width = div.style.height = size + 'px'; - div.style.border = 'solid 1px ' + borderColor; - div.style.borderRadius = size / 2 + 'px'; - div.style.boxShadow = '0 0 5px ' + shadowColor; - div.innerHTML = context.count; - div.style.lineHeight = size + 'px'; - div.style.color = fontColor; - div.style.fontSize = '14px'; - div.style.textAlign = 'center'; - context.marker.setOffset(new AMap.Pixel(-size / 2, -size / 2)); - context.marker.setContent(div) - }; - var _renderMarker = (context)=> { - var content = ``; - var offset = new AMap.Pixel(-15, -15); - context.marker.setContent(content) - context.marker.setOffset(offset) - } - this.fireForceCluster = new AMap.MarkerCluster(this.map, fireForceMarkerArrcluster, { - gridSize: gridSize, // 设置网格像素大小 - renderClusterMarker: _renderClusterMarker, // 自定义聚合点样式 - renderMarker: _renderMarker, // 自定义非聚合点样式 - }); - }); - } - //取消消防力量 - resetFireForce(){ - this.fireForceForm.reset() - this.fireForceForm.controls.areaFireForce.setValue('-1') - this.map.remove(this.circleoffireForce) - this.fireForceCluster.setData([]) - } - - - - - //联动力量提交 - linkageForcesSubmit(value){ - console.log(this.selectedLinkageForcesList) - if(this.markers.length == 0){ - let paramsdata:any = { - PageSize : 999999, - LinkageForceTypes:this.selectedLinkageForcesList.length != 0 ? this.selectedLinkageForcesList : -1 - } - this.http.get("/api/LinkageForces",{params:paramsdata}).subscribe((data:any) => { - console.log(data) - this.createLinkageForcesMarker(data.items) - }) - }else{ - this.circleoflinkageForces.setRadius(Number(this.linkageForcesAreaDefault)) - this.circleoflinkageForces.setCenter(this.markers[0]._position) - this.circleoflinkageForces.setMap(this.map) - let Distance - let lnglat = new AMap.LngLat(this.selectedUnit.location.x, this.selectedUnit.location.y) // lng, lat 替换成传入的坐标 - if(this.linkageForcesAreaDefault == '0'){ - this.circleoflinkageForces.setRadius(this.Calculationofdistance(this.map.getBounds())/2) - Distance = Math.abs(lnglat.offset(0, this.Calculationofdistance(this.map.getBounds())/2).lat - this.selectedUnit.location.y) - }else{ - Distance = Math.abs(lnglat.offset(0, this.linkageForcesAreaDefault).lat - this.selectedUnit.location.y) - } - if(this.linkageForcesAreaDefault == '-1'){//如果勾选全部 - let paramsdata:any = { - PageSize : 999999, - LinkageForceTypes:this.selectedLinkageForcesList.length != 0 ? this.selectedLinkageForcesList : -1 + this.map.plugin(["AMap.MarkerClusterer"], () => { + var gridSize = 60 + var count = linkageForcesMarkerArrcluster.length; + var _renderClusterMarker = function (context) { + var factor = Math.pow(context.count / count, 1 / 18); + var div = document.createElement('div'); + var Hue = 180 - factor * 180; + var bgColor = 'hsla(' + Hue + ',100%,40%,0.7)'; + var fontColor = 'hsla(' + Hue + ',100%,90%,1)'; + var borderColor = 'hsla(' + Hue + ',100%,40%,1)'; + var shadowColor = 'hsla(' + Hue + ',100%,90%,1)'; + div.style.backgroundColor = bgColor; + var size = Math.round(30 + Math.pow(context.count / count, 1 / 5) * 20); + div.style.width = div.style.height = size + 'px'; + div.style.border = 'solid 1px ' + borderColor; + div.style.borderRadius = size / 2 + 'px'; + div.style.boxShadow = '0 0 5px ' + shadowColor; + div.innerHTML = context.count; + div.style.lineHeight = size + 'px'; + div.style.color = fontColor; + div.style.fontSize = '14px'; + div.style.textAlign = 'center'; + context.marker.setOffset(new AMap.Pixel(-size / 2, -size / 2)); + context.marker.setContent(div) + }; + var _renderMarker = (context) => { + var content = ``; + var offset = new AMap.Pixel(-15, -15); + context.marker.setContent(content) + context.marker.setOffset(offset) + } + this.linkageForcesCluster = new AMap.MarkerCluster(this.map, linkageForcesMarkerArrcluster, { + gridSize: gridSize, // 设置网格像素大小 + renderClusterMarker: _renderClusterMarker, // 自定义聚合点样式 + renderMarker: _renderMarker, // 自定义非聚合点样式 + }); + }); + } + //取消联动力量 + resetLinkageForces() { + this.linkageForcesForm.reset() + this.linkageForcesForm.controls.areaLinkageForces.setValue('-1') + this.map.remove(this.circleoflinkageForces) + this.linkageForcesCluster.setData([]) + } + + + + + + //水源提交 + waterSubmit(value) { + if (this.markers.length == 0) { + if (this.selectedWaterList.length != 0) {//勾选了水源类型 + let paramsdata: any = { + PageSize: 99999, + WaterSourceTypes: this.selectedWaterList + } + this.http.get("/api/WaterSources", { params: paramsdata }).subscribe((data: any) => { + this.createwaterMarker(data.items) + }) + } else { + let config = new MatSnackBarConfig(); + config.verticalPosition = 'top'; + config.duration = 3000 + this.snackBar.open('请勾选想要显示的水源类型', '确定', config); + } + } else { + this.circleofwater.setRadius(Number(this.waterAreaDefault)) + this.circleofwater.setCenter(this.markers[0]._position) + this.circleofwater.setMap(this.map) + let Distance + let lnglat = new AMap.LngLat(this.selectedUnit.location.x, this.selectedUnit.location.y) // lng, lat 替换成传入的坐标 + + //如果选择当前的视野范围算出查询半径 + if (this.waterAreaDefault == '0') { + this.circleofwater.setRadius(this.Calculationofdistance(this.map.getBounds()) / 2) + Distance = Math.abs(lnglat.offset(0, this.Calculationofdistance(this.map.getBounds()) / 2).lat - this.selectedUnit.location.y) + } else { + Distance = Math.abs(lnglat.offset(0, this.waterAreaDefault).lat - this.selectedUnit.location.y) + } + //如果选择全部 + if (this.waterAreaDefault == '-1') { + if (this.selectedWaterList.length != 0) { + let paramsdata: any = { + PageSize: 99999, + WaterSourceTypes: this.selectedWaterList + } + this.http.get("/api/WaterSources", { params: paramsdata }).subscribe((data: any) => { + this.createwaterMarker(data.items) + }) + } else { + let config = new MatSnackBarConfig(); + config.verticalPosition = 'top'; + config.duration = 3000 + this.snackBar.open('请勾选想要显示的水源类型', '确定', config); + } + + } else { + if (this.selectedWaterList.length != 0) { + let paramsdata: any = { + PageSize: 99999, + Lon: this.selectedUnit.location.x, + Lat: this.selectedUnit.location.y, + Distance: Distance, + WaterSourceTypes: this.selectedWaterList + } + this.http.get("/api/WaterSources", { params: paramsdata }).subscribe((data: any) => { + this.createwaterMarker(data.items) + }) + } else { + let config = new MatSnackBarConfig(); + config.verticalPosition = 'top'; + config.duration = 3000 + this.snackBar.open('请勾选想要显示的水源类型', '确定', config); + } + } } - this.http.get("/api/LinkageForces",{params:paramsdata}).subscribe((data:any) => { - this.createLinkageForcesMarker(data.items) + } + //循环渲染出所有水源markers + waterCluster: any //水源聚合实例 + createwaterMarker(list) { + let waterMarkerArrcluster = [] + this.waterCluster ? this.waterCluster.setData([]) : null + list.forEach((item) => { + let image + if (item.waterSourceType == 0) {//消火栓 + image = '/assets/waterMarkers/szxhs.png' + } else if (item.waterSourceType == 1) {//消防水池 + image = '/assets/waterMarkers/fxcsc.png' + } else if (item.waterSourceType == 2) {//天然水源 + image = '/assets/waterMarkers/trsy.png' + } + // 用于点集合的数组 + waterMarkerArrcluster.push({ + lnglat: [item.location.x, item.location.y], + image: image, + data: item + }) }) - }else{ - let paramsdata:any = { - PageSize:99999, - Lon : this.selectedUnit.location.x, - Lat : this.selectedUnit.location.y, - Distance : Distance, - LinkageForceTypes:this.selectedLinkageForcesList.length != 0 ? this.selectedLinkageForcesList : -1 + this.map.plugin(["AMap.MarkerClusterer"], () => { + var gridSize = 60 + var count = waterMarkerArrcluster.length; + var _renderClusterMarker = function (context) { + var factor = Math.pow(context.count / count, 1 / 18); + var div = document.createElement('div'); + var Hue = 180 - factor * 180; + var bgColor = 'hsla(' + Hue + ',100%,40%,0.7)'; + var fontColor = 'hsla(' + Hue + ',100%,90%,1)'; + var borderColor = 'hsla(' + Hue + ',100%,40%,1)'; + var shadowColor = 'hsla(' + Hue + ',100%,90%,1)'; + div.style.backgroundColor = bgColor; + var size = Math.round(30 + Math.pow(context.count / count, 1 / 5) * 20); + div.style.width = div.style.height = size + 'px'; + div.style.border = 'solid 1px ' + borderColor; + div.style.borderRadius = size / 2 + 'px'; + div.style.boxShadow = '0 0 5px ' + shadowColor; + div.innerHTML = context.count; + div.style.lineHeight = size + 'px'; + div.style.color = fontColor; + div.style.fontSize = '14px'; + div.style.textAlign = 'center'; + context.marker.setOffset(new AMap.Pixel(-size / 2, -size / 2)); + context.marker.setContent(div) + }; + var _renderMarker = (context) => { + var content = ``; + var offset = new AMap.Pixel(-15, -15); + context.marker.setContent(content) + context.marker.setOffset(offset) + } + this.waterCluster = new AMap.MarkerCluster(this.map, waterMarkerArrcluster, { + gridSize: gridSize, // 设置网格像素大小 + renderClusterMarker: _renderClusterMarker, // 自定义聚合点样式 + renderMarker: _renderMarker, // 自定义非聚合点样式 + }); + this.waterCluster.on('click', (e) => { + if (e.clusterData.length == 1) { + + } + }) + }); + + } + //取消显示水源 + resetWater() { + this.watertForm.reset() + this.watertForm.controls.areaWater.setValue('-1') + this.map.remove(this.circleofwater) + this.waterCluster.setData([]) + } + + + //计算两地距离 + Calculationofdistance(bounds) { + let p1 = [bounds.northEast.lng, bounds.northEast.lat]; + let p2 = [bounds.northEast.lng, bounds.southWest.lat]; + // 返回 p1 到 p2 间的地面距离,单位:米 + let dis = AMap.GeometryUtil.distance(p1, p2); + return dis + } + + //全选重点单位 + selectedAllUnit(event) { + if (event.checked) { + this.units.controls.forEach(item => { item.setValue(true) }) + } else { + this.keyUnitForm.reset() + this.keyUnitForm.controls.areaUnit.setValue('0') } - this.http.get("/api/LinkageForces",{params:paramsdata}).subscribe((data:any) => { - this.createLinkageForcesMarker(data.items) - }) - } - } - } - //创建联动力量markers - linkageForcesCluster:any //联动力量点聚合实例 - createLinkageForcesMarker(list){ - let linkageForcesMarkerArrcluster = [] - this.linkageForcesCluster ? this.linkageForcesCluster.setData([]) : null - list.forEach((item) => { - let image - if(item.linkageForceType == 0){//消火栓 - image = '/assets/linkageForcesMarkers/anjian.png' - }else if(item.linkageForceType == 1){//消防水池 - image = '/assets/linkageForcesMarkers/dianliju.png' - }else if(item.linkageForceType == 2){//天然联动力量 - image = '/assets/linkageForcesMarkers/gongan.png' - }else if(item.linkageForceType == 3){//天然水源 - image = '/assets/linkageForcesMarkers/haishi.png' - }else if(item.linkageForceType == 4){//天然水源 - image = '/assets/linkageForcesMarkers/huanbaoju.png' - }else if(item.linkageForceType == 5){//天然水源 - image = '/assets/linkageForcesMarkers/jiaotong.png' - }else if(item.linkageForceType == 6){//天然水源 - image = '/assets/linkageForcesMarkers/minzheng.png' - }else if(item.linkageForceType == 7){//天然水源 - image = '/assets/linkageForcesMarkers/qixiangju.png' - }else if(item.linkageForceType == 8){//天然水源 - image = '/assets/linkageForcesMarkers/ranqiju.png' - }else if(item.linkageForceType == 9){//天然水源 - image = '/assets/linkageForcesMarkers/shizheng.png' - }else if(item.linkageForceType == 10){//天然水源 - image = '/assets/linkageForcesMarkers/shuili.png' - }else if(item.linkageForceType == 11){//天然水源 - image = '/assets/linkageForcesMarkers/tongxin.png' - }else if(item.linkageForceType == 12){//天然水源 - image = '/assets/linkageForcesMarkers/yiliao.png' - }else if(item.linkageForceType == 13){//天然水源 - image = '/assets/linkageForcesMarkers/yingjiguanli.png' - }else if(item.linkageForceType == 14){//天然水源 - image = '/assets/linkageForcesMarkers/zhujian.png' - } - // 用于点集合的数组 - if(item.location && item.location.x){ - linkageForcesMarkerArrcluster.push({ - lnglat : [item.location.x,item.location.y], - image : image, - data : item - }) - } - // 用于点集合的数组 - }) - this.map.plugin(["AMap.MarkerClusterer"],() => { - var gridSize = 60 - var count = linkageForcesMarkerArrcluster.length; - var _renderClusterMarker = function (context) { - var factor = Math.pow(context.count / count, 1 / 18); - var div = document.createElement('div'); - var Hue = 180 - factor * 180; - var bgColor = 'hsla(' + Hue + ',100%,40%,0.7)'; - var fontColor = 'hsla(' + Hue + ',100%,90%,1)'; - var borderColor = 'hsla(' + Hue + ',100%,40%,1)'; - var shadowColor = 'hsla(' + Hue + ',100%,90%,1)'; - div.style.backgroundColor = bgColor; - var size = Math.round(30 + Math.pow(context.count / count, 1 / 5) * 20); - div.style.width = div.style.height = size + 'px'; - div.style.border = 'solid 1px ' + borderColor; - div.style.borderRadius = size / 2 + 'px'; - div.style.boxShadow = '0 0 5px ' + shadowColor; - div.innerHTML = context.count; - div.style.lineHeight = size + 'px'; - div.style.color = fontColor; - div.style.fontSize = '14px'; - div.style.textAlign = 'center'; - context.marker.setOffset(new AMap.Pixel(-size / 2, -size / 2)); - context.marker.setContent(div) - }; - var _renderMarker = (context)=> { - var content = ``; - var offset = new AMap.Pixel(-15, -15); - context.marker.setContent(content) - context.marker.setOffset(offset) - } - this.linkageForcesCluster = new AMap.MarkerCluster(this.map, linkageForcesMarkerArrcluster, { - gridSize: gridSize, // 设置网格像素大小 - renderClusterMarker: _renderClusterMarker, // 自定义聚合点样式 - renderMarker: _renderMarker, // 自定义非聚合点样式 - }); - }); - } - //取消联动力量 - resetLinkageForces(){ - this.linkageForcesForm.reset() - this.linkageForcesForm.controls.areaLinkageForces.setValue('-1') - this.map.remove(this.circleoflinkageForces) - this.linkageForcesCluster.setData([]) - } - - - - - - //水源提交 - waterSubmit(value){ - if(this.markers.length == 0){ - if(this.selectedWaterList.length != 0){//勾选了水源类型 - let paramsdata:any = { - PageSize:99999, - WaterSourceTypes : this.selectedWaterList + } + //全选水源 + selectedAllWater(event) { + if (event.checked) { + this.waters.controls.forEach(item => { item.setValue(true) }) + } else { + this.watertForm.reset() + this.watertForm.controls.areaWater.setValue('0') } - this.http.get("/api/WaterSources",{params:paramsdata}).subscribe((data:any) => { - this.createwaterMarker(data.items) - }) - }else{ - let config = new MatSnackBarConfig(); - config.verticalPosition = 'top'; - config.duration = 3000 - this.snackBar.open('请勾选想要显示的水源类型','确定',config); - } - }else{ - this.circleofwater.setRadius(Number(this.waterAreaDefault)) - this.circleofwater.setCenter(this.markers[0]._position) - this.circleofwater.setMap(this.map) - let Distance - let lnglat = new AMap.LngLat(this.selectedUnit.location.x, this.selectedUnit.location.y) // lng, lat 替换成传入的坐标 - - //如果选择当前的视野范围算出查询半径 - if(this.waterAreaDefault == '0'){ - this.circleofwater.setRadius(this.Calculationofdistance(this.map.getBounds())/2) - Distance = Math.abs(lnglat.offset(0, this.Calculationofdistance(this.map.getBounds())/2).lat - this.selectedUnit.location.y) - }else{ - Distance = Math.abs(lnglat.offset(0, this.waterAreaDefault).lat - this.selectedUnit.location.y) - } - //如果选择全部 - if(this.waterAreaDefault == '-1'){ - if(this.selectedWaterList.length != 0){ - let paramsdata:any = { - PageSize:99999, - WaterSourceTypes : this.selectedWaterList - } - this.http.get("/api/WaterSources",{params:paramsdata}).subscribe((data:any) => { - this.createwaterMarker(data.items) - }) - }else{ - let config = new MatSnackBarConfig(); - config.verticalPosition = 'top'; - config.duration = 3000 - this.snackBar.open('请勾选想要显示的水源类型','确定',config); + } + //全选消防力量 + selectedAllFireForce(event) { + if (event.checked) { + this.fireForce.controls.forEach(item => { item.setValue(true) }) + } else { + this.fireForceForm.reset() + this.fireForceForm.controls.areaFireForce.setValue('0') } - - }else{ - if(this.selectedWaterList.length != 0){ - let paramsdata:any = { - PageSize:99999, - Lon : this.selectedUnit.location.x, - Lat : this.selectedUnit.location.y, - Distance : Distance, - WaterSourceTypes :this.selectedWaterList - } - this.http.get("/api/WaterSources",{params:paramsdata}).subscribe((data:any) => { - this.createwaterMarker(data.items) - }) - }else{ - let config = new MatSnackBarConfig(); - config.verticalPosition = 'top'; - config.duration = 3000 - this.snackBar.open('请勾选想要显示的水源类型','确定',config); + } + //全选联动力量 + selectedAllLinkageForces(event) { + if (event.checked) { + this.linkageForces.controls.forEach(item => { item.setValue(true) }) + } else { + this.linkageForcesForm.reset() + this.linkageForcesForm.controls.areaLinkageForces.setValue('0') } - } - } - } - //循环渲染出所有水源markers - waterCluster:any //水源聚合实例 - createwaterMarker(list){ - let waterMarkerArrcluster = [] - this.waterCluster ? this.waterCluster.setData([]) : null - list.forEach((item) => { - let image - if(item.waterSourceType == 0){//消火栓 - image = '/assets/waterMarkers/szxhs.png' - }else if(item.waterSourceType == 1){//消防水池 - image = '/assets/waterMarkers/fxcsc.png' - }else if(item.waterSourceType == 2){//天然水源 - image = '/assets/waterMarkers/trsy.png' - } - // 用于点集合的数组 - waterMarkerArrcluster.push({ - lnglat : [item.location.x,item.location.y], - image : image, - data : item - }) - }) - this.map.plugin(["AMap.MarkerClusterer"],() => { - var gridSize = 60 - var count = waterMarkerArrcluster.length; - var _renderClusterMarker = function (context) { - var factor = Math.pow(context.count / count, 1 / 18); - var div = document.createElement('div'); - var Hue = 180 - factor * 180; - var bgColor = 'hsla(' + Hue + ',100%,40%,0.7)'; - var fontColor = 'hsla(' + Hue + ',100%,90%,1)'; - var borderColor = 'hsla(' + Hue + ',100%,40%,1)'; - var shadowColor = 'hsla(' + Hue + ',100%,90%,1)'; - div.style.backgroundColor = bgColor; - var size = Math.round(30 + Math.pow(context.count / count, 1 / 5) * 20); - div.style.width = div.style.height = size + 'px'; - div.style.border = 'solid 1px ' + borderColor; - div.style.borderRadius = size / 2 + 'px'; - div.style.boxShadow = '0 0 5px ' + shadowColor; - div.innerHTML = context.count; - div.style.lineHeight = size + 'px'; - div.style.color = fontColor; - div.style.fontSize = '14px'; - div.style.textAlign = 'center'; - context.marker.setOffset(new AMap.Pixel(-size / 2, -size / 2)); - context.marker.setContent(div) - }; - var _renderMarker = (context)=> { - var content = ``; - var offset = new AMap.Pixel(-15, -15); - context.marker.setContent(content) - context.marker.setOffset(offset) - } - this.waterCluster = new AMap.MarkerCluster(this.map, waterMarkerArrcluster, { - gridSize: gridSize, // 设置网格像素大小 - renderClusterMarker: _renderClusterMarker, // 自定义聚合点样式 - renderMarker: _renderMarker, // 自定义非聚合点样式 - }); - this.waterCluster.on('click',(e)=>{ - if(e.clusterData.length == 1){ - + } + + + + + //右上角点击每一个title + clickTitle(index) { + this.selectedTitle = index + } + closertdiv() { + this.selectedTitle = null + } + + //卫星图层 + satelliteLayer = new AMap.TileLayer.Satellite(); + satelliteModel: boolean = false + satelliteChange(e) { + e.checked ? this.map.add(this.satelliteLayer) : this.map.remove(this.satelliteLayer); + } + + //路网图层 + roadNetLayer = new AMap.TileLayer.RoadNet(); + loadModel: boolean = false + loadChange(e) { + e.checked ? this.map.add(this.roadNetLayer) : this.map.remove(this.roadNetLayer); + } + + @ViewChild('appLeft', { static: false }) appLeft: any //子组件 + leftDivState: boolean = false; //左侧工作区显示隐藏 + showLeftDiv: boolean = false//左侧工作区消失 + + //左侧工作区显示隐藏 + toggleLeft(e) { + this.leftDivState = e + } + + //左侧工作区关闭 + closeDiv() { + this.leftDivState = false + this.showLeftDiv = false + } + + map: any //地图 + markers: any = []; //markers标注 + + //地图2D 3D切换 + mapPattern: boolean = true//默认是2D + mapPatternChange(type) { + this.unitCluster = null + this.waterCluster = null + this.checkRadio = false + if (type == '2D') { + this.mapPattern = true + this.mapInit() + } else { + this.unitCluster ? this.unitCluster.setData([]) : null + this.mapPattern = false + this.map = new AMap.Map('map', { + viewMode: '3D', + pitch: 60, + rotation: -35, + features: ['bg', 'road', 'point', 'building'], + mapStyle: 'amap://styles/light', + }); + + + + this.map.setCity('上海市'); } - }) - }); - - } - //取消显示水源 - resetWater(){ - this.watertForm.reset() - this.watertForm.controls.areaWater.setValue('-1') - this.map.remove(this.circleofwater) - this.waterCluster.setData([]) - } - - - //计算两地距离 - Calculationofdistance(bounds){ - let p1 = [bounds.northEast.lng, bounds.northEast.lat]; - let p2 = [bounds.northEast.lng, bounds.southWest.lat]; - // 返回 p1 到 p2 间的地面距离,单位:米 - let dis = AMap.GeometryUtil.distance(p1, p2); - return dis - } - - //全选重点单位 - selectedAllUnit(event){ - if(event.checked){ - this.units.controls.forEach(item => {item.setValue(true)}) - }else{ - this.keyUnitForm.reset() - this.keyUnitForm.controls.areaUnit.setValue('0') - } - } - //全选水源 - selectedAllWater(event){ - if(event.checked){ - this.waters.controls.forEach(item => {item.setValue(true)}) - }else{ - this.watertForm.reset() - this.watertForm.controls.areaWater.setValue('0') - } - } - //全选消防力量 - selectedAllFireForce(event){ - if(event.checked){ - this.fireForce.controls.forEach(item => {item.setValue(true)}) - }else{ - this.fireForceForm.reset() - this.fireForceForm.controls.areaFireForce.setValue('0') - } - } - //全选联动力量 - selectedAllLinkageForces(event){ - if(event.checked){ - this.linkageForces.controls.forEach(item => {item.setValue(true)}) - }else{ - this.linkageForcesForm.reset() - this.linkageForcesForm.controls.areaLinkageForces.setValue('0') - } - } - - - - - //右上角点击每一个title - clickTitle(index){ - this.selectedTitle = index - } - closertdiv(){ - this.selectedTitle = null - } - - //卫星图层 - satelliteLayer = new AMap.TileLayer.Satellite(); - satelliteModel:boolean = false - satelliteChange(e){ - e.checked ? this.map.add(this.satelliteLayer) : this.map.remove(this.satelliteLayer); - } - - //路网图层 - roadNetLayer = new AMap.TileLayer.RoadNet(); - loadModel:boolean = false - loadChange(e){ - e.checked ? this.map.add(this.roadNetLayer) : this.map.remove(this.roadNetLayer); - } - - @ViewChild( 'appLeft',{static: false} ) appLeft:any //子组件 - leftDivState:boolean = false; //左侧工作区显示隐藏 - showLeftDiv:boolean = false//左侧工作区消失 - - //左侧工作区显示隐藏 - toggleLeft (e) { - this.leftDivState = e - } - - //左侧工作区关闭 - closeDiv(){ - this.leftDivState = false - this.showLeftDiv = false - } - - map:any //地图 - markers:any = []; //markers标注 - - //地图2D 3D切换 - mapPattern:boolean = true//默认是2D - mapPatternChange(type){ - this.unitCluster = null - this.waterCluster = null - this.checkRadio = false - if(type == '2D'){ - this.mapPattern = true - this.mapInit() - }else{ - this.unitCluster ? this.unitCluster.setData([]) : null - this.mapPattern = false - this.map = new AMap.Map('map',{ - viewMode: '3D', - pitch: 60, - rotation: -35, - features: ['bg', 'road', 'point','building'], - mapStyle: 'amap://styles/light', - }); - this.map.setCity('上海市'); - } - this.satelliteModel = false - this.loadModel = false - } - - //地图初始化 - mapInit () { - let that = this - var layer = new AMap.createDefaultLayer({ - zooms:[3,20], //可见级别 - visible:true, //是否可见 - opacity:1, //透明度 - zIndex:0, //叠加层级 - resizeEnable: true //是否监控地图容器尺寸变化, - }) - that.map = new AMap.Map('map',{ - layers:[layer], //当只想显示标准图层时layers属性可缺省, - }); - - that.map.setCity('上海市'); - AMap.plugin(["AMap.RangingTool", "AMap.MouseTool"],function () { - that.mouseTool=new AMap.MouseTool(that.map); - }); - - } - - searchText:string; //搜索单位名称 - allCompany = []; //搜索到 匹配的单位 - - measureDistance; //测距离 - distanceList = []; //测距离 点和线 - measureArea; //测面积 - mouseTool;//二合一测距和侧面积 - checkRadio=false //判断测距和侧面积是否选中 - - //测距离 开始 - startDistance(){ - this.measureArea.close(false) - this.measureDistance.turnOn() - } - - //侧面积 开始 - startArea(){ - this.measureDistance.turnOff() - this.measureArea.measureArea({ - strokeColor:'#80d8ff', - fillColor:'#80d8ff', - fillOpacity:0.3 - //同 Polygon 的 Option 设置 - }); - } - - //清空距离测量 - clearDistance(){ - this.distanceList.forEach(item=>{ - if (item.className == 'AMap.Marker') { - let parent = item.dom.parentNode - let children = item.dom.nextElementSibling - parent && children? parent.removeChild(item.dom.nextElementSibling) : null - this.map.remove(item) - } else { - this.map.remove(item) - } - }) - this.distanceList = [] //清空数组 - } - - //清空面积测量 - clearArea(){ - this.measureArea.close(true) - } - //合并测距和侧面积 - measure(type){ - switch(type){ - case 'rule':{ - this.mouseTool.rule({ - startMarkerOptions : {//可缺省 - icon: new AMap.Icon({ - size: new AMap.Size(19, 31),//图标大小 - imageSize:new AMap.Size(19, 31), - image: "https://webapi.amap.com/theme/v1.3/markers/b/start.png" - }) - }, - endMarkerOptions : {//可缺省 - icon: new AMap.Icon({ - size: new AMap.Size(19, 31),//图标大小 - imageSize:new AMap.Size(19, 31), - image: "https://webapi.amap.com/theme/v1.3/markers/b/end.png" - }), - offset: new AMap.Pixel(-9, -31) - }, - midMarkerOptions : {//可缺省 - icon: new AMap.Icon({ - size: new AMap.Size(19, 31),//图标大小 - imageSize:new AMap.Size(19, 31), - image: "https://webapi.amap.com/theme/v1.3/markers/b/mid.png" - }), - offset: new AMap.Pixel(-9, -31) - }, - lineOptions : {//可缺省 - strokeStyle: "solid", - strokeColor: "#FF33FF", - strokeOpacity: 1, - strokeWeight: 2 - } - //同 RangingTool 的 自定义 设置,缺省为默认样式 - }); - break; - } - case 'measureArea':{ - this.mouseTool.measureArea({ - strokeColor:'#80d8ff', - fillColor:'#80d8ff', - fillOpacity:0.3 + this.satelliteModel = false + this.loadModel = false + } + + //地图初始化 + mapInit() { + let that = this + var layer = new AMap.createDefaultLayer({ + zooms: [3, 20], //可见级别 + visible: true, //是否可见 + opacity: 1, //透明度 + zIndex: 0, //叠加层级 + resizeEnable: true //是否监控地图容器尺寸变化, + }) + // that.map = new AMap.Map('map', { + // layers: [layer], //当只想显示标准图层时layers属性可缺省, + // }); + that.map = MapFactory.MapInstance('map', { layers: [layer] }).self; + debugger; + that.map.setCity('上海市'); + AMap.plugin(["AMap.RangingTool", "AMap.MouseTool"], function () { + that.mouseTool = new AMap.MouseTool(that.map); + }); + + } + + searchText: string; //搜索单位名称 + allCompany = []; //搜索到 匹配的单位 + + measureDistance; //测距离 + distanceList = []; //测距离 点和线 + measureArea; //测面积 + mouseTool;//二合一测距和侧面积 + checkRadio = false //判断测距和侧面积是否选中 + + //测距离 开始 + startDistance() { + this.measureArea.close(false) + this.measureDistance.turnOn() + } + + //侧面积 开始 + startArea() { + this.measureDistance.turnOff() + this.measureArea.measureArea({ + strokeColor: '#80d8ff', + fillColor: '#80d8ff', + fillOpacity: 0.3 //同 Polygon 的 Option 设置 - }); - break; - } - } - } - //合并清空 - clearnAll(){ - this.mouseTool.close(true) - this.checkRadio=false - } - - //搜索 - search () { - this.allCompany = [] - let paramsdata:any = {Name: this.searchText || ''} - this.http.get("/api/Companies",{params:paramsdata}).subscribe((data:any)=>{ - this.allCompany = data.items - const config = new MatSnackBarConfig(); - config.verticalPosition = 'top'; - config.duration = 3000 - this.snackBar.open(`搜索目标结果为${data.items.length}个`,'确定',config); - }) - } - - //清除 - clear () { - this.allCompany = [] - this.searchText = '' - this.markers ? this.markers.forEach((element,index) => { this.map.remove(element);}) : null - this.infoWindow ? this.map.remove(this.infoWindow) : null - } - - selectedUnit:any//当前打开的单位 - - //选择 单位 地图跳转 - //弹窗实例 - infoWindow:any - selectCompany (e) { - if (e.location && e.location.x && e.location.y) { - this.selectedUnit = e - this.markers.forEach((element,index) => { this.map.remove(element);}); //先删除所有标点 - this.markers = [] - - let marker = new AMap.Marker({ - map: this.map, - position: [e.location.x,e.location.y], // 基点位置, - }); - this.markers.push(marker) - - let markerContent = `
+ }); + } + + //清空距离测量 + clearDistance() { + this.distanceList.forEach(item => { + if (item.className == 'AMap.Marker') { + let parent = item.dom.parentNode + let children = item.dom.nextElementSibling + parent && children ? parent.removeChild(item.dom.nextElementSibling) : null + this.map.remove(item) + } else { + this.map.remove(item) + } + }) + this.distanceList = [] //清空数组 + } + + //清空面积测量 + clearArea() { + this.measureArea.close(true) + } + //合并测距和侧面积 + measure(type) { + switch (type) { + case 'rule': { + this.mouseTool.rule({ + startMarkerOptions: {//可缺省 + icon: new AMap.Icon({ + size: new AMap.Size(19, 31),//图标大小 + imageSize: new AMap.Size(19, 31), + image: "https://webapi.amap.com/theme/v1.3/markers/b/start.png" + }) + }, + endMarkerOptions: {//可缺省 + icon: new AMap.Icon({ + size: new AMap.Size(19, 31),//图标大小 + imageSize: new AMap.Size(19, 31), + image: "https://webapi.amap.com/theme/v1.3/markers/b/end.png" + }), + offset: new AMap.Pixel(-9, -31) + }, + midMarkerOptions: {//可缺省 + icon: new AMap.Icon({ + size: new AMap.Size(19, 31),//图标大小 + imageSize: new AMap.Size(19, 31), + image: "https://webapi.amap.com/theme/v1.3/markers/b/mid.png" + }), + offset: new AMap.Pixel(-9, -31) + }, + lineOptions: {//可缺省 + strokeStyle: "solid", + strokeColor: "#FF33FF", + strokeOpacity: 1, + strokeWeight: 2 + } + //同 RangingTool 的 自定义 设置,缺省为默认样式 + }); + break; + } + case 'measureArea': { + this.mouseTool.measureArea({ + strokeColor: '#80d8ff', + fillColor: '#80d8ff', + fillOpacity: 0.3 + //同 Polygon 的 Option 设置 + }); + break; + } + } + } + //合并清空 + clearnAll() { + this.mouseTool.close(true) + this.checkRadio = false + } + + //搜索 + search() { + this.allCompany = [] + let paramsdata: any = { Name: this.searchText || '' } + this.http.get("/api/Companies", { params: paramsdata }).subscribe((data: any) => { + this.allCompany = data.items + const config = new MatSnackBarConfig(); + config.verticalPosition = 'top'; + config.duration = 3000 + this.snackBar.open(`搜索目标结果为${data.items.length}个`, '确定', config); + }) + } + + //清除 + clear() { + this.allCompany = [] + this.searchText = '' + this.markers ? this.markers.forEach((element, index) => { this.map.remove(element); }) : null + this.infoWindow ? this.map.remove(this.infoWindow) : null + } + + selectedUnit: any//当前打开的单位 + + //选择 单位 地图跳转 + //弹窗实例 + infoWindow: any + selectCompany(e) { + if (e.location && e.location.x && e.location.y) { + this.selectedUnit = e + this.markers.forEach((element, index) => { this.map.remove(element); }); //先删除所有标点 + this.markers = [] + + let marker = new AMap.Marker({ + map: this.map, + position: [e.location.x, e.location.y], // 基点位置, + }); + this.markers.push(marker) + + let markerContent = `
${e.name}
-
单位性质:
+
单位性质:
消防负责人:
@@ -1175,252 +1182,253 @@ export class GisLabelingComponent implements OnInit {
分享
` - // 创建一个自定义内容的 infowindow 实例 - this.infoWindow = new AMap.InfoWindow({ - position: [e.location.x,e.location.y], - offset: new AMap.Pixel(0, -30), - content: markerContent, - }); - this.infoWindow.open(this.map); - this.renderer2.listen(this.elementRef.nativeElement.querySelector('#baseInformation'),'click',(event)=>{ this.baseInformation(e) })//基本信息点击事件 - this.renderer2.listen(this.elementRef.nativeElement.querySelector('#route'),'click',(event)=>{ this.route(e) })//导航点击事件 - this.renderer2.listen(this.elementRef.nativeElement.querySelector('#fullViewNavigation'),'click',(event)=>{ this.fullViewNavigation(e) })//全景漫游点击事件 - this.renderer2.listen(this.elementRef.nativeElement.querySelector('#threeeScene'),'click',(event)=>{ this.threeeScene(e) })//三维场景点击事件 - this.renderer2.listen(this.elementRef.nativeElement.querySelector('#seePlan'),'click',(event)=>{ this.seePlan(e) })//查看预案点击事件 - this.renderer2.listen(this.elementRef.nativeElement.querySelector('#share'),'click',(event)=>{ this.share(e) })//分享点击事件 - marker.on('click', (ev) => { //marker点击事件 - this.infoWindow = new AMap.InfoWindow({ - position: [e.location.x,e.location.y], - offset: new AMap.Pixel(0, -30), - content: markerContent, + // 创建一个自定义内容的 infowindow 实例 + this.infoWindow = new AMap.InfoWindow({ + position: [e.location.x, e.location.y], + offset: new AMap.Pixel(0, -30), + content: markerContent, + }); + this.infoWindow.open(this.map); + this.renderer2.listen(this.elementRef.nativeElement.querySelector('#baseInformation'), 'click', (event) => { this.baseInformation(e) })//基本信息点击事件 + this.renderer2.listen(this.elementRef.nativeElement.querySelector('#route'), 'click', (event) => { this.route(e) })//导航点击事件 + this.renderer2.listen(this.elementRef.nativeElement.querySelector('#fullViewNavigation'), 'click', (event) => { this.fullViewNavigation(e) })//全景漫游点击事件 + this.renderer2.listen(this.elementRef.nativeElement.querySelector('#threeeScene'), 'click', (event) => { this.threeeScene(e) })//三维场景点击事件 + this.renderer2.listen(this.elementRef.nativeElement.querySelector('#seePlan'), 'click', (event) => { this.seePlan(e) })//查看预案点击事件 + this.renderer2.listen(this.elementRef.nativeElement.querySelector('#share'), 'click', (event) => { this.share(e) })//分享点击事件 + marker.on('click', (ev) => { //marker点击事件 + this.infoWindow = new AMap.InfoWindow({ + position: [e.location.x, e.location.y], + offset: new AMap.Pixel(0, -30), + content: markerContent, + }); + this.infoWindow.open(this.map); + this.renderer2.listen(this.elementRef.nativeElement.querySelector('#baseInformation'), 'click', (event) => { this.baseInformation(e) })//基本信息点击事件 + this.renderer2.listen(this.elementRef.nativeElement.querySelector('#route'), 'click', (event) => { this.route(e) })//导航点击事件 + this.renderer2.listen(this.elementRef.nativeElement.querySelector('#fullViewNavigation'), 'click', (event) => { this.fullViewNavigation(e) })//全景漫游点击事件 + this.renderer2.listen(this.elementRef.nativeElement.querySelector('#threeeScene'), 'click', (event) => { this.threeeScene(e) })//三维场景点击事件 + this.renderer2.listen(this.elementRef.nativeElement.querySelector('#seePlan'), 'click', (event) => { this.seePlan(e) })//查看预案点击事件 + this.renderer2.listen(this.elementRef.nativeElement.querySelector('#share'), 'click', (event) => { this.share(e) })//分享点击事件 + }) + this.map.setZoomAndCenter(13, [marker._position[0], marker._position[1] + 0.015]); //设置地图中心点 + this.allCompany = [] + } else { + const config = new MatSnackBarConfig(); + config.verticalPosition = 'top'; + config.duration = 3000 + this.snackBar.open('请完善单位地理位置', '确定', config); + } + } + + //基本信息 + baseInformation(e) { + this.leftDivState = true + this.showLeftDiv = true + this.appLeft.selectBaseInfo(e) //调用子组件方法 + } + + //导航 + route(e) { + this.leftDivState = false + this.showLeftDiv = false + this.isShowRouteGIS = true + this.routeEnd = e.name + this.endCoordinate = new AMap.LngLat(e.location.x, e.location.y) + } + + //全景漫游 + fullViewNavigation(e) { + console.log(e, '全景漫游') + } + + //三维场景 + threeeScene(e) { + window.open('http://39.106.78.171:8088/%E6%BC%94%E7%A4%BA%E6%A1%88%E4%BE%8B/--SHGJHYZX/') + } + + //查看预案 + seePlan(e) { + let data = e + let dialogRef = this.dialog.open(LookPlanDialog, {//调用open方法打开对话框并且携带参数过去 + width: '1400px', + height: '800px', + id: 'lookPlanDialog', + data }); - this.infoWindow.open(this.map); - this.renderer2.listen(this.elementRef.nativeElement.querySelector('#baseInformation'),'click',(event)=>{ this.baseInformation(e) })//基本信息点击事件 - this.renderer2.listen(this.elementRef.nativeElement.querySelector('#route'),'click',(event)=>{ this.route(e) })//导航点击事件 - this.renderer2.listen(this.elementRef.nativeElement.querySelector('#fullViewNavigation'),'click',(event)=>{ this.fullViewNavigation(e) })//全景漫游点击事件 - this.renderer2.listen(this.elementRef.nativeElement.querySelector('#threeeScene'),'click',(event)=>{ this.threeeScene(e) })//三维场景点击事件 - this.renderer2.listen(this.elementRef.nativeElement.querySelector('#seePlan'),'click',(event)=>{ this.seePlan(e) })//查看预案点击事件 - this.renderer2.listen(this.elementRef.nativeElement.querySelector('#share'),'click',(event)=>{ this.share(e) })//分享点击事件 - }) - this.map.setZoomAndCenter(13,[marker._position[0],marker._position[1]+0.015]); //设置地图中心点 - this.allCompany = [] - } else { - const config = new MatSnackBarConfig(); - config.verticalPosition = 'top'; - config.duration = 3000 - this.snackBar.open('请完善单位地理位置','确定',config); - } - } - - //基本信息 - baseInformation (e) { - this.leftDivState = true - this.showLeftDiv = true - this.appLeft.selectBaseInfo(e) //调用子组件方法 - } - - //导航 - route (e) { - this.leftDivState = false - this.showLeftDiv = false - this.isShowRouteGIS = true - this.routeEnd = e.name - this.endCoordinate = new AMap.LngLat(e.location.x, e.location.y) - } - - //全景漫游 - fullViewNavigation (e) { - console.log(e,'全景漫游') - } - - //三维场景 - threeeScene (e) { - window.open('http://39.106.78.171:8088/%E6%BC%94%E7%A4%BA%E6%A1%88%E4%BE%8B/--SHGJHYZX/') - } - - //查看预案 - seePlan (e) { - let data = e - let dialogRef = this.dialog.open(LookPlanDialog,{//调用open方法打开对话框并且携带参数过去 - width: '1400px', - height:'800px', - id:'lookPlanDialog', - data - }); - dialogRef.afterClosed().subscribe((data)=>{ - - }); - } - - //分享 - share (e) { - let data = { - url:'https://www.baidu.com/', - buildingType:e.buildingTypes[0].name, - address:e.address - } - let dialogRef = this.dialog.open(ShareUrlDialog,{//调用open方法打开对话框并且携带参数过去 - width: '540px', - height:'596px', - id:'shareDialog', - data}); - dialogRef.afterClosed().subscribe((data)=>{ - - }); - } - - //导航路线 - isShowRouteGIS:boolean = false; //导航路线 显隐 - routeStart:any; //起点 - routeStartList:any = [] //起点 搜索结果 - routeEnd:any; //终点 - routeEndList:any = [] //终点 搜索结果 - timeout:any; //延时器 - routeGIS:any; //查询结果 规划路线 - selectType:boolean = true; //路线选择 推荐方案/躲避用拥堵 - - //关闭导航路线 - closeRouteGIS () { - this.isShowRouteGIS = false - } - - //输入框 输入事件 - routeChange (e) { - let that = this - window.clearTimeout(this.timeout) - this.timeout = window.setTimeout(()=>{ - - that.map.getCity( function(info){ //获取当前 city - AMap.plugin(['AMap.AutoComplete'], () =>{ - var autoOptions = {city: info.city} - let keywords - e == 0 ? keywords = that.routeStart : keywords = that.routeEnd - var autoComplete = new AMap.Autocomplete(autoOptions); - autoComplete.search(keywords, function(status, result) { - if (result && result.tips && result.tips.length) { //搜索到数据时 - that._ngZone.run(()=>{ - if(e == 0){//起点 - that.routeStartList = result.tips - if(result.tips.length != 0){ - for (let index = 0; index < result.tips.length; index++) { - const element = result.tips[index]; - if(element.location){ - that.startCoordinate = new AMap.LngLat(element.location.lng, element.location.lat) - return - } - } - } - }else{//终点 - that.routeEndList = result.tips - that.endCoordinate = new AMap.LngLat(result.tips[0].location.lng, result.tips[0].location.lat) + dialogRef.afterClosed().subscribe((data) => { + + }); + } + + //分享 + share(e) { + let data = { + url: 'https://www.baidu.com/', + buildingType: e.buildingTypes[0].name, + address: e.address + } + let dialogRef = this.dialog.open(ShareUrlDialog, {//调用open方法打开对话框并且携带参数过去 + width: '540px', + height: '596px', + id: 'shareDialog', + data + }); + dialogRef.afterClosed().subscribe((data) => { + + }); + } + + //导航路线 + isShowRouteGIS: boolean = false; //导航路线 显隐 + routeStart: any; //起点 + routeStartList: any = [] //起点 搜索结果 + routeEnd: any; //终点 + routeEndList: any = [] //终点 搜索结果 + timeout: any; //延时器 + routeGIS: any; //查询结果 规划路线 + selectType: boolean = true; //路线选择 推荐方案/躲避用拥堵 + + //关闭导航路线 + closeRouteGIS() { + this.isShowRouteGIS = false + } + + //输入框 输入事件 + routeChange(e) { + let that = this + window.clearTimeout(this.timeout) + this.timeout = window.setTimeout(() => { + + that.map.getCity(function (info) { //获取当前 city + AMap.plugin(['AMap.AutoComplete'], () => { + var autoOptions = { city: info.city } + let keywords + e == 0 ? keywords = that.routeStart : keywords = that.routeEnd + var autoComplete = new AMap.Autocomplete(autoOptions); + autoComplete.search(keywords, function (status, result) { + if (result && result.tips && result.tips.length) { //搜索到数据时 + that._ngZone.run(() => { + if (e == 0) {//起点 + that.routeStartList = result.tips + if (result.tips.length != 0) { + for (let index = 0; index < result.tips.length; index++) { + const element = result.tips[index]; + if (element.location) { + that.startCoordinate = new AMap.LngLat(element.location.lng, element.location.lat) + return + } + } + } + } else {//终点 + that.routeEndList = result.tips + that.endCoordinate = new AMap.LngLat(result.tips[0].location.lng, result.tips[0].location.lat) + } + }); + + } //if + }) + }) + }); //获取当前 city + + }, 500) + } + + //清空导航输入框 + deleteSearchGIS(e) { + if (e == 0) { + this.routeStart = null + this.routeStartList = [] + this.startCoordinate = null + } else { + this.routeEnd = null + this.routeEndList = [] + this.endCoordinate = null + } + } + + //清除路线 + clearGISRoute() { + this.routeStart = null + this.routeStartList = [] + this.routeEnd = null + this.routeEndList = [] + this.startCoordinate = null + this.endCoordinate = null + this.routeGIS ? this.routeGIS.clear() : null + this.routes = { distance: 0, time: 0, steps: [], } + this.map.setZoomAndCenter(13, [this.selectedUnit.location.x, this.selectedUnit.location.y]); //设置地图中心点 + } + + //交换起始点 + exchangeGISRoute() { + let data = this.routeStart + this.routeStart = this.routeEnd + this.routeEnd = data + this.routeStartList = [] + this.routeEndList = [] + let data2 = this.startCoordinate + this.startCoordinate = this.endCoordinate + this.endCoordinate = data2 + } + + routes: any = { distance: 0, time: 0, steps: [], };//导航查询结果 路线规划 + + startCoordinate: any//开始坐标 + endCoordinate: any//结束坐标 + + //导航查询 + queryGISRoute() { + //构造路线导航类 + let that = this + this.selectType = true + this.routeGIS ? this.routeGIS.clear() : null + this.routeGIS = new AMap.Driving({ + map: this.map, + }); + if (!this.startCoordinate) { + let config = new MatSnackBarConfig(); + config.verticalPosition = 'top'; + config.duration = 3000 + this.snackBar.open('未查询到起点坐标信息,请输入有效地址', '确定', config); + return + } else if (!this.startCoordinate) { + let config = new MatSnackBarConfig(); + config.verticalPosition = 'top'; + config.duration = 3000 + this.snackBar.open('未查询到终点坐标信息,请输入有效地址', '确定', config); + return + } else { + this.routeGIS.search(this.startCoordinate, this.endCoordinate, + function (status, result) { + if (status === 'complete') { + that.routes = result.routes[0] + } else { alert('获取驾驶规划路线失败') } } - }); - - } //if - }) - }) - }); //获取当前 city - - },500) - } - - //清空导航输入框 - deleteSearchGIS (e) { - if (e==0) { - this.routeStart = null - this.routeStartList = [] - this.startCoordinate = null - } else { - this.routeEnd = null - this.routeEndList = [] - this.endCoordinate = null - } - } - - //清除路线 - clearGISRoute () { - this.routeStart = null - this.routeStartList = [] - this.routeEnd = null - this.routeEndList = [] - this.startCoordinate = null - this.endCoordinate = null - this.routeGIS? this.routeGIS.clear() : null - this.routes = { distance: 0, time: 0, steps: [], } - this.map.setZoomAndCenter(13,[this.selectedUnit.location.x,this.selectedUnit.location.y]); //设置地图中心点 - } - - //交换起始点 - exchangeGISRoute () { - let data = this.routeStart - this.routeStart = this.routeEnd - this.routeEnd = data - this.routeStartList = [] - this.routeEndList = [] - let data2 = this.startCoordinate - this.startCoordinate = this.endCoordinate - this.endCoordinate = data2 - } - - routes:any = { distance: 0, time: 0, steps: [], };//导航查询结果 路线规划 - - startCoordinate:any//开始坐标 - endCoordinate:any//结束坐标 - - //导航查询 - queryGISRoute () { - //构造路线导航类 - let that = this - this.selectType = true - this.routeGIS? this.routeGIS.clear() : null - this.routeGIS = new AMap.Driving({ - map: this.map, - }); - if(!this.startCoordinate){ - let config = new MatSnackBarConfig(); - config.verticalPosition = 'top'; - config.duration = 3000 - this.snackBar.open('未查询到起点坐标信息,请输入有效地址','确定',config); - return - }else if(!this.startCoordinate){ - let config = new MatSnackBarConfig(); - config.verticalPosition = 'top'; - config.duration = 3000 - this.snackBar.open('未查询到终点坐标信息,请输入有效地址','确定',config); - return - }else{ - this.routeGIS.search(this.startCoordinate,this.endCoordinate, - function(status, result) { - if (status === 'complete') { - that.routes = result.routes[0] - } else { alert('获取驾驶规划路线失败') } + ); } - ); - } - - } - - //切换 导航模式 推荐方案/躲避拥堵 - toggleRoute (e) { - let that = this - if (this.selectType != e) { - this.selectType = e - this.routeGIS? this.routeGIS.clear() : null - this.routeGIS = new AMap.Driving({ - map: this.map, - policy: e==true? AMap.DrivingPolicy.LEAST_TIME : AMap.DrivingPolicy.REAL_TRAFFIC - }); - // 根据起终点名称规划驾车导航路线 - - this.routeGIS.search(this.startCoordinate,this.endCoordinate, - function(status, result) { - if (status === 'complete') { - that.routes = result.routes[0] - } else { alert('获取驾驶规划路线失败') } + + } + + //切换 导航模式 推荐方案/躲避拥堵 + toggleRoute(e) { + let that = this + if (this.selectType != e) { + this.selectType = e + this.routeGIS ? this.routeGIS.clear() : null + this.routeGIS = new AMap.Driving({ + map: this.map, + policy: e == true ? AMap.DrivingPolicy.LEAST_TIME : AMap.DrivingPolicy.REAL_TRAFFIC + }); + // 根据起终点名称规划驾车导航路线 + + this.routeGIS.search(this.startCoordinate, this.endCoordinate, + function (status, result) { + if (status === 'complete') { + that.routes = result.routes[0] + } else { alert('获取驾驶规划路线失败') } + } + ); } - ); } - } @@ -1430,291 +1438,292 @@ export class GisLabelingComponent implements OnInit { //分享 @Component({ - selector: 'shareUrl-dialog', - templateUrl: './shareUrl.html', - styleUrls: ['./shareUrl.scss'] + selector: 'shareUrl-dialog', + templateUrl: './shareUrl.html', + styleUrls: ['./shareUrl.scss'] }) export class ShareUrlDialog { - constructor(public http: HttpClient,public snackBar: MatSnackBar, - public dialogRef: MatDialogRef, - @Inject(MAT_DIALOG_DATA) public data,private render2: Renderer2) {} - - selectetime:any = [{id:0,name:'今日有效'},{id:1,name:'本周有效'},{id:2,name:'本月有效'},{id:3,name:'仅一次有效'}] - selectedTimeIndex = 0 - ngOnInit() { - this.makeCode() - } - //生成二维码 - qrCode - makeCode () { - this.qrCode = new QRCode(document.getElementById("qrcode"),{ - text: this.data.url, - width: 200, - height: 200, - colorDark : "#000000", - colorLight : "#ffffff", - correctLevel : QRCode.CorrectLevel.H - }); - } - //下载二维码 - downloadFile () { - let canvas = this.qrCode._el.querySelector("canvas") - var base64Text = canvas.toDataURL("image/png"); - let url = base64Text //createObjectURL创建一个下载Blob的url地址 - let link = document.createElement("a"); - link.style.display = "none"; - link.href = url; - link.setAttribute("download", '二维码'); - document.body.appendChild(link); - link.click(); - } - //复制链接 - copyUrl(){ - var copyTest = this.data.url - var inputTest = document.createElement('input') - inputTest.value = copyTest - document.body.appendChild(inputTest) - inputTest.select() - document.execCommand('Copy') - inputTest.className = 'oInput' - inputTest.style.display = 'none' - const config = new MatSnackBarConfig(); - config.verticalPosition = 'top'; - config.duration = 3000 - this.snackBar.open('复制链接成功','确定',config); - } - selectedTime(index){ - if(this.selectedTimeIndex != index){ - this.selectedTimeIndex = index - this.qrCode.clear(); - if(index == 0){//如果今日有效 - console.log("今日") - } - if(index == 1){//如果本周有效 - console.log("本周") - this.qrCode.makeCode("http://www.w3cschool.cc") - } - if(index == 2){//如果本月有效 - console.log("本月") - } - if(index == 3){//如果仅一次有效 - console.log("一次") - } - } - } - //关闭 - closeDiv(){ - this.dialogRef.close() - } + constructor(public http: HttpClient, public snackBar: MatSnackBar, + public dialogRef: MatDialogRef, + @Inject(MAT_DIALOG_DATA) public data, private render2: Renderer2) { } + + selectetime: any = [{ id: 0, name: '今日有效' }, { id: 1, name: '本周有效' }, { id: 2, name: '本月有效' }, { id: 3, name: '仅一次有效' }] + selectedTimeIndex = 0 + ngOnInit() { + this.makeCode() + } + //生成二维码 + qrCode + makeCode() { + this.qrCode = new QRCode(document.getElementById("qrcode"), { + text: this.data.url, + width: 200, + height: 200, + colorDark: "#000000", + colorLight: "#ffffff", + correctLevel: QRCode.CorrectLevel.H + }); + } + //下载二维码 + downloadFile() { + let canvas = this.qrCode._el.querySelector("canvas") + var base64Text = canvas.toDataURL("image/png"); + let url = base64Text //createObjectURL创建一个下载Blob的url地址 + let link = document.createElement("a"); + link.style.display = "none"; + link.href = url; + link.setAttribute("download", '二维码'); + document.body.appendChild(link); + link.click(); + } + //复制链接 + copyUrl() { + var copyTest = this.data.url + var inputTest = document.createElement('input') + inputTest.value = copyTest + document.body.appendChild(inputTest) + inputTest.select() + document.execCommand('Copy') + inputTest.className = 'oInput' + inputTest.style.display = 'none' + const config = new MatSnackBarConfig(); + config.verticalPosition = 'top'; + config.duration = 3000 + this.snackBar.open('复制链接成功', '确定', config); + } + selectedTime(index) { + if (this.selectedTimeIndex != index) { + this.selectedTimeIndex = index + this.qrCode.clear(); + if (index == 0) {//如果今日有效 + console.log("今日") + } + if (index == 1) {//如果本周有效 + console.log("本周") + this.qrCode.makeCode("http://www.w3cschool.cc") + } + if (index == 2) {//如果本月有效 + console.log("本月") + } + if (index == 3) {//如果仅一次有效 + console.log("一次") + } + } + } + //关闭 + closeDiv() { + this.dialogRef.close() + } } //查看预案 @Component({ - selector: 'lookPlan-dialog', - templateUrl: './lookPlan.html', - styleUrls: ['./lookPlan.scss'] + selector: 'lookPlan-dialog', + templateUrl: './lookPlan.html', + styleUrls: ['./lookPlan.scss'] }) export class LookPlanDialog { - constructor(public http: HttpClient,public snackBar: MatSnackBar, - public dialogRef: MatDialogRef, - @Inject(MAT_DIALOG_DATA) public data,private render2: Renderer2,public dialog: MatDialog) {} - - - ngOnInit() { - // console.log(this.data) - this.getAllPlans() - } - //关闭弹窗 - closeDiv(){ - this.dialogRef.close() - } - //查看单位详情 - lookUnitDetails(){ - window.open(`/keyUnit/viewunitinfo?id=${this.data.id}`) - } - //获得所有预案组件 - allPlanComponents:any//所有预案组件 - getAllPlans(){ - let paramsData:any = { - companyId:this.data.id, - pageNumber: 1, - pageSize: "100", - sort: "" - } - this.http.get("/api/PlanComponents",{params:paramsData}).subscribe((data:any)=>{ - this.allPlanComponents = data.items - }) - } - //查看预案 - lookPlan(e){ - if(e.planMode == 0){ - const config = new MatSnackBarConfig(); - config.verticalPosition = 'top'; - config.duration = 3000 - this.snackBar.open('本地文件,请下载查看','确定',config); - } - if(e.planMode == 1){ - const config = new MatSnackBarConfig(); - config.verticalPosition = 'top'; - config.duration = 3000 - this.snackBar.open('查看导入word文件','确定',config); - } - if(e.planMode == 2){ //如果是在线编辑 - let id = e.id - sessionStorage.setItem("planId",id) - sessionStorage.setItem("companyId",this.data.id) - sessionStorage.setItem("buildingTypeId",this.data.buildingTypes[0].id) - sessionStorage.setItem("editable","0") - sessionStorage.setItem("planName",e.name) - let companyId = sessionStorage.getItem("companyId") - window.open(`/keyUnit/viewunitinfoplan?id=${companyId}`); - } - if(e.planMode == 3){ //如果是跳转网页 - sessionStorage.setItem("url",e.url) - window.open(`/planManagement/webLook`) - } - } - - //点击下载 - readFile(element){ - this.uploadFileLonging = element - let data =element - const dialogRef = this.dialog.open(DownloadFile, { - width:"435px", - data - }); - dialogRef.afterClosed().subscribe( - data=>{ - if(data){ - this.downloadFileName = data.fileName - this.download = data - this.downloadFile() + constructor(public http: HttpClient, public snackBar: MatSnackBar, + public dialogRef: MatDialogRef, + @Inject(MAT_DIALOG_DATA) public data, private render2: Renderer2, public dialog: MatDialog) { } + + + ngOnInit() { + // console.log(this.data) + this.getAllPlans() + } + //关闭弹窗 + closeDiv() { + this.dialogRef.close() + } + //查看单位详情 + lookUnitDetails() { + window.open(`/keyUnit/viewunitinfo?id=${this.data.id}`) + } + //获得所有预案组件 + allPlanComponents: any//所有预案组件 + getAllPlans() { + let paramsData: any = { + companyId: this.data.id, + pageNumber: 1, + pageSize: "100", + sort: "" } - } - ); - } - - //下载↓ - selectDownloadFile:any; //选择下载的文件 - download:any; //下载文件元数据 - downloadFileName:any //下载文件的文件名 - downloadisLoading:boolean = false; //进度条loading是否加载 - downloadProgress:number = 0; //进度条进度 - - uploadFileLonging:any - downloadFile(){ - this.downloadProgress = 0 - let file = this.download - let fileSize = file.fileLength//下载文件的总大小 - let shardSize = 10 * 1024 * 1024 //文件大小是否大于10MB - - if (file && fileSize<=shardSize) { //<=10MB时直接下载 - this.downloadisLoading = true - this.http.get(`/api/Objects/PlanPlatform/${file.objectName}`,{responseType: 'blob'},).subscribe(data=>{ - let url = window.URL.createObjectURL(new Blob([data])); //createObjectURL创建一个下载Blob的url地址 - let link = document.createElement("a"); - link.style.display = "none"; - link.href = url; - let suffix = file.objectName.substring(file.objectName.lastIndexOf(".")+1,file.objectName.length) ; - link.setAttribute("download", file.fileName ? file.fileName : this.data.name + "-" +this.uploadFileLonging.name + "." + suffix); - document.body.appendChild(link); - link.click(); - this.downloadisLoading = false - }) - } else if (file && fileSize > shardSize) { //>10MB时分块下载 - this.blockingDownload() //分段下载 - this.downloadisLoading = true - } - } - //分段下载并合并 - async blockingDownload () { - let file = this.download - let fileSize = file.fileLength //下载文件的总大小 - let shardSize = 3 * 1024 * 1024 //3MB一个分片 - let allSlice = Math.ceil(fileSize / shardSize) //总文件/3MB===共分多少段 - let allFile:any = [] //所有的file分段 - - for (let i=0;i{ - this.http.get(`/api/Objects/PlanPlatform/${file.objectName}`,{headers:{'range':`bytes= ${start}-${end}`},responseType:'blob'}).subscribe(data=>{ - result(data) }) - }) - allFile.push(result) - - - - if (allFile.length === allSlice) { //合并文件输出给浏览器 - let url = window.URL.createObjectURL(new Blob(allFile)); //createObjectURL创建一个下载Blob的url地址 - let link = document.createElement("a"); - link.style.display = "none"; - link.href = url; - let suffix = file.objectName.substring(file.objectName.lastIndexOf(".")+1,file.objectName.length) ; - link.setAttribute("download", file.fileName ? file.fileName : this.data.unitname + "-" +this.uploadFileLonging.name + "." + suffix); - document.body.appendChild(link); - link.click(); - this.downloadisLoading = false - } + this.http.get("/api/PlanComponents", { params: paramsData }).subscribe((data: any) => { + this.allPlanComponents = data.items + }) + } + //查看预案 + lookPlan(e) { + if (e.planMode == 0) { + const config = new MatSnackBarConfig(); + config.verticalPosition = 'top'; + config.duration = 3000 + this.snackBar.open('本地文件,请下载查看', '确定', config); + } + if (e.planMode == 1) { + const config = new MatSnackBarConfig(); + config.verticalPosition = 'top'; + config.duration = 3000 + this.snackBar.open('查看导入word文件', '确定', config); + } + if (e.planMode == 2) { //如果是在线编辑 + let id = e.id + sessionStorage.setItem("planId", id) + sessionStorage.setItem("companyId", this.data.id) + sessionStorage.setItem("buildingTypeId", this.data.buildingTypes[0].id) + sessionStorage.setItem("editable", "0") + sessionStorage.setItem("planName", e.name) + let companyId = sessionStorage.getItem("companyId") + window.open(`/keyUnit/viewunitinfoplan?id=${companyId}`); + } + if (e.planMode == 3) { //如果是跳转网页 + sessionStorage.setItem("url", e.url) + window.open(`/planManagement/webLook`) + } + } - } //for循环 + //点击下载 + readFile(element) { + this.uploadFileLonging = element + let data = element + const dialogRef = this.dialog.open(DownloadFile, { + width: "435px", + data + }); + dialogRef.afterClosed().subscribe( + data => { + if (data) { + this.downloadFileName = data.fileName + this.download = data + this.downloadFile() + } + } + ); + } - } + //下载↓ + selectDownloadFile: any; //选择下载的文件 + download: any; //下载文件元数据 + downloadFileName: any //下载文件的文件名 + downloadisLoading: boolean = false; //进度条loading是否加载 + downloadProgress: number = 0; //进度条进度 + + uploadFileLonging: any + downloadFile() { + this.downloadProgress = 0 + let file = this.download + let fileSize = file.fileLength//下载文件的总大小 + let shardSize = 10 * 1024 * 1024 //文件大小是否大于10MB + + if (file && fileSize <= shardSize) { //<=10MB时直接下载 + this.downloadisLoading = true + this.http.get(`/api/Objects/PlanPlatform/${file.objectName}`, { responseType: 'blob' },).subscribe(data => { + let url = window.URL.createObjectURL(new Blob([data])); //createObjectURL创建一个下载Blob的url地址 + let link = document.createElement("a"); + link.style.display = "none"; + link.href = url; + let suffix = file.objectName.substring(file.objectName.lastIndexOf(".") + 1, file.objectName.length); + link.setAttribute("download", file.fileName ? file.fileName : this.data.name + "-" + this.uploadFileLonging.name + "." + suffix); + document.body.appendChild(link); + link.click(); + this.downloadisLoading = false + }) + } else if (file && fileSize > shardSize) { //>10MB时分块下载 + this.blockingDownload() //分段下载 + this.downloadisLoading = true + } + } + //分段下载并合并 + async blockingDownload() { + let file = this.download + let fileSize = file.fileLength //下载文件的总大小 + let shardSize = 3 * 1024 * 1024 //3MB一个分片 + let allSlice = Math.ceil(fileSize / shardSize) //总文件/3MB===共分多少段 + let allFile: any = [] //所有的file分段 + + for (let i = 0; i < allSlice; i++) { + let start = i * shardSize //每次下载文件开始位置 + let end = Math.min(fileSize, start + shardSize - 1); //每次下载文件结束为止 + + let result = await new Promise((result, reject) => { + this.http.get(`/api/Objects/PlanPlatform/${file.objectName}`, { headers: { 'range': `bytes= ${start}-${end}` }, responseType: 'blob' }).subscribe(data => { + result(data) + }) + }) + allFile.push(result) + + + + if (allFile.length === allSlice) { //合并文件输出给浏览器 + let url = window.URL.createObjectURL(new Blob(allFile)); //createObjectURL创建一个下载Blob的url地址 + let link = document.createElement("a"); + link.style.display = "none"; + link.href = url; + let suffix = file.objectName.substring(file.objectName.lastIndexOf(".") + 1, file.objectName.length); + link.setAttribute("download", file.fileName ? file.fileName : this.data.unitname + "-" + this.uploadFileLonging.name + "." + suffix); + document.body.appendChild(link); + link.click(); + this.downloadisLoading = false + } + + } //for循环 + + } - //取消分块下载 - cancelDowload () { - } + //取消分块下载 + cancelDowload() { + } } //下载文件弹出框 @Component({ - selector: 'downloadfile', - templateUrl: './downloadFile.html', - styleUrls: ['./downloadFile.scss'] + selector: 'downloadfile', + templateUrl: './downloadFile.html', + styleUrls: ['./downloadFile.scss'] }) export class DownloadFile { - - constructor(private http: HttpClient,public dialogRef: MatDialogRef,@Inject(MAT_DIALOG_DATA) public data,public snackBar: MatSnackBar) {} - name:any //如果真实姓名为空时 - fileUrls:any //当前预案附件地址数组 - fileDatas:any = [] //用于循环的数组 - selectedFileIndex : any = 0 - selectedFileData : any - - ngOnInit(): void { - // console.log(this.data) - this.name = this.data.name - this.fileUrls = this.data.attachmentUrls - this.fileUrls.forEach(item=>{ - this.http.get('/api/ObjectMetadata/PlanPlatform/'+item).subscribe((data:any)=>{ - data.filePige = (data.fileLength / (1024*1024)).toFixed(2) - this.fileDatas.push(data) - this.selectedFileData = data - }) - }) - - } - - //取消 - onNoClick(): void { - this.dialogRef.close(); - } - //确定 - confirm(){ - this.dialogRef.close(this.selectedFileData); - } - - //点击想要下载的文件 - addurl(item,key){ - // console.log(item,key) - this.selectedFileIndex = key - this.selectedFileData = item - } + + constructor(private http: HttpClient, public dialogRef: MatDialogRef, @Inject(MAT_DIALOG_DATA) public data, public snackBar: MatSnackBar) { } + name: any //如果真实姓名为空时 + fileUrls: any //当前预案附件地址数组 + fileDatas: any = [] //用于循环的数组 + selectedFileIndex: any = 0 + selectedFileData: any + + ngOnInit(): void { + // console.log(this.data) + this.name = this.data.name + this.fileUrls = this.data.attachmentUrls + this.fileUrls.forEach(item => { + this.http.get('/api/ObjectMetadata/PlanPlatform/' + item).subscribe((data: any) => { + data.filePige = (data.fileLength / (1024 * 1024)).toFixed(2) + this.fileDatas.push(data) + this.selectedFileData = data + }) + }) + + } + + //取消 + onNoClick(): void { + this.dialogRef.close(); + } + //确定 + confirm() { + this.dialogRef.close(this.selectedFileData); + } + + //点击想要下载的文件 + addurl(item, key) { + // console.log(item,key) + this.selectedFileIndex = key + this.selectedFileData = item + } } \ No newline at end of file diff --git a/src/app/ui/collection-tools-plan/addPlaneFigure.html b/src/app/ui/collection-tools-plan/addPlaneFigure.html index 344170b..80cbac6 100644 --- a/src/app/ui/collection-tools-plan/addPlaneFigure.html +++ b/src/app/ui/collection-tools-plan/addPlaneFigure.html @@ -12,9 +12,9 @@
- +
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 b680cfc..78769db 100644 --- a/src/app/ui/collection-tools-plan/collection-tools.component.ts +++ b/src/app/ui/collection-tools-plan/collection-tools.component.ts @@ -17,2556 +17,2560 @@ import { TabbarAndScoreService } from 'src/app/http-interceptors/tabbar-and-scor import { MaskLayerService } from 'src/app/mask-layer.service'; import * as ObjectID from 'bson-objectid'; import { AxMessageSystem } from 'src/app/working-area/model/axMessageSystem'; +import { MapFactory } from 'src/modules/map/declare/factory'; +import { IMap } from 'src/modules/map/declare/map'; declare var AMap: any declare global { - interface Window { - deleteMarker: any; - } + interface Window { + deleteMarker: any; + } } @Component({ - selector: 'app-collection-tools-plan', - templateUrl: './collection-tools.component.html', - styleUrls: ['./collection-tools.component.scss'] + selector: 'app-collection-tools-plan', + templateUrl: './collection-tools.component.html', + styleUrls: ['./collection-tools.component.scss'] }) export class CollectionToolsPlanComponent implements OnInit { - @ViewChild('canvas') canvas: WorkingAreaComponent; //父组件中获得子组件的引用 - - constructor(public renderer2: Renderer2, 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) => {//要给渲染节点传那些属性参数 - return { - expandable: !!node.children && node.children.length > 0, - name: node.name || node.Name, - level: level, - id: node.id || node.Id, - children: node.children, - isTemplate: node.isTemplate, - isNewElement: node.isNewElement, - isLook: node.isLook, - isLookPattern: node.isLookPattern || null - }; - } - treeControl = new FlatTreeControl(node => node.level, node => node.expandable); - - treeFlattener = new MatTreeFlattener(this._transformer, node => node.level, node => node.expandable, node => node.children); - dataSource = new MatTreeFlatDataSource(this.treeControl, this.treeFlattener); - hasChild = (_: number, node: any) => node.expandable; - - colors = ['#076eec', '#4dd0e1', '#00ee76', '#ffff00', '#eeb422', - '#FF6A6A', '#ff0000', '#ff6eb4', '#00bfff', '#54ff9f', - '#009688', '#836fff', '#ff8c00', '#ee00ee', '#ffa07a', - '#00C500', '#00ffff', '#6495ed', '#ffdAb9', '#AA00FF'] - selected = "1" //图标大小选择框 - - allBuildings //该单位所有建筑 - beforeOneCheckedBuilding: any = { 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 = [] //属性中的图片链接集合 - clickedIndex //点击图片时的索引值 - - //传入素材对象,设置右侧属性栏内容 - canvasAssetObj //传入的素材属性对象 - isImgNumCss = false //控制上传文件input显隐 - mySwiper: any //轮播图实例 - - gallery//viewerJs实例 - //设置属性框 - setAssetsProperty(obj) { - console.log('传进来的属性信息', obj) - //初始化viewerJs实例 - setTimeout(() => { - obj.PropertyInfos.forEach(item => { - if (item.PropertyType == 4) { - if (document.getElementById('viewerjs')) { - this.gallery = new Viewer(document.getElementById('viewerjs'), { - url: 'data-original' - }); - } + @ViewChild('canvas') canvas: WorkingAreaComponent; //父组件中获得子组件的引用 + + constructor(public renderer2: Renderer2, 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) => {//要给渲染节点传那些属性参数 + return { + expandable: !!node.children && node.children.length > 0, + name: node.name || node.Name, + level: level, + id: node.id || node.Id, + children: node.children, + isTemplate: node.isTemplate, + isNewElement: node.isNewElement, + isLook: node.isLook, + isLookPattern: node.isLookPattern || null + }; + } + treeControl = new FlatTreeControl(node => node.level, node => node.expandable); + + treeFlattener = new MatTreeFlattener(this._transformer, node => node.level, node => node.expandable, node => node.children); + dataSource = new MatTreeFlatDataSource(this.treeControl, this.treeFlattener); + hasChild = (_: number, node: any) => node.expandable; + + colors = ['#076eec', '#4dd0e1', '#00ee76', '#ffff00', '#eeb422', + '#FF6A6A', '#ff0000', '#ff6eb4', '#00bfff', '#54ff9f', + '#009688', '#836fff', '#ff8c00', '#ee00ee', '#ffa07a', + '#00C500', '#00ffff', '#6495ed', '#ffdAb9', '#AA00FF'] + selected = "1" //图标大小选择框 + + allBuildings //该单位所有建筑 + beforeOneCheckedBuilding: any = { 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 = [] //属性中的图片链接集合 + clickedIndex //点击图片时的索引值 + + //传入素材对象,设置右侧属性栏内容 + canvasAssetObj //传入的素材属性对象 + isImgNumCss = false //控制上传文件input显隐 + mySwiper: any //轮播图实例 + + gallery//viewerJs实例 + //设置属性框 + setAssetsProperty(obj) { + console.log('传进来的属性信息', obj) + //初始化viewerJs实例 + setTimeout(() => { + obj.PropertyInfos.forEach(item => { + 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) + this.colorDivSliderValue = opacity + + this.isShowProperty = true + this.isShowAttribute = false + let _this = this + this.imagesArr = [] + this.imagesArrNum = "" + + this.canvasAssetObj = obj //将选中素材对象存到本地变量 + + this.assetName = obj.Name + this.assetWidth = obj.Width + this.assetHeight = obj.Height + this.sliderValue = obj.Angle + this.selectedcolor = obj.Color + this.PropertyInfos = obj.PropertyInfos + this.sliderValueThickness = obj.Thickness + this.PropertyInfos.forEach(item => { + if (item.PropertyType == 3) { //如果是图片链接类型 + this.imagesArr.push(item) + } + if (item.PropertyType == 4) {//图片数值上线 + this.imagesArrNum = item.PropertyValue + } + }) + + //如果存在图片则加载轮播图 + if (this.imagesArr.length) { + setTimeout(() => { + this.mySwiper = new Swiper('.swiper-container', { + loop: false, + // grabCursor: true, + // 如果需要前进后退按钮 + navigation: { + nextEl: '.swiper-button-next', + prevEl: '.swiper-button-prev', + }, + on: { + click: function () { + _this.clickedIndex = this.clickedIndex + }, + } + }); + }, 0); } - }) - }, 0); - - //从颜色中取出透明度 - let color = obj.Color - let strh = color.substring(color.length - 2, color.length) - let opacity = Math.round(parseInt(strh, 16) / 255 * 100) - this.colorDivSliderValue = opacity - - this.isShowProperty = true - this.isShowAttribute = false - let _this = this - this.imagesArr = [] - this.imagesArrNum = "" - - this.canvasAssetObj = obj //将选中素材对象存到本地变量 - - this.assetName = obj.Name - this.assetWidth = obj.Width - this.assetHeight = obj.Height - this.sliderValue = obj.Angle - this.selectedcolor = obj.Color - this.PropertyInfos = obj.PropertyInfos - this.sliderValueThickness = obj.Thickness - this.PropertyInfos.forEach(item => { - if (item.PropertyType == 3) { //如果是图片链接类型 - this.imagesArr.push(item) - } - if (item.PropertyType == 4) {//图片数值上线 - this.imagesArrNum = item.PropertyValue - } - }) - - //如果存在图片则加载轮播图 - if (this.imagesArr.length) { - setTimeout(() => { - this.mySwiper = new Swiper('.swiper-container', { - loop: false, - // grabCursor: true, - // 如果需要前进后退按钮 - navigation: { - nextEl: '.swiper-button-next', - prevEl: '.swiper-button-prev', - }, - on: { - click: function () { - _this.clickedIndex = this.clickedIndex - }, - } - }); - }, 0); - } - //判断此时图片数量是否达到上限 - if (this.imagesArr.length < this.imagesArrNum) {//如果不超出 - this.isImgNumCss = true - } else { - this.isImgNumCss = false - } - } - pattern: boolean = true//默认为基本信息编辑 - //适应缩放 - adaptZoom() { - this.canvas.zoomFit() - } - //重置缩放 - resetZoom() { - this.canvas.resetCamera2D() - } - - - //消防要素div边框高度调节 - firecategoriesDivMouseDown(e) { - document.onmousemove = (ev) => { - let bodyHeight = document.body.clientHeight //网页宽度 - let maxHeight = this.element.nativeElement.querySelector('#rightDiv').clientHeight - 35 //最大宽度 - if (bodyHeight - ev.clientY >= maxHeight) { - this.element.nativeElement.querySelector('#firecategories').style.height = maxHeight + 'px' - this.element.nativeElement.querySelector('#property').style.height = 35 + 'px' - } else { - this.element.nativeElement.querySelector('#firecategories').style.height = (bodyHeight - ev.clientY) + 'px'; - this.element.nativeElement.querySelector('#property').style.height = (this.element.nativeElement.querySelector('#rightDiv').clientHeight - this.element.nativeElement.querySelector('#firecategories').clientHeight) + 'px' - } - } - document.onmouseup = () => { - document.onmousemove = null; - document.onmouseup = null; - } - } - - //左侧div边框宽度调节 - leftDivMouseDown(e) { - document.onmousemove = (ev) => { - let bodyWidth = document.body.clientWidth //网页宽度 - let maxWidth = bodyWidth - 260 - this.element.nativeElement.querySelector('#rightDiv').clientWidth //最大宽度 - if (ev.clientX - 240 >= maxWidth) { - this.element.nativeElement.querySelector('#leftDiv').style.width = maxWidth + 'px' - } else { - this.element.nativeElement.querySelector('#leftDiv').style.width = ev.clientX - 260 + 'px'; - } - } - document.onmouseup = () => { - document.onmousemove = null; - document.onmouseup = null; - } - } - - - //右侧div边框宽度调节 - rightDivMouseDown(e) { - document.onmousemove = (ev) => { - let bodyWidth = document.body.clientWidth //网页宽度 - let maxWidth = bodyWidth - 240 - this.element.nativeElement.querySelector('#leftDiv').clientWidth //最大宽度 - if (bodyWidth - ev.clientX >= maxWidth) { - this.element.nativeElement.querySelector('#rightDiv').style.width = maxWidth + 'px' - } else { - this.element.nativeElement.querySelector('#rightDiv').style.width = bodyWidth - ev.clientX + 'px'; - } - } - document.onmouseup = () => { - document.onmousemove = null; - document.onmouseup = null; - } - } - - //放大图标 - iconScale() { - let number = Number(this.selected) - this.canvas.setIconScale(number) - } - - //素材宽度输入框改变 - assetWidthIunput() { - this.canvasAssetObj.Width = this.assetWidth - this.canvasData.isChange = true - if (!this.isGis) { - this.canvas.refreshIcon(this.canvasAssetObj.Id) - } - - } - - //素材高度输入框改变 - assetHeightIunput() { - this.canvasAssetObj.Height = this.assetHeight - this.canvasData.isChange = true - if (!this.isGis) { - this.canvas.refreshIcon(this.canvasAssetObj.Id) - } - } - - //素材角度输入框改变 - assetAngleIunput() { - this.canvasAssetObj.Angle = this.sliderValue - this.canvasData.isChange = true - if (!this.isGis) { - this.canvas.refreshIcon(this.canvasAssetObj.Id) - } - } - - //素材厚度输入框改变 - assetThicknessIunput() { - this.canvasAssetObj.Thickness = this.sliderValueThickness - this.canvasData.isChange = true - if (!this.isGis) { - this.canvas.refreshIcon(this.canvasAssetObj.Id) - } - } - - //素材是否高亮改变----->本地操作行为 - assetHighLightIunput() { - // console.log(this.isHighLight,this.canvasAssetObj) - // let arr = [] - // arr.push(this.canvasAssetObj.Id) - // this.canvas.setHighlight(arr) - } - - //判断是否是数字类型 - myIsNaN(value) { - return typeof value === 'number' && !isNaN(value); - } - //动态属性素材input框值改变 - assetInputChange(i, e) { - let index = this.canvasAssetObj.PropertyInfos.findIndex((item) => { - return i.PropertyName == item.PropertyName - }) - if (this.myIsNaN(e.target.value)) { - e.target.value = String(e.target.value) - } - this.canvasAssetObj.PropertyInfos[index].PropertyValue = e.target.value - this.canvasData.isChange = true - if (!this.isGis) { - this.canvas.refreshIcon(this.canvasAssetObj.Id) - } - } - - //动态属性素材布尔值框改变radio - assetRadioChange(i, boolean) { - let index = this.canvasAssetObj.PropertyInfos.findIndex((item) => { - return i.PropertyName == item.PropertyName - }) - this.canvasAssetObj.PropertyInfos[index].PropertyValue = boolean - this.canvasData.isChange = true - } - - colorIndex//默认素材颜色 - selectedcolor//点击选择的颜色 - //选择素材颜色 - selectcolor(item, key) { - //在当前透明度基础上改变颜色 - this.selectedcolor = item + this.selectedcolor.substring(this.selectedcolor.length - 2) - this.canvasAssetObj.Color = this.selectedcolor - this.canvasData.isChange = true - if (!this.isGis) { - this.canvas.refreshIcon(this.canvasAssetObj.Id) - } - } - //颜色选择滑竿的值 - colorDivSliderValue - colorDivSliderChange() { - let colorOpacity = Math.round(255 * this.colorDivSliderValue * 0.01) - //根据滑竿值改变16进制颜色后两位 - function replacepos(text, start, stop, replacetext) { - let mystr = text.substring(0, stop - 1) + replacetext + text.substring(stop + 1); - return mystr; - } - this.selectedcolor = replacepos(this.selectedcolor, 7, 8, colorOpacity.toString(16)) - this.canvasAssetObj.Color = this.selectedcolor - this.canvasData.isChange = true - if (!this.isGis) { - this.canvas.refreshIcon(this.canvasAssetObj.Id) - } - } - - //上传素材图片 - selectFile(e) { - let imgFile = e.target.files[0] || null //上传的文件 - this.startUploading(imgFile) - } - objectName: any //上传对象名 - startUploading(imgFile) { - let _this = this - let file = imgFile || null //获取上传的文件 - let fileSize = file.size || null //上传文件的总大小 - let shardSize = 5 * 1024 * 1024 //5MB一个分片 - let companyId = sessionStorage.getItem("companyId") - if (file && fileSize <= shardSize) { //上传文件<=5MB时 - let formData = new FormData() - formData.append("file", file) - this.http.post(`api/Objects/WebPlan2D/${companyId}`, formData).subscribe((data: any) => { - this.objectName = data.objectName + //判断此时图片数量是否达到上限 + if (this.imagesArr.length < this.imagesArrNum) {//如果不超出 + this.isImgNumCss = true + } else { + this.isImgNumCss = false + } + } + pattern: boolean = true//默认为基本信息编辑 + //适应缩放 + adaptZoom() { + this.canvas.zoomFit() + } + //重置缩放 + resetZoom() { + this.canvas.resetCamera2D() + } + + + //消防要素div边框高度调节 + firecategoriesDivMouseDown(e) { + document.onmousemove = (ev) => { + let bodyHeight = document.body.clientHeight //网页宽度 + let maxHeight = this.element.nativeElement.querySelector('#rightDiv').clientHeight - 35 //最大宽度 + if (bodyHeight - ev.clientY >= maxHeight) { + this.element.nativeElement.querySelector('#firecategories').style.height = maxHeight + 'px' + this.element.nativeElement.querySelector('#property').style.height = 35 + 'px' + } else { + this.element.nativeElement.querySelector('#firecategories').style.height = (bodyHeight - ev.clientY) + 'px'; + this.element.nativeElement.querySelector('#property').style.height = (this.element.nativeElement.querySelector('#rightDiv').clientHeight - this.element.nativeElement.querySelector('#firecategories').clientHeight) + 'px' + } + } + document.onmouseup = () => { + document.onmousemove = null; + document.onmouseup = null; + } + } + + //左侧div边框宽度调节 + leftDivMouseDown(e) { + document.onmousemove = (ev) => { + let bodyWidth = document.body.clientWidth //网页宽度 + let maxWidth = bodyWidth - 260 - this.element.nativeElement.querySelector('#rightDiv').clientWidth //最大宽度 + if (ev.clientX - 240 >= maxWidth) { + this.element.nativeElement.querySelector('#leftDiv').style.width = maxWidth + 'px' + } else { + this.element.nativeElement.querySelector('#leftDiv').style.width = ev.clientX - 260 + 'px'; + } + } + document.onmouseup = () => { + document.onmousemove = null; + document.onmouseup = null; + } + } + + + //右侧div边框宽度调节 + rightDivMouseDown(e) { + document.onmousemove = (ev) => { + let bodyWidth = document.body.clientWidth //网页宽度 + let maxWidth = bodyWidth - 240 - this.element.nativeElement.querySelector('#leftDiv').clientWidth //最大宽度 + if (bodyWidth - ev.clientX >= maxWidth) { + this.element.nativeElement.querySelector('#rightDiv').style.width = maxWidth + 'px' + } else { + this.element.nativeElement.querySelector('#rightDiv').style.width = bodyWidth - ev.clientX + 'px'; + } + } + document.onmouseup = () => { + document.onmousemove = null; + document.onmouseup = null; + } + } + + //放大图标 + iconScale() { + let number = Number(this.selected) + this.canvas.setIconScale(number) + } + + //素材宽度输入框改变 + assetWidthIunput() { + this.canvasAssetObj.Width = this.assetWidth + this.canvasData.isChange = true + if (!this.isGis) { + this.canvas.refreshIcon(this.canvasAssetObj.Id) + } + + } + + //素材高度输入框改变 + assetHeightIunput() { + this.canvasAssetObj.Height = this.assetHeight + this.canvasData.isChange = true + if (!this.isGis) { + this.canvas.refreshIcon(this.canvasAssetObj.Id) + } + } + + //素材角度输入框改变 + assetAngleIunput() { + this.canvasAssetObj.Angle = this.sliderValue + this.canvasData.isChange = true + if (!this.isGis) { + this.canvas.refreshIcon(this.canvasAssetObj.Id) + } + } + + //素材厚度输入框改变 + assetThicknessIunput() { + this.canvasAssetObj.Thickness = this.sliderValueThickness + this.canvasData.isChange = true + if (!this.isGis) { + this.canvas.refreshIcon(this.canvasAssetObj.Id) + } + } + + //素材是否高亮改变----->本地操作行为 + assetHighLightIunput() { + // console.log(this.isHighLight,this.canvasAssetObj) + // let arr = [] + // arr.push(this.canvasAssetObj.Id) + // this.canvas.setHighlight(arr) + } + + //判断是否是数字类型 + myIsNaN(value) { + return typeof value === 'number' && !isNaN(value); + } + //动态属性素材input框值改变 + assetInputChange(i, e) { + let index = this.canvasAssetObj.PropertyInfos.findIndex((item) => { + return i.PropertyName == item.PropertyName + }) + if (this.myIsNaN(e.target.value)) { + e.target.value = String(e.target.value) + } + this.canvasAssetObj.PropertyInfos[index].PropertyValue = e.target.value + this.canvasData.isChange = true + if (!this.isGis) { + this.canvas.refreshIcon(this.canvasAssetObj.Id) + } + } + + //动态属性素材布尔值框改变radio + assetRadioChange(i, boolean) { + let index = this.canvasAssetObj.PropertyInfos.findIndex((item) => { + return i.PropertyName == item.PropertyName + }) + this.canvasAssetObj.PropertyInfos[index].PropertyValue = boolean + this.canvasData.isChange = true + } + + colorIndex//默认素材颜色 + selectedcolor//点击选择的颜色 + //选择素材颜色 + selectcolor(item, key) { + //在当前透明度基础上改变颜色 + this.selectedcolor = item + this.selectedcolor.substring(this.selectedcolor.length - 2) + this.canvasAssetObj.Color = this.selectedcolor + this.canvasData.isChange = true + if (!this.isGis) { + this.canvas.refreshIcon(this.canvasAssetObj.Id) + } + } + //颜色选择滑竿的值 + colorDivSliderValue + colorDivSliderChange() { + let colorOpacity = Math.round(255 * this.colorDivSliderValue * 0.01) + //根据滑竿值改变16进制颜色后两位 + function replacepos(text, start, stop, replacetext) { + let mystr = text.substring(0, stop - 1) + replacetext + text.substring(stop + 1); + return mystr; + } + this.selectedcolor = replacepos(this.selectedcolor, 7, 8, colorOpacity.toString(16)) + this.canvasAssetObj.Color = this.selectedcolor + this.canvasData.isChange = true + if (!this.isGis) { + this.canvas.refreshIcon(this.canvasAssetObj.Id) + } + } + + //上传素材图片 + selectFile(e) { + let imgFile = e.target.files[0] || null //上传的文件 + this.startUploading(imgFile) + } + objectName: any //上传对象名 + startUploading(imgFile) { + let _this = this + let file = imgFile || null //获取上传的文件 + let fileSize = file.size || null //上传文件的总大小 + let shardSize = 5 * 1024 * 1024 //5MB一个分片 + let companyId = sessionStorage.getItem("companyId") + if (file && fileSize <= shardSize) { //上传文件<=5MB时 + let formData = new FormData() + formData.append("file", file) + this.http.post(`api/Objects/WebPlan2D/${companyId}`, formData).subscribe((data: any) => { + this.objectName = data.objectName + const config = new MatSnackBarConfig(); + config.verticalPosition = 'top'; + config.duration = 3000 + this.snackBar.open('上传成功', '确定', config) + + //在原始素材对象和需要循环图片的对象中分别push最新上传的图片 + let imgObj = { + "Tag": null, + "Order": 0, + "Enabled": false, + "Visible": false, + "Required": false, + "RuleName": null, + "RuleValue": null, + "PhysicalUnit": null, + "PropertyName": "图片", + "PropertyType": 3, + "PropertyValue": "/api/Objects/WebPlan2D/" + this.objectName + } + + this.imagesArr.push(imgObj) + this.canvasAssetObj.PropertyInfos.push(imgObj) + + setTimeout(() => { + this.mySwiper = new Swiper('.swiper-container', { + loop: false, + // grabCursor: true, + // 如果需要前进后退按钮 + navigation: { + nextEl: '.swiper-button-next', + prevEl: '.swiper-button-prev', + }, + on: { + click: function () { + _this.clickedIndex = this.clickedIndex + }, + } + }); + + this.mySwiper.slideTo(this.imagesArr.length - 1) + this.gallery.update() + }, 0); + + //判断上传素材属性图片是否超出数量 超出数量则隐藏input框 + if (this.imagesArr.length < this.imagesArrNum) {//不超出input才会显示 + this.isImgNumCss = true + } else { + this.isImgNumCss = false + } + + this.canvasData.isChange = true + }) + } else if (file && fileSize > shardSize) { //上传文件>5MB时,分块上传 + let config = new MatSnackBarConfig(); + config.verticalPosition = 'top'; + config.duration = 3000 + this.snackBar.open('上传图片文件不允许大于5mb', '确定', config); + } + + } + + //不能上传图片提示 + imgNumBeyond() { const config = new MatSnackBarConfig(); config.verticalPosition = 'top'; config.duration = 3000 - this.snackBar.open('上传成功', '确定', config) - - //在原始素材对象和需要循环图片的对象中分别push最新上传的图片 - let imgObj = { - "Tag": null, - "Order": 0, - "Enabled": false, - "Visible": false, - "Required": false, - "RuleName": null, - "RuleValue": null, - "PhysicalUnit": null, - "PropertyName": "图片", - "PropertyType": 3, - "PropertyValue": "/api/Objects/WebPlan2D/" + this.objectName + this.snackBar.open('图片数量已达上限', '确定', config); + } + + //删除素材属性图片 + deleteImg() { + if (this.imagesArr.length == 0) { + const config = new MatSnackBarConfig(); + config.verticalPosition = 'top'; + config.duration = 3000 + this.snackBar.open('没有可删除的图片,请先上传', '确定', config) + } else { + // 在素材原始对象中将删除的图片去掉 + this.canvasAssetObj.PropertyInfos = [...this.canvasAssetObj.PropertyInfos.filter((item) => { + return item.PropertyValue != this.imagesArr[this.mySwiper.activeIndex].PropertyValue + })] + //在图片循环数组中将图片去掉 + this.imagesArr.splice(this.mySwiper.activeIndex, 1); + //更新swiper视图 + setTimeout(() => { + this.mySwiper.update(); + this.gallery.update() + }, 0); + + //将上传的input框显示出来 + this.isImgNumCss = true; + //清除图片缓存 + if ((document.getElementById('inputimg'))) { + (document.getElementById('inputimg')).value = null //清空input框缓存 + } + + this.canvasData.isChange = true } + } - this.imagesArr.push(imgObj) - this.canvasAssetObj.PropertyInfos.push(imgObj) + //动态属性方向select选择框 + direction(i, e) { + let index = this.canvasAssetObj.PropertyInfos.findIndex((item) => { + return i.PropertyName == item.PropertyName + }) + this.canvasAssetObj.PropertyInfos[index].PropertyValue = e.target.value + this.canvasData.isChange = true + } - setTimeout(() => { - this.mySwiper = new Swiper('.swiper-container', { - loop: false, - // grabCursor: true, - // 如果需要前进后退按钮 - navigation: { - nextEl: '.swiper-button-next', - prevEl: '.swiper-button-prev', - }, - on: { - click: function () { - _this.clickedIndex = this.clickedIndex - }, + //动态属性供给区域select选择框 + supplyArea(i, e) { + let index = this.canvasAssetObj.PropertyInfos.findIndex((item) => { + return i.PropertyName == item.PropertyName + }) + this.canvasAssetObj.PropertyInfos[index].PropertyValue = e.target.value + this.canvasData.isChange = true + } + + //动态属性供给类型select选择框 + supplyType(i, e) { + let index = this.canvasAssetObj.PropertyInfos.findIndex((item) => { + return i.PropertyName == item.PropertyName + }) + this.canvasAssetObj.PropertyInfos[index].PropertyValue = e.target.value + this.canvasData.isChange = true + } + + isediticon = true //控制查看编辑模式的编辑模式小笔按钮 + + isMultipleAsset: boolean = false//框选多个素材属性显隐 + multipleAsset: any = { + Width: null, + Height: null, + Angle: null, + Thickness: null, + Color: null, + PropertyInfos: [] + }//多个素材共同属性 + multipleAssetData: any//当前多选的素材 + firstMultipleAssetData: any//当前多选的第一个素材 + ngOnInit(): void { + + let _this = this + 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()) { + 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: [] + } + 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) { + this.multipleAsset.InteractiveMode = InteractiveMode + } + let isFillMode = this.canvas.selection.all().every(item => item.assetData.FillMode === 0) //素材填充方式都为0 + 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) { + index++ + 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) { + this.isShowProperty = false } - }); + }, this) + AxMessageSystem.addListener('imageResize', (eventName, args1) => { + this.assetWidth = args1.Width + this.assetHeight = args1.Height + }, this) + 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) { //编辑模式 + this.canvasData.gameMode = GameMode.BasicInformation + } - this.mySwiper.slideTo(this.imagesArr.length - 1) - this.gallery.update() + //gis模块平面图 + 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 + } else { + this.getAllLibrary() //获取素材库 + } + + let that = this + window.setTimeout(() => { + document.getElementById("functionalDomainContent").oncontextmenu = function (event) { + // that.canvas.cancelPaint() + that.selectImageIndex = -1 + event.preventDefault(); + }; + }) + + this.canvasData.getMessage().subscribe((message: any) => { + if (message == "send a message") { + // this.refurbishTreeData() + } + }) + + //点击marker关闭按钮 + window.deleteMarker = () => { + this.canvasData.isChange = true + //清除地图标点 + this.planDataMarkers.forEach((element, index) => { + if (element.id == this.clickId) { + this.planDataMarkers[index].setMap(null); + } + }); + + // 删除楼层数据 + delete this.canvasData.originaleveryStoreyData.data[this.clickId]; + // 删除建筑数据 + delete this.canvasData.originalcompanyBuildingData.data[this.clickId]; + + console.log('originalcompanyBuildingData', this.canvasData.originalcompanyBuildingData) + console.log('originaleveryStoreyData', this.canvasData.originaleveryStoreyData) + + } + } + //多选宽度共同改变 + 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 => { + item.assetData.Height = this.multipleAsset.Height + this.canvas.refreshIcon(item.assetData.Id) + this.canvasData.isChange = true + }) + } + //多选角度共同改变 + 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 => { + item.assetData.Thickness = this.multipleAsset.Thickness + this.canvas.refreshIcon(item.assetData.Id) + this.canvasData.isChange = true + }) + } + //多选颜色共同改变 + multipleSelectedcolor: any + multipleAssetSelectcolor(item, key) { + //在当前透明度基础上改变颜色 + this.multipleSelectedcolor = 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) + //根据滑竿值改变16进制颜色后两位 + 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)) + item.assetData.Color = this.multipleSelectedcolor + this.canvasData.isChange = true + this.canvas.refreshIcon(item.assetData.Id) + }) + } + //多选状态动态属性素材input框值改变 + multipleAssetInputChange(i, e) { + e.stopPropagation() + setTimeout(() => { + this.multipleAssetData.forEach(item => { + item.assetData.PropertyInfos.forEach(element => { + if (element.PropertyName == i.PropertyName) { + if (this.myIsNaN(i.PropertyValue)) { + i.PropertyValue = String(i.PropertyValue) + } + element.PropertyValue = i.PropertyValue + this.canvas.refreshIcon(item.assetData.Id) + this.canvasData.isChange = true + } + }) + }) }, 0); + } + //多选状态动态属性素材radio框值改变 + multipleAssetRadioChange(i, value) { + // e.stopPropagation() + this.multipleAssetData.forEach(item => { + // console.log(item) + item.assetData.PropertyInfos.forEach(element => { + if (element.PropertyName == i.PropertyName) { + element.PropertyValue = value + this.canvas.refreshIcon(item.assetData.Id) + this.canvasData.isChange = true + } + }) + }) + } + //多选状态动态属性素材下拉框值改变 + multipleSupplyArea(i, e) { + e.stopPropagation() + this.multipleAssetData.forEach(item => { + item.assetData.PropertyInfos.forEach(element => { + if (element.PropertyName == i.PropertyName) { + element.PropertyValue = i.PropertyValue + this.canvas.refreshIcon(item.assetData.Id) + this.canvasData.isChange = true + } + }) + }) + } + + ngAfterViewInit(): void { + //不是gis模块平面图 + if (this.router.url.indexOf("gis") == -1) { + this.getSitePlan() + } + } + + copyAssetData: any //存储用于复制的素材 + //复制素材 + copyAsset() { + this.canvas.copy() + } + //粘贴素材 + pasteAsset() { + let companyId = sessionStorage.getItem("companyId") + let buildingId = this.beforeOneCheckedBuilding.id + let floorId = this.selectingSitePlan.id + this.canvas.paste(companyId, buildingId, floorId) + // this.renovateTreeData(false) + } + //截图 + 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) } + + basicInfo: boolean = true //基本信息名称显隐 + wantToWork: boolean = true //想定作业名称显隐 + //点击基本信息名称 + basicInfoClick() { + this.basicInfo = !this.basicInfo + this.canvas.setNameVisible(this.basicInfo, 0) + } + + //点击想定作业名称 + wantToWorkClick() { + this.wantToWork = !this.wantToWork + this.canvas.setNameVisible(this.wantToWork, 1) + } + + isEditPattern: boolean = true //是否为编辑模式 + //进入编辑模式 + editpat() { + let config = new MatSnackBarConfig(); + config.verticalPosition = 'top'; + config.duration = 3000 + this.snackBar.open('进入编辑模式', '确定', config); + this.isEditPattern = true + } + + //进入查看模式 + lookpat() { + let config = new MatSnackBarConfig(); + config.verticalPosition = 'top'; + config.duration = 3000 + this.snackBar.open('进入查看模式', '确定', config); + this.isEditPattern = false + } - //判断上传素材属性图片是否超出数量 超出数量则隐藏input框 - if (this.imagesArr.length < this.imagesArrNum) {//不超出input才会显示 - this.isImgNumCss = true + //保存平面图 + saveNum: any = [] + saveSite() { + //更新用于统计的数据 + this.canvasData.updateBuildingData() + + if (this.selectingSitePlan && this.selectingSitePlan.id) { + //打开遮罩层 + this.maskLayerService.sendMessage(true) + this.saveNum = [] + let SitePlanData = JSON.parse(JSON.stringify(this.canvasData.originaleveryStoreyData)); + SitePlanData.data = JSON.stringify(SitePlanData.data) + let CompanyData = JSON.parse(JSON.stringify(this.canvasData.originalcompanyBuildingData)); + CompanyData.data = JSON.stringify(CompanyData.data) + + let object = this.canvasData.originalcompanyBuildingData.data + let adjoinArr = [] //毗邻数组 + + if (this.pattern) {//如果是基本信息编辑模式 + for (const key in object) { + if (object[key].Name == "毗邻") {//如果是相同楼层,则筛选出毗邻 + + object[key].PropertyInfos.forEach(element => { + if (element.PropertyName == "方向") { + adjoinArr.push(element.PropertyValue) + } + }); + } + } + if ((new Set(adjoinArr)).size != adjoinArr.length) { + this.maskLayerService.sendMessage(false) + let config = new MatSnackBarConfig(); + config.verticalPosition = 'top'; + config.duration = 3000 + this.snackBar.open('保存失败,毗邻存在相同方向', '确定', config); + return false + } else { + //如果是单位 总平面图 + if (this.checkedBuildingIndex == -1) { + + if (this.isGis) { + let data = JSON.parse(JSON.stringify(this.selectingSitePlan)) + data.zoomLevel = this.map.getZoom(), + data.defaultCenter = { x: this.map.getCenter().lng, y: this.map.getCenter().lat } + delete data.userId + delete data.userName + delete data.sitePlanDataInfo + this.http.put(`/api/SitePlans/${this.selectingSitePlan.id}`, data).subscribe(data => { + this.sitePlanData.forEach(element => { + if (element.id == this.selectingSitePlan.id) { + element.zoomLevel = this.map.getZoom() + element.defaultCenter = { x: this.map.getCenter().lng, y: this.map.getCenter().lat } + } + }); + }, err => { + let config = new MatSnackBarConfig(); + config.verticalPosition = 'top'; + config.duration = 3000 + this.snackBar.open('gis保存当前视角失败', '确定', config); + }) + } + + //保存平面图数据 + this.http.post("/api/SitePlanData", SitePlanData, { + params: { + companyId: this.params.companyId + } + }).subscribe(data => { + this.saveNum.push("1") + if (this.saveNum.length == 5) { + this.maskLayerService.sendMessage(false) + this.canvasData.isChange = false + let config = new MatSnackBarConfig(); + config.verticalPosition = 'top'; + config.duration = 3000 + this.snackBar.open('保存成功', '确定', config); + this.tabbarService.sendMessage('changeScore'); + } + }, err => { + this.maskLayerService.sendMessage(false) + let config = new MatSnackBarConfig(); + config.verticalPosition = 'top'; + config.duration = 3000 + this.canvasData.isChange = true + this.snackBar.open('平面图数据保存失败', '确定', config); + }) + + //保存建筑数据 + this.http.post("/api/CompanyData", CompanyData, { + params: { + companyId: this.params.companyId + } + }).subscribe(data => { + this.saveNum.push("1") + if (this.saveNum.length == 5) { + this.maskLayerService.sendMessage(false) + this.canvasData.isChange = false + let config = new MatSnackBarConfig(); + config.verticalPosition = 'top'; + config.duration = 3000 + this.snackBar.open('保存成功', '确定', config); + this.tabbarService.sendMessage('changeScore'); + } + }, err => { + this.maskLayerService.sendMessage(false) + let config = new MatSnackBarConfig(); + config.verticalPosition = 'top'; + config.duration = 3000 + this.canvasData.isChange = true + this.snackBar.open('单位数据保存失败', '确定', config); + }) + + //批量保存单位毗邻 + let CompanyAdjoins = this.canvasData.getCompanyAdjoinInfo() + this.http.post("/api/CompanyAdjoins/Batch", CompanyAdjoins, { + params: { + companyId: this.params.companyId + } + }).subscribe(data => { + this.saveNum.push("1") + if (this.saveNum.length == 5) { + this.maskLayerService.sendMessage(false) + this.canvasData.isChange = false + let config = new MatSnackBarConfig(); + config.verticalPosition = 'top'; + config.duration = 3000 + this.snackBar.open('保存成功', '确定', config); + this.tabbarService.sendMessage('changeScore'); + } + }, err => { + this.maskLayerService.sendMessage(false) + let config = new MatSnackBarConfig(); + config.verticalPosition = 'top'; + config.duration = 3000 + this.canvasData.isChange = true + if (err == 'infos 有重复方向!') { + this.snackBar.open('单位毗邻同步失败,存在相同方向', '确定', config); + } else { + this.snackBar.open('单位毗邻同步失败', '确定', config); + } + }) + + //批量保存单位重点部位 + let CompanyImportantLocations = this.canvasData.getCompanyImportantLocations() + this.http.post("/api/CompanyImportantLocations/Batch", CompanyImportantLocations, { + params: { + companyId: this.params.companyId + } + }).subscribe(data => { + this.saveNum.push("1") + if (this.saveNum.length == 5) { + this.maskLayerService.sendMessage(false) + this.canvasData.isChange = false + let config = new MatSnackBarConfig(); + config.verticalPosition = 'top'; + config.duration = 3000 + this.snackBar.open('保存成功', '确定', config); + this.tabbarService.sendMessage('changeScore'); + } + }, err => { + this.maskLayerService.sendMessage(false) + let config = new MatSnackBarConfig(); + config.verticalPosition = 'top'; + config.duration = 3000 + this.canvasData.isChange = true + this.snackBar.open('单位重点部位同步失败', '确定', config); + }) + + //批量保存单位消防设施素材 + let CompanyFacilityAssets = this.canvasData.getAllCompanyFacilityAssetInfo() + this.http.post("/api/CompanyFacilityAssets/Batch", CompanyFacilityAssets, { + params: { + companyId: this.params.companyId + } + }).subscribe(data => { + this.saveNum.push("1") + if (this.saveNum.length == 5) { + this.maskLayerService.sendMessage(false) + this.maskLayerService.sendMessage(false) + this.canvasData.isChange = false + let config = new MatSnackBarConfig(); + config.verticalPosition = 'top'; + config.duration = 3000 + this.snackBar.open('保存成功', '确定', config); + this.tabbarService.sendMessage('changeScore'); + } + }, err => { + this.maskLayerService.sendMessage(false) + let config = new MatSnackBarConfig(); + config.verticalPosition = 'top'; + config.duration = 3000 + this.canvasData.isChange = true + this.snackBar.open('单位消防设施素材同步失败', '确定', config); + }) + + } else { //如果是建筑 + + //建筑平面图数据 + this.http.post("/api/BuildingAreaData", SitePlanData, { + params: { + companyId: this.params.companyId + } + }).subscribe(data => { + this.saveNum.push("1") + if (this.saveNum.length == 5) { + this.maskLayerService.sendMessage(false) + this.maskLayerService.sendMessage(false) + this.canvasData.isChange = false + let config = new MatSnackBarConfig(); + config.verticalPosition = 'top'; + config.duration = 3000 + this.snackBar.open('保存成功', '确定', config); + this.tabbarService.sendMessage('changeScore'); + } + }, err => { + this.maskLayerService.sendMessage(false) + let config = new MatSnackBarConfig(); + config.verticalPosition = 'top'; + config.duration = 3000 + this.canvasData.isChange = true + this.snackBar.open('平面图数据保存失败', '确定', config); + }) + + //建筑数据 + this.http.post("/api/BuildingData", CompanyData, { + params: { + companyId: this.params.companyId + } + }).subscribe(data => { + this.saveNum.push("1") + if (this.saveNum.length == 5) { + this.maskLayerService.sendMessage(false) + this.canvasData.isChange = false + this.maskLayerService.sendMessage(false) + let config = new MatSnackBarConfig(); + config.verticalPosition = 'top'; + config.duration = 3000 + this.snackBar.open('保存成功', '确定', config); + this.tabbarService.sendMessage('changeScore'); + } + }, err => { + this.maskLayerService.sendMessage(false) + let config = new MatSnackBarConfig(); + config.verticalPosition = 'top'; + config.duration = 3000 + this.canvasData.isChange = true + this.snackBar.open('单位数据保存失败', '确定', config); + }) + + //批量保存建筑毗邻 + let buildingAdjoins = this.canvasData.getBuildingAdjoinInfo() + this.http.post(`/api/BuildingAdjoins/Batch?companyId=${this.params.companyId}&buildingId=${this.canvasData.selectStorey.buildingId}`, buildingAdjoins).subscribe(data => { + this.saveNum.push("1") + if (this.saveNum.length == 5) { + this.maskLayerService.sendMessage(false) + this.canvasData.isChange = false + let config = new MatSnackBarConfig(); + config.verticalPosition = 'top'; + config.duration = 3000 + this.snackBar.open('保存成功', '确定', config); + this.tabbarService.sendMessage('changeScore'); + } + }, err => { + this.maskLayerService.sendMessage(false) + let config = new MatSnackBarConfig(); + config.verticalPosition = 'top'; + config.duration = 3000 + this.canvasData.isChange = true + if (err == 'infos 有重复方向!') { + this.snackBar.open('建筑毗邻同步失败,存在相同方向', '确定', config); + } else { + this.snackBar.open('建筑毗邻同步失败', '确定', config); + } + }) + + //批量保存建筑重点部位 + let buildingImportantLocations = this.canvasData.getBuildingImportantLocations() + this.http.post(`/api/BuildingImportantLocations/Batch?companyId=${this.params.companyId}&buildingId=${this.canvasData.selectStorey.buildingId}`, buildingImportantLocations).subscribe(data => { + this.saveNum.push("1") + if (this.saveNum.length == 5) { + this.maskLayerService.sendMessage(false) + this.canvasData.isChange = false + let config = new MatSnackBarConfig(); + config.verticalPosition = 'top'; + config.duration = 3000 + this.snackBar.open('保存成功', '确定', config); + this.tabbarService.sendMessage('changeScore'); + } + }, err => { + this.maskLayerService.sendMessage(false) + let config = new MatSnackBarConfig(); + config.verticalPosition = 'top'; + config.duration = 3000 + this.canvasData.isChange = true + this.snackBar.open('建筑重点部位同步失败', '确定', config); + }) + + //批量保存建筑消防设施素材 + let buildingFacilityAssets = this.canvasData.getAllBuildingFacilityAssetInfo() + this.http.post(`/api/BuildingFacilityAssets/Batch?companyId=${this.params.companyId}&buildingId=${this.canvasData.selectStorey.buildingId}`, buildingFacilityAssets).subscribe(data => { + this.saveNum.push("1") + if (this.saveNum.length == 5) { + this.maskLayerService.sendMessage(false) + this.canvasData.isChange = false + let config = new MatSnackBarConfig(); + config.verticalPosition = 'top'; + config.duration = 3000 + this.snackBar.open('保存成功', '确定', config); + this.tabbarService.sendMessage('changeScore'); + } + }, err => { + this.maskLayerService.sendMessage(false) + let config = new MatSnackBarConfig(); + config.verticalPosition = 'top'; + config.duration = 3000 + this.canvasData.isChange = true + this.snackBar.open('建筑消防设施素材同步失败', '确定', config); + }) + + } + } + } + } else { //if + const config = new MatSnackBarConfig(); + config.verticalPosition = 'top'; + config.duration = 3000 + this.snackBar.open('暂无楼层数据', '确定', config); + } + } + + //获得所有的建筑物 + getAllBuildings() { + this.http.get("/api/Buildings", { + params: { + companyId: this.params.companyId + } + }).subscribe(data => { + this.allBuildings = data + }) + } + + + //创建建筑 + createBuilding() { + let data = { + allBuildings: this.allBuildings, + companyId: this.params.companyId + } + 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.getAllBuildings() + } else if (data == "创建失败") { + const config = new MatSnackBarConfig(); + config.verticalPosition = 'top'; + config.duration = 3000 + this.snackBar.open('创建失败', '确定', config); + } + }); + } + + //选择建筑 + checkedBuilding(item, index) { + if (this.checkedBuildingIndex != index) { + this.canvasData.selectPanelPoint = new DisposalNodeData(); + if (this.canvasData.isChange) { //true 数据被改动 + let isTrue = confirm('是否保存当前编辑数据') + if (isTrue) { //先保存数据 在切换 + let isSuccess = this.saveSite()//true的时候 先保存数据 + if (isSuccess != false) { + this.beforeOneCheckedBuilding = item + this.checkedBuildingIndex = index + if (index == -1) { //总平面图数据 + this.getSitePlan() + } else { //建筑楼层/区域数据 + this.getBuildingSitePlan(item) + } + } + } else { + this.beforeOneCheckedBuilding = item + this.checkedBuildingIndex = index + if (index == -1) { //总平面图数据 + this.getSitePlan() + } else { //建筑楼层/区域数据 + this.getBuildingSitePlan(item) + } + } + } else { //flase 数据未被改动 + this.beforeOneCheckedBuilding = item + this.checkedBuildingIndex = index + if (index == -1) { //总平面图数据 + this.getSitePlan() + } else { //建筑楼层/区域数据 + this.getBuildingSitePlan(item) + } + } //if + + } //if + } + + //编辑建筑 + editBuilding(e, item) { + e.stopPropagation(); + let dialogRef = this.dialog.open(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.getAllBuildings() + } else if (data == "修改失败") { + const config = new MatSnackBarConfig(); + config.verticalPosition = 'top'; + config.duration = 3000 + this.snackBar.open('修改失败', '确定', config); + } + }); + } + + //删除建筑 + deleteBuilding(e, item) { + e.stopPropagation(); + if (confirm("是否删除该建筑") == true) { + let isHave = this.canvasData.allDisposalNode.find(items => { return items.buildingId === item.id }) + if (isHave == undefined) { + this.http.delete(`/api/Buildings/${item.id}`).subscribe(data => { + const config = new MatSnackBarConfig(); + config.verticalPosition = 'top'; + config.duration = 3000 + this.snackBar.open('删除成功', '确定', config); + this.http.get("/api/Buildings", { + params: { + companyId: this.params.companyId + } + }).subscribe(data => { + this.allBuildings = data + this.beforeOneCheckedBuilding = { name: "总平面图" } + this.checkedBuildingIndex = -1 + this.getSitePlan() + }) + }, err => { + const config = new MatSnackBarConfig(); + config.verticalPosition = 'top'; + config.duration = 3000 + this.snackBar.open('删除失败', '确定', config); + this.getAllBuildings() + }) + } else { //建筑 含有数据节点时 + const config = new MatSnackBarConfig(); + config.verticalPosition = 'top'; + config.duration = 3000 + this.snackBar.open('含有数据节点的建筑不允许删除', '确定', config); + } + } + } + + storeyData //将建筑素材和当前楼层素材合二为一 + //处理 tree 数据结构 + handleTreeData(storeyData) { + + this.storeyData = storeyData + let data = this.allFireElements //所有消防要素模板 + let treeData = [] //tree型 处理完成后的数据 + data.forEach(element => { + element.isTemplate = true //添加模板标识 + element.isLook = true //添加是否可见标识 + element.name != '其他' ? element.children = [] : null + + if (storeyData) { + for (let key in storeyData.data) { + storeyData.data[key].isLookPattern = true + if (element.id == storeyData.data[key].FireElementId) { + storeyData.data[key].isTemplate = false + storeyData.data[key].isLook = true + + element.isNewElement = true //该节点children是否存在新添加的真实素材 标识 + + //定义查看模式下能看到的元素 + element.isLookPattern = true + if (element.parentId) { + data.forEach(i => { + if (i.id == element.parentId) { + i.isLookPattern = true + } + }) + } + // + + element.children.push(storeyData.data[key]) + } + } + } + data.forEach(item => { if (item.parentId == element.id) { element.children.push(item) } }); + }); + data.forEach(element => { + if (!element.parentId) { treeData.push(element) } + }); + this.dataSource.data = treeData + this.treeControl.expandAll() + + } + + //点击树节点 + clickTreeNode(node) { + if (this.canvasData.originalcompanyBuildingData.data[node.id]) { + this.setAssetsProperty(this.canvasData.originalcompanyBuildingData.data[node.id]) + } else if (this.canvasData.originaleveryStoreyData.data[node.id]) { + this.setAssetsProperty(this.canvasData.originaleveryStoreyData.data[node.id]) + } + + //canvas上的素材高亮 + let iconHighLightArr: any = [] + if (node.isTemplate) {//如果是模板,则开始向下找 + node.children.forEach(item => { + if (item.isTemplate) {//如果子节点依旧是模板,则继续开始向下找 + item.children.forEach(i => { + iconHighLightArr.push(i.Id) + }) + } else { + iconHighLightArr.push(item.Id) + } + }) } else { - this.isImgNumCss = false + iconHighLightArr.push(node.id) + } + this.canvas.setHighlight(iconHighLightArr) + } + 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.treeControl.dataNodes.forEach(item => { + this.hideAllTreenode ? item.isLook = false : item.isLook = true + item.level === 0 ? list.push(item) : null + }) + list.forEach(item => { + this.clickLookItem(item) + }) + } + + //点击数节点的显示隐藏icon + clickLookItem(node) { + + + //修改真实素材islook属性 + for (let key in this.storeyData.data) { + if (key == node.id) { + this.storeyData.data[key].isLook = !this.storeyData.data[key].isLook + } } - this.canvasData.isChange = true - }) - } else if (file && fileSize > shardSize) { //上传文件>5MB时,分块上传 - let config = new MatSnackBarConfig(); - config.verticalPosition = 'top'; - config.duration = 3000 - this.snackBar.open('上传图片文件不允许大于5mb', '确定', config); - } - - } - - //不能上传图片提示 - imgNumBeyond() { - const config = new MatSnackBarConfig(); - config.verticalPosition = 'top'; - config.duration = 3000 - this.snackBar.open('图片数量已达上限', '确定', config); - } - - //删除素材属性图片 - deleteImg() { - if (this.imagesArr.length == 0) { - const config = new MatSnackBarConfig(); - config.verticalPosition = 'top'; - config.duration = 3000 - this.snackBar.open('没有可删除的图片,请先上传', '确定', config) - } else { - // 在素材原始对象中将删除的图片去掉 - this.canvasAssetObj.PropertyInfos = [...this.canvasAssetObj.PropertyInfos.filter((item) => { - return item.PropertyValue != this.imagesArr[this.mySwiper.activeIndex].PropertyValue - })] - //在图片循环数组中将图片去掉 - this.imagesArr.splice(this.mySwiper.activeIndex, 1); - //更新swiper视图 - setTimeout(() => { - this.mySwiper.update(); - this.gallery.update() - }, 0); - - //将上传的input框显示出来 - this.isImgNumCss = true; - //清除图片缓存 - if ((document.getElementById('inputimg'))) { - (document.getElementById('inputimg')).value = null //清空input框缓存 - } - - this.canvasData.isChange = true - } - } - - //动态属性方向select选择框 - direction(i, e) { - let index = this.canvasAssetObj.PropertyInfos.findIndex((item) => { - return i.PropertyName == item.PropertyName - }) - this.canvasAssetObj.PropertyInfos[index].PropertyValue = e.target.value - this.canvasData.isChange = true - } - - //动态属性供给区域select选择框 - supplyArea(i, e) { - let index = this.canvasAssetObj.PropertyInfos.findIndex((item) => { - return i.PropertyName == item.PropertyName - }) - this.canvasAssetObj.PropertyInfos[index].PropertyValue = e.target.value - this.canvasData.isChange = true - } - - //动态属性供给类型select选择框 - supplyType(i, e) { - let index = this.canvasAssetObj.PropertyInfos.findIndex((item) => { - return i.PropertyName == item.PropertyName - }) - this.canvasAssetObj.PropertyInfos[index].PropertyValue = e.target.value - this.canvasData.isChange = true - } - - isediticon = true //控制查看编辑模式的编辑模式小笔按钮 - - isMultipleAsset: boolean = false//框选多个素材属性显隐 - multipleAsset: any = { - Width: null, - Height: null, - Angle: null, - Thickness: null, - Color: null, - PropertyInfos: [] - }//多个素材共同属性 - multipleAssetData: any//当前多选的素材 - firstMultipleAssetData: any//当前多选的第一个素材 - ngOnInit(): void { - - let _this = this - 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()) { - 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: [] + //所有消防要素模板变化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 + }) + } + }) + } + + + const nodes = this.treeControl.dataNodes; + const expandNodes = []; + nodes.forEach((item) => { + if (item.expandable && this.treeControl.isExpanded(item)) { + expandNodes.push(item.id); + } + }); + + this.dataSource.data = [...this.dataSource.data] + + let newNodes = this.treeControl.dataNodes; + newNodes = newNodes.filter(n => { + return expandNodes.indexOf(n.id) >= 0; + }); + newNodes.forEach(item => { + this.treeControl.expand(item); + }); + + //canvas上的素材显隐 + let iconVisibleArr: any = [] + if (node.isTemplate) {//如果是模板,则开始向下找 + node.children.forEach(item => { + if (item.isTemplate) {//如果子节点依旧是模板,则继续开始向下找 + item.children.forEach(i => { + iconVisibleArr.push(i.Id) + }) + } else { + iconVisibleArr.push(item.Id) + } + }) + } else { + iconVisibleArr.push(node.id) + } + this.canvas.setIconVisible(iconVisibleArr, !node.isLook) + } + + + //封装 刷新 tree 数据 + async renovateTreeData(isRefresh: boolean = true) { + // this.allFireElements[this.allFireElements.length-1].children = [] + if (!this.selectingSitePlan.isGis) { + 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 + } else { + //加载高德地图 + this.toLoadGis() + } + + let beforeOneId = this.selectingSitePlan.id || '' //当前 选中 平面图 楼层/区域 id + let companyBuildingData = JSON.parse(JSON.stringify(this.canvasData.originalcompanyBuildingData || {})) // 当前 单位/建筑 数据 + let storeyData = JSON.parse(JSON.stringify(this.canvasData.originaleveryStoreyData || {})) //当前 楼层 数据 + + for (let key in companyBuildingData.data) { + if (companyBuildingData.data[key].FloorId === beforeOneId) { //处理 单位/建筑 数据是否归于当前楼层下 + storeyData.data[key] = companyBuildingData.data[key] + } } - 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) { - this.multipleAsset.InteractiveMode = InteractiveMode + 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]) + } } - let isFillMode = this.canvas.selection.all().every(item => item.assetData.FillMode === 0) //素材填充方式都为0 - if (isFillMode) { - this.multipleAsset.FillMode = 0 + this.handleTreeData(storeyData) //处理tree数据结构 + } + map: IMap + toLoadGis() { + console.log(666666, this.selectingSitePlan) + + this.map = + MapFactory.MapInstance("planContainer", { + viewMode: '2D', // 默认使用 2D 模式,如果希望使用带有俯仰角的 3D 模式,请设置 viewMode: '3D', + zoom: 11, //初始化地图层级 + }); + if (this.selectingSitePlan.defaultCenter) { + this.map.self.setZoom(this.selectingSitePlan.zoomLevel); //设置地图层级 + this.map.self.setCenter([this.selectingSitePlan.defaultCenter.x, this.selectingSitePlan.defaultCenter.y]) + } else { + this.map.self.setCity('上海市'); + } + + this.map.on('click', (e) => { + this.showInfoClick(e) + }); + this.map.on("complete", () => { + for (const key in this.canvasData.originaleveryStoreyData.data) { + if (Object.prototype.hasOwnProperty.call(this.canvasData.originaleveryStoreyData.data, key)) { + const element = this.canvasData.originaleveryStoreyData.data[key]; + let editable = sessionStorage.getItem('editable') + let markerContent + if (editable == '1') { + markerContent = '' + + '
' + + `` + + `
X
` + + '
'; + } else { + markerContent = '' + + '
' + + `` + + '
'; + } + + // 将 icon 传入 marker + let startMarker = new AMap.Marker({ + position: new AMap.LngLat(element.Point.x, element.Point.y), + // 将 html 传给 content + content: markerContent, + // 以 icon 的 [center bottom] 为原点 + //offset: MapFactory.PixelInstance(-13,-30).self, + offset: MapFactory.PixelInstance(-13, 30).self, + draggable: editable == '1' ? true : false, + }); + + startMarker.id = element.Id + startMarker.on('click', (e) => { + this.clickId = e.target.id + this.setAssetsProperty(this.canvasData.originaleveryStoreyData.data[e.target.id]) + }); + startMarker.on('dragend', (e) => { + // console.log('拖拽完成', e) + this.canvasData.isChange = true + this.clickId = e.target.id + this.canvasData.originaleveryStoreyData.data[e.target.id].Point = { x: e.lnglat.lng, y: e.lnglat.lat } + }); + this.planDataMarkers.push(startMarker) + this.map.add(startMarker); + } + } + }); + this.map.on('rightclick', (e) => { + this.selectImage.imageUrl = null + }); + } + + + + + + + + + //陈鹏飞↓↓↓ + //陈鹏飞↓↓↓ + //陈鹏飞↓↓↓ + params = { companyId: sessionStorage.getItem('companyId') } + allFireElements: any = []; //当前 单位/建筑 下的消防要素 + + isShowAttribute: boolean = true; //属性栏 是否显示 默认数据 + isShowProperty: boolean = false //属性栏 是否有东西 + + toggleExpandPanel: boolean = false; //左侧可展开面板展开或关闭 + toggleExpandPanelRight: boolean = false; //右侧可展开面板展开或关闭 + togglePlane: boolean = true; //可展开面板平面图 显隐 + toggleMaterialBank: boolean = false; //可展开面板素材库 显隐 + toggleHandlePlans: boolean = true; //可展开面板处置预案 显隐 + //可展开面板展开或关闭 + toggle() { + this.toggleExpandPanel = !this.toggleExpandPanel + } + //可展开面板展开或关闭 + toggle2() { + this.toggleExpandPanelRight = !this.toggleExpandPanelRight + } + //可展开面板 平面图 展开或关闭 + togglePlanarGraph() { + this.togglePlane = !this.togglePlane + } + //可展开面板 素材库 展开或关闭 + toggleMaterial() { + this.toggleMaterialBank = !this.toggleMaterialBank + } + //可展开面板 处置预案 展开或关闭 + toggleHandlePlan() { + this.toggleHandlePlans = !this.toggleHandlePlans + } + + sitePlanData: any = []; //总平面图 楼层/区域 数据 + selectingSitePlan: any; //选中的 平面图 楼层/区域 + selectSitePlanIndex: number; //选中的 平面图 楼层/区域 index + + //获取总平面图 + getSitePlan() { + let fireData = this.getFireElements(sessionStorage.getItem('buildingTypeId')) //获取单位下 消防要素 + let planData = this.getSitePlanCompanyData() //获取 单位 数据 + this.http.get('/api/SitePlans', { params: this.params }).subscribe(data => { + this.sitePlanData = data + this.selectingSitePlan = this.sitePlanData[0] || {} + this.canvasData.selectStorey = this.sitePlanData[0] || {} //服务中 存一份数据 + if (this.sitePlanData.length != 0 && this.sitePlanData[0].isGis) { + this.isGis = true + } else { + this.isGis = false + } + this.selectSitePlanIndex = 0 + + Promise.all([planData]).then((res) => { + this.getSitePlanStorey(this.selectingSitePlan) //获取 平面图 楼层数据 + }) + + }) + } + + //获取建筑 楼层/区域 废弃 + getBuildingSitePlan(item) { + let params = { buildingId: item.id } + let fireData = this.getFireElements(item.buildingTypes[0].id || '') //获取建筑下 消防要素 + let planData = this.getBuildingData(params) //获取 建筑 数据 + this.http.get('/api/BuildingAreas', { params }).subscribe(data => { + this.sitePlanData = data + this.selectingSitePlan = this.sitePlanData[0] || {} + this.canvasData.selectStorey = this.sitePlanData[0] || {} //服务中 存一份数据 + this.selectSitePlanIndex = 0 + + Promise.all([planData]).then((res) => { + this.getBuildingStorey(this.selectingSitePlan) //获取 建筑 楼层数据 + }) + + }) + } + + //根据单位类型获得所有的消防要素 + getFireElements(e) { + let params = { ids: e } + return new Promise((resolve, reject) => { + this.http.get('/api/Companies/FireElements', { params }).subscribe((data: any) => { + this.allFireElements = data //所有消防要素 + let other = { + children: [], + computed: true, + id: '', + name: '其他', + order: 999, + parentId: null, + tag: "INPUT", + isLookPattern: true + } + this.allFireElements.push(other) + resolve('success') + }) + }) + } + + //获取 单位 数据 + getSitePlanCompanyData() { + return new Promise((resolve, reject) => { + this.http.get('/api/CompanyData', { params: this.params }).subscribe((data: any) => { + console.log('单位数据', 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') + resolve('success') + }) + }) + } + + //获取 平面图 楼层数据 + getSitePlanStorey(e) { + let params = { sitePlanId: e.id } + this.http.get(`/api/SitePlanData`, { params }).subscribe((data: any) => { + console.log('平面图数据', 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.renovateTreeData() + }) + } + + //获取 建筑 数据 + getBuildingData(e) { + return new Promise((resolve, reject) => { + this.http.get(`/api/BuildingData`, { params: e }).subscribe((data: any) => { + this.canvasData.originalcompanyBuildingData = data || {} // 建筑原数据 + this.canvasData.originalcompanyBuildingData.data ? this.canvasData.originalcompanyBuildingData.data = JSON.parse(this.canvasData.originalcompanyBuildingData.data) : this.canvasData.originalcompanyBuildingData.data = {} + this.canvasData.originalcompanyBuildingData.version = "2.0" + this.canvasData.originalcompanyBuildingData.buildingId ? null : this.canvasData.originalcompanyBuildingData.buildingId = e.buildingId + resolve('success') + }) + }) + } + + //获取 建筑 楼层数据 + getBuildingStorey(e) { + let params = { buildingAreaId: e.id } + this.http.get(`/api/BuildingAreaData`, { params }).subscribe((data: any) => { + this.canvasData.originaleveryStoreyData = data || {} // 楼层原数据 + this.canvasData.originaleveryStoreyData.data ? this.canvasData.originaleveryStoreyData.data = JSON.parse(this.canvasData.originaleveryStoreyData.data) : this.canvasData.originaleveryStoreyData.data = {} + this.canvasData.originaleveryStoreyData.version = "2.0" + this.canvasData.originaleveryStoreyData.buildingAreaId ? null : this.canvasData.originaleveryStoreyData.buildingAreaId = e.id || null + this.renovateTreeData() + }) + } + + //点击选中 平面图 楼层/区域 时 + isGis: boolean + selectSitePlan(item, index) { + console.log('点击楼层', item) + if (item.isGis) { + this.isGis = true + } else { + this.isGis = false + } + + if (this.selectSitePlanIndex != index) { + this.canvasData.selectPanelPoint = new DisposalNodeData(); + if (this.canvasData.isChange) { //true 数据被改动 + let isTrue = confirm('是否保存当前编辑数据') + if (isTrue) { //先保存数据 在切换 + let isSuccess = this.saveSite()//true的时候 先保存数据 + if (isSuccess != false) { + this.selectingSitePlan = item + this.selectSitePlanIndex = index + this.canvasData.selectStorey = item //服务中 存一份数据 + if (this.checkedBuildingIndex == -1) { //总平面图时 + this.getSitePlanStorey(item) //获取 平面图 楼层数据 + } else { //楼层/区域时 + this.getBuildingStorey(item) //获取 建筑 楼层数据 + } + } + } else { //不保存数据 直接切换 + this.selectingSitePlan = item + this.selectSitePlanIndex = index + this.canvasData.selectStorey = item //服务中 存一份数据 + if (this.checkedBuildingIndex == -1) { //总平面图时 + this.getSitePlanStorey(item) //获取 平面图 楼层数据 + this.getSitePlanCompanyData() + } else { //楼层/区域时 + this.getBuildingStorey(item) //获取 建筑 楼层数据 + let params = { buildingId: this.beforeOneCheckedBuilding.id } + this.getBuildingData(params) + } + } + + } else { //false 数据没被改动 + this.selectingSitePlan = item + this.selectSitePlanIndex = index + this.canvasData.selectStorey = item //服务中 存一份数据 + if (this.checkedBuildingIndex == -1) { //总平面图时 + this.getSitePlanStorey(item) //获取 平面图 楼层数据 + } else { //楼层/区域时 + this.getBuildingStorey(item) //获取 建筑 楼层数据 + } + } //if + + } + } + + //新增平面图 楼层/区域 + foundPanel(e) { + e.stopPropagation() + let data = { + isBuilding: this.checkedBuildingIndex == -1 ? false : true, + Panel: this.beforeOneCheckedBuilding, + order: this.sitePlanData.length ? this.sitePlanData[this.sitePlanData.length - 1].order + 1 : 0, + } + let dialogRef = this.dialog.open(leftFunctionalDomainComponentPlan, { data }); + dialogRef.afterClosed().subscribe(data => { + if (data == '总平面图') { + this.sitePlanData.length ? this.renovateSitePlan() : this.getSitePlan() + this.maskLayerService.sendMessage(false) + } else if (data == '建筑') { + this.renovateBuilding() + this.maskLayerService.sendMessage(false) + } + }) + } + + //编辑平面图 楼层/区域 + editPlaneData(e) { + let data = { + isBuilding: this.checkedBuildingIndex == -1 ? false : true, + Panel: this.beforeOneCheckedBuilding, + buildingData: e, + isGis: this.isGis + } + 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 == '总平面图') { + let isSuccess = this.renovateSitePlan() + isSuccess.then(res => { + this.canvas.refreshBackgroundImage() + }) + } else if (data == '建筑') { + let isSuccess = this.renovateBuilding() + isSuccess.then(res => { + this.canvas.refreshBackgroundImage() + }) + } else if (data == '更新背景图') { + this.canvas.refreshBackgroundImage() + } + }) + } + + //平面图 楼层/区域 上移 + moveUp(item, index) { + if (index != 0) { + let replaceIndex = this.sitePlanData[index].order + this.sitePlanData[index].order = this.sitePlanData[index - 1].order + this.sitePlanData[index - 1].order = replaceIndex + if (this.checkedBuildingIndex == -1) { //总平面图 + this.http.put(`/api/SitePlans/${this.sitePlanData[index - 1].id}`, this.sitePlanData[index - 1]).subscribe(data => { + this.http.put(`/api/SitePlans/${this.sitePlanData[index].id}`, this.sitePlanData[index]).subscribe(data => { + this.selectSitePlanIndex = this.selectSitePlanIndex - 1 + this.renovateSitePlan() + }) + }) + } else { //楼层/区域 + this.http.put(`/api/BuildingAreas/${this.sitePlanData[index - 1].id}`, this.sitePlanData[index - 1], { params: this.params }).subscribe(data => { + this.http.put(`/api/BuildingAreas/${this.sitePlanData[index].id}`, this.sitePlanData[index], { params: this.params }).subscribe(data => { + this.selectSitePlanIndex = this.selectSitePlanIndex - 1 + this.renovateBuilding() + }) + }) + } + + } //if index + } + + //平面图 楼层/区域 下移 + moveDown(item, index) { + if (index != this.sitePlanData.length - 1) { + let replaceIndex = this.sitePlanData[index].order + this.sitePlanData[index].order = this.sitePlanData[index + 1].order + this.sitePlanData[index + 1].order = replaceIndex + if (this.checkedBuildingIndex == -1) { //总平面图 + this.http.put(`/api/SitePlans/${this.sitePlanData[index + 1].id}`, this.sitePlanData[index + 1]).subscribe(data => { + this.http.put(`/api/SitePlans/${this.sitePlanData[index].id}`, this.sitePlanData[index]).subscribe(data => { + this.selectSitePlanIndex = this.selectSitePlanIndex + 1 + this.renovateSitePlan() + }) + }) + } else { //楼层/区域 + this.http.put(`/api/BuildingAreas/${this.sitePlanData[index + 1].id}`, this.sitePlanData[index + 1], { params: this.params }).subscribe(data => { + this.http.put(`/api/BuildingAreas/${this.sitePlanData[index].id}`, this.sitePlanData[index], { params: this.params }).subscribe(data => { + this.selectSitePlanIndex = this.selectSitePlanIndex + 1 + this.renovateBuilding() + }) + }) + } + + } //if index + } + + //旋转底图 + revolveImg(item) { + if (item.isGis) { + const config = new MatSnackBarConfig(); + config.verticalPosition = 'top'; + config.duration = 3000 + this.snackBar.open('gis底图不允许旋转', '确定', config); + return + } + 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) + }) + }) + } else { //楼层/区域 + 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) + }) + }) } - 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) { - index++ - if (index == this.canvas.selection.size()) { - let newElement = JSON.parse(JSON.stringify(element)) - newElement.PropertyValue = '' - this.multipleAsset.PropertyInfos.push(newElement) + + } + + //删除 平面图 楼层/区域 + deletePlaneData(item) { + const isDelete = confirm('您确定要删除吗'); + if (isDelete) { + if (this.checkedBuildingIndex == -1) { //总平面图 + let isHave = this.canvasData.allDisposalNode.find(items => { return items.sitePlanId === item.id }) + if (isHave == undefined) { + this.http.delete(`/api/SitePlans/${item.id}`).subscribe(data => { + this.deleteShareData(item, -1) + }) + } else { + const config = new MatSnackBarConfig(); + config.verticalPosition = 'top'; + config.duration = 3000 + this.snackBar.open('含有数据节点的楼层不允许删除', '确定', config); } - } - }); - }) - }) - // console.log(666,_this.multipleAsset.PropertyInfos) - } else if (this.canvas.selection.size() == 0) { - this.isShowProperty = false - } - }, this) - AxMessageSystem.addListener('imageResize', (eventName, args1) => { - this.assetWidth = args1.Width - this.assetHeight = args1.Height - }, this) - 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) { //编辑模式 - this.canvasData.gameMode = GameMode.BasicInformation - } - - //gis模块平面图 - 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 - } else { - this.getAllLibrary() //获取素材库 - } - - let that = this - window.setTimeout(() => { - document.getElementById("functionalDomainContent").oncontextmenu = function (event) { - // that.canvas.cancelPaint() - that.selectImageIndex = -1 - event.preventDefault(); - }; - }) - - this.canvasData.getMessage().subscribe((message: any) => { - if (message == "send a message") { - // this.refurbishTreeData() - } - }) - - //点击marker关闭按钮 - window.deleteMarker = () => { - this.canvasData.isChange = true - //清除地图标点 - this.planDataMarkers.forEach((element, index) => { - if (element.id == this.clickId) { - this.planDataMarkers[index].setMap(null); + } else { //楼层/区域 + let isHave = this.canvasData.allDisposalNode.find(items => { return items.buildingAreaId === item.id }) + if (isHave == undefined) { + this.http.delete(`/api/BuildingAreas/${item.id}`).subscribe(data => { + this.deleteShareData(item, 1) + }) + } else { + const config = new MatSnackBarConfig(); + config.verticalPosition = 'top'; + config.duration = 3000 + this.snackBar.open('含有数据节点的楼层不允许删除', '确定', config); + } + } } - }); - - // 删除楼层数据 - delete this.canvasData.originaleveryStoreyData.data[this.clickId]; - // 删除建筑数据 - delete this.canvasData.originalcompanyBuildingData.data[this.clickId]; - - console.log('originalcompanyBuildingData', this.canvasData.originalcompanyBuildingData) - console.log('originaleveryStoreyData', this.canvasData.originaleveryStoreyData) - - } - } - //多选宽度共同改变 - 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 => { - item.assetData.Height = this.multipleAsset.Height - this.canvas.refreshIcon(item.assetData.Id) - this.canvasData.isChange = true - }) - } - //多选角度共同改变 - 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 => { - item.assetData.Thickness = this.multipleAsset.Thickness - this.canvas.refreshIcon(item.assetData.Id) - this.canvasData.isChange = true - }) - } - //多选颜色共同改变 - multipleSelectedcolor: any - multipleAssetSelectcolor(item, key) { - //在当前透明度基础上改变颜色 - this.multipleSelectedcolor = 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) - //根据滑竿值改变16进制颜色后两位 - 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)) - item.assetData.Color = this.multipleSelectedcolor - this.canvasData.isChange = true - this.canvas.refreshIcon(item.assetData.Id) - }) - } - //多选状态动态属性素材input框值改变 - multipleAssetInputChange(i, e) { - e.stopPropagation() - setTimeout(() => { - this.multipleAssetData.forEach(item => { - item.assetData.PropertyInfos.forEach(element => { - if (element.PropertyName == i.PropertyName) { - if (this.myIsNaN(i.PropertyValue)) { - i.PropertyValue = String(i.PropertyValue) + } + + //删除当前 单位/建筑的 共享数据中 已删除data + deleteShareData(e, isCompany) { + this.sitePlanData.forEach((element, index) => { + if (element.id === e.id) { + this.sitePlanData.splice(index, 1) + return + } + }); + let data = this.canvasData.originalcompanyBuildingData; + for (let key in data.data) { + if (data.data[key].FloorId === e.id) { //处理 单位/建筑 数据是否归于当前楼层下 + delete data.data[key] } - element.PropertyValue = i.PropertyValue - this.canvas.refreshIcon(item.assetData.Id) - this.canvasData.isChange = true - } - }) - }) - }, 0); - } - //多选状态动态属性素材radio框值改变 - multipleAssetRadioChange(i, value) { - // e.stopPropagation() - this.multipleAssetData.forEach(item => { - // console.log(item) - item.assetData.PropertyInfos.forEach(element => { - if (element.PropertyName == i.PropertyName) { - element.PropertyValue = value - this.canvas.refreshIcon(item.assetData.Id) - this.canvasData.isChange = true } - }) - }) - } - //多选状态动态属性素材下拉框值改变 - multipleSupplyArea(i, e) { - e.stopPropagation() - this.multipleAssetData.forEach(item => { - item.assetData.PropertyInfos.forEach(element => { - if (element.PropertyName == i.PropertyName) { - element.PropertyValue = i.PropertyValue - this.canvas.refreshIcon(item.assetData.Id) - this.canvasData.isChange = true + let newData = JSON.parse(JSON.stringify(this.canvasData.originalcompanyBuildingData)); + newData.data = JSON.stringify(newData.data) // 转换JSON 数据格式 + this.selectingSitePlan = this.sitePlanData[0] || {} + this.canvasData.selectStorey = this.sitePlanData[0] || {} //服务中 存一份数据 + this.selectSitePlanIndex = 0 + this.canvasData.isChange = false + if (isCompany === -1) { + this.http.post("/api/CompanyData", newData).subscribe(data => { }) + this.getSitePlanStorey(this.selectingSitePlan) //获取 平面图 楼层数据 + } else { + this.http.post("/api/BuildingData", newData, { params: this.params }).subscribe(data => { }) + this.getBuildingStorey(this.selectingSitePlan) //获取 建筑 楼层数据 } - }) - }) - } - - ngAfterViewInit(): void { - //不是gis模块平面图 - if (this.router.url.indexOf("gis") == -1) { - this.getSitePlan() - } - } - - copyAssetData: any //存储用于复制的素材 - //复制素材 - copyAsset() { - this.canvas.copy() - } - //粘贴素材 - pasteAsset() { - let companyId = sessionStorage.getItem("companyId") - let buildingId = this.beforeOneCheckedBuilding.id - let floorId = this.selectingSitePlan.id - this.canvas.paste(companyId, buildingId, floorId) - // this.renovateTreeData(false) - } - //截图 - 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) } - - basicInfo: boolean = true //基本信息名称显隐 - wantToWork: boolean = true //想定作业名称显隐 - //点击基本信息名称 - basicInfoClick() { - this.basicInfo = !this.basicInfo - this.canvas.setNameVisible(this.basicInfo, 0) - } - - //点击想定作业名称 - wantToWorkClick() { - this.wantToWork = !this.wantToWork - this.canvas.setNameVisible(this.wantToWork, 1) - } - - isEditPattern: boolean = true //是否为编辑模式 - //进入编辑模式 - editpat() { - let config = new MatSnackBarConfig(); - config.verticalPosition = 'top'; - config.duration = 3000 - this.snackBar.open('进入编辑模式', '确定', config); - this.isEditPattern = true - } - - //进入查看模式 - lookpat() { - let config = new MatSnackBarConfig(); - config.verticalPosition = 'top'; - config.duration = 3000 - this.snackBar.open('进入查看模式', '确定', config); - this.isEditPattern = false - } - - //保存平面图 - saveNum: any = [] - saveSite() { - //更新用于统计的数据 - this.canvasData.updateBuildingData() - - if (this.selectingSitePlan && this.selectingSitePlan.id) { - //打开遮罩层 - this.maskLayerService.sendMessage(true) - this.saveNum = [] - let SitePlanData = JSON.parse(JSON.stringify(this.canvasData.originaleveryStoreyData)); - SitePlanData.data = JSON.stringify(SitePlanData.data) - let CompanyData = JSON.parse(JSON.stringify(this.canvasData.originalcompanyBuildingData)); - CompanyData.data = JSON.stringify(CompanyData.data) - - let object = this.canvasData.originalcompanyBuildingData.data - let adjoinArr = [] //毗邻数组 - - if (this.pattern) {//如果是基本信息编辑模式 - for (const key in object) { - if (object[key].Name == "毗邻") {//如果是相同楼层,则筛选出毗邻 - - object[key].PropertyInfos.forEach(element => { - if (element.PropertyName == "方向") { - adjoinArr.push(element.PropertyValue) - } - }); - } + } + + //复制图层 平面图 楼层/区域 + duplicateLayer(item) { + if (item.isGis) { + const config = new MatSnackBarConfig(); + config.verticalPosition = 'top'; + config.duration = 3000 + this.snackBar.open('gis底图不允许复制', '确定', config); + return } - if ((new Set(adjoinArr)).size != adjoinArr.length) { - this.maskLayerService.sendMessage(false) - let config = new MatSnackBarConfig(); - config.verticalPosition = 'top'; - config.duration = 3000 - this.snackBar.open('保存失败,毗邻存在相同方向', '确定', config); - return false - } else { - //如果是单位 总平面图 - if (this.checkedBuildingIndex == -1) { - - if (this.isGis) { - let data = JSON.parse(JSON.stringify(this.selectingSitePlan)) - data.zoomLevel = this.map.getZoom(), - data.defaultCenter = { x: this.map.getCenter().lng, y: this.map.getCenter().lat } - delete data.userId - delete data.userName - delete data.sitePlanDataInfo - this.http.put(`/api/SitePlans/${this.selectingSitePlan.id}`, data).subscribe(data => { - this.sitePlanData.forEach(element => { - if (element.id == this.selectingSitePlan.id) { - element.zoomLevel = this.map.getZoom() - element.defaultCenter = { x: this.map.getCenter().lng, y: this.map.getCenter().lat } - } - }); - }, err => { - let config = new MatSnackBarConfig(); - config.verticalPosition = 'top'; - config.duration = 3000 - this.snackBar.open('gis保存当前视角失败', '确定', config); - }) + this.maskLayerService.sendMessage(true) + let paramsData = JSON.parse(JSON.stringify(this.canvasData.originaleveryStoreyData.data || {})) + Object.keys(paramsData).forEach((key) => { + if (key != '图例') { + let ID = ObjectID.default.generate() + paramsData[key].Id = ID + paramsData[ID] = paramsData[key] + delete paramsData[key] } + }) //图标Id重新赋值 + if (this.checkedBuildingIndex == -1) { //总平面图 + item.id = "" + item.modifiedTime = new Date() + item.name = item.name + '(副本)' + item.order = this.sitePlanData[this.sitePlanData.length - 1].order + 1 + this.http.post('/api/SitePlans', item).subscribe((data: any) => { + let newData = { + version: "2.0", + id: "", + data: JSON.stringify(paramsData) || null, + sitePlanId: data.id + } + this.http.post('/api/SitePlanData', newData, { params: this.params }).subscribe(data => { + this.canvasData.originaleveryStoreyData = data || {} // 楼层原数据 + this.canvasData.originaleveryStoreyData.data ? this.canvasData.originaleveryStoreyData.data = JSON.parse(this.canvasData.originaleveryStoreyData.data) : this.canvasData.originaleveryStoreyData.data = {} + Object.keys(this.canvasData.originaleveryStoreyData.data).forEach((key) => { + this.canvasData.originalcompanyBuildingData.data[key] = this.canvasData.originaleveryStoreyData.data[key]; + }); + let list = [] + //保存建筑数据 + let CompanyData = JSON.parse(JSON.stringify(this.canvasData.originalcompanyBuildingData)); + CompanyData.data = JSON.stringify(CompanyData.data) + this.http.post("/api/CompanyData", CompanyData, { params: { companyId: this.params.companyId } }).subscribe(data => { + list.push(1) + if (list.length === 4) { this.updateCurrentFloor() } + }) + //批量保存单位毗邻 + let CompanyAdjoins = this.canvasData.getCompanyAdjoinInfo() + this.http.post("/api/CompanyAdjoins/Batch", CompanyAdjoins, { params: { companyId: this.params.companyId } }).subscribe(data => { + list.push(1) + if (list.length === 4) { this.updateCurrentFloor() } + }, err => { + let config = new MatSnackBarConfig(); + config.verticalPosition = 'top'; + config.duration = 3000 + if (err == 'infos 有重复方向!') { + this.snackBar.open('单位毗邻同步失败,存在相同方向', '确定', config); + } else { + this.snackBar.open('单位毗邻同步失败', '确定', config); + } + }) + //批量保存单位重点部位 + let CompanyImportantLocations = this.canvasData.getCompanyImportantLocations() + this.http.post("/api/CompanyImportantLocations/Batch", CompanyImportantLocations, { params: { companyId: this.params.companyId } }).subscribe(data => { + list.push(1) + if (list.length === 4) { this.updateCurrentFloor() } + }) + //批量保存单位消防设施素材 + let CompanyFacilityAssets = this.canvasData.getAllCompanyFacilityAssetInfo() + this.http.post("/api/CompanyFacilityAssets/Batch", CompanyFacilityAssets, { params: { companyId: this.params.companyId } }).subscribe(data => { + list.push(1) + if (list.length === 4) { this.updateCurrentFloor() } + }) + }) - //保存平面图数据 - this.http.post("/api/SitePlanData", SitePlanData, { - params: { - companyId: this.params.companyId - } - }).subscribe(data => { - this.saveNum.push("1") - if (this.saveNum.length == 5) { - this.maskLayerService.sendMessage(false) - this.canvasData.isChange = false - let config = new MatSnackBarConfig(); - config.verticalPosition = 'top'; - config.duration = 3000 - this.snackBar.open('保存成功', '确定', config); - this.tabbarService.sendMessage('changeScore'); - } - }, err => { - this.maskLayerService.sendMessage(false) - let config = new MatSnackBarConfig(); - config.verticalPosition = 'top'; - config.duration = 3000 - this.canvasData.isChange = true - this.snackBar.open('平面图数据保存失败', '确定', config); }) + } else { //楼层/区域 + item.id = "" + item.modifiedTime = new Date() + item.name = item.name + '(副本)' + item.order = this.sitePlanData[this.sitePlanData.length - 1].order + 1 + this.http.post('/api/BuildingAreas', item, { params: this.params }).subscribe((data: any) => { + let newData = { + version: "2.0", + id: "", + data: JSON.stringify(paramsData) || null, + buildingAreaId: data.id + } + this.http.post('/api/BuildingAreaData', newData, { params: this.params }).subscribe(data => { + this.canvasData.originaleveryStoreyData = data || {} // 楼层原数据 + this.canvasData.originaleveryStoreyData.data ? this.canvasData.originaleveryStoreyData.data = JSON.parse(this.canvasData.originaleveryStoreyData.data) : this.canvasData.originaleveryStoreyData.data = {} + Object.keys(this.canvasData.originaleveryStoreyData.data).forEach((key) => { + this.canvasData.originalcompanyBuildingData.data[key] = this.canvasData.originaleveryStoreyData.data[key]; + }); + let list = [] + //建筑数据 + let CompanyData = JSON.parse(JSON.stringify(this.canvasData.originalcompanyBuildingData)); + CompanyData.data = JSON.stringify(CompanyData.data) + this.http.post("/api/BuildingData", CompanyData, { params: { companyId: this.params.companyId } }).subscribe(data => { + list.push(1) + if (list.length === 4) { this.updateCurrentFloor() } + }) + //批量保存建筑毗邻 + let buildingAdjoins = this.canvasData.getBuildingAdjoinInfo() + this.http.post(`/api/BuildingAdjoins/Batch?companyId=${this.params.companyId}&buildingId=${this.canvasData.selectStorey.buildingId}`, buildingAdjoins).subscribe(data => { + list.push(1) + if (list.length === 4) { this.updateCurrentFloor() } + }, err => { + let config = new MatSnackBarConfig(); + config.verticalPosition = 'top'; + config.duration = 3000 + 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 => { + list.push(1) + if (list.length === 4) { this.updateCurrentFloor() } + }) + //批量保存建筑消防设施素材 + let buildingFacilityAssets = this.canvasData.getAllBuildingFacilityAssetInfo() + this.http.post(`/api/BuildingFacilityAssets/Batch?companyId=${this.params.companyId}&buildingId=${this.canvasData.selectStorey.buildingId}`, buildingFacilityAssets).subscribe(data => { + list.push(1) + if (list.length === 4) { this.updateCurrentFloor() } + }) + }) - //保存建筑数据 - this.http.post("/api/CompanyData", CompanyData, { - params: { - companyId: this.params.companyId - } - }).subscribe(data => { - this.saveNum.push("1") - if (this.saveNum.length == 5) { - this.maskLayerService.sendMessage(false) - this.canvasData.isChange = false - let config = new MatSnackBarConfig(); - config.verticalPosition = 'top'; - config.duration = 3000 - this.snackBar.open('保存成功', '确定', config); - this.tabbarService.sendMessage('changeScore'); - } - }, err => { - this.maskLayerService.sendMessage(false) - let config = new MatSnackBarConfig(); - config.verticalPosition = 'top'; - config.duration = 3000 - this.canvasData.isChange = true - this.snackBar.open('单位数据保存失败', '确定', config); }) + } + } - //批量保存单位毗邻 - let CompanyAdjoins = this.canvasData.getCompanyAdjoinInfo() - this.http.post("/api/CompanyAdjoins/Batch", CompanyAdjoins, { - params: { - companyId: this.params.companyId - } - }).subscribe(data => { - this.saveNum.push("1") - if (this.saveNum.length == 5) { - this.maskLayerService.sendMessage(false) - this.canvasData.isChange = false - let config = new MatSnackBarConfig(); - config.verticalPosition = 'top'; - config.duration = 3000 - this.snackBar.open('保存成功', '确定', config); - this.tabbarService.sendMessage('changeScore'); - } - }, err => { - this.maskLayerService.sendMessage(false) - let config = new MatSnackBarConfig(); - config.verticalPosition = 'top'; - config.duration = 3000 - this.canvasData.isChange = true - if (err == 'infos 有重复方向!') { - this.snackBar.open('单位毗邻同步失败,存在相同方向', '确定', config); - } else { - this.snackBar.open('单位毗邻同步失败', '确定', config); - } - }) + //复制完楼层后 刷新视图 + updateCurrentFloor() { + if (this.checkedBuildingIndex == -1) { //总平面图 + let fireData = this.getFireElements(sessionStorage.getItem('buildingTypeId')) //获取单位下 消防要素 + let planData = this.getSitePlanCompanyData() //获取 单位 数据 + this.http.get('/api/SitePlans', { params: this.params }).subscribe(data => { + this.sitePlanData = data + this.selectingSitePlan = this.sitePlanData[this.sitePlanData.length - 1] || {} + this.canvasData.selectStorey = this.sitePlanData[this.sitePlanData.length - 1] || {} //服务中 存一份数据 + this.selectSitePlanIndex = this.sitePlanData.length - 1 + + Promise.all([fireData, planData]).then((res) => { + this.getSitePlanStorey(this.selectingSitePlan) //获取 平面图 楼层数据 + this.maskLayerService.sendMessage(false) + }) + + }) //重新加载 新楼层 + } else { //楼层/区域 + let params = { buildingId: this.beforeOneCheckedBuilding.id } + let fireData = this.getFireElements(this.beforeOneCheckedBuilding.buildingTypes[0].id || '') //获取建筑下 消防要素 + let planData = this.getBuildingData(params) //获取 建筑 数据 + this.http.get('/api/BuildingAreas', { params }).subscribe(data => { + this.sitePlanData = data + this.selectingSitePlan = this.sitePlanData[this.sitePlanData.length - 1] || {} + this.canvasData.selectStorey = this.sitePlanData[this.sitePlanData.length - 1] || {} //服务中 存一份数据 + this.selectSitePlanIndex = this.sitePlanData.length - 1 + + Promise.all([fireData, planData]).then((res) => { + this.getBuildingStorey(this.selectingSitePlan) //获取 建筑 楼层数据 + this.maskLayerService.sendMessage(false) + }) + + }) //重新加载 新楼层 + } + } - //批量保存单位重点部位 - let CompanyImportantLocations = this.canvasData.getCompanyImportantLocations() - this.http.post("/api/CompanyImportantLocations/Batch", CompanyImportantLocations, { - params: { - companyId: this.params.companyId - } - }).subscribe(data => { - this.saveNum.push("1") - if (this.saveNum.length == 5) { - this.maskLayerService.sendMessage(false) - this.canvasData.isChange = false - let config = new MatSnackBarConfig(); - config.verticalPosition = 'top'; - config.duration = 3000 - this.snackBar.open('保存成功', '确定', config); - this.tabbarService.sendMessage('changeScore'); - } - }, err => { - this.maskLayerService.sendMessage(false) - let config = new MatSnackBarConfig(); - config.verticalPosition = 'top'; - config.duration = 3000 - this.canvasData.isChange = true - this.snackBar.open('单位重点部位同步失败', '确定', config); - }) + //平面图 楼层/区域 替换底图 + 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 = 100 * 1024 * 1024 //100MB限制 + if (file && file.name.toLowerCase().indexOf('png') == -1 && file.name.toLowerCase().indexOf('jpg') == -1 && file.name.toLowerCase().indexOf('jpeg') == -1) { + const config = new MatSnackBarConfig(); + config.verticalPosition = 'top'; + config.duration = 3000 + this.snackBar.open('请上传图片后缀为png,jpg,jpeg的文件', '确定', config); + return + } - //批量保存单位消防设施素材 - let CompanyFacilityAssets = this.canvasData.getAllCompanyFacilityAssetInfo() - this.http.post("/api/CompanyFacilityAssets/Batch", CompanyFacilityAssets, { - params: { - companyId: this.params.companyId - } - }).subscribe(data => { - this.saveNum.push("1") - if (this.saveNum.length == 5) { - this.maskLayerService.sendMessage(false) - this.maskLayerService.sendMessage(false) - this.canvasData.isChange = false - let config = new MatSnackBarConfig(); - config.verticalPosition = 'top'; - config.duration = 3000 - this.snackBar.open('保存成功', '确定', config); - this.tabbarService.sendMessage('changeScore'); - } - }, err => { - this.maskLayerService.sendMessage(false) - let config = new MatSnackBarConfig(); - config.verticalPosition = 'top'; - config.duration = 3000 - this.canvasData.isChange = true - this.snackBar.open('单位消防设施素材同步失败', '确定', config); + 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) }) + } else if (file && fileSize > maxSize && fileSize < tenSize) { //上传文件5-100MB时 + let upload = this.canvasData.sectionUpload(sessionStorage.getItem('companyId'), file) + upload.then(res => { this.renovateBaseMap('/api/Objects/PlanPlatform/' + res, item) }) + } else { + const config = new MatSnackBarConfig(); + config.verticalPosition = 'top'; + config.duration = 3000 + this.snackBar.open('上传底图需小于100MB', '确定', config); + } + } - } else { //如果是建筑 + //封装 替换底图 function + renovateBaseMap(e, item) { + let that = this + let img = new Image() + img.src = e + img.onload = function () { + 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 => { + let isSuccess = that.renovateSitePlan() + isSuccess.then(res => { + that.canvas.refreshBackgroundImage() + }) + const config = new MatSnackBarConfig(); + config.verticalPosition = 'top'; + config.duration = 3000 + that.snackBar.open('上传底图成功', '确定', config); + }) + } else { //楼层/区域 + that.http.put(`/api/BuildingAreas/${item.id}`, item, { params: that.params }).subscribe(data => { + let isSuccess = that.renovateBuilding() + isSuccess.then(res => { + that.canvas.refreshBackgroundImage() + }) + const config = new MatSnackBarConfig(); + config.verticalPosition = 'top'; + config.duration = 3000 + that.snackBar.open('上传底图成功', '确定', config); + }) + } //else + } //onload + } - //建筑平面图数据 - this.http.post("/api/BuildingAreaData", SitePlanData, { - params: { - companyId: this.params.companyId - } - }).subscribe(data => { - this.saveNum.push("1") - if (this.saveNum.length == 5) { - this.maskLayerService.sendMessage(false) - this.maskLayerService.sendMessage(false) - this.canvasData.isChange = false - let config = new MatSnackBarConfig(); + //封装 刷新总平面图 数据 + renovateSitePlan() { + return new Promise((resolve, reject) => { + this.http.get('/api/SitePlans', { params: this.params }).subscribe(data => { + this.sitePlanData = data + this.selectingSitePlan = this.sitePlanData[this.selectSitePlanIndex] + this.canvasData.selectStorey = this.sitePlanData[this.selectSitePlanIndex] //服务中 存一份数据 + this.canvasData.originaleveryStoreyData.sitePlanId ? null : this.canvasData.originaleveryStoreyData.sitePlanId = this.selectingSitePlan.id || null + const config = new MatSnackBarConfig(); config.verticalPosition = 'top'; config.duration = 3000 - this.snackBar.open('保存成功', '确定', config); - this.tabbarService.sendMessage('changeScore'); - } - }, err => { - this.maskLayerService.sendMessage(false) - let config = new MatSnackBarConfig(); - config.verticalPosition = 'top'; - config.duration = 3000 - this.canvasData.isChange = true - this.snackBar.open('平面图数据保存失败', '确定', config); + this.snackBar.open('数据更新成功', '确定', config); + resolve('success') }) + }) + } - //建筑数据 - this.http.post("/api/BuildingData", CompanyData, { - params: { - companyId: this.params.companyId - } - }).subscribe(data => { - this.saveNum.push("1") - if (this.saveNum.length == 5) { - this.maskLayerService.sendMessage(false) - this.canvasData.isChange = false - this.maskLayerService.sendMessage(false) - let config = new MatSnackBarConfig(); + //封装 刷新 楼层/区域 数据 + renovateBuilding() { + let params = { + buildingId: this.beforeOneCheckedBuilding.id + } + return new Promise((resolve, reject) => { + this.http.get('/api/BuildingAreas', { params }).subscribe(data => { + this.sitePlanData = data + this.selectingSitePlan = this.sitePlanData[this.selectSitePlanIndex] + this.canvasData.selectStorey = this.sitePlanData[this.selectSitePlanIndex] //服务中 存一份数据 + this.canvasData.originaleveryStoreyData.buildingAreaId ? null : this.canvasData.originaleveryStoreyData.buildingAreaId = this.selectingSitePlan.id || null + const config = new MatSnackBarConfig(); config.verticalPosition = 'top'; config.duration = 3000 - this.snackBar.open('保存成功', '确定', config); - this.tabbarService.sendMessage('changeScore'); - } - }, err => { - this.maskLayerService.sendMessage(false) - let config = new MatSnackBarConfig(); - config.verticalPosition = 'top'; - config.duration = 3000 - this.canvasData.isChange = true - this.snackBar.open('单位数据保存失败', '确定', config); + this.snackBar.open('数据更新成功', '确定', config); + resolve('success') }) + }) + } - //批量保存建筑毗邻 - let buildingAdjoins = this.canvasData.getBuildingAdjoinInfo() - this.http.post(`/api/BuildingAdjoins/Batch?companyId=${this.params.companyId}&buildingId=${this.canvasData.selectStorey.buildingId}`, buildingAdjoins).subscribe(data => { - this.saveNum.push("1") - if (this.saveNum.length == 5) { - this.maskLayerService.sendMessage(false) - this.canvasData.isChange = false - let config = new MatSnackBarConfig(); - config.verticalPosition = 'top'; - config.duration = 3000 - this.snackBar.open('保存成功', '确定', config); - this.tabbarService.sendMessage('changeScore'); - } - }, err => { - this.maskLayerService.sendMessage(false) - let config = new MatSnackBarConfig(); - config.verticalPosition = 'top'; - config.duration = 3000 - this.canvasData.isChange = true - if (err == 'infos 有重复方向!') { - this.snackBar.open('建筑毗邻同步失败,存在相同方向', '确定', config); - } else { - this.snackBar.open('建筑毗邻同步失败', '确定', config); - } - }) + allLibrary: any = []; //所有素材库 + 素材 + selectLibrary: any; //选中的素材库 + selectImage: any; //选中的素材库图片 + selectImageIndex: number; //选中的素材库图片index + searchSettimeout: any; //延时器 + searchInput: string = null; //模糊搜索 input + searchLibrary: any = []; //模糊搜索 素材 + + //输入框 输入事件 + libraryChange() { + window.clearTimeout(this.searchSettimeout) + this.searchSettimeout = window.setTimeout(() => { + if (this.searchInput === "") { + this.searchLibrary = [] + } else { + this.http.get(`/api/Assets?assetName=${this.searchInput}`).subscribe((data: any) => { + this.searchLibrary = data + }) + } + }, 500) + } - //批量保存建筑重点部位 - let buildingImportantLocations = this.canvasData.getBuildingImportantLocations() - this.http.post(`/api/BuildingImportantLocations/Batch?companyId=${this.params.companyId}&buildingId=${this.canvasData.selectStorey.buildingId}`, buildingImportantLocations).subscribe(data => { - this.saveNum.push("1") - if (this.saveNum.length == 5) { - this.maskLayerService.sendMessage(false) - this.canvasData.isChange = false - let config = new MatSnackBarConfig(); - config.verticalPosition = 'top'; - config.duration = 3000 - this.snackBar.open('保存成功', '确定', config); - this.tabbarService.sendMessage('changeScore'); - } - }, err => { - this.maskLayerService.sendMessage(false) - let config = new MatSnackBarConfig(); - config.verticalPosition = 'top'; - config.duration = 3000 - this.canvasData.isChange = true - this.snackBar.open('建筑重点部位同步失败', '确定', config); - }) + //获取素材库 + getAllLibrary(type: string = 'input') { + this.http.get(`/api/AssetLibraries?tag=${type}`).subscribe((data: any) => { + data.forEach(element => { + element.images = [] + }); + this.allLibrary = data + this.selectImageIndex = -1 + }) + } - //批量保存建筑消防设施素材 - let buildingFacilityAssets = this.canvasData.getAllBuildingFacilityAssetInfo() - this.http.post(`/api/BuildingFacilityAssets/Batch?companyId=${this.params.companyId}&buildingId=${this.canvasData.selectStorey.buildingId}`, buildingFacilityAssets).subscribe(data => { - this.saveNum.push("1") - if (this.saveNum.length == 5) { - this.maskLayerService.sendMessage(false) - this.canvasData.isChange = false - let config = new MatSnackBarConfig(); - config.verticalPosition = 'top'; - config.duration = 3000 - this.snackBar.open('保存成功', '确定', config); - this.tabbarService.sendMessage('changeScore'); - } - }, err => { - this.maskLayerService.sendMessage(false) - let config = new MatSnackBarConfig(); - config.verticalPosition = 'top'; - config.duration = 3000 - this.canvasData.isChange = true - this.snackBar.open('建筑消防设施素材同步失败', '确定', config); + //素材库展开面板展开时 + opened(e) { + if (!e.images.length) { //当前素材库没加载素材时 + this.http.get(`/api/Assets?libraryId=${e.id}`).subscribe((data: any) => { + e.images = data }) - - } - } - } - } else { //if - const config = new MatSnackBarConfig(); - config.verticalPosition = 'top'; - config.duration = 3000 - this.snackBar.open('暂无楼层数据', '确定', config); - } - } - - //获得所有的建筑物 - getAllBuildings() { - this.http.get("/api/Buildings", { - params: { - companyId: this.params.companyId - } - }).subscribe(data => { - this.allBuildings = data - }) - } - - - //创建建筑 - createBuilding() { - let data = { - allBuildings: this.allBuildings, - companyId: this.params.companyId - } - 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.getAllBuildings() - } else if (data == "创建失败") { - const config = new MatSnackBarConfig(); - config.verticalPosition = 'top'; - config.duration = 3000 - this.snackBar.open('创建失败', '确定', config); - } - }); - } - - //选择建筑 - checkedBuilding(item, index) { - if (this.checkedBuildingIndex != index) { - this.canvasData.selectPanelPoint = new DisposalNodeData(); - if (this.canvasData.isChange) { //true 数据被改动 - let isTrue = confirm('是否保存当前编辑数据') - if (isTrue) { //先保存数据 在切换 - let isSuccess = this.saveSite()//true的时候 先保存数据 - if (isSuccess != false) { - this.beforeOneCheckedBuilding = item - this.checkedBuildingIndex = index - if (index == -1) { //总平面图数据 - this.getSitePlan() - } else { //建筑楼层/区域数据 - this.getBuildingSitePlan(item) - } - } - } else { - this.beforeOneCheckedBuilding = item - this.checkedBuildingIndex = index - if (index == -1) { //总平面图数据 - this.getSitePlan() - } else { //建筑楼层/区域数据 - this.getBuildingSitePlan(item) - } - } - } else { //flase 数据未被改动 - this.beforeOneCheckedBuilding = item - this.checkedBuildingIndex = index - if (index == -1) { //总平面图数据 - this.getSitePlan() - } else { //建筑楼层/区域数据 - this.getBuildingSitePlan(item) } - } //if - - } //if - } + } - //编辑建筑 - editBuilding(e, item) { - e.stopPropagation(); - let dialogRef = this.dialog.open(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.getAllBuildings() - } else if (data == "修改失败") { - const config = new MatSnackBarConfig(); - config.verticalPosition = 'top'; - config.duration = 3000 - this.snackBar.open('修改失败', '确定', config); - } - }); - } - - //删除建筑 - deleteBuilding(e, item) { - e.stopPropagation(); - if (confirm("是否删除该建筑") == true) { - let isHave = this.canvasData.allDisposalNode.find(items => { return items.buildingId === item.id }) - if (isHave == undefined) { - this.http.delete(`/api/Buildings/${item.id}`).subscribe(data => { - const config = new MatSnackBarConfig(); - config.verticalPosition = 'top'; - config.duration = 3000 - this.snackBar.open('删除成功', '确定', config); - this.http.get("/api/Buildings", { - params: { - companyId: this.params.companyId - } - }).subscribe(data => { - this.allBuildings = data - this.beforeOneCheckedBuilding = { name: "总平面图" } - this.checkedBuildingIndex = -1 - this.getSitePlan() - }) - }, err => { - const config = new MatSnackBarConfig(); - config.verticalPosition = 'top'; - config.duration = 3000 - this.snackBar.open('删除失败', '确定', config); - this.getAllBuildings() - }) - } else { //建筑 含有数据节点时 - const config = new MatSnackBarConfig(); - config.verticalPosition = 'top'; - config.duration = 3000 - this.snackBar.open('含有数据节点的建筑不允许删除', '确定', config); - } - } - } - - storeyData //将建筑素材和当前楼层素材合二为一 - //处理 tree 数据结构 - handleTreeData(storeyData) { - - this.storeyData = storeyData - let data = this.allFireElements //所有消防要素模板 - let treeData = [] //tree型 处理完成后的数据 - data.forEach(element => { - element.isTemplate = true //添加模板标识 - element.isLook = true //添加是否可见标识 - element.name != '其他' ? element.children = [] : null - - if (storeyData) { - for (let key in storeyData.data) { - storeyData.data[key].isLookPattern = true - if (element.id == storeyData.data[key].FireElementId) { - storeyData.data[key].isTemplate = false - storeyData.data[key].isLook = true - - element.isNewElement = true //该节点children是否存在新添加的真实素材 标识 - - //定义查看模式下能看到的元素 - element.isLookPattern = true - if (element.parentId) { - data.forEach(i => { - if (i.id == element.parentId) { - i.isLookPattern = true - } - }) - } - // + //点击选中素材库图片时 + selectImg(item, items, index) { + //如果是gis + this.selectLibrary = item.name + this.selectImage = JSON.parse(JSON.stringify(items)) + // console.log('选中图片',this.selectImage) + this.selectImageIndex = index + if (this.isGis) { + console.log(this.map) - element.children.push(storeyData.data[key]) - } - } - } - data.forEach(item => { if (item.parentId == element.id) { element.children.push(item) } }); - }); - data.forEach(element => { - if (!element.parentId) { treeData.push(element) } - }); - this.dataSource.data = treeData - this.treeControl.expandAll() - - } - - //点击树节点 - clickTreeNode(node) { - if (this.canvasData.originalcompanyBuildingData.data[node.id]) { - this.setAssetsProperty(this.canvasData.originalcompanyBuildingData.data[node.id]) - } else if (this.canvasData.originaleveryStoreyData.data[node.id]) { - this.setAssetsProperty(this.canvasData.originaleveryStoreyData.data[node.id]) - } - - //canvas上的素材高亮 - let iconHighLightArr: any = [] - if (node.isTemplate) {//如果是模板,则开始向下找 - node.children.forEach(item => { - if (item.isTemplate) {//如果子节点依旧是模板,则继续开始向下找 - item.children.forEach(i => { - iconHighLightArr.push(i.Id) - }) } else { - iconHighLightArr.push(item.Id) - } - }) - } else { - iconHighLightArr.push(node.id) - } - this.canvas.setHighlight(iconHighLightArr) - } - 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.treeControl.dataNodes.forEach(item => { - this.hideAllTreenode ? item.isLook = false : item.isLook = true - item.level === 0 ? list.push(item) : null - }) - list.forEach(item => { - this.clickLookItem(item) - }) - } - - //点击数节点的显示隐藏icon - clickLookItem(node) { - - - //修改真实素材islook属性 - for (let key in this.storeyData.data) { - if (key == node.id) { - this.storeyData.data[key].isLook = !this.storeyData.data[key].isLook - } - } - - //所有消防要素模板变化islook值 - if (node.isTemplate) { - this.allFireElements.forEach(item => { - if (item.id == node.id) { item.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 - }) + this.canvasData.selectTemplateData = items + this.canvas.beginPaint() } - }) - } - - - const nodes = this.treeControl.dataNodes; - const expandNodes = []; - nodes.forEach((item) => { - if (item.expandable && this.treeControl.isExpanded(item)) { - expandNodes.push(item.id); - } - }); - - this.dataSource.data = [...this.dataSource.data] - - let newNodes = this.treeControl.dataNodes; - newNodes = newNodes.filter(n => { - return expandNodes.indexOf(n.id) >= 0; - }); - newNodes.forEach(item => { - this.treeControl.expand(item); - }); - - //canvas上的素材显隐 - let iconVisibleArr: any = [] - if (node.isTemplate) {//如果是模板,则开始向下找 - node.children.forEach(item => { - if (item.isTemplate) {//如果子节点依旧是模板,则继续开始向下找 - item.children.forEach(i => { - iconVisibleArr.push(i.Id) - }) - } else { - iconVisibleArr.push(item.Id) + } + + //存储当前gis平面图的所有图标信息 + planData = [] + //存储当前gis平面图的所有marker信息 + planDataMarkers = [] + + //地图单击事件 + clickId + showInfoClick(e) { + if (!this.selectImage || !this.selectImage.imageUrl) { + return } - }) - } else { - iconVisibleArr.push(node.id) - } - this.canvas.setIconVisible(iconVisibleArr, !node.isLook) - } - - - //封装 刷新 tree 数据 - async renovateTreeData(isRefresh: boolean = true) { - // this.allFireElements[this.allFireElements.length-1].children = [] - if (!this.selectingSitePlan.isGis) { - 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 - } else { - //加载高德地图 - this.toLoadGis() - } - - let beforeOneId = this.selectingSitePlan.id || '' //当前 选中 平面图 楼层/区域 id - let companyBuildingData = JSON.parse(JSON.stringify(this.canvasData.originalcompanyBuildingData || {})) // 当前 单位/建筑 数据 - let storeyData = JSON.parse(JSON.stringify(this.canvasData.originaleveryStoreyData || {})) //当前 楼层 数据 - - for (let key in companyBuildingData.data) { - if (companyBuildingData.data[key].FloorId === beforeOneId) { //处理 单位/建筑 数据是否归于当前楼层下 - storeyData.data[key] = companyBuildingData.data[key] - } - } - for (let key in storeyData.data) { //筛选数据 没有匹配全部放入到 其他 数组 - let noMatch = this.allFireElements.find(every => every.id === storeyData.data[key].FireElementId) - if (!noMatch && storeyData.data[key].Id != "图例") { - this.allFireElements[this.allFireElements.length - 1].children.push(storeyData.data[key]) - } - } - this.handleTreeData(storeyData) //处理tree数据结构 - } - map: any - toLoadGis() { - console.log(666666, this.selectingSitePlan) - - this.map = new AMap.Map('planContainer', { - viewMode: '2D', // 默认使用 2D 模式,如果希望使用带有俯仰角的 3D 模式,请设置 viewMode: '3D', - zoom: 11, //初始化地图层级 - }); - if (this.selectingSitePlan.defaultCenter) { - this.map.setZoom(this.selectingSitePlan.zoomLevel); //设置地图层级 - this.map.setCenter([this.selectingSitePlan.defaultCenter.x, this.selectingSitePlan.defaultCenter.y]) - } else { - this.map.setCity('上海市'); - } - - this.map.on('click', (e) => { - this.showInfoClick(e) - }); - this.map.on("complete", () => { - for (const key in this.canvasData.originaleveryStoreyData.data) { - if (Object.prototype.hasOwnProperty.call(this.canvasData.originaleveryStoreyData.data, key)) { - const element = this.canvasData.originaleveryStoreyData.data[key]; - let editable = sessionStorage.getItem('editable') - let markerContent - if (editable == '1') { - markerContent = '' + - '
' + - `` + - `
X
` + - '
'; - } else { - markerContent = '' + - '
' + - `` + - '
'; - } - - // 将 icon 传入 marker - let startMarker = new AMap.Marker({ - position: new AMap.LngLat(element.Point.x, element.Point.y), + this.canvasData.isChange = true + let id = ObjectID.default.generate() + // 新增点标记 + // 点标记显示内容,HTML要素字符串 + let markerContent = '' + + '
' + + `` + + `
X
` + + '
'; + + // 将 icon 传入 marker + let startMarker = new AMap.Marker({ + position: new AMap.LngLat(e.lnglat.lng, e.lnglat.lat), // 将 html 传给 content content: markerContent, // 以 icon 的 [center bottom] 为原点 - offset: new AMap.Pixel(-13, -30), - draggable: editable == '1' ? true : false, - }); + offset: MapFactory.PixelInstance(-13, -30).self, + draggable: true, + }); - startMarker.id = element.Id - startMarker.on('click', (e) => { + startMarker.id = id + startMarker.on('click', (e) => { this.clickId = e.target.id this.setAssetsProperty(this.canvasData.originaleveryStoreyData.data[e.target.id]) - }); - startMarker.on('dragend', (e) => { + }); + startMarker.on('dragend', (e) => { // console.log('拖拽完成', e) this.canvasData.isChange = true this.clickId = e.target.id this.canvasData.originaleveryStoreyData.data[e.target.id].Point = { x: e.lnglat.lng, y: e.lnglat.lat } - }); - this.planDataMarkers.push(startMarker) - this.map.add(startMarker); - } - } - }); - this.map.on('rightclick', (e) => { - this.selectImage.imageUrl = null - }); - } - - - - - - - - - //陈鹏飞↓↓↓ - //陈鹏飞↓↓↓ - //陈鹏飞↓↓↓ - params = { companyId: sessionStorage.getItem('companyId') } - allFireElements: any = []; //当前 单位/建筑 下的消防要素 - - isShowAttribute: boolean = true; //属性栏 是否显示 默认数据 - isShowProperty: boolean = false //属性栏 是否有东西 - - toggleExpandPanel: boolean = false; //左侧可展开面板展开或关闭 - toggleExpandPanelRight: boolean = false; //右侧可展开面板展开或关闭 - togglePlane: boolean = true; //可展开面板平面图 显隐 - toggleMaterialBank: boolean = false; //可展开面板素材库 显隐 - toggleHandlePlans: boolean = true; //可展开面板处置预案 显隐 - //可展开面板展开或关闭 - toggle() { - this.toggleExpandPanel = !this.toggleExpandPanel - } - //可展开面板展开或关闭 - toggle2() { - this.toggleExpandPanelRight = !this.toggleExpandPanelRight - } - //可展开面板 平面图 展开或关闭 - togglePlanarGraph() { - this.togglePlane = !this.togglePlane - } - //可展开面板 素材库 展开或关闭 - toggleMaterial() { - this.toggleMaterialBank = !this.toggleMaterialBank - } - //可展开面板 处置预案 展开或关闭 - toggleHandlePlan() { - this.toggleHandlePlans = !this.toggleHandlePlans - } - - sitePlanData: any = []; //总平面图 楼层/区域 数据 - selectingSitePlan: any; //选中的 平面图 楼层/区域 - selectSitePlanIndex: number; //选中的 平面图 楼层/区域 index - - //获取总平面图 - getSitePlan() { - let fireData = this.getFireElements(sessionStorage.getItem('buildingTypeId')) //获取单位下 消防要素 - let planData = this.getSitePlanCompanyData() //获取 单位 数据 - this.http.get('/api/SitePlans', { params: this.params }).subscribe(data => { - this.sitePlanData = data - this.selectingSitePlan = this.sitePlanData[0] || {} - this.canvasData.selectStorey = this.sitePlanData[0] || {} //服务中 存一份数据 - if (this.sitePlanData.length != 0 && this.sitePlanData[0].isGis) { - this.isGis = true - } else { - this.isGis = false - } - this.selectSitePlanIndex = 0 - - Promise.all([planData]).then((res) => { - this.getSitePlanStorey(this.selectingSitePlan) //获取 平面图 楼层数据 - }) - - }) - } - - //获取建筑 楼层/区域 废弃 - getBuildingSitePlan(item) { - let params = { buildingId: item.id } - let fireData = this.getFireElements(item.buildingTypes[0].id || '') //获取建筑下 消防要素 - let planData = this.getBuildingData(params) //获取 建筑 数据 - this.http.get('/api/BuildingAreas', { params }).subscribe(data => { - this.sitePlanData = data - this.selectingSitePlan = this.sitePlanData[0] || {} - this.canvasData.selectStorey = this.sitePlanData[0] || {} //服务中 存一份数据 - this.selectSitePlanIndex = 0 - - Promise.all([planData]).then((res) => { - this.getBuildingStorey(this.selectingSitePlan) //获取 建筑 楼层数据 - }) - - }) - } - - //根据单位类型获得所有的消防要素 - getFireElements(e) { - let params = { ids: e } - return new Promise((resolve, reject) => { - this.http.get('/api/Companies/FireElements', { params }).subscribe((data: any) => { - this.allFireElements = data //所有消防要素 - let other = { - children: [], - computed: true, - id: '', - name: '其他', - order: 999, - parentId: null, - tag: "INPUT", - isLookPattern: true - } - this.allFireElements.push(other) - resolve('success') - }) - }) - } - - //获取 单位 数据 - getSitePlanCompanyData() { - return new Promise((resolve, reject) => { - this.http.get('/api/CompanyData', { params: this.params }).subscribe((data: any) => { - console.log('单位数据', 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') - resolve('success') - }) - }) - } - - //获取 平面图 楼层数据 - getSitePlanStorey(e) { - let params = { sitePlanId: e.id } - this.http.get(`/api/SitePlanData`, { params }).subscribe((data: any) => { - console.log('平面图数据', 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.renovateTreeData() - }) - } - - //获取 建筑 数据 - getBuildingData(e) { - return new Promise((resolve, reject) => { - this.http.get(`/api/BuildingData`, { params: e }).subscribe((data: any) => { - this.canvasData.originalcompanyBuildingData = data || {} // 建筑原数据 - this.canvasData.originalcompanyBuildingData.data ? this.canvasData.originalcompanyBuildingData.data = JSON.parse(this.canvasData.originalcompanyBuildingData.data) : this.canvasData.originalcompanyBuildingData.data = {} - this.canvasData.originalcompanyBuildingData.version = "2.0" - this.canvasData.originalcompanyBuildingData.buildingId ? null : this.canvasData.originalcompanyBuildingData.buildingId = e.buildingId - resolve('success') - }) - }) - } - - //获取 建筑 楼层数据 - getBuildingStorey(e) { - let params = { buildingAreaId: e.id } - this.http.get(`/api/BuildingAreaData`, { params }).subscribe((data: any) => { - this.canvasData.originaleveryStoreyData = data || {} // 楼层原数据 - this.canvasData.originaleveryStoreyData.data ? this.canvasData.originaleveryStoreyData.data = JSON.parse(this.canvasData.originaleveryStoreyData.data) : this.canvasData.originaleveryStoreyData.data = {} - this.canvasData.originaleveryStoreyData.version = "2.0" - this.canvasData.originaleveryStoreyData.buildingAreaId ? null : this.canvasData.originaleveryStoreyData.buildingAreaId = e.id || null - this.renovateTreeData() - }) - } - - //点击选中 平面图 楼层/区域 时 - isGis: boolean - selectSitePlan(item, index) { - console.log('点击楼层', item) - if (item.isGis) { - this.isGis = true - } else { - this.isGis = false - } - - if (this.selectSitePlanIndex != index) { - this.canvasData.selectPanelPoint = new DisposalNodeData(); - if (this.canvasData.isChange) { //true 数据被改动 - let isTrue = confirm('是否保存当前编辑数据') - if (isTrue) { //先保存数据 在切换 - let isSuccess = this.saveSite()//true的时候 先保存数据 - if (isSuccess != false) { - this.selectingSitePlan = item - this.selectSitePlanIndex = index - this.canvasData.selectStorey = item //服务中 存一份数据 - if (this.checkedBuildingIndex == -1) { //总平面图时 - this.getSitePlanStorey(item) //获取 平面图 楼层数据 - } else { //楼层/区域时 - this.getBuildingStorey(item) //获取 建筑 楼层数据 - } - } - } else { //不保存数据 直接切换 - this.selectingSitePlan = item - this.selectSitePlanIndex = index - this.canvasData.selectStorey = item //服务中 存一份数据 - if (this.checkedBuildingIndex == -1) { //总平面图时 - this.getSitePlanStorey(item) //获取 平面图 楼层数据 - this.getSitePlanCompanyData() - } else { //楼层/区域时 - this.getBuildingStorey(item) //获取 建筑 楼层数据 - let params = { buildingId: this.beforeOneCheckedBuilding.id } - this.getBuildingData(params) - } - } + }); - } else { //false 数据没被改动 - this.selectingSitePlan = item - this.selectSitePlanIndex = index - this.canvasData.selectStorey = item //服务中 存一份数据 - if (this.checkedBuildingIndex == -1) { //总平面图时 - this.getSitePlanStorey(item) //获取 平面图 楼层数据 - } else { //楼层/区域时 - this.getBuildingStorey(item) //获取 建筑 楼层数据 - } - } //if - - } - } - - //新增平面图 楼层/区域 - foundPanel(e) { - e.stopPropagation() - let data = { - isBuilding: this.checkedBuildingIndex == -1 ? false : true, - Panel: this.beforeOneCheckedBuilding, - order: this.sitePlanData.length ? this.sitePlanData[this.sitePlanData.length - 1].order + 1 : 0, - } - let dialogRef = this.dialog.open(leftFunctionalDomainComponentPlan, { data }); - dialogRef.afterClosed().subscribe(data => { - if (data == '总平面图') { - this.sitePlanData.length ? this.renovateSitePlan() : this.getSitePlan() - this.maskLayerService.sendMessage(false) - } else if (data == '建筑') { - this.renovateBuilding() - this.maskLayerService.sendMessage(false) - } - }) - } - - //编辑平面图 楼层/区域 - editPlaneData(e) { - let data = { - isBuilding: this.checkedBuildingIndex == -1 ? false : true, - Panel: this.beforeOneCheckedBuilding, - buildingData: e, - isGis: this.isGis - } - 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 == '总平面图') { - let isSuccess = this.renovateSitePlan() - isSuccess.then(res => { - this.canvas.refreshBackgroundImage() - }) - } else if (data == '建筑') { - let isSuccess = this.renovateBuilding() - isSuccess.then(res => { - this.canvas.refreshBackgroundImage() - }) - } else if (data == '更新背景图') { - this.canvas.refreshBackgroundImage() - } - }) - } - - //平面图 楼层/区域 上移 - moveUp(item, index) { - if (index != 0) { - let replaceIndex = this.sitePlanData[index].order - this.sitePlanData[index].order = this.sitePlanData[index - 1].order - this.sitePlanData[index - 1].order = replaceIndex - if (this.checkedBuildingIndex == -1) { //总平面图 - this.http.put(`/api/SitePlans/${this.sitePlanData[index - 1].id}`, this.sitePlanData[index - 1]).subscribe(data => { - this.http.put(`/api/SitePlans/${this.sitePlanData[index].id}`, this.sitePlanData[index]).subscribe(data => { - this.selectSitePlanIndex = this.selectSitePlanIndex - 1 - this.renovateSitePlan() - }) - }) - } else { //楼层/区域 - this.http.put(`/api/BuildingAreas/${this.sitePlanData[index - 1].id}`, this.sitePlanData[index - 1], { params: this.params }).subscribe(data => { - this.http.put(`/api/BuildingAreas/${this.sitePlanData[index].id}`, this.sitePlanData[index], { params: this.params }).subscribe(data => { - this.selectSitePlanIndex = this.selectSitePlanIndex - 1 - this.renovateBuilding() - }) + //将图标数据添加 + let itemData = JSON.parse(JSON.stringify(this.selectImage)) + itemData.id = id + itemData.point = { x: e.lnglat.lng, y: e.lnglat.lat } + itemData = this.canvasData.deserialize(JSON.stringify(itemData))//反序列化为大写 + // 添加楼层数据 + this.canvasData.originaleveryStoreyData.data[id] = itemData; + // 添加建筑数据 + this.canvasData.originalcompanyBuildingData.data[id] = itemData; + console.log('originalcompanyBuildingData', this.canvasData.originalcompanyBuildingData) + console.log('originaleveryStoreyData', this.canvasData.originaleveryStoreyData) + + //将marker点添加 + this.planDataMarkers.push(startMarker) + this.map.add(startMarker); + + } + + + + //处置预案 + allFirePlan: any = []; //所有灾情 + selectDisposalNode: string = ''; //当前点击tree节点 css选中样式 + + //获取所有灾情 + getAllFirePlan() { + let params = { componentId: sessionStorage.getItem('planId') } + this.http.get('/api/Disasters', { params: params }).subscribe((data: any) => { + if (!data.length) { //该 单位没有灾情时 + let msg = { + name: '灾情', + modifiedTime: new Date(), + planComponentId: sessionStorage.getItem('planId') + } + this.http.post('/api/Disasters', msg).subscribe(data => { + this.allFirePlan.push(data) + let params = { disasterId: this.allFirePlan[0].id || '' } + this.http.get('/api/DisposalNodes', { params: params }).subscribe(data => { //所有处置节点 + this.canvasData.allDisposalNode = data + }) + }) + } else { //单位 有灾情时 + this.allFirePlan = data + let params = { disasterId: this.allFirePlan[0].id || '' } + this.http.get('/api/DisposalNodes', { params: params }).subscribe(data => { //所有处置节点 + this.canvasData.allDisposalNode = data + }) + } }) - } - - } //if index - } - - //平面图 楼层/区域 下移 - moveDown(item, index) { - if (index != this.sitePlanData.length - 1) { - let replaceIndex = this.sitePlanData[index].order - this.sitePlanData[index].order = this.sitePlanData[index + 1].order - this.sitePlanData[index + 1].order = replaceIndex - if (this.checkedBuildingIndex == -1) { //总平面图 - this.http.put(`/api/SitePlans/${this.sitePlanData[index + 1].id}`, this.sitePlanData[index + 1]).subscribe(data => { - this.http.put(`/api/SitePlans/${this.sitePlanData[index].id}`, this.sitePlanData[index]).subscribe(data => { - this.selectSitePlanIndex = this.selectSitePlanIndex + 1 - this.renovateSitePlan() - }) + } + + //获取所有处置节点 + getDisposalNode() { + this.selectDisposalNode = '' + let params = { disasterId: this.allFirePlan[0].id || '' } + this.http.get('/api/DisasterData/Markers', { params: params }).subscribe(data => { //灾情标签信息 + this.canvasData.allNodeMarkers = data + this.mateFireForce() }) - } else { //楼层/区域 - this.http.put(`/api/BuildingAreas/${this.sitePlanData[index + 1].id}`, this.sitePlanData[index + 1], { params: this.params }).subscribe(data => { - this.http.put(`/api/BuildingAreas/${this.sitePlanData[index].id}`, this.sitePlanData[index], { params: this.params }).subscribe(data => { - this.selectSitePlanIndex = this.selectSitePlanIndex + 1 - this.renovateBuilding() - }) + this.http.get('/api/DisposalNodes', { params: params }).subscribe(data => { //处置节点 + this.canvasData.allDisposalNode = data + this.handleHybridTree() }) - } - - } //if index - } - - //旋转底图 - revolveImg(item) { - if (item.isGis) { - const config = new MatSnackBarConfig(); - config.verticalPosition = 'top'; - config.duration = 3000 - this.snackBar.open('gis底图不允许旋转', '确定', config); - return - } - 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) + } + + treeData: any = []; //渲染tree处理完成数据 + defaultExpandedKeys: any = []; //首次渲染 tree展开状态 + //处理 节点 Tree数据 + handleHybridTree() { + this.defaultExpandedKeys = [] + let treeData = [] + let data = JSON.parse(JSON.stringify(this.canvasData.allDisposalNode || [])) + data.forEach(element => { + this.defaultExpandedKeys.push(element.id) + element.title = element.name //name + element.key = element.id //id + element.children = [] //children + if (element.sitePlanId || element.buildingAreaId) { //是数据节点 + element.isLeaf = true + element.isDataNode = true + } else { //不是数据节点 + element.isLeaf = false + element.isDataNode = false + } + data.forEach(item => { + item.parentId === element.id ? element.children.push(item) : null + }) + }); + data.forEach(element => { + !element.parentId ? treeData.push(element) : null }) - }) - } else { //楼层/区域 - 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) + this.treeData = [...treeData] + this.defaultExpandedKeys = [...this.defaultExpandedKeys] + } + + //刷新 treeData 保存已展开节点 + refurbishTreeData() { + this.defaultExpandedKeys = [] + let params = { disasterId: this.allFirePlan[0].id || '' } + this.http.get('/api/DisposalNodes', { params: params }).subscribe(nodeData => { //处置节点 + this.canvasData.allDisposalNode = nodeData + let oldTreeData = this.nzTreeComponent.getExpandedNodeList() + oldTreeData.forEach(item => { + this.defaultExpandedKeys.push(item.key) + }) + let treeData = [] + let data = JSON.parse(JSON.stringify(this.canvasData.allDisposalNode || [])) + data.forEach(element => { + element.title = element.name //name + element.key = element.id //id + element.children = [] //children + if (element.sitePlanId || element.buildingAreaId) { //是数据节点 + element.isLeaf = true + element.isDataNode = true + } else { //不是数据节点 + element.isLeaf = false + element.isDataNode = false + } + data.forEach(item => { + item.parentId === element.id ? element.children.push(item) : null + }) + }); + data.forEach(element => { + !element.parentId ? treeData.push(element) : null + }) + this.treeData = [...treeData] + this.defaultExpandedKeys = [...this.defaultExpandedKeys] }) - }) } - } + sitePlanIcon = { fire: 0, force: 0 } // 总平面图 火源/力量 图标 是否展示 - //删除 平面图 楼层/区域 - deletePlaneData(item) { - const isDelete = confirm('您确定要删除吗'); - if (isDelete) { - if (this.checkedBuildingIndex == -1) { //总平面图 - let isHave = this.canvasData.allDisposalNode.find(items => { return items.sitePlanId === item.id }) - if (isHave == undefined) { - this.http.delete(`/api/SitePlans/${item.id}`).subscribe(data => { - this.deleteShareData(item, -1) - }) - } else { - const config = new MatSnackBarConfig(); - config.verticalPosition = 'top'; - config.duration = 3000 - this.snackBar.open('含有数据节点的楼层不允许删除', '确定', config); - } - } else { //楼层/区域 - let isHave = this.canvasData.allDisposalNode.find(items => { return items.buildingAreaId === item.id }) - if (isHave == undefined) { - this.http.delete(`/api/BuildingAreas/${item.id}`).subscribe(data => { - this.deleteShareData(item, 1) - }) - } else { - const config = new MatSnackBarConfig(); - config.verticalPosition = 'top'; - config.duration = 3000 - this.snackBar.open('含有数据节点的楼层不允许删除', '确定', config); + //刷新 建筑楼层 匹配 火源/力量 图标 + mateFireForce() { + let data = this.canvasData.allNodeMarkers.markers || {} + for (let key in data) { //遍历 火/力量 图标 + this.sitePlanData.forEach(element => { //楼层 + if (element.id == key) { // 相匹配时 + data[key].fireCount != 0 ? element.fire = 1 : element.fire = 0 + data[key].forceCount != 0 ? element.force = 1 : element.force = 0 + } + }); + this.allBuildings.forEach(element => { //建筑 + if (element.id == key) { // 相匹配时 + data[key].fireCount != 0 ? element.fire = 1 : element.fire = 0 + data[key].forceCount != 0 ? element.force = 1 : element.force = 0 + } + }); + if (this.params.companyId == key) { //总平面图时 + data[key].fireCount != 0 ? this.sitePlanIcon.fire = 1 : this.sitePlanIcon.fire = 0 + data[key].forceCount != 0 ? this.sitePlanIcon.force = 1 : this.sitePlanIcon.force = 0 + } } - } - } - } - - //删除当前 单位/建筑的 共享数据中 已删除data - deleteShareData(e, isCompany) { - this.sitePlanData.forEach((element, index) => { - if (element.id === e.id) { - this.sitePlanData.splice(index, 1) - return - } - }); - let data = this.canvasData.originalcompanyBuildingData; - for (let key in data.data) { - if (data.data[key].FloorId === e.id) { //处理 单位/建筑 数据是否归于当前楼层下 - delete data.data[key] - } - } - let newData = JSON.parse(JSON.stringify(this.canvasData.originalcompanyBuildingData)); - newData.data = JSON.stringify(newData.data) // 转换JSON 数据格式 - this.selectingSitePlan = this.sitePlanData[0] || {} - this.canvasData.selectStorey = this.sitePlanData[0] || {} //服务中 存一份数据 - this.selectSitePlanIndex = 0 - this.canvasData.isChange = false - if (isCompany === -1) { - this.http.post("/api/CompanyData", newData).subscribe(data => { }) - this.getSitePlanStorey(this.selectingSitePlan) //获取 平面图 楼层数据 - } else { - this.http.post("/api/BuildingData", newData, { params: this.params }).subscribe(data => { }) - this.getBuildingStorey(this.selectingSitePlan) //获取 建筑 楼层数据 - } - } - - //复制图层 平面图 楼层/区域 - duplicateLayer(item) { - if (item.isGis) { - const config = new MatSnackBarConfig(); - config.verticalPosition = 'top'; - config.duration = 3000 - this.snackBar.open('gis底图不允许复制', '确定', config); - return - } - this.maskLayerService.sendMessage(true) - let paramsData = JSON.parse(JSON.stringify(this.canvasData.originaleveryStoreyData.data || {})) - Object.keys(paramsData).forEach((key) => { - if (key != '图例') { - let ID = ObjectID.default.generate() - paramsData[key].Id = ID - paramsData[ID] = paramsData[key] - delete paramsData[key] - } - }) //图标Id重新赋值 - if (this.checkedBuildingIndex == -1) { //总平面图 - item.id = "" - item.modifiedTime = new Date() - item.name = item.name + '(副本)' - item.order = this.sitePlanData[this.sitePlanData.length - 1].order + 1 - this.http.post('/api/SitePlans', item).subscribe((data: any) => { - let newData = { - version: "2.0", - id: "", - data: JSON.stringify(paramsData) || null, - sitePlanId: data.id + + let buildingMSG = this.canvasData.allNodeMarkers.highlightMarkers || {} + for (let key in buildingMSG) { + if (key === this.canvasData.selectPanelPoint.DisposalNodeId) { + for (let keys in buildingMSG[key]) { + this.sitePlanData.forEach(element => { //楼层 + if (element.id === keys) { + buildingMSG[key][keys].fireCount != 0 ? element.fire = 2 : null + buildingMSG[key][keys].forceCount != 0 ? element.force = 2 : null + } + }); + this.allBuildings.forEach(element => { //建筑 + if (element.id === keys) { // 相匹配时 + buildingMSG[key][keys].fireCount != 0 ? element.fire = 2 : null + buildingMSG[key][keys].forceCount != 0 ? element.force = 2 : null + } + }); + if (this.params.companyId === keys) { //总平面图时 + buildingMSG[key][keys].fireCount != 0 ? this.sitePlanIcon.fire = 2 : null + buildingMSG[key][keys].forceCount != 0 ? this.sitePlanIcon.force = 2 : null + } + } + } } - this.http.post('/api/SitePlanData', newData, { params: this.params }).subscribe(data => { - this.canvasData.originaleveryStoreyData = data || {} // 楼层原数据 - this.canvasData.originaleveryStoreyData.data ? this.canvasData.originaleveryStoreyData.data = JSON.parse(this.canvasData.originaleveryStoreyData.data) : this.canvasData.originaleveryStoreyData.data = {} - Object.keys(this.canvasData.originaleveryStoreyData.data).forEach((key) => { - this.canvasData.originalcompanyBuildingData.data[key] = this.canvasData.originaleveryStoreyData.data[key]; - }); - let list = [] - //保存建筑数据 - let CompanyData = JSON.parse(JSON.stringify(this.canvasData.originalcompanyBuildingData)); - CompanyData.data = JSON.stringify(CompanyData.data) - this.http.post("/api/CompanyData", CompanyData, { params: { companyId: this.params.companyId } }).subscribe(data => { - list.push(1) - if (list.length === 4) { this.updateCurrentFloor() } - }) - //批量保存单位毗邻 - let CompanyAdjoins = this.canvasData.getCompanyAdjoinInfo() - this.http.post("/api/CompanyAdjoins/Batch", CompanyAdjoins, { params: { companyId: this.params.companyId } }).subscribe(data => { - list.push(1) - if (list.length === 4) { this.updateCurrentFloor() } - }, err => { - let config = new MatSnackBarConfig(); + } + + // 切换 基本信息时 刷新 删除 建筑楼层 自定义属性 + mateDeleteCustomize() { + this.canvasData.selectPanelPointBaseData = { description: '', notes: '', weather: '', airTemperature: '', windDirection: '', windScale: '' } + this.defaultExpandedKeys = [] + this.sitePlanIcon = { fire: 0, force: 0 } + this.sitePlanData.forEach(element => { //楼层 + delete element.fire + delete element.force + }); + this.allBuildings.forEach(element => { //建筑 + delete element.fire + delete element.force + }); + } + + //计算差异 + countValue(e) { + e.stopPropagation() + let params = { disasterId: this.allFirePlan[0].id || '' } + this.http.get('/api/DisasterData/Diffs', { params: params }).subscribe(data => { + this.canvasData.allNodeMarkers = data + this.mateFireForce() + const config = new MatSnackBarConfig(); config.verticalPosition = 'top'; config.duration = 3000 - if (err == 'infos 有重复方向!') { - this.snackBar.open('单位毗邻同步失败,存在相同方向', '确定', config); - } else { - this.snackBar.open('单位毗邻同步失败', '确定', config); - } - }) - //批量保存单位重点部位 - let CompanyImportantLocations = this.canvasData.getCompanyImportantLocations() - this.http.post("/api/CompanyImportantLocations/Batch", CompanyImportantLocations, { params: { companyId: this.params.companyId } }).subscribe(data => { - list.push(1) - if (list.length === 4) { this.updateCurrentFloor() } - }) - //批量保存单位消防设施素材 - let CompanyFacilityAssets = this.canvasData.getAllCompanyFacilityAssetInfo() - this.http.post("/api/CompanyFacilityAssets/Batch", CompanyFacilityAssets, { params: { companyId: this.params.companyId } }).subscribe(data => { - list.push(1) - if (list.length === 4) { this.updateCurrentFloor() } - }) + this.snackBar.open('计算差异完成', '确定', config); }) + } - }) - } else { //楼层/区域 - item.id = "" - item.modifiedTime = new Date() - item.name = item.name + '(副本)' - item.order = this.sitePlanData[this.sitePlanData.length - 1].order + 1 - this.http.post('/api/BuildingAreas', item, { params: this.params }).subscribe((data: any) => { - let newData = { - version: "2.0", - id: "", - data: JSON.stringify(paramsData) || null, - buildingAreaId: data.id - } - this.http.post('/api/BuildingAreaData', newData, { params: this.params }).subscribe(data => { - this.canvasData.originaleveryStoreyData = data || {} // 楼层原数据 - this.canvasData.originaleveryStoreyData.data ? this.canvasData.originaleveryStoreyData.data = JSON.parse(this.canvasData.originaleveryStoreyData.data) : this.canvasData.originaleveryStoreyData.data = {} - Object.keys(this.canvasData.originaleveryStoreyData.data).forEach((key) => { - this.canvasData.originalcompanyBuildingData.data[key] = this.canvasData.originaleveryStoreyData.data[key]; - }); - let list = [] - //建筑数据 - let CompanyData = JSON.parse(JSON.stringify(this.canvasData.originalcompanyBuildingData)); - CompanyData.data = JSON.stringify(CompanyData.data) - this.http.post("/api/BuildingData", CompanyData, { params: { companyId: this.params.companyId } }).subscribe(data => { - list.push(1) - if (list.length === 4) { this.updateCurrentFloor() } - }) - //批量保存建筑毗邻 - let buildingAdjoins = this.canvasData.getBuildingAdjoinInfo() - this.http.post(`/api/BuildingAdjoins/Batch?companyId=${this.params.companyId}&buildingId=${this.canvasData.selectStorey.buildingId}`, buildingAdjoins).subscribe(data => { - list.push(1) - if (list.length === 4) { this.updateCurrentFloor() } - }, err => { - let config = new MatSnackBarConfig(); - config.verticalPosition = 'top'; - config.duration = 3000 - if (err == 'infos 有重复方向!') { - this.snackBar.open('建筑毗邻同步失败,存在相同方向', '确定', config); + //复制 处置预案 节点 + copyPanelPoint(e, item, treeData) { + e.stopPropagation() + if (confirm(`确定要复制 ${item.title} ?`)) { + let params = { id: item.origin.id } + let order + if (item.level == 0) { + treeData.length ? order = treeData[treeData.length - 1].order + 1 : order = 0 } else { - this.snackBar.open('建筑毗邻同步失败', '确定', config); + let parent = item.getParentNode() //获取父节点 + parent.origin.children.length ? order = parent.origin.children[parent.origin.children.length - 1].order + 1 : order = 0 } - }) - //批量保存建筑重点部位 - let buildingImportantLocations = this.canvasData.getBuildingImportantLocations() - this.http.post(`/api/BuildingImportantLocations/Batch?companyId=${this.params.companyId}&buildingId=${this.canvasData.selectStorey.buildingId}`, buildingImportantLocations).subscribe(data => { - list.push(1) - if (list.length === 4) { this.updateCurrentFloor() } - }) - //批量保存建筑消防设施素材 - let buildingFacilityAssets = this.canvasData.getAllBuildingFacilityAssetInfo() - this.http.post(`/api/BuildingFacilityAssets/Batch?companyId=${this.params.companyId}&buildingId=${this.canvasData.selectStorey.buildingId}`, buildingFacilityAssets).subscribe(data => { - list.push(1) - if (list.length === 4) { this.updateCurrentFloor() } - }) - }) - - }) + let data = { + name: item.title + '(副本)', + level: item.level, + order: order, + description: '', + disasterId: item.origin.disasterId || '', + parentId: item.origin.parentId || null, + planComponentId: item.origin.planComponentId || '', + } + this.http.post('/api/DisposalNodes/Clone', data, { params: params }).subscribe(data => { + this.refurbishTreeData() + }) + } //isTrue } - } - - //复制完楼层后 刷新视图 - updateCurrentFloor() { - if (this.checkedBuildingIndex == -1) { //总平面图 - let fireData = this.getFireElements(sessionStorage.getItem('buildingTypeId')) //获取单位下 消防要素 - let planData = this.getSitePlanCompanyData() //获取 单位 数据 - this.http.get('/api/SitePlans', { params: this.params }).subscribe(data => { - this.sitePlanData = data - this.selectingSitePlan = this.sitePlanData[this.sitePlanData.length - 1] || {} - this.canvasData.selectStorey = this.sitePlanData[this.sitePlanData.length - 1] || {} //服务中 存一份数据 - this.selectSitePlanIndex = this.sitePlanData.length - 1 - Promise.all([fireData, planData]).then((res) => { - this.getSitePlanStorey(this.selectingSitePlan) //获取 平面图 楼层数据 - this.maskLayerService.sendMessage(false) - }) + //删除 处置预案 节点 + deletePanelPoint(e, item) { + e.stopPropagation() + if (confirm(`确定要删除 ${item.name} ?`)) { + this.http.delete(`/api/DisposalNodes/${item.id}`).subscribe(data => { + this.refurbishTreeData() + }) + } + } - }) //重新加载 新楼层 - } else { //楼层/区域 - let params = { buildingId: this.beforeOneCheckedBuilding.id } - let fireData = this.getFireElements(this.beforeOneCheckedBuilding.buildingTypes[0].id || '') //获取建筑下 消防要素 - let planData = this.getBuildingData(params) //获取 建筑 数据 - this.http.get('/api/BuildingAreas', { params }).subscribe(data => { - this.sitePlanData = data - this.selectingSitePlan = this.sitePlanData[this.sitePlanData.length - 1] || {} - this.canvasData.selectStorey = this.sitePlanData[this.sitePlanData.length - 1] || {} //服务中 存一份数据 - this.selectSitePlanIndex = this.sitePlanData.length - 1 - - Promise.all([fireData, planData]).then((res) => { - this.getBuildingStorey(this.selectingSitePlan) //获取 建筑 楼层数据 - this.maskLayerService.sendMessage(false) - }) + //点击 处置Tree节点 + selectanelPoint(e) { + if (!e.buildingAreaId && !e.sitePlanId) { //当前节点 不是 数据节点 时 + let msg = this.canvasData.findDisposalNode(e.id) + this.canvasData.selectPanelPointBaseData = msg + this.selectDisposalNode == msg.id ? this.selectDisposalNode = '' : this.selectDisposalNode = msg.id //选中 节点 + + } else if (e.buildingAreaId || e.sitePlanId) { //当前节点 是 数据节点 时 + let msg = this.canvasData.findDisposalNode(e.parentId) + this.canvasData.selectPanelPointBaseData = msg + this.selectDisposalNode = e.parentId //选中 节点 + + if (this.canvasData.selectPanelPoint.DisposalNodeId != e.id) { //选择节点 不是当前节点时 + let params = { nodeId: e.id } + let parameter = { //查询 节点 对应 建筑/楼层 index,id + buildingIndex: e.sitePlanId ? -1 : this.allBuildings.findIndex(item => { return item.id === e.buildingId }), //总平面图/建筑 index + storeyId: e.sitePlanId ? e.sitePlanId : e.buildingAreaId, //楼层id + } + this.http.get('/api/DisposalNodeData', { params: params }).subscribe(data => { + this.canvasData.selectPanelPoint = this.canvasData.deserialize(JSON.stringify(data || new DisposalNodeData())) //选择 当前 节点 + this.canvasData.selectPanelPoint.Data = this.canvasData.deserialize(this.canvasData.selectPanelPoint.Data) + this.seekPanelPoint(parameter) + }) + } //if + + } //else if + } - }) //重新加载 新楼层 - } - } - - //平面图 楼层/区域 替换底图 - 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 = 100 * 1024 * 1024 //100MB限制 - if (file && file.name.toLowerCase().indexOf('png') == -1 && file.name.toLowerCase().indexOf('jpg') == -1 && file.name.toLowerCase().indexOf('jpeg') == -1) { - const config = new MatSnackBarConfig(); - config.verticalPosition = 'top'; - config.duration = 3000 - this.snackBar.open('请上传图片后缀为png,jpg,jpeg的文件', '确定', config); - return - } - - 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) - }) - } else if (file && fileSize > maxSize && fileSize < tenSize) { //上传文件5-100MB时 - let upload = this.canvasData.sectionUpload(sessionStorage.getItem('companyId'), file) - upload.then(res => { this.renovateBaseMap('/api/Objects/PlanPlatform/' + res, item) }) - } else { - const config = new MatSnackBarConfig(); - config.verticalPosition = 'top'; - config.duration = 3000 - this.snackBar.open('上传底图需小于100MB', '确定', config); - } - } - - //封装 替换底图 function - renovateBaseMap(e, item) { - let that = this - let img = new Image() - img.src = e - img.onload = function () { - 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 => { - let isSuccess = that.renovateSitePlan() - isSuccess.then(res => { - that.canvas.refreshBackgroundImage() - }) - const config = new MatSnackBarConfig(); - config.verticalPosition = 'top'; - config.duration = 3000 - that.snackBar.open('上传底图成功', '确定', config); - }) - } else { //楼层/区域 - that.http.put(`/api/BuildingAreas/${item.id}`, item, { params: that.params }).subscribe(data => { - let isSuccess = that.renovateBuilding() - isSuccess.then(res => { - that.canvas.refreshBackgroundImage() - }) - const config = new MatSnackBarConfig(); - config.verticalPosition = 'top'; - config.duration = 3000 - that.snackBar.open('上传底图成功', '确定', config); - }) - } //else - } //onload - } - - //封装 刷新总平面图 数据 - renovateSitePlan() { - return new Promise((resolve, reject) => { - this.http.get('/api/SitePlans', { params: this.params }).subscribe(data => { - this.sitePlanData = data - this.selectingSitePlan = this.sitePlanData[this.selectSitePlanIndex] - this.canvasData.selectStorey = this.sitePlanData[this.selectSitePlanIndex] //服务中 存一份数据 - this.canvasData.originaleveryStoreyData.sitePlanId ? null : this.canvasData.originaleveryStoreyData.sitePlanId = this.selectingSitePlan.id || null - const config = new MatSnackBarConfig(); - config.verticalPosition = 'top'; - config.duration = 3000 - this.snackBar.open('数据更新成功', '确定', config); - resolve('success') - }) - }) - } - - //封装 刷新 楼层/区域 数据 - renovateBuilding() { - let params = { - buildingId: this.beforeOneCheckedBuilding.id - } - return new Promise((resolve, reject) => { - this.http.get('/api/BuildingAreas', { params }).subscribe(data => { - this.sitePlanData = data - this.selectingSitePlan = this.sitePlanData[this.selectSitePlanIndex] - this.canvasData.selectStorey = this.sitePlanData[this.selectSitePlanIndex] //服务中 存一份数据 - this.canvasData.originaleveryStoreyData.buildingAreaId ? null : this.canvasData.originaleveryStoreyData.buildingAreaId = this.selectingSitePlan.id || null - const config = new MatSnackBarConfig(); - config.verticalPosition = 'top'; - config.duration = 3000 - this.snackBar.open('数据更新成功', '确定', config); - resolve('success') - }) - }) - } - - allLibrary: any = []; //所有素材库 + 素材 - selectLibrary: any; //选中的素材库 - selectImage: any; //选中的素材库图片 - selectImageIndex: number; //选中的素材库图片index - searchSettimeout: any; //延时器 - searchInput: string = null; //模糊搜索 input - searchLibrary: any = []; //模糊搜索 素材 - - //输入框 输入事件 - libraryChange() { - window.clearTimeout(this.searchSettimeout) - this.searchSettimeout = window.setTimeout(() => { - if (this.searchInput === "") { - this.searchLibrary = [] - } else { - this.http.get(`/api/Assets?assetName=${this.searchInput}`).subscribe((data: any) => { - this.searchLibrary = data - }) - } - }, 500) - } - - //获取素材库 - getAllLibrary(type: string = 'input') { - this.http.get(`/api/AssetLibraries?tag=${type}`).subscribe((data: any) => { - data.forEach(element => { - element.images = [] - }); - this.allLibrary = data - this.selectImageIndex = -1 - }) - } - - //素材库展开面板展开时 - opened(e) { - if (!e.images.length) { //当前素材库没加载素材时 - this.http.get(`/api/Assets?libraryId=${e.id}`).subscribe((data: any) => { - e.images = data - }) - } - } - - //点击选中素材库图片时 - selectImg(item, items, index) { - //如果是gis - this.selectLibrary = item.name - this.selectImage = JSON.parse(JSON.stringify(items)) - // console.log('选中图片',this.selectImage) - this.selectImageIndex = index - if (this.isGis) { - console.log(this.map) - - } else { - this.canvasData.selectTemplateData = items - this.canvas.beginPaint() - } - } - - //存储当前gis平面图的所有图标信息 - planData = [] - //存储当前gis平面图的所有marker信息 - planDataMarkers = [] - - //地图单击事件 - clickId - showInfoClick(e) { - if (!this.selectImage || !this.selectImage.imageUrl) { - return - } - this.canvasData.isChange = true - let id = ObjectID.default.generate() - // 新增点标记 - // 点标记显示内容,HTML要素字符串 - let markerContent = '' + - '
' + - `` + - `
X
` + - '
'; - - // 将 icon 传入 marker - let startMarker = new AMap.Marker({ - position: new AMap.LngLat(e.lnglat.lng, e.lnglat.lat), - // 将 html 传给 content - content: markerContent, - // 以 icon 的 [center bottom] 为原点 - offset: new AMap.Pixel(-13, -30), - draggable: true, - }); - - startMarker.id = id - startMarker.on('click', (e) => { - this.clickId = e.target.id - this.setAssetsProperty(this.canvasData.originaleveryStoreyData.data[e.target.id]) - }); - startMarker.on('dragend', (e) => { - // console.log('拖拽完成', e) - this.canvasData.isChange = true - this.clickId = e.target.id - this.canvasData.originaleveryStoreyData.data[e.target.id].Point = { x: e.lnglat.lng, y: e.lnglat.lat } - }); - - //将图标数据添加 - let itemData = JSON.parse(JSON.stringify(this.selectImage)) - itemData.id = id - itemData.point = { x: e.lnglat.lng, y: e.lnglat.lat } - itemData = this.canvasData.deserialize(JSON.stringify(itemData))//反序列化为大写 - // 添加楼层数据 - this.canvasData.originaleveryStoreyData.data[id] = itemData; - // 添加建筑数据 - this.canvasData.originalcompanyBuildingData.data[id] = itemData; - console.log('originalcompanyBuildingData', this.canvasData.originalcompanyBuildingData) - console.log('originaleveryStoreyData', this.canvasData.originaleveryStoreyData) - - //将marker点添加 - this.planDataMarkers.push(startMarker) - this.map.add(startMarker); - - } - - - - //处置预案 - allFirePlan: any = []; //所有灾情 - selectDisposalNode: string = ''; //当前点击tree节点 css选中样式 - - //获取所有灾情 - getAllFirePlan() { - let params = { componentId: sessionStorage.getItem('planId') } - this.http.get('/api/Disasters', { params: params }).subscribe((data: any) => { - if (!data.length) { //该 单位没有灾情时 - let msg = { - name: '灾情', - modifiedTime: new Date(), - planComponentId: sessionStorage.getItem('planId') - } - this.http.post('/api/Disasters', msg).subscribe(data => { - this.allFirePlan.push(data) - let params = { disasterId: this.allFirePlan[0].id || '' } - this.http.get('/api/DisposalNodes', { params: params }).subscribe(data => { //所有处置节点 - this.canvasData.allDisposalNode = data - }) - }) - } else { //单位 有灾情时 - this.allFirePlan = data - let params = { disasterId: this.allFirePlan[0].id || '' } - this.http.get('/api/DisposalNodes', { params: params }).subscribe(data => { //所有处置节点 - this.canvasData.allDisposalNode = data - }) - } - }) - } - - //获取所有处置节点 - getDisposalNode() { - this.selectDisposalNode = '' - let params = { disasterId: this.allFirePlan[0].id || '' } - this.http.get('/api/DisasterData/Markers', { params: params }).subscribe(data => { //灾情标签信息 - this.canvasData.allNodeMarkers = data - this.mateFireForce() - }) - this.http.get('/api/DisposalNodes', { params: params }).subscribe(data => { //处置节点 - this.canvasData.allDisposalNode = data - this.handleHybridTree() - }) - } - - treeData: any = []; //渲染tree处理完成数据 - defaultExpandedKeys: any = []; //首次渲染 tree展开状态 - //处理 节点 Tree数据 - handleHybridTree() { - this.defaultExpandedKeys = [] - let treeData = [] - let data = JSON.parse(JSON.stringify(this.canvasData.allDisposalNode || [])) - data.forEach(element => { - this.defaultExpandedKeys.push(element.id) - element.title = element.name //name - element.key = element.id //id - element.children = [] //children - if (element.sitePlanId || element.buildingAreaId) { //是数据节点 - element.isLeaf = true - element.isDataNode = true - } else { //不是数据节点 - element.isLeaf = false - element.isDataNode = false - } - data.forEach(item => { - item.parentId === element.id ? element.children.push(item) : null - }) - }); - data.forEach(element => { - !element.parentId ? treeData.push(element) : null - }) - this.treeData = [...treeData] - this.defaultExpandedKeys = [...this.defaultExpandedKeys] - } - - //刷新 treeData 保存已展开节点 - refurbishTreeData() { - this.defaultExpandedKeys = [] - let params = { disasterId: this.allFirePlan[0].id || '' } - this.http.get('/api/DisposalNodes', { params: params }).subscribe(nodeData => { //处置节点 - this.canvasData.allDisposalNode = nodeData - let oldTreeData = this.nzTreeComponent.getExpandedNodeList() - oldTreeData.forEach(item => { - this.defaultExpandedKeys.push(item.key) - }) - let treeData = [] - let data = JSON.parse(JSON.stringify(this.canvasData.allDisposalNode || [])) - data.forEach(element => { - element.title = element.name //name - element.key = element.id //id - element.children = [] //children - if (element.sitePlanId || element.buildingAreaId) { //是数据节点 - element.isLeaf = true - element.isDataNode = true - } else { //不是数据节点 - element.isLeaf = false - element.isDataNode = false - } - data.forEach(item => { - item.parentId === element.id ? element.children.push(item) : null - }) - }); - data.forEach(element => { - !element.parentId ? treeData.push(element) : null - }) - this.treeData = [...treeData] - this.defaultExpandedKeys = [...this.defaultExpandedKeys] - }) - } - - sitePlanIcon = { fire: 0, force: 0 } // 总平面图 火源/力量 图标 是否展示 - - //刷新 建筑楼层 匹配 火源/力量 图标 - mateFireForce() { - let data = this.canvasData.allNodeMarkers.markers || {} - for (let key in data) { //遍历 火/力量 图标 - this.sitePlanData.forEach(element => { //楼层 - if (element.id == key) { // 相匹配时 - data[key].fireCount != 0 ? element.fire = 1 : element.fire = 0 - data[key].forceCount != 0 ? element.force = 1 : element.force = 0 - } - }); - this.allBuildings.forEach(element => { //建筑 - if (element.id == key) { // 相匹配时 - data[key].fireCount != 0 ? element.fire = 1 : element.fire = 0 - data[key].forceCount != 0 ? element.force = 1 : element.force = 0 - } - }); - if (this.params.companyId == key) { //总平面图时 - data[key].fireCount != 0 ? this.sitePlanIcon.fire = 1 : this.sitePlanIcon.fire = 0 - data[key].forceCount != 0 ? this.sitePlanIcon.force = 1 : this.sitePlanIcon.force = 0 - } - } - - let buildingMSG = this.canvasData.allNodeMarkers.highlightMarkers || {} - for (let key in buildingMSG) { - if (key === this.canvasData.selectPanelPoint.DisposalNodeId) { - for (let keys in buildingMSG[key]) { - this.sitePlanData.forEach(element => { //楼层 - if (element.id === keys) { - buildingMSG[key][keys].fireCount != 0 ? element.fire = 2 : null - buildingMSG[key][keys].forceCount != 0 ? element.force = 2 : null - } - }); - this.allBuildings.forEach(element => { //建筑 - if (element.id === keys) { // 相匹配时 - buildingMSG[key][keys].fireCount != 0 ? element.fire = 2 : null - buildingMSG[key][keys].forceCount != 0 ? element.force = 2 : null - } - }); - if (this.params.companyId === keys) { //总平面图时 - buildingMSG[key][keys].fireCount != 0 ? this.sitePlanIcon.fire = 2 : null - buildingMSG[key][keys].forceCount != 0 ? this.sitePlanIcon.force = 2 : null - } - } - } - } - } - - // 切换 基本信息时 刷新 删除 建筑楼层 自定义属性 - mateDeleteCustomize() { - this.canvasData.selectPanelPointBaseData = { description: '', notes: '', weather: '', airTemperature: '', windDirection: '', windScale: '' } - this.defaultExpandedKeys = [] - this.sitePlanIcon = { fire: 0, force: 0 } - this.sitePlanData.forEach(element => { //楼层 - delete element.fire - delete element.force - }); - this.allBuildings.forEach(element => { //建筑 - delete element.fire - delete element.force - }); - } - - //计算差异 - countValue(e) { - e.stopPropagation() - let params = { disasterId: this.allFirePlan[0].id || '' } - this.http.get('/api/DisasterData/Diffs', { params: params }).subscribe(data => { - this.canvasData.allNodeMarkers = data - this.mateFireForce() - const config = new MatSnackBarConfig(); - config.verticalPosition = 'top'; - config.duration = 3000 - this.snackBar.open('计算差异完成', '确定', config); - }) - } - - //复制 处置预案 节点 - copyPanelPoint(e, item, treeData) { - e.stopPropagation() - if (confirm(`确定要复制 ${item.title} ?`)) { - let params = { id: item.origin.id } - let order - if (item.level == 0) { - treeData.length ? order = treeData[treeData.length - 1].order + 1 : order = 0 - } else { - let parent = item.getParentNode() //获取父节点 - parent.origin.children.length ? order = parent.origin.children[parent.origin.children.length - 1].order + 1 : order = 0 - } - let data = { - name: item.title + '(副本)', - level: item.level, - order: order, - description: '', - disasterId: item.origin.disasterId || '', - parentId: item.origin.parentId || null, - planComponentId: item.origin.planComponentId || '', - } - this.http.post('/api/DisposalNodes/Clone', data, { params: params }).subscribe(data => { - this.refurbishTreeData() - }) - } //isTrue - } - - //删除 处置预案 节点 - deletePanelPoint(e, item) { - e.stopPropagation() - if (confirm(`确定要删除 ${item.name} ?`)) { - this.http.delete(`/api/DisposalNodes/${item.id}`).subscribe(data => { - this.refurbishTreeData() - }) - } - } - - //点击 处置Tree节点 - selectanelPoint(e) { - if (!e.buildingAreaId && !e.sitePlanId) { //当前节点 不是 数据节点 时 - let msg = this.canvasData.findDisposalNode(e.id) - this.canvasData.selectPanelPointBaseData = msg - this.selectDisposalNode == msg.id ? this.selectDisposalNode = '' : this.selectDisposalNode = msg.id //选中 节点 - - } else if (e.buildingAreaId || e.sitePlanId) { //当前节点 是 数据节点 时 - let msg = this.canvasData.findDisposalNode(e.parentId) - this.canvasData.selectPanelPointBaseData = msg - this.selectDisposalNode = e.parentId //选中 节点 - - if (this.canvasData.selectPanelPoint.DisposalNodeId != e.id) { //选择节点 不是当前节点时 - let params = { nodeId: e.id } - let parameter = { //查询 节点 对应 建筑/楼层 index,id - buildingIndex: e.sitePlanId ? -1 : this.allBuildings.findIndex(item => { return item.id === e.buildingId }), //总平面图/建筑 index - storeyId: e.sitePlanId ? e.sitePlanId : e.buildingAreaId, //楼层id + //查找 数据节点 对应 建筑/楼层 + seekPanelPoint(paramsData) { + this.checkedBuildingIndex = paramsData.buildingIndex + if (paramsData.buildingIndex == -1) { //总平面图时 + this.beforeOneCheckedBuilding = { name: "总平面图" } + let fireData = this.getFireElements(sessionStorage.getItem('buildingTypeId')) //获取单位下 消防要素 + let planData = this.getSitePlanCompanyData() //获取 单位 数据 + this.http.get('/api/SitePlans', { params: this.params }).subscribe(data => { + this.sitePlanData = data + let index = this.sitePlanData.findIndex(item => { return item.id === paramsData.storeyId }) + this.selectingSitePlan = this.sitePlanData[index] || {} + this.canvasData.selectStorey = this.sitePlanData[index] || {} //服务中 存一份数据 + this.selectSitePlanIndex = index + + Promise.all([fireData, planData]).then((res) => { + this.getSitePlanStorey(this.selectingSitePlan) //获取 平面图 楼层数据 + }) + }) //get + } else { //建筑时 + this.beforeOneCheckedBuilding = this.allBuildings[paramsData.buildingIndex] + let params = { buildingId: this.beforeOneCheckedBuilding.id } + let fireData = this.getFireElements(this.beforeOneCheckedBuilding.buildingTypes[0].id || '') //获取建筑下 消防要素 + let planData = this.getBuildingData(params) //获取 建筑 数据 + this.http.get('/api/BuildingAreas', { params }).subscribe(data => { + this.sitePlanData = data + let index = this.sitePlanData.findIndex(item => { return item.id === paramsData.storeyId }) + this.selectingSitePlan = this.sitePlanData[index] || {} + this.canvasData.selectStorey = this.sitePlanData[index] || {} //服务中 存一份数据 + this.selectSitePlanIndex = index + + Promise.all([fireData, planData]).then((res) => { + this.getBuildingStorey(this.selectingSitePlan) //获取 建筑 楼层数据 + }) + }) //get } - this.http.get('/api/DisposalNodeData', { params: params }).subscribe(data => { - this.canvasData.selectPanelPoint = this.canvasData.deserialize(JSON.stringify(data || new DisposalNodeData())) //选择 当前 节点 - this.canvasData.selectPanelPoint.Data = this.canvasData.deserialize(this.canvasData.selectPanelPoint.Data) - this.seekPanelPoint(parameter) - }) - } //if - - } //else if - } - - //查找 数据节点 对应 建筑/楼层 - seekPanelPoint(paramsData) { - this.checkedBuildingIndex = paramsData.buildingIndex - if (paramsData.buildingIndex == -1) { //总平面图时 - this.beforeOneCheckedBuilding = { name: "总平面图" } - let fireData = this.getFireElements(sessionStorage.getItem('buildingTypeId')) //获取单位下 消防要素 - let planData = this.getSitePlanCompanyData() //获取 单位 数据 - this.http.get('/api/SitePlans', { params: this.params }).subscribe(data => { - this.sitePlanData = data - let index = this.sitePlanData.findIndex(item => { return item.id === paramsData.storeyId }) - this.selectingSitePlan = this.sitePlanData[index] || {} - this.canvasData.selectStorey = this.sitePlanData[index] || {} //服务中 存一份数据 - this.selectSitePlanIndex = index - - Promise.all([fireData, planData]).then((res) => { - this.getSitePlanStorey(this.selectingSitePlan) //获取 平面图 楼层数据 - }) - }) //get - } else { //建筑时 - this.beforeOneCheckedBuilding = this.allBuildings[paramsData.buildingIndex] - let params = { buildingId: this.beforeOneCheckedBuilding.id } - let fireData = this.getFireElements(this.beforeOneCheckedBuilding.buildingTypes[0].id || '') //获取建筑下 消防要素 - let planData = this.getBuildingData(params) //获取 建筑 数据 - this.http.get('/api/BuildingAreas', { params }).subscribe(data => { - this.sitePlanData = data - let index = this.sitePlanData.findIndex(item => { return item.id === paramsData.storeyId }) - this.selectingSitePlan = this.sitePlanData[index] || {} - this.canvasData.selectStorey = this.sitePlanData[index] || {} //服务中 存一份数据 - this.selectSitePlanIndex = index - - Promise.all([fireData, planData]).then((res) => { - this.getBuildingStorey(this.selectingSitePlan) //获取 建筑 楼层数据 - }) - }) //get } - } @@ -2576,107 +2580,107 @@ export class CollectionToolsPlanComponent implements OnInit { //创建建筑 @Component({ - selector: 'app-createBuilding-plan', - templateUrl: './createBuilding.html', - styleUrls: ['./collection-tools.component.scss'] + selector: 'app-createBuilding-plan', + templateUrl: './createBuilding.html', + styleUrls: ['./collection-tools.component.scss'] }) export class CreateBuildingPlan { - constructor(private http: HttpClient, public dialog: MatDialog, public dialogRef: MatDialogRef, @Inject(MAT_DIALOG_DATA) public data) { } - - allBuildingType: any//所有的建筑类型 - selected: any; //选中的建筑 - ngOnInit(): void { - this.getAllBuildingType() - } - - //获得所有单位类型 - getAllBuildingType() { - this.http.get("/api/BuildingTypes/Simple").subscribe(data => { - this.allBuildingType = data - }) - } - - //创建建筑功能分区 - onSubmit(e) { - let companyId = sessionStorage.getItem("companyId") - let lastBuildingOrder = this.data.allBuildings.length != 0 ? this.data.allBuildings[this.data.allBuildings.length - 1].order + 1 : 0 - let data = - { - id: "", - name: e.propertyName, - order: lastBuildingOrder, - enabled: true, - companyId: companyId, - buildingTypes: [ + constructor(private http: HttpClient, public dialog: MatDialog, public dialogRef: MatDialogRef, @Inject(MAT_DIALOG_DATA) public data) { } + + allBuildingType: any//所有的建筑类型 + selected: any; //选中的建筑 + ngOnInit(): void { + this.getAllBuildingType() + } + + //获得所有单位类型 + getAllBuildingType() { + this.http.get("/api/BuildingTypes/Simple").subscribe(data => { + this.allBuildingType = data + }) + } + + //创建建筑功能分区 + onSubmit(e) { + let companyId = sessionStorage.getItem("companyId") + let lastBuildingOrder = this.data.allBuildings.length != 0 ? this.data.allBuildings[this.data.allBuildings.length - 1].order + 1 : 0 + let data = { - id: e.buildingId, - name: "" + id: "", + name: e.propertyName, + order: lastBuildingOrder, + enabled: true, + companyId: companyId, + buildingTypes: [ + { + id: e.buildingId, + name: "" + } + ] } - ] - } - this.http.post("/api/Buildings", data, { - params: { - companyId: this.data.companyId - } - }).subscribe(data => { - this.dialogRef.close("创建成功"); - }, err => { - this.dialogRef.close("创建失败"); - }) - } + this.http.post("/api/Buildings", data, { + params: { + companyId: this.data.companyId + } + }).subscribe(data => { + this.dialogRef.close("创建成功"); + }, err => { + this.dialogRef.close("创建失败"); + }) + } } //编辑建筑 @Component({ - selector: 'app-editBuilding-plan', - templateUrl: './editBuilding.html', - styleUrls: ['./collection-tools.component.scss'] + selector: 'app-editBuilding-plan', + templateUrl: './editBuilding.html', + styleUrls: ['./collection-tools.component.scss'] }) 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//所有的建筑类型 - - ngOnInit(): void { - this.getAllBuildingType() - } - - getAllBuildingType() { - this.http.get("/api/BuildingTypes/Simple").subscribe(data => { - this.allBuildingType = data - }) - } - - //编辑建筑信息 - onSubmit(e) { - let companyId = sessionStorage.getItem("companyId") - let data = - { - id: this.data.item.id, - name: e.propertyName, - order: this.data.item.order, - enabled: true, - companyId: companyId, - buildingTypes: [ + constructor(private http: HttpClient, public dialog: MatDialog, public dialogRef: MatDialogRef, @Inject(MAT_DIALOG_DATA) public data) { } + + defaultName: String = this.data.item.name//默认建筑名称 + defaultBuildingType: String = this.data.item.buildingTypes[0].id//默认建筑类型 + allBuildingType: any//所有的建筑类型 + + ngOnInit(): void { + this.getAllBuildingType() + } + + getAllBuildingType() { + this.http.get("/api/BuildingTypes/Simple").subscribe(data => { + this.allBuildingType = data + }) + } + + //编辑建筑信息 + onSubmit(e) { + let companyId = sessionStorage.getItem("companyId") + let data = { - id: e.buildingId, - name: "" + id: this.data.item.id, + name: e.propertyName, + order: this.data.item.order, + enabled: true, + companyId: companyId, + buildingTypes: [ + { + id: e.buildingId, + name: "" + } + ] } - ] - } - this.http.put(`/api/Buildings/${this.data.item.id}`, data, { - params: { - id: this.data.item.id, - companyId: companyId - } - }).subscribe(data => { - this.dialogRef.close("修改成功"); - }, err => { - this.dialogRef.close("修改失败"); - }) - } + this.http.put(`/api/Buildings/${this.data.item.id}`, data, { + params: { + id: this.data.item.id, + companyId: companyId + } + }).subscribe(data => { + this.dialogRef.close("修改成功"); + }, err => { + this.dialogRef.close("修改失败"); + }) + } } diff --git a/src/modules/map/declare/factory.ts b/src/modules/map/declare/factory.ts new file mode 100644 index 0000000..6182f98 --- /dev/null +++ b/src/modules/map/declare/factory.ts @@ -0,0 +1,24 @@ +const mapSupplier: number = 1;//1:高德 + +import { IMap, IMapOptions, IPixel } from './map' +import { GaoDeMap, GaoDePixel } from './gaode-map' +import { KeDaMap, KeDaPixel } from './keda-map'; + + +export class MapFactory { + public static MapInstance(container: string, options: IMapOptions | any): IMap { + switch (mapSupplier) { + case 1: return new GaoDeMap(container, options); + case 2: return new KeDaMap(container, options); + default: return null; + } + } + + public static PixelInstance(x: number, y: number): IPixel { + switch (mapSupplier) { + case 1: return new GaoDePixel(x, y); + case 2: return new KeDaPixel(x, y); + default: return null; + } + } +} diff --git a/src/modules/map/declare/gaode-map.ts b/src/modules/map/declare/gaode-map.ts new file mode 100644 index 0000000..22a2111 --- /dev/null +++ b/src/modules/map/declare/gaode-map.ts @@ -0,0 +1,33 @@ +import { IMap, IMapOptions, IMarker, IPixel } from './map' +declare var AMap: any; + + +export class GaoDeMap implements IMap { + self: any;//AMap.Map + constructor(container: string, options: IMapOptions) { + this.self = new AMap.Map(container, options); + } + getCenter() { + return this.self.getCenter(); + } + getZoom() { + return this.self.getZoom(); + } + on(eventName: string, callback: Function): void { + this.self.on(eventName, callback); + } +} + +export class GaoDePixel implements IPixel { + self: any; + constructor(x: number, y: number) { + this.self = new AMap.Pixel(x, y); + } +} + +export class GaoDeMarker implements IMarker { + self: any; + constructor(options: any) { + this.self = new AMap.Marker(options); + } +} \ No newline at end of file diff --git a/src/modules/map/declare/keda-map.ts b/src/modules/map/declare/keda-map.ts new file mode 100644 index 0000000..8ad9ab3 --- /dev/null +++ b/src/modules/map/declare/keda-map.ts @@ -0,0 +1,45 @@ +import { IMap, IMapOptions, IMarker, IPixel } from './map' +declare var KMap: any; +import $ from 'jquery'; + +export class KeDaMap implements IMap { + self: any; + constructor(container: string, options: IMapOptions) { + let opt = Object.assign({}, { containerId: container }, options) as any; + opt.configUrl = ""; + this.self = new KMap(opt); + } + on(eventName: string, callback: Function): void { + let eventMapProfile = { + complete: "load", + click: "click", + rightclick: "contextmenu" + }; + this.self.addEventOnMap({ + event: eventMapProfile[eventName], + handler: callback + }); + } +} + +export class KeDaPixel implements IPixel { + self: any; + constructor(x: number, y: number) { + this.self = [x, y]; + } +} + +export class KeDaMarker implements IMarker { + self: any; + constructor(options: any) { + let element = $(options.content)[0]; + let d = { + offset: options.offset, + element: element + }; + + + + this.self = d; + } +} \ No newline at end of file diff --git a/src/modules/map/declare/map.d.ts b/src/modules/map/declare/map.d.ts new file mode 100644 index 0000000..4aa3946 --- /dev/null +++ b/src/modules/map/declare/map.d.ts @@ -0,0 +1,29 @@ +//AMap.Circle +//AMap.Map +//AMap.Icon +//AMap.Pixel +//AMap.LngLat + +export interface ISelf { + self: any; +} + +export interface IMap extends ISelf { + on(eventName: string, callback: Function): void; + getZoom(): any; + getCenter(): any; +} + +export interface IMapOptions { + zoom?: number; + zooms?: number[]; +} + +export interface IMarker extends ISelf { + +} + + +export interface IPixel extends ISelf { + +} diff --git a/tsconfig.json b/tsconfig.json index a7aa874..fffdf4d 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -18,7 +18,10 @@ "lib": [ "es2018", "dom" - ] + ], + "paths": { + "@src/*":["src/*"] + } }, "angularCompilerOptions": { "fullTemplateTypeCheck": true,