mirror of
https://gitee.com/js-yhsec/energy_storage.git
synced 2026-05-27 18:59:26 +08:00
修改菜单+权限+图表渲染
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
<template>
|
||||
<div class="map">
|
||||
|
||||
<div ref="mapContent" class="mapContent" >
|
||||
<div ref="mapContent" class="mapContent">
|
||||
<tdt-map
|
||||
ref="tiandituMap"
|
||||
:center="center"
|
||||
@@ -16,7 +15,7 @@
|
||||
:position="[marker.lon, marker.lat]"
|
||||
:key="marker.id"
|
||||
:icon="marker.iconMap"
|
||||
style="width: 20px; height: 20px"
|
||||
style="width: 20px;height: auto"
|
||||
@click="clickArrayMarker(marker)"
|
||||
:title="marker.name"
|
||||
>
|
||||
@@ -44,11 +43,12 @@
|
||||
</a-modal>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { getReq, postReq } from '@/request/api'
|
||||
import Modal from '@/components/Home/Modal.vue'
|
||||
import { loadTMap } from '@/utils/loadTMap'
|
||||
import {gcj02ToWgs84} from '@/utils/gcj02ToWgs84'
|
||||
import { gcj02ToWgs84, wgs84ToGcj02 } from '@/utils/gcj02ToWgs84'
|
||||
import { TdtMap } from 'vue-tianditu'
|
||||
|
||||
export default {
|
||||
@@ -57,14 +57,12 @@ export default {
|
||||
|
||||
data() {
|
||||
return {
|
||||
center: [],
|
||||
// zoom: 16,
|
||||
zoom: 2,
|
||||
center: [116.404, 39.915], // 默认中心点(北京)
|
||||
zoom: 12,
|
||||
map: null,
|
||||
currentMarker: {},
|
||||
showCtrModal: false,
|
||||
markers: [],
|
||||
|
||||
testVal: {
|
||||
name: '场站211',
|
||||
id: '2'
|
||||
@@ -75,19 +73,11 @@ export default {
|
||||
},
|
||||
mounted() {
|
||||
this.initMap()
|
||||
// this.getMarkList()
|
||||
},
|
||||
methods: {
|
||||
init(map) {
|
||||
this.map = map
|
||||
// console.log(this.map.getCenter(),"this.map.getCenter()")
|
||||
this.map.centerAndZoom(new T.LngLat(116.404, 39.915), 12);
|
||||
// 监听地图加载完成事件
|
||||
this.map.addEventListener('load', () => {
|
||||
const c= this.map.getCenter()
|
||||
this.center =gcj02ToWgs84(c);
|
||||
console.log('GCJ02坐标:', this.center);
|
||||
});
|
||||
this.center= [110.404, 40.915]
|
||||
this.getMarkList()
|
||||
},
|
||||
async getMarkList() {
|
||||
@@ -98,50 +88,41 @@ export default {
|
||||
const res = await getReq('/queryStationList', query)
|
||||
if (res.errcode === 0) {
|
||||
this.markers = res.data.map((item) => {
|
||||
console.log(gcj02ToWgs84(+item.lon, +item.lat),"gcj02ToWgs84(+item.lon, +item.lat)")
|
||||
let wgs = +item.lat && +item.lon ? gcj02ToWgs84(+item.lon, +item.lat) : [null, null]
|
||||
return {
|
||||
...item,
|
||||
lon: wgs[0],
|
||||
lat: wgs[1],
|
||||
iconMap: !+item.status
|
||||
? require('../../assets/home/homeIcon1.png')
|
||||
: require('../../assets/home/homeIcon.png')
|
||||
}
|
||||
})
|
||||
console.log("this.markers ",this.markers )
|
||||
} else {
|
||||
this.markers = []
|
||||
throw res
|
||||
}
|
||||
} catch (error) {
|
||||
console.log(error,'eeeeeeeeeeeeeeee')
|
||||
console.log(error, 'eeeeeeeeeeeeeeee')
|
||||
}
|
||||
},
|
||||
async initMap() {
|
||||
try {
|
||||
const [mapKey] = await Promise.all([this.getSysConfig('map-key')])
|
||||
// const gcj02LngLat=map.getCenter()
|
||||
// console.log(gcj02LngLat.getLng())
|
||||
console.log(mapKey,"mapKey")
|
||||
await loadTMap(mapKey)
|
||||
|
||||
|
||||
// 创建地图实例(需要HTML中存在id为mapContainer的元素)
|
||||
// this.map = new T.Map("amap-vue");
|
||||
// // this.map.centerAndZoom(new T.LngLat(116.404, 39.915), 12); // 初始中心点
|
||||
|
||||
// const centerGcj02 = this.map.getCenter();
|
||||
// console.log("GCJ02坐标:", centerGcj02.getLng(), centerGcj02.getLat());
|
||||
// const centerWgs84=gcj02ToWgs84(centerGcj02.getLng(),centerGcj02.getLat())
|
||||
|
||||
|
||||
|
||||
// this.center =[]
|
||||
} catch (err) {
|
||||
console.error('天地图加载失败:', err)
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
|
||||
// 备用定位方案
|
||||
// setFallbackLocation() {
|
||||
// const fallbackCoords = [116.404, 39.915] // 北京坐标
|
||||
// this.center = fallbackCoords
|
||||
// if (this.map) {
|
||||
// this.map.setCenter(new T.LngLat(...fallbackCoords))
|
||||
// }
|
||||
// },
|
||||
|
||||
async getSysConfig() {
|
||||
let sysConfig
|
||||
try {
|
||||
@@ -157,28 +138,17 @@ export default {
|
||||
}
|
||||
return sysConfig
|
||||
},
|
||||
|
||||
async clickArrayMarker(currentVal) {
|
||||
this.changeStationId = currentVal.station_id
|
||||
console.log(currentVal, 'cccccccccccccccccccccc')
|
||||
this.showCtrModal = true
|
||||
// try {
|
||||
// const query = {
|
||||
// // station_id:this.changeStationId
|
||||
// }
|
||||
// const res = await postReq(query, '')
|
||||
// if (res.errcode === 0) {
|
||||
// this.modalInfo = res.data.records
|
||||
// } else {
|
||||
// throw res
|
||||
// }
|
||||
// } catch (err) {
|
||||
// console.log(err, 'eeeeeeeeeeeeeeeerr')
|
||||
// }
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
/* 保持原有样式不变 */
|
||||
.map {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
@@ -266,4 +236,4 @@ export default {
|
||||
height:auto!important;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
</style>
|
||||
Reference in New Issue
Block a user