Files
SaaS-lib/hx-ai-intelligent/src/config/app.config.ts

117 lines
3.8 KiB
TypeScript
Raw Normal View History

2024-05-28 14:48:37 +08:00
import { http } from '/nerv-lib/saas';
2024-06-04 11:40:32 +08:00
import { permission } from '/@/api/origanizemanage';
2024-06-14 18:27:07 +08:00
import { appConfigStore } from '/nerv-lib/saas/store/modules/app-config';
import { authorizationService } from '/nerv-base/store/modules/authorization-service';
2024-06-17 13:48:27 +08:00
import { get } from 'lodash-es';
import { computed, ref, toRef } from 'vue';
2024-06-04 11:40:32 +08:00
2024-06-17 13:48:27 +08:00
const ORGID = sessionStorage.getItem('ORGID') ? Number(sessionStorage.getItem('ORGID')) : '';
2024-06-11 13:37:10 +08:00
2024-06-17 13:48:27 +08:00
const selectDefaultValue = ref(ORGID);
2024-05-28 14:48:37 +08:00
const transform = (data, map) => {
return Object.keys(map).reduce((pre, cur) => {
pre[cur] = data[map[cur]];
return pre;
}, {});
};
2024-06-17 13:48:27 +08:00
2024-05-21 16:42:16 +08:00
export const appConfig = {
projectType: 'web',
baseApi: '/api',
2024-06-17 16:59:30 +08:00
projectName: '济阳站_AI智能BAS系统',
2024-07-03 17:58:39 +08:00
enablePermissions: false,
2024-05-22 14:36:37 +08:00
// themeColor: '#eee',
2024-05-21 16:42:16 +08:00
siderPosition: 'left',
baseHeader: '/parkingManage',
baseRouter: '/parkingManage/parkingLotManage',
2024-05-27 13:27:54 +08:00
themeConfig: {
bgImageUrl: `${import.meta.env.VITE_PUBLIC_PATH}/asset/image/login/background.png`,
2024-06-21 15:19:28 +08:00
logoLessUrl: `${import.meta.env.VITE_PUBLIC_PATH}/asset/image/headerIcon.png`,
2024-07-15 15:53:54 +08:00
logoUrl: `${import.meta.env.VITE_PUBLIC_PATH}/asset/image/headerIcon.png`,
2024-05-27 13:27:54 +08:00
},
2024-06-17 17:41:30 +08:00
// userCustomRouterGuard: (to, from, next, whiteNameList, authorizationStore, appConfig) => {
// console.log({ to, from, next, whiteNameList, authorizationStore, appConfig }, 'routeConfig');
// next();
// },
2024-05-21 16:42:16 +08:00
// customUpdatePwd: () => import('/@/view/updatePassword/updatePassword.vue'),
2024-05-28 14:48:37 +08:00
2024-05-23 17:49:25 +08:00
headerSlotConfig: {
2024-06-11 13:37:10 +08:00
component: 'NsSelectApi',
2024-05-23 17:49:25 +08:00
componentProps: {
2024-06-21 15:19:28 +08:00
style: { width: '200px', color: '#2778FF', marginRight: '10px' },
2024-06-11 13:37:10 +08:00
api: '/carbon-smart/user/login/logInInfo',
2024-06-21 15:19:28 +08:00
size: 'large',
2024-06-17 13:48:27 +08:00
defaultValue: selectDefaultValue,
// autoSelectFirst: true,
2024-05-23 17:49:25 +08:00
placeholder: '请选择',
2024-06-17 13:48:27 +08:00
onSelect: async (cur, record) => {
2024-06-14 18:27:07 +08:00
console.log(cur, record);
const configStore = appConfigStore();
const useAuthorization = authorizationService();
2024-06-17 13:48:27 +08:00
sessionStorage.setItem('ORGID', record.orgId);
const res = await configStore.userResource({ data: record });
2024-06-14 18:27:07 +08:00
useAuthorization.updateUserResource(res.data);
2024-06-17 13:48:27 +08:00
2024-06-11 13:37:10 +08:00
// value.value = cur;
2024-05-23 17:49:25 +08:00
},
2024-06-11 13:37:10 +08:00
resultField: 'data.linkList',
labelField: 'orgName',
valueField: 'orgId',
immediate: true,
dropdownReload: true,
2024-05-23 17:49:25 +08:00
},
},
2024-05-21 16:42:16 +08:00
timeout: 60 * 1000,
2024-06-14 11:49:51 +08:00
userLoginApi: (params) => {
return http.post('/carbon-smart/user/login', { ...params });
},
2024-06-14 18:27:07 +08:00
userResourceApi: (params) => {
2024-06-17 13:48:27 +08:00
const { orgId } = get(params, 'data') || { orgId: '' };
const finalId = orgId || ORGID;
// 解决初始化登录select无初始值的问题
selectDefaultValue.value = finalId;
2024-06-14 18:27:07 +08:00
2024-07-11 15:53:41 +08:00
const userInfo = JSON.parse(sessionStorage.getItem(import.meta.env.VITE_PUBLIC_PATH)!);
2024-06-17 13:48:27 +08:00
const ownOrgInfo = userInfo.linkList?.filter(({ orgId: id }) => id === finalId)[0];
return http.post('/carbon-smart/user/login/logInPermission', ownOrgInfo).then((res) => {
return res;
});
2024-05-21 16:42:16 +08:00
},
userInfoApi: () => {
2024-05-28 14:48:37 +08:00
return http.post('/carbon-smart/user/login/logInInfo').then((res) => {
const info = res.data;
const trD = transform(info, {
accountCode: 'userId',
2024-06-14 18:27:07 +08:00
accountName: 'accountNo',
accountRealName: 'accountNo',
2024-05-28 18:00:25 +08:00
orgId: 'orgId',
2024-06-04 10:54:02 +08:00
orgName: 'orgName',
projectId: 'projectId',
2024-06-11 13:37:10 +08:00
linkList: 'linkList',
2024-06-14 11:49:51 +08:00
permissionVos: 'permissionVos',
2024-05-28 14:48:37 +08:00
});
2024-06-17 13:48:27 +08:00
sessionStorage.setItem('ORGID', info.orgId);
2024-07-03 17:58:39 +08:00
selectDefaultValue.value = info.orgId;
2024-05-28 14:48:37 +08:00
return { data: { ...trD } };
});
2024-05-21 16:42:16 +08:00
},
2024-05-28 14:48:37 +08:00
2024-05-21 16:42:16 +08:00
useHistoryTag: false,
// 修改密码配置
updatePassWordInfo: {
title: '修改密码',
2024-05-22 14:36:37 +08:00
subtitle: 'huaxing平台',
2024-07-15 15:53:54 +08:00
api: '/carbon-smart/api/user/password',
2024-05-21 16:42:16 +08:00
},
// headerBellInfo: {
// isShow: true,
// api: '/api/web/objs/bulletin/readCount',
// toRouterName: 'NoticeManageIndex',
// },
resourceInfo: {
2024-06-04 11:40:32 +08:00
api: permission.add,
2024-05-21 16:42:16 +08:00
},
};