From 01b9e7244825cac11146e3961cafa6525dad56f1 Mon Sep 17 00:00:00 2001
From: web <candymxq888@outlook.com>
Date: 星期五, 25 四月 2025 17:24:33 +0800
Subject: [PATCH] fix:水温监控添加定时器

---
 src/screen/flow.vue |   49 +++++++++++++++++++++++++++++++++++++++++++------
 1 files changed, 43 insertions(+), 6 deletions(-)

diff --git a/src/screen/flow.vue b/src/screen/flow.vue
index 03c0a0c..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' : ''">
@@ -29,11 +30,11 @@
 </template>
 <script setup>
 import{ useRouter,useRoute } from 'vue-router'
-import useUserStore from '@/store/modules/user.js'
-import {onMounted, ref, watch} from "vue";
-import { getUserType } from '@/utils/auth'
+import {onMounted, ref, watch, onUnmounted} from "vue";
+import {getUserType, removeToken} from '@/utils/auth'
+import { warnHistory } from '@/api/screen/warning/index.js'
+import {ElMessageBox} from "element-plus";
 
-const userStore = useUserStore()
 
 const router = useRouter()
 const route = ref(useRoute())
@@ -48,7 +49,7 @@
 const userType = ref(getUserType())
 
 const openWarn = ref(false)
-const text = ref('新扎沟口流量监测点水位到达下限值, 金川水电站生态流量监测点水位到达下限值,流量监测点水位到达下限值')
+const text = ref('')
 let timer = null;
 
 watch(openWarn, (newVal) => {
@@ -71,9 +72,40 @@
     router.push(item.url)
 }
 
+// 获取报警内容
+const getWarnList = () => {
+    let str = ''
+    warnHistory({limit: 10, page: 1, monitorType: 2}).then(res => {
+        res.data.list?.forEach((item)=>{
+            str += item.description + ','
+        })
+        text.value = str
+    })
+}
+
+// 退出登录
+const loginOut = () => {
+    ElMessageBox.confirm('确定注销并退出系统吗?', '提示', {
+        confirmButtonText: '确定',
+        cancelButtonText: '取消',
+        type: 'warning'
+    }).then((e) => {
+        removeToken()
+        window.location.reload();
+
+    })
+}
+
 onMounted(() => {
-    if(userStore.userType == 1) {
+    getWarnList()
+    if(userType.value == 1) {
         btnList.value.push({name:'系统管理',url:'/user'})
+    }
+})
+
+onUnmounted(() => {
+    if(timer){
+        clearInterval(timer)
     }
 })
 
@@ -116,6 +148,11 @@
                 right: 100px;
                 cursor: pointer;
             }
+            .top-login{
+                position: absolute;
+                right: 20px;
+                cursor: pointer;
+            }
         }
         .nav{
             display: flex;

--
Gitblit v1.9.3