项目内切换角色
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
parent
177510643d
commit
a95a129dde
|
@ -5,3 +5,6 @@ npm install
|
|||
# 启动服务
|
||||
npm run dev
|
||||
|
||||
# v1.9.0修改
|
||||
1. 角色修改,全局userId实际意义修改为userRoleId(用户角色id),新增identityUserId(新的用户id)
|
||||
|
||||
|
|
|
@ -30,7 +30,6 @@
|
|||
</script>
|
||||
<% } else { %>
|
||||
<script>
|
||||
console.log(2)
|
||||
window.zzSessionStorage = {
|
||||
setItem: (item, value) => {
|
||||
return sessionStorage.setItem(item, value)
|
||||
|
|
|
@ -47,7 +47,7 @@ export function updateUser(param) {
|
|||
|
||||
export function getUser(userId) {
|
||||
return request({
|
||||
url: `/user/getUser/${userId}`,
|
||||
url: `/user/getUser`,
|
||||
method: 'get'
|
||||
})
|
||||
}
|
||||
|
|
|
@ -5,14 +5,15 @@
|
|||
v-dialogDrag
|
||||
width="540px"
|
||||
:close-on-click-modal="false"
|
||||
:close-on-press-escape="false"
|
||||
append-to-body
|
||||
:title="$t('toggleRole:tip:title')"
|
||||
center
|
||||
top="30vh"
|
||||
:show-close="false"
|
||||
@close="cancel"
|
||||
:before-close="cancel"
|
||||
>
|
||||
<el-radio-group v-model="form.UserTypeId" class="roles" v-if="hasRole">
|
||||
<el-radio-group v-model="form.userRoleId" class="roles" v-if="hasRole">
|
||||
<el-radio
|
||||
v-for="item in roles"
|
||||
:key="item.Id"
|
||||
|
@ -23,10 +24,22 @@
|
|||
{{ item.UserTypeShortName }}
|
||||
</el-radio>
|
||||
</el-radio-group>
|
||||
<div v-else>{{ $t('toggleRole:tip:noRole') }}</div>
|
||||
<div v-else style="text-align: center">
|
||||
{{ $t('toggleRole:tip:noRole') }}
|
||||
</div>
|
||||
<div slot="footer">
|
||||
<!-- 取消 -->
|
||||
<el-button size="small" @click="cancel()">
|
||||
{{ $t('common:button:cancel') }}
|
||||
</el-button>
|
||||
<!-- 保存 -->
|
||||
<el-button type="primary" size="small" @click="save" :loading="loading">
|
||||
<el-button
|
||||
type="primary"
|
||||
size="small"
|
||||
@click="save"
|
||||
:loading="loading"
|
||||
v-if="hasRole"
|
||||
>
|
||||
{{ $t('common:button:confirm') }}
|
||||
</el-button>
|
||||
</div>
|
||||
|
@ -48,10 +61,13 @@ export default {
|
|||
data() {
|
||||
return {
|
||||
form: {
|
||||
UserTypeId: null,
|
||||
userRoleId: null,
|
||||
},
|
||||
}
|
||||
},
|
||||
created() {
|
||||
this.form.userRoleId = zzSessionStorage.getItem('userId')
|
||||
},
|
||||
computed: {
|
||||
roles() {
|
||||
return this.$store.state.user.roles
|
||||
|
@ -63,12 +79,13 @@ export default {
|
|||
methods: {
|
||||
cancel() {
|
||||
this.$emit('update:visible', false)
|
||||
this.$emit('cancel')
|
||||
},
|
||||
async save() {
|
||||
try {
|
||||
if (!this.form.UserTypeId)
|
||||
if (!this.form.userRoleId)
|
||||
return this.$message.warning(this.$t('toggleRole:ruleMessage:select'))
|
||||
this.$emit('save', this.form.UserTypeId)
|
||||
this.$emit('save', this.form.userRoleId)
|
||||
} catch (err) {
|
||||
console.log(err)
|
||||
}
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
import { SubjectCheckConfig } from './module/Subject'
|
||||
|
||||
console.log(SubjectCheckConfig.moduleType)
|
||||
export const checkConfig = {
|
||||
ModuleType: {
|
||||
...SubjectCheckConfig.ModuleType
|
||||
|
|
|
@ -78,6 +78,7 @@ router.beforeEach(async (to, from, next) => {
|
|||
try {
|
||||
// 获取用户信息
|
||||
await store.dispatch('user/getInfo')
|
||||
await store.dispatch('user/getUserInfo')
|
||||
const accessRoutes = await store.dispatch('permission/generateRoutes')
|
||||
router.addRoutes(accessRoutes)
|
||||
next({ ...to, replace: true })
|
||||
|
|
|
@ -7,7 +7,7 @@ const getters = {
|
|||
tree: state => state.user.tree,
|
||||
userName: state => state.user.userName,
|
||||
userId: state => state.user.userId,
|
||||
userRoleId: state => state.user.userRoleId,
|
||||
identityUserId: state => state.user.identityUserId,
|
||||
routes: state => state.permission.routes,
|
||||
asyncRoutes: state => state.permission.addRoutes,
|
||||
visitedViews: state => state.tagsView.visitedViews,
|
||||
|
|
|
@ -118,7 +118,6 @@ const actions = {
|
|||
return new Promise(resolve => {
|
||||
var newTree = JSON.parse(zzSessionStorage.getItem('newTree'))
|
||||
const sidebarRoutes = filterAsyncRouter(newTree || [])
|
||||
console.log(sidebarRoutes, 'sidebarRoutes')
|
||||
commit('SET_ROUTES', sidebarRoutes)
|
||||
resolve(sidebarRoutes)
|
||||
})
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import { getToken, setToken, removeToken, setName, removeName } from '@/utils/auth'
|
||||
import { login, loginOut, getUserMenuTree, getUserPermissions, getUserLoginRoleList, loginSelectUserRole } from '@/api/user'
|
||||
import { getUser } from '@/api/admin'
|
||||
|
||||
import { resetRouter } from '@/router'
|
||||
import md5 from 'js-md5'
|
||||
|
@ -9,7 +10,7 @@ const getDefaultState = () => {
|
|||
name: '',
|
||||
userName: '',
|
||||
userId: '',
|
||||
userRoleId: '',
|
||||
identityUserId: '',
|
||||
avatar: '',
|
||||
permissions: [],
|
||||
tree: [],
|
||||
|
@ -54,8 +55,8 @@ const mutations = {
|
|||
SET_USERID: (state, id) => {
|
||||
state.userId = id
|
||||
},
|
||||
SET_USEROLEID: (state, id) => {
|
||||
state.userRoleId = id
|
||||
SET_IDENTITYUSERID: (state, id) => {
|
||||
state.identityUserId = id
|
||||
},
|
||||
SET_ISTESTUSER: (state, isTestUser) => {
|
||||
state.isTestUser = eval(isTestUser)
|
||||
|
@ -126,18 +127,18 @@ const actions = {
|
|||
zzSessionStorage.setItem('IsReviewer', data.BasicInfo.IsReviewer)
|
||||
zzSessionStorage.setItem('userName', data.BasicInfo.UserName)
|
||||
commit('SET_TOKEN', data.JWTStr)
|
||||
commit('SET_NAME', data.BasicInfo.RealName)
|
||||
zzSessionStorage.setItem('realName', data.BasicInfo.RealName)
|
||||
// commit('SET_NAME', data.BasicInfo.UserName)
|
||||
zzSessionStorage.setItem('isTestUser', data.BasicInfo.IsTestUser)
|
||||
commit('SET_ISTESTUSER', data.BasicInfo.IsTestUser)
|
||||
commit('SET_USERNAME', data.BasicInfo.UserName)
|
||||
commit('SET_USERID', data.BasicInfo.IdentityUserId)
|
||||
setToken(data.JWTStr)
|
||||
setName(data.BasicInfo.RealName)
|
||||
// setName(data.BasicInfo.RealName)
|
||||
const userString = decodeURIComponent(escape(window.atob(data.JWTStr.split('.')[1].replace(/-/g, '+').replace(/_/g, '/'))))
|
||||
const user = JSON.parse(userString)
|
||||
zzSessionStorage.setItem('userTypeShortName', user.userTypeShortName)
|
||||
zzSessionStorage.setItem('userId', user.identityUserId)
|
||||
// zzSessionStorage.setItem('userId', user.identityUserId)
|
||||
commit('SET_IDENTITYUSERID', user.identityUserId)
|
||||
zzSessionStorage.setItem('identityUserId', user.identityUserId)
|
||||
zzSessionStorage.setItem('userTypeEnumInt', user.userTypeEnumInt)
|
||||
// var permissions = await getUserPermissions()
|
||||
// var menuTree = await getUserMenuTree()
|
||||
|
@ -170,10 +171,13 @@ const actions = {
|
|||
const data = response.Result
|
||||
|
||||
try {
|
||||
commit('SET_USEROLEID', userRoleId)
|
||||
zzSessionStorage.setItem('userRoleId', userRoleId)
|
||||
commit('SET_TOKEN', data)
|
||||
setToken(data)
|
||||
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_NAME', user.fullName)
|
||||
setName(user.fullName)
|
||||
var permissions = await getUserPermissions()
|
||||
var menuTree = await getUserMenuTree()
|
||||
commit('SET_TREE', menuTree.Result)
|
||||
|
@ -217,23 +221,34 @@ const actions = {
|
|||
commit('SET_PERMISSIONS', JSON.parse(zzSessionStorage.getItem('permissions')))
|
||||
commit('SET_ISTESTUSER', zzSessionStorage.getItem('isTestUser'))
|
||||
const user = JSON.parse(userString)
|
||||
commit('SET_NAME', zzSessionStorage.getItem('realName'))
|
||||
commit('SET_USEROLEID', user.userRoleId)
|
||||
commit('SET_USERID', user.identityUserId)
|
||||
commit('SET_NAME', zzSessionStorage.getItem('Name'))
|
||||
commit('SET_IDENTITYUSERID', user.identityUserId)
|
||||
commit('SET_USERID', user.userRoleId)
|
||||
commit('SET_USERNAME', zzSessionStorage.getItem('userName'))
|
||||
commit('SET_NEED_SIGN_SYSTEM_DOC_COUNT', parseInt(zzSessionStorage.getItem('TotalNeedSignSystemDocCount')))
|
||||
commit('SET_NEED_SIGN_TRIALS_DOC_COUNT', parseInt(zzSessionStorage.getItem('TotalNeedSignTrialDocCount')))
|
||||
console.log(zzSessionStorage.getItem('TotalNeedSignSystemDocCount'))
|
||||
console.log(zzSessionStorage.getItem('TotalNeedSignTrialDocCount'))
|
||||
// console.log(zzSessionStorage.getItem('TotalNeedSignSystemDocCount'))
|
||||
// console.log(zzSessionStorage.getItem('TotalNeedSignTrialDocCount'))
|
||||
zzSessionStorage.setItem('userName', user.name)
|
||||
zzSessionStorage.setItem('userId', user.identityUserId)
|
||||
zzSessionStorage.setItem('userRoleId', user.userRoleId)
|
||||
zzSessionStorage.setItem('userId', user.userRoleId)
|
||||
zzSessionStorage.setItem('identityUserId', user.identityUserId)
|
||||
zzSessionStorage.setItem('userTypeShortName', user.userTypeShortName)
|
||||
zzSessionStorage.setItem('userTypeEnumInt', user.userTypeEnumInt)
|
||||
return user
|
||||
},
|
||||
updateInfo({ commit, state }) {
|
||||
commit('SET_NAME', zzSessionStorage.getItem('realName'))
|
||||
commit('SET_NAME', zzSessionStorage.getItem('Name'))
|
||||
},
|
||||
// 获取用户信息
|
||||
getUserInfo({ commit, state }) {
|
||||
return new Promise((resolve, reject) => {
|
||||
getUser().then(res => {
|
||||
commit('SET_ROLES', res.Result.AccountList)
|
||||
resolve(res.Result)
|
||||
}).catch(err => {
|
||||
reject(err)
|
||||
})
|
||||
})
|
||||
},
|
||||
// user logout
|
||||
async logout({ commit, state }) {
|
||||
|
|
|
@ -244,9 +244,10 @@
|
|||
</el-dialog>
|
||||
<browserTip ref="browserTip" />
|
||||
<toggleRole
|
||||
:visible="toggleRoleVisible"
|
||||
:visible.sync="toggleRoleVisible"
|
||||
:loading="toggleRoleLoading"
|
||||
@save="loginByRole"
|
||||
@cancel="cancel"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
|
@ -424,6 +425,13 @@ export default {
|
|||
// this.$alert(this.$t('login:message:login4'), this.$t('common:title:warning'))
|
||||
this.$message.warning(this.$t('login:message:login4'))
|
||||
}
|
||||
if (
|
||||
Array.isArray(this.$store.state.user.roles) &&
|
||||
this.$store.state.user.roles.length === 1
|
||||
) {
|
||||
this.loginByRole(this.$store.state.user.roles[0].Id)
|
||||
return
|
||||
}
|
||||
return (this.toggleRoleVisible = true)
|
||||
})
|
||||
.catch(() => {
|
||||
|
@ -438,7 +446,9 @@ export default {
|
|||
.then((res) => {
|
||||
this.toggleRoleLoading = false
|
||||
if (res) {
|
||||
this.$store.dispatch('permission/generateRoutes').then((res) => {
|
||||
this.$store
|
||||
.dispatch('permission/generateRoutes')
|
||||
.then((res) => {
|
||||
this.loading = false
|
||||
if (res && res.length > 0) {
|
||||
this.$store.dispatch('global/getNoticeList')
|
||||
|
@ -464,10 +474,16 @@ export default {
|
|||
this.$router.replace({ path: '/trials' })
|
||||
}
|
||||
} else {
|
||||
this.toggleRoleLoading = false
|
||||
// 此账户暂未配置菜单权限,请联系管理员处理后再登录。
|
||||
this.$message.warning(this.$t('login:message:login2'))
|
||||
}
|
||||
})
|
||||
.catch((err) => {
|
||||
this.toggleRoleLoading = false
|
||||
})
|
||||
} else {
|
||||
this.toggleRoleLoading = false
|
||||
}
|
||||
})
|
||||
.catch(() => {
|
||||
|
@ -476,6 +492,12 @@ export default {
|
|||
this.toggleRoleLoading = false
|
||||
})
|
||||
},
|
||||
cancel() {
|
||||
this.showCode = true
|
||||
this.loading = false
|
||||
this.toggleRoleLoading = false
|
||||
// this.toggleRoleVisible = false
|
||||
},
|
||||
onSuccess() {
|
||||
this.isShow = false
|
||||
this.loginIn()
|
||||
|
|
|
@ -44,7 +44,6 @@ export default {
|
|||
this.$i18n.locale = lang
|
||||
this.setLanguage(lang)
|
||||
this.$updateDictionary()
|
||||
console.log(Vue)
|
||||
this.$upload()
|
||||
window.location.reload()
|
||||
}
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
<img v-else src="@/assets/zzlogo4.png" alt="" />
|
||||
<span style="white-space: nowrap" v-if="NODE_ENV !== 'usa'">
|
||||
<!-- 中心影像系统(EICS) -->
|
||||
{{ $t("trials:trials:title:eics") }}
|
||||
{{ $t('trials:trials:title:eics') }}
|
||||
</span>
|
||||
</div>
|
||||
<div class="center-menu">
|
||||
|
@ -39,13 +39,17 @@
|
|||
>
|
||||
<i class="el-icon-odometer" />
|
||||
<!-- 工作台 -->
|
||||
<span slot="title">{{ $t("trials:menuTitle:workbench") }}</span>
|
||||
<span slot="title">{{ $t('trials:menuTitle:workbench') }}</span>
|
||||
</el-menu-item>
|
||||
<el-menu-item v-if="!hasPermi(['role:zys','role:zyss','role:zybs'])" index="2" :disabled="TotalNeedSignSystemDocCount !== 0">
|
||||
<el-menu-item
|
||||
v-if="!hasPermi(['role:zys', 'role:zyss', 'role:zybs'])"
|
||||
index="2"
|
||||
:disabled="TotalNeedSignSystemDocCount !== 0"
|
||||
>
|
||||
<i class="el-icon-box" />
|
||||
<!-- 我的项目 -->
|
||||
<span slot="title">
|
||||
{{ $t("trials:tab:trials") }}
|
||||
{{ $t('trials:tab:trials') }}
|
||||
</span>
|
||||
</el-menu-item>
|
||||
<el-menu-item
|
||||
|
@ -63,7 +67,7 @@
|
|||
>
|
||||
<i class="el-icon-chat-dot-square" />
|
||||
<!-- 通知消息 -->
|
||||
<span slot="title">{{ $t("trials:tab:notice") }}</span>
|
||||
<span slot="title">{{ $t('trials:tab:notice') }}</span>
|
||||
</el-menu-item>
|
||||
|
||||
<el-submenu index="4" class="my_info">
|
||||
|
@ -75,128 +79,214 @@
|
|||
</span>
|
||||
<!-- 账户信息 -->
|
||||
<el-menu-item v-if="!hasPermi(['role:air'])" index="4-2">{{
|
||||
$t("trials:trials-myinfo:title:accountInfo")
|
||||
$t('trials:trials-myinfo:title:accountInfo')
|
||||
}}</el-menu-item>
|
||||
<!-- 管理后台 -->
|
||||
<el-menu-item
|
||||
v-if="hasPermi(['role:dev', 'role:oa', 'role:admin'])"
|
||||
index="4-4"
|
||||
>{{ $t("trials:trials-myinfo:title:system") }}</el-menu-item
|
||||
>{{ $t('trials:trials-myinfo:title:system') }}</el-menu-item
|
||||
>
|
||||
<!-- 切换角色 -->
|
||||
<el-menu-item index="4-5" v-if="hasRole">{{
|
||||
$t('trials:trials-myinfo:title:toggleRole')
|
||||
}}</el-menu-item>
|
||||
<!-- 退出 -->
|
||||
<el-menu-item index="4-3">{{
|
||||
$t("trials:trials-myinfo:button:loginout")
|
||||
$t('trials:trials-myinfo:button:loginout')
|
||||
}}</el-menu-item>
|
||||
</el-submenu>
|
||||
</el-menu>
|
||||
<TopLang v-if="VUE_APP_OSS_CONFIG_REGION !== 'oss-us-west-1'&& NODE_ENV !== 'usa'" />
|
||||
<TopLang
|
||||
v-if="
|
||||
VUE_APP_OSS_CONFIG_REGION !== 'oss-us-west-1' && NODE_ENV !== 'usa'
|
||||
"
|
||||
/>
|
||||
</div>
|
||||
<toggleRole
|
||||
:visible.sync="toggleRoleVisible"
|
||||
:loading="toggleRoleLoading"
|
||||
@save="loginByRole"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { mapGetters, mapMutations } from "vuex";
|
||||
import TopLang from "./topLang";
|
||||
import NoticeMarquee from "./noticeMarquee";
|
||||
import { mapGetters, mapMutations } from 'vuex'
|
||||
import TopLang from './topLang'
|
||||
import NoticeMarquee from './noticeMarquee'
|
||||
import toggleRole from '@/components/toggleRole'
|
||||
export default {
|
||||
components: { TopLang, NoticeMarquee },
|
||||
components: { TopLang, NoticeMarquee, toggleRole },
|
||||
data() {
|
||||
return {
|
||||
activeIndex: "2",
|
||||
activeIndex: '2',
|
||||
isReviewer: false,
|
||||
userTypeShortName: zzSessionStorage.getItem("userTypeShortName"),
|
||||
notice: "",
|
||||
userTypeShortName: zzSessionStorage.getItem('userTypeShortName'),
|
||||
notice: '',
|
||||
VUE_APP_OSS_CONFIG_REGION: process.env.VUE_APP_OSS_CONFIG_REGION,
|
||||
NODE_ENV: process.env.NODE_ENV,
|
||||
};
|
||||
toggleRoleVisible: false,
|
||||
toggleRoleLoading: false,
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
...mapGetters([
|
||||
"sidebar",
|
||||
"name",
|
||||
"userName",
|
||||
"device",
|
||||
"TotalNeedSignSystemDocCount",
|
||||
"language",
|
||||
'sidebar',
|
||||
'name',
|
||||
'userName',
|
||||
'device',
|
||||
'TotalNeedSignSystemDocCount',
|
||||
'language',
|
||||
]),
|
||||
roles() {
|
||||
return this.$store.state.user.roles
|
||||
},
|
||||
hasRole() {
|
||||
return this.roles && this.roles.length > 1
|
||||
},
|
||||
},
|
||||
watch: {
|
||||
$route(v) {
|
||||
this.changeRoute(v);
|
||||
this.changeRoute(v)
|
||||
},
|
||||
},
|
||||
created() {
|
||||
console.log(!this.hasPermi(["role:air"]));
|
||||
this.isReviewer = JSON.parse(zzSessionStorage.getItem("IsReviewer"));
|
||||
this.changeRoute(this.$route);
|
||||
// this.isReviewer = JSON.parse(zzSessionStorage.getItem('IsReviewer'))
|
||||
console.log(this.$route.path, 'this.$route.path')
|
||||
this.changeRoute(this.$route)
|
||||
},
|
||||
methods: {
|
||||
...mapMutations({ setLanguage: "lang/setLanguage" }),
|
||||
...mapMutations({ setLanguage: 'lang/setLanguage' }),
|
||||
changeRoute(v) {
|
||||
if (v.path === "/trials/trials-workbench") {
|
||||
this.activeIndex = "1";
|
||||
if (v.path === '/trials/trials-workbench') {
|
||||
this.activeIndex = '1'
|
||||
}
|
||||
if (
|
||||
v.path === "/trials/trials-list" ||
|
||||
~v.path.indexOf("/trials/trials-panel")
|
||||
v.path === '/trials/trials-list' ||
|
||||
~v.path.indexOf('/trials/trials-panel')
|
||||
) {
|
||||
this.activeIndex = "2";
|
||||
this.activeIndex = '2'
|
||||
}
|
||||
if (v.path === "/trials/trials-notice") {
|
||||
this.activeIndex = "3";
|
||||
if (v.path === '/trials/trials-notice') {
|
||||
this.activeIndex = '3'
|
||||
}
|
||||
if (v.path === "/trials/trials-myinfo") {
|
||||
this.activeIndex = "4-2";
|
||||
if (v.path === '/trials/trials-myinfo') {
|
||||
this.activeIndex = '4-2'
|
||||
}
|
||||
},
|
||||
handleSelect(key, keyPath) {
|
||||
switch (key) {
|
||||
case "4-2":
|
||||
this.go("/trials/trials-myinfo");
|
||||
break;
|
||||
case "4-3":
|
||||
this.logout();
|
||||
break;
|
||||
case "4-4":
|
||||
this.go("/dashboard/list");
|
||||
break;
|
||||
case "1":
|
||||
this.go("/trials/trials-workbench");
|
||||
break;
|
||||
case "2":
|
||||
if (~this.$route.path.indexOf("/trials/trials-panel")) {
|
||||
return;
|
||||
case '4-2':
|
||||
this.go('/trials/trials-myinfo')
|
||||
break
|
||||
case '4-3':
|
||||
this.logout()
|
||||
break
|
||||
case '4-4':
|
||||
this.go('/dashboard/list')
|
||||
break
|
||||
case '4-5':
|
||||
// this.go('/dashboard/list')
|
||||
// console.log('切换角色')
|
||||
this.$store.dispatch('user/getUserInfo').then((res) => {
|
||||
this.toggleRoleVisible = true
|
||||
})
|
||||
|
||||
break
|
||||
case '1':
|
||||
this.go('/trials/trials-workbench')
|
||||
break
|
||||
case '2':
|
||||
if (~this.$route.path.indexOf('/trials/trials-panel')) {
|
||||
return
|
||||
}
|
||||
var lastWorkbench = zzSessionStorage.getItem("lastWorkbench");
|
||||
var lastWorkbench = zzSessionStorage.getItem('lastWorkbench')
|
||||
if (lastWorkbench) {
|
||||
this.go(lastWorkbench);
|
||||
this.go(lastWorkbench)
|
||||
} else {
|
||||
this.go("/trials/trials-list");
|
||||
this.go('/trials/trials-list')
|
||||
}
|
||||
break;
|
||||
case "3":
|
||||
this.go("/trials/trials-notice");
|
||||
break;
|
||||
break
|
||||
case '3':
|
||||
this.go('/trials/trials-notice')
|
||||
break
|
||||
}
|
||||
},
|
||||
toggleSideBar() {
|
||||
this.$store.dispatch("app/toggleSideBar");
|
||||
this.$store.dispatch('app/toggleSideBar')
|
||||
},
|
||||
async logout() {
|
||||
await this.$store.dispatch("user/logout");
|
||||
this.$router.push(`/login`);
|
||||
this.$i18n.locale = "zh";
|
||||
this.setLanguage("zh");
|
||||
this.$updateDictionary();
|
||||
await this.$store.dispatch('user/logout')
|
||||
this.$router.push(`/login`)
|
||||
this.$i18n.locale = 'zh'
|
||||
this.setLanguage('zh')
|
||||
this.$updateDictionary()
|
||||
},
|
||||
go(value) {
|
||||
this.$router.push({ path: value });
|
||||
this.$router.push({ path: value })
|
||||
},
|
||||
account() {
|
||||
this.$router.push({ name: "Account" });
|
||||
this.$router.push({ name: 'Account' })
|
||||
},
|
||||
loginByRole(userRoleId) {
|
||||
if (this.$store.state.user.userId === userRoleId) {
|
||||
this.toggleRoleVisible = false
|
||||
this.toggleRoleLoading = false
|
||||
return false
|
||||
}
|
||||
this.toggleRoleLoading = true
|
||||
this.$store
|
||||
.dispatch('user/loginByRole', { userRoleId })
|
||||
.then((res) => {
|
||||
if (res) {
|
||||
this.$store
|
||||
.dispatch('permission/generateRoutes')
|
||||
.then((res) => {
|
||||
if (res && res.length > 0) {
|
||||
this.$store.dispatch('global/getNoticeList')
|
||||
this.$router.addRoutes(res)
|
||||
this.toggleRoleLoading = false
|
||||
if (this.loginType === 'DevOps') {
|
||||
this.$router.replace({ path: res[0].path })
|
||||
return
|
||||
}
|
||||
if (this.hasPermi(['role:radmin'])) {
|
||||
this.$router.replace({ path: res[0].path })
|
||||
return
|
||||
}
|
||||
if (
|
||||
this.hasPermi([
|
||||
'role:air',
|
||||
'role:rpm',
|
||||
'role:rcrc',
|
||||
'role:rir',
|
||||
])
|
||||
) {
|
||||
this.$router.replace({ path: '/trials/trials-list' })
|
||||
} else {
|
||||
this.$router.replace({ path: '/trials' })
|
||||
}
|
||||
window.location.reload()
|
||||
} else {
|
||||
// 此账户暂未配置菜单权限,请联系管理员处理后再登录。
|
||||
this.toggleRoleLoading = false
|
||||
this.$message.warning(this.$t('login:message:login2'))
|
||||
}
|
||||
})
|
||||
.catch((err) => {
|
||||
this.toggleRoleLoading = false
|
||||
})
|
||||
} else {
|
||||
this.toggleRoleLoading = false
|
||||
}
|
||||
})
|
||||
.catch(() => {
|
||||
this.toggleRoleLoading = false
|
||||
})
|
||||
},
|
||||
},
|
||||
};
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
|
|
|
@ -108,6 +108,35 @@
|
|||
{{ $t('trials:trials-myinfo:button:update') }}
|
||||
</el-button>
|
||||
</el-form-item>
|
||||
<el-form-item
|
||||
:label="$t('trials:trials-myinfo:form:toggleRole')"
|
||||
style="position: relative"
|
||||
prop="VerificationCode"
|
||||
v-if="hasRole"
|
||||
>
|
||||
<el-radio-group v-model="userRoleId" class="roles" v-if="hasRole">
|
||||
<el-radio
|
||||
v-for="item in roles"
|
||||
:key="item.Id"
|
||||
:label="item.Id"
|
||||
:disabled="item.isUserRoleDisabled"
|
||||
style="margin-bottom: 10px"
|
||||
>
|
||||
{{ item.UserTypeShortName }}
|
||||
</el-radio>
|
||||
</el-radio-group>
|
||||
<!-- 修改 -->
|
||||
<el-button
|
||||
:disabled="!userRoleId"
|
||||
class="saveBtn"
|
||||
:loading="toggleRoleLoading"
|
||||
type="primary"
|
||||
size="small"
|
||||
@click="toggleRole"
|
||||
>
|
||||
{{ $t('trials:trials-myinfo:button:toggleRole') }}
|
||||
</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</div>
|
||||
<password />
|
||||
|
@ -142,6 +171,8 @@ export default {
|
|||
data() {
|
||||
return {
|
||||
userForm: {},
|
||||
userRoleId: null,
|
||||
toggleRoleLoading: false,
|
||||
sendDisabled: true,
|
||||
sendTitle: this.$t('trials:trials-myinfo:button:getVCode'),
|
||||
rule: {
|
||||
|
@ -174,7 +205,35 @@ export default {
|
|||
},
|
||||
}
|
||||
},
|
||||
created() {
|
||||
this.userRoleId = zzSessionStorage.getItem('userId')
|
||||
},
|
||||
computed: {
|
||||
roles() {
|
||||
return this.$store.state.user.roles
|
||||
},
|
||||
hasRole() {
|
||||
return this.roles && this.roles.length > 1
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
// 切换角色
|
||||
toggleRole() {
|
||||
if (
|
||||
this.userRoleId === zzSessionStorage.getItem('userId') ||
|
||||
this.toggleRoleLoading
|
||||
)
|
||||
return false
|
||||
this.toggleRoleLoading = true
|
||||
this.$store
|
||||
.dispatch('user/loginByRole', { userRoleId: this.userRoleId })
|
||||
.then((res) => {
|
||||
window.location.reload()
|
||||
})
|
||||
.catch(() => {
|
||||
this.toggleRoleLoading = false
|
||||
})
|
||||
},
|
||||
setNewEmail() {
|
||||
setNewEmail(this.userForm.EMail, this.userForm.VerificationCode).then(
|
||||
() => {
|
||||
|
|
|
@ -471,7 +471,6 @@ export default {
|
|||
...mapState('user', ['isTestUser'])
|
||||
},
|
||||
mounted() {
|
||||
console.log('isTestUser: ',this.isTestUser)
|
||||
this.getUserTobeDoneRecord()
|
||||
this.getNeedSignTrialDocTrialIdList()
|
||||
this.getUserInfo()
|
||||
|
@ -507,7 +506,6 @@ export default {
|
|||
},
|
||||
getNeedSignTrialDocTrialIdList() {
|
||||
getNeedSignTrialDocTrialIdList().then(res => {
|
||||
console.log(res)
|
||||
this.trialIdList = res.Result
|
||||
this.$nextTick(() => {
|
||||
var list = document.querySelectorAll('div[tab-data]')
|
||||
|
|
Loading…
Reference in New Issue