Commit 430a8830 authored by wends's avatar wends

update 增加跳转

parent 31ed8676
......@@ -2,22 +2,42 @@
<div>
<el-card class="no-bottom">
<el-form
ref="searchForm"
:model="searchForm"
ref="form"
:model="form"
label-width="80px"
inline
>
<el-form-item label="设备类型:" prop="deviceType">
<el-select v-model="form.deviceType" @change="onDeviceTypeChange">
<el-option
v-for="(deviceType, index) in deviceTypeList"
:key="index"
:label="deviceType.name"
:value="deviceType.id"
/>
</el-select>
</el-form-item>
<el-form-item label="设备实例:" prop="deviceInstance">
<el-select v-model="form.deviceInstance" placeholder="请选择">
<el-option
v-for="(deviceInstance, index) in deviceInstanceList"
:key="index"
:label="deviceInstance.name"
:value="deviceInstance.id"
/>
</el-select>
</el-form-item>
<el-form-item
label="设备名称:"
prop="deviceName"
>
<el-input v-model="searchForm.deviceName" />
<el-input v-model="form.deviceName" />
</el-form-item>
<el-form-item
label="告警等级:"
prop="alarmLevel"
>
<el-select v-model="searchForm.alarmLevel">
<el-select v-model="form.alarmLevel">
<el-option label="故障" :value="1" />
<el-option label="警告" :value="2" />
</el-select>
......@@ -155,6 +175,8 @@
<script>
import { getTableData } from '@/api/device-alarm/alarm-show'
import dictionary from '@/utils/dictionary'
import { getAllDeviceModel } from '@/api/equipment-management/equipment-instance'
import { getAllInstanceByDeviceTypeId } from '@/api/data-visible/dashboard'
export default {
name: 'AlarmShow',
mixins: [
......@@ -163,11 +185,15 @@ export default {
props: {},
data() {
return {
searchForm: {
form: {
deviceType: null,
deviceInstance: null,
deviceName: null,
alarmLevel: null
},
add: true,
deviceTypeList: [],
deviceInstanceList: [],
dialogVisible: false,
tableData: [],
detailItem: {
......@@ -191,14 +217,37 @@ export default {
}
},
created() {
this.getTableData()
const { deviceTypeId, deviceInstanceId } = this.$route.query
getAllDeviceModel()
.then(res => {
this.deviceTypeList = res.data
this.form.deviceType = deviceTypeId || this.deviceTypeList.length ? this.deviceTypeList[0].id : null
})
.then(_ => getAllInstanceByDeviceTypeId({ deviceTypeId: this.form.deviceType }))
.then(res => {
this.deviceInstanceList = res.data
this.form.deviceInstance = deviceInstanceId || this.deviceInstanceList.length ? this.deviceInstanceList[0].id : null
})
.then(_ => this.getTableData(1))
.catch(_ => {})
},
mounted() {},
methods: {
onDeviceTypeChange(val) {
this.getAllInstanceByDeviceTypeId(val)
},
getAllInstanceByDeviceTypeId(val, deviceInstanceId) {
getAllInstanceByDeviceTypeId({ deviceTypeId: val })
.then(res => {
this.deviceInstanceList = res.data
this.form.deviceInstance = deviceInstanceId || this.deviceInstanceList.length ? this.deviceInstanceList[0].id : null
})
.catch(_ => {})
},
getTableData(pageNum) {
const params = {
...this.searchForm,
pageNum: this.pageForm.pageNum,
...this.form,
pageNum: pageNum,
pageSize: this.pageForm.pageSize
}
getTableData(params)
......@@ -210,7 +259,7 @@ export default {
.catch(err => console.error(err))
},
resetForm() {
this.$refs.searchForm.resetFields()
this.$refs.form.resetFields()
},
addRow() {
this.add = true
......
......@@ -125,13 +125,12 @@ export default {
}
},
created() {
const { deviceTypeId, deviceInstanceId } = this.$route.query
getAllDeviceModel()
.then(res => {
this.deviceTypeList = res.data
if (this.deviceTypeList.length) {
this.form.deviceType = this.deviceTypeList[0].id
}
this.getAllInstanceByDeviceTypeId(this.form.deviceType)
this.form.deviceType = deviceTypeId || (this.deviceTypeList.length ? this.deviceTypeList[0].id : null)
this.getAllInstanceByDeviceTypeId(this.form.deviceType, deviceInstanceId)
this.getDataModelByDeviceTypeId(this.form.deviceType)
})
.catch(_ => {})
......@@ -141,12 +140,16 @@ export default {
this.getAllInstanceByDeviceTypeId(val)
this.getDataModelByDeviceTypeId(val)
},
getAllInstanceByDeviceTypeId(val) {
getAllInstanceByDeviceTypeId(val, deviceInstanceId) {
getAllInstanceByDeviceTypeId({ deviceTypeId: val })
.then(res => {
this.deviceInstanceList = res.data
if (this.deviceInstanceList.length) {
this.form.deviceInstance = this.deviceInstanceList[0].id
if (deviceInstanceId) {
this.form.deviceInstance = deviceInstanceId
} else {
this.form.deviceInstance = this.deviceInstanceList[0].id
}
}
})
.catch(_ => {})
......
......@@ -178,35 +178,30 @@ export default {
}
},
created() {
const { deviceTypeId, deviceInstanceId } = this.$route.query
this.timer && clearInterval(this.timer)
this.init()
this.init(deviceTypeId, deviceInstanceId)
},
beforeDestroy() {
this.timer && clearInterval(this.timer)
},
methods: {
async init() {
async init(deviceTypeId, deviceInstanceId) {
// 获取所有设备类型
const deviceTypeList = await getAllDeviceModel()
this.deviceTypeList = deviceTypeList.data
if (this.deviceTypeList.length) {
this.form.deviceType = this.deviceTypeList[0].id
}
this.form.deviceType = deviceTypeId || (this.deviceTypeList.length ? this.deviceTypeList[0].id : null)
// 获取该设备类型下的设备实例
const deviceInstanceList = await getAllInstanceByDeviceTypeId({ deviceTypeId: this.form.deviceType })
this.deviceInstanceList = deviceInstanceList.data
if (this.deviceInstanceList.length) {
this.form.deviceInstance = this.deviceInstanceList[0].id
}
this.form.deviceInstance = deviceInstanceId || (this.deviceInstanceList.length ? this.deviceInstanceList[0].id : null)
// 根据设备类型 ID 获取关联数据模型
const dataModelList = await getDataModelByDeviceTypeId({ id: this.form.deviceType })
this.dataModelList = dataModelList.data
if (this.dataModelList.length) {
this.form.dataMode = this.dataModelList[0].id
this.propertyList = this.dataModelList[0].propertyList
if (this.propertyList.length) {
this.activeProperty = this.propertyList[0].propertyCode
}
this.activeProperty = this.propertyList.length ? this.propertyList[0].propertyCode : null
}
// // 查询图表数据
await this.queryData()
......
......@@ -228,35 +228,30 @@ export default {
}
},
created() {
const { deviceTypeId, deviceInstanceId } = this.$route.query
const now = new Date().getTime()
const beginTime = new Date(now - 1000 * 3600 * 24 * 7)
const endTime = new Date(now)
this.form.startAndEndTime = [beginTime, endTime]
this.init()
this.init(deviceTypeId, deviceInstanceId)
},
methods: {
async init() {
async init(deviceTypeId, deviceInstanceId) {
// 获取所有设备类型
const deviceTypeList = await getAllDeviceModel()
this.deviceTypeList = deviceTypeList.data
if (this.deviceTypeList.length) {
this.form.deviceType = this.deviceTypeList[0].id
}
this.form.deviceType = deviceTypeId || (this.deviceTypeList.length ? this.deviceTypeList[0].id : null)
// 获取该设备类型下的设备实例
const deviceInstanceList = await getAllInstanceByDeviceTypeId({ deviceTypeId: this.form.deviceType })
this.deviceInstanceList = deviceInstanceList.data
if (this.deviceInstanceList.length) {
this.form.deviceInstance = this.deviceInstanceList[0].id
}
this.form.deviceInstance = deviceInstanceId || (this.deviceInstanceList.length ? this.deviceInstanceList[0].id : null)
// 根据设备类型 ID 获取关联数据模型
const dataModelList = await getDataModelByDeviceTypeId({ id: this.form.deviceType })
this.dataModelList = dataModelList.data
if (this.dataModelList.length) {
this.form.dataMode = this.dataModelList[0].id
this.propertyList = this.dataModelList[0].propertyList
if (this.propertyList.length) {
this.activeProperty = this.propertyList[0].propertyCode
}
this.activeProperty = this.propertyList.length ? this.propertyList[0].propertyCode : null
}
// 查询图表数据
await this.queryData()
......
......@@ -87,18 +87,24 @@
<template slot-scope="scope">
<el-button
type="text"
@click="goto('/device-management/device-detail')"
@click="goto('/device-management/device-detail', scope.row)"
>详情</el-button>
<el-button
type="text"
@click="goto('/device-management/device-monitoring')"
@click="goto('/device-management/device-monitoring', scope.row)"
>监控</el-button>
<el-button
type="text"
@click="goto('/device-management/history-data')"
@click="goto('/device-management/history-data', scope.row)"
>历史数据</el-button>
<el-button type="text" @click="goto('/device-alarm/alarm-show')">告警历史</el-button>
<el-button type="text" @click="editItem(scope.row)">编辑</el-button>
<el-button
type="text"
@click="goto('/device-alarm/alarm-show', scope.row)"
>告警历史</el-button>
<el-button
type="text"
@click="editItem(scope.row)"
>编辑</el-button>
<el-popconfirm
title="确定要删除此条记录吗?"
style="margin-left: 10px"
......@@ -234,8 +240,9 @@ export default {
this.dialogVisible = true
this.add = true
},
goto(url) {
this.$router.push(url)
goto(url, row) {
const { id, deviceTypeId } = row
this.$router.push({ path: url, query: { deviceTypeId, deviceInstanceId: id }})
},
getTableData(pageNum) {
const params = {
......
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