代码合并

This commit is contained in:
BianLzhaoMin 2024-08-09 10:10:15 +08:00
parent 9808a3d03c
commit 377c904af2
1 changed files with 224 additions and 72 deletions

View File

@ -18,20 +18,20 @@
</div> </div>
<div class="equipment" v-if="false">{{ engineering }}工程</div> <div class="equipment" v-if="false">{{ engineering }}工程</div>
<el-row :gutter="24"> <el-row :gutter="24">
<el-col :span="8"> <el-col :span="16">
<el-date-picker <el-date-picker
v-model="queryForm.date" v-model="queryForm.date"
type="daterange" type="datetimerange"
range-separator="至" range-separator="至"
start-placeholder="请选择开始日期" start-placeholder="请选择开始日期"
end-placeholder="请选择结束日期" end-placeholder="请选择结束日期"
style="width: 330px" value-format="yyyy-MM-dd HH:mm:ss"
value-format="yyyy-MM-dd" @change="onChangeTime"
format="yyyy-MM-dd"
/> />
<el-button <el-button
type="primary" type="primary"
style="padding: 8px 16px; margin-left: 5px" style="padding: 8px 16px; margin-left: 5px"
@click="handleQuery()"
>查询</el-button >查询</el-button
> >
</el-col> </el-col>
@ -44,29 +44,34 @@
<el-tab-pane label="行程"> <el-tab-pane label="行程">
<div <div
class="trip-container" class="trip-container"
@click="handlePreviewTrip()" @click="handlePreviewTrip(item, index)"
v-for="(item, index) in tripList"
:key="index"
> >
<div class="left-num">1</div> <div class="left-num">{{ index + 1 }}</div>
<div class="right-info"> <div
<ul> class="right-info"
<li>0KM</li> :class="{ active: activeIndex === index }"
<li>22</li> >
<li>5KM/h</li> <!-- <ul>
<li>0KM/h</li> <li>{{ item.tripdistance }}KM</li>
<li>{{ item.drivingDuration }}</li>
<li>{{ item.maxspeed }}KM/h</li>
<li>{{ item.averagespeed }}KM/h</li>
</ul> </ul>
<ul> <ul>
<li>里程</li> <li>里程</li>
<li>行驶时长</li> <li>行驶时长</li>
<li>最大速度</li> <li>最大速度</li>
<li>平均速度</li> <li>平均速度</li>
</ul> </ul> -->
<div style="margin-top: 10px"> <div style="margin-top: 10px">
<div class="time-container"> <div class="time-container">
<span class="radius-span"></span> <span class="radius-span"></span>
<span>2024-07-18 01:18:53</span> <span>{{ item.startTime }}</span>
</div> </div>
<h3>安徽省------</h3> <h3>{{ item.startAddress }}</h3>
</div> </div>
<div style="margin-top: 10px"> <div style="margin-top: 10px">
<div class="time-container"> <div class="time-container">
@ -77,30 +82,46 @@
" "
></span ></span
> >
<span>2024-07-18 01:18:53</span> <span>{{ item.endTime }}</span>
</div> </div>
<h3>安徽省------</h3> <h3>{{ item.endAddress }}</h3>
</div> </div>
</div> </div>
</div> </div>
</el-tab-pane> </el-tab-pane>
<el-tab-pane label="停留点"> <el-tab-pane label="停留点">
<div class="point-container"> <div
class="point-container"
v-for="(item, index) in parkList"
:key="index"
>
<div class="time-container"> <div class="time-container">
<span class="radius-span">1</span> <span class="radius-span">{{
<span>2024-07-18 01:18:53</span> index + 1
<span>1时19分</span> }}</span>
<span>{{ item.startTime }}</span>
<span
>{{ item.hours }}{{
item.mints
}}</span
>
</div> </div>
<h3>安徽省------</h3> <h3>{{ item.address }}</h3>
</div> </div>
</el-tab-pane> </el-tab-pane>
<el-tab-pane label="报警"> <el-tab-pane label="报警">
<div class="point-container"> <div
class="point-container"
v-for="(item, index) in warningList"
:key="index"
>
<div class="time-container"> <div class="time-container">
<span class="radius-span">1</span> <span class="radius-span">{{
<span>2024-07-18 01:18:53</span> index + 1
}}</span>
<span>{{ item.warnTime }}</span>
</div> </div>
<h3>手动触发紧急报警---------</h3> <h3>{{ item.startAlarm }}</h3>
</div> </div>
</el-tab-pane> </el-tab-pane>
</el-tabs> </el-tabs>
@ -118,6 +139,13 @@
</template> </template>
<script> <script>
import moment from 'moment'
import {
getIotDeviceLocationApi,
getIotDeviceTripApi,
getIotDeviceParkDetailApi,
getIotDeviceAlarmApi,
} from '@/api/store/iotManagement.js'
export default { export default {
name: 'MapDialog', name: 'MapDialog',
props: { props: {
@ -131,13 +159,21 @@ export default {
type: String, type: String,
default: () => '', default: () => '',
}, },
// iotid
iotCode: {
type: String,
default: () => '',
},
}, },
data() { data() {
return { return {
dialogVisible: true, dialogVisible: true,
openMap: false, // openMap: false, //
queryForm: { queryForm: {
date: '', date: [
moment().subtract(1, 'days').format('YYYY-MM-DD HH:mm:ss'),
moment().format('YYYY-MM-DD HH:mm:ss'),
],
}, },
equipment: '', // equipment: '', //
equipmentNumber: 'H906L', // equipmentNumber: 'H906L', //
@ -146,45 +182,48 @@ export default {
// //
linePointList: [ linePointList: [
{ {
lng: 116.297611, lng: '',
lat: 40.047363, lat: '',
}, },
{ {
lng: 116.302839, lng: '',
lat: 40.048219, lat: '',
},
{
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,
}, },
], ],
count: 0, count: 0,
trackAni: null, // trackAni: null, //
calLon: '',
calLat: '',
//
tripParams: {
beginTime: moment()
.subtract(1, 'days')
.format('YYYY-MM-DD HH:mm:ss'),
endTime: moment().format('YYYY-MM-DD HH:mm:ss'),
iotId: '',
},
//
tripList: [],
activeIndex: '',
//
parkList: [],
} }
}, },
created() {
this.handleQuery()
},
mounted() { mounted() {
console.log('地图弹框组件被创建--') Promise.all([this.getIotDeviceLocation()])
// this.getEquipmentInfo() .then((res) => {
this.initMap() this.initMap()
})
.catch((err) => {
console.log(err)
})
// this.getIotDeviceLocation()
}, },
beforeDestroy() { beforeDestroy() {
@ -201,9 +240,103 @@ export default {
}, },
methods: { methods: {
/** 获取当前设备的信息 */
async getIotDeviceLocation() {
if (this.iotCode) {
const { data: res } = await getIotDeviceLocationApi({
iotId: this.iotCode,
})
//
this.calLon = res.callon
this.calLat = res.callat
}
},
/** 查询按钮 */
async handleQuery() {
this.tripParams.iotId = this.iotCode
const res = await getIotDeviceTripApi({ ...this.tripParams })
console.log(res, '行程信息--')
const resS = await getIotDeviceParkDetailApi({ ...this.tripParams })
console.log(resS, '停留点信息--')
const params = { ...this.tripParams }
params.beginTime = params.beginTime.slice(0, 10)
params.endTime = params.endTime.slice(0, 10)
const resSs = await getIotDeviceAlarmApi(params)
this.warningList = resSs.data
this.warningList.forEach((e) => {
e.warnTime = moment(parseInt(e.startAlarmTime)).format(
'YYYY-MM-DD HH:mm:ss',
)
})
console.log(resSs, '报警信息--')
this.parkList = resS.data
this.parkList.forEach((e) => {
e.startTime = moment(parseInt(e.beginTime)).format(
'YYYY-MM-DD HH:mm:ss',
)
e.hours = parseInt(
(parseInt(e.endTime) - parseInt(e.beginTime)) /
1000 /
60 /
60,
)
e.mints = parseInt(
((parseInt(e.endTime) - parseInt(e.beginTime)) /
1000 /
60) %
60,
)
})
let tripInfo = JSON.parse(res.msg)
console.log(tripInfo, '反序列化之后', this.parkList)
let addressList = []
if (tripInfo.addressmap) {
addressList = Object.keys(tripInfo.addressmap)
}
tripInfo.totaltrips.forEach((e) => {
e.startTime = moment(e.trackstarttime).format(
'YYYY-MM-DD HH:mm:ss',
)
e.endTime = moment(e.trackendtime).format('YYYY-MM-DD HH:mm:ss')
e.drivingDuration = parseInt(
(e.trackendtime - e.trackstarttime) / 1000,
)
addressList.forEach((v) => {
if (v.indexOf(e.slat.toString().slice(0, 7)) > -1) {
e.startAddress = tripInfo.addressmap[v]
}
if (v.indexOf(e.elat.toString().slice(0, 7)) > -1) {
e.endAddress = tripInfo.addressmap[v]
}
})
})
this.tripList = tripInfo.totaltrips
console.log(tripInfo, '处理之后-----')
},
/** 查看行程 */ /** 查看行程 */
handlePreviewTrip() { handlePreviewTrip(item, index) {
this.activeIndex = index
if (this.trackAni) {
this.trackAni.cancel()
}
this.map.clearOverlays()
let pointList = [] let pointList = []
this.linePointList[0].lng = item.slon
this.linePointList[0].lat = item.slat
this.linePointList[1].lng = item.elon
this.linePointList[1].lat = item.elat
if (this.linePointList.length === 0) return if (this.linePointList.length === 0) return
for (var i = 0; i < this.linePointList.length; i++) { for (var i = 0; i < this.linePointList.length; i++) {
pointList.push( pointList.push(
@ -213,6 +346,9 @@ export default {
), ),
) )
} }
// pointList.push(new BMapGL.Point(item.slon, item.slat))
// pointList.push(new BMapGL.Point(item.elon, item.elat))
let polyline = new BMapGL.Polyline(pointList) let polyline = new BMapGL.Polyline(pointList)
// 线 // 线
polyline.setStrokeColor('#EA3323') // 线 #EA3323 polyline.setStrokeColor('#EA3323') // 线 #EA3323
@ -220,24 +356,24 @@ export default {
this.trackAni = new BMapGLLib.TrackAnimation(this.map, polyline, { this.trackAni = new BMapGLLib.TrackAnimation(this.map, polyline, {
overallView: true, // overallView: true, //
tilt: 30, // 55 tilt: 30, // 55
duration: 5000, // 10000ms duration: 3000, // 10000ms
delay: 2000, // 0ms delay: 500, // 0ms
}) })
this.trackAni.start() this.trackAni.start()
// //
this.triggerMovement() this.triggerMovement()
}, },
async handleQuery() { // async handleQuery() {
console.log('🚀 ~ handleQuery ~ 查询:', this.queryForm.date) // console.log('🚀 ~ handleQuery ~ :', this.queryForm.date)
const params = { // const params = {
date: this.queryForm.date, // date: this.queryForm.date,
} // }
this.getEquipmentInfo(params) // this.getEquipmentInfo(params)
// // //
this.map.clearOverlays() // this.map.clearOverlays()
this.map = null // this.map = null
await this.initMap() // await this.initMap()
}, // },
openMapDialog(val) { openMapDialog(val) {
this.openMap = val this.openMap = val
this.initMap() this.initMap()
@ -254,15 +390,25 @@ export default {
}, },
// //
initMap() { initMap() {
console.log('地图初始化--')
this.$nextTick(() => { this.$nextTick(() => {
this.map = new BMapGL.Map('container') // this.map = new BMapGL.Map('container') //
let point = new BMapGL.Point(117.14, 31.87) // // let point = new BMapGL.Point(117.13805, 31.8734) //
let point = new BMapGL.Point(this.calLon, this.calLat) //
this.map.centerAndZoom(point, 15) // this.map.centerAndZoom(point, 15) //
this.map.enableScrollWheelZoom(true) // this.map.enableScrollWheelZoom(true) //
this.map.setHeading(64.5) // this.map.setHeading(64.5) //
this.map.setTilt(73) // this.map.setTilt(73) //
let marker = new BMapGL.Marker(point) // let marker = new BMapGL.Marker(point) //
this.map.addOverlay(marker) this.map.addOverlay(marker)
var myGeo = new BMapGL.Geocoder()
//
// myGeo.getLocation(new BMapGL.Point(this.calLon, this.calLat))
// this.map.getLocation(point, (res) => {
// console.log(res, '--')
// })
}) })
}, },
// //
@ -303,6 +449,11 @@ export default {
handelCloseDialog() { handelCloseDialog() {
this.$emit('handelCloseDialog') this.$emit('handelCloseDialog')
}, },
/** 时间选择器 */
onChangeTime(val) {
this.tripParams.beginTime = val[0]
this.tripParams.endTime = val[1]
},
}, },
} }
</script> </script>
@ -380,6 +531,7 @@ export default {
margin: 0; margin: 0;
list-style: none; list-style: none;
display: flex; display: flex;
align-items: center;
li { li {
flex: 1; flex: 1;
text-align: center; text-align: center;