|
|
@@ -89,6 +89,7 @@
|
|
|
import { logout } from '@/utils/page-tab-util';
|
|
|
import { userLogout } from '@/api/system/user';
|
|
|
import router from '@/router/index';
|
|
|
+ import { getCurrentUser, setCurrentUser } from '@/utils/token-util';
|
|
|
|
|
|
export default {
|
|
|
components: { HeaderNotice, PasswordModal, SettingDrawer, I18nIcon },
|
|
|
@@ -103,49 +104,49 @@
|
|
|
// 是否显示主题设置抽屉
|
|
|
settingVisible: false,
|
|
|
groupId: '',
|
|
|
- roleId: '',
|
|
|
- currentUser:{
|
|
|
- currentGroupId:'',
|
|
|
- currentRoleId:''
|
|
|
- }
|
|
|
+ roleId: '',
|
|
|
+ currentUser: {
|
|
|
+ currentGroupId: '',
|
|
|
+ currentRoleId: ''
|
|
|
+ }
|
|
|
};
|
|
|
},
|
|
|
created() {
|
|
|
- this.currentUser = JSON.parse(sessionStorage['currentUser']);
|
|
|
- this.groupId = this.currentUser.currentGroupId;
|
|
|
- this.roleId = this.currentUser.currentRoleId;
|
|
|
- },
|
|
|
+ this.currentUser = getCurrentUser();
|
|
|
+ this.groupId = this.currentUser.currentGroupId;
|
|
|
+ this.roleId = this.currentUser.currentRoleId;
|
|
|
+ },
|
|
|
computed: {
|
|
|
// 当前用户信息
|
|
|
loginUser() {
|
|
|
return this.$store.state.user.info;
|
|
|
},
|
|
|
- // 部门下拉
|
|
|
- loginChangeGroupVOList() {
|
|
|
- return this.$store.state.user?.info?.loginChangeGroupVOList;
|
|
|
- },
|
|
|
- // 角色下拉
|
|
|
- loginChangeRoleVOList() {
|
|
|
- return this.$store.state.user?.info?.loginChangeGroupVOList.find(
|
|
|
- (item) => item.groupId == this.groupId
|
|
|
- )?.loginChangeRoleVOList;
|
|
|
- }
|
|
|
+ // 部门下拉
|
|
|
+ loginChangeGroupVOList() {
|
|
|
+ return this.$store.state.user?.info?.loginChangeGroupVOList;
|
|
|
+ },
|
|
|
+ // 角色下拉
|
|
|
+ loginChangeRoleVOList() {
|
|
|
+ return this.$store.state.user?.info?.loginChangeGroupVOList.find(
|
|
|
+ (item) => item.groupId == this.groupId
|
|
|
+ )?.loginChangeRoleVOList;
|
|
|
+ }
|
|
|
},
|
|
|
methods: {
|
|
|
groupIdChange(val) {
|
|
|
- this.roleChange(this.loginChangeRoleVOList[0].roleId);
|
|
|
- },
|
|
|
- roleChange(val) {
|
|
|
- this.roleId = val;
|
|
|
- this.currentUser.currentGroupId = this.groupId;
|
|
|
- this.currentUser.currentRoleId = val;
|
|
|
- sessionStorage['currentUser']=JSON.stringify(this.currentUser)
|
|
|
- this.$store
|
|
|
- .dispatch('user/fetchUserInfo')
|
|
|
- .then(({ menus, homePath, authoritiesRouter }) => {
|
|
|
- router.roleChange({ menus, homePath, authoritiesRouter });
|
|
|
- });
|
|
|
- },
|
|
|
+ this.roleChange(this.loginChangeRoleVOList[0].roleId);
|
|
|
+ },
|
|
|
+ roleChange(val) {
|
|
|
+ this.roleId = val;
|
|
|
+ this.currentUser.currentGroupId = this.groupId;
|
|
|
+ this.currentUser.currentRoleId = val;
|
|
|
+ setCurrentUser(this.currentUser)
|
|
|
+ this.$store
|
|
|
+ .dispatch('user/fetchUserInfo')
|
|
|
+ .then(({ menus, homePath, authoritiesRouter }) => {
|
|
|
+ router.roleChange({ menus, homePath, authoritiesRouter });
|
|
|
+ });
|
|
|
+ },
|
|
|
/* 用户信息下拉点击事件 */
|
|
|
onUserDropClick(command) {
|
|
|
if (command === 'password') {
|