切换角色跳转页面问题
continuous-integration/drone/push Build is passing Details

uat_us
wangxiaoshuang 2024-12-26 12:29:55 +08:00
parent 9e8d537358
commit 9cd540d1ec
4 changed files with 24 additions and 4 deletions

View File

@ -1,4 +1,5 @@
import router from './router'
import { resetRouter } from '@/router'
import store from './store'
// import { Message } from 'element-ui'
import NProgress from 'nprogress'
@ -80,6 +81,7 @@ router.beforeEach(async (to, from, next) => {
await store.dispatch('user/getInfo')
await store.dispatch('user/getUserInfo')
const accessRoutes = await store.dispatch('permission/generateRoutes')
resetRouter()
router.addRoutes(accessRoutes)
next({ ...to, replace: true })
} catch (error) {

View File

@ -3,6 +3,7 @@ const getters = {
device: state => state.app.device,
token: state => state.user.token,
name: state => state.user.name,
userTypeShortName: state => state.user.userTypeShortName,
permissions: state => state.user.permissions,
tree: state => state.user.tree,
userName: state => state.user.userName,

View File

@ -8,6 +8,7 @@ const getDefaultState = () => {
return {
token: getToken(),
name: '',
userTypeShortName: "",
userName: '',
userId: '',
identityUserId: '',
@ -40,6 +41,9 @@ const mutations = {
SET_NAME: (state, name) => {
state.name = name
},
SET_USERTYPESHORTNAME: (state, userTypeShortName) => {
state.userTypeShortName = userTypeShortName
},
SET_USERNAME: (state, name) => {
state.userName = name
},
@ -176,6 +180,7 @@ const actions = {
const userString = decodeURIComponent(escape(window.atob(data.split('.')[1].replace(/-/g, '+').replace(/_/g, '/'))))
const user = JSON.parse(userString)
zzSessionStorage.setItem('userTypeShortName', user.userTypeShortName)
commit('SET_USERTYPESHORTNAME', user.userTypeShortName)
commit('SET_NAME', user.fullName)
setName(user.fullName)
var permissions = await getUserPermissions()
@ -222,6 +227,7 @@ const actions = {
commit('SET_ISTESTUSER', zzSessionStorage.getItem('isTestUser'))
const user = JSON.parse(userString)
commit('SET_NAME', zzSessionStorage.getItem('Name'))
commit('SET_USERTYPESHORTNAME', user.userTypeShortName)
commit('SET_IDENTITYUSERID', user.identityUserId)
commit('SET_USERID', user.userRoleId)
commit('SET_USERNAME', zzSessionStorage.getItem('userName'))

View File

@ -116,6 +116,7 @@
import { mapGetters, mapMutations } from 'vuex'
import TopLang from './topLang'
import NoticeMarquee from './noticeMarquee'
import { resetRouter } from '@/router'
import toggleRole from '@/components/toggleRole'
export default {
components: { TopLang, NoticeMarquee, toggleRole },
@ -123,7 +124,7 @@ export default {
return {
activeIndex: '2',
isReviewer: false,
userTypeShortName: zzSessionStorage.getItem('userTypeShortName'),
// userTypeShortName: zzSessionStorage.getItem('userTypeShortName'),
notice: '',
VUE_APP_OSS_CONFIG_REGION: process.env.VUE_APP_OSS_CONFIG_REGION,
NODE_ENV: process.env.NODE_ENV,
@ -139,6 +140,7 @@ export default {
'device',
'TotalNeedSignSystemDocCount',
'language',
'userTypeShortName',
]),
roles() {
return this.$store.state.user.roles
@ -244,6 +246,7 @@ export default {
.dispatch('permission/generateRoutes')
.then(async (res) => {
if (res && res.length > 0) {
resetRouter()
await this.$store.dispatch('global/getNoticeList')
this.$router.addRoutes(res)
this.toggleRoleLoading = false
@ -263,11 +266,19 @@ export default {
'role:rir',
])
) {
this.$router.replace({ path: '/trials/trials-list' })
history.replaceState(null, null, '/trials/trials-list')
history.go(0)
// this.$router.replace({ path: '/trials/trials-list' })
} else {
this.$router.replace({ path: '/trials' })
history.replaceState(null, null, '/trials')
history.go(0)
// this.$router.replace({ path: '/trials/trials-workbench' })
}
window.location.reload()
this.toggleRoleVisible = false
this.toggleRoleLoading = false
this.$nextTick(() => {
window.location.reload()
})
} else {
//
this.toggleRoleLoading = false