diff --git a/README-zh.md b/README-zh.md index e472d1d6..9e111c1e 100644 --- a/README-zh.md +++ b/README-zh.md @@ -5,3 +5,6 @@ npm install # 启动服务 npm run dev +# v1.9.0修改 +1. 角色修改,全局userId实际意义修改为userRoleId(用户角色id),新增identityUserId(新的用户id) + diff --git a/public/index.html b/public/index.html index 0c22a84a..8703f504 100644 --- a/public/index.html +++ b/public/index.html @@ -30,7 +30,6 @@ <% } else { %> + \ No newline at end of file diff --git a/src/const/check/index.js b/src/const/check/index.js index 8b2ea225..f19bc6c2 100644 --- a/src/const/check/index.js +++ b/src/const/check/index.js @@ -1,6 +1,5 @@ import { SubjectCheckConfig } from './module/Subject' -console.log(SubjectCheckConfig.moduleType) export const checkConfig = { ModuleType: { ...SubjectCheckConfig.ModuleType diff --git a/src/layout/components/Navbar.vue b/src/layout/components/Navbar.vue index d8a1ad17..49442e19 100644 --- a/src/layout/components/Navbar.vue +++ b/src/layout/components/Navbar.vue @@ -69,7 +69,7 @@ export default { ...mapGetters(['sidebar', 'name', 'device']) }, created() { - this.isReviewer = JSON.parse(zzSessionStorage.getItem('IsReviewer')) + // this.isReviewer = JSON.parse(zzSessionStorage.getItem('IsReviewer')) }, methods: { ...mapMutations({ setLanguage: 'lang/setLanguage' }), diff --git a/src/permission.js b/src/permission.js index 755d8f65..185ace75 100644 --- a/src/permission.js +++ b/src/permission.js @@ -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 }) diff --git a/src/store/getters.js b/src/store/getters.js index 9f5c1c33..6ab90e66 100644 --- a/src/store/getters.js +++ b/src/store/getters.js @@ -7,6 +7,7 @@ const getters = { tree: state => state.user.tree, userName: state => state.user.userName, userId: state => state.user.userId, + identityUserId: state => state.user.identityUserId, routes: state => state.permission.routes, asyncRoutes: state => state.permission.addRoutes, visitedViews: state => state.tagsView.visitedViews, diff --git a/src/store/modules/user.js b/src/store/modules/user.js index a2cf9be9..5d725e21 100644 --- a/src/store/modules/user.js +++ b/src/store/modules/user.js @@ -1,5 +1,6 @@ import { getToken, setToken, removeToken, setName, removeName } from '@/utils/auth' -import { login, loginOut, getUserMenuTree, getUserPermissions } from '@/api/user' +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,6 +10,7 @@ const getDefaultState = () => { name: '', userName: '', userId: '', + identityUserId: '', avatar: '', permissions: [], tree: [], @@ -16,13 +18,17 @@ const getDefaultState = () => { TotalNeedSignSystemDocCount: eval(process.env.VUE_APP_WORD_FOR_PERMISSION) ? null : 0, TotalNeedSignTrialDocCount: eval(process.env.VUE_APP_WORD_FOR_PERMISSION) ? null : 0, TrialStatusStr: null, - isTestUser: false + isTestUser: false, + roles: [] } } const state = getDefaultState() const mutations = { + SET_ROLES: (state, roles) => { + state.roles = roles + }, RESET_STATE: (state) => { Object.assign(state, getDefaultState()) }, @@ -49,6 +55,9 @@ const mutations = { SET_USERID: (state, id) => { state.userId = id }, + SET_IDENTITYUSERID: (state, id) => { + state.identityUserId = id + }, SET_ISTESTUSER: (state, isTestUser) => { state.isTestUser = eval(isTestUser) }, @@ -78,6 +87,9 @@ const mutations = { } const actions = { + setRoles({ commit }, roles) { + commit('SET_ROLES', roles) + }, changeUserName({ commit }, userName) { commit('SET_USERNAME', userName) }, @@ -91,7 +103,7 @@ const actions = { if (UserId) { data.UserId = UserId; } - login(data).then(async response => { + getUserLoginRoleList(data).then(async response => { if (response.IsSuccess) { zzSessionStorage.removeItem('lastWorkbench') zzSessionStorage.setItem('my_username', username.trim()) @@ -99,6 +111,7 @@ const actions = { zzSessionStorage.setItem('my_EMail', response.Result.BasicInfo.EMail) localStorage.setItem('CompanyInfo', JSON.stringify(response.Result.CompanyInfo)) const data = response.Result + commit('SET_ROLES', data.BasicInfo.AccountList) if (data.BasicInfo.IsFirstAdd || data.BasicInfo.LoginState === 1) { try { zzSessionStorage.setItem('userId', data.BasicInfo.Id) @@ -114,25 +127,25 @@ 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.Id) + 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.id) + // 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() - commit('SET_TREE', menuTree.Result) - commit('SET_PERMISSIONS', permissions.Result) - zzSessionStorage.setItem('newTree', JSON.stringify(menuTree.Result)) - zzSessionStorage.setItem('permissions', JSON.stringify(permissions.Result)) + // var permissions = await getUserPermissions() + // var menuTree = await getUserMenuTree() + // commit('SET_TREE', menuTree.Result) + // commit('SET_PERMISSIONS', permissions.Result) + // zzSessionStorage.setItem('newTree', JSON.stringify(menuTree.Result)) + // zzSessionStorage.setItem('permissions', JSON.stringify(permissions.Result)) } catch (e) { console.log(e) } @@ -146,6 +159,44 @@ const actions = { }) }) }, + loginByRole({ commit }, userInfo) { + const { userRoleId } = userInfo + let params = { + userRoleId + } + return new Promise((resolve, reject) => { + + loginSelectUserRole(params).then(async response => { + if (response.IsSuccess) { + const data = response.Result + + try { + 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) + commit('SET_PERMISSIONS', permissions.Result) + zzSessionStorage.setItem('newTree', JSON.stringify(menuTree.Result)) + zzSessionStorage.setItem('permissions', JSON.stringify(permissions.Result)) + } catch (e) { + console.log(e) + } + resolve(response.Result) + + } else { + reject(response.ErrorMessage) + } + }).catch(() => { + reject() + }) + }) + }, setTree({ commit }, tree) { commit('SET_TREE', tree) }, @@ -170,21 +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_USERID', user.id) + 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.id) + 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 }) { diff --git a/src/views/admin/user/components/UserInfo.vue b/src/views/admin/user/components/UserInfo.vue index c77558a7..5b2057d5 100644 --- a/src/views/admin/user/components/UserInfo.vue +++ b/src/views/admin/user/components/UserInfo.vue @@ -5,7 +5,7 @@ :model="user" :rules="userFormRules" label-width="150px" - style="width:800px;" + style="width: 800px" >
@@ -25,7 +25,7 @@ - + Male Female @@ -37,13 +37,24 @@ - - + + - + - +
Affiliation
- + Internal External - + @@ -78,19 +100,24 @@ type="primary" size="small" :disabled="isDisabled" - style="margin:10px 15px" + style="margin: 10px 15px" @click="handleSave" - >Save + >Save - diff --git a/src/views/email-recompose/index.vue b/src/views/email-recompose/index.vue index 9a11ceb9..ba74eceb 100644 --- a/src/views/email-recompose/index.vue +++ b/src/views/email-recompose/index.vue @@ -95,7 +95,6 @@ export default { : 'zh' /* eslint-disable */ var reg1 = /^[a-zA-Z0-9_]{4,16}$/ //密码必须是8位以上、必须含有字母、数字、特殊符号 - console.log(!reg1.test(value)) if (!reg1.test(value)) { callback( lang === 'zh' diff --git a/src/views/forgetpassword/index.vue b/src/views/forgetpassword/index.vue index 1f18d6f4..d66f6c34 100644 --- a/src/views/forgetpassword/index.vue +++ b/src/views/forgetpassword/index.vue @@ -76,7 +76,8 @@ > - + - - +
--> { this.formLoading = false - this.users = res.Result - if (this.users.length === 1) { - this.form.UserId = this.users[0].UserId - this.form.UserType = this.users[0].UserType - } + this.form.UserId = res.Result.Id + this.form.UserName = res.Result.UserName + // this.users = res.Result + // if (this.users.length === 1) { + // this.form.UserId = this.users[0].UserId + // this.form.UserType = this.users[0].UserType + // } // 验证成功 this.$message.success( this.$t('passwordReset:message:verifiedSuccessfully') diff --git a/src/views/login/index.vue b/src/views/login/index.vue index 95879c6f..f37debd8 100644 --- a/src/views/login/index.vue +++ b/src/views/login/index.vue @@ -83,7 +83,7 @@ - - + +
@@ -253,9 +260,10 @@ import TopLang from './topLang' import Vcode from 'vue-puzzle-vcode' import browserTip from '@/views/dictionary/template/browser/tip.vue' import Img1 from '@/assets/pic-2.png' +import toggleRole from '@/components/toggleRole' export default { name: 'Login', - components: { TopLang, Vcode, browserTip }, + components: { TopLang, Vcode, browserTip, toggleRole }, data() { return { NODE_ENV: process.env.NODE_ENV, // process.env.NODE_ENV @@ -298,6 +306,8 @@ export default { isShow: false, showCode: false, Img1, + toggleRoleVisible: false, + toggleRoleLoading: false, } }, computed: { @@ -318,6 +328,7 @@ export default { }, }, mounted() { + zzSessionStorage.clear() this.loginType = this.$route.query.loginType this.location = this.$route.query.location zzSessionStorage.setItem('loginType', this.loginType) @@ -416,37 +427,79 @@ export default { // this.$alert(this.$t('login:message:login4'), this.$t('common:title:warning')) this.$message.warning(this.$t('login:message:login4')) } - this.$store.dispatch('permission/generateRoutes').then((res) => { - this.loading = false - if (res && res.length > 0) { - this.$store.dispatch('global/getNoticeList') - this.$router.addRoutes(res) - 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' }) - } - } else { - // 此账户暂未配置菜单权限,请联系管理员处理后再登录。 - this.$message.warning(this.$t('login:message:login2')) - } - }) + 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(() => { this.showCode = true this.loading = false }) }, + loginByRole(userRoleId) { + this.toggleRoleLoading = true + this.$store + .dispatch('user/loginByRole', { userRoleId }) + .then((res) => { + this.toggleRoleLoading = false + if (res) { + this.$store + .dispatch('permission/generateRoutes') + .then((res) => { + this.loading = false + if (res && res.length > 0) { + this.$store.dispatch('global/getNoticeList') + this.$router.addRoutes(res) + 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' }) + } + } else { + this.toggleRoleLoading = false + // 此账户暂未配置菜单权限,请联系管理员处理后再登录。 + this.$message.warning(this.$t('login:message:login2')) + } + }) + .catch((err) => { + this.toggleRoleLoading = false + }) + } else { + this.toggleRoleLoading = false + } + }) + .catch(() => { + this.showCode = true + this.loading = false + this.toggleRoleLoading = false + }) + }, + cancel() { + this.showCode = true + this.loading = false + this.toggleRoleLoading = false + // this.toggleRoleVisible = false + }, onSuccess() { this.isShow = false this.loginIn() diff --git a/src/views/system/user/components/UserInfo.vue b/src/views/system/user/components/UserInfo.vue index 7b98223b..1f8de2ec 100644 --- a/src/views/system/user/components/UserInfo.vue +++ b/src/views/system/user/components/UserInfo.vue @@ -5,24 +5,38 @@ :model="user" :rules="userFormRules" label-width="150px" - style="width:800px;" + style="width: 800px" >
{{ $t('system:userlist:title:Information') }}
- + - + - + - + + + {{ $t('common:button:confirm') }} + + + + + + + + + + +
+ + + {{ $t('common:button:confirm') }} + + + + {{ $t('common:button:cancel') }} + +
+
+ + + \ No newline at end of file diff --git a/src/views/system/user/list/index.vue b/src/views/system/user/list/index.vue index f00d9a15..36a149a9 100644 --- a/src/views/system/user/list/index.vue +++ b/src/views/system/user/list/index.vue @@ -35,6 +35,16 @@ + @@ -115,7 +125,7 @@ export default { showOverflowTooltip: true, }, { - prop: 'RealName', + prop: 'FullName', label: this.$t('system:userlist:table:RealName'), minWidth: 120, sortable: 'custom', @@ -154,6 +164,7 @@ export default { prop: 'UserType', label: this.$t('system:userlist:table:UserType'), minWidth: 100, + slot: 'UserTypeSlot', sortable: 'custom', showOverflowTooltip: true, }, diff --git a/src/views/trials/trials-layout/components/topLang.vue b/src/views/trials/trials-layout/components/topLang.vue index c3b9caf1..c41d6a92 100644 --- a/src/views/trials/trials-layout/components/topLang.vue +++ b/src/views/trials/trials-layout/components/topLang.vue @@ -44,7 +44,6 @@ export default { this.$i18n.locale = lang this.setLanguage(lang) this.$updateDictionary() - console.log(Vue) this.$upload() window.location.reload() } diff --git a/src/views/trials/trials-layout/components/trialsNavbar.vue b/src/views/trials/trials-layout/components/trialsNavbar.vue index d09a8fe8..e8404a87 100644 --- a/src/views/trials/trials-layout/components/trialsNavbar.vue +++ b/src/views/trials/trials-layout/components/trialsNavbar.vue @@ -11,7 +11,7 @@ - {{ $t("trials:trials:title:eics") }} + {{ $t('trials:trials:title:eics') }}
@@ -39,13 +39,17 @@ > - {{ $t("trials:menuTitle:workbench") }} + {{ $t('trials:menuTitle:workbench') }} - + - {{ $t("trials:tab:trials") }} + {{ $t('trials:tab:trials') }} - {{ $t("trials:tab:notice") }} + {{ $t('trials:tab:notice') }} @@ -75,128 +79,214 @@ {{ - $t("trials:trials-myinfo:title:accountInfo") + $t('trials:trials-myinfo:title:accountInfo') }} {{ $t("trials:trials-myinfo:title:system") }}{{ $t('trials:trials-myinfo:title:system') }} + + {{ + $t('trials:trials-myinfo:title:toggleRole') + }} {{ - $t("trials:trials-myinfo:button:loginout") + $t('trials:trials-myinfo:button:loginout') }} - +
+ \ No newline at end of file diff --git a/src/views/trials/trials-panel/setting/personnel-manage/components/site.vue b/src/views/trials/trials-panel/setting/personnel-manage/components/site.vue index fed20e1a..1f232dbf 100644 --- a/src/views/trials/trials-panel/setting/personnel-manage/components/site.vue +++ b/src/views/trials/trials-panel/setting/personnel-manage/components/site.vue @@ -150,12 +150,7 @@ min-width="100" > @@ -207,30 +256,60 @@ - diff --git a/src/views/trials/trials-panel/setting/personnel-manage/components/staffExternalForm.vue b/src/views/trials/trials-panel/setting/personnel-manage/components/staffExternalForm.vue index d6071671..b068b91c 100644 --- a/src/views/trials/trials-panel/setting/personnel-manage/components/staffExternalForm.vue +++ b/src/views/trials/trials-panel/setting/personnel-manage/components/staffExternalForm.vue @@ -19,8 +19,12 @@ {{ $t('common:button:reset') }} + + + {{ $t('trials:staff:button:permissionConfiguration') }} + - + {{ $t('trials:staff:button:sendEmail') }} @@ -113,12 +117,52 @@ + + + +