2024-01-17 18:54:45 +08:00

418 lines
14 KiB
Vue

<template>
<!-- 有毒气体监测-告警监测 -->
<!-- <vue-scroll style="height: 100%"> -->
<div class="fullHeight">
<div class="searchBox whiteBlock">
<el-form :inline="true" size="medium" class="demo-form-inline">
<el-form-item label="设备名称">
<el-select v-model="devName" placeholder="请选择">
<el-option :label="item.devName" :value="item.devSn" v-for="(item, index) in towerList" :key="item.devSn"></el-option>
</el-select>
</el-form-item>
<el-form-item>
<el-button type="primary" @click="onSubmit" plain>查询</el-button>
<el-button type="warning" plain @click="refreshBtn">刷新</el-button>
</el-form-item>
</el-form>
</div>
<div class="table_wrap whiteBlock">
<el-table :data="tableData" class="tables" style="width: 100%" height="600px">
<el-table-column prop="devName" align="center" label="设备名称"> </el-table-column>
<el-table-column prop="alarmDetail" align="center" label="告警详情"> </el-table-column>
<el-table-column prop="alarmTime" align="center" label="告警时间"> </el-table-column>
<el-table-column prop="monitorObject" align="center" label="监测气体">
<template slot-scope="scope">{{
scope.row.monitorObject == 1 ? '氧气' : scope.row.monitorObject == 2 ? '甲烷' : '一氧化碳'
}}</template>
</el-table-column>
<el-table-column prop="gasVal" align="center" label="监测值">
<template slot-scope="scope">{{
scope.row.monitorObject == 1
? scope.row.gasVal + '(%VOL)'
: scope.row.monitorObject == 2
? scope.row.gasVal + '(%LEL)'
: scope.row.gasVal + '(ppm)'
}}</template>
</el-table-column>
<el-table-column prop="alarmType" align="center" label="状态">
<template slot-scope="scope">
<div v-if="scope.row.alarmType">
{{alarmTypeOptions[scope.row.alarmType - 1].desc}}
</div>
</template>
</el-table-column>
<el-table-column label="操作" align="center" width="250">
<template slot-scope="scope">
<div class="tableBtns">
<div @click="dispBtn(scope.row.id)" class="operationText" v-if="scope.row.handleDone == 0">
<span style="background: #5181f6; color: #fff; width: 60px">待处置</span>
</div>
<div @click="closedBtn(scope.row)" class="operationText" v-else>
<span style="background: #a2a4af; color: #fff; width: 60px">已闭合</span>
</div>
<div class="operationText last" @click="detailBtn(scope.row)">
<i class="el-icon-tickets" style="color: #8dacfa; font-size: 16px; margin-right: 2px"></i>
<span>详情</span>
</div>
<div @click="deleteDev(scope.row)" class="operationText">
<img src="@/assets/images/icon-delete.png" width="15px" height="15px" />
<span>删除</span>
</div>
</div>
</template>
</el-table-column>
</el-table>
<el-pagination
class="pagerBox"
@size-change="handleSizeChange"
@current-change="handleCurrentChange"
:current-page="pageNo"
:page-sizes="$store.state.PAGESIZRS"
:page-size="pageSize"
layout="total, sizes, prev, pager, next"
:total="Number(total)"
background
></el-pagination>
</div>
<!-- 处置记录弹框-->
<el-dialog :modal-append-to-body="false" @close="close" :title="disTitle" :visible.sync="recordShow" width="667px">
<div class="dialog_content">
<el-form size="medium" ref="addEditForm" :model="addEditForm" :rules="addEditRules" label-width="120px" class="dialogFormBox">
<el-form-item label="操作人" v-if="disTitle == '处置记录'">
<el-input v-model="addEditForm.operateName" disabled></el-input>
</el-form-item>
<el-form-item label="操作时间" v-if="disTitle == '处置记录'">
<el-input v-model="addEditForm.operateTime" disabled></el-input>
</el-form-item>
<el-form-item label="处置结果" prop="handleResult">
<el-radio v-model="addEditForm.handleResult" :label="1" :disabled="disTitle == '处置记录'">已处置</el-radio>
<el-radio v-model="addEditForm.handleResult" :label="2" :disabled="disTitle == '处置记录'">误报忽略</el-radio>
</el-form-item>
<el-form-item label="描述" prop="description">
<el-input
:disabled="disTitle == '处置记录'"
type="textarea"
:rows="2"
v-model="addEditForm.description"
:placeholder="disTitle == '处置记录' ? '' : '请输入'"
></el-input>
</el-form-item>
<el-form-item label="上传图片" prop="image">
<el-upload
:disabled="disTitle == '处置记录'"
:action="$store.state.UPLOADURL"
list-type="picture-card"
multiple
name="files"
:limit="1"
:file-list="fileList"
:on-success="handleSuccess"
:on-remove="handleRemove"
>
<i class="el-icon-plus"></i>
</el-upload>
</el-form-item>
<div class="dialog-footer">
<el-button class="cancleBtn" icon="el-icon-circle-close" size="medium" @click="recordShow = false">取消 </el-button>
<el-button
@click="addBtn"
type="primary"
icon="el-icon-circle-check"
size="medium"
v-if="disTitle == '处置详情' || disTitle == '修改处置记录'"
>确定
</el-button>
<el-button v-if="disTitle == '处置记录'" type="primary" icon="el-icon-edit-outline" size="medium" @click="editRecord"
>修改
</el-button>
</div>
</el-form>
</div>
</el-dialog>
<!-- 详情弹框-->
<el-dialog :modal-append-to-body="false" title="详情" :visible.sync="detailsShow" width="667px">
<div class="dialog_content">
<el-form size="medium" label-width="120px" class="dialogFormBox">
<el-form-item label="安装位置">
<el-input v-model="detailData.location" disabled></el-input>
</el-form-item>
<el-form-item label="设备名称">
<el-input v-model="detailData.devName" disabled></el-input>
</el-form-item>
<el-form-item label="编号">
<el-input v-model="detailData.devSn" disabled></el-input>
</el-form-item>
<el-form-item label="监测对象">
<el-input v-model="detailData.monitorObject" disabled></el-input>
</el-form-item>
<el-form-item label="告警详情">
<el-input v-model="detailData.alarmDetail" disabled></el-input>
</el-form-item>
<el-form-item label="报警时间">
<el-input v-model="detailData.alarmTime" disabled></el-input>
</el-form-item>
<div class="dialog-footer">
<el-button @click="detailsShow = false" type="primary" size="medium">关闭 </el-button>
</div>
</el-form>
</div>
</el-dialog>
</div>
<!-- </vue-scroll> -->
</template>
<script>
import {
getPoisonousGasDevAlarmTypeEnum, // 告警状态枚举
deletePoisonousGasDevAlarmApi,
getPoisonousGasDevAlarmPageApi,
editPoisonousGasDevAlarmApi,
getPoisonousGasDevListApi //设备下拉
} from '@/assets/js/api/edgeProtection'
export default {
data() {
return {
// 报警状态 1低报警2高报警3超量程4故障5、A2报警6、A1报警
alarmTypeOptions: [
// {
// value: 1,
// desc: '低报警'
// },
// {
// value: 2,
// desc: '高报警'
// },
// {
// value: 3,
// desc: '超量程'
// },
// {
// value: 4,
// desc: '故障'
// },
// {
// value: 5,
// desc: 'A2报警'
// },
// {
// value: 6,
// desc: 'A1报警'
// }
],
detailData: {},
disTitle: '',
fileList: [],
dialogShow: false, //处置详情弹框
recordShow: false, //处置记录弹框
detailsShow: false, //详情弹框
addEditForm: {
operateName: '', //操作人
operateTime: '', //操作时间
handleResult: 1,
description: '',
handleDone: 0,
image: '',
id: ''
// monitorObject: '',
// alarmDetail: '',
// alarmTime: '',
},
addEditRules: {
handleResult: [
{ required: true, message: '必填', trigger: 'blur' },
{ required: true, message: '必填', trigger: 'change' }
]
},
projectSn: '',
towerList: [],
devName: '',
time: [],
pageNo: 1,
pageSize: 10,
total: 0,
tableData: []
}
},
created() {
this.projectSn = this.$store.state.projectSn
this.getTowerList()
this.getListData()
this.getAlarmTypeEnum()
},
methods: {
//获取设备下拉
getTowerList() {
let data = {
projectSn: this.projectSn
}
getPoisonousGasDevListApi(data).then(res => {
if (res.code == 200) {
this.towerList = res.result
}
})
},
// 烟感告警状态枚举
getAlarmTypeEnum() {
let data = {
projectSn: this.projectSn
}
getPoisonousGasDevAlarmTypeEnum(data).then(res => {
if (res.code == 200) {
console.log("告警枚举",res)
this.alarmTypeOptions = res.result
}
})
},
//查询数据
getListData() {
let data = {
queryStartTime: this.time.length > 0 ? this.time[0] : '',
queryEndTime: this.time.length > 0 ? this.time[1] : '',
pageNo: this.pageNo,
pageSize: this.pageSize,
projectSn: this.projectSn,
devSn: this.devName
}
getPoisonousGasDevAlarmPageApi(data).then(res => {
if (res.code == 200) {
console.log('查询告警监测数据', res)
this.tableData = res.result.records
this.total = res.result.total
res.result.records.map(item => {
if (item.image != null) {
item.image = JSON.parse(item.image)
if (item.image.length !== 0 && !item.image[0].url.includes(this.$store.state.FILEURL)) {
item.image[0].url = this.$store.state.FILEURL + item.image[0].url
}
} else {
item.image = []
}
})
}
})
},
//删除
deleteDev(obj) {
this.$confirm('此操作将永久删除, 是否继续?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
})
.then(() => {
deletePoisonousGasDevAlarmApi({ id: obj.id }).then(result => {
if (result.success) {
this.$message.success(result.message)
this.getListData()
}
})
})
.catch(() => {})
},
//点击待处置
dispBtn(val) {
this.disTitle = '处置详情'
this.recordShow = true
this.addEditForm.id = val
this.addEditForm.handleResult = 1
},
//点击已闭合
closedBtn(obj) {
this.recordShow = true
this.disTitle = '处置记录'
this.fileList = obj.image
this.addEditForm = JSON.parse(JSON.stringify(obj))
},
//点击详情修改
editRecord() {
this.disTitle = '修改处置记录'
this.dialogShow = true
},
//待处置提交
addBtn() {
this.processTheFile()
let params = JSON.parse(JSON.stringify(this.addEditForm))
params.projectSn = this.$store.state.projectSn
params.handleDone = 1
this.$refs.addEditForm.validate(valid => {
if (valid) {
if (this.disTitle == '处置详情' || this.disTitle == '修改处置记录') {
editPoisonousGasDevAlarmApi(params).then(result => {
if (result.success) {
this.$message.success(result.message)
this.getListData()
}
})
}
this.recordShow = false
} else {
return false
}
})
},
//查询数据
onSubmit() {
this.getListData()
},
//查看详情
detailBtn(val) {
this.detailData = val
this.detailsShow = true
console.log('查看详情', val)
this.addEditForm = JSON.parse(JSON.stringify(val))
this.fileList = val.image
},
//刷新
refreshBtn() {
this.time = []
this.pageNo = 1
this.pageSize = 10
this.devName = ''
this.getListData()
},
processTheFile() {
//处理el上传的文件格式(结构)
this.addEditForm.image = []
this.fileList.map(item => {
if (!item.response) {
this.addEditForm.image.push(item)
} else if (item.response) {
this.addEditForm.image.push({
name: item.response.data[0].filename,
url: item.response.data[0].imageUrl
})
}
})
this.addEditForm.image = JSON.stringify(this.addEditForm.image)
},
handleSuccess(response, file, fileList) {
console.log('图片上传成功', fileList)
this.fileList = fileList
},
handleRemove(response, fileList) {
this.fileList = fileList
},
handleSizeChange(val) {
this.pageSize = val
this.getListData()
},
handleCurrentChange(val) {
this.pageNo = val
this.getListData()
},
close() {
this.addEditForm = {}
this.fileList = []
this.$nextTick(() => {
this.$refs.addEditForm.clearValidate()
})
}
}
}
</script>
<style lang="less" scoped></style>