<template> <div> <el-row :gutter="10" class="mb8"> <el-col :span="1.5"> <el-button type="primary" plain icon="Plus" @click="handleAddMonitor" >新增</el-button > </el-col> </el-row> <el-table v-loading="monitorLoading" :data="monitorList" border :max-height="500" > <el-table-column label="序号" type="index" width="55" align="center" /> <el-table-column label="站点编号" align="center" prop="stCode" /> <el-table-column label="站点名称" align="center" prop="stName" /> <el-table-column label="监测项名称" align="center" prop="monitorValue" show-overflow-tooltip /> <el-table-column label="监测项编号" align="center" prop="monitorCode" /> <el-table-column label="监测范围" align="center"> <template #default="scope"> <span>{{ scope.row.minValue }}--{{ scope.row.maxValue }}</span> </template> </el-table-column> <el-table-column label="异常值" align="center" prop="exceptionValue" /> <el-table-column label="操作" align="center" width="200" class-name="small-padding fixed-width" > <template #default="scope"> <el-button link type="primary" icon="Edit" @click="handleUpdate(scope.row)" v-hasPermi="['newfiber-business-base:rtuSiteInfo:edit']" >修改</el-button > <el-button link type="primary" icon="Delete" @click="handleDelete(scope.row)" v-hasPermi="['newfiber-business-base:rtuSiteInfo:remove']" >删除</el-button > </template> </el-table-column> </el-table> <pagination v-show="monitorTotal > 0" :total="monitorTotal" v-model:page="queryParams.pageNum" v-model:limit="queryParams.pageSize" @pagination="getMonitorList" /> <!-- 添加或修改RTU站点对话框 --> <el-dialog :title="title" v-model="open" width="900px" append-to-body> <el-form ref="rtuSiteMonitorInfoRef" :model="form" :rules="rules" label-width="150px" > <el-row> <el-col :span="12"> <el-form-item label="监测对象类型" prop="monitorCode"> <el-select v-model="form.monitorCode" placeholder="请选择"> <el-option v-for="dict in monitorCodeList" :key="dict.code" :label="dict.name" :value="dict.code" ></el-option> </el-select> </el-form-item> </el-col> <el-col :span="12"> <el-form-item label="最小值" prop="minValue"> <el-input v-model="form.minValue" placeholder="请输入最小值" /> </el-form-item> </el-col> <el-col :span="12"> <el-form-item label="最大值" prop="maxValue"> <el-input v-model="form.maxValue" placeholder="请输入最大值" /> </el-form-item ></el-col> <el-col :span="12"> <el-form-item label="异常值" prop="exceptionValue"> <el-input v-model="form.exceptionValue" placeholder="请输入异常值" /> </el-form-item> </el-col> <el-col :span="24"> <el-form-item label="备注" prop="remark"> <el-input type="textarea" v-model="form.remark" placeholder="请输入备注" /> </el-form-item> </el-col> </el-row> </el-form> <template #footer> <div class="dialog-footer"> <el-button type="primary" @click="submitForm">确 定</el-button> <el-button @click="cancel">取 消</el-button> </div> </template> </el-dialog> </div> </template> <script setup> import { pageRtuSiteMonitor, getRtuSiteMonitor, addRtuSiteMonitor, updateRtuSiteMonitor, delRtuSiteMonitor, } from "@/api/dataAnalysis/rtuSiteMonitor"; import { listRtuMonitorProperty } from "@/api/dataAnalysis/rtuMonitorProperty"; import { findDictObj } from "@/utils/ruoyi.js"; const { proxy } = getCurrentInstance(); const loading = ref(false); const open = ref(false); const title = ref(""); const monitorLoading = ref(false); const monitorCodeList = ref([]); //监测因子列表 const monitorList = ref([]); //站点配置的监测项列表 const monitorTotal = ref(0); const data = reactive({ form: {}, rules: { siteType: [ { required: true, message: "站点类型不能为空", trigger: "change" }, ], monitorTargetType: [ { required: true, message: "监测对象类型不能为空", trigger: "change" }, ], buildType: [ { required: true, message: "建设方式不能为空", trigger: "change" }, ], stName: [{ required: true, message: "站点不能为空", trigger: "blur" }], stCode: [{ required: true, message: "站点编号不能为空", trigger: "blur" }], }, queryParams: { pageNum: 1, pageSize: 10, }, }); const { queryParams, form, rules, monitorQueryParams } = toRefs(data); const props = defineProps({ //刷新标志 refresh: { type: [String, Number], default: 1, }, //行数据 row: { type: Object, default: {}, }, }); watch( () => props.refresh, () => { queryParams.value = { pageNum: 1, pageSize: 10, }; getList(); getListRtuMonitorProperty(); }, { deep: true, immediate: true, } ); function getList() { queryParams.value.stCode = props.row.stCode; loading.value = true; pageRtuSiteMonitor(queryParams.value).then((res) => { monitorList.value = res.data; monitorTotal.value = res.total; monitorLoading.value = false; }); } //获取监测项 function getListRtuMonitorProperty() { listRtuMonitorProperty().then((res) => { monitorCodeList.value = res.data; }); } function handleAddMonitor() { reset(); open.value = true; title.value = "新增监测项"; } // 表单重置 function reset() { form.value = { exceptionValue: 0, id: null, maxValue: 0, minValue: 0, monitorCode: "", monitorValue: "", previousTt: "", previousValue: "", remark: "", stCode: "", status: "", tt: "", updateBy: "", updateTime: "", ut: "", valueTrend: "", }; proxy.resetForm("rtuSiteMonitorInfoRef"); } // 取消按钮 function cancel() { open.value = false; reset(); } /** 修改按钮操作 */ function handleUpdate(row) { reset(); const _id = row.id || ids.value; getRtuSiteMonitor(_id).then((response) => { form.value = response.data; open.value = true; title.value = "修改监测项"; }); } /** 提交按钮 */ function submitForm() { proxy.$refs["rtuSiteMonitorInfoRef"].validate((valid) => { if (valid) { form.value.stCode = props.row.stCode; form.value.monitorValue = findDictObj( form.value.monitorCode, "code", monitorCodeList.value ).name; if (form.value.id != null) { updateRtuSiteMonitor(form.value).then((response) => { proxy.$modal.msgSuccess("修改成功"); open.value = false; getList(); }); } else { addRtuSiteMonitor(form.value).then((response) => { proxy.$modal.msgSuccess("新增成功"); open.value = false; getList(); }); } } }); } /** 删除按钮操作 */ function handleDelete(row) { const _ids = row.id || ids.value; proxy.$modal .confirm("是否确认删除?") .then(function () { return delRtuSiteMonitor(_ids); }) .then(() => { getList(); proxy.$modal.msgSuccess("删除成功"); }) .catch(() => {}); } </script>