Commit 430a8830 authored by wends's avatar wends

update 增加跳转

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