|
@ -5,12 +5,17 @@ import { authorizationService } from '/nerv-base/store/modules/authorization-ser |
|
|
import { get } from 'lodash-es'; |
|
|
import { get } from 'lodash-es'; |
|
|
import { computed, ref, toRef} from 'vue'; |
|
|
import { computed, ref, toRef} from 'vue'; |
|
|
|
|
|
|
|
|
const ORGID = sessionStorage.getItem('ORGID') ? Number(sessionStorage.getItem('ORGID')) : ''; |
|
|
import { router } from '/nerv-lib/saas/router'; |
|
|
const isAdmin = sessionStorage.getItem('ISADMIN') |
|
|
import { replyRoutesButton } from '/@/util/dynamicRoutes'; |
|
|
? Boolean(sessionStorage.getItem('ISADMIN')) |
|
|
import { replyDynamRoutesPath } from '/nerv-lib/util/dynamicRoutesss'; |
|
|
: false; |
|
|
import { useTags } from '/nerv-base/store/modules/tags'; |
|
|
const selectDefaultValue = ref(ORGID); |
|
|
|
|
|
const selectDefaultDisabled = ref(isAdmin); |
|
|
const ROLEID = sessionStorage.getItem('ROLEID') ? Number(sessionStorage.getItem('ROLEID')) : ''; |
|
|
|
|
|
// const isAdmin = sessionStorage.getItem('ISADMIN')
|
|
|
|
|
|
// ? Boolean(sessionStorage.getItem('ISADMIN'))
|
|
|
|
|
|
// : false;
|
|
|
|
|
|
const selectDefaultValue = ref(ROLEID); |
|
|
|
|
|
// const selectDefaultDisabled = ref(isAdmin);
|
|
|
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]]; |
|
@ -46,22 +51,25 @@ export const appConfig = { |
|
|
api: '/carbon-smart/user/login/logInInfo', |
|
|
api: '/carbon-smart/user/login/logInInfo', |
|
|
size: 'large', |
|
|
size: 'large', |
|
|
defaultValue: selectDefaultValue, |
|
|
defaultValue: selectDefaultValue, |
|
|
disabled: selectDefaultDisabled, |
|
|
disabled:false, |
|
|
|
|
|
// disabled: selectDefaultDisabled,
|
|
|
// autoSelectFirst: true,
|
|
|
// autoSelectFirst: true,
|
|
|
placeholder: '请选择', |
|
|
placeholder: '请选择', |
|
|
onSelect: async (cur, record) => { |
|
|
onSelect: async (cur:any, record:any) => { |
|
|
console.log(cur, record); |
|
|
|
|
|
const configStore = appConfigStore(); |
|
|
const configStore = appConfigStore(); |
|
|
const useAuthorization = authorizationService(); |
|
|
const useAuthorization = authorizationService(); |
|
|
sessionStorage.setItem('ORGID', record.orgId); |
|
|
sessionStorage.setItem('ORGID', record.orgId); |
|
|
|
|
|
sessionStorage.setItem('ROLEID', record.roleId); |
|
|
const res = await configStore.userResource({ data: record }); |
|
|
const res = await configStore.userResource({ data: record }); |
|
|
useAuthorization.updateUserResource(res.data); |
|
|
useAuthorization.updateUserResource(res.data); |
|
|
|
|
|
setTimeout(() => { |
|
|
window.location.reload(); |
|
|
window.location.reload(); |
|
|
|
|
|
}, 200); |
|
|
// value.value = cur;
|
|
|
// value.value = cur;
|
|
|
}, |
|
|
}, |
|
|
resultField: 'data.linkList', |
|
|
resultField: 'data.userRoles', |
|
|
labelField: 'orgName', |
|
|
labelField: 'orgName', |
|
|
valueField: 'orgId', |
|
|
valueField: 'roleId', |
|
|
immediate: true, |
|
|
immediate: true, |
|
|
dropdownReload: true, |
|
|
dropdownReload: true, |
|
|
}, |
|
|
}, |
|
@ -71,15 +79,33 @@ export const appConfig = { |
|
|
return http.post('/carbon-smart/user/login', { ...params }); |
|
|
return http.post('/carbon-smart/user/login', { ...params }); |
|
|
}, |
|
|
}, |
|
|
userResourceApi: (params) => { |
|
|
userResourceApi: (params) => { |
|
|
const { orgId } = get(params, 'data') || { orgId: '' }; |
|
|
const { roleId } = get(params, 'data') || { roleId: '' }; |
|
|
const finalId = orgId || ORGID; |
|
|
const finalId = roleId || ROLEID; |
|
|
// 解决初始化登录select无初始值的问题
|
|
|
// 解决初始化登录select无初始值的问题
|
|
|
selectDefaultValue.value = finalId; |
|
|
selectDefaultValue.value = finalId; |
|
|
|
|
|
|
|
|
const userInfo = JSON.parse(sessionStorage.getItem(import.meta.env.VITE_PUBLIC_PATH)!); |
|
|
// const userInfo = JSON.parse(sessionStorage.getItem(import.meta.env.VITE_PUBLIC_PATH)!);
|
|
|
const ownOrgInfo = userInfo.linkList?.filter(({ orgId: id }) => id === finalId)[0]; |
|
|
// const ownOrgInfo = userInfo.userRoles?.filter(({ roleId: id }) => id === finalId)[0];
|
|
|
|
|
|
// return http.post('/carbon-smart/user/login/logInPermission', ownOrgInfo).then((res) => {
|
|
|
return http.post('/carbon-smart/user/login/logInPermission', ownOrgInfo).then((res) => { |
|
|
// return res;
|
|
|
|
|
|
// });
|
|
|
|
|
|
// 切换角色时获取新的权限菜单
|
|
|
|
|
|
return http.post('/carbon-smart/user/login/role/permission/'+finalId).then((res) => { |
|
|
|
|
|
//切换后重新处理动态菜单数据
|
|
|
|
|
|
let resetDynamicRouteList = replyRoutesButton(res.data); |
|
|
|
|
|
sessionStorage.setItem("dynamicRouteList",JSON.stringify(resetDynamicRouteList)); |
|
|
|
|
|
if(resetDynamicRouteList && resetDynamicRouteList.length>0){ |
|
|
|
|
|
let addDynamicRoutes = replyDynamRoutesPath(resetDynamicRouteList); |
|
|
|
|
|
addDynamicRoutes.forEach(item => { |
|
|
|
|
|
if (item.children && !item.component) { |
|
|
|
|
|
item.component = () => import('/nerv-lib/saas/view/system/application.vue');//hx-ai-intelligent项目下的首页
|
|
|
|
|
|
} |
|
|
|
|
|
router.addRoute(item); |
|
|
|
|
|
}) |
|
|
|
|
|
} |
|
|
|
|
|
//删除所有已经打开的tag标签
|
|
|
|
|
|
useTags().clearTags(); |
|
|
|
|
|
router.replace({ name: 'home' }); |
|
|
return res; |
|
|
return res; |
|
|
}); |
|
|
}); |
|
|
}, |
|
|
}, |
|
@ -96,16 +122,25 @@ export const appConfig = { |
|
|
linkList: 'linkList', |
|
|
linkList: 'linkList', |
|
|
permissionVos: 'permissionVos', |
|
|
permissionVos: 'permissionVos', |
|
|
adminFlag: 'adminFlag', |
|
|
adminFlag: 'adminFlag', |
|
|
|
|
|
userRoles:'userRoles', |
|
|
}); |
|
|
}); |
|
|
sessionStorage.setItem('ORGID', info.orgId); |
|
|
sessionStorage.setItem('ORGID', info.orgId); |
|
|
sessionStorage.setItem('LINKLIST', JSON.stringify(info.linkList)); |
|
|
sessionStorage.setItem('LINKLIST', JSON.stringify(info.linkList)); |
|
|
sessionStorage.setItem('ISADMIN', trD?.adminFlag === '1'); |
|
|
// 头部“企业角色”切换暂不需要以下屏蔽的两个参数
|
|
|
selectDefaultDisabled.value = info?.adminFlag === '1'; |
|
|
// sessionStorage.setItem('ISADMIN', trD?.adminFlag === '1');
|
|
|
selectDefaultValue.value = info.orgId; |
|
|
// selectDefaultDisabled.value = info?.adminFlag === '1';
|
|
|
|
|
|
if(info.userRoles && info.userRoles.length>0){ |
|
|
|
|
|
sessionStorage.setItem('ROLEID', info.userRoles[0].roleId); |
|
|
|
|
|
sessionStorage.setItem('USERROLES', JSON.stringify(info.userRoles)); |
|
|
|
|
|
selectDefaultValue.value = info.userRoles[0].roleId; |
|
|
|
|
|
//路由接口数据暂时组装
|
|
|
|
|
|
let getRoutesList = replyRoutesButton(info.userRoles[0].routes); |
|
|
|
|
|
sessionStorage.setItem("dynamicRouteList",JSON.stringify(getRoutesList)) |
|
|
|
|
|
sessionStorage.setItem("isRefrech",'1') |
|
|
|
|
|
} |
|
|
return { data: { ...trD } }; |
|
|
return { data: { ...trD } }; |
|
|
}); |
|
|
}); |
|
|
}, |
|
|
}, |
|
|
|
|
|
|
|
|
useHistoryTag: false, |
|
|
useHistoryTag: false, |
|
|
// 修改密码配置
|
|
|
// 修改密码配置
|
|
|
updatePassWordInfo: { |
|
|
updatePassWordInfo: { |
|
|