From 01b9e7244825cac11146e3961cafa6525dad56f1 Mon Sep 17 00:00:00 2001 From: web <candymxq888@outlook.com> Date: 星期五, 25 四月 2025 17:24:33 +0800 Subject: [PATCH] fix:水温监控添加定时器 --- .gitignore | 1 src/screen/flow.vue | 22 ++++++++++ src/views/screen/flow/ecology/index.vue | 2 src/layout/components/Navbar.vue | 2 src/views/screen/flow/warning/index.vue | 2 src/views/screen/temperature/monitor/index.vue | 50 ++++++++++++++++++++---- src/views/screen/flow/graphic/index.vue | 2 7 files changed, 67 insertions(+), 14 deletions(-) diff --git a/.gitignore b/.gitignore index 944c283..4f54387 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ node_modules .idea/ +dist diff --git a/src/layout/components/Navbar.vue b/src/layout/components/Navbar.vue index 3b8f805..96d390e 100644 --- a/src/layout/components/Navbar.vue +++ b/src/layout/components/Navbar.vue @@ -22,7 +22,7 @@ <!-- <el-dropdown-item command="setLayout" v-if="settingsStore.showSettings">--> <!-- <span>布局设置</span>--> <!-- </el-dropdown-item>--> - <el-dropdown-item divided command="logout"> + <el-dropdown-item command="logout"> <span>退出登录</span> </el-dropdown-item> </el-dropdown-menu> diff --git a/src/screen/flow.vue b/src/screen/flow.vue index e37bbb9..0bfb60a 100644 --- a/src/screen/flow.vue +++ b/src/screen/flow.vue @@ -11,6 +11,7 @@ 公告弹窗提示 <el-switch v-model="openWarn" /> </div> + <div class="top-login" v-if="userType !== '1'" @click="loginOut">退出登录</div> </div> <div class="nav"> <div v-for="(item,index) in btnList" :key="index" @click="navTo(item)" class="plain" :class="item.url === route.path ? 'active' : ''"> @@ -30,8 +31,9 @@ <script setup> import{ useRouter,useRoute } from 'vue-router' import {onMounted, ref, watch, onUnmounted} from "vue"; -import { getUserType } from '@/utils/auth' +import {getUserType, removeToken} from '@/utils/auth' import { warnHistory } from '@/api/screen/warning/index.js' +import {ElMessageBox} from "element-plus"; const router = useRouter() @@ -78,6 +80,19 @@ str += item.description + ',' }) text.value = str + }) +} + +// 退出登录 +const loginOut = () => { + ElMessageBox.confirm('确定注销并退出系统吗?', '提示', { + confirmButtonText: '确定', + cancelButtonText: '取消', + type: 'warning' + }).then((e) => { + removeToken() + window.location.reload(); + }) } @@ -133,6 +148,11 @@ right: 100px; cursor: pointer; } + .top-login{ + position: absolute; + right: 20px; + cursor: pointer; + } } .nav{ display: flex; diff --git a/src/views/screen/flow/ecology/index.vue b/src/views/screen/flow/ecology/index.vue index ce342f4..969b1c5 100644 --- a/src/views/screen/flow/ecology/index.vue +++ b/src/views/screen/flow/ecology/index.vue @@ -132,7 +132,7 @@ } } -// 新扎口图表 +// 更新图表 const updateLine = () => { const option = getLineOption(tongjiData.value, 'rgba(94,229,92,1)', 'rgba(94,229,92,0.2)') ssCharts.setOption(option) diff --git a/src/views/screen/flow/graphic/index.vue b/src/views/screen/flow/graphic/index.vue index c3c3016..364126c 100644 --- a/src/views/screen/flow/graphic/index.vue +++ b/src/views/screen/flow/graphic/index.vue @@ -33,7 +33,7 @@ // 抓拍 const handleSnap = (index) => { - ezKitList[index].capturePicture(`capture-${new Date().getTime()}`, 0.8); // 参数:回调函数,图片格式,质量(0-1) + ezKitList[index].capturePicture(`capture-${new Date().getTime()}`, 0.8); } // 获取监控点菜单 diff --git a/src/views/screen/flow/warning/index.vue b/src/views/screen/flow/warning/index.vue index 779de76..716aec9 100644 --- a/src/views/screen/flow/warning/index.vue +++ b/src/views/screen/flow/warning/index.vue @@ -97,7 +97,7 @@ // 导出报警报表 const exportWarnTabl = () => { - exportWarnHistory({ createTimeRange: searchData.createTimeRange }).then(res => { + exportWarnHistory(searchData).then(res => { exportBlobFile(res, '报警记录') }) } diff --git a/src/views/screen/temperature/monitor/index.vue b/src/views/screen/temperature/monitor/index.vue index bdd961c..89bec41 100644 --- a/src/views/screen/temperature/monitor/index.vue +++ b/src/views/screen/temperature/monitor/index.vue @@ -1,5 +1,5 @@ <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' @@ -15,12 +15,17 @@ 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() } // 获取水温监控点菜单 @@ -31,8 +36,16 @@ } // 获取监控点列表 -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 { @@ -41,22 +54,35 @@ } }) }) + + // 挂载定时器获取数据 + 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) { @@ -75,6 +101,12 @@ getTempMonitor() getMonitorList() getMonitorConfig() +}) + +onUnmounted(() => { + if(timer) { + clearInterval(timer) + } }) </script> @@ -105,7 +137,7 @@ <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> -- Gitblit v1.9.3