修改登录进去时获取当前公司从缓存中取
Showing
2 changed files
with
54 additions
and
21 deletions
| ... | @@ -87,6 +87,11 @@ export const getUserTenant = () => request({ | ... | @@ -87,6 +87,11 @@ export const getUserTenant = () => request({ |
| 87 | method: 'get' | 87 | method: 'get' |
| 88 | }) | 88 | }) |
| 89 | 89 | ||
| 90 | export const getCurrentTenantCache = () => request({ | ||
| 91 | url: `${import.meta.env.VITE_APP_PERSONAL_URL}/tenant/get-current-user-tenant-from-cache`, | ||
| 92 | method: 'get' | ||
| 93 | }) | ||
| 94 | |||
| 90 | // 获取企业信息 | 95 | // 获取企业信息 |
| 91 | export const getEnterpriseData = (params) => request({ | 96 | export const getEnterpriseData = (params) => request({ |
| 92 | url: `${import.meta.env.VITE_APP_DIGITAL_CONTRACT_URL}/enterprise/detail-by-logonUser`, | 97 | url: `${import.meta.env.VITE_APP_DIGITAL_CONTRACT_URL}/enterprise/detail-by-logonUser`, | ... | ... |
| ... | @@ -6,6 +6,7 @@ import apiUser from '@/api/modules/user' | ... | @@ -6,6 +6,7 @@ import apiUser from '@/api/modules/user' |
| 6 | import { getCurrentTime } from '@/utils/common' | 6 | import { getCurrentTime } from '@/utils/common' |
| 7 | import { getSystemMenu, getUserInfo, getTokenByCode, loginOut, refreshToken, editPasswordInterface, getCurrentUserInfo, getTenantDetailInfo } from '@/api/modules/queryService' | 7 | import { getSystemMenu, getUserInfo, getTokenByCode, loginOut, refreshToken, editPasswordInterface, getCurrentUserInfo, getTenantDetailInfo } from '@/api/modules/queryService' |
| 8 | import { getConnectorStatus } from '@/api/modules/dataRequire' | 8 | import { getConnectorStatus } from '@/api/modules/dataRequire' |
| 9 | import { getCurrentTenantCache } from '@/api/modules/dataIdentify' | ||
| 9 | 10 | ||
| 10 | const useUserStore = defineStore( | 11 | const useUserStore = defineStore( |
| 11 | // 唯一ID | 12 | // 唯一ID |
| ... | @@ -55,33 +56,49 @@ const useUserStore = defineStore( | ... | @@ -55,33 +56,49 @@ const useUserStore = defineStore( |
| 55 | refreshUserToken(false); | 56 | refreshUserToken(false); |
| 56 | //获取用户信息 | 57 | //获取用户信息 |
| 57 | account.value = res.data.logonUser | 58 | account.value = res.data.logonUser |
| 58 | userId.value = res.data.userId | 59 | userId.value = res.data.userId; |
| 59 | currentTenantGuid.value = res.data.tenantInfoList && res.data.tenantInfoList.length ? res.data.tenantInfoList[0].guid : ''; | 60 | let exec = (currTenantGuid) => { |
| 60 | localStorage.setItem('currentTenantGuid', currentTenantGuid.value); | 61 | currentTenantGuid.value = currTenantGuid ? currTenantGuid : ( |
| 61 | let currentTenant = res.data.tenantInfoList?.[0]; | 62 | res.data.tenantInfoList && res.data.tenantInfoList.length |
| 62 | getTenantDetailInfo(currentTenantGuid.value).then((res: any) => { | 63 | ? res.data.tenantInfoList[0].guid |
| 63 | if (res.code == '00000') { | 64 | : ""); |
| 64 | localStorage.setItem('tenantInfo', JSON.stringify(res.data)); | 65 | localStorage.setItem( |
| 66 | "currentTenantGuid", | ||
| 67 | currentTenantGuid.value, | ||
| 68 | ); | ||
| 69 | getTenantDetailInfo(currentTenantGuid.value).then( | ||
| 70 | (res: any) => { | ||
| 71 | if (res.code == "00000") { | ||
| 72 | localStorage.setItem( | ||
| 73 | "tenantInfo", | ||
| 74 | JSON.stringify(res.data), | ||
| 75 | ); | ||
| 65 | } else { | 76 | } else { |
| 66 | ElMessage.error(res.msg) | 77 | ElMessage.error(res.msg); |
| 67 | } | 78 | } |
| 68 | }) | 79 | }, |
| 80 | ); | ||
| 69 | getConnectorStatus().then((res: any) => { | 81 | getConnectorStatus().then((res: any) => { |
| 70 | if (res.code == '00000') { | 82 | if (res.code == "00000") { |
| 71 | isLogOutConnector.value = res.data?.isLogOut || 'N'; | 83 | isLogOutConnector.value = res.data?.isLogOut || "N"; |
| 72 | localStorage.setItem('isLogOutConnector', isLogOutConnector.value); | 84 | localStorage.setItem( |
| 85 | "isLogOutConnector", | ||
| 86 | isLogOutConnector.value, | ||
| 87 | ); | ||
| 73 | } else { | 88 | } else { |
| 74 | // 暂不弹错误提示 | 89 | // 暂不弹错误提示 |
| 75 | } | 90 | } |
| 76 | }) | 91 | }); |
| 77 | return getCurrentUserInfo({tenantGuid: currentTenantGuid.value}).then((res: any) => { | 92 | return getCurrentUserInfo({ |
| 78 | console.log(res, 'getCurrentUserInfo'); | 93 | tenantGuid: currentTenantGuid.value, |
| 79 | if (res.code == '00000') { | 94 | }).then((res: any) => { |
| 95 | console.log(res, "getCurrentUserInfo"); | ||
| 96 | if (res.code == "00000") { | ||
| 80 | userName.value = res.data.staffName; | 97 | userName.value = res.data.staffName; |
| 81 | localStorage.setItem('userName', res.data?.staffName); | 98 | localStorage.setItem("userName", res.data?.staffName); |
| 82 | localStorage.setItem('userData', JSON.stringify(res.data)); | 99 | localStorage.setItem("userData", JSON.stringify(res.data)); |
| 83 | userData.value = localStorage.getItem('userData'); | 100 | userData.value = localStorage.getItem("userData"); |
| 84 | isGetCurrUserInfo.value = true | 101 | isGetCurrUserInfo.value = true; |
| 85 | // return getSystemMenu({ tenantGuid: currentTenantGuid.value }, res.data?.isAdmin == 'Y' && (!res.data?.superTubeFlag || res.data?.superTubeFlag == 'Y')).then((info: any) => { //解决页面调用流程接口传递staffGuid,为空的问题 | 102 | // return getSystemMenu({ tenantGuid: currentTenantGuid.value }, res.data?.isAdmin == 'Y' && (!res.data?.superTubeFlag || res.data?.superTubeFlag == 'Y')).then((info: any) => { //解决页面调用流程接口传递staffGuid,为空的问题 |
| 86 | // if (info.code == '00000') { | 103 | // if (info.code == '00000') { |
| 87 | // localStorage.setItem('userInfoData', JSON.stringify(info.data)); | 104 | // localStorage.setItem('userInfoData', JSON.stringify(info.data)); |
| ... | @@ -92,8 +109,19 @@ const useUserStore = defineStore( | ... | @@ -92,8 +109,19 @@ const useUserStore = defineStore( |
| 92 | // } | 109 | // } |
| 93 | // }) | 110 | // }) |
| 94 | } else { | 111 | } else { |
| 95 | ElMessage.error(res.msg) | 112 | ElMessage.error(res.msg); |
| 96 | } | 113 | } |
| 114 | }); | ||
| 115 | }; | ||
| 116 | getCurrentTenantCache().then((res: any) => { | ||
| 117 | if (res?.code == '00000') { | ||
| 118 | exec(res.data || null); | ||
| 119 | } else { | ||
| 120 | exec(null); | ||
| 121 | res?.msg && ElMessage.error(res.msg); | ||
| 122 | } | ||
| 123 | }).catch(() => { | ||
| 124 | exec(null); | ||
| 97 | }) | 125 | }) |
| 98 | } else { | 126 | } else { |
| 99 | isLogin.value = false; | 127 | isLogin.value = false; | ... | ... |
-
Please register or sign in to post a comment