8a653196 by lihua

修改登录进去时获取当前公司从缓存中取

1 parent 7a43a111
......@@ -87,6 +87,11 @@ export const getUserTenant = () => request({
method: 'get'
})
export const getCurrentTenantCache = () => request({
url: `${import.meta.env.VITE_APP_PERSONAL_URL}/tenant/get-current-user-tenant-from-cache`,
method: 'get'
})
// 获取企业信息
export const getEnterpriseData = (params) => request({
url: `${import.meta.env.VITE_APP_DIGITAL_CONTRACT_URL}/enterprise/detail-by-logonUser`,
......
......@@ -6,6 +6,7 @@ import apiUser from '@/api/modules/user'
import { getCurrentTime } from '@/utils/common'
import { getSystemMenu, getUserInfo, getTokenByCode, loginOut, refreshToken, editPasswordInterface, getCurrentUserInfo, getTenantDetailInfo } from '@/api/modules/queryService'
import { getConnectorStatus } from '@/api/modules/dataRequire'
import { getCurrentTenantCache } from '@/api/modules/dataIdentify'
const useUserStore = defineStore(
// 唯一ID
......@@ -55,45 +56,72 @@ const useUserStore = defineStore(
refreshUserToken(false);
//获取用户信息
account.value = res.data.logonUser
userId.value = res.data.userId
currentTenantGuid.value = res.data.tenantInfoList && res.data.tenantInfoList.length ? res.data.tenantInfoList[0].guid : '';
localStorage.setItem('currentTenantGuid', currentTenantGuid.value);
let currentTenant = res.data.tenantInfoList?.[0];
getTenantDetailInfo(currentTenantGuid.value).then((res: any) => {
if (res.code == '00000') {
localStorage.setItem('tenantInfo', JSON.stringify(res.data));
userId.value = res.data.userId;
let exec = (currTenantGuid) => {
currentTenantGuid.value = currTenantGuid ? currTenantGuid : (
res.data.tenantInfoList && res.data.tenantInfoList.length
? res.data.tenantInfoList[0].guid
: "");
localStorage.setItem(
"currentTenantGuid",
currentTenantGuid.value,
);
getTenantDetailInfo(currentTenantGuid.value).then(
(res: any) => {
if (res.code == "00000") {
localStorage.setItem(
"tenantInfo",
JSON.stringify(res.data),
);
} else {
ElMessage.error(res.msg);
}
},
);
getConnectorStatus().then((res: any) => {
if (res.code == "00000") {
isLogOutConnector.value = res.data?.isLogOut || "N";
localStorage.setItem(
"isLogOutConnector",
isLogOutConnector.value,
);
} else {
// 暂不弹错误提示
}
});
return getCurrentUserInfo({
tenantGuid: currentTenantGuid.value,
}).then((res: any) => {
console.log(res, "getCurrentUserInfo");
if (res.code == "00000") {
userName.value = res.data.staffName;
localStorage.setItem("userName", res.data?.staffName);
localStorage.setItem("userData", JSON.stringify(res.data));
userData.value = localStorage.getItem("userData");
isGetCurrUserInfo.value = true;
// return getSystemMenu({ tenantGuid: currentTenantGuid.value }, res.data?.isAdmin == 'Y' && (!res.data?.superTubeFlag || res.data?.superTubeFlag == 'Y')).then((info: any) => { //解决页面调用流程接口传递staffGuid,为空的问题
// if (info.code == '00000') {
// localStorage.setItem('userInfoData', JSON.stringify(info.data));
// userInfoData.value = info.data;
// // window.location.href = location.origin + info.data[0].menuList[0].path
// } else {
// ElMessage.error(info.msg)
// }
// })
} else {
ElMessage.error(res.msg);
}
});
};
getCurrentTenantCache().then((res: any) => {
if (res?.code == '00000') {
exec(res.data || null);
} else {
ElMessage.error(res.msg)
}
})
getConnectorStatus().then((res: any) => {
if (res.code == '00000') {
isLogOutConnector.value = res.data?.isLogOut || 'N';
localStorage.setItem('isLogOutConnector', isLogOutConnector.value);
} else {
// 暂不弹错误提示
}
})
return getCurrentUserInfo({tenantGuid: currentTenantGuid.value}).then((res: any) => {
console.log(res, 'getCurrentUserInfo');
if (res.code == '00000') {
userName.value = res.data.staffName;
localStorage.setItem('userName', res.data?.staffName);
localStorage.setItem('userData', JSON.stringify(res.data));
userData.value = localStorage.getItem('userData');
isGetCurrUserInfo.value = true
// return getSystemMenu({ tenantGuid: currentTenantGuid.value }, res.data?.isAdmin == 'Y' && (!res.data?.superTubeFlag || res.data?.superTubeFlag == 'Y')).then((info: any) => { //解决页面调用流程接口传递staffGuid,为空的问题
// if (info.code == '00000') {
// localStorage.setItem('userInfoData', JSON.stringify(info.data));
// userInfoData.value = info.data;
// // window.location.href = location.origin + info.data[0].menuList[0].path
// } else {
// ElMessage.error(info.msg)
// }
// })
} else {
ElMessage.error(res.msg)
exec(null);
res?.msg && ElMessage.error(res.msg);
}
}).catch(() => {
exec(null);
})
} else {
isLogin.value = false;
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!