diff --git a/hx-ai-intelligent/src/config/app.config.ts b/hx-ai-intelligent/src/config/app.config.ts index 6a1b5dd..8f83d01 100644 --- a/hx-ai-intelligent/src/config/app.config.ts +++ b/hx-ai-intelligent/src/config/app.config.ts @@ -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 } }; }); }, diff --git a/hx-ai-intelligent/src/router/equipmentManage.ts b/hx-ai-intelligent/src/router/equipmentManage.ts index 0b18f9f..6fde6d1 100644 --- a/hx-ai-intelligent/src/router/equipmentManage.ts +++ b/hx-ai-intelligent/src/router/equipmentManage.ts @@ -15,8 +15,8 @@ const equipment = { { path: 'index', name: 'LedgerIndex', - component: () => import('/nerv-lib/saas/view/menuManage/index.vue'), - // component: () => import('/@/view/equipmentManage/ledger/index.vue'), + // component: () => import('/nerv-lib/saas/view/menuManage/index.vue'), + component: () => import('/@/view/equipmentManage/ledger/index.vue'), meta: { title: '设备台账', keepAlive: true, diff --git a/lib/saas/view/system/login.vue b/lib/saas/view/system/login.vue index 9872c98..d17e189 100644 --- a/lib/saas/view/system/login.vue +++ b/lib/saas/view/system/login.vue @@ -104,7 +104,7 @@ : ''; loading.value = false; if (configStore.enablePermissions) { - const res = await configStore.userResource(); + const res = await configStore.userResource(info); if (configStore.customApplication) { await useAuthorization.initMenuResource();