From 4ffb0acc35d85a78959edb97ef80e23a92cefc89 Mon Sep 17 00:00:00 2001 From: 疯狂的狮子Li <15040126243@163.com> Date: 星期六, 11 三月 2023 23:59:05 +0800 Subject: [PATCH] fix 修复 超管切换租户后 点击个人中心报错 --- ruoyi-ui/src/layout/components/Navbar.vue | 72 +++++++++++++++++++++++++++++++++--- 1 files changed, 66 insertions(+), 6 deletions(-) diff --git a/ruoyi-ui/src/layout/components/Navbar.vue b/ruoyi-ui/src/layout/components/Navbar.vue index 9d220e9..55844db 100644 --- a/ruoyi-ui/src/layout/components/Navbar.vue +++ b/ruoyi-ui/src/layout/components/Navbar.vue @@ -5,10 +5,27 @@ <breadcrumb id="breadcrumb-container" class="breadcrumb-container" v-if="!topNav"/> <top-nav id="topmenu-container" class="topmenu-container" v-if="topNav"/> - <div class="right-menu"> - <template v-if="device!=='mobile'"> + <div class="right-menu flex align-center"> + <template v-if="device!=='mobile' "> + <el-select v-model="companyName" + clearable + filterable + reserve-keyword + placeholder="璇烽�夋嫨绉熸埛" + v-if="userId === 1" + @change="dynamicTenantEvent" + @clear="dynamicClearEvent"> + <el-option + v-for="item in tenantList" + :key="item.tenantId" + :label="item.companyName" + :value="item.tenantId"> + </el-option> + <svg-icon slot="prefix" icon-class="company" class="el-input__icon input-icon" /> + </el-select> + <search id="header-search" class="right-menu-item" /> - + <el-tooltip content="婧愮爜鍦板潃" effect="dark" placement="bottom"> <ruo-yi-git id="ruoyi-git" class="right-menu-item hover-effect" /> </el-tooltip> @@ -31,7 +48,7 @@ <i class="el-icon-caret-bottom" /> </div> <el-dropdown-menu slot="dropdown"> - <router-link to="/user/profile"> + <router-link to="/user/profile" v-if="!dynamic"> <el-dropdown-item>涓汉涓績</el-dropdown-item> </router-link> <el-dropdown-item @click.native="setting = true"> @@ -56,8 +73,19 @@ import Search from '@/components/HeaderSearch' import RuoYiGit from '@/components/RuoYi/Git' import RuoYiDoc from '@/components/RuoYi/Doc' +import { tenantList } from "@/api/login"; +import { dynamicClear, dynamicTenant } from "@/api/system/tenant"; export default { + data() { + return { + userId: this.$store.getters.userId, + companyName: undefined, + tenantList: [], + // 鏄惁鍒囨崲浜嗙鎴� + dynamic: false + } + }, components: { Breadcrumb, TopNav, @@ -92,6 +120,29 @@ } }, methods: { + // 鍔ㄦ�佸垏鎹� + dynamicTenantEvent(tenantId) { + if (this.companyName != null && this.companyName !== '') { + dynamicTenant(tenantId).then(res => { + this.dynamic = true; + this.$tab.closeAllPage() + this.$router.push('/') + }); + } + }, + dynamicClearEvent() { + dynamicClear().then(res => { + this.dynamic = false; + this.$tab.closeAllPage() + this.$router.push('/') + }); + }, + // 绉熸埛鍒楄〃 + getTenantList() { + tenantList().then(res => { + this.tenantList = res.data; + }); + }, toggleSideBar() { this.$store.dispatch('app/toggleSideBar') }, @@ -102,15 +153,24 @@ type: 'warning' }).then(() => { this.$store.dispatch('LogOut').then(() => { - location.href = '/index'; + location.href = process.env.VUE_APP_CONTEXT_PATH + "index"; }) - }) + }).catch(() => {}); } } } </script> <style lang="scss" scoped> + +.flex { + display: flex; +} + +.align-center { + align-items: center; +} + .navbar { height: 50px; overflow: hidden; -- Gitblit v1.9.3