|
|
|
@ -19,7 +19,7 @@ import { isNgTemplate } from '@angular/compiler';
|
|
|
|
|
import * as _ from 'lodash'; |
|
|
|
|
import Swiper from 'swiper'; |
|
|
|
|
import { LookMaster } from './lookmaster.component' |
|
|
|
|
|
|
|
|
|
declare var AMap: any; |
|
|
|
|
|
|
|
|
|
@Component({ |
|
|
|
|
selector: 'app-basicinfo', |
|
|
|
@ -86,13 +86,72 @@ export class BasicinfoComponent implements OnInit {
|
|
|
|
|
allorganizing:any = [] //所有组织机构
|
|
|
|
|
constructor(private http: HttpClient, private tree: TreeService, private sanitizer: DomSanitizer, public dialog: MatDialog,public snackBar: MatSnackBar) { } |
|
|
|
|
|
|
|
|
|
isMapLabel:boolean |
|
|
|
|
ngOnInit(): void { |
|
|
|
|
this.getallunittype() |
|
|
|
|
this.getorganization() |
|
|
|
|
// this.getunitinfo()
|
|
|
|
|
this.getunitallbuilding() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//地图标注位置
|
|
|
|
|
marker:any//单位点标记
|
|
|
|
|
markerPosition:any = {x: 0, y: 0}//单位坐标
|
|
|
|
|
labelGis(){ |
|
|
|
|
var map = new AMap.Map('container', { |
|
|
|
|
zoom:12 |
|
|
|
|
}) |
|
|
|
|
if(this.isMapLabel){ |
|
|
|
|
this.marker = new AMap.Marker({ |
|
|
|
|
position: [this.unitinfo.location.x,this.unitinfo.location.y], // 经纬度对象,也可以是经纬度构成的一维数组[116.39, 39.9]
|
|
|
|
|
draggable: true |
|
|
|
|
}); |
|
|
|
|
map.add(this.marker); |
|
|
|
|
map.setFitView(); |
|
|
|
|
this.marker.on('dragging', (e)=>{ |
|
|
|
|
this.markerPosition = {x: e.lnglat.lng, y: e.lnglat.lat} |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//输入提示
|
|
|
|
|
var autoOptions = { |
|
|
|
|
input: "tipinput" |
|
|
|
|
}; |
|
|
|
|
AMap.plugin(['AMap.PlaceSearch','AMap.AutoComplete'], () =>{ |
|
|
|
|
var auto = new AMap.AutoComplete(autoOptions); |
|
|
|
|
var placeSearch = new AMap.PlaceSearch({ |
|
|
|
|
// map: map
|
|
|
|
|
// pageSize: 5, // 单页显示结果条数
|
|
|
|
|
// pageIndex: 1 // 页码
|
|
|
|
|
}); //构造地点查询类
|
|
|
|
|
auto.on("select", (e)=>{ |
|
|
|
|
placeSearch.search(e.poi.name, (status, result) => { |
|
|
|
|
if(this.marker){ |
|
|
|
|
map.remove(this.marker); |
|
|
|
|
} |
|
|
|
|
this.isMapLabel = true |
|
|
|
|
// 查询成功时,result即对应匹配的POI信息
|
|
|
|
|
var poi = result.poiList.pois[0]; |
|
|
|
|
this.markerPosition = {x: poi.location.lng, y: poi.location.lat} |
|
|
|
|
this.marker = new AMap.Marker({ |
|
|
|
|
position: poi.location, // 经纬度对象,也可以是经纬度构成的一维数组[116.39, 39.9]
|
|
|
|
|
title: poi.name, |
|
|
|
|
draggable: true |
|
|
|
|
}); |
|
|
|
|
map.add(this.marker); |
|
|
|
|
map.setFitView(); |
|
|
|
|
this.marker.on('dragend', (e)=>{ |
|
|
|
|
this.markerPosition = {x: e.lnglat.lng, y: e.lnglat.lat} |
|
|
|
|
}) |
|
|
|
|
}); |
|
|
|
|
});//注册监听,当选中某条记录时会触发
|
|
|
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//获得所有单位类型
|
|
|
|
|
getallunittype() { |
|
|
|
|
this.http.get("/api/BuildingTypes/Simple").subscribe(data => { |
|
|
|
@ -105,57 +164,73 @@ export class BasicinfoComponent implements OnInit {
|
|
|
|
|
(data: any) => { |
|
|
|
|
this.allorganizing = JSON.parse( JSON.stringify(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() |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
) |
|
|
|
|
} |
|
|
|
|
//获得当前单位的基本信息
|
|
|
|
|
getunitinfo(){ |
|
|
|
|
this.http.get("/api/CompanyAccount/Company").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/CompanyAccount/Company").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) |
|
|
|
|
console.log(456789,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 |
|
|
|
|
} |
|
|
|
|
})
|
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
//获得建筑自定义信息
|
|
|
|
|
getbuildingCustomData(){ |
|
|
|
@ -848,7 +923,8 @@ export class BasicinfoComponent implements OnInit {
|
|
|
|
|
|
|
|
|
|
hasChild = (_: number, node: any) => node.expandable; |
|
|
|
|
|
|
|
|
|
imgsrc = "../../../assets/images/upload.jpg" //没有上传图片时显示的图片,当上传后就会被替换,即保存时需要传的图片地址参数
|
|
|
|
|
imgsrc = "" //没有上传图片时显示的图片,当上传后就会被替换,即保存时需要传的图片地址参数
|
|
|
|
|
noImg = '../../../assets/images/upload.jpg' |
|
|
|
|
imgUrl = ""//返回来的图片地址后缀
|
|
|
|
|
file: any; //上传的文件
|
|
|
|
|
objectName: any; //上传对象名
|
|
|
|
@ -1027,10 +1103,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.allorganizing.length? this.allorganizing[0].id : null, |
|
|
|
|
organizationName: null, |
|
|
|
|