Browse Source

fix: header 切换缓存逻辑补充

main
xuziqiang 5 months ago
parent
commit
91dd7a7d0c
  1. 38
      hx-ai-intelligent/src/config/app.config.ts
  2. 4
      hx-ai-intelligent/src/router/equipmentManage.ts
  3. 2
      hx-ai-intelligent/vite.config.ts
  4. 2
      lib/saas/view/system/login.vue

38
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 } };
});
},

4
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,

2
hx-ai-intelligent/vite.config.ts

@ -12,7 +12,7 @@ const proxy = {
changeOrigin: true,
},
'/carbon-smart': {
target: 'http://192.168.112.144:8224',
target: 'http://123.60.103.97:8224',
changeOrigin: true,
rewrite: (path) => path.replace(/^\/carbon-smart/, ''),
},

2
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();

Loading…
Cancel
Save