yudao-dev/src/layout/components/NavbarRight.vue

120 lines
2.9 KiB
Vue
Raw Normal View History

2023-11-14 15:47:06 +08:00
<template>
<div class="right-msg" :style="blackTitle ? 'color: #000' : 'color: #fff'">
2023-11-17 14:04:53 +08:00
<div class="home-icon" v-if='blackTitle'>
<svg-icon icon-class="home" style="font-size: 24px; cursor: pointer;" @click="toHome"/>
</div>
2023-11-14 15:47:06 +08:00
<div class="time-msg">
<div class="line1">{{timeZone}}&nbsp;&nbsp;&nbsp;&nbsp;{{topTime}}</div>
<div class="line2">{{topDate}}</div>
</div>
<div class="base-msg">
<div class="avatar">
<el-dropdown>
<img :src="require(`../../assets/images/choicepart/avatar.png`)" alt="" width="32" height="32" />
<el-dropdown-menu slot="dropdown">
<el-dropdown-item><svg-icon icon-class="helpbtn"/>帮助文档</el-dropdown-item>
<el-dropdown-item @click.native="logout"><svg-icon icon-class="exitbtn"/>退出登录</el-dropdown-item>
</el-dropdown-menu>
</el-dropdown>
</div>
<div class="use-msg">
<div class="line1">{{nickname}}</div>
<div class="line2">{{dept}}</div>
</div>
</div>
</div>
</template>
<script>
import moment from 'moment'
2024-02-22 16:23:19 +08:00
import { getUserSimple } from "@/api/system/user.js";
2023-11-14 15:47:06 +08:00
import {getPath} from "@/utils/ruoyi";
export default {
name: 'navRight',
data() {
return {
topDate: '',
topTime: '',
timeZone: '',
timer: '',
dept:' ',
nickname: this.$store.getters.nickname
}
},
props: {
blackTitle: {
type: Boolean,
default: () => {
return false
}
}
},
2023-11-17 14:04:53 +08:00
created() {
2023-11-14 15:47:06 +08:00
this.getUserMsg()
this.getTime()
},
beforeDestroy() {
clearInterval(this.timer)
},
methods: {
getTime() {
let _this = this
this.timer = setInterval(function () {
_this.topDate = moment().format('YYYY/MM/DD')
let temp = moment().format('A-hh:mm').split('-')
_this.timeZone = temp[0]
_this.topTime = temp[1]
}, 1000)
},
getUserMsg() {
let id = this.$store.getters.userId
2024-02-22 16:23:19 +08:00
getUserSimple(id).then(res => {
this.dept = res.data.deptName ? res.data.dept.deptName : '---'
2023-11-14 15:47:06 +08:00
})
},
async logout() {
this.$modal.confirm('确定注销并退出系统吗?', '提示').then(() => {
this.$store.dispatch('LogOut').then(() => {
location.href = getPath('/');
})
2023-11-17 14:04:53 +08:00
}).catch(() => {})
},
toHome() {
this.$router.push({ path: "/" })
2023-11-14 15:47:06 +08:00
}
}
}
</script>
<style lang='scss' scoped>
.right-msg {
float: right;
height: 100%;
font-size: 14px;
.time-msg {
display: inline-block;
margin-right: 30px;
}
2023-11-17 14:04:53 +08:00
.home-icon {
display: inline-block;
margin-right: 30px;
vertical-align: top;
padding-top: 7px;
}
2023-11-14 15:47:06 +08:00
.base-msg {
display: inline-block;
.avatar {
display: inline-block;
margin-right: 10px;
}
.use-msg {
display: inline-block;
}
}
.line1 {
height: 19px;
}
.line2 {
height: 19px;
opacity: 0.65;
}
}
</style>