|
|
|
@ -8,6 +8,7 @@ import { HttpClient } from '@angular/common/http';
|
|
|
|
|
import { asBlob } from 'html-docx-js-typescript' |
|
|
|
|
// 要保存这个docx文件推荐引入file-saver哦,你可以用npm i -D file-saver来安装
|
|
|
|
|
import { saveAs } from 'file-saver' |
|
|
|
|
declare var AMap: any; |
|
|
|
|
@Component({ |
|
|
|
|
selector: 'app-unit-details', |
|
|
|
|
templateUrl: './unit-details.component.html', |
|
|
|
@ -16,7 +17,7 @@ import { saveAs } from 'file-saver'
|
|
|
|
|
|
|
|
|
|
export class UnitDetailsComponent implements OnInit { |
|
|
|
|
@ViewChild('box') box: ElementRef; |
|
|
|
|
constructor(private message:NzMessageService, private router: Router, private toTree: TreeService, private fb: FormBuilder, private http: HttpClient, private renderer: Renderer2, private el: ElementRef) { |
|
|
|
|
constructor(private message: NzMessageService, private router: Router, private toTree: TreeService, private fb: FormBuilder, private http: HttpClient, private renderer: Renderer2, private el: ElementRef, public renderer2: Renderer2, private elementRef: ElementRef) { |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
disableds = false |
|
|
|
@ -37,7 +38,7 @@ export class UnitDetailsComponent implements OnInit {
|
|
|
|
|
west: "", |
|
|
|
|
north: "", |
|
|
|
|
routeAndTime: "", |
|
|
|
|
|
|
|
|
|
positionCoordinates: { x: 0, y: 0 } |
|
|
|
|
}, |
|
|
|
|
facilities: { |
|
|
|
|
controlPosition: "", |
|
|
|
@ -91,7 +92,6 @@ export class UnitDetailsComponent implements OnInit {
|
|
|
|
|
id = "" |
|
|
|
|
integrity = 0 |
|
|
|
|
ngOnInit(): void { |
|
|
|
|
console.log(this.router); |
|
|
|
|
this.id = this.router['browserUrlTree'].queryParams.id |
|
|
|
|
if (this.router['browserUrlTree'].queryParams.pattern != "edit") { |
|
|
|
|
this.disableds = true |
|
|
|
@ -103,11 +103,228 @@ export class UnitDetailsComponent implements OnInit {
|
|
|
|
|
buildingTypeId: [null] |
|
|
|
|
|
|
|
|
|
}); |
|
|
|
|
console.log(this.validateForm); |
|
|
|
|
this.getAllOrganization() |
|
|
|
|
this.getCompanies() |
|
|
|
|
this.getBuildingTypes() |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
isMapLabel: boolean |
|
|
|
|
//地图标注位置
|
|
|
|
|
markerPosition: any = { x: 0, y: 0 }//单位坐标
|
|
|
|
|
map: any //地图实例
|
|
|
|
|
isGisTopBox: boolean = false//点击位置按钮
|
|
|
|
|
isGisTopBoxTwo: boolean = false//点击位置按钮
|
|
|
|
|
oldPositionMarker: any //旧位置marker实例
|
|
|
|
|
newPositionMarker: any //新位置marker实例
|
|
|
|
|
|
|
|
|
|
newPositionMarkerContent: any = |
|
|
|
|
'<div class="custom-content-marker">' + |
|
|
|
|
' <img class="positionimg" src="/assets/images/newposition.png">' + |
|
|
|
|
' <div class="btnbox2"></div>' + |
|
|
|
|
'</div>' |
|
|
|
|
newPositionMarkerContentBtn: any = |
|
|
|
|
'<div class="custom-content-marker">' + |
|
|
|
|
' <img class="positionimg" 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 class="positionimg" src="/assets/images/oldposition.png">' + |
|
|
|
|
' <div class="btnbox2"></div>' + |
|
|
|
|
'</div>' |
|
|
|
|
//初始化地图
|
|
|
|
|
searchTitle: any//搜索内容
|
|
|
|
|
placeSearch: any//地址搜索类
|
|
|
|
|
search() { |
|
|
|
|
this.placeSearch.search(this.searchTitle, (status, result) => { |
|
|
|
|
// 搜索成功时,result即是对应的匹配数据
|
|
|
|
|
if (result.info == "OK") { |
|
|
|
|
this.newPositionMarker.setPosition([result.poiList.pois[0].location.lng, result.poiList.pois[0].location.lat]) |
|
|
|
|
this.markerPosition2 = { x: result.poiList.pois[0].location.lng, y: result.poiList.pois[0].location.lat } |
|
|
|
|
this.map.setCenter([result.poiList.pois[0].location.lng, result.poiList.pois[0].location.lat]); //设置地图中心点
|
|
|
|
|
} else { |
|
|
|
|
alert('查询不到输入地址信息') |
|
|
|
|
} |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
//初始化地图
|
|
|
|
|
markerPosition2 |
|
|
|
|
labelGis() { |
|
|
|
|
console.log('初始化地图') |
|
|
|
|
this.map = new AMap.Map('container', { |
|
|
|
|
zoom: 12 |
|
|
|
|
}) |
|
|
|
|
this.map.on('complete', () => { |
|
|
|
|
this.isGisTopBox = true |
|
|
|
|
}); |
|
|
|
|
//输入提示
|
|
|
|
|
var autoOptions = { |
|
|
|
|
input: "tipinput" |
|
|
|
|
}; |
|
|
|
|
AMap.plugin(['AMap.PlaceSearch', 'AMap.AutoComplete'], () => { |
|
|
|
|
var auto = new AMap.AutoComplete(autoOptions); |
|
|
|
|
this.placeSearch = new AMap.PlaceSearch(); //构造地点查询类
|
|
|
|
|
auto.on("select", (e) => { |
|
|
|
|
this.newPositionMarker.setPosition([e.poi.location.lng, e.poi.location.lat]) |
|
|
|
|
this.markerPosition2 = { x: e.poi.location.lng, y: e.poi.location.lat } |
|
|
|
|
this.map.setCenter([e.poi.location.lng, e.poi.location.lat]); //设置地图中心点
|
|
|
|
|
});//注册监听,当选中某条记录时会触发
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
if (this.isMapLabel) {//如果已经标注单位坐标
|
|
|
|
|
console.log('已标注单位位置') |
|
|
|
|
this.map.setCenter([this.datas.basicInfo.positionCoordinates.x, this.datas.basicInfo.positionCoordinates.y]); |
|
|
|
|
this.oldPositionMarker = new AMap.Marker({ |
|
|
|
|
position: [this.datas.basicInfo.positionCoordinates.x, this.datas.basicInfo.positionCoordinates.y], |
|
|
|
|
content: this.newPositionMarkerContent, |
|
|
|
|
offset: new AMap.Pixel(-34, -36) |
|
|
|
|
}) |
|
|
|
|
// 将 markers 添加到地图
|
|
|
|
|
this.map.add(this.oldPositionMarker); |
|
|
|
|
} else { |
|
|
|
|
// console.log('未标注单位位置')
|
|
|
|
|
this.map.setCity('济南'); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//点击位置按钮
|
|
|
|
|
setPosition() { |
|
|
|
|
|
|
|
|
|
if(this.disableds){ |
|
|
|
|
return |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this.isGisTopBox = false |
|
|
|
|
this.isGisTopBoxTwo = true |
|
|
|
|
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(-34, -36) |
|
|
|
|
}); |
|
|
|
|
this.map.add(this.newPositionMarker); |
|
|
|
|
if (this.markerPosition.x && this.markerPosition.x != 0) { |
|
|
|
|
this.markerPosition2 = { x: this.markerPosition.x, y: this.markerPosition.y } |
|
|
|
|
} else { |
|
|
|
|
this.markerPosition2 = { x: this.map.getCenter().lng, y: this.map.getCenter().lat } //获取当前地图中心位置
|
|
|
|
|
} |
|
|
|
|
this.newPositionMarker.on('dragend', (e) => { |
|
|
|
|
let lnglat = this.map.containerToLngLat(e.pixel) |
|
|
|
|
this.markerPosition2 = { x: lnglat.KL, y: lnglat.kT } |
|
|
|
|
}) |
|
|
|
|
this.newPositionMarker.on('dragging', (e) => { |
|
|
|
|
let lnglat = this.map.containerToLngLat(e.pixel) |
|
|
|
|
this.newPositionMarker.setPosition(lnglat); |
|
|
|
|
}) |
|
|
|
|
//点击确定
|
|
|
|
|
this.renderer2.listen(this.elementRef.nativeElement.querySelector('#setPositionOk'), 'click', (event) => { |
|
|
|
|
this.map.clearMap(); |
|
|
|
|
this.isGisTopBox = true |
|
|
|
|
this.isGisTopBoxTwo = false |
|
|
|
|
this.newPositionMarker = new AMap.Marker({ |
|
|
|
|
position: [this.markerPosition2.x, this.markerPosition2.y], |
|
|
|
|
content: this.newPositionMarkerContent, |
|
|
|
|
offset: new AMap.Pixel(-34, -36) |
|
|
|
|
}); |
|
|
|
|
this.markerPosition = this.markerPosition2 |
|
|
|
|
this.map.add(this.newPositionMarker); |
|
|
|
|
}) |
|
|
|
|
//点击取消
|
|
|
|
|
this.renderer2.listen(this.elementRef.nativeElement.querySelector('#setPositionClose'), 'click', (event) => { |
|
|
|
|
this.isGisTopBox = true |
|
|
|
|
this.isGisTopBoxTwo = false |
|
|
|
|
this.map.clearMap(); |
|
|
|
|
this.newPositionMarker = new AMap.Marker({ |
|
|
|
|
position: [this.markerPosition.x, this.markerPosition.y], |
|
|
|
|
content: this.newPositionMarkerContent, |
|
|
|
|
offset: new AMap.Pixel(-34, -36) |
|
|
|
|
}); |
|
|
|
|
this.map.setCenter([this.markerPosition.x, this.markerPosition.y]); //设置地图中心点
|
|
|
|
|
this.map.add(this.newPositionMarker); |
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
} else { |
|
|
|
|
// console.log('未标注单位位置')
|
|
|
|
|
if (this.newPositionMarker) { |
|
|
|
|
this.newPositionMarker.setContent(this.oldPositionMarkerContent) |
|
|
|
|
} |
|
|
|
|
let center |
|
|
|
|
//this.markerPosition---单位坐标
|
|
|
|
|
if (this.markerPosition.x && this.markerPosition.x != 0) { |
|
|
|
|
center = [this.markerPosition.x, this.markerPosition.y] |
|
|
|
|
} else { |
|
|
|
|
center = this.map.getCenter(); //获取当前地图中心位置
|
|
|
|
|
// console.log('获取当前地图中心位置', center)
|
|
|
|
|
this.map.setCenter(center); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
this.newPositionMarker = new AMap.Marker({ |
|
|
|
|
draggable: true, |
|
|
|
|
position: center, |
|
|
|
|
content: this.newPositionMarkerContentBtn, |
|
|
|
|
offset: new AMap.Pixel(-34, -36) |
|
|
|
|
}); |
|
|
|
|
this.map.add(this.newPositionMarker); |
|
|
|
|
|
|
|
|
|
if (this.markerPosition.x && this.markerPosition.x != 0) { |
|
|
|
|
this.markerPosition2 = { x: this.markerPosition.x, y: this.markerPosition.y } |
|
|
|
|
} else { |
|
|
|
|
this.markerPosition2 = { x: this.map.getCenter().lng, y: this.map.getCenter().lat } //获取当前地图中心位置
|
|
|
|
|
} |
|
|
|
|
this.newPositionMarker.on('dragend', (e) => { |
|
|
|
|
let lnglat = this.map.containerToLngLat(e.pixel) |
|
|
|
|
this.markerPosition2 = { x: lnglat.KL, y: lnglat.kT } |
|
|
|
|
}) |
|
|
|
|
this.newPositionMarker.on('dragging', (e) => { |
|
|
|
|
let lnglat = this.map.containerToLngLat(e.pixel) |
|
|
|
|
this.newPositionMarker.setPosition(lnglat); |
|
|
|
|
}) |
|
|
|
|
//点击确定
|
|
|
|
|
this.renderer2.listen(this.elementRef.nativeElement.querySelector('#setPositionOk'), 'click', (event) => { |
|
|
|
|
this.isGisTopBox = true |
|
|
|
|
this.isGisTopBoxTwo = false |
|
|
|
|
this.markerPosition = this.markerPosition2 |
|
|
|
|
this.map.clearMap(); |
|
|
|
|
this.newPositionMarker = new AMap.Marker({ |
|
|
|
|
position: [this.markerPosition.x, this.markerPosition.y], |
|
|
|
|
content: this.newPositionMarkerContent, |
|
|
|
|
offset: new AMap.Pixel(-34, -36) |
|
|
|
|
}); |
|
|
|
|
this.newPositionMarker.setMap(this.map) |
|
|
|
|
}) |
|
|
|
|
this.renderer2.listen(this.elementRef.nativeElement.querySelector('#setPositionClose'), 'click', (event) => { |
|
|
|
|
this.map.clearMap(); |
|
|
|
|
this.isGisTopBox = true |
|
|
|
|
this.isGisTopBoxTwo = false |
|
|
|
|
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(-34, -36) |
|
|
|
|
}); |
|
|
|
|
this.map.setCenter([this.markerPosition.x, this.markerPosition.y]); //设置地图中心点
|
|
|
|
|
this.map.add(this.newPositionMarker); |
|
|
|
|
} |
|
|
|
|
})//取消
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
listOfData: any[] = []; |
|
|
|
|
listOfData2: any[] = []; |
|
|
|
|
|
|
|
|
@ -825,9 +1042,12 @@ export class UnitDetailsComponent implements OnInit {
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
let num4=(num+num2+num3-1)/56 |
|
|
|
|
let num4 = (num + num2 + num3 - 1) / 57 |
|
|
|
|
this.integrity = Math.floor(num4 * 100) / 100 |
|
|
|
|
console.log(num, num2, num3, num4); |
|
|
|
|
this.datas.basicInfo.positionCoordinates = { |
|
|
|
|
x: this.markerPosition.x, y: this.markerPosition.y |
|
|
|
|
} |
|
|
|
|
let body = { |
|
|
|
|
id: this.id, |
|
|
|
|
companyName: this.datas.basicInfo.name, |
|
|
|
@ -858,7 +1078,6 @@ export class UnitDetailsComponent implements OnInit {
|
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
getCompanies() { |
|
|
|
|
|
|
|
|
|
this.http.get('/api/Companies/' + this.id).subscribe((data: any) => { |
|
|
|
|
console.log(data); |
|
|
|
|
if (data.data) { |
|
|
|
@ -876,6 +1095,14 @@ export class UnitDetailsComponent implements OnInit {
|
|
|
|
|
buildingTypeId: data.buildingTypeId |
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (this.datas.basicInfo.positionCoordinates && (this.datas.basicInfo.positionCoordinates.x != 0 && this.datas.basicInfo.positionCoordinates.y != 0)) {//已标注
|
|
|
|
|
this.isMapLabel = true |
|
|
|
|
this.markerPosition = this.datas.basicInfo.positionCoordinates |
|
|
|
|
} else {//未标注
|
|
|
|
|
this.isMapLabel = false |
|
|
|
|
} |
|
|
|
|
this.labelGis() |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
nodes: any = [] |
|
|
|
|