Commit 0ba0aa19 authored by jiaxu.yan's avatar jiaxu.yan

feat: 权限修改

parent 7dcc08f6
......@@ -11,11 +11,11 @@ VITE_BUILD_COMPRESS = 'gzip'
# Basic interface address SPA
VITE_GLOB_API_URL = https://dev.unitj.cn
# VITE_GLOB_API_URL = https://dev.unitj.cn
VITE_GLOB_API_URL = http://172.72.253.25:8088/
# File upload address, optional
# It can be forwarded by nginx or write the actual address directly
VITE_GLOB_UPLOAD_URL = '/api/system/file/add'
VITE_GLOB_UPLOAD_URL = '/system/file/add'
# Interface prefix
......
import { defHttp } from '@/utils/http/axios';
enum Api {
GetList = '/eam/utils/getUserMenu',
}
export const getList = () => defHttp.get<any>({ url: Api.GetList });
......@@ -3,7 +3,7 @@
<LayoutFeatures />
<LayoutHeader fixed v-if="getShowFullHeaderRef" />
<Layout :class="[layoutClass, `${prefixCls}-out`]">
<LayoutSideBar v-if="(getShowSidebar || getIsMobile) && isDev" />
<LayoutSideBar v-if="getShowSidebar || getIsMobile" />
<Layout :class="`${prefixCls}-main`">
<LayoutMultipleHeader v-if="isDev" />
<LayoutContent />
......
......@@ -19,6 +19,42 @@ Object.keys(modules).forEach((key) => {
const modList = Array.isArray(mod) ? [...mod] : [mod];
menuModules.push(...modList);
});
// import { filter } from '@/utils/helper/treeHelper';
// import { getList } from '@/api/role';
// import.meta.glob() 直接引入所有的模块 Vite 独有的功能
// const routeModuleList: AppRouteModule[] = [];
// export const asyncRoutes = [PAGE_NOT_FOUND_ROUTE, ...routeModuleList];
// const menuModules: MenuModule[] = [];
// let roleList;
// if (localStorage.getItem('urlRoles')) {
// const str: any = localStorage.getItem('urlRoles');
// roleList = JSON.parse(str);
// } else {
// const res = await getList();
// roleList = res;
// localStorage.setItem('urlRoles', JSON.stringify(res));
// }
// const routeFilter = (route: any) => {
// const { meta } = route;
// // 抽出角色
// const { auth } = meta || {};
// if (!auth) return false;
// // 进行角色权限判断
// return roleList.some((role) => auth === role);
// };
// const modules = import.meta.glob('./modules/**/*.ts', { eager: true });
// Object.keys(modules).forEach((key) => {
// const mod = (modules as Recordable)[key].default || {};
// const modList = Array.isArray(mod) ? [...mod] : [mod];
// const anyRoute = filter(modList, routeFilter);
// if (anyRoute.length > 0) {
// menuModules.push(...anyRoute);
// }
// });
// console.log(menuModules);
// ===========================
// ==========Helper===========
......
......@@ -4,17 +4,38 @@ import { PAGE_NOT_FOUND_ROUTE, REDIRECT_ROUTE } from '@/router/routes/basic';
import { mainOutRoutes } from './mainOut';
import { PageEnum } from '@/enums/pageEnum';
import { t } from '@/hooks/web/useI18n';
import { log } from 'echarts/types/src/util/log.js';
import { filter } from '@/utils/helper/treeHelper';
import { getList } from '@/api/role';
// import.meta.glob() 直接引入所有的模块 Vite 独有的功能
const modules = import.meta.glob('./modules/**/*.ts', { eager: true });
const routeModuleList: AppRouteModule[] = [];
let roleList;
if (localStorage.getItem('urlRoles')) {
const str: any = localStorage.getItem('urlRoles');
roleList = JSON.parse(str);
} else {
const res = await getList();
roleList = res;
localStorage.setItem('urlRoles', JSON.stringify(res));
}
const routeFilter = (route: any) => {
const { meta } = route;
// 抽出角色
const { auth } = meta || {};
if (!auth) return false;
// 进行角色权限判断
return roleList.some((role) => auth === role);
};
// 加入到路由集合中
Object.keys(modules).forEach((key) => {
const mod = (modules as Recordable)[key].default || {};
const modList = Array.isArray(mod) ? [...mod] : [mod];
routeModuleList.push(...modList);
const anyRoute = filter(modList, routeFilter);
if (anyRoute.length > 0) {
routeModuleList.push(...anyRoute);
}
});
export const asyncRoutes = [PAGE_NOT_FOUND_ROUTE, ...routeModuleList];
......@@ -38,20 +59,9 @@ export const LoginRoute: AppRouteRecordRaw = {
},
};
const menuModules: MenuModule[] = [];
Object.keys(modules).forEach((key) => {
const modules = import.meta.glob('../routes/modules/**/*.ts', { eager: true });
const mod = (modules as Recordable)[key].default || {};
const modList = Array.isArray(mod) ? [...mod] : [mod];
menuModules.push(...modList);
});
// Basic routing without permission
// 未经许可的基本路由
export const basicRoutes = [
menuModules,
LoginRoute,
RootRoute,
...mainOutRoutes,
......
......@@ -11,6 +11,7 @@ const annualPlan: AppRouteModule = {
hideChildrenInMenu: true,
icon: 'icon-park-outline:align-text-left-one',
orderNo: 10,
auth: '/www/dist/index.html#/annualPlan/index',
title: '年度工程资金计划',
},
children: [
......@@ -19,7 +20,7 @@ const annualPlan: AppRouteModule = {
name: 'annualPlan',
component: () => import('@/views/annualPlan/index.vue'),
meta: {
// affix: true,
auth: '/www/dist/index.html#/annualPlan/index',
title: '年度工程资金计划',
orderNo: 10,
},
......@@ -29,7 +30,7 @@ const annualPlan: AppRouteModule = {
name: 'annualPlanEdit',
component: () => import('@/views/annualPlan/annualPlanEdit/annualPlanEdit.vue'),
meta: {
// affix: true,
auth: '/www/dist/index.html#/annualPlan/index',
title: '新建计划(储备)',
orderNo: 8,
},
......
......@@ -11,6 +11,7 @@ const biddingManagement: AppRouteModule = {
hideChildrenInMenu: true,
icon: 'tdesign:map-aiming',
orderNo: 3,
auth: '/www/dist/index.html#/biddingManagement/index',
title: '招标管理',
},
children: [
......@@ -19,7 +20,7 @@ const biddingManagement: AppRouteModule = {
name: 'biddingManagement',
component: () => import('@/views/biddingManagement/index.vue'),
meta: {
// affix: true,
auth: '/www/dist/index.html#/biddingManagement/index',
title: '招标管理',
orderNo: 3,
},
......@@ -29,7 +30,7 @@ const biddingManagement: AppRouteModule = {
name: 'biddingManagementEdit',
component: () => import('@/views/biddingManagement/biddingManagementEdit.vue'),
meta: {
// affix: true,
auth: '/www/dist/index.html#/biddingManagement/index',
title: '招标管理',
orderNo: 3,
},
......
......@@ -11,6 +11,7 @@ const biddingPlan: AppRouteModule = {
hideChildrenInMenu: true,
icon: 'mingcute:aiming-2-line',
orderNo: 2,
auth: '/www/dist/index.html#/biddingPlan/index',
title: '招标计划',
},
children: [
......@@ -19,7 +20,7 @@ const biddingPlan: AppRouteModule = {
name: 'plan',
component: () => import('@/views/biddingPlan/index.vue'),
meta: {
// affix: true,
auth: '/www/dist/index.html#/biddingPlan/index',
title: '招标计划',
orderNo: 2,
},
......@@ -29,7 +30,7 @@ const biddingPlan: AppRouteModule = {
name: 'planEdit',
component: () => import('@/views/biddingPlan/biddingPlanEdit.vue'),
meta: {
// affix: true,
auth: '/www/dist/index.html#/biddingPlan/index',
title: '招标计划',
orderNo: 2,
},
......
......@@ -11,6 +11,7 @@ const changeSignature: AppRouteModule = {
hideChildrenInMenu: true,
icon: 'icon-park-outline:align-text-left-one',
orderNo: 5,
auth: '/www/dist/index.html#/changeSignature/index',
title: '变更签证管理',
},
children: [
......@@ -19,7 +20,7 @@ const changeSignature: AppRouteModule = {
name: 'changeSignature',
component: () => import('@/views/changeSignature/index.vue'),
meta: {
// affix: true,
auth: '/www/dist/index.html#/changeSignature/index',
title: '变更签证管理',
orderNo: 5,
},
......@@ -29,7 +30,7 @@ const changeSignature: AppRouteModule = {
name: 'addChangeSignature',
component: () => import('@/views/changeSignature/addChangeSignature.vue'),
meta: {
// affix: true,
auth: '/www/dist/index.html#/changeSignature/index',
title: '新建变更管理',
orderNo: 8,
},
......
......@@ -11,6 +11,7 @@ const completed: AppRouteModule = {
hideChildrenInMenu: true,
icon: 'icon-park-outline:align-text-left-one',
orderNo: 12,
auth: '/www/dist/index.html#/completed/index',
title: '已竣工验收项目陈欠资金计划',
},
children: [
......@@ -19,7 +20,7 @@ const completed: AppRouteModule = {
name: 'completed',
component: () => import('@/views/completed/index.vue'),
meta: {
// affix: true,
auth: '/www/dist/index.html#/completed/index',
title: '已竣工验收项目陈欠资金计划',
orderNo: 12,
},
......@@ -29,7 +30,7 @@ const completed: AppRouteModule = {
name: 'completedEdit',
component: () => import('@/views/completed//completedEdit/completedEdit.vue'),
meta: {
// affix: true,
auth: '/www/dist/index.html#/completed/index',
title: '新建已竣工验收项目陈欠资金计划',
orderNo: 12,
},
......
......@@ -11,6 +11,7 @@ const dashboard: AppRouteModule = {
hideChildrenInMenu: true,
icon: 'ion:home-outline',
orderNo: 0,
auth: 'www/dist/index.html#/dashboard/index',
title: '门户页',
},
children: [
......@@ -20,6 +21,7 @@ const dashboard: AppRouteModule = {
component: () => import('@/views/dashboard/analysis/index.vue'),
meta: {
affix: true,
auth: 'www/dist/index.html#/dashboard/index',
title: '门户页',
orderNo: 0,
},
......
......@@ -2,7 +2,7 @@ import type { AppRouteModule } from '@/router/types';
import { LAYOUT } from '@/router/constant';
const engineeringProject: { redirect: string; path: string; component: () => Promise<{}>; children: ({ path: string; component: () => Promise<{}>; meta: { orderNo: number; title: string }; name: string } | { path: string; component: () => Promise<{}>; meta: { orderNo: number; title: string }; name: string } | { path: string; component: () => Promise<{}>; meta: { orderNo: number; title: string }; name: string })[]; meta: { orderNo: number; icon: string; hideChildrenInMenu: boolean; title: string }; name: string } = {
const engineeringProject: AppRouteModule = {
path: '/engineeringProject',
name: 'engineeringProject',
component: LAYOUT,
......@@ -11,6 +11,7 @@ const engineeringProject: { redirect: string; path: string; component: () => Pro
hideChildrenInMenu: true,
icon: 'icon-park-outline:align-text-left-one',
orderNo: 8,
auth: '/www/dist/index.html#/engineeringProject/index',
title: '工程项目投资计划',
},
children: [
......@@ -19,7 +20,7 @@ const engineeringProject: { redirect: string; path: string; component: () => Pro
name: 'engineeringProject',
component: () => import('@/views/engineeringProject/index.vue'),
meta: {
// affix: true,
auth: '/www/dist/index.html#/engineeringProject/index',
title: '工程项目投资计划',
orderNo: 8,
},
......@@ -29,7 +30,7 @@ const engineeringProject: { redirect: string; path: string; component: () => Pro
name: 'engineeringEdit',
component: () => import('@/views/engineeringProject/engineeringEdit/engineeringEdit.vue'),
meta: {
// affix: true,
auth: '/www/dist/index.html#/engineeringProject/index',
title: '新建计划(工程)',
orderNo: 8,
},
......@@ -39,7 +40,7 @@ const engineeringProject: { redirect: string; path: string; component: () => Pro
name: 'constructionEdit',
component: () => import('@/views/engineeringProject/constructionEdit/constructionEdit.vue'),
meta: {
// affix: true,
auth: '/www/dist/index.html#/engineeringProject/index',
title: '新建计划(承建)',
orderNo: 8,
},
......@@ -49,7 +50,7 @@ const engineeringProject: { redirect: string; path: string; component: () => Pro
name: 'reserveEdit',
component: () => import('@/views/engineeringProject/reserveEdit/reserveEdit.vue'),
meta: {
// affix: true,
auth: '/www/dist/index.html#/engineeringProject/index',
title: '新建计划(储备)',
orderNo: 8,
},
......
......@@ -2,19 +2,7 @@ import type { AppRouteModule } from '@/router/types';
import { LAYOUT } from '@/router/constant';
const monthlyPlan: {
redirect: string;
path: string;
component: () => Promise<{}>;
children: {
path: string;
component: () => Promise<{}>;
meta: { orderNo: number; title: string };
name: string;
}[];
meta: { orderNo: number; icon: string; hideChildrenInMenu: boolean; title: string };
name: string;
} = {
const monthlyPlan: AppRouteModule = {
path: '/monthlyPlan',
name: 'monthlyPlan',
component: LAYOUT,
......@@ -23,6 +11,7 @@ const monthlyPlan: {
hideChildrenInMenu: true,
icon: 'icon-park-outline:align-text-left-one',
orderNo: 11,
auth: '/www/dist/index.html#/monthlyPlan/index',
title: '月度工程资金计划',
},
children: [
......@@ -31,7 +20,7 @@ const monthlyPlan: {
name: 'monthlyPlan',
component: () => import('@/views/monthlyPlan/index.vue'),
meta: {
// affix: true,
auth: '/www/dist/index.html#/monthlyPlan/index',
title: '月度工程资金计划',
orderNo: 11,
},
......@@ -41,7 +30,7 @@ const monthlyPlan: {
name: 'monthlyPlanEdit',
component: () => import('@/views/monthlyPlan/monthlyPlanEdit/monthlyPlanEdit.vue'),
meta: {
// affix: true,
auth: '/www/dist/index.html#/monthlyPlan/index',
title: '月度工程资金计划',
orderNo: 8,
},
......
......@@ -11,6 +11,7 @@ const performance: AppRouteModule = {
hideChildrenInMenu: true,
icon: 'icon-park-outline:align-text-left-one',
orderNo: 9,
auth: '/www/dist/index.html#/performance/index',
title: '工程项目投资计划完成情况',
},
children: [
......@@ -19,7 +20,7 @@ const performance: AppRouteModule = {
name: 'performance',
component: () => import('@/views/performance/index.vue'),
meta: {
// affix: true,
auth: '/www/dist/index.html#/performance/index',
title: '工程项目投资计划完成情况',
orderNo: 9,
},
......@@ -29,7 +30,7 @@ const performance: AppRouteModule = {
name: 'performanceEdit',
component: () => import('@/views/performance/performanceEdit.vue'),
meta: {
// affix: true,
auth: '/www/dist/index.html#/performance/index',
title: '工程项目投资计划完成情况',
orderNo: 9,
},
......
......@@ -11,6 +11,7 @@ const potentialSafety: AppRouteModule = {
hideChildrenInMenu: true,
icon: 'icon-park-outline:align-text-left-one',
orderNo: 6,
auth: '/www/dist/index.html#/potentialSafety/index',
title: '安全隐患管理',
},
children: [
......@@ -19,7 +20,7 @@ const potentialSafety: AppRouteModule = {
name: 'potentialSafety',
component: () => import('@/views/potentialSafety/index.vue'),
meta: {
// affix: true,
auth: '/www/dist/index.html#/potentialSafety/index',
title: '安全隐患管理',
orderNo: 6,
},
......
......@@ -11,6 +11,7 @@ const dashboard: AppRouteModule = {
hideChildrenInMenu: true,
orderNo: 1,
icon: 'eos-icons:project-outlined',
auth: 'www/dist/index.html#/project/project',
title: '项目库',
},
children: [
......@@ -19,7 +20,7 @@ const dashboard: AppRouteModule = {
name: 'projectDetail',
component: () => import('@/views/project/detail.vue'),
meta: {
// affix: true,
auth: 'www/dist/index.html#/project/project',
ignoreKeepAlive: true,
title: '项目详情',
},
......@@ -31,7 +32,7 @@ const dashboard: AppRouteModule = {
meta: {
orderNo: 1,
ignoreKeepAlive: true,
// affix: true,
auth: 'www/dist/index.html#/project/project',
title: '项目库',
},
},
......
......@@ -11,6 +11,7 @@ const safetyEducation: AppRouteModule = {
hideChildrenInMenu: true,
icon: 'icon-park-outline:align-text-left-one',
orderNo: 7,
auth: '/www/dist/index.html#/safetyEducation/index',
title: '安全教育培训',
},
children: [
......@@ -19,7 +20,7 @@ const safetyEducation: AppRouteModule = {
name: 'safetyEducation',
component: () => import('@/views/safetyEducation/index.vue'),
meta: {
// affix: true,
auth: '/www/dist/index.html#/safetyEducation/index',
title: '安全教育培训',
orderNo: 7,
},
......
......@@ -11,6 +11,7 @@ const settlementManagement: AppRouteModule = {
hideChildrenInMenu: true,
icon: 'icon-park-outline:align-text-left-one',
orderNo: 4,
auth: '/www/dist/index.html#/settlementManagement/index',
title: '结算管理',
},
children: [
......@@ -19,6 +20,7 @@ const settlementManagement: AppRouteModule = {
name: 'settlementManagement',
component: () => import('@/views/settlementManagement/index.vue'),
meta: {
auth: '/www/dist/index.html#/settlementManagement/index',
// affix: true,
title: '结算管理',
orderNo: 4,
......@@ -29,6 +31,7 @@ const settlementManagement: AppRouteModule = {
name: 'settlementManageEdit',
component: () => import('@/views/settlementManagement/settlementManageEdit.vue'),
meta: {
auth: '/www/dist/index.html#/settlementManagement/index',
// affix: true,
title: '新建结算管理',
orderNo: 8,
......
import type { AppRouteModule } from '@/router/types';
import { LAYOUT } from '@/router/constant';
import { v } from 'vxe-table';
const statement: AppRouteModule = {
path: '/statement',
......@@ -13,6 +12,7 @@ const statement: AppRouteModule = {
icon: 'icon-park-outline:align-text-left-one',
orderNo: 13,
title: '报表中心',
auth: '/www/dist/index.html#/statement/index',
},
children: [
{
......@@ -20,6 +20,7 @@ const statement: AppRouteModule = {
name: 'statement',
component: () => import('@/views/statement/index.vue'),
meta: {
auth: '/www/dist/index.html#/statement/index',
// affix: true,
title: '报表中心',
orderNo: 13,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment