Sfoglia il codice sorgente

更新动态路由

zhengnaiwen_citu 4 mesi fa
parent
commit
ff58eaa6a8

+ 1 - 1
components.d.ts

@@ -33,8 +33,8 @@ declare module 'vue' {
     Echarts: typeof import('./src/components/Echarts/index.vue')['default']
     ElCascader: typeof import('element-plus/es')['ElCascader']
     ElConfigProvider: typeof import('element-plus/es')['ElConfigProvider']
-    ElTree: typeof import('element-plus/es')['ElTree']
     ElImage: typeof import('element-plus/es')['ElImage']
+    ElTree: typeof import('element-plus/es')['ElTree']
     Empty: typeof import('./src/components/Empty/index.vue')['default']
     File: typeof import('./src/components/Upload/file.vue')['default']
     HeadSearch: typeof import('./src/components/headSearch/index.vue')['default']

+ 10 - 0
src/api/recruit/enterprise/system/role/index.js

@@ -90,4 +90,14 @@ export const saveUserRole = async (data) => {
     url: '/app-api/menduner/system/recruit/permission/assign-user-role',
     data
   })
+}
+
+
+
+// 获取登录用户的权限信息
+export const getPermissionInfo = async (params) => {
+  return await request.get({
+    url: '/app-api/menduner/system/recruit/permission/get-permission-info',
+    params
+  })
 }

+ 27 - 24
src/layout/company/side.vue

@@ -45,51 +45,54 @@
 defineOptions({ name: 'enterprise-side'})
 import { computed } from 'vue'
 import { getCurrentLocaleLang } from '@/utils/lang.js'
-import enterpriseRoute from '@/router/modules/components/recruit/enterprise'
+// import enterpriseRoute from '@/router/modules/components/recruit/enterprise'
+import { useEnterpriseStore } from '@/store/enterprise'
+
+const enterpriseStore = useEnterpriseStore()
 
 const list = computed(() => {
-  return getList(enterpriseRoute)
+  return getList(enterpriseStore.enterpriseMenu)
 })
-console.log(import.meta.env.VITE_NODE_ENV, '当前环境变量============')
+// console.log(import.meta.env.VITE_NODE_ENV, '当前环境变量============')
 
-const info = localStorage.getItem('entBaseInfo') ? JSON.parse(localStorage.getItem('entBaseInfo')) : {}
+// const isAdmin = localStorage.getItem('isAdmin') === '1'
+// const info = localStorage.getItem('entBaseInfo') ? JSON.parse(localStorage.getItem('entBaseInfo')) : {}
 const getList = (arr, obj = []) => {
   // 是否为企业管理员
-  const isAdmin = localStorage.getItem('isAdmin')
-
   arr.forEach(element => {
-    if (element.show) return
+    if (!element.alwaysShow) return
     let data = {}
+    const path = element.path[0] === '/' ? element.path : '/' + element.path
     data = {
-      title: element?.meta?.title,
+      title: element.name,
       enName: element?.meta?.enName,
-      icon: element?.meta?.icon,
-      name: element?.name,
-      path: element?.path,
+      icon: element.icon,
+      name: element.name,
+      path,
       children: []
     }
-    if (element?.meta?.isAdmin) {
-      data.isAdmin = true
-    }
+    // if (element?.meta?.isAdmin) {
+    //   data.isAdmin = true
+    // }
     // 人才地图
-    if (element?.meta?.isPersonMap) data.isPersonMap = true
+    // if (element?.meta?.isPersonMap) data.isPersonMap = true
     // 全员猎寻
-    if (element?.meta?.hireJob) data.hireJob = true
+    // if (element?.meta?.hireJob) data.hireJob = true
     if (element?.children) {
       getList(element.children, data.children)
     }
     obj.push(data)
   })
-  if (isAdmin === 'false') {
-    obj = obj.filter(e => !e.isAdmin)
-    obj.map(e => {
-      e.children = e.children.filter(val => !val.isAdmin)
-    })
-  }
+  // if (!isAdmin) {
+  //   obj = obj.filter(e => !e.isAdmin)
+  //   obj.map(e => {
+  //     e.children = e.children.filter(val => !val.isAdmin)
+  //   })
+  // }
   // 人才地图是否可看
-  if (info && Object.keys(info).length && !info?.entitlement?.personMap) obj = obj.filter(e => !e.isPersonMap)
+  // if (info && Object.keys(info).length && !info?.entitlement?.personMap) obj = obj.filter(e => !e.isPersonMap)
   // 全员猎寻是否可看
-  if (info && Object.keys(info).length && !info?.entitlement?.hireJob) obj = obj.filter(e => !e.hireJob)
+  // if (info && Object.keys(info).length && !info?.entitlement?.hireJob) obj = obj.filter(e => !e.hireJob)
 
   // 生产环境隐藏门墩儿新任命
   if (import.meta.env.VITE_NODE_ENV === 'production') obj = obj.filter(e => e.path !== '/recruit/enterprise/newlyAppointed')

+ 40 - 9
src/permission.js

@@ -7,8 +7,12 @@ import { useUserStore } from '@/store/user'
 import Confirm from '@/plugins/confirm'
 import dialogExtend from '@/plugins/dialogExtend'
 import { useMallStore } from '@/store/mall'
+import { useEnterpriseStore } from '@/store/enterprise'
 
 const { start, done } = useNProgress()
+
+let isRefresh = true
+
 // loginType:1.enterprise: 企业路由
 //            2.personal: 个人路由
 //            3.common: 没有限制访问权限
@@ -17,6 +21,7 @@ const { start, done } = useNProgress()
 router.beforeEach(async (to, from, next) => {
   // 获取商城装修模版
   const mallStore = useMallStore()
+  const enterpriseStore = useEnterpriseStore()
   if (!localStorage.getItem('mallTemplate')) {
     await mallStore.getMallDiyTemplate()
   }
@@ -28,9 +33,34 @@ router.beforeEach(async (to, from, next) => {
   if (to.path === '/enterpriseVerification') {
     const res = JSON.parse(localStorage.getItem('emailLoginInfo') || "false")
     const obj = res ? { ...res, type: 'emailLogin' } : {}
+
+    // 清除路由表
+    enterpriseStore.clearEnterpriseMenu()
+    isRefresh = true
     useUserStore().changeRole(obj)
     next()
-  } else if (getToken(tokenIndex)) {
+    return
+  }
+  if (getToken(tokenIndex)) {
+    if (!enterpriseStore.enterpriseMenu || !enterpriseStore.enterpriseMenu.length ) {
+      const { menus } = await enterpriseStore.getEnterpriseMenu()
+      enterpriseStore.saveEnterpriseMenu(menus)
+    }
+    if (isRefresh) {
+      try {
+        isRefresh = false
+        const routes = enterpriseStore.assignEnterpriseMenu(enterpriseStore.enterpriseMenu)
+        console.log(routes)
+        routes.forEach(route => {
+          router.addRoute(route)
+        })
+        next({ ...to, replace: true })
+      } catch(error) {
+        console.log(error)
+      }
+      // debugger
+      return
+    }
     // 强制修改密码
     if (localStorage.getItem('entUpdatePassword') === 'needChange') fullScreen('entUpdatePassword')
     // 强制填写个人信息 fddeaddc47868b/ready
@@ -62,15 +92,16 @@ router.beforeEach(async (to, from, next) => {
     // const dictStore = useDictStore()
     // dictStore.getDictTypeData()
     next()
-  } else {
-    if (to.meta?.loginType === 'personalCommon' || to.meta?.loginType === 'common') { // 路由不重定向
-      next()
-    } else if (to.meta?.loginType === 'enterprise') { // 没有企业token->去个人首页
-      next({ path: '/recruitHome' })
-    } else {
-      next(`/login?redirect=${to.fullPath}`) // 否则全部重定向到登录页
-    }
   }
+  if (to.meta?.loginType === 'personalCommon' || to.meta?.loginType === 'common') { // 路由不重定向
+    next()
+    return
+  }
+  if (to.meta?.loginType === 'enterprise') { // 没有企业token->去个人首页
+    next({ path: '/recruitHome' })
+    return
+  }
+  next(`/login?redirect=${to.fullPath}`) // 否则全部重定向到登录页
 })
 
 router.afterEach((to) => {

+ 378 - 377
src/router/modules/components/recruit/enterprise.js

@@ -15,388 +15,389 @@ const enterprise = [
   //   }
   //   // redirect: '/enterprise',
   // },
+
   {
     path: '/recruit/enterprise',
     show: true,
     redirect: '/recruit/enterprise/position',
   },
-  {
-    path: '/recruit/enterprise/position',
-    component: Layout,
-    name: 'jobManagement',
-    meta: {
-      title: '职位管理',
-      enName: 'Job Management',
-      icon: 'mdi-format-list-bulleted-square'
-    },
-    children: [
-      {
-        path: '/recruit/enterprise/position',
-        show: true,
-        meta: {
-          title: '职位列表',
-          enName: 'Job list'
-        },
-        component: () => import('@/views/recruit/enterprise/positionManagement/index.vue')
-      },
-      {
-        path: '/recruit/enterprise/position/add',
-        show: true,
-        meta: {
-          title: '新增职位'
-        },
-        component: () => import('@/views/recruit/enterprise/positionManagement/components/add.vue')
-      },
-      {
-        path: '/recruit/enterprise/position/edit',
-        show: true,
-        meta: {
-          title: '职位编辑'
-        },
-        component: () => import('@/views/recruit/enterprise/positionManagement/components/add.vue')
-      },
-      {
-        path: '/recruit/enterprise/position/details',
-        show: true,
-        meta: {
-          hideSide: true,
-          title: '职位详情',
-          enName: 'Position Details'
-        },
-        component: () => import('@/views/recruit/enterprise/positionManagement/components/details.vue')
-      },
-    ]
-  },
-  {
-    path: '/recruit/enterprise/talentRecruitment',
-    redirect: '/recruit/enterprise/search',
-    component: Layout,
-    name: 'Talent Recruitment',
-    meta: {
-      title: '人才招聘',
-      enName: 'Talent Recruitment',
-      icon: 'mdi-account-settings-outline'
-    },
-    children: [
-      {
-        path: '/recruit/enterprise/search',
-        meta: {
-          title: '找人',
-          enName: 'Search People',
-        },
-        component: () => import('@/views/recruit/enterprise/search/index.vue')
-      },
-      {
-        path: '/recruit/enterprise/interviewManagement',
-        meta: {
-          title: '面试',
-          enName: 'Interview'
-        },
-        component: () => import('@/views/recruit/enterprise/interviewManagement/index.vue')
-      },
-      {
-        path: '/recruit/enterprise/chatTools',
-        meta: {
-          title: '沟通',
-          enName: 'Communication',
-        },
-        component: () => import('@/views/recruit/enterprise/chatTools/index.vue')
-      },
-      {
-        path: '/recruit/enterprise/resume',
-        meta: {
-          title: '简历',
-          enName: 'Resume'
-        },
-        component: () => import('@/views/recruit/enterprise/resume/index.vue')
-      }
-    ]
-  },
-  {
-    path: '/recruit/enterprise/jobFair',
-    component: Layout,
-    name: 'jobFair',
-    meta: {
-      title: '招聘会',
-      enName: 'Job Fair',
-      icon: 'mdi-account-filter-outline'
-    },
-    children: [
-      {
-        path: '/recruit/enterprise/jobFair',
-        show: true,
-        meta: {
-          title: '招聘会',
-          enName: 'Job Fair'
-        },
-        component: () => import('@/views/recruit/enterprise/jobFair/index.vue')
-      },
-      {
-        path: '/recruit/enterprise/jobFair/details/:id',
-        show: true,
-        meta: {
-          title: '招聘会详情',
-          enName: 'Job Fair Details'
-        },
-        component: () => import('@/views/recruit/enterprise/jobFair/detailsBox.vue'),
-        children: [
-          {
-            path: '/recruit/enterprise/jobFair/details/:id',
-            show: true,
-            meta: {
-              title: '招聘会详情',
-              enName: 'Job Fair Details'
-            },
-            component: () => import('@/views/recruit/enterprise/jobFair/details.vue'),
-          },
-          {
-            path: '/recruit/enterprise/jobFair/details/:id/edit',
-            show: true,
-            meta: {
-              title: '职位编辑',
-              enName: 'Job Fair Edit'
-            },
-            component: () => import('@/views/recruit/enterprise/jobFair/editJob.vue')
-          }
-        ]
-      },
+  // {
+  //   path: '/recruit/enterprise/position',
+  //   component: Layout,
+  //   name: 'jobManagement',
+  //   meta: {
+  //     title: '职位管理',
+  //     enName: 'Job Management',
+  //     icon: 'mdi-format-list-bulleted-square'
+  //   },
+  //   children: [
+  //     {
+  //       path: '/recruit/enterprise/position',
+  //       show: true,
+  //       meta: {
+  //         title: '职位列表',
+  //         enName: 'Job list'
+  //       },
+  //       component: () => import('@/views/recruit/enterprise/positionManagement/index.vue')
+  //     },
+  //     {
+  //       path: '/recruit/enterprise/position/add',
+  //       show: true,
+  //       meta: {
+  //         title: '新增职位'
+  //       },
+  //       component: () => import('@/views/recruit/enterprise/positionManagement/components/add.vue')
+  //     },
+  //     {
+  //       path: '/recruit/enterprise/position/edit',
+  //       show: true,
+  //       meta: {
+  //         title: '职位编辑'
+  //       },
+  //       component: () => import('@/views/recruit/enterprise/positionManagement/components/add.vue')
+  //     },
+  //     {
+  //       path: '/recruit/enterprise/position/details',
+  //       show: true,
+  //       meta: {
+  //         hideSide: true,
+  //         title: '职位详情',
+  //         enName: 'Position Details'
+  //       },
+  //       component: () => import('@/views/recruit/enterprise/positionManagement/components/details.vue')
+  //     },
+  //   ]
+  // },
+  // {
+  //   path: '/recruit/enterprise/talentRecruitment',
+  //   redirect: '/recruit/enterprise/search',
+  //   component: Layout,
+  //   name: 'Talent Recruitment',
+  //   meta: {
+  //     title: '人才招聘',
+  //     enName: 'Talent Recruitment',
+  //     icon: 'mdi-account-settings-outline'
+  //   },
+  //   children: [
+  //     {
+  //       path: '/recruit/enterprise/search',
+  //       meta: {
+  //         title: '找人',
+  //         enName: 'Search People',
+  //       },
+  //       component: () => import('@/views/recruit/enterprise/search/index.vue')
+  //     },
+  //     {
+  //       path: '/recruit/enterprise/interviewManagement',
+  //       meta: {
+  //         title: '面试',
+  //         enName: 'Interview'
+  //       },
+  //       component: () => import('@/views/recruit/enterprise/interviewManagement/index.vue')
+  //     },
+  //     {
+  //       path: '/recruit/enterprise/chatTools',
+  //       meta: {
+  //         title: '沟通',
+  //         enName: 'Communication',
+  //       },
+  //       component: () => import('@/views/recruit/enterprise/chatTools/index.vue')
+  //     },
+  //     {
+  //       path: '/recruit/enterprise/resume',
+  //       meta: {
+  //         title: '简历',
+  //         enName: 'Resume'
+  //       },
+  //       component: () => import('@/views/recruit/enterprise/resume/index.vue')
+  //     }
+  //   ]
+  // },
+  // {
+  //   path: '/recruit/enterprise/jobFair',
+  //   component: Layout,
+  //   name: 'jobFair',
+  //   meta: {
+  //     title: '招聘会',
+  //     enName: 'Job Fair',
+  //     icon: 'mdi-account-filter-outline'
+  //   },
+  //   children: [
+  //     {
+  //       path: '/recruit/enterprise/jobFair',
+  //       show: true,
+  //       meta: {
+  //         title: '招聘会',
+  //         enName: 'Job Fair'
+  //       },
+  //       component: () => import('@/views/recruit/enterprise/jobFair/index.vue')
+  //     },
+  //     {
+  //       path: '/recruit/enterprise/jobFair/details/:id',
+  //       show: true,
+  //       meta: {
+  //         title: '招聘会详情',
+  //         enName: 'Job Fair Details'
+  //       },
+  //       component: () => import('@/views/recruit/enterprise/jobFair/detailsBox.vue'),
+  //       children: [
+  //         {
+  //           path: '/recruit/enterprise/jobFair/details/:id',
+  //           show: true,
+  //           meta: {
+  //             title: '招聘会详情',
+  //             enName: 'Job Fair Details'
+  //           },
+  //           component: () => import('@/views/recruit/enterprise/jobFair/details.vue'),
+  //         },
+  //         {
+  //           path: '/recruit/enterprise/jobFair/details/:id/edit',
+  //           show: true,
+  //           meta: {
+  //             title: '职位编辑',
+  //             enName: 'Job Fair Edit'
+  //           },
+  //           component: () => import('@/views/recruit/enterprise/jobFair/editJob.vue')
+  //         }
+  //       ]
+  //     },
       
-    ]
-  },
-  {
-    path: '/recruit/enterprise/talentPool',
-    component: Layout,
-    name: 'Elite Reserve',
-    meta: {
-      title: '精英储备',
-      enName: 'Job Management',
-      icon: 'mdi-account-supervisor-circle'
-    },
-    children: [
-      {
-        path: '/recruit/enterprise/talentPool',
-        show: true,
-        component: () => import('@/views/recruit/enterprise/talentPool/index.vue')
-      },
-      {
-        path: '/recruit/enterprise/talentPool/details/:id',
-        show: true, // 侧边栏不展示
-        component: () => import('@/views/recruit/enterprise/talentPool/components/details'),
-        name: 'talentPoolDetails',
-        meta: {
-          title: '人才详情',
-          hideSide: true
-        }
-      },
-    ]
-  },
-  {
-    path: '/recruit/enterprise/hirePosition',
-    component: Layout,
-    name: 'crowdSourcing',
-    meta: {
-      title: '全员猎寻',
-      enName: 'Crowd Sourcing',
-      icon: 'mdi-account-star-outline',
-      hireJob: true
-    },
-    children: [
-      {
-        path: '/recruit/enterprise/hirePosition',
-        show: true,
-        meta: {
-          title: '全员猎寻'
-        },
-        component: () => import('@/views/recruit/enterprise/hirePosition/index.vue')
-      },
-      {
-        path: '/recruit/enterprise/hirePosition/add',
-        show: true,
-        meta: {
-          title: '新增职位'
-        },
-        component: () => import('@/views/recruit/enterprise/hirePosition/components/add.vue')
-      },
-      {
-        path: '/recruit/enterprise/hirePosition/edit',
-        show: true,
-        meta: {
-          title: '职位编辑'
-        },
-        component: () => import('@/views/recruit/enterprise/hirePosition/components/add.vue')
-      }
-    ]
-  },
-  {
-    path: '/recruit/enterprise/talentMap',
-    component: Layout,
-    name: 'Talent Map',
-    meta: {
-      title: '人才地图',
-      enName: 'Talent Map',
-      icon: 'mdi-map-check',
-      isPersonMap: true
-    },
-    children: [
-      {
-        path: '/recruit/enterprise/talentMap',
-        show: true,
-        component: () => import('@/views/recruit/enterprise/talentMap/index.vue')
-      }
-    ]
-  },
-  {
-    path: '/recruit/enterprise/statistics/overallAnalysis',
-    component: Layout,
-    name: 'enterpriseStatistics',
-    meta: {
-      title: '统计分析',
-      enName: 'Statistics',
-      icon: 'mdi-chart-arc'
-    },
-    children: [
-      {
-        path: '/recruit/enterprise/statistics/overallAnalysis',
-        show: true,
-        component: () => import('@/views/recruit/enterprise/statistics/overallAnalysis.vue')
-      }
-    ]
-  },
-  {
-    path: '/recruit/enterprise/systemManagement',
-    component: Layout,
-    redirect: '/recruit/enterprise/systemManagement/userManagement',
-    name: 'systemManagement',
-    meta: {
-      title: '系统管理',
-      enName: 'system Management',
-      icon: 'mdi-cog-outline'
-    },
-    children: [
-      // 角色管理
-      {
-        path: '/recruit/enterprise/systemManagement/roleManagement',
-        meta: {
-          title: '角色管理',
-          enName: 'Role Management',
-          isAdmin: true // 企业管理员菜单
-        },
-        component: () => import('@/views/recruit/enterprise/systemManagement/roleManagement/index.vue')
-      },
-      // 集团
-      {
-        path: '/recruit/enterprise/systemManagement/groupAccount',
-        meta: {
-          title: '集团账户',
-          enName: 'Group Account ',
-          isAdmin: true // 企业管理员菜单
-        },
-        component: () => import('@/views/recruit/enterprise/systemManagement/groupAccount/index.vue')
-      },
-      // 邀请生成链接页面(非邀请页)
-      {
-        path: '/recruit/enterprise/systemManagement/groupAccount/invite/:type',
-        show: true,
-        meta: {
-          hideSide: true,
-          title: '邀请',
-          enName: 'Invite',
-          isAdmin: true // 企业管理员菜单
-        },
-        component: () => import('@/views/recruit/enterprise/systemManagement/groupAccount/invite.vue')
-      },
-      // 企业信息 
-      {
-        path: '/recruit/enterprise/entInfoSetting',
-        meta: {
-          title: '企业信息',
-          enName: 'Group Account ',
-          isAdmin: true // 企业管理员菜单
-        },
-        component: () => import('@/views/recruit/enterprise/entInfoSetting/index.vue')
-      },
-      // 员工信息 
-      {
-        path: '/recruit/enterprise/staffInfoSetting',
-        meta: {
-          title: '员工信息',
-          enName: 'Group Account '
-        },
-        component: () => import('@/views/recruit/enterprise/staffInfoSetting/index.vue')
-      },
-      {
-        path: '/recruit/enterprise/staffChangePassword',
-        show: true,
-        meta: {
-          title: '修改登录密码',
-        },
-        component: () => import('@/views/recruit/enterprise/staffChangePassword/index.vue')
-      },
-    ]
-  },
-  {
-    component: Layout,
-    path: '/recruit/enterprise/financialCenter',
-    redirect: '/recruit/enterprise/tradingOrder',
-    name: 'enterpriseMemberCenter',
-    meta: {
-      title: '财务中心',
-      enName: 'system Management',
-      icon: 'mdi-finance',
-      // isAdmin: true // 企业管理员菜单
-    },
-    children: [
-      {
-        path: '/recruit/enterprise/tradingOrder',
-        meta: {
-          title:'订单管理',
-          enName: 'Order management'
-        },
-        component: () => import('@/views/recruit/enterprise/tradingOrder/index.vue')
-      },
-      {
-        path: '/recruit/enterprise/invoiceManagement',
-        meta: {
-          title: '发票抬头管理',
-          enName: 'Invoice Management '
-        },
-        component: () => import('@/views/recruit/enterprise/invoiceManagement/index.vue')
-      }
-    ]
-  },
-  {
-    path: '/recruit/enterprise/membershipPackage',
-    component: Layout,
-    name: 'membershipPackage',
-    meta: {
-      title: '会员套餐',
-      enName: 'Membership Benefits',
-      icon: 'mdi-wallet-membership'
-    },
-    children: [
-      {
-        path: '/recruit/enterprise/membershipPackage',
-        show: true,
-        component: () => import('@/views/recruit/enterprise/membershipPackage/index.vue')
-      }
-    ]
-  },
-  {
-    path: '/recruit/enterprise/newlyAppointed',
-    component: Layout,
-    name: 'Newly Appointed',
-    meta: {
-      title: '门墩儿新任命',
-      enName: 'Newly Appointed',
-      icon: 'mdi-new-box'
-    },
-    children: [
-      {
-        path: '/recruit/enterprise/newlyAppointed',
-        show: true,
-        component: () => import('@/views/recruit/enterprise/newlyAppointed/index.vue')
-      }
-    ]
-  }
+  //   ]
+  // },
+  // {
+  //   path: '/recruit/enterprise/talentPool',
+  //   component: Layout,
+  //   name: 'Elite Reserve',
+  //   meta: {
+  //     title: '精英储备',
+  //     enName: 'Job Management',
+  //     icon: 'mdi-account-supervisor-circle'
+  //   },
+  //   children: [
+  //     {
+  //       path: '/recruit/enterprise/talentPool',
+  //       show: true,
+  //       component: () => import('@/views/recruit/enterprise/talentPool/index.vue')
+  //     },
+  //     {
+  //       path: '/recruit/enterprise/talentPool/details/:id',
+  //       show: true, // 侧边栏不展示
+  //       component: () => import('@/views/recruit/enterprise/talentPool/components/details'),
+  //       name: 'talentPoolDetails',
+  //       meta: {
+  //         title: '人才详情',
+  //         hideSide: true
+  //       }
+  //     },
+  //   ]
+  // },
+  // {
+  //   path: '/recruit/enterprise/hirePosition',
+  //   component: Layout,
+  //   name: 'crowdSourcing',
+  //   meta: {
+  //     title: '全员猎寻',
+  //     enName: 'Crowd Sourcing',
+  //     icon: 'mdi-account-star-outline',
+  //     hireJob: true
+  //   },
+  //   children: [
+  //     {
+  //       path: '/recruit/enterprise/hirePosition',
+  //       show: true,
+  //       meta: {
+  //         title: '全员猎寻'
+  //       },
+  //       component: () => import('@/views/recruit/enterprise/hirePosition/index.vue')
+  //     },
+  //     {
+  //       path: '/recruit/enterprise/hirePosition/add',
+  //       show: true,
+  //       meta: {
+  //         title: '新增职位'
+  //       },
+  //       component: () => import('@/views/recruit/enterprise/hirePosition/components/add.vue')
+  //     },
+  //     {
+  //       path: '/recruit/enterprise/hirePosition/edit',
+  //       show: true,
+  //       meta: {
+  //         title: '职位编辑'
+  //       },
+  //       component: () => import('@/views/recruit/enterprise/hirePosition/components/add.vue')
+  //     }
+  //   ]
+  // },
+  // {
+  //   path: '/recruit/enterprise/talentMap',
+  //   component: Layout,
+  //   name: 'Talent Map',
+  //   meta: {
+  //     title: '人才地图',
+  //     enName: 'Talent Map',
+  //     icon: 'mdi-map-check',
+  //     isPersonMap: true
+  //   },
+  //   children: [
+  //     {
+  //       path: '/recruit/enterprise/talentMap',
+  //       show: true,
+  //       component: () => import('@/views/recruit/enterprise/talentMap/index.vue')
+  //     }
+  //   ]
+  // },
+  // {
+  //   path: '/recruit/enterprise/statistics/overallAnalysis',
+  //   component: Layout,
+  //   name: 'enterpriseStatistics',
+  //   meta: {
+  //     title: '统计分析',
+  //     enName: 'Statistics',
+  //     icon: 'mdi-chart-arc'
+  //   },
+  //   children: [
+  //     {
+  //       path: '/recruit/enterprise/statistics/overallAnalysis',
+  //       show: true,
+  //       component: () => import('@/views/recruit/enterprise/statistics/overallAnalysis.vue')
+  //     }
+  //   ]
+  // },
+  // {
+  //   path: '/recruit/enterprise/systemManagement',
+  //   component: Layout,
+  //   redirect: '/recruit/enterprise/systemManagement/userManagement',
+  //   name: 'systemManagement',
+  //   meta: {
+  //     title: '系统管理',
+  //     enName: 'system Management',
+  //     icon: 'mdi-cog-outline'
+  //   },
+  //   children: [
+  //     // 角色管理
+  //     {
+  //       path: '/recruit/enterprise/systemManagement/roleManagement',
+  //       meta: {
+  //         title: '角色管理',
+  //         enName: 'Role Management',
+  //         isAdmin: true // 企业管理员菜单
+  //       },
+  //       component: () => import('@/views/recruit/enterprise/systemManagement/roleManagement/index.vue')
+  //     },
+  //     // 集团
+  //     {
+  //       path: '/recruit/enterprise/systemManagement/groupAccount',
+  //       meta: {
+  //         title: '集团账户',
+  //         enName: 'Group Account ',
+  //         isAdmin: true // 企业管理员菜单
+  //       },
+  //       component: () => import('@/views/recruit/enterprise/systemManagement/groupAccount/index.vue')
+  //     },
+  //     // 邀请生成链接页面(非邀请页)
+  //     {
+  //       path: '/recruit/enterprise/systemManagement/groupAccount/invite/:type',
+  //       show: true,
+  //       meta: {
+  //         hideSide: true,
+  //         title: '邀请',
+  //         enName: 'Invite',
+  //         isAdmin: true // 企业管理员菜单
+  //       },
+  //       component: () => import('@/views/recruit/enterprise/systemManagement/groupAccount/invite.vue')
+  //     },
+  //     // 企业信息 
+  //     {
+  //       path: '/recruit/enterprise/entInfoSetting',
+  //       meta: {
+  //         title: '企业信息',
+  //         enName: 'Group Account ',
+  //         isAdmin: true // 企业管理员菜单
+  //       },
+  //       component: () => import('@/views/recruit/enterprise/entInfoSetting/index.vue')
+  //     },
+  //     // 员工信息 
+  //     {
+  //       path: '/recruit/enterprise/staffInfoSetting',
+  //       meta: {
+  //         title: '员工信息',
+  //         enName: 'Group Account '
+  //       },
+  //       component: () => import('@/views/recruit/enterprise/staffInfoSetting/index.vue')
+  //     },
+  //     {
+  //       path: '/recruit/enterprise/staffChangePassword',
+  //       show: true,
+  //       meta: {
+  //         title: '修改登录密码',
+  //       },
+  //       component: () => import('@/views/recruit/enterprise/staffChangePassword/index.vue')
+  //     },
+  //   ]
+  // },
+  // {
+  //   component: Layout,
+  //   path: '/recruit/enterprise/financialCenter',
+  //   redirect: '/recruit/enterprise/tradingOrder',
+  //   name: 'enterpriseMemberCenter',
+  //   meta: {
+  //     title: '财务中心',
+  //     enName: 'system Management',
+  //     icon: 'mdi-finance',
+  //     // isAdmin: true // 企业管理员菜单
+  //   },
+  //   children: [
+  //     {
+  //       path: '/recruit/enterprise/tradingOrder',
+  //       meta: {
+  //         title:'订单管理',
+  //         enName: 'Order management'
+  //       },
+  //       component: () => import('@/views/recruit/enterprise/tradingOrder/index.vue')
+  //     },
+  //     {
+  //       path: '/recruit/enterprise/invoiceManagement',
+  //       meta: {
+  //         title: '发票抬头管理',
+  //         enName: 'Invoice Management '
+  //       },
+  //       component: () => import('@/views/recruit/enterprise/invoiceManagement/index.vue')
+  //     }
+  //   ]
+  // },
+  // {
+  //   path: '/recruit/enterprise/membershipPackage',
+  //   component: Layout,
+  //   name: 'membershipPackage',
+  //   meta: {
+  //     title: '会员套餐',
+  //     enName: 'Membership Benefits',
+  //     icon: 'mdi-wallet-membership'
+  //   },
+  //   children: [
+  //     {
+  //       path: '/recruit/enterprise/membershipPackage',
+  //       show: true,
+  //       component: () => import('@/views/recruit/enterprise/membershipPackage/index.vue')
+  //     }
+  //   ]
+  // },
+  // {
+  //   path: '/recruit/enterprise/newlyAppointed',
+  //   component: Layout,
+  //   name: 'Newly Appointed',
+  //   meta: {
+  //     title: '门墩儿新任命',
+  //     enName: 'Newly Appointed',
+  //     icon: 'mdi-new-box'
+  //   },
+  //   children: [
+  //     {
+  //       path: '/recruit/enterprise/newlyAppointed',
+  //       show: true,
+  //       component: () => import('@/views/recruit/enterprise/newlyAppointed/index.vue')
+  //     }
+  //   ]
+  // }
 ]
 export default enterprise

+ 80 - 0
src/store/enterprise.js

@@ -0,0 +1,80 @@
+import { defineStore } from 'pinia'
+import { ref, defineAsyncComponent } from 'vue'
+import { getPermissionInfo } from '@/api/recruit/enterprise/system/role'
+import { cloneDeep } from 'lodash'
+
+export const useEnterpriseStore = defineStore('enterpriseStore', 
+  () => {
+    const enterpriseMenu = ref([])
+    
+    const saveEnterpriseMenu = (menu) => {
+      enterpriseMenu.value = menu
+    }
+
+    const getEnterpriseMenu = () => {
+      return new Promise((resolve, reject) => {
+        getPermissionInfo().then(data => {
+          resolve(data)
+        }).catch(reject)
+      })
+    }
+
+    const clearEnterpriseMenu = () => {
+      enterpriseMenu.value = []
+    }
+    const MENU_TYPE = {
+      CATALOGUE: 1,
+      MENU: 2,
+      BUTTON: 3
+    }
+    // 动态加载路由函数  
+    const assignEnterpriseMenu = (menuTree) => {  
+      const modules = import.meta.glob('../views/recruit/enterprise/**/*.{vue,tsx}')
+      const modulesRoutesKeys = Object.keys(modules)
+      const formatRoutes = (menu) => {
+        return menu.map(item => {
+          const data = JSON.parse(JSON.stringify(item))
+          Object.assign(data, {
+            meta: {
+              title: item.name,
+              icon: item.icon,
+              loginType: 'enterprise'
+            }
+          })
+
+  
+          if (item.type === MENU_TYPE.CATALOGUE) {
+            data.component = () => import('@/layout/enterprise.vue')
+          }
+  
+          if (item.type === MENU_TYPE.MENU) {
+            const index = modulesRoutesKeys.findIndex((ev) => ev.includes(data.component))
+            if (index > -1) {
+              data.component = modules[modulesRoutesKeys[index]]
+              data.path = `/${item.path}`
+            }
+          }
+
+          // 如果有子菜单,递归调用  
+          if (item.children && Array.isArray(item.children) && item.children.length) {  
+            data.children = formatRoutes(item.children)
+          }  
+
+          return data  
+        })
+      }
+
+      return formatRoutes(menuTree)
+    }  
+
+    return {
+      enterpriseMenu,
+      assignEnterpriseMenu,
+      clearEnterpriseMenu,
+      saveEnterpriseMenu,
+      getEnterpriseMenu
+    }
+  },
+  {
+    persist: true
+  })

+ 4 - 3
src/store/user.js

@@ -28,6 +28,7 @@ import { checkPersonBaseInfo } from '@/utils/check'
 export const useUserStore = defineStore('user',
   {
     state: () => ({
+      isAdmin: localStorage.getItem('isAdmin') === '1',
       token: getToken(),
       accountInfo: localStorage.getItem('accountInfo') ? JSON.parse(localStorage.getItem('accountInfo')) : {}, // 登录返回的信息
       userInfo: localStorage.getItem('userInfo') ? JSON.parse(localStorage.getItem('userInfo')) : {}, // 当前登录账号信息
@@ -194,9 +195,9 @@ export const useUserStore = defineStore('user',
         this.entBaseInfo = result
         
         // 是否为企业账号管理员
-        const isAdmin = result.userType === '1'
-        localStorage.setItem('isAdmin', isAdmin)
-        if (isAdmin && !check) await this.checkEnterpriseBaseInfo() // 校验企业必填信息
+        this.isAdmin = result.userType === '1'
+        localStorage.setItem('isAdmin', result.userType)
+        if (this.isAdmin && !check) await this.checkEnterpriseBaseInfo() // 校验企业必填信息
         localStorage.setItem('entBaseInfo', JSON.stringify(result))
       },
       // 获取企业账户信息

+ 1 - 1
src/views/recruit/enterprise/systemManagement/groupAccount/index.vue

@@ -62,7 +62,7 @@
             <v-btn v-if="item.userType === '0'" color="primary" variant="text" @click="handleEdit(item)">编辑</v-btn>
             <v-btn v-if="item.status === '1' && item.userType !== '1'" color="primary" variant="text" @click="handleAction('', 0, item)">{{ $t('enterprise.userManagement.enable') }}</v-btn>
             <v-btn v-if="item.status === '0' && item.userType !== '1'" color="primary" variant="text" @click="handleAction('', 1, item)">{{ $t('enterprise.userManagement.disable') }}</v-btn>
-            <v-btn color="primary" variant="text" @click="handleRole(item)">分配角色</v-btn>
+            <v-btn v-if="item.status === '0' && item.userType !== '1'" color="primary" variant="text" @click="handleRole(item)">分配角色</v-btn>
           </template>
         </CtTable>
       </v-col>