<template> <!-- 告警配置 --> <div class="publicContainer"> <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 type="success" icon="Refresh" @click="resetQuery">重置</el-button> <el-button type="primary" plain icon="Plus" @click="handleAdd(_, 1)">新增</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="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="stName" width="200" show-overflow-tooltip /> <el-table-column label="告警因子" prop="warnFactorName" show-overflow-tooltip /> <el-table-column label="告警公式" prop="warnFormulaName" width="200" show-overflow-tooltip></el-table-column> <el-table-column label="时间阈值(分钟)" prop="timeThreshold"></el-table-column> <el-table-column label="状态" prop="status"> <template #default="scope"> <el-tag effect="dark" class="ml-2" :type="scope.row.status == 1 ? 'success' : 'danger'"> {{ scope.row.status == 1 ? '启用 ' : '停用' }} </el-tag> </template> </el-table-column> <el-table-column label="创建时间" prop="createTime" width="180"> <template #default="scope"> <span>{{ scope.row.createTime }}</span> </template> </el-table-column> <el-table-column label="操作" width="160" class-name="small-padding fixed-width"> <template #default="scope"> <el-button link type="primary" icon="Edit" @click="handleAdd(scope.row, 2)" v-hasPermi="['dataAnalysis:rtuSiteInfo:edit']"> 修改 </el-button> <el-button link type="danger" icon="Delete" @click="handleDelete(scope.row)" v-hasPermi="['dataAnalysis:rtuSiteInfo:remove']"> 删除 </el-button> </template> </el-table-column> </el-table> <pagination v-show="totals > 0" :total="totals" v-model:page="queryParams.pageNum" v-model:limit="queryParams.pageSize" @pagination="rtuWarnConfigPageM(queryParams)" /> <!-- 新增修改弹窗 --> <el-dialog v-model="dialogShow" :title="dialogTitle" width="800px" append-to-body class="equipmentDialog"> <AlertServiceAdd @closeEd="closeEd" :infoList="infoList" :key="keyLit"></AlertServiceAdd> </el-dialog> </div> </template> <script setup name="syntheticData"> import bus from '@/utils/mitt'; import { rtuWarnConfigPage, rtuWarnConfigInfo, rtuWarnConfDelete, rtuSiteInfoList } from '@/api/dataAnalysis/AlertService'; import AlertServiceAdd from './alertServiceAdd.vue'; //新增告警弹窗 const { proxy } = getCurrentInstance(); const showSearch = ref(true); const tableData = ref([]); const tableLoading = ref(false); const dialogShow = ref(false); const dialogTitle = ref('新增告警'); const totals = ref(0); // 变量声明 const data = reactive({ form: {}, queryParams: { pageNum: 1, pageSize: 10, dataType: '', dateTime: [], }, }); const { queryParams, form } = toRefs(data); const dataTypes = reactive([ { label: '告警 ', value: 'warn' }, { label: '预警 ', value: 'early_warn' }, ]); const rtuSiteInfo = ref([]); const pagParms = ref({ pageNum: 1, pageSize: 10 }); // 方法 //获取站点下拉 async function getSiteSelectListM(p) { let { data } = await rtuSiteInfoList(p); rtuSiteInfo.value = data; } //分页搜索告警规则 async function rtuWarnConfigPageM(p) { let { data, total } = await rtuWarnConfigPage(p); tableLoading.value = false; tableData.value = data; totals.value = total; } 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() { queryParams.value.pageNum = 1; tableLoading.value = true; rtuWarnConfigPageM(pagParms.value); } /** 重置按钮操作 */ function resetQuery() { tableLoading.value = true; pagParms.value.stCode = ''; pagParms.value.warnLevel = ''; rtuWarnConfigPageM(pagParms.value); } // 多选框选中数据 function handleSelectionChange(selection) { ids.value = selection.map(item => item.id); single.value = selection.length != 1; multiple.value = !selection.length; } //获取详情接口 const keyLit = ref(0); const infoList = ref({}); function handleAdd({ id }, t) { dialogShow.value = true; if (t == 2) { dialogTitle.value = '修改告警'; rtuWarnConfigInfo(id).then(({ data }) => { infoList.value = data; keyLit.value++; }); } else { dialogTitle.value = '新增告警'; infoList.value = {}; keyLit.value++; } infoList.value.type = t; } function closeEd() { dialogShow.value = false; rtuWarnConfigPageM(pagParms.value); } //删除成功 function handleDelete(row) { proxy.$modal .confirm('是否确认删除?') .then(function () { rtuWarnConfDelete(row.id).then(({ code }) => { if (code == 200) { rtuWarnConfigPageM(pagParms.value); } }); }) .then(() => { proxy.$modal.msgSuccess('删除成功'); }) .catch(() => {}); } // 初始化 onMounted(() => { handleQuery(); bus.on('mapPointClick3', type => { tableLoading.value = true; pagParms.value.warnType = type; rtuWarnConfigPageM(pagParms.value); }); getSiteSelectListM(); }); // 页面销毁 onBeforeUnmount(() => { bus.off('mapPointClick3'); }); </script> <style lang="scss" scoped></style>