Compare commits

...

6 Commits

  1. 85
      hx-ai-intelligent/src/config/app.config.ts
  2. 44
      hx-ai-intelligent/src/router/dynamicRoute.ts
  3. 98
      hx-ai-intelligent/src/util/dynamicRoutes.ts
  4. 94
      hx-op/src/view/organizationManage/enterpriseManage/index.vue
  5. 12
      hx-op/src/view/systemManage/systemMenu/editSystemMenu.vue
  6. 2
      lib/paas/store/index.ts
  7. 2
      lib/saas/store/modules/route.ts
  8. 22
      lib/saas/view/system/layout/tags.vue
  9. 15
      lib/saas/view/system/login.vue
  10. 25
      lib/util/dynamicRoutesss.ts
  11. 1
      package.json

85
hx-ai-intelligent/src/config/app.config.ts

@ -3,14 +3,19 @@ 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 { 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);
window.location.reload(); setTimeout(() => {
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';
return { data: { ...trD } }; 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 } };
});
}, },
useHistoryTag: false, useHistoryTag: false,
// 修改密码配置 // 修改密码配置
updatePassWordInfo: { updatePassWordInfo: {

44
hx-ai-intelligent/src/router/dynamicRoute.ts

@ -0,0 +1,44 @@
const sessionStoreRoute = sessionStorage.getItem("dynamicRouteList");
let getDynamicRouteList = sessionStoreRoute?JSON.parse(sessionStoreRoute):[];
let dynamicRoute:any = [];
// getDynamicRouteList.map(itemRouter => {
// if(itemRouter.children && itemRouter.children.length > 0){
// itemRouter.children.map(childRoute => {
// let modulePath0 = childRoute.component;
// childRoute.component = () => new Function(`return import('/nerv-lib/saas/view/${modulePath0}')`)();///nerv-lib/saas/view/
// if(childRoute.children && childRoute.children.length > 0){
// childRoute.children.map(child2=>{
// let modulePath = child2.component;
// child2.component = () => new Function(`return import('/@/view/${modulePath}')`)();///@/view/
// })
// }else{//如没有下一级菜单代表是一级,重新处理一级菜单路由
// childRoute.component = () => new Function(`return import('/@/view/${modulePath0}')`)();
// }
// })
// }
// dynamicRoute.push(itemRouter)
// })
getDynamicRouteList.forEach(itemRouter => {
if (itemRouter.children && itemRouter.children.length > 0) {
itemRouter.children.forEach(childRoute => {
const modulePath0 = childRoute.component;
// 修改 component 属性
// childRoute.component = () => import(`/nerv-lib/saas/view/${modulePath0}`).then(mod => mod.default);
childRoute.component = () => new Function(`return import('/nerv-lib/saas/view/${modulePath0}')`)();
if (childRoute.children && childRoute.children.length > 0) {
childRoute.children.forEach(child2 => {
const modulePath = child2.component;
// 修改 component 属性
// child2.component = /* @vite-ignore */ () => import(`/@/view/${modulePath}`).then(mod => mod.default);
child2.component = () => new Function(`return import('/@/view/${modulePath}')`)();
});
} else { // 如果没有下一级菜单代表是一级,重新处理一级菜单路由
// childRoute.component = /* @vite-ignore */ () => import(`/@/view/${modulePath0}`).then(mod => mod.default);
childRoute.component = () => new Function(`return import('/@/view/${modulePath0}')`)();
}
});
}
dynamicRoute.push(itemRouter);
});
export default dynamicRoute;

98
hx-ai-intelligent/src/util/dynamicRoutes.ts

@ -0,0 +1,98 @@
/***公共方法==>处理动态路由数据 将“按钮”部分的数据追加到meta中*/
//处理路由按钮,存放在meta中
export const replyRoutesButton = (data:any) => {
if(!data) return;
return data.map(item => {
if(item.children && item.children.length > 0){
item.meta.operates = [];
item.children.map(itemChild => {
if(itemChild.type=="3"){
let operateObj = {title:'',code:''};
operateObj.title = itemChild.meta.title;
operateObj.code = itemChild.name;
item.meta.operates.push(operateObj);
item.children = item.children.filter(its => its.name != itemChild.name);
}
})
if(item.meta.operates.length == 0){
delete item.meta.operates;
}
return {
...item,
children: replyRoutesButton(item.children),
};
}
return item;
});
};
// //处理路由compontent路径
// export const replyRoutesPath = (itemRouter:any) => {
// if (itemRouter.children && itemRouter.children.length > 0) {
// itemRouter.children.forEach(childRoute => {
// const modulePath0 = childRoute.component;
// // 修改 component 属性
// // childRoute.component = () => import(`/nerv-lib/saas/view/${modulePath0}`).then(mod => mod.default);
// childRoute.component = () => new Function(`return import('/nerv-lib/saas/view/${modulePath0}')`)();
// if (childRoute.children && childRoute.children.length > 0) {
// childRoute.children.forEach(child2 => {
// const modulePath = child2.component;
// // 修改 component 属性
// // child2.component = /* @vite-ignore */ () => import(`/@/view/${modulePath}`).then(mod => mod.default);
// child2.component = () => new Function(`return import('/@/view/${modulePath}')`)();
// });
// } else { // 如果没有下一级菜单代表是一级,重新处理一级菜单路由
// // childRoute.component = /* @vite-ignore */ () => import(`/@/view/${modulePath0}`).then(mod => mod.default);
// childRoute.component = () => new Function(`return import('/@/view/${modulePath0}')`)();
// }
// });
// }
// return itemRouter;
// }

94
hx-op/src/view/organizationManage/enterpriseManage/index.vue

@ -32,7 +32,7 @@
v-model:value="searchValue" v-model:value="searchValue"
style="margin-bottom: 8px" style="margin-bottom: 8px"
@search="onSearch" /> --> @search="onSearch" /> -->
<a-tree v-if="treeData?.length" v-model:checkedKeys="checkedKeys" v-bind="serverTree" /> <a-tree v-if="treeData?.length" v-model:checkedKeys="checkedKeys" v-bind="serverTree"/>
</ns-drawer> </ns-drawer>
<TreeAdd ref="treeAdd" @ok="handleOk" :info="currentBoundaryRecord" /> <TreeAdd ref="treeAdd" @ok="handleOk" :info="currentBoundaryRecord" />
@ -50,6 +50,7 @@
// import { mockData, treeData } from './mock'; // import { mockData, treeData } from './mock';
import { enterPrise } from '/@/api/origanizemanage'; import { enterPrise } from '/@/api/origanizemanage';
import { tableConfig as insertConfig } from './config'; import { tableConfig as insertConfig } from './config';
import { string } from 'vue-types';
defineOptions({ defineOptions({
name: 'EnterpriseManageIndex', name: 'EnterpriseManageIndex',
}); });
@ -82,7 +83,6 @@
const comApi = computed(() => { const comApi = computed(() => {
return calMap[opType.value as keyof typeof calMap]; return calMap[opType.value as keyof typeof calMap];
}); });
// tablereloaddrawerclose // tablereloaddrawerclose
const fetch = (params, isReload = true) => { const fetch = (params, isReload = true) => {
http.post(comApi.value, params).then(() => { http.post(comApi.value, params).then(() => {
@ -152,14 +152,20 @@
}); });
}; };
// // checkedKeys
const serverOK = () => { const serverOK = () => {
const params = { let getPermissionSelected = totalCheckedKeys.value;
orgId: currentServerRecord.value?.orgId, if(getPermissionSelected.length==0){
orgName: currentServerRecord.value?.orgName, NsMessage.success('请选择相应的权限菜单分配!');
permissionVoList: totalCheckedKeys.value, return false;
}; }else{
fetch(params, false); const params = {
orgId: currentServerRecord.value?.orgId,
orgName: currentServerRecord.value?.orgName,
permissionVoList: getPermissionSelected,
};
fetch(params, false);
}
}; };
const ServiceSelect = (selectedKeys: any, info: any) => { const ServiceSelect = (selectedKeys: any, info: any) => {
@ -197,10 +203,61 @@
// //
const getTree = (params) => { const getTree = (params) => {
return http.post(enterPrise.permissionTree, params).then((res) => { return http.post(enterPrise.permissionTree, params).then((res) => {
treeData.value = res.data?.data; // treeData.value = res.data?.data;
let dataTreeList = res.data?.data;
let getDataTreeList = dataTreeListReply(dataTreeList)
treeData.value = filterTreeData(getDataTreeList);
}); });
}; };
getTree({}); // hidden"
const dataTreeListReply =(data:any)=>{
return data.map(item => {
if (item.menus && item.menus.length > 0) {
return {
...item,
menus: dataTreeListReply(item.menus),
};
}
if (item.menus && item.menus.length == 0) {
item.hidden = true;
}
return item;
});
}
//menus
const filterTreeData = (data:any) => {
return data.map(item => {
//menus
if (item.menus && item.menus.length > 0) {
item.menus.map(itemchild=>{
if(itemchild.menus && itemchild.menus.length==0){
item.class = 'parentNodeArrowHide';
}
})
return {
...item,
menus: filterTreeData(item.menus),
};
}else{
if(item.hidden){
item.class = 'leafNodeHide';
}
}
return item;
})
//hidden
// return data.filter(item => !item.hidden).map(item => {
// if (item.menus) {
// return {
// ...item,
// menus: filterTreeData(item.menus),
// };
// }
// return item;
// });
}
getTree({})
// //
const getPermissionData = (params) => { const getPermissionData = (params) => {
@ -210,6 +267,13 @@
.map((item) => { .map((item) => {
return item.permissionId; return item.permissionId;
}); });
const finalResult = res.data.map((items) => {
return {
halfCheck: items.halfCheck,
permissionId: items.permissionId,
};
})
totalCheckedKeys.value = finalResult;
}); });
}; };
@ -354,3 +418,11 @@
} }
} }
</style> </style>
<style>
.leafNodeHide{
display:none!important;
}
.parentNodeArrowHide .ant-tree-switcher{
visibility: hidden;
}
</style>

12
hx-op/src/view/systemManage/systemMenu/editSystemMenu.vue

@ -106,7 +106,7 @@
const componentIsshow = ref(false);// const componentIsshow = ref(false);//
const redirectIsshow = ref(true);// const redirectIsshow = ref(true);//
const keepAliveIsshow = ref(false);// const keepAliveIsshow = ref(false);//
const hideChildrenIsshow = ref(false);// const hideChildrenIsshow = ref(true);//
interface FormState { interface FormState {
menuName: string; menuName: string;
previousMenu:string; previousMenu:string;
@ -164,7 +164,6 @@
}; };
// //
const chanageMenuType = (e:any,typeMenu:any)=>{ const chanageMenuType = (e:any,typeMenu:any)=>{
console.log(e)
let currentType = null; let currentType = null;
if(e && e.target){ if(e && e.target){
currentType = e.target.value; currentType = e.target.value;
@ -184,7 +183,7 @@
componentIsshow.value = false; componentIsshow.value = false;
redirectIsshow.value = true; redirectIsshow.value = true;
keepAliveIsshow.value = false; keepAliveIsshow.value = false;
hideChildrenIsshow.value = false; hideChildrenIsshow.value = true;
}else if(currentType==2){// }else if(currentType==2){//
menuNameIsshow.value = true; menuNameIsshow.value = true;
preMenuIsshow.value = true; preMenuIsshow.value = true;
@ -245,9 +244,8 @@
} }
if(menuRadioType.value==1){ if(menuRadioType.value==1){
params.pid = currentLineData.value?currentLineData.value.pid:"root";//pid,'root' params.pid = currentLineData.value?currentLineData.value.pid:"root";//pid,'root'
params.hideChildren = formState.value.hideChildren;//
} }
console.log("1234567777")
console.log(menuRadioType.value)
if(addOrEditType.value==1){// if(addOrEditType.value==1){//
http.post(menuS.queryMenuPageAdd, params).then(() => { http.post(menuS.queryMenuPageAdd, params).then(() => {
NsMessage.success('操作成功'); NsMessage.success('操作成功');
@ -315,7 +313,9 @@
menuCode:'', menuCode:'',
type:'', type:'',
menuJumpUrl:'', menuJumpUrl:'',
menuRedirect:'' menuRedirect:'',
keepAlive:false,
hideChildren:false
}; };
}else if(type==2){// }else if(type==2){//
drawerTitele.value = '编辑菜单'; drawerTitele.value = '编辑菜单';

2
lib/paas/store/index.ts

@ -1,6 +1,8 @@
import type { App } from 'vue'; import type { App } from 'vue';
import { createPinia } from 'pinia'; import { createPinia } from 'pinia';
const store = createPinia(); const store = createPinia();
// import piniaPluginPersistedstate from 'pinia-plugin-persistedstate'
// store.use(piniaPluginPersistedstate)
export function setupStore(app: App<Element>) { export function setupStore(app: App<Element>) {
app.use(store); app.use(store);

2
lib/saas/store/modules/route.ts

@ -135,4 +135,6 @@ export const useRouteStore = defineStore({
}); });
}, },
}, },
// //开启数据缓存
// persist:true,
}); });

22
lib/saas/view/system/layout/tags.vue

@ -266,18 +266,18 @@
resizeButtom() { resizeButtom() {
this.$nextTick(() => { this.$nextTick(() => {
if (this.$refs.tags !== undefined) { if (this.$refs.tags !== undefined) {
const clientWidth = (this.$refs.tags as HTMLElement).clientWidth; const clientWidth = (this.$refs.tags as HTMLElement).clientWidth;
if (this.currentPage === 0) { if (this.currentPage === 0) {
this.isdisabledl = this.tagList.length * 100 > clientWidth; this.isdisabledl = this.tagList.length * 100 > clientWidth;
} else { } else {
this.isdisabledl = this.isdisabledl =
(this.tagList.length - this.number * this.currentPage) * 100 > clientWidth; (this.tagList.length - this.number * this.currentPage) * 100 > clientWidth;
if (this.tagList.length * 100 < clientWidth) { if (this.tagList.length * 100 < clientWidth) {
(this.$refs.tags as HTMLElement).style.cssText = `transform: translateX(${0}px)`; (this.$refs.tags as HTMLElement).style.cssText = `transform: translateX(${0}px)`;
this.isdisabledr = false; this.isdisabledr = false;
this.currentPage = 0; this.currentPage = 0;
}
} }
}
} }
}); });
}, },

15
lib/saas/view/system/login.vue

@ -79,6 +79,7 @@
import { Cookies } from '/nerv-lib/util/cookie'; import { Cookies } from '/nerv-lib/util/cookie';
import { storeToRefs } from 'pinia'; import { storeToRefs } from 'pinia';
import { NsMessage } from '/nerv-lib/component'; import { NsMessage } from '/nerv-lib/component';
import { replyDynamRoutesPath } from '/nerv-lib/util/dynamicRoutesss';
export default defineComponent({ export default defineComponent({
name: 'UserLogin', name: 'UserLogin',
@ -194,12 +195,22 @@
name: initRouterList.length === 0 ? 'error403' : res.data[0]['code'], name: initRouterList.length === 0 ? 'error403' : res.data[0]['code'],
}); });
} else { } else {
router.replace({ name: 'root' }); const sessionStoreRoute = sessionStorage.getItem("dynamicRouteList");
let getDynamicRouteList = sessionStoreRoute?JSON.parse(sessionStoreRoute):[];
if(getDynamicRouteList && getDynamicRouteList.lenght>0){
let addDynamicRoutes = replyDynamRoutesPath(getDynamicRouteList);
addDynamicRoutes.forEach(item => {
if (item.children && !item.component) {
item.component = () => import('/nerv-lib/saas/view/system/application.vue');//hx-ai-intelligent
}
router.addRoute(item);
});
}
router.replace({ name: 'home' });
} }
} }
} catch (err) { } catch (err) {
console.log(err); console.log(err);
loading.value = false; loading.value = false;
} }
} }

25
lib/util/dynamicRoutesss.ts

@ -0,0 +1,25 @@
//处理路由compontent路径
export const replyDynamRoutesPath = (data:any) => {
return data.map(item => {
if(item.children && item.children.length > 0){
item.children.map(itemChild => {
if(itemChild.component){
const modulePath0 = itemChild.component;
itemChild.component = () => new Function(`return import('/nerv-lib/saas/view/${modulePath0}')`)();
if(itemChild.children && itemChild.children.length > 0){
itemChild.children.map(itemChildChild => {
if(itemChildChild.component){
const modulePath1 = itemChildChild.component;
itemChildChild.component = () => new Function(`return import('/@/view/${modulePath1}')`)();
}
})
}else{
itemChild.component = () => new Function(`return import('/@/view/${modulePath0}')`)();
}
}
})
}
return item;
})
}

1
package.json

@ -68,6 +68,7 @@
"nanoid": "^4.0.2", "nanoid": "^4.0.2",
"path-to-regexp": "^6.2.1", "path-to-regexp": "^6.2.1",
"pinia": "^2.0.14", "pinia": "^2.0.14",
"pinia-plugin-persistedstate": "^3.2.1",
"pnpm": "^8.7.6", "pnpm": "^8.7.6",
"qrcode.vue": "^3.3.3", "qrcode.vue": "^3.3.3",
"recorder-core": "^1.3.23122400", "recorder-core": "^1.3.23122400",

Loading…
Cancel
Save