<template>
|
<div class="navbar">
|
<!-- <hamburger id="hamburger-container" :is-active="sidebar.opened" class="hamburger-container" @toggleClick="toggleSideBar" /> -->
|
<div class="title">通信电源监控主站测控系统</div>
|
<div class="info">
|
<!-- 左边 -->
|
<div class="left">
|
<div class="box">
|
分闸开关
|
<div class="num">{{ offSwitch }}</div>
|
</div>
|
<div class="box">
|
合闸开关
|
<div class="num">{{ onSwitch }}</div>
|
</div>
|
</div>
|
<!-- 右边 -->
|
<div class="right">
|
<!-- <div class="box">
|
开关告警数
|
<div class="num">4</div>
|
</div>
|
<div class="box">
|
跳闸开关
|
<div class="num">12</div>
|
</div> -->
|
<div class="box">
|
跳闸开关
|
<div class="num">{{ breakSwitch }}</div>
|
</div>
|
<div class="connect-state">
|
<div class="state">{{ isTimeout ? "离线" : "在线" }}</div>
|
<div :class="['i', { danger: isTimeout }]"></div>
|
</div>
|
</div>
|
</div>
|
<div class="right-menu">
|
<el-dropdown
|
class="avatar-container right-menu-item hover-effect"
|
trigger="hover"
|
>
|
<div class="avatar-wrapper">
|
<span class="user-name">{{ name }}</span>
|
<i class="el-icon-caret-bottom" />
|
</div>
|
<el-dropdown-menu slot="dropdown">
|
<el-dropdown-item @click.native="changePwd">
|
<span style="display: block">修改密码</span>
|
</el-dropdown-item>
|
<el-dropdown-item @click.native="logout">
|
<span style="display: block">退出登录</span>
|
</el-dropdown-item>
|
</el-dropdown-menu>
|
</el-dropdown>
|
</div>
|
<!-- 密码修改 -->
|
<el-dialog
|
title="密码修改"
|
width="400px"
|
:visible.sync="changePwdVisible"
|
:close-on-click-modal="false"
|
top="0"
|
class="dialog-center"
|
:modal-append-to-body="false"
|
>
|
<pwd-change
|
v-if="changePwdVisible"
|
:visible.sync="changePwdVisible"
|
></pwd-change>
|
</el-dialog>
|
</div>
|
</template>
|
|
<script>
|
import { mapGetters } from "vuex";
|
// import Hamburger from '@/components/Hamburger'
|
import PwdChange from "./PwdChange";
|
|
import createWs from "@/assets/js/websocket/plus";
|
const WSMixin = createWs("switch");
|
|
export default {
|
mixins: [WSMixin],
|
components: {
|
// Hamburger,
|
PwdChange,
|
},
|
computed: {
|
...mapGetters(["sidebar", "avatar", "device", "name"]),
|
isTimeout() {
|
let time = new Date(this.recordTime).getTime();
|
let stamp = new Date(this.nowTime).getTime();
|
|
return Math.abs(time - stamp) > 2 * 60 * 1000;
|
},
|
},
|
data() {
|
return {
|
breakSwitch: 0,
|
onSwitch: 0,
|
offSwitch: 0,
|
recordTime: -200 * 1000,
|
nowTime: 0,
|
changePwdVisible: false,
|
};
|
},
|
methods: {
|
onWSMessage1(res) {
|
let {
|
data: { onSwitch, offSwitch, recordTime, nowTime, breakSwitch },
|
} = JSON.parse(res.data);
|
// console.log(data, "=====data??", data2);
|
this.breakSwitch = breakSwitch;
|
this.onSwitch = onSwitch;
|
this.offSwitch = offSwitch;
|
this.recordTime = recordTime;
|
this.nowTime = nowTime;
|
},
|
changePwd() {
|
this.changePwdVisible = true;
|
},
|
toggleSideBar() {
|
this.$store.dispatch("app/toggleSideBar");
|
},
|
async logout() {
|
await this.$store.dispatch("user/logout");
|
this.$router.push(`/login?redirect=${this.$route.fullPath}`);
|
},
|
},
|
};
|
</script>
|
|
<style lang="less" scoped>
|
.navbar {
|
height: 104px;
|
overflow: hidden;
|
position: relative;
|
color: #fff;
|
background: #011f39 url("../../assets/images/header-bg.png") 50% 50% / auto
|
100% no-repeat;
|
box-shadow: 0 1px 4px rgba(0, 21, 41, 0.08);
|
.title {
|
font-size: 34px;
|
font-weight: bold;
|
text-align: center;
|
line-height: 76px;
|
letter-spacing: 6px;
|
}
|
.info {
|
position: absolute;
|
left: 0;
|
right: 0;
|
top: 30px;
|
bottom: 0;
|
display: flex;
|
.left,
|
.right {
|
width: 50%;
|
display: flex;
|
justify-content: center;
|
}
|
.left {
|
// padding-right: 380px;
|
padding-right: 264px;
|
}
|
.right {
|
padding-left: 264px;
|
}
|
.box {
|
display: inline-block;
|
width: 160px;
|
height: 40px;
|
line-height: 38px;
|
font-size: 16px;
|
border: 1px #5ec7d4 solid;
|
border-radius: 10px;
|
text-align: center;
|
.num {
|
display: inline-block;
|
height: 36px;
|
min-width: 36px;
|
padding: 6px;
|
background: #78eef8;
|
margin-top: 1px;
|
line-height: 24px;
|
border-radius: 18px;
|
color: #011f39;
|
margin-left: 1.2em;
|
}
|
& + .box {
|
margin-left: 10px;
|
}
|
}
|
.connect-state {
|
height: 40px;
|
display: flex;
|
margin-left: 10px;
|
align-items: center;
|
}
|
}
|
.hamburger-container {
|
line-height: 46px;
|
height: 100%;
|
float: left;
|
cursor: pointer;
|
transition: background 0.3s;
|
-webkit-tap-highlight-color: transparent;
|
|
&:hover {
|
background: rgba(0, 0, 0, 0.025);
|
}
|
}
|
|
.breadcrumb-container {
|
float: left;
|
}
|
|
.errLog-container {
|
display: inline-block;
|
vertical-align: top;
|
}
|
|
.right-menu {
|
position: absolute;
|
right: 0;
|
top: 0;
|
height: 100%;
|
line-height: 50px;
|
padding-top: 40px;
|
&:focus {
|
outline: none;
|
}
|
|
.right-menu-item {
|
display: inline-block;
|
padding: 0 8px;
|
height: 100%;
|
font-size: 18px;
|
color: #fff;
|
vertical-align: text-bottom;
|
|
&.hover-effect {
|
cursor: pointer;
|
transition: background 0.3s;
|
|
&:hover {
|
background: rgba(0, 0, 0, 0.025);
|
}
|
}
|
}
|
|
.avatar-container {
|
margin-right: 30px;
|
|
.avatar-wrapper {
|
margin-top: 5px;
|
position: relative;
|
|
.user-avatar {
|
cursor: pointer;
|
width: 40px;
|
height: 40px;
|
border-radius: 10px;
|
}
|
|
.user-name {
|
vertical-align: middle;
|
}
|
|
.el-icon-caret-bottom {
|
margin-left: 4px;
|
cursor: pointer;
|
font-size: 12px;
|
vertical-align: middle;
|
}
|
}
|
}
|
}
|
.i {
|
margin-left: 20px;
|
display: inline-block;
|
width: 20px;
|
height: 20px;
|
border-radius: 50%;
|
background: radial-gradient(
|
circle farthest-side at 50% 50%,
|
rgba(1, 31, 57, 0.5) 50%,
|
rgba(74, 253, 136, 0.5) 100%
|
);
|
text-align: center;
|
position: relative;
|
&::after {
|
content: "";
|
display: inline-block;
|
position: absolute;
|
border-radius: 50%;
|
top: 4px;
|
right: 4px;
|
bottom: 4px;
|
left: 4px;
|
background: #4afd88;
|
}
|
&.danger {
|
background: radial-gradient(
|
circle farthest-side at 50% 50%,
|
rgba(1, 31, 57, 0.5) 50%,
|
rgba(255, 56, 1, 0.5) 100%
|
);
|
&::after {
|
background: #ff3801;
|
}
|
}
|
}
|
}
|
</style>
|