切换角色跳转页面问题
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 router from './router'
import { resetRouter } from '@/router'
import store from './store' import store from './store'
// import { Message } from 'element-ui' // import { Message } from 'element-ui'
import NProgress from 'nprogress' import NProgress from 'nprogress'
@ -80,6 +81,7 @@ router.beforeEach(async (to, from, next) => {
await store.dispatch('user/getInfo') await store.dispatch('user/getInfo')
await store.dispatch('user/getUserInfo') await store.dispatch('user/getUserInfo')
const accessRoutes = await store.dispatch('permission/generateRoutes') const accessRoutes = await store.dispatch('permission/generateRoutes')
resetRouter()
router.addRoutes(accessRoutes) router.addRoutes(accessRoutes)
next({ ...to, replace: true }) next({ ...to, replace: true })
} catch (error) { } catch (error) {

View File

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

View File

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

View File

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