web
2025-03-19 ae8d9d380854076d0b2da145576ae08f14a8f835
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
<template>
    <div class="main">
        <div class="header">
            <div class="top">
                <div class="top-name">金川水电站生态流量监测系统</div>
                <div class="top-modal">
                    公告弹窗提示
                    <el-switch v-model="openWarn" />
                </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' : ''">
                    <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">
                <div class="text">{{text}}</div>
            </div>
        </div>
    </div>
</template>
<script setup>
import{ useRouter,useRoute } from 'vue-router'
import useUserStore from '@/store/modules/user.js'
import {onMounted, ref, watch} from "vue";
 
const userStore = useUserStore()
 
const router = useRouter()
const route = ref(useRoute())
const btnList = ref([
    {name:'首页总览',url:'/flow/home'},
    {name:'生态流量',url:'/flow/ecology'},
    {name:'图像监测', url:'/flow/graphic'},
    {name:'设备管理',url:'/flow/shebei'},
    {name:'报警管理',url:'/flow/warning'},
    {name:'报表管理',url:'/flow/report'},
])
 
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)
}
 
onMounted(() => {
    if(userStore.userType == 1) {
        btnList.value.push({name:'系统管理',url:'/user'})
    }
})
 
</script>
 
<style lang="scss" scoped>
.main{
    width: 100%;
    height: 100%;
    .header{
        width: 100%;
        height: 14%;
        background-color: rgb(82, 120, 128);
        position: relative;
        .top{
            height: 60%;
            display: flex;
            align-items: center;
            justify-content: center;
            font-weight: 700;
            color: #fff;
            position: relative;
            z-index: 100;
            .top-name{
                font-size: 48px;
            }
            .top-modal{
                position: absolute;
                right: 100px;
                cursor: pointer;
            }
        }
        .nav{
            display: flex;
            height: 40%;
            position: relative;
            z-index: 100;
            .plain{
                flex-grow: 1;
                height: 100%;
                display: flex;
                align-items: center;
                justify-content: center;
                border: 1px solid #fff;
                background-color: rgba(23, 108, 229, 0.3);
                color: #fff;
                font-size: 22px;
                cursor: pointer;
            }
            .active{
                background-color: #91BDDB;
            }
        }
    }
    .content{
        width: 100%;
        height: 86%;
        position: relative;
        .warningBox{
            position: absolute;
            left: 0;
            top: 2%;
            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>