<template> <!-- 告警服务 实时告警 --> <div class="publicContainer realAlarmSS"> <el-form :model="pagParms" ref="queryRef" :inline="true" v-show="showSearch"> <el-form-item label="告警站点" prop="dataType"> <el-select clearable filterable v-model="pagParms.stCode" placeholder="请选择"> <el-option v-for="dict in rtuSiteInfo" :key="dict.stCode" :label="dict.stName" :value="dict.stCode"></el-option> </el-select> </el-form-item> <el-form-item label="告警级别" prop="warnLevel"> <el-select clearable v-model="pagParms.warnLevel" placeholder="请选择"> <el-option v-for="dict in dataTypes" :key="dict.value" :label="dict.label" :value="dict.value"></el-option> </el-select> </el-form-item> <el-form-item> <el-button type="primary" icon="Search" @click="handleQuery">搜索</el-button> <el-button icon="Refresh" @click="resetQuery">重置</el-button> </el-form-item> </el-form> <el-table v-loading="tableLoading" :data="tableData" @selection-change="handleSelectionChange" max-height="620"> <el-table-column type="selection" width="55" /> <el-table-column label="序号" type="index" width="55" /> <el-table-column label="告警站点" prop="stName" show-overflow-tooltip /> <el-table-column label="告警类型" prop="warnType"> <template #default="scope"> <span>{{ getChangeType(scope.row.warnType) }}</span> </template> </el-table-column> <el-table-column label="告警级别" prop="warnLevel"> <template #default="{ row }"> <span>{{ row.warnLevel == 'warn' ? '告警 ' : '预警 ' }}</span> </template> </el-table-column> <el-table-column label="告警因子" prop="warnFactorName" show-overflow-tooltip /> <el-table-column label="监测值" prop="warnFactorValueName" show-overflow-tooltip> <template #default="{ row }"> <span>{{ row.warnFactorValueName }}</span> <!-- <span>{{ row.warnFactorValueName.substring(1, row.warnFactorValueName.length - 1) }}</span> --> </template> </el-table-column> <el-table-column label="告警公式" prop="warnFormulaName"> </el-table-column> <el-table-column label="时间阈值(分钟)" prop="timeThreshold"> </el-table-column> <el-table-column label="告警时间" prop="warnDatetime" width="180"> <template #default="scope"> <span>{{ scope.row.warnDatetime }}</span> </template> </el-table-column> </el-table> <pagination v-show="total > 0" :total="total" v-model:page="pagParms.pageNum" v-model:limit="pagParms.pageSize" @pagination="searchData" /> </div> </template> <script setup name="realAlarm"> import { rtuWarnConfigPage } from '@/api/dataAnalysis/realAlarm'; import { rtuSiteInfoList } from '@/api/dataAnalysis/AlertService'; import { reactive } from 'vue'; const props = defineProps({ checkedKey: String, }); const { proxy } = getCurrentInstance(); const showSearch = ref(true); const tableData = ref([]); const tableLoading = ref(false); const total = ref(0); const dataTypes = reactive([ { label: '告警 ', value: 'warn ' }, { label: '预警 ', value: 'early_warn' }, ]); const rtuSiteInfo = ref([]); const pagParms = ref({ warnType: '', stCode: '', warnLevel: '', pageSize: 10, pageNum: 1 }); // 获取站点 async function getSiteSelectListM() { let { data } = await rtuSiteInfoList(); rtuSiteInfo.value = data; } //分页搜索 async function searchData() { tableLoading.value = true; let params = { ...pagParms.value }; let { data, total: totals } = await rtuWarnConfigPage(params); tableLoading.value = false; tableData.value = data; total.value = totals; } const typeList = [ { dictValue: 'water_level', dictLabel: '水位', }, { dictValue: 'flow', dictLabel: '流量', }, { dictValue: 'rain', dictLabel: '降雨 ', }, { dictValue: 'quality', dictLabel: '水质 ', }, { dictValue: 'other', dictLabel: '其它 ', }, ]; function getChangeType(e) { for (var i = 0; i < typeList.length; i++) { if (typeList[i].dictValue == e) { //dictValue,dictLabel保持和上面定义一致 return typeList[i].dictLabel; } } } /** 搜索按钮操作 */ function handleQuery() { pagParms.value.pageNum = 1; searchData(); } /** 重置按钮操作 */ function resetQuery() { pagParms.value.stCode = ''; pagParms.value.warnLevel = ''; searchData(); } // 多选框选中数据 function handleSelectionChange(selection) { ids.value = selection.map(item => item.id); single.value = selection.length != 1; multiple.value = !selection.length; } // 初始化 onMounted(() => { getSiteSelectListM(); searchData(); }); </script> <style lang="scss" scoped></style>