|
|
|
@@ -1,21 +1,20 @@
|
|
|
|
|
import { userInfo, userResource } from './../../../hx-op/src/api/user';
|
|
|
|
|
import { http } from '/nerv-lib/saas';
|
|
|
|
|
import { permission } from '/@/api/origanizemanage';
|
|
|
|
|
import { appConfigStore } from '/nerv-lib/saas/store/modules/app-config';
|
|
|
|
|
import { authorizationService } from '/nerv-base/store/modules/authorization-service';
|
|
|
|
|
import { isEmpty } from 'lodash-es';
|
|
|
|
|
import { get } from 'lodash-es';
|
|
|
|
|
import { computed, ref, toRef } from 'vue';
|
|
|
|
|
|
|
|
|
|
// const { permissionVos } = sessionStorage.getItem('userInfo');
|
|
|
|
|
// ? JSON.parse(sessionStorage.getItem('userInfo')!)
|
|
|
|
|
// : [{}];
|
|
|
|
|
// const value = ref(linkList[0]?.orgId);
|
|
|
|
|
const ORGID = sessionStorage.getItem('ORGID') ? Number(sessionStorage.getItem('ORGID')) : '';
|
|
|
|
|
|
|
|
|
|
const selectDefaultValue = ref(ORGID);
|
|
|
|
|
const transform = (data, map) => {
|
|
|
|
|
return Object.keys(map).reduce((pre, cur) => {
|
|
|
|
|
pre[cur] = data[map[cur]];
|
|
|
|
|
return pre;
|
|
|
|
|
}, {});
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export const appConfig = {
|
|
|
|
|
projectType: 'web',
|
|
|
|
|
baseApi: '/api',
|
|
|
|
@@ -57,15 +56,17 @@ export const appConfig = {
|
|
|
|
|
componentProps: {
|
|
|
|
|
style: { width: '200px' },
|
|
|
|
|
api: '/carbon-smart/user/login/logInInfo',
|
|
|
|
|
defaultValue: selectDefaultValue,
|
|
|
|
|
// autoSelectFirst: true,
|
|
|
|
|
placeholder: '请选择',
|
|
|
|
|
autoSelectFirst: true,
|
|
|
|
|
onChange: async (cur, record) => {
|
|
|
|
|
onSelect: async (cur, record) => {
|
|
|
|
|
console.log(cur, record);
|
|
|
|
|
const configStore = appConfigStore();
|
|
|
|
|
const useAuthorization = authorizationService();
|
|
|
|
|
|
|
|
|
|
const res = await configStore.userResource(record);
|
|
|
|
|
sessionStorage.setItem('ORGID', record.orgId);
|
|
|
|
|
const res = await configStore.userResource({ data: record });
|
|
|
|
|
useAuthorization.updateUserResource(res.data);
|
|
|
|
|
|
|
|
|
|
// value.value = cur;
|
|
|
|
|
},
|
|
|
|
|
resultField: 'data.linkList',
|
|
|
|
@@ -80,15 +81,17 @@ export const appConfig = {
|
|
|
|
|
return http.post('/carbon-smart/user/login', { ...params });
|
|
|
|
|
},
|
|
|
|
|
userResourceApi: (params) => {
|
|
|
|
|
console.log(params, 'userResource');
|
|
|
|
|
const { orgId } = get(params, 'data') || { orgId: '' };
|
|
|
|
|
const finalId = orgId || ORGID;
|
|
|
|
|
// 解决初始化登录select无初始值的问题
|
|
|
|
|
selectDefaultValue.value = finalId;
|
|
|
|
|
|
|
|
|
|
const userInfo = JSON.parse(sessionStorage.getItem('userInfo')!);
|
|
|
|
|
const ownOrgInfo = userInfo.linkList?.filter(({ isOwn }) => isOwn)[0];
|
|
|
|
|
return http
|
|
|
|
|
.post('/carbon-smart/user/login/logInPermission', !isEmpty(params) ? params : ownOrgInfo)
|
|
|
|
|
.then((res) => {
|
|
|
|
|
return res;
|
|
|
|
|
});
|
|
|
|
|
const ownOrgInfo = userInfo.linkList?.filter(({ orgId: id }) => id === finalId)[0];
|
|
|
|
|
|
|
|
|
|
return http.post('/carbon-smart/user/login/logInPermission', ownOrgInfo).then((res) => {
|
|
|
|
|
return res;
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
userInfoApi: () => {
|
|
|
|
|
return http.post('/carbon-smart/user/login/logInInfo').then((res) => {
|
|
|
|
@@ -103,6 +106,7 @@ export const appConfig = {
|
|
|
|
|
linkList: 'linkList',
|
|
|
|
|
permissionVos: 'permissionVos',
|
|
|
|
|
});
|
|
|
|
|
sessionStorage.setItem('ORGID', info.orgId);
|
|
|
|
|
return { data: { ...trD } };
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|