车辆定位

main
xuechunyuan 3 years ago
parent 585ae20caf
commit 0a28d47e7e
  1. 8
      src/api/data.js
  2. 12
      src/views/components/carMile.vue
  3. 48
      src/views/components/carWarn.vue

@ -29,16 +29,16 @@ export const lunzApi = {
data, data,
}), }),
//设备昨日公里数 //设备昨日公里数
getYesterdayMile: (appKey) => request({ getYesterdayMile: (key) => request({
url: '/gatewayapi/ApiPlat/GetYesterdayMile', url: '/gatewayapi/ApiPlat/GetYesterdayMile',
method: 'get', method: 'get',
headers:{ headers:{
appKey appKey: key
}, },
}), }),
//报警记录 //报警记录
getMessInfoByMessType: (appKey, data) => request({ getMessInfoByMessType: (key, data) => request({
url: '/gatewayapi/ApiPlat/GetMessInfoByMessType?appKey=' + appKey, url: '/gatewayapi/ApiPlat/GetMessInfoByMessType?appkey=' + key,
method: 'post', method: 'post',
data, data,
}) })

@ -1,6 +1,6 @@
<template> <template>
<div class="mile_warp"> <div class="mile_warp">
<table> <table class="table">
<thead> <thead>
<tr> <tr>
<th>排名</th> <th>排名</th>
@ -38,7 +38,6 @@ export default {
queryYesterdayMile() { queryYesterdayMile() {
lunzApi.getYesterdayMile(key).then(res => { lunzApi.getYesterdayMile(key).then(res => {
let resData = res.Data; let resData = res.Data;
console.log(resData)
this.carList.map(item => { this.carList.map(item => {
let idx = resData.findIndex(item2 => item2.Imei == item.deviceId); let idx = resData.findIndex(item2 => item2.Imei == item.deviceId);
item.mile = idx > -1 ? res.Data[idx].Mile : 0; item.mile = idx > -1 ? res.Data[idx].Mile : 0;
@ -58,6 +57,13 @@ export default {
width: 100%; width: 100%;
height: 100%; height: 100%;
overflow: hidden; overflow: hidden;
font-size: 12px; .table {
width: 100%;
th,td{
color:#fff;
font-size: 0.16rem;
padding: 0.03rem 0.05rem;
}
}
} }
</style> </style>

@ -1,6 +1,6 @@
<template> <template>
<div class="mile_warp"> <div class="mile_warp">
<table> <table class="table">
<thead> <thead>
<tr> <tr>
<th>时间</th> <th>时间</th>
@ -9,10 +9,10 @@
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
<tr v-for="(item,index) in carMile" :key="'car'+index"> <tr v-for="(item, index) in carWarn" :key="'car' + index">
<td>{{item.cardNo}}</td> <td>{{ item.TimeStamp }}</td>
<td>{{item.mile}}</td> <td>{{ item.MESSTYPE }}</td>
<td><a :href="`https://lcrm3.lunz.cn/#/Equipment/LocatMonitor/Path/${item.key}`" target="_blank">查询</a></td> <td>{{ item.MESSCONTENT }}</td>
</tr> </tr>
</tbody> </tbody>
</table> </table>
@ -21,29 +21,33 @@
<script> <script>
import { lunzApi, key, carList } from "@/api/data"; import { lunzApi, key, carList } from "@/api/data";
import { dateFormat } from "@/util/date";
export default { export default {
data() { data() {
return { return {
carList: carList,// carList: carList,//
carMile:[], carWarn: [],
} }
}, },
mounted() { mounted() {
this.queryYesterdayMile(); this.queryYesterdayMile();
}, },
methods: { methods: {
// //
queryYesterdayMile() { queryYesterdayMile() {
lunzApi.getYesterdayMile(key).then(res => { let now = new Date();
let yesterDay1 = now.setDate(now.getDate() - 1);
let param = {
"StartTime": dateFormat(new Date(yesterDay1), 'yyyy-MM-dd'),
"EndTime": dateFormat(new Date(), 'yyyy-MM-dd')
}
lunzApi.getMessInfoByMessType(key, param).then(res => {
let resData = res.Data; let resData = res.Data;
console.log(resData) resData.map(item => {
this.carList.map(item => { let idx = this.carList.findIndex(item2 => item2.deviceId == item.Imei);
let idx = resData.findIndex(item2 => item2.Imei == item.deviceId); item.carNo = idx > -1 ? this.carList[idx].cardNo : '-';
item.mile = idx > -1 ? res.Data[idx].Mile : 0; item.TimeStamp = dateFormat(new Date(TimeStamp), 'yyyy-MM-dd hh:mm:ss')
this.carMile.push(item); this.carWarn.push(item);
})
this.carMile.sort((a,b) => {
return b.mile - a.mile;
}) })
}) })
}, },
@ -56,6 +60,16 @@ export default {
width: 100%; width: 100%;
height: 100%; height: 100%;
overflow: hidden; overflow: hidden;
font-size: 12px;
.table {
width: 100%;
th,
td {
color: #fff;
font-size: 0.16rem;
padding: 0.03rem 0.05rem;
}
}
} }
</style> </style>
Loading…
Cancel
Save