Browse Source

Merge branch 'master' into shibei_master

shibei_master
YUJT 3 years ago
parent
commit
c8567af692
  1. 122
      src/views/modules/visual/plugin/power/components/screen-org-map.vue
  2. 48
      src/views/modules/visual/plugin/power/organization.vue

122
src/views/modules/visual/plugin/power/components/screen-org-map.vue

@ -31,6 +31,12 @@ let gaodeMapLayer // 背景地图图层
let markerSource let markerSource
let markerLayer let markerLayer
let markerSource_1
let markerLayer_1
let markerSource_2
let markerLayer_2
let parentLayer;// let parentLayer;//
@ -130,7 +136,8 @@ export default {
orgData: {},// orgData: {},//
iconCoordinators: [], iconCoordinators: [],
parentPolygon: [], parentPolygon: [],
subAgencyArray: [] subAgencyArray: [],
centerFlag: 'point',//flag point fit
} }
}, },
async mounted() { async mounted() {
@ -148,6 +155,8 @@ export default {
// //
this.loadPolygon() this.loadPolygon()
this.setMapLocation()
}, },
methods: { methods: {
initMap () { initMap () {
@ -179,6 +188,45 @@ export default {
// console.log(transform(e.coordinate, 'EPSG:3857', 'EPSG:4326')); // console.log(transform(e.coordinate, 'EPSG:3857', 'EPSG:4326'));
}) })
}, },
//
setMapLocation () {
if (!this.zoom) {
this.setZoom(this.orgData.agencyLevel)
}
this.centerPoint = []
//
if (parentLayer.getSource().getFeatures()[0]) {//
this.centerFlag = 'flag_parent'
} else if (polygonLayer.getSource().getFeatures()[0]) {//,
this.centerFlag = 'flag_polygon'
} else if (this.orgData.longitude && this.orgData.latitude) {
this.centerPoint.push(this.orgData.longitude)
this.centerPoint.push(this.orgData.latitude)
this.centerFlag = 'point'
} else {
this.centerPoint = centerPointGlobal
this.centerFlag = 'point'
}
// debugger
if (this.centerFlag === 'flag_parent') {
let parentFeatures = parentLayer.getSource().getFeatures()[0]
let polygon = parentFeatures.getGeometry();
map.getView().fit(polygon, map.getSize());
this.zoom = map.getView().getZoom() - 1
} else if (this.centerFlag === 'flag_polygon') {
let polygonFeatures = polygonLayer.getSource().getFeatures()[0]
let polygon = polygonFeatures.getGeometry();
map.getView().fit(polygon, map.getSize());
this.zoom = map.getView().getZoom() - 1
} else {
mapView.setCenter(this.centerPoint);
}
mapView.setZoom(this.zoom);
},
firstCenterMap () { firstCenterMap () {
this.centerPoint = [] this.centerPoint = []
if (this.orgData.longitude && this.orgData.latitude) { if (this.orgData.longitude && this.orgData.latitude) {
@ -190,6 +238,9 @@ export default {
} }
}, },
addMarker (list, icon=iconArray[0], scale=1) { addMarker (list, icon=iconArray[0], scale=1) {
if (markerSource) {
markerSource.clear()
}
markerSource = new VectorSource({ markerSource = new VectorSource({
// features: new GeoJSON().readFeatures(geojsonObject) // features: new GeoJSON().readFeatures(geojsonObject)
}) })
@ -245,6 +296,70 @@ export default {
markerSource.addFeatures(features) markerSource.addFeatures(features)
map.addLayer(markerLayer) map.addLayer(markerLayer)
}, },
addMarker_1 (list, icon=iconArray[0], scale=1) {
if (markerSource_1) {
markerSource_1.clear()
}
markerSource_1 = new VectorSource({
// features: new GeoJSON().readFeatures(geojsonObject)
})
markerLayer_1 = new VectorLayer({
source: markerSource_1,
zIndex: 50
})
let features = []
list.forEach((item, index) => {
const point = [parseFloat(item.longitude), parseFloat(item.latitude)]
let marker = new Feature({
geometry: new Point(point),
properties: {
...item
}
})
let iconStyle = new Style({
image: new Icon({
scale: scale,
src: icon
})
})
marker.setStyle(iconStyle)
features.push(marker)
})
markerSource_1.addFeatures(features)
map.addLayer(markerLayer_1)
},
addMarker_2 (list, icon=iconArray[0], scale=1) {
if (markerSource_2) {
markerSource_2.clear()
}
markerSource_2 = new VectorSource({
// features: new GeoJSON().readFeatures(geojsonObject)
})
markerLayer_2 = new VectorLayer({
source: markerSource_2,
zIndex: 50
})
let features = []
list.forEach((item, index) => {
const point = [parseFloat(item.longitude), parseFloat(item.latitude)]
let marker = new Feature({
geometry: new Point(point),
properties: {
...item
}
})
let iconStyle = new Style({
image: new Icon({
scale: scale,
src: icon
})
})
marker.setStyle(iconStyle)
features.push(marker)
})
markerSource_2.addFeatures(features)
map.addLayer(markerLayer_2)
},
// //
async loadOrgData () { async loadOrgData () {
@ -276,8 +391,6 @@ export default {
}, },
// //
loadParentPolygon () { loadParentPolygon () {
parentSource.clear()//
let featureData = []// let featureData = []//
if (this.parentPolygon && this.parentPolygon.length > 0) {// if (this.parentPolygon && this.parentPolygon.length > 0) {//
let oneData = {} let oneData = {}
@ -435,7 +548,6 @@ export default {
parentSource = new VectorSource({ parentSource = new VectorSource({
//features: (new GeoJSON()).readFeatures(geojsonObject) //features: (new GeoJSON()).readFeatures(geojsonObject)
}); });
parentLayer = new VectorLayer({ parentLayer = new VectorLayer({
source: parentSource, source: parentSource,
style: parentStyleFunction, style: parentStyleFunction,
@ -505,9 +617,7 @@ export default {
source: iconSource, source: iconSource,
zIndex: 70 zIndex: 70
}); });
map.addLayer(iconLayer); map.addLayer(iconLayer);
}, },
}, },

48
src/views/modules/visual/plugin/power/organization.vue

@ -17,8 +17,8 @@
:options="agencytree" :options="agencytree"
v-model="agencyId" v-model="agencyId"
:show-all-levels="false" :show-all-levels="false"
:props="{ expandTrigger: 'hover', emitPath: false, label: 'orgName', value: 'orgId', children: 'subOrgList' }" @change="handleChangeAgencytree"
clearable/> :props="{ expandTrigger: 'hover', emitPath: false, label: 'orgName', value: 'orgId', children: 'subOrgList' }"/>
</div> </div>
<!-- <div class="second-select "> <!-- <div class="second-select ">
@ -202,6 +202,7 @@ export default {
let params = { let params = {
axisStructId: this.axisStructId, axisStructId: this.axisStructId,
pageSize: this.pageSize, pageSize: this.pageSize,
agencyId: this.agencyId,
pageNo: this.pageNo, pageNo: this.pageNo,
} }
const url = "/pli/power/data/kernelHousehold/list" const url = "/pli/power/data/kernelHousehold/list"
@ -284,6 +285,7 @@ export default {
getMapData() { getMapData() {
const params1 = { const params1 = {
axisStructId: this.axisStructId, axisStructId: this.axisStructId,
agencyId: this.agencyId,
limit: 99 limit: 99
} }
// //
@ -321,7 +323,7 @@ export default {
this.xiaozuList.push(ob) this.xiaozuList.push(ob)
}) })
this.$nextTick(() => { this.$nextTick(() => {
this.$refs.orgMap.addMarker(this.xiaozuList, lyxzIcon) this.$refs.orgMap.addMarker_1(this.xiaozuList, lyxzIcon)
}) })
}).catch(err => { }).catch(err => {
this.$message.error(err) this.$message.error(err)
@ -339,7 +341,7 @@ export default {
this.zhongxinhuList.push(ob) this.zhongxinhuList.push(ob)
}) })
this.$nextTick(() => { this.$nextTick(() => {
this.$refs.orgMap.addMarker(this.zhongxinhuList, dyzxhIcon) this.$refs.orgMap.addMarker_2(this.zhongxinhuList, dyzxhIcon)
}) })
}).catch(err => { }).catch(err => {
this.$message.error(err) this.$message.error(err)
@ -354,7 +356,6 @@ export default {
// //
async getAgencylist () { async getAgencylist () {
const url = '/data/aggregator/org/agencytree' const url = '/data/aggregator/org/agencytree'
let params = { let params = {
agencyId: this.agencyId, agencyId: this.agencyId,
client:'gov' client:'gov'
@ -366,13 +367,13 @@ export default {
_data = this.removeByOrgType(data, 'agency') _data = this.removeByOrgType(data, 'agency')
if (_data) { if (_data) {
this.agencytree = this.removeEmptySubOrgList(_data) this.agencytree = this.removeEmptySubOrgList(_data)
this.agencyId = this.agencytree ? this.agencytree[0].orgId : '' // id
this.agencyId = this.agencytree[0].subOrgList && this.agencytree[0].subOrgList.length > 0 ? this.setListAgencyId_one(this.agencytree[0].subOrgList) : this.agencytree[0].orgId
} }
} }
} else { } else {
this.$message.error(msg) this.$message.error(msg)
} }
}, },
removeByOrgType (orgArray, orgType) { removeByOrgType (orgArray, orgType) {
if (orgArray && orgArray.length > 0) { if (orgArray && orgArray.length > 0) {
@ -401,12 +402,33 @@ export default {
}) })
return orgArray; return orgArray;
}, },
async handleChangeAgency (value) { // orgId
let selAgency = this.$refs["myCascader"].getCheckedNodes()[0].data setListAgencyId_one(subOrgList) {
// this.agencyName = this.$refs["myCascader"].getCheckedNodes()[0].label if (subOrgList[0].subOrgList && subOrgList[0].subOrgList.length > 0) {
this.agencyName = selAgency.name this.setAgencyId_two(subOrgList[0].subOrgList)
this.agencyId = selAgency.agencyId } else {
this.level = selAgency.level === 'grid' ? 'grid' : 'agency' return subOrgList[0].orgId
}
},
setAgencyId_two(subOrgList) {
if (subOrgList[0].subOrgList && subOrgList[0].subOrgList.length > 0) {
this.setListAgencyId_one(subOrgList[0].subOrgList)
} else {
return subOrgList[0].orgId
}
},
async handleChangeAgencytree() {
this.pageNo = 1
this.pageSize = 5
this.total = 0
this.dangqunList = [] //
this.xiaozuList = [] //
this.zhongxinhuList = [] //
this.tableData = []
this.axisStructId = ''
await this.getStructTree()
await this.getCount()
await this.getMapData()
}, },
}, },
} }

Loading…
Cancel
Save