Commit 22b3f912 authored by wends's avatar wends

update 设备监控

parent 6abc3a90
...@@ -47,6 +47,7 @@ ...@@ -47,6 +47,7 @@
</el-form-item> </el-form-item>
<el-form-item> <el-form-item>
<el-button type="primary" @click="queryData">查询</el-button> <el-button type="primary" @click="queryData">查询</el-button>
<el-button v-if="false" @click="clearIntervalT">clear</el-button>
</el-form-item> </el-form-item>
</el-form> </el-form>
</el-card> </el-card>
...@@ -74,7 +75,7 @@ ...@@ -74,7 +75,7 @@
v-for="(property, index) in dataModelDetail" v-for="(property, index) in dataModelDetail"
:key="index" :key="index"
:label="property.propertyName" :label="property.propertyName"
:value="`${property.propertyValue} ${property.propertyUnit}`" :value="formatProperty(property)"
/> />
</el-card> </el-card>
<el-card class="margin-top-20"> <el-card class="margin-top-20">
...@@ -195,6 +196,9 @@ export default { ...@@ -195,6 +196,9 @@ export default {
this.timer && clearInterval(this.timer) this.timer && clearInterval(this.timer)
}, },
methods: { methods: {
clearIntervalT() {
this.timer && clearInterval(this.timer)
},
async init(deviceTypeId, deviceInstanceId) { async init(deviceTypeId, deviceInstanceId) {
// 获取所有设备类型 // 获取所有设备类型
const deviceTypeList = await getAllDeviceModel() const deviceTypeList = await getAllDeviceModel()
...@@ -243,15 +247,19 @@ export default { ...@@ -243,15 +247,19 @@ export default {
}] }]
}) })
.then(params => { .then(params => {
const { dataMode, deviceInstance } = this.form
this.timer && clearInterval(this.timer) this.timer && clearInterval(this.timer)
this.timer = setInterval(async() => { this.timer = setInterval(async() => {
await this.getPropertyDetail(this.form.dataMode, this.form.deviceInstance) await this.getPropertyDetail(dataMode, deviceInstance)
const chartData = await getModelInstanceChart(params) const chartData = await getModelInstanceChart(params)
this.tableData = chartData.data[0].dataList this.tableData = chartData.data[0].dataList
this.property.data = [...this.getChartData(this.activeProperty)] this.property.data = [...this.getChartData(this.activeProperty)]
}, this.form.refresh * 1000) }, this.form.refresh * 1000)
}) })
.catch(_ => {}) .catch(e => console.error(e))
},
formatProperty(property) {
return property.propertyValue ? `${property.propertyValue} ${property.propertyUnit}` : ''
}, },
getDeviceInstanceDetail(id) { getDeviceInstanceDetail(id) {
getDeviceInstanceDetail({ id }) getDeviceInstanceDetail({ id })
...@@ -270,8 +278,8 @@ export default { ...@@ -270,8 +278,8 @@ export default {
getPropertyDetail(dataModelId, deviceId) { getPropertyDetail(dataModelId, deviceId) {
getPropertyDetail({ dataModelId, deviceId }) getPropertyDetail({ dataModelId, deviceId })
.then(res => { .then(res => {
this.dataModelDetail = res.data.propertyList this.dataModelDetail = res.data.propertyList.length ? res.data.propertyList : []
this.dataModelReportTime = res.data.reportTime this.dataModelReportTime = res.data.reportTime ? res.data.reportTime : null
}) })
.catch(_ => {}) .catch(_ => {})
}, },
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment