You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
232 lines
7.3 KiB
232 lines
7.3 KiB
<template>
|
|
<div>
|
|
<nav
|
|
v-if="showHeader"
|
|
class="aui-navbar"
|
|
:class="`aui-navbar--${$store.state.navbarLayoutType}`"
|
|
>
|
|
<div class="aui-navbar__header">
|
|
<h1 class="aui-navbar__brand" @click="$router.push({ name: 'home' })">
|
|
<a class="aui-navbar__brand-lg" href="javascript:;">{{
|
|
userType === 'work' ? customerName : $t('brand.lg')
|
|
}}</a>
|
|
<a class="aui-navbar__brand-mini" href="javascript:;">{{
|
|
$t('brand.mini')
|
|
}}</a>
|
|
</h1>
|
|
</div>
|
|
<div class="aui-navbar__body">
|
|
<el-menu class="aui-navbar__menu mr-auto" mode="horizontal">
|
|
<el-menu-item
|
|
index="1"
|
|
@click="$store.state.sidebarFold = !$store.state.sidebarFold"
|
|
>
|
|
<svg
|
|
class="icon-svg aui-navbar__icon-menu aui-navbar__icon-menu--switch"
|
|
aria-hidden="true"
|
|
>
|
|
<use xlink:href="#icon-outdent"></use>
|
|
</svg>
|
|
</el-menu-item>
|
|
</el-menu>
|
|
|
|
<el-menu
|
|
v-if="userType == 'work'"
|
|
:default-active="$store.state.LevelOneMenuActiveName"
|
|
:collapse="$store.state.sidebarFold"
|
|
:unique-opened="true"
|
|
:collapseTransition="false"
|
|
mode="horizontal"
|
|
class="aui-navbar__menu mr-auto"
|
|
>
|
|
<el-menu-item
|
|
v-for="menu in $store.state.sidebarMenuList"
|
|
:key="menu.id"
|
|
:menu="menu"
|
|
:index="menu.id"
|
|
@click="gotoRouteHandle(menu.id)"
|
|
>
|
|
<span>{{ menu.name }}</span>
|
|
</el-menu-item>
|
|
</el-menu>
|
|
|
|
<el-menu class="aui-navbar__menu" mode="horizontal">
|
|
<!-- <el-menu-item index="1">
|
|
<el-dropdown placement="bottom"
|
|
:show-timeout="0">
|
|
<el-button size="mini">{{ $t('_lang') }}</el-button>
|
|
<el-dropdown-menu slot="dropdown">
|
|
<el-dropdown-item v-for="(val, key) in i18nMessages"
|
|
:key="key"
|
|
@click.native="$i18n.locale = key">{{ val._lang }}</el-dropdown-item>
|
|
</el-dropdown-menu>
|
|
</el-dropdown>
|
|
</el-menu-item> -->
|
|
<!-- <el-menu-item index="2">
|
|
<a href="//www.renren.io/"
|
|
target="_blank">
|
|
<svg class="icon-svg aui-navbar__icon-menu"
|
|
aria-hidden="true">
|
|
<use xlink:href="#icon-earth"></use>
|
|
</svg>
|
|
</a>
|
|
</el-menu-item> -->
|
|
<!-- <el-menu-item index="3"
|
|
@click="fullscreenHandle()">
|
|
<svg class="icon-svg aui-navbar__icon-menu"
|
|
aria-hidden="true">
|
|
<use xlink:href="#icon-fullscreen"></use>
|
|
</svg>
|
|
</el-menu-item> -->
|
|
<el-menu-item index="2" @click="refresh()">
|
|
<svg class="icon-svg aui-navbar__icon-menu" aria-hidden="true">
|
|
<use xlink:href="#icon-sync"></use>
|
|
</svg>
|
|
</el-menu-item>
|
|
<el-menu-item index="4" class="aui-navbar__avatar">
|
|
<el-dropdown placement="bottom" :show-timeout="0">
|
|
<span class="el-dropdown-link">
|
|
<img
|
|
v-if="$store.state.user.gender === '2'"
|
|
src="~@/assets/img/staff-default-avatar-girl.png"
|
|
/>
|
|
<img v-else src="~@/assets/img/staff-default-avatar-boy.png" />
|
|
<span>{{ $store.state.user.realName }}</span>
|
|
<i class="el-icon-arrow-down"></i>
|
|
</span>
|
|
<el-dropdown-menu slot="dropdown">
|
|
<!-- <el-dropdown-item @click.native="updatePasswordHandle()">{{ $t('updatePassword.title') }}</el-dropdown-item> -->
|
|
<el-dropdown-item @click.native="logoutHandle()">{{
|
|
$t('logout')
|
|
}}</el-dropdown-item>
|
|
</el-dropdown-menu>
|
|
</el-dropdown>
|
|
</el-menu-item>
|
|
</el-menu>
|
|
</div>
|
|
<!-- 弹窗, 修改密码 -->
|
|
<update-password
|
|
v-if="updatePassowrdVisible"
|
|
ref="updatePassowrd"
|
|
></update-password>
|
|
</nav>
|
|
<nav v-else class="aui-navbar main-line"></nav>
|
|
</div>
|
|
</template>
|
|
|
|
<script>
|
|
import { messages } from '@/i18n'
|
|
import { mapGetters } from 'vuex'
|
|
import screenfull from 'screenfull'
|
|
import UpdatePassword from './main-navbar-update-password'
|
|
import { clearLoginInfo } from '@/utils'
|
|
export default {
|
|
inject: ['refresh'],
|
|
data() {
|
|
return {
|
|
showHeader: true,
|
|
i18nMessages: messages,
|
|
updatePassowrdVisible: false,
|
|
customerName: localStorage.getItem('customerName')
|
|
}
|
|
},
|
|
components: {
|
|
UpdatePassword
|
|
},
|
|
created() {
|
|
let platformToken = localStorage.getItem('showHeader') || ''
|
|
if (
|
|
typeof platformToken !== 'undefined' &&
|
|
platformToken !== 'undefined' &&
|
|
platformToken !== ''
|
|
) {
|
|
this.showHeader = false
|
|
}
|
|
console.log('=============================', this.userType)
|
|
},
|
|
computed: {
|
|
userType() {
|
|
return localStorage.getItem('userType')
|
|
}
|
|
},
|
|
methods: {
|
|
// 通过menuId与动态(菜单)路由进行匹配跳转至指定路由
|
|
gotoRouteHandle(menuId) {
|
|
var route = window.SITE_CONFIG['dynamicMenuRoutes'].filter(
|
|
(item) => item.meta.menuId === menuId
|
|
)[0]
|
|
if (route) {
|
|
this.$router.push({ name: route.name })
|
|
}
|
|
this.$store.state.LevelOneMenuActiveName = menuId
|
|
},
|
|
changeCustomerName(customerName) {
|
|
this.customerName = localStorage.getItem('customerName')
|
|
},
|
|
// 全屏
|
|
fullscreenHandle() {
|
|
if (!screenfull.enabled) {
|
|
return this.$message({
|
|
message: this.$t('fullscreen.prompt'),
|
|
type: 'warning',
|
|
duration: 500
|
|
})
|
|
}
|
|
screenfull.toggle()
|
|
},
|
|
// 修改密码
|
|
updatePasswordHandle() {
|
|
this.updatePassowrdVisible = true
|
|
this.$nextTick(() => {
|
|
this.$refs.updatePassowrd.init()
|
|
})
|
|
},
|
|
// 退出
|
|
logoutHandle() {
|
|
this.$confirm(
|
|
this.$t('prompt.info', { handle: this.$t('logout') }),
|
|
this.$t('prompt.title'),
|
|
{
|
|
confirmButtonText: this.$t('confirm'),
|
|
cancelButtonText: this.$t('cancel'),
|
|
type: 'warning'
|
|
}
|
|
)
|
|
.then(() => {
|
|
//关闭所有标签页
|
|
// tabs, 关闭全部
|
|
this.$store.state.contentTabs = this.$store.state.contentTabs.filter(
|
|
(item) => item.name === 'home'
|
|
)
|
|
|
|
this.$http
|
|
.post('/auth/login/logout')
|
|
.then(({ data: res }) => {
|
|
if (res.code !== 0) {
|
|
//别处登陆时 退出不提示 直接跳登陆页即可
|
|
if (res.code !== 10007) {
|
|
this.$message.error(res.msg)
|
|
}
|
|
}
|
|
|
|
clearLoginInfo()
|
|
|
|
if (localStorage.getItem('userType') === 'work') {
|
|
this.$router.push({ name: 'loginWork' })
|
|
} else {
|
|
this.$router.push({ name: 'login' })
|
|
}
|
|
})
|
|
.catch(() => {})
|
|
})
|
|
.catch(() => {})
|
|
}
|
|
}
|
|
}
|
|
</script>
|
|
<style lang="scss" scoped>
|
|
.main-line {
|
|
height: 50px;
|
|
background: #eeeeee;
|
|
}
|
|
</style>
|
|
|