代码优化

This commit is contained in:
BianLzhaoMin 2024-08-09 17:05:07 +08:00
parent 5bd0f38ff2
commit f62151ef83
2 changed files with 103 additions and 67 deletions

View File

@ -115,7 +115,7 @@
/>
</el-select>
</el-form-item>
<el-form-item label="设备编号" prop="iotId">
<el-form-item label="设备编号">
<el-select
v-model="IOTForm.iotId"
filterable
@ -276,6 +276,13 @@ export default {
},
//
submit() {
const isType = this.typeList.some((e) => e == this.IOTForm.iotType)
if (isType) {
this.$message.error(
'当前机具已绑定改IOT类型设备不可重复绑定',
)
return
}
try {
//
this.$refs.IOTForm.validate(async (valid) => {

View File

@ -40,6 +40,7 @@
<el-col :span="6">
<el-tabs type="border-card" class="map-left">
<el-tab-pane label="行程">
<template v-if="tripList.length > 0">
<div
class="trip-container"
@click="handlePreviewTrip(item, index)"
@ -49,7 +50,9 @@
<div class="left-num">{{ index + 1 }}</div>
<div
class="right-info"
:class="{ active: activeIndex === index }"
:class="{
active: activeIndex === index,
}"
>
<!-- <ul>
<li>{{ item.tripdistance }}KM</li>
@ -66,8 +69,12 @@
<div style="margin-top: 10px">
<div class="time-container">
<span class="radius-span"></span>
<span>{{ item.startTime }}</span>
<span class="radius-span"
></span
>
<span>{{
item.startTime
}}</span>
</div>
<h3>{{ item.startAddress }}</h3>
</div>
@ -86,8 +93,13 @@
</div>
</div>
</div>
</template>
<template v-else>
{{ loadingData ? '数据加载中...' : 暂无数据 }}
</template>
</el-tab-pane>
<el-tab-pane label="停留点">
<template v-if="parkList.length > 0">
<div
class="point-container"
v-for="(item, index) in parkList"
@ -106,8 +118,11 @@
</div>
<h3>{{ item.address }}</h3>
</div>
</template>
<template v-else> 暂无数据 </template>
</el-tab-pane>
<el-tab-pane label="报警">
<template v-if="warningList.length > 0">
<div
class="point-container"
v-for="(item, index) in warningList"
@ -121,6 +136,8 @@
</div>
<h3>{{ item.startAlarm }}</h3>
</div>
</template>
<template v-else> 暂无数据 </template>
</el-tab-pane>
</el-tabs>
</el-col>
@ -193,6 +210,7 @@ export default {
trackAni: null, //
calLon: '',
calLat: '',
//
tripParams: {
beginTime: moment()
@ -206,18 +224,20 @@ export default {
activeIndex: '',
//
parkList: [],
warningList: [],
loadingData: true,
}
},
created() {
this.handleQuery()
},
created() {},
mounted() {
Promise.all([this.getIotDeviceLocation()])
Promise.all([this.getIotDeviceLocation(), this.handleQuery()])
.then((res) => {
this.loadingData = false
this.initMap()
})
.catch((err) => {
console.log(err)
this.loadingData = false
})
// this.getIotDeviceLocation()
@ -231,9 +251,12 @@ export default {
this.trackAni.cancel()
}
// 2.
if (this.map) {
this.map.clearOverlays()
this.map.destroy()
this.map = null
}
},
methods: {
@ -250,6 +273,10 @@ export default {
},
/** 查询按钮 */
async handleQuery() {
if (!this.queryForm.date) {
this.$message.error('请选择时间范围!')
return
}
this.tripParams.iotId = this.iotCode
const res = await getIotDeviceTripApi({ ...this.tripParams })
console.log(res, '行程信息--')
@ -448,8 +475,10 @@ export default {
},
/** 时间选择器 */
onChangeTime(val) {
if (val) {
this.tripParams.beginTime = val[0]
this.tripParams.endTime = val[1]
}
},
},
}