You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

174 lines
4.4 KiB
Vue

2 years ago
<template>
<el-dialog
class="gpsPoisitiondialog"
title="GPS位置"
:visible.sync="isShow"
:close-on-click-modal="false"
width="662px"
@close="handleclose"
>
2 years ago
<!-- <div class="gpsbox" v-loading="loading">
2 years ago
<p>
<span>经度</span><span>{{ infornr.longitude }}</span>
</p>
<p>
<span>纬度</span><span>{{ infornr.latitude }}</span>
</p>
<p>
<span>半径</span><span>{{ infornr.radius }}</span>
</p>
2 years ago
</div> -->
<div class="gpsbox" v-loading="loading">
<el-descriptions :column="1" border>
<el-descriptions-item>
<template slot="label"> 采集时间 </template
>{{ $moment(infornr.updatetime).format("YYYY-MM-DD HH:mm:ss") }}
</el-descriptions-item>
<el-descriptions-item>
<template slot="label"> 经度 </template>{{ infornr.longitude }}
</el-descriptions-item>
<el-descriptions-item>
<template slot="label"> 纬度 </template>{{ infornr.latitude }}
</el-descriptions-item>
<el-descriptions-item>
<template slot="label"> 半径 </template>{{ infornr.radius }}
</el-descriptions-item>
</el-descriptions>
<el-button type="text" class="newBtn" @click="getgpsData()"
>获取最新GPS位置</el-button
>
2 years ago
</div>
<div slot="footer" class="dialog-footer">
<el-button type="primary" @click="isShow = false"> </el-button>
</div>
</el-dialog>
</template>
<script>
2 years ago
import {
getTermLastGPSPosition,
getTermGPSJoggle,
getTermGPSPosition,
} from "@/utils/api/index";
2 years ago
export default {
props: {
title: String,
},
data() {
return {
2 years ago
loading: false,
2 years ago
isShow: false,
timer: null,
infornr: {},
i: 0,
queryTime: "", //查询ID
2 years ago
zzcmdid: "",
zztermid: "",
2 years ago
};
},
mounted() {},
methods: {
2 years ago
//获取数据信息
getgpssql() {
getTermLastGPSPosition({
termId: this.zztermid,
})
.then((res) => {
this.infornr = res.data;
// this.$message({
// duration: 1500,
// showClose: true,
// message: "gps信息已更新",
// type: "success",
// });
})
.catch((err) => {});
},
2 years ago
//获取第一次数据
2 years ago
getgpsData() {
console.log(this.zzcmdid);
console.log(this.zztermid);
2 years ago
this.loading = true;
getTermGPSPosition({
2 years ago
cmdId: this.zzcmdid,
2 years ago
})
.then((res) => {
this.queryTime = res.data;
2 years ago
console.log(this.zztermid);
this.getNewgpsData(this.zztermid);
2 years ago
this.timer = window.setInterval(() => {
2 years ago
this.getNewgpsData(this.zztermid);
2 years ago
this.i++;
}, 5000);
})
.catch((err) => {});
},
//最新数据
getNewgpsData(val) {
getTermGPSJoggle({
queryTime: this.queryTime,
2 years ago
termid: val,
2 years ago
})
.then((res) => {
this.loading = true;
if (res.code == 200) {
this.infornr = res.data;
if (res.data.hasNew == true) {
this.loading = false;
this.i = 0;
this.$message({
duration: 1500,
2 years ago
showClose: true,
message: "gps信息已更新",
type: "success",
});
clearInterval(this.timer);
} else if (this.i > 9) {
this.loading = false;
this.i = 0;
this.$message({
duration: 1500,
2 years ago
showClose: true,
message: "暂未获取到GPS信息请稍后再试",
type: "warning",
});
clearInterval(this.timer);
}
} else {
this.$message.error(res.code.msg);
}
})
.catch((err) => {});
},
2 years ago
display(data) {
console.log(data);
2 years ago
this.isShow = true;
2 years ago
this.zzcmdid = data.cmdId;
this.zztermid = data.id;
2 years ago
},
hide() {
this.isShow = false;
},
handleclose() {
this.i = 0;
clearInterval(this.timer);
this.timer = null;
2 years ago
this.loading = false;
2 years ago
},
},
};
</script>
<style lang="less">
.gpsPoisitiondialog {
.gpsbox {
p {
line-height: 32px;
height: 32px;
font-size: 16px;
}
2 years ago
.newBtn {
margin-top: 14px;
}
2 years ago
}
}
</style>