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.

165 lines
4.5 KiB
Vue

<template>
<el-dialog
class="infoDialog"
title="装置信息"
:visible.sync="isShow"
:close-on-click-modal="false"
width="50%"
2 years ago
@close="handleclose"
>
<div class="infoTable" v-loading="loading">
2 years ago
<el-descriptions :column="1" border>
<el-descriptions-item>
<template slot="label"> 装置编号 </template>{{ cmdid }}
</el-descriptions-item>
<el-descriptions-item>
2 years ago
<template slot="label"> 电池电量 </template
>{{ infornr.batteryCapacity }}
</el-descriptions-item>
<el-descriptions-item>
2 years ago
<template slot="label"> 电池电压 </template
2 years ago
>{{ infornr.batteryVoltage }}V
</el-descriptions-item>
<el-descriptions-item>
2 years ago
<template slot="label"> MEID </template>{{ infornr.cmld }}
</el-descriptions-item>
<el-descriptions-item>
2 years ago
<template slot="label"> 网络连接状态 </template
2 years ago
>{{ infornr.connectionState == 0 ? "正常" : "断开" }}
</el-descriptions-item>
<el-descriptions-item>
2 years ago
<template slot="label"> 浮充状态 </template
2 years ago
>{{ infornr.floatingCharge == 0 ? "充电" : "放电" }}
</el-descriptions-item>
<el-descriptions-item>
2 years ago
<template slot="label"> 工作总时间 </template
>{{ infornr.totalWorkingTime }}小时
2 years ago
</el-descriptions-item>
<el-descriptions-item>
2 years ago
<template slot="label"> 本次连续工作时间 </template
>{{ infornr.workingTime }}小时
2 years ago
</el-descriptions-item>
<el-descriptions-item>
2 years ago
<template slot="label"> 工作状态更新时间 </template
2 years ago
>{{
$moment(infornr.wsUpdateTime * 1000).format("yy-MM-DD HH:mm:ss")
}}
</el-descriptions-item>
</el-descriptions>
2 years ago
<el-button type="text" class="newBtn" @click="getListData()"
>获取最新装置信息</el-button
>
</div>
<div slot="footer" class="dialog-footer">
<!-- <el-button @click="isShow = false"> </el-button> -->
<el-button type="primary" @click="handleclose"> </el-button>
</div>
</el-dialog>
</template>
<script>
2 years ago
import {
getDeviceList,
getNewDeviceList,
getinfoStatus,
} from "@/utils/api/index";
export default {
props: {
title: String,
},
data() {
return {
2 years ago
loading: false,
isShow: false,
2 years ago
infornr: {}, //装置信息内容
timer: null,
2 years ago
i: 0,
2 years ago
queryTime: "", //查询ID
cmdid: "",
2 years ago
zztermid: "",
};
},
2 years ago
mounted() {},
methods: {
2 years ago
//数据库获取最新数据
getinfo() {
getinfoStatus({
termId: this.zztermid,
})
.then((res) => {
this.infornr = res.data;
})
.catch((err) => {});
},
2 years ago
//获取第一次数据
2 years ago
getListData() {
this.loading = true;
2 years ago
getDeviceList({
2 years ago
termId: this.zztermid,
2 years ago
})
2 years ago
.then((res) => {
2 years ago
this.queryTime = res.data.queryTime;
2 years ago
this.getNewListData(this.zztermid);
2 years ago
this.timer = window.setInterval(() => {
2 years ago
this.getNewListData(this.zztermid);
2 years ago
this.i++;
2 years ago
}, 10000);
})
.catch((err) => {});
2 years ago
},
//最新数据
2 years ago
getNewListData(val) {
2 years ago
getNewDeviceList({
queryTime: this.queryTime,
2 years ago
termId: val,
})
2 years ago
.then((res) => {
2 years ago
if (res.code == 200) {
2 years ago
this.infornr = res.data;
2 years ago
2 years ago
if (res.data.isNew == true) {
2 years ago
this.i = 0;
2 years ago
this.$message.success("装置信息已更新");
clearInterval(this.timer);
2 years ago
this.loading = false;
2 years ago
} else if (this.i > 9) {
this.i = 0;
2 years ago
this.$message.warning("暂无响应,请稍后再试!");
clearInterval(this.timer);
2 years ago
this.loading = false;
2 years ago
}
2 years ago
} else {
2 years ago
this.$message.error(res.code.msg);
2 years ago
}
})
.catch((err) => {});
2 years ago
},
2 years ago
// display() {
// this.isShow = true;
// },
display(newTermId, cmdid) {
console.log(newTermId, cmdid);
this.isShow = true;
2 years ago
this.zztermid = newTermId;
this.cmdid = cmdid;
},
hide() {
this.isShow = false;
},
2 years ago
handleclose() {
this.isShow = false;
2 years ago
this.i = 0;
2 years ago
clearInterval(this.timer);
2 years ago
this.timer = null;
2 years ago
},
},
};
</script>
<style lang="less">
.infoDialog {
2 years ago
.newBtn {
margin-top: 14px;
}
}
</style>