<template>
|
<div>
|
<el-menu class="navbar" mode="horizontal">
|
<hamburger class="hamburger-container" :toggleClick="toggleSideBar" :isActive="sidebar.opened"></hamburger>
|
<breadcrumb></breadcrumb>
|
<el-dropdown class="avatar-container" trigger="click">
|
<div class="avatar-wrapper">
|
<img class="user-avatar" :src="userInfo.avatar+'?imageView2/1/w/80/h/80'">
|
<span class="user-name">{{userInfo.name}}</span>
|
<i class="el-icon-caret-bottom"></i>
|
</div>
|
<el-dropdown-menu class="user-dropdown" slot="dropdown">
|
<!--<router-link class="inlineBlock" to="/">
|
<el-dropdown-item>
|
首页
|
</el-dropdown-item>
|
</router-link>-->
|
<!-- <el-dropdown-item>-->
|
<!-- <span @click="openCimcoBs()">打开实时展示</span>-->
|
<!-- </el-dropdown-item>-->
|
<!-- <el-dropdown-item>-->
|
<!-- <span @click="openCimcoMdc()">打开报表</span>-->
|
<!-- </el-dropdown-item>-->
|
<!-- <el-dropdown-item>-->
|
<!-- <span @click="alterPw()">修改密码</span>-->
|
<!-- </el-dropdown-item>-->
|
<el-dropdown-item>
|
<span @click="logout" style="display:block;">登出</span>
|
</el-dropdown-item>
|
</el-dropdown-menu>
|
</el-dropdown>
|
</el-menu>
|
<alter-password-dialog :is-visible="showAlterPass" @submit="onAlterResult"></alter-password-dialog>
|
</div>
|
</template>
|
|
<script>
|
import { mapGetters } from 'vuex'
|
import Breadcrumb from '@/components/Breadcrumb'
|
import Hamburger from '@/components/Hamburger'
|
import AlterPasswordDialog from './AlterPasswordDialog'
|
import { alterUserSelfPw } from '@/api/MdcApi'
|
import { localCimcoMdc } from '@/api/MdcApi'
|
export default {
|
components: {
|
AlterPasswordDialog,
|
Breadcrumb,
|
Hamburger
|
},
|
data() {
|
return {
|
showAlterPass: false
|
}
|
},
|
computed: {
|
...mapGetters({
|
sidebar: 'sidebar',
|
userInfo: 'userInfo'
|
})
|
},
|
methods: {
|
toggleSideBar() {
|
this.$store.dispatch('ToggleSideBar')
|
},
|
/**
|
* 查询机床
|
*/
|
openCimcoBs() {
|
window.location.href = 'http://192.168.234.2:8080'
|
},
|
openCimcoMdc() {
|
localCimcoMdc().then(res => {
|
if (res.result === 'SUCCESS') {
|
this.$message({
|
type: 'success',
|
message: '打开成功!'
|
})
|
// this.showAlterPass = false
|
// setTimeout(() => {
|
// this.logout()
|
// }, 1500)
|
}
|
})
|
},
|
logout() {
|
this.$store.dispatch('LogOut').then(() => {
|
location.reload() // 为了重新实例化vue-router对象 避免bug
|
})
|
},
|
/**
|
* 修改密码
|
*/
|
alterPw() {
|
// console.log(12345)
|
this.showAlterPass = true
|
},
|
onAlterResult({ action, data }) {
|
// console.log(data)
|
switch (action) {
|
case 'confirm':
|
// todo 模拟网络请求 修改密码
|
alterUserSelfPw(this.userInfo.user, data.oldPass, data.newPass).then(res => {
|
if (res.result === 'SUCCESS') {
|
this.$message({
|
type: 'success',
|
message: '密码修改成功!'
|
})
|
this.showAlterPass = false
|
setTimeout(() => {
|
this.logout()
|
}, 1500)
|
} else {
|
this.$message({
|
type: 'error',
|
message: '密码修改失败,请确认原始密码是否正确!'
|
})
|
}
|
})
|
break
|
case 'cancel':
|
this.showAlterPass = false
|
break
|
}
|
}
|
}
|
}
|
</script>
|
|
<style rel="stylesheet/scss" lang="scss" scoped>
|
.navbar {
|
height: 50px;
|
line-height: 50px;
|
border-radius: 0px !important;
|
.hamburger-container {
|
line-height: 58px;
|
height: 50px;
|
float: left;
|
padding: 0 10px;
|
}
|
.screenfull {
|
position: absolute;
|
right: 90px;
|
top: 16px;
|
color: red;
|
}
|
.avatar-container {
|
height: 50px;
|
display: inline-block;
|
position: absolute;
|
right: 16px;
|
.avatar-wrapper {
|
cursor: pointer;
|
/*margin-top: 5px;*/
|
/*position: relative;*/
|
display: flex;align-items: center;
|
.user-avatar {
|
width: 40px;
|
height: 40px;
|
border-radius: 10px;
|
}
|
.user-name{
|
padding-left: 8px;padding-right: 2px;font-size: 12px;
|
}
|
.el-icon-caret-bottom {
|
/*position: absolute;*/
|
right: -20px;
|
top: 25px;
|
font-size: 12px;
|
}
|
}
|
}
|
}
|
</style>
|
|