| | |
| | | <script setup> |
| | | import {ref, onMounted} from "vue"; |
| | | import {ref, onMounted, onUnmounted} from "vue"; |
| | | import {getUserType} from '@/utils/auth.js' |
| | | import {setTempMonitor, getTempMonitorConfig, editTempMonitorConfig} from '@/api/screen/monitor/index.js' |
| | | import {getTemperaturePointList} from '@/api/screen/index.js' |
| | |
| | | const userType = ref(getUserType()) |
| | | const monitorRef = ref() |
| | | const searchVal = ref('') |
| | | let timer = null; |
| | | |
| | | // 选择菜单 |
| | | const handleSelectMenu = (id) => { |
| | | pointApi().get(id).then(res => { |
| | | monitorList.value = [res.data] |
| | | }) |
| | | clearInterval(timer) |
| | | getMonitorList(id) |
| | | } |
| | | |
| | | // 搜索 |
| | | const handleSearch = () => { |
| | | getMonitorList() |
| | | } |
| | | |
| | | // 获取水温监控点菜单 |
| | |
| | | } |
| | | |
| | | // 获取监控点列表 |
| | | const getMonitorList = () => { |
| | | pointApi().search({type: 1, page: 1, limit: 100, keywords: searchVal.value}).then(res => { |
| | | const getMonitorList = (id) => { |
| | | clearInterval(timer) |
| | | const data = { |
| | | type: 1, |
| | | page: 1, |
| | | limit: 100, |
| | | keywords: searchVal.value, |
| | | pointId: id || '' |
| | | } |
| | | pointApi().search(data).then(res => { |
| | | //0-未报警, 1-下限报警, 2-上限报警 |
| | | monitorList.value = res.data.list.filter(el => el.parentId !== 0).map(item => { |
| | | return { |
| | |
| | | } |
| | | }) |
| | | }) |
| | | |
| | | // 挂载定时器获取数据 |
| | | timer = setInterval(() => { |
| | | pointApi().search(data).then(res => { |
| | | monitorList.value = res.data.list.filter(el => el.parentId !== 0).map(item => { |
| | | return { |
| | | ...item, |
| | | errorType: Number(item.waterTemperature) < Number(item.lowWaterLevel) ? 1 : Number(item.waterTemperature) > Number(item.tallWaterLevel) ? 2 : 0 |
| | | } |
| | | }) |
| | | }) |
| | | }, 5000) |
| | | } |
| | | |
| | | // 获取监控点参数 |
| | | // 获取监控点配置 |
| | | const getMonitorConfig = () => { |
| | | getTempMonitorConfig().then(res => { |
| | | monitorConfig.value = res.data |
| | | }) |
| | | } |
| | | |
| | | // 设置监控点参数 |
| | | // 设置监控点配置 |
| | | const setMonitorConfig = () => { |
| | | editTempMonitorConfig(monitorConfig.value).then(res => { |
| | | ElMessage.success('设置成功') |
| | | }) |
| | | } |
| | | |
| | | // 监控点参数设置 |
| | | const setMonitorData = (data) => { |
| | | setTempMonitor(data).then(res => { |
| | | if (res.code === 200) { |
| | |
| | | getTempMonitor() |
| | | getMonitorList() |
| | | getMonitorConfig() |
| | | }) |
| | | |
| | | onUnmounted(() => { |
| | | if(timer) { |
| | | clearInterval(timer) |
| | | } |
| | | }) |
| | | |
| | | </script> |
| | |
| | | <div class="monitor-tool"> |
| | | <div class="tool-l"> |
| | | <el-input v-model="searchVal" style="width: 20rem" placeholder="请输入监测点名称" clearable/> |
| | | <el-button @click="getMonitorList"> |
| | | <el-button @click="handleSearch"> |
| | | <el-icon> |
| | | <Search/> |
| | | </el-icon> |