修改车辆监测

master
夜笙歌 2 years ago
parent 79771ee6e5
commit 824fa51336

@ -4,7 +4,7 @@ import request from '@/utils/request'
export function getCarGpsList(query) {
return request({
url: '/basecar/car/getCarGpsList',
method: 'post',
method: 'get',
params: query
})
}

@ -47,6 +47,15 @@ service.interceptors.request.use(config => {
config.params = {};
config.url = url;
}
if (config.method === 'post') {
config.data = typeof config.data === 'object' ? JSON.stringify({
...config.data,
lang
}) : JSON.stringify({
...JSON.parse(config.data || '{}'),
lang
});
}
if (!isRepeatSubmit && (config.method === 'post' || config.method === 'put')) {
const requestObj = {
url: config.url,

@ -8,146 +8,45 @@
<script setup>
import AMapLoader from '@amap/amap-jsapi-loader';
import { getCarGpsList, listBasetyre } from '@/api/realTimeMonitoring/vehicleMonitoring'
import { parseTime } from "@/utils/ruoyi";
const treeData = ref([
{
title: 'Level one 1',
id: 1,
baseCarList: [
{
title: 'Level two 1-1',
id: 11,
baseCarList: [
{
title: 'Level three 1-1-1',
id: 111,
},
],
},
],
},
{
title: 'Level one 2',
baseCarList: [
{
title: 'Level two 2-1',
baseCarList: [
{
title: 'Level three 2-1-1',
},
],
},
{
title: 'Level two 2-2',
baseCarList: [
{
title: 'Level three 2-2-1',
},
],
},
],
},
{
title: 'Level one 3',
baseCarList: [
{
title: 'Level two 3-1',
baseCarList: [
{
title: 'Level three 3-1-1',
},
],
},
{
title: 'Level two 3-2',
baseCarList: [
{
title: 'Level three 3-2-1',
},
],
},
],
},
])
let map = null
const treeData = ref([])
const markers = ref([])
const treeDefaultProps = { label: 'title', children: 'baseCarList' }
const treeClick = (data) => {
console.log(data)
if (!data.baseCarList) {
map.remove(markers.value);
markers.value = []
setMarker({ id: data.id }, 14)
} else {
map.remove(markers.value);
markers.value = []
setMarker({ queueId: data.id }, 8)
}
const mockRequest = () => {
return new Promise((resolve, reject) => {
setTimeout(() => {
resolve([
{
title: '车牌号1',
one: '离线',
two: '监控',
three: '报警',
four: new Date(),
location: [116.606315, 44.008775]
},
{
title: '车牌号2',
one: '离线',
two: '监控',
three: '报警',
four: new Date(),
location: [116.706315, 40.108775]
},
{
title: '车牌号3',
one: '离线',
two: '监控',
three: '报警',
four: new Date(),
location: [116.806315, 40.208775]
},
])
}, 2000)
})
}
const setMarker = async () => {
const {data: markerArr} = await getCarGpsList()
console.log(markerArr)
markerArr.forEach(e => {
const setMarker = async (data, zoom) => {
const { data: markerArr } = await getCarGpsList(data)
markerArr.forEach((e, index) => {
//
let marker = new AMap.Marker({
markers.value[index] = new AMap.Marker({
content: '<div class="markerIcon" />',
position: [e.longitude, e.latitude],
anchor: 'bottom-center',
offset: new AMap.Pixel(0, 0),
label: {
direction: 'top',
content: `<div class='info'>${e.carLicense || ''} - <span style="color: ${e.state === 0? 'green">在线':'red">离线'}</span></div><div class='info'>${e.two || ''} ${e.three || ''}</div><div class='info'>${e.laseRuntime || ''}</div>`, //
content: `<div class='info'>${e.carLicense || ''} - <span style="color: ${e.state === 0 ? 'green">在线' : 'red">离线'}</span></div><div class='info' onClick='function a(i){location.href = (location.origin+location.pathname+"?id="+i)}a("${e.id}")'>监控 ${e.three || ''}</div><div class='info'>${parseTime(e.laseRuntime) || ''}</div>`, //
}
});
marker.setMap(map);
})
}
const setLine = async () => {
let path = [[116.478935, 39.997761], [103.85094, 35.987496], [106.205794, 38.458831], [108.983569, 34.285675], [111.761777, 40.875595]]
let polyline = new AMap.Polyline({
path: path,
showDir: true,
strokeColor: '#77DDFF', // 线--
strokeWeight: 6, // 线
lineJoin: 'round', // 线
})
let distance = Math.round(AMap.GeometryUtil.distanceOfLine(path));
let text = new AMap.Text({
position: new AMap.LngLat(path[path.length - 1][0], path[path.length - 1][1]),
text: '路径长' + distance + '米',
offset: new AMap.Pixel(0, 0)
})
map.add(text);
map.add(polyline);
map.add(markers.value)
map.setFitView()
map.setZoom(zoom || 8)
}
let map = null
let path = [[116.478935, 39.997761], [103.85094, 35.987496], [106.205794, 38.458831], [108.983569, 34.285675], [111.761777, 40.875595]]
AMapLoader.load({
key: "ba8fb8d8bae1b280b93406d5959d492f", // WebKey load
@ -166,7 +65,6 @@ AMapLoader.load({
center: [116.397428, 39.90923], //
});
await setMarker()
await setLine()
//
@ -182,7 +80,6 @@ AMapLoader.load({
map.addControl(new AMap.MapType());
map.setFitView()
}).catch(e => {
console.log(e);
})

Loading…
Cancel
Save