| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170 |
- <template>
- <div class="l-flex--row c-navbar">
- <breadcrumb class="l-flex__auto c-sibling-item" />
- <div
- v-if="isSuperAdmin"
- class="l-flex__none c-sibling-item farthest has-active"
- @click="onChangeTenant"
- >
- {{ tenantName }}
- </div>
- <upload-dashboard
- v-if="isOperator"
- class="l-flex__none c-sibling-item farthest"
- />
- <el-dropdown
- class="l-flex__none c-sibling-item farthest c-navbar__user u-color--blue u-font-size--sm has-active"
- trigger="click"
- @command="onCommand"
- >
- <div class="l-flex--row">
- <img
- v-if="avatar"
- class="c-navbar__avatar"
- :src="avatar"
- >
- <span class="c-sibling-item">{{ name }}</span>
- <i class="c-sibling-item near el-icon-arrow-down" />
- </div>
- <el-dropdown-menu slot="dropdown">
- <el-dropdown-item command="profile">个人设置</el-dropdown-item>
- <el-dropdown-item
- command="logout"
- divided
- >
- 退出登录
- </el-dropdown-item>
- </el-dropdown-menu>
- </el-dropdown>
- <radio-table-dialog
- ref="tenantDialog"
- :title="title"
- :schema="tenantSchema"
- append-to-body
- @confirm="onChoosenTenant"
- />
- <el-drawer
- title="个人设置"
- :visible.sync="drawer"
- direction="rtl"
- :size="480"
- :with-header="false"
- :destroy-on-close="true"
- append-to-body
- >
- <profile
- class="l-flex__fill"
- @close="drawer = false"
- />
- </el-drawer>
- </div>
- </template>
- <script>
- import { mapGetters } from 'vuex'
- import {
- getPlatformTenants,
- resetDepartmentCache
- } from '@/api/user'
- import Breadcrumb from './Breadcrumb'
- import UploadDashboard from './UploadDashboard'
- import Profile from './Profile'
- export default {
- name: 'Navbar',
- components: {
- Profile,
- Breadcrumb,
- UploadDashboard
- },
- data () {
- return {
- drawer: false,
- tenantSchema: {
- condition: { name: '' },
- list: getPlatformTenants,
- filters: [
- { key: 'name', type: 'search', placeholder: '标识' }
- ],
- cols: [
- { prop: 'remark', label: '名称' },
- { prop: 'name', label: '标识' }
- ]
- }
- }
- },
- computed: {
- ...mapGetters([
- 'avatar',
- 'name',
- 'isSuperAdmin',
- 'isOperator',
- 'tenantId',
- 'tenantName'
- ]),
- title () {
- return `租户切换(${this.tenantName})`
- }
- },
- methods: {
- onCommand (command) {
- switch (command) {
- case 'profile':
- // this.$router.push({ name: 'profile' })
- this.drawer = true
- break
- case 'logout':
- this.$store.dispatch('user/logout')
- break
- default:
- break
- }
- },
- onChangeTenant () {
- this.$refs.tenantDialog.show({ id: this.tenantId, name: this.tenantName })
- },
- onChoosenTenant ({ value, done }) {
- if (value.path !== this.tenant) {
- resetDepartmentCache()
- this.$store.commit('user/SET_TENANT', value)
- }
- done()
- }
- }
- }
- </script>
- <style lang="scss" scoped>
- .c-navbar {
- position: relative;
- height: $height--md;
- padding: 0 $padding--xl;
- background-color: #fff;
- box-shadow: 0 1px 4px rgba(0, 21, 41, 0.08);
- overflow: hidden;
- z-index: 1;
- &__info {
- background: url("~@/assets/icon_inform.png") 0 0 / 100% 100% no-repeat;
- }
- &__user.hover-effect {
- cursor: pointer;
- transition: background 0.3s;
- &:hover {
- background: rgba(0, 0, 0, 0.025);
- }
- }
- &__avatar {
- width: 40px;
- height: 40px;
- border-radius: 50%;
- }
- .el-icon-arrow-down {
- font-weight: bolder;
- }
- }
- </style>
|