<script setup>
|
import {nextTick, onMounted, reactive, ref} from 'vue';
|
import {
|
BaiduMap,
|
BmInfoWindow
|
} from "vue-baidu-map-3x";
|
import {View, IconLayer, TextLayer} from "mapvgl";
|
import mapJson from "@/assets/mapJson/map_config";
|
import {FullScreen} from "@element-plus/icons-vue";
|
import BoxComponent from "@/components/boxComponent.vue";
|
import HdwChart from "@/components/echarts/hdwChart.vue";
|
import getGaugeOption from "@/components/echarts/options/gauge";
|
import getRadiusBarOption from "@/components/echarts/options/radiusBar";
|
import getHorizontalTechnologyOption from "@/components/echarts/options/horizontalTechnologyBar";
|
import carPng from "@/assets/images/car.png";
|
import ChartBox from "@/components/chartBox.vue";
|
const isFullScreen = ref(false);
|
const mapStyle = ref({styleJson: mapJson});
|
const boxGauge = ref(null);
|
const boxBar = ref(null);
|
|
const videoGauge = ref(null);
|
const videoBar = ref(null);
|
|
const battGauge = ref(null);
|
const battBar = ref(null);
|
|
const alarmBar = ref(null);
|
const changeScreenState = ()=>{
|
isFullScreen.value = !isFullScreen.value;
|
}
|
|
import carPosModule from "@/views/moudle/carInfo/carPosModule";
|
import CarInfoList from "@/components/carInfoList.vue";
|
|
const {
|
getCarPosList
|
} = carPosModule();
|
|
const infoWindow = reactive({
|
show: false,
|
content: {
|
boxName: "",
|
boxSn: "",
|
lon: 0,
|
lat: 0,
|
createTime: "",
|
updateTime: ""
|
},
|
});
|
|
const mapPosition = {
|
lng: 116.404,
|
lat: 39.915
|
};
|
const iconLayer = ref({});
|
const textLayer = ref({});
|
|
const handleMapReady = ({map})=>{
|
let view = new View({
|
map: map
|
});
|
|
textLayer.value = new TextLayer({
|
enablePicked: false,
|
autoSelect: false,
|
selectedColor: '#f00', // 选中项颜色
|
color: '#fff',
|
offset: [0, 30],
|
lineWidth: 3, // 文字粗细,在设置描边时才有效
|
//textMaxWidth: 500, // 文字最大宽度,超过则换行
|
textMaxHeight: 50,
|
textAlign: 'center', // 文字对齐方式,支持'center'、'left'
|
lineHeight: 24,
|
stroke: {
|
color: '#000'
|
}
|
});
|
|
view.addLayer(textLayer.value);
|
|
iconLayer.value = new IconLayer({
|
width: 40,
|
height: 29,
|
opacity: 0.8,
|
icon: carPng,
|
selectedIndex: -1, // 选中项
|
enablePicked: true, // 是否可以拾取
|
selectedColor: '#ff0000', // 选中项颜色
|
autoSelect: true, // 根据鼠标位置来自动设置选中项
|
onClick: (e)=>{
|
if(e.dataIndex !== -1) {
|
const point = e.dataItem.geometry.coordinates;
|
const info = e.dataItem.properties.info;
|
infoWindow.show = false;
|
nextTick(()=>{
|
infoWindow.show = true;
|
infoWindow.content = info;
|
mapPosition.lng = point[0];
|
mapPosition.lat = point[1];
|
});
|
}
|
},
|
});
|
|
view.addLayer(iconLayer.value);
|
searchCarPos();
|
}
|
|
const searchCarPos = async ()=>{
|
const res = await getCarPosList();
|
let data = res.map(item=>{
|
return {
|
geometry: {
|
type: 'Point',
|
coordinates: [item.lon, item.lat]
|
},
|
properties: {
|
icon: carPng,
|
text: item.boxName,
|
info: item
|
}
|
}
|
});
|
textLayer.value.setData(data);
|
iconLayer.value.setData(data);
|
}
|
|
const infoWinOpen = ()=>{}
|
const infoWinClose = ()=>{
|
infoWindow.show = false;
|
}
|
|
import {
|
recentDaysCarModule,
|
totalCarNumModule
|
} from "@/views/moudle/carInfo/carInfoModule";
|
|
const {
|
todayCarNum,
|
getRecentDaysCarNum
|
} = recentDaysCarModule();
|
|
const boxGaugeOption = getGaugeOption(0, 2000, "当前在线汽车数");
|
const boxBarOption = getRadiusBarOption();
|
const searchRecentDaysCarNum = async ()=>{
|
const data = await getRecentDaysCarNum(7);
|
boxBarOption.series[0].name = "在线车辆数:"
|
boxBarOption.series[0].data = data.map(item=>{
|
return [new Date(item.date).format("MM-dd"), item.value];
|
});
|
boxBar.value.setOption(boxBarOption);
|
boxGauge.value.setOption(getGaugeOption(todayCarNum.value, 2000, "当前在线汽车数"));
|
}
|
|
const {
|
totalCarNum,
|
getTotalCarNum
|
} = totalCarNumModule();
|
|
|
import {
|
recentDaysBattModule,
|
totalBattNumModule
|
} from "@/views/moudle/battShow/battInfo"
|
|
const battBarOption = getRadiusBarOption();
|
const battGaugeOption = getGaugeOption(1, 500, "今日新增电池数");
|
|
const {
|
todayBattNum,
|
getRecentDaysBattNum
|
} = recentDaysBattModule();
|
const searchRecentDaysBattNum = async ()=>{
|
const data = await getRecentDaysBattNum(7);
|
battBarOption.series[0].name = "新增电池组数:";
|
battBarOption.series[0].data = data.map(item=>{
|
return [new Date(item.date).format("MM-dd"), item.value];
|
});
|
battBar.value.setOption(battBarOption);
|
battGauge.value.setOption(getGaugeOption(todayBattNum.value, 500, "今日新增电池数"));
|
}
|
|
const {
|
totalBattNum,
|
getTotalBattNum
|
} = totalBattNumModule();
|
|
|
import {
|
recentDaysVideoModule,
|
totalVideoNumModule
|
} from "@/views/moudle/videoInf/videoInf";
|
|
const videoGaugeOption = getGaugeOption(1, 500, "今日新增摄像头数");
|
const videoBarOption = getRadiusBarOption();
|
|
const {
|
todayVideoNum,
|
getRecentDaysVideoNum
|
} = recentDaysVideoModule();
|
const searchRecentDaysVideoNum = async ()=>{
|
const data = await getRecentDaysVideoNum(7);
|
videoBarOption.series[0].name = "新增摄像头数:";
|
videoBarOption.series[0].data = data.map(item=>{
|
return [new Date(item.date).format("MM-dd"), item.value];
|
});
|
videoBar.value.setOption(videoBarOption);
|
videoGauge.value.setOption(getGaugeOption(todayVideoNum.value, 500, "今日新增摄像头数"));
|
}
|
|
const {
|
totalVideoNum,
|
getTotalVideoNum
|
} = totalVideoNumModule();
|
|
|
import {
|
bmsStaticAlarmModule
|
} from "@/views/moudle/bmsInf/bmsInf";
|
|
const {
|
getBmsStaticAlarm
|
} = bmsStaticAlarmModule();
|
|
let alarmBarOption = getHorizontalTechnologyOption();
|
const searchBmsStaticAlarm = async ()=>{
|
let res = await getBmsStaticAlarm();
|
|
alarmBarOption = getHorizontalTechnologyOption(res.map(item=>{
|
return {
|
name: item.bmsAlarmName,
|
value: item.num
|
}
|
}));
|
alarmBar.value.setOption(alarmBarOption);
|
}
|
|
/**
|
* 查询车辆,电池,摄像头,告警的图表数据
|
*/
|
const searchEchartsData = ()=>{
|
searchRecentDaysCarNum();
|
getTotalCarNum();
|
|
searchRecentDaysVideoNum();
|
getTotalVideoNum();
|
|
searchRecentDaysBattNum();
|
getTotalBattNum();
|
|
searchBmsStaticAlarm();
|
}
|
|
onMounted(()=>{
|
boxGauge.value.setOption(boxGaugeOption);
|
boxBar.value.setOption(boxBarOption);
|
|
videoGauge.value.setOption(videoGaugeOption);
|
videoBar.value.setOption(videoBarOption);
|
|
battGauge.value.setOption(battGaugeOption);
|
battBar.value.setOption(battBarOption);
|
searchEchartsData();
|
|
alarmBar.value.setOption(alarmBarOption);
|
});
|
</script>
|
|
<template>
|
<div class="baidu-map-wrapper" :class="{'full-screen': isFullScreen}">
|
<div class="baidu-map-container">
|
<div class="baidu-map-header" v-if="isFullScreen">
|
<div class="baidu-map-header-wrapper">
|
<div class="baidu-map-header-left"></div>
|
<div class="baidu-map-header-content">
|
动力电池安全检测大数据分析平台
|
</div>
|
<div class="baidu-map-header-right">
|
<el-button type="primary" @click="changeScreenState" :icon="FullScreen" />
|
</div>
|
</div>
|
</div>
|
<div class="baidu-map-content">
|
<div class="baidu-map-float">
|
<div class="box-container">
|
<div class="box-container-top">
|
<box-component>
|
<div class="box-content-inner-wrapper">
|
<div class="content-inner-header">
|
<el-row>
|
<el-col :span="12">
|
<div class="box-value-wrapper">
|
<div class="text-content">当前在线汽车数:</div>
|
<div class="text-value">{{todayCarNum}}</div>
|
</div>
|
<div class="box-value-wrapper">
|
<div class="text-content">汽车总数:</div>
|
<div class="text-value">{{totalCarNum}}</div>
|
</div>
|
</el-col>
|
<el-col :span="12">
|
<div class="hdw-chart-box">
|
<hdw-chart ref="boxGauge"></hdw-chart>
|
</div>
|
</el-col>
|
</el-row>
|
</div>
|
<div class="content-inner-body">
|
<chart-box title="最近7天在线汽车数">
|
<hdw-chart ref="boxBar"></hdw-chart>
|
</chart-box>
|
</div>
|
</div>
|
</box-component>
|
</div>
|
<div class="box-container-top">
|
<box-component>
|
<div class="box-content-inner-wrapper">
|
<div class="content-inner-header">
|
<el-row>
|
<el-col :span="12">
|
<div class="box-value-wrapper">
|
<div class="text-content">今日新增摄像头数:</div>
|
<div class="text-value">{{todayVideoNum}}</div>
|
</div>
|
<div class="box-value-wrapper">
|
<div class="text-content">摄像头总数:</div>
|
<div class="text-value">{{ totalVideoNum }}</div>
|
</div>
|
</el-col>
|
<el-col :span="12">
|
<div class="hdw-chart-box">
|
<hdw-chart ref="videoGauge"></hdw-chart>
|
</div>
|
</el-col>
|
</el-row>
|
</div>
|
<div class="content-inner-body">
|
<chart-box title="最近7天新增摄像头数">
|
<hdw-chart ref="videoBar"></hdw-chart>
|
</chart-box>
|
</div>
|
</div>
|
</box-component>
|
</div>
|
</div>
|
</div>
|
<div class="baidu-map-float right">
|
<div class="box-container">
|
<div class="box-container-top">
|
<box-component>
|
<div class="box-content-inner-wrapper">
|
<div class="content-inner-header">
|
<el-row>
|
<el-col :span="12">
|
<div class="box-value-wrapper">
|
<div class="text-content">今日新增电池数:</div>
|
<div class="text-value">{{todayBattNum}}</div>
|
</div>
|
<div class="box-value-wrapper">
|
<div class="text-content">电池总数:</div>
|
<div class="text-value">{{totalBattNum}}</div>
|
</div>
|
</el-col>
|
<el-col :span="12">
|
<div class="hdw-chart-box">
|
<hdw-chart ref="battGauge"></hdw-chart>
|
</div>
|
</el-col>
|
</el-row>
|
</div>
|
<div class="content-inner-body">
|
<chart-box title="最近7天新增电池数">
|
<hdw-chart ref="battBar"></hdw-chart>
|
</chart-box>
|
</div>
|
</div>
|
</box-component>
|
</div>
|
<div class="box-container-top">
|
<box-component>
|
<hdw-chart ref="alarmBar"></hdw-chart>
|
</box-component>
|
</div>
|
</div>
|
</div>
|
<baidu-map
|
class="map-container"
|
ak="4GdR40xNyYI2w2XiIgYgS4TdiS3c197C"
|
v="3.0"
|
type="WebGL"
|
:center="{lng: 114.3202, lat: 30.59}"
|
:zoom="5"
|
:scroll-wheel-zoom="true"
|
:mapStyle="mapStyle" @ready="handleMapReady">
|
<bm-info-window :width="300" :position="mapPosition" title="车辆信息" :show="infoWindow.show" @close="infoWinClose" @open="infoWinOpen">
|
<car-info-list :infos="infoWindow.content"></car-info-list>
|
</bm-info-window>
|
</baidu-map>
|
</div>
|
</div>
|
|
</div>
|
</template>
|
|
<style scoped>
|
.baidu-map-wrapper {
|
height: 100%;
|
background-color: #091220ff;
|
&.full-screen {
|
position: fixed;
|
top: 0;
|
left: 0;
|
right: 0;
|
bottom: 0;
|
}
|
.baidu-map-container {
|
display: flex;
|
height: 100%;
|
flex-direction: column;
|
.baidu-map-header {
|
height: 81px;
|
background-image: url("@/assets/images/header_bg.png");
|
background-repeat: no-repeat;
|
background-size: 100% 100%;
|
}
|
.baidu-map-content {
|
position: relative;
|
flex: 1;
|
.map-container {
|
width: 100%;
|
height: 100%;
|
}
|
.baidu-map-tools-right {
|
position: absolute;
|
right: 16px;
|
top: 16px;
|
z-index: 9;
|
}
|
.baidu-map-float {
|
position: absolute;
|
top: 0;
|
bottom: 0;
|
width: 450px;
|
height: 100%;
|
z-index: 8;
|
&.right {
|
right: 0;
|
}
|
}
|
}
|
}
|
}
|
|
.baidu-map-header-wrapper {
|
position: relative;
|
.baidu-map-header-content {
|
text-align: center;
|
font-size: 2rem;
|
line-height: 81px;
|
font-weight: bold;
|
color: #00FEFF;
|
}
|
.baidu-map-header-right {
|
position: absolute;
|
top: 1.5rem;
|
right: 1rem;
|
}
|
}
|
|
.box-container {
|
display: flex;
|
height: 100%;
|
flex-direction: column;
|
padding: 16px;
|
.box-container-top {
|
flex: 1;
|
padding-bottom: 32px;
|
}
|
}
|
.box-content-inner-wrapper {
|
display: flex;
|
height: 100%;
|
flex-direction: column;
|
.content-inner-body {
|
flex: 1;
|
}
|
}
|
|
.box-value-wrapper {
|
margin-bottom: 24px;
|
background: linear-gradient(to bottom, #0363f1, #033f8f, #0363f1);
|
white-space: nowrap;
|
color: #FFFFFF;
|
font-size: 14px;
|
padding: 4px 8px;
|
border-radius: 4px;
|
vertical-align: middle;
|
.text-content {
|
display: inline-block;
|
vertical-align: middle;
|
}
|
.text-value {
|
display: inline-block;
|
margin-left: 8px;
|
font-weight: bold;
|
text-align: right;
|
font-size: 2rem;
|
vertical-align: middle;
|
}
|
}
|
.hdw-chart-box {
|
height: 150px;
|
}
|
</style>
|