|
|
|
@ -1,4 +1,4 @@
|
|
|
|
|
import { Component, OnInit, Inject ,ViewChild} from '@angular/core'; |
|
|
|
|
import { Component, OnInit, Inject ,ViewChild, ElementRef, Renderer2} from '@angular/core'; |
|
|
|
|
import { MatTreeFlatDataSource, MatTreeFlattener } from '@angular/material/tree'; |
|
|
|
|
import { FlatTreeControl } from '@angular/cdk/tree'; |
|
|
|
|
import { HttpClient,HttpHeaders, HttpEventType } from '@angular/common/http'; |
|
|
|
@ -21,6 +21,7 @@ import * as _ from 'lodash';
|
|
|
|
|
import { LookMaster } from './lookmaster.component' |
|
|
|
|
import { Router,ActivatedRoute } from '@angular/router' |
|
|
|
|
import { TabbarAndScoreService } from 'src/app/http-interceptors/tabbar-and-score.service'; |
|
|
|
|
declare var AMap: any; |
|
|
|
|
|
|
|
|
|
@Component({ |
|
|
|
|
selector: 'app-basicinfo', |
|
|
|
@ -85,7 +86,7 @@ export class BasicinfoComponent implements OnInit {
|
|
|
|
|
buildingCustomData:any //存储当前建筑的自定义信息
|
|
|
|
|
allunittype: any //所有单位类型
|
|
|
|
|
allorganizing:any = [] //所有组织机构
|
|
|
|
|
constructor(private tabbarService: TabbarAndScoreService,private router:Router,private route:ActivatedRoute,private http: HttpClient, private tree: TreeService, private sanitizer: DomSanitizer, public dialog: MatDialog,public snackBar: MatSnackBar) { } |
|
|
|
|
constructor(private elementRef: ElementRef,public renderer2: Renderer2,private tabbarService: TabbarAndScoreService,private router:Router,private route:ActivatedRoute,private http: HttpClient, private tree: TreeService, private sanitizer: DomSanitizer, public dialog: MatDialog,public snackBar: MatSnackBar) { } |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
unitId : any //当前单位id
|
|
|
|
@ -97,6 +98,166 @@ export class BasicinfoComponent implements OnInit {
|
|
|
|
|
this.unitId = this.route.snapshot.queryParams.id |
|
|
|
|
sessionStorage.setItem("companyId",this.route.snapshot.queryParams.id); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
isMapLabel:boolean |
|
|
|
|
//地图标注位置
|
|
|
|
|
markerPosition:any = {x: 0, y: 0}//单位坐标
|
|
|
|
|
map:any //地图实例
|
|
|
|
|
isGisTopBox:boolean = false//点击位置按钮
|
|
|
|
|
oldPositionMarker:any //旧位置marker实例
|
|
|
|
|
newPositionMarker:any //新位置marker实例
|
|
|
|
|
|
|
|
|
|
newPositionMarkerContent:any =
|
|
|
|
|
'<div class="custom-content-marker">' + |
|
|
|
|
' <img src="/assets/images/newposition.png">' + |
|
|
|
|
'</div>' |
|
|
|
|
newPositionMarkerContentBtn:any =
|
|
|
|
|
'<div class="custom-content-marker">' + |
|
|
|
|
' <img src="/assets/images/newposition.png">' + |
|
|
|
|
' <div class="btnbox"><img id="setPositionOk" src="/assets/images/ok.png"><span>|</span><img id="setPositionClose" src="/assets/images/close.png"></div>' + |
|
|
|
|
'</div>' |
|
|
|
|
oldPositionMarkerContent:any =
|
|
|
|
|
'<div class="custom-content-marker">' + |
|
|
|
|
' <img src="/assets/images/oldposition.png">' + |
|
|
|
|
'</div>' |
|
|
|
|
//初始化地图
|
|
|
|
|
labelGis(){ |
|
|
|
|
this.map = new AMap.Map('container', { |
|
|
|
|
zoom:12 |
|
|
|
|
}) |
|
|
|
|
this.map.on('complete', () => { |
|
|
|
|
this.isGisTopBox = true |
|
|
|
|
}); |
|
|
|
|
if(this.isMapLabel){//如果已经标注单位坐标
|
|
|
|
|
console.log('已标注单位位置') |
|
|
|
|
this.map.setCenter([this.unitinfo.location.x,this.unitinfo.location.y]); |
|
|
|
|
this.oldPositionMarker = new AMap.Marker({ |
|
|
|
|
position: [this.unitinfo.location.x,this.unitinfo.location.y], |
|
|
|
|
content: this.newPositionMarkerContent, |
|
|
|
|
offset: new AMap.Pixel(-15, -18) |
|
|
|
|
}) |
|
|
|
|
// 将 markers 添加到地图
|
|
|
|
|
this.map.add(this.oldPositionMarker); |
|
|
|
|
}else{ |
|
|
|
|
console.log('未标注单位位置') |
|
|
|
|
this.map.setCity('上海市'); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
//点击位置按钮
|
|
|
|
|
setPosition(){ |
|
|
|
|
this.isGisTopBox = false |
|
|
|
|
if(this.isMapLabel){//如果已经标注单位坐标
|
|
|
|
|
console.log('已标注单位位置') |
|
|
|
|
|
|
|
|
|
if(this.oldPositionMarker){ |
|
|
|
|
this.oldPositionMarker.setContent(this.oldPositionMarkerContent) |
|
|
|
|
} |
|
|
|
|
if(this.newPositionMarker){ |
|
|
|
|
this.newPositionMarker.setContent(this.oldPositionMarkerContent) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
this.newPositionMarker = new AMap.Marker({ |
|
|
|
|
draggable: true, |
|
|
|
|
position: [this.markerPosition.x,this.markerPosition.y], |
|
|
|
|
content: this.newPositionMarkerContentBtn, |
|
|
|
|
offset: new AMap.Pixel(-15, -18) |
|
|
|
|
}); |
|
|
|
|
this.map.add(this.newPositionMarker); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let markerPosition
|
|
|
|
|
if(this.markerPosition.x && this.markerPosition.x != 0){ |
|
|
|
|
markerPosition = {x: this.markerPosition.x,y: this.markerPosition.y} |
|
|
|
|
}else{ |
|
|
|
|
markerPosition = {x: this.map.getCenter().lng,y: this.map.getCenter().lat} //获取当前地图中心位置
|
|
|
|
|
} |
|
|
|
|
this.newPositionMarker.on('dragend', (e)=>{ |
|
|
|
|
markerPosition = {x: e.lnglat.lng, y: e.lnglat.lat} |
|
|
|
|
}) |
|
|
|
|
//点击确定
|
|
|
|
|
this.renderer2.listen(this.elementRef.nativeElement.querySelector('#setPositionOk'),'click',(event)=>{
|
|
|
|
|
this.map.clearMap(); |
|
|
|
|
this.isGisTopBox = true |
|
|
|
|
this.newPositionMarker = new AMap.Marker({ |
|
|
|
|
position: [markerPosition.x,markerPosition.y], |
|
|
|
|
content: this.newPositionMarkerContent, |
|
|
|
|
offset: new AMap.Pixel(-15, -18) |
|
|
|
|
}); |
|
|
|
|
this.markerPosition = markerPosition |
|
|
|
|
this.map.add(this.newPositionMarker); |
|
|
|
|
}) |
|
|
|
|
//点击取消
|
|
|
|
|
this.renderer2.listen(this.elementRef.nativeElement.querySelector('#setPositionClose'),'click',(event)=>{
|
|
|
|
|
this.isGisTopBox = true |
|
|
|
|
this.map.clearMap(); |
|
|
|
|
this.newPositionMarker = new AMap.Marker({ |
|
|
|
|
position: [this.markerPosition.x,this.markerPosition.y], |
|
|
|
|
content: this.newPositionMarkerContent, |
|
|
|
|
offset: new AMap.Pixel(-15, -18) |
|
|
|
|
}); |
|
|
|
|
this.map.add(this.newPositionMarker);
|
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
}else{ |
|
|
|
|
console.log('未标注单位位置') |
|
|
|
|
if(this.newPositionMarker){ |
|
|
|
|
this.newPositionMarker.setContent(this.oldPositionMarkerContent) |
|
|
|
|
} |
|
|
|
|
let center |
|
|
|
|
if(this.markerPosition.x && this.markerPosition.x != 0){ |
|
|
|
|
center = [this.markerPosition.x,this.markerPosition.y] |
|
|
|
|
}else{ |
|
|
|
|
center = this.map.getCenter(); //获取当前地图中心位置
|
|
|
|
|
this.map.setCenter(center); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
this.newPositionMarker = new AMap.Marker({ |
|
|
|
|
draggable: true, |
|
|
|
|
position: center, |
|
|
|
|
content: this.newPositionMarkerContentBtn, |
|
|
|
|
offset: new AMap.Pixel(-15, -18) |
|
|
|
|
}); |
|
|
|
|
this.map.add(this.newPositionMarker); |
|
|
|
|
|
|
|
|
|
let markerPosition
|
|
|
|
|
if(this.markerPosition.x && this.markerPosition.x != 0){ |
|
|
|
|
markerPosition = {x: this.markerPosition.x,y: this.markerPosition.y} |
|
|
|
|
}else{ |
|
|
|
|
markerPosition = {x: this.map.getCenter().lng,y: this.map.getCenter().lat} //获取当前地图中心位置
|
|
|
|
|
} |
|
|
|
|
this.newPositionMarker.on('dragend', (e)=>{ |
|
|
|
|
markerPosition = {x: e.lnglat.lng, y: e.lnglat.lat} |
|
|
|
|
}) |
|
|
|
|
//点击确定
|
|
|
|
|
this.renderer2.listen(this.elementRef.nativeElement.querySelector('#setPositionOk'),'click',(event)=>{
|
|
|
|
|
this.isGisTopBox = true |
|
|
|
|
this.markerPosition = markerPosition |
|
|
|
|
this.map.clearMap(); |
|
|
|
|
this.newPositionMarker = new AMap.Marker({ |
|
|
|
|
position: [this.markerPosition.x,this.markerPosition.y], |
|
|
|
|
content: this.newPositionMarkerContent, |
|
|
|
|
offset: new AMap.Pixel(-15, -18) |
|
|
|
|
}); |
|
|
|
|
this.map.add(this.newPositionMarker); |
|
|
|
|
}) |
|
|
|
|
this.renderer2.listen(this.elementRef.nativeElement.querySelector('#setPositionClose'),'click',(event)=>{
|
|
|
|
|
this.map.clearMap(); |
|
|
|
|
this.isGisTopBox = true |
|
|
|
|
if(this.markerPosition.x && this.markerPosition.x != 0){//说明之前标过点
|
|
|
|
|
this.newPositionMarker = new AMap.Marker({ |
|
|
|
|
position: [this.markerPosition.x,this.markerPosition.y], |
|
|
|
|
content: this.newPositionMarkerContent, |
|
|
|
|
offset: new AMap.Pixel(-15, -18) |
|
|
|
|
}); |
|
|
|
|
this.map.add(this.newPositionMarker); |
|
|
|
|
} |
|
|
|
|
})//取消
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//获得所有单位类型
|
|
|
|
|
getallunittype() { |
|
|
|
|
this.http.get("/api/BuildingTypes/Simple").subscribe(data => { |
|
|
|
@ -109,59 +270,71 @@ export class BasicinfoComponent implements OnInit {
|
|
|
|
|
(data: any) => { |
|
|
|
|
this.allorganizing = data; |
|
|
|
|
this.dataSource.data = this.tree.toTree(data); |
|
|
|
|
this.getunitinfo(); |
|
|
|
|
let _this = this |
|
|
|
|
this.getunitinfo().then((e)=>{ |
|
|
|
|
if(this.unitinfo.location && (this.unitinfo.location.x != 0 && this.unitinfo.location.y != 0) ){//已标注
|
|
|
|
|
_this.isMapLabel = true |
|
|
|
|
_this.markerPosition = _this.unitinfo.location |
|
|
|
|
}else{//未标注
|
|
|
|
|
_this.isMapLabel = false |
|
|
|
|
} |
|
|
|
|
this.labelGis() |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
) |
|
|
|
|
} |
|
|
|
|
//获得当前单位的基本信息
|
|
|
|
|
CompanyId
|
|
|
|
|
getunitinfo(){ |
|
|
|
|
|
|
|
|
|
this.http.get(`/api/Companies/${this.unitId}`).subscribe((data:any)=>{ |
|
|
|
|
if(data.buildingTypes.length){ |
|
|
|
|
sessionStorage.setItem('buildingTypeId',data.buildingTypes[0].id) |
|
|
|
|
}else{ |
|
|
|
|
sessionStorage.setItem('buildingTypeId',"") |
|
|
|
|
} |
|
|
|
|
let node |
|
|
|
|
this.allorganizing.forEach(item => { |
|
|
|
|
if(item.id == data.organizationId){ |
|
|
|
|
node = item |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
if(node){ |
|
|
|
|
if(!node.parentId){ |
|
|
|
|
this.selectedorganization = node.name |
|
|
|
|
async getunitinfo(){ |
|
|
|
|
let result = await new Promise((resolve, reject) => { |
|
|
|
|
this.http.get(`/api/Companies/${this.unitId}`).subscribe((data:any)=>{ |
|
|
|
|
if(data.buildingTypes.length){ |
|
|
|
|
sessionStorage.setItem('buildingTypeId',data.buildingTypes[0].id) |
|
|
|
|
}else{ |
|
|
|
|
let namearr = [node.name] |
|
|
|
|
let targetId = node.parentId; // 临时变量
|
|
|
|
|
for(let i = 0; i < node.level ; i++){ |
|
|
|
|
this.allorganizing.forEach(item => { |
|
|
|
|
if(item.id == targetId ){ |
|
|
|
|
namearr.push(item.name)
|
|
|
|
|
targetId = item.parentId; // 临时变量更新没有副作用
|
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
sessionStorage.setItem('buildingTypeId',"") |
|
|
|
|
} |
|
|
|
|
let node |
|
|
|
|
this.allorganizing.forEach(item => { |
|
|
|
|
if(item.id == data.organizationId){ |
|
|
|
|
node = item |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
if(node){ |
|
|
|
|
if(!node.parentId){ |
|
|
|
|
this.selectedorganization = node.name |
|
|
|
|
}else{ |
|
|
|
|
let namearr = [node.name] |
|
|
|
|
let targetId = node.parentId; // 临时变量
|
|
|
|
|
for(let i = 0; i < node.level ; i++){ |
|
|
|
|
this.allorganizing.forEach(item => { |
|
|
|
|
if(item.id == targetId ){ |
|
|
|
|
namearr.push(item.name)
|
|
|
|
|
targetId = item.parentId; // 临时变量更新没有副作用
|
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
namearr.reverse() |
|
|
|
|
let str = '' |
|
|
|
|
namearr.forEach(item=>{ |
|
|
|
|
str += '/' + item |
|
|
|
|
}) |
|
|
|
|
this.selectedorganization = str.substr(1) |
|
|
|
|
} |
|
|
|
|
namearr.reverse() |
|
|
|
|
let str = '' |
|
|
|
|
namearr.forEach(item=>{ |
|
|
|
|
str += '/' + item |
|
|
|
|
}) |
|
|
|
|
this.selectedorganization = str.substr(1) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
this.unitinfo = data |
|
|
|
|
this.selectedorganizationid = data.organizationId |
|
|
|
|
if(data.imageUrl){ |
|
|
|
|
this.imgsrc = data.imageUrl |
|
|
|
|
} |
|
|
|
|
if(data.buildingTypes[0]){ |
|
|
|
|
this.defaultbuildingTypes = data.buildingTypes[0].id |
|
|
|
|
this.buildingTypesname = data.buildingTypes[0].name |
|
|
|
|
} |
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
this.unitinfo = data |
|
|
|
|
resolve(this.unitinfo) |
|
|
|
|
this.selectedorganizationid = data.organizationId |
|
|
|
|
if(data.imageUrl){ |
|
|
|
|
this.imgsrc = data.imageUrl |
|
|
|
|
} |
|
|
|
|
if(data.buildingTypes[0]){ |
|
|
|
|
this.defaultbuildingTypes = data.buildingTypes[0].id |
|
|
|
|
this.buildingTypesname = data.buildingTypes[0].name |
|
|
|
|
} |
|
|
|
|
})
|
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
//石油化工 装置信息 勾选框
|
|
|
|
|
checkboxchange(item,e){ |
|
|
|
@ -1012,10 +1185,7 @@ export class BasicinfoComponent implements OnInit {
|
|
|
|
|
phone: value.linkphone, |
|
|
|
|
address: value.unitaddress, |
|
|
|
|
imageUrl: this.imgsrc, |
|
|
|
|
location: { |
|
|
|
|
x: 0, |
|
|
|
|
y: 0 |
|
|
|
|
}, |
|
|
|
|
location: this.markerPosition, |
|
|
|
|
modifiedTime: time, |
|
|
|
|
organizationId: this.selectedorganizationid, |
|
|
|
|
organizationName: null, |
|
|
|
|