|
|
|
@ -17,8 +17,14 @@ 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'; |
|
|
|
|
declare var AMap: any |
|
|
|
|
|
|
|
|
|
declare global { |
|
|
|
|
interface Window { |
|
|
|
|
deleteMarker: any; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
declare var AMap:any |
|
|
|
|
@Component({ |
|
|
|
|
selector: 'app-collection-tools-plan', |
|
|
|
|
templateUrl: './collection-tools.component.html', |
|
|
|
@ -28,7 +34,7 @@ export class CollectionToolsPlanComponent implements OnInit {
|
|
|
|
|
|
|
|
|
|
@ViewChild('canvas') canvas: WorkingAreaComponent; //父组件中获得子组件的引用
|
|
|
|
|
|
|
|
|
|
constructor(public _ngZone: NgZone, private maskLayerService: MaskLayerService, private tabbarService: TabbarAndScoreService, private http: HttpClient, public dialog: MatDialog, public snackBar: MatSnackBar, private element: ElementRef, public canvasData: CanvasShareDataService, private router: Router, private route: ActivatedRoute) { } |
|
|
|
|
constructor(public 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) => {//要给渲染节点传那些属性参数
|
|
|
|
@ -80,6 +86,7 @@ export class CollectionToolsPlanComponent implements OnInit {
|
|
|
|
|
gallery//viewerJs实例
|
|
|
|
|
//设置属性框
|
|
|
|
|
setAssetsProperty(obj) { |
|
|
|
|
console.log(obj) |
|
|
|
|
//初始化viewerJs实例
|
|
|
|
|
setTimeout(() => { |
|
|
|
|
obj.PropertyInfos.forEach(item => { |
|
|
|
@ -465,11 +472,12 @@ export class CollectionToolsPlanComponent implements OnInit {
|
|
|
|
|
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)
|
|
|
|
|
console.log('单选', this.canvas.selection.first().assetData) |
|
|
|
|
this.setAssetsProperty(this.canvas.selection.first().assetData) |
|
|
|
|
} else if (this.canvas.selection.size()) { |
|
|
|
|
this.isShowProperty = true |
|
|
|
@ -1227,6 +1235,21 @@ export class CollectionToolsPlanComponent implements OnInit {
|
|
|
|
|
} |
|
|
|
|
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) { |
|
|
|
@ -1301,7 +1324,7 @@ export class CollectionToolsPlanComponent implements OnInit {
|
|
|
|
|
//封装 刷新 tree 数据
|
|
|
|
|
async renovateTreeData(isRefresh: boolean = true) { |
|
|
|
|
// this.allFireElements[this.allFireElements.length-1].children = []
|
|
|
|
|
if(!this.selectingSitePlan.isGis){ |
|
|
|
|
if (!this.selectingSitePlan.isGis) { |
|
|
|
|
isRefresh ? await this.canvas.refresh() : null |
|
|
|
|
this.canvas.setNameVisible(this.basicInfo, 0) |
|
|
|
|
this.canvas.setNameVisible(this.wantToWork, 1) |
|
|
|
@ -1309,34 +1332,37 @@ export class CollectionToolsPlanComponent implements OnInit {
|
|
|
|
|
isRefresh ? this.canvasData.isChange = false : null //服务中 数据是否改动 改为false
|
|
|
|
|
isRefresh ? this.isShowProperty = true : null |
|
|
|
|
isRefresh ? this.isShowAttribute = true : null |
|
|
|
|
}else{ |
|
|
|
|
} 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(){ |
|
|
|
|
this.map = new AMap.Map('container', { |
|
|
|
|
|
|
|
|
|
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() { |
|
|
|
|
this.map = new AMap.Map('planContainer', { |
|
|
|
|
viewMode: '2D', // 默认使用 2D 模式,如果希望使用带有俯仰角的 3D 模式,请设置 viewMode: '3D',
|
|
|
|
|
zoom:11, //初始化地图层级
|
|
|
|
|
center: [116.397428, 39.90923] //初始化地图中心点
|
|
|
|
|
zoom: 11, //初始化地图层级
|
|
|
|
|
}); |
|
|
|
|
this.map.setCity('上海市'); |
|
|
|
|
this.map.on('click', (e) => { |
|
|
|
|
this.showInfoClick(e) |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -1388,15 +1414,15 @@ export class CollectionToolsPlanComponent implements OnInit {
|
|
|
|
|
|
|
|
|
|
//获取总平面图
|
|
|
|
|
getSitePlan() { |
|
|
|
|
// let fireData = this.getFireElements(sessionStorage.getItem('buildingTypeId')) //获取单位下 消防要素
|
|
|
|
|
let fireData = this.getFireElements(sessionStorage.getItem('buildingTypeId')) //获取单位下 消防要素
|
|
|
|
|
let planData = this.getSitePlanCompanyData() //获取 单位 数据
|
|
|
|
|
this.http.get('/api/SitePlans', { params: this.params }).subscribe(data => { |
|
|
|
|
this.sitePlanData = data |
|
|
|
|
this.selectingSitePlan = this.sitePlanData[0] || {} |
|
|
|
|
this.canvasData.selectStorey = this.sitePlanData[0] || {} //服务中 存一份数据
|
|
|
|
|
if(this.sitePlanData.length != 0 && this.sitePlanData[0].isGis){ |
|
|
|
|
if (this.sitePlanData.length != 0 && this.sitePlanData[0].isGis) { |
|
|
|
|
this.isGis = true |
|
|
|
|
}else{ |
|
|
|
|
} else { |
|
|
|
|
this.isGis = false |
|
|
|
|
} |
|
|
|
|
this.selectSitePlanIndex = 0 |
|
|
|
@ -1411,7 +1437,7 @@ export class CollectionToolsPlanComponent implements OnInit {
|
|
|
|
|
//获取建筑 楼层/区域 废弃
|
|
|
|
|
getBuildingSitePlan(item) { |
|
|
|
|
let params = { buildingId: item.id } |
|
|
|
|
// let fireData = this.getFireElements(item.buildingTypes[0].id || '') //获取建筑下 消防要素
|
|
|
|
|
let fireData = this.getFireElements(item.buildingTypes[0].id || '') //获取建筑下 消防要素
|
|
|
|
|
let planData = this.getBuildingData(params) //获取 建筑 数据
|
|
|
|
|
this.http.get('/api/BuildingAreas', { params }).subscribe(data => { |
|
|
|
|
this.sitePlanData = data |
|
|
|
@ -1452,6 +1478,7 @@ export class CollectionToolsPlanComponent implements OnInit {
|
|
|
|
|
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" |
|
|
|
@ -1465,6 +1492,7 @@ export class CollectionToolsPlanComponent implements OnInit {
|
|
|
|
|
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" |
|
|
|
@ -1499,12 +1527,12 @@ export class CollectionToolsPlanComponent implements OnInit {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//点击选中 平面图 楼层/区域 时
|
|
|
|
|
isGis:boolean |
|
|
|
|
isGis: boolean |
|
|
|
|
selectSitePlan(item, index) { |
|
|
|
|
console.log('点击楼层',item) |
|
|
|
|
if(item.isGis){ |
|
|
|
|
console.log('点击楼层', item) |
|
|
|
|
if (item.isGis) { |
|
|
|
|
this.isGis = true |
|
|
|
|
}else{ |
|
|
|
|
} else { |
|
|
|
|
this.isGis = false |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -1654,7 +1682,7 @@ export class CollectionToolsPlanComponent implements OnInit {
|
|
|
|
|
|
|
|
|
|
//旋转底图
|
|
|
|
|
revolveImg(item) { |
|
|
|
|
if(item.isGis){ |
|
|
|
|
if (item.isGis) { |
|
|
|
|
const config = new MatSnackBarConfig(); |
|
|
|
|
config.verticalPosition = 'top'; |
|
|
|
|
config.duration = 3000 |
|
|
|
@ -1744,7 +1772,7 @@ export class CollectionToolsPlanComponent implements OnInit {
|
|
|
|
|
//复制图层 平面图 楼层/区域
|
|
|
|
|
duplicateLayer(item) { |
|
|
|
|
|
|
|
|
|
if(item.isGis){ |
|
|
|
|
if (item.isGis) { |
|
|
|
|
const config = new MatSnackBarConfig(); |
|
|
|
|
config.verticalPosition = 'top'; |
|
|
|
|
config.duration = 3000 |
|
|
|
@ -1938,11 +1966,102 @@ export class CollectionToolsPlanComponent implements OnInit {
|
|
|
|
|
|
|
|
|
|
//点击选中素材库图片时
|
|
|
|
|
selectImg(item, items, index) { |
|
|
|
|
//如果是gis
|
|
|
|
|
this.selectLibrary = item.name |
|
|
|
|
this.selectImage = items |
|
|
|
|
// console.log('选中图片',this.selectImage)
|
|
|
|
|
this.selectImageIndex = index |
|
|
|
|
this.canvasData.selectTemplateData = items |
|
|
|
|
this.canvas.beginPaint() |
|
|
|
|
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.imageUrl) { |
|
|
|
|
return |
|
|
|
|
} |
|
|
|
|
let id = ObjectID.default.generate() |
|
|
|
|
// console.log('点击了地图', e)
|
|
|
|
|
|
|
|
|
|
// 新增点标记
|
|
|
|
|
// 点标记显示内容,HTML要素字符串
|
|
|
|
|
let markerContent = '' + |
|
|
|
|
'<div class="custom-content-marker" id="xxxx">' + |
|
|
|
|
`<img src="${this.selectImage.imageUrl}">` + |
|
|
|
|
`<div class="close-btn" id="${id}" onclick='deleteMarker()'>X</div>` + |
|
|
|
|
'</div>'; |
|
|
|
|
|
|
|
|
|
// 将 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 |
|
|
|
|
for (let index = 0; index < this.planData.length; index++) { |
|
|
|
|
const item = this.planData[index]; |
|
|
|
|
if (item.id == e.target.id) { |
|
|
|
|
this.setAssetsProperty(item) |
|
|
|
|
return |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
startMarker.on('dragend', (e) => { |
|
|
|
|
console.log('拖拽完成', e) |
|
|
|
|
this.clickId = e.target.id |
|
|
|
|
for (let index = 0; index < this.planData.length; index++) { |
|
|
|
|
const item = this.planData[index]; |
|
|
|
|
if (item.id == e.target.id) { |
|
|
|
|
//修改最终坐标数据
|
|
|
|
|
item.point = { x: e.lnglat.lng, y: e.lnglat.lat } |
|
|
|
|
return |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
//将图标数据添加
|
|
|
|
|
let itemData = JSON.parse(JSON.stringify(this.selectImage)) |
|
|
|
|
itemData.id = id |
|
|
|
|
itemData.point = { x: e.lnglat.lng, y: e.lnglat.lat } |
|
|
|
|
this.planData.push(itemData) |
|
|
|
|
//将marker点添加
|
|
|
|
|
this.planDataMarkers.push(startMarker) |
|
|
|
|
this.map.add(startMarker); |
|
|
|
|
//点击关闭按钮
|
|
|
|
|
window.deleteMarker = () => { |
|
|
|
|
//清除地图标点
|
|
|
|
|
this.planDataMarkers.forEach((element, index) => { |
|
|
|
|
if (element.id == this.clickId) { |
|
|
|
|
this.planDataMarkers[index].setMap(null); |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
//删除指定数据
|
|
|
|
|
for (let index = 0; index < this.planData.length; index++) { |
|
|
|
|
const item = this.planData[index]; |
|
|
|
|
if (item.id == this.clickId) { |
|
|
|
|
this.planData.splice(index, 1) |
|
|
|
|
return |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|