iot页面调试

This commit is contained in:
BianLzhaoMin 2024-08-05 18:10:34 +08:00
parent 34511e5972
commit dc8546d7c4
2 changed files with 211 additions and 163 deletions

View File

@ -1,180 +1,223 @@
<template>
<div>
<!-- 地图弹框 展示设备轨迹 -->
<el-dialog title="装备定位信息" :visible.sync="openMap" width="80%" :close-on-click-modal="false" @close="close">
<!-- 表单 根据日期查询设备轨迹 -->
<el-card shadow="hover">
<el-form :model="queryForm" inline>
<el-form-item label="查询日期">
<el-date-picker
v-model="queryForm.date"
type="daterange"
range-separator="至"
start-placeholder="请选择开始日期"
end-placeholder="请选择结束日期"
style="width: 330px"
value-format="yyyy-MM-dd"
format="yyyy-MM-dd"
></el-date-picker>
</el-form-item>
<el-form-item>
<el-button type="primary" size="small" @click="handleQuery">轨迹查询</el-button>
</el-form-item>
</el-form>
<div>
<h2>{{ equipment }}</h2>
<div class="equipment">定位设备编号: {{ equipmentNumber }}</div>
<div class="equipment">{{ engineering }}工程</div>
</div>
<div>
<!-- 地图弹框 展示设备轨迹 -->
<el-dialog
title="装备定位信息"
:visible.sync="openMap"
v-if="openMap"
width="80%"
:close-on-click-modal="false"
@close="close"
>
<!-- 表单 根据日期查询设备轨迹 -->
<el-card shadow="hover">
<el-form :model="queryForm" inline>
<el-form-item label="查询日期">
<el-date-picker
v-model="queryForm.date"
type="daterange"
range-separator="至"
start-placeholder="请选择开始日期"
end-placeholder="请选择结束日期"
style="width: 330px"
value-format="yyyy-MM-dd"
format="yyyy-MM-dd"
></el-date-picker>
</el-form-item>
<el-form-item>
<el-button
type="primary"
size="small"
@click="handleQuery"
>轨迹查询</el-button
>
</el-form-item>
</el-form>
<div>
<h2>{{ equipment }}</h2>
<div class="equipment"
>定位设备编号: {{ equipmentNumber }}</div
>
<div class="equipment">{{ engineering }}工程</div>
</div>
<!-- 地图 -->
<div v-if="openMap" id="container" style="height: 500px; background-color: #bfc; margin-top: 13px"></div>
</el-card>
</el-dialog>
</div>
<!-- 地图 -->
<div
v-if="openMap"
id="container"
style="
height: 500px;
background-color: #bfc;
margin-top: 13px;
"
></div>
</el-card>
</el-dialog>
</div>
</template>
<script>
export default {
name: 'MapDialog',
data() {
return {
openMap: false, //
queryForm: {
date: '',
},
equipment: '', //
equipmentNumber: 'H906L', //
engineering: '大禹治水', //
map: null,
//
linePointList: [
{
lng: 116.297611,
lat: 40.047363,
},
{
lng: 116.302839,
lat: 40.048219,
},
{
lng: 116.308301,
lat: 40.050566,
},
{
lng: 116.305732,
lat: 40.054957,
},
{
lng: 116.304754,
lat: 40.057953,
},
{
lng: 116.306487,
lat: 40.058312,
},
{
lng: 116.307223,
lat: 40.056379,
},
],
}
},
mounted() {
this.getEquipmentInfo()
},
methods: {
async handleQuery() {
console.log('🚀 ~ handleQuery ~ 查询:', this.queryForm.date)
const params = {
date: this.queryForm.date,
}
this.getEquipmentInfo(params)
//
this.map.clearOverlays()
this.map = null
await this.initMap()
},
openMapDialog(val) {
this.openMap = val
this.initMap()
},
close() {
this.openMap = false
this.$emit('getList')
},
//
getEquipmentInfo(params = {}) {
console.log('🚀 ~ getEquipmentInfo ~ 获取装备信息', params)
// (params).then(res => {
// this.equipment = res.equipment
// this.equipmentNumber = res.equipmentNumber
// this.engineering = res.engineering
// this.linePointList = res.linePointList
// })
},
//
initMap() {
this.$nextTick(() => {
this.map = new BMapGL.Map('container') //
let point = new BMapGL.Point(117.14, 31.87) //
console.log('🚀 ~ this.$nextTick ~ point:', point)
this.map.centerAndZoom(point, 15) //
this.map.enableScrollWheelZoom(true) //
//
let pointList = []
if (this.linePointList.length === 0) return
for (var i = 0; i < this.linePointList.length; i++) {
pointList.push(new BMapGL.Point(this.linePointList[i].lng, this.linePointList[i].lat))
name: 'MapDialog',
data() {
return {
openMap: false, //
queryForm: {
date: '',
},
equipment: '', //
equipmentNumber: 'H906L', //
engineering: '大禹治水', //
map: null,
//
linePointList: [
{
lng: 116.297611,
lat: 40.047363,
},
{
lng: 116.302839,
lat: 40.048219,
},
{
lng: 116.308301,
lat: 40.050566,
},
{
lng: 116.305732,
lat: 40.054957,
},
{
lng: 116.304754,
lat: 40.057953,
},
{
lng: 116.306487,
lat: 40.058312,
},
{
lng: 116.307223,
lat: 40.056379,
},
],
}
let polyline = new BMapGL.Polyline(pointList)
// 线
polyline.setStrokeColor('#EA3323') // 线 #EA3323
// polyline.setStrokeWeight(2) // 线
let trackAni = new BMapGLLib.TrackAnimation(this.map, polyline, {
overallView: true, //
tilt: 30, // 55
duration: 5000, // 10000ms
delay: 2000, // 0ms
})
trackAni.start()
//
this.triggerMovement()
})
},
//
addStartEndMarkers(startLatLng, endLatLng) {
let startIcon = new BMapGL.Icon(require('/src/assets/images/startIcon.png'), new BMapGL.Size(32, 32))
let startMarker = new BMapGL.Marker(startLatLng, { icon: startIcon })
this.map.addOverlay(startMarker)
let endIcon = new BMapGL.Icon(require('/src/assets/images/endIcon.png'), new BMapGL.Size(32, 32))
let endMarker = new BMapGL.Marker(endLatLng, { icon: endIcon })
this.map.addOverlay(endMarker)
mounted() {
this.getEquipmentInfo()
},
//
triggerMovement() {
//
let startLatLng = new BMapGL.Point(this.linePointList[0].lng, this.linePointList[0].lat)
let endLatLng = new BMapGL.Point(
this.linePointList[this.linePointList.length - 1].lng,
this.linePointList[this.linePointList.length - 1].lat
)
//
this.addStartEndMarkers(startLatLng, endLatLng)
methods: {
async handleQuery() {
console.log('🚀 ~ handleQuery ~ 查询:', this.queryForm.date)
const params = {
date: this.queryForm.date,
}
this.getEquipmentInfo(params)
//
this.map.clearOverlays()
this.map = null
await this.initMap()
},
openMapDialog(val) {
this.openMap = val
this.initMap()
},
close() {
this.openMap = false
this.$emit('getList')
},
//
getEquipmentInfo(params = {}) {
console.log('🚀 ~ getEquipmentInfo ~ 获取装备信息', params)
// (params).then(res => {
// this.equipment = res.equipment
// this.equipmentNumber = res.equipmentNumber
// this.engineering = res.engineering
// this.linePointList = res.linePointList
// })
},
//
initMap() {
this.$nextTick(() => {
this.map = new BMapGL.Map('container') //
let point = new BMapGL.Point(117.14, 31.87) //
console.log('🚀 ~ this.$nextTick ~ point:', point)
this.map.centerAndZoom(point, 15) //
this.map.enableScrollWheelZoom(true) //
//
let pointList = []
if (this.linePointList.length === 0) return
for (var i = 0; i < this.linePointList.length; i++) {
pointList.push(
new BMapGL.Point(
this.linePointList[i].lng,
this.linePointList[i].lat,
),
)
}
let polyline = new BMapGL.Polyline(pointList)
// 线
polyline.setStrokeColor('#EA3323') // 线 #EA3323
// polyline.setStrokeWeight(2) // 线
let trackAni = new BMapGLLib.TrackAnimation(
this.map,
polyline,
{
overallView: true, //
tilt: 30, // 55
duration: 5000, // 10000ms
delay: 2000, // 0ms
},
)
trackAni.start()
//
this.triggerMovement()
})
},
//
addStartEndMarkers(startLatLng, endLatLng) {
let startIcon = new BMapGL.Icon(
require('/src/assets/images/startIcon.png'),
new BMapGL.Size(32, 32),
)
let startMarker = new BMapGL.Marker(startLatLng, {
icon: startIcon,
})
this.map.addOverlay(startMarker)
let endIcon = new BMapGL.Icon(
require('/src/assets/images/endIcon.png'),
new BMapGL.Size(32, 32),
)
let endMarker = new BMapGL.Marker(endLatLng, { icon: endIcon })
this.map.addOverlay(endMarker)
},
//
triggerMovement() {
//
let startLatLng = new BMapGL.Point(
this.linePointList[0].lng,
this.linePointList[0].lat,
)
let endLatLng = new BMapGL.Point(
this.linePointList[this.linePointList.length - 1].lng,
this.linePointList[this.linePointList.length - 1].lat,
)
//
this.addStartEndMarkers(startLatLng, endLatLng)
},
},
},
}
</script>
<style lang="scss" scoped>
.equipment {
font-weight: 600;
font-size: 15px;
margin-top: 10px;
font-weight: 600;
font-size: 15px;
margin-top: 10px;
}
</style>

View File

@ -232,7 +232,12 @@
align="center"
prop="ownHouseName"
>
<i class="el-icon-location location-icon" @click="handleMap" />
<template slot-scope="{ row }">
<i
class="el-icon-location location-icon"
@click="handleMap(row)"
/>
</template>
</el-table-column>
<el-table-column
label="操作"