| | |
| | | <template> |
| | | <div class="main"> |
| | | <div class="header"> |
| | | <div class="top">金川水电站生态流量监测系统 </div> |
| | | <div class="top"> |
| | | <div class="top-exit" v-if="userType === '1'" @click="() => { router.push('/screen') }"> |
| | | <img src="@/assets/images/exit.png" alt="" /> |
| | | <span>选择系统</span> |
| | | </div> |
| | | <div class="top-name">金川水电站生态流量监测系统</div> |
| | | <div class="top-modal"> |
| | | 公告弹窗提示 |
| | | <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' : ''">{{ item.name }}</div> |
| | | <div v-for="(item,index) in btnList" :key="index" @click="navTo(item)" class="plain" :class="item.url === route.path ? 'active' : ''"> |
| | | <span>{{ item.name }}</span> |
| | | </div> |
| | | </div> |
| | | </div> |
| | | <div class="content"> |
| | | <router-view></router-view> |
| | | <div class="warningBox" v-if="openWarn"> |
| | | <img src="@/assets/images/flow/warn-icon.png" alt=""> |
| | | <div class="text">{{text}}</div> |
| | | </div> |
| | | </div> |
| | | </div> |
| | | </template> |
| | | <script setup> |
| | | import{ useRouter,useRoute } from 'vue-router' |
| | | 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 router = useRouter() |
| | | const route = ref(useRoute()) |
| | |
| | | {name:'报警管理',url:'/flow/warning'}, |
| | | {name:'报表管理',url:'/flow/report'}, |
| | | ]) |
| | | const userType = ref(getUserType()) |
| | | |
| | | const openWarn = ref(false) |
| | | const text = ref('') |
| | | let timer = null; |
| | | |
| | | watch(openWarn, (newVal) => { |
| | | if(newVal){ |
| | | splitText() |
| | | } else { |
| | | clearInterval(timer) |
| | | } |
| | | }) |
| | | |
| | | // 设置警告滚动 |
| | | const splitText = () => { |
| | | timer = setInterval(function () { |
| | | const val = text.value.substring(1) + text.value.substring(0,1) |
| | | text.value = val |
| | | }, 300) |
| | | } |
| | | |
| | | const navTo = (item) =>{ |
| | | 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(() => { |
| | | getWarnList() |
| | | if(userType.value == 1) { |
| | | btnList.value.push({name:'系统管理',url:'/user'}) |
| | | } |
| | | }) |
| | | |
| | | onUnmounted(() => { |
| | | if(timer){ |
| | | clearInterval(timer) |
| | | } |
| | | }) |
| | | |
| | | </script> |
| | | |
| | |
| | | display: flex; |
| | | align-items: center; |
| | | justify-content: center; |
| | | font-size: 38px; |
| | | font-weight: 700; |
| | | color: #fff; |
| | | position: relative; |
| | | z-index: 100; |
| | | .top-exit{ |
| | | position: absolute; |
| | | left: 100px; |
| | | cursor: pointer; |
| | | font-size: 20px; |
| | | img{ |
| | | width: 30px; |
| | | vertical-align: top; |
| | | margin-right: 10px; |
| | | } |
| | | } |
| | | .top-name{ |
| | | font-size: 48px; |
| | | } |
| | | .top-modal{ |
| | | position: absolute; |
| | | right: 100px; |
| | | cursor: pointer; |
| | | } |
| | | .top-login{ |
| | | position: absolute; |
| | | right: 20px; |
| | | cursor: pointer; |
| | | } |
| | | } |
| | | .nav{ |
| | | display: flex; |
| | |
| | | .content{ |
| | | width: 100%; |
| | | height: 86%; |
| | | .warningBox{ |
| | | position: absolute; |
| | | left: 0; |
| | | top: 15.5%; |
| | | z-index: 100; |
| | | width: 100%; |
| | | padding: 0 150px; |
| | | height: 100px; |
| | | display: flex; |
| | | align-items: center; |
| | | background: linear-gradient( 270deg, |
| | | rgba(255,74,74,0) 0%, |
| | | rgba(255,74,74,0.5) 8%, |
| | | rgba(255,74,74,0.5) 50%, |
| | | rgba(255,74,74,0.5) 92%, |
| | | rgba(255,74,74,0) 100%); |
| | | .text{ |
| | | margin: 0 30px; |
| | | color: #fff; |
| | | font-size: 36px; |
| | | overflow: hidden; |
| | | white-space: nowrap; |
| | | } |
| | | } |
| | | } |
| | | } |
| | | </style> |