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