浏览代码

动态路由

zhengnaiwen_citu 3 月之前
父节点
当前提交
7ccc4e6b01

+ 1 - 0
components.d.ts

@@ -32,6 +32,7 @@ declare module 'vue' {
     DatePicker: typeof import('./src/components/DatePicker/index.vue')['default']
     Echarts: typeof import('./src/components/Echarts/index.vue')['default']
     ElConfigProvider: typeof import('element-plus/es')['ElConfigProvider']
+    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']

+ 1 - 1
src/components/pay/index.vue

@@ -382,7 +382,7 @@ const formatDuration = (remainder) => {
 }
 
 const handleToJump = () => {
-  router.push('/recruit/enterprise/membershipPackage?fromName=positionPay')
+  router.push('/recruit/enterprise/membershipPackage/index?fromName=positionPay')
 }
 
 </script>

+ 4 - 4
src/layout/company/navBar.vue

@@ -18,7 +18,7 @@
             <span @click="enterpriseClick(1)" class="ml-3 commonHover">{{ formatName(baseInfo?.enterpriseAnotherName || baseInfo?.enterpriseName) }}</span>
           </div>
           <div class="ml-3 cursor-pointer border-left border-right px-3 commonHover" @click="handleLogout(false)">我要求职</div>
-          <div class="d-flex align-center px-3 border-right cursor-pointer commonHover" @click="router.push('/recruit/enterprise/membershipPackage?key=1')">
+          <div class="d-flex align-center px-3 border-right cursor-pointer commonHover" @click="router.push('/recruit/enterprise/membershipPackage/index?key=1')">
             <div>剩余M豆:{{ enterpriseUserAccount?.balance ? enterpriseUserAccount?.balance / 100 : 0 }}个</div>
           </div>
           <svg-icon v-if="baseInfo?.vipFlag && Date.now() < baseInfo?.vipExpireDate" name="vip" size="30" class="ml-3"></svg-icon>
@@ -72,7 +72,7 @@
           </v-menu> -->
 
           <!-- 消息通知 -->
-          <MessageNotification class="commonHover2" path="/recruit/enterprise/chatTools"></MessageNotification>
+          <MessageNotification class="commonHover2" path="/recruit/enterprise/invite/chatTools"></MessageNotification>
         </div>
       </div>
     </v-toolbar>
@@ -113,7 +113,7 @@ onMounted(() => {
 const handleLogoClick = () => { window.open('/recruitHome') } // 点击logo
 
 const enterpriseClick = (tabKey = 1) => {
-  const path = '/recruit/enterprise/entInfoSetting'
+  const path = '/recruit/enterprise/systemManagement/entInfoSetting'
   router.push({ path, query: { tabKey } })
 }
 
@@ -125,7 +125,7 @@ const handleLogout = async (exit = true) => {
 const enterpriseList = ref([])
 
 const menuList = ref([
-  { title: t('setting.editPassword'), icon: 'mdi-shield-lock-open-outline', change: () => router.push({ path: '/recruit/enterprise/staffChangePassword' }) },
+  { title: t('setting.editPassword'), icon: 'mdi-shield-lock-open-outline', change: () => router.push({ path: '/recruit/enterprise/systemManagement/staffChangePassword' }) },
   { title: t('setting.logOut'), icon: 'mdi-logout', change: handleLogout }
 ])
 const items = computed(() => {

+ 6 - 5
src/layout/company/side.vue

@@ -56,18 +56,19 @@ const list = computed(() => {
 
 // const isAdmin = localStorage.getItem('isAdmin') === '1'
 // const info = localStorage.getItem('entBaseInfo') ? JSON.parse(localStorage.getItem('entBaseInfo')) : {}
-const getList = (arr, obj = []) => {
+const getList = (arr, obj = [], root = '') => {
   // 是否为企业管理员
   arr.forEach(element => {
     if (!element.alwaysShow) return
     let data = {}
-    const path = element.path[0] === '/' ? element.path : '/' + element.path
+    // const path = element.path[0] === '/' ? element.path : '/' + element.path
+    const path = root + element.path
     data = {
       title: element.name,
       enName: element?.meta?.enName,
       icon: element.icon,
       name: element.name,
-      path,
+      path: enterpriseStore.menuType.CATALOGUE === element.type ? path + '/index' : path,
       children: []
     }
     // if (element?.meta?.isAdmin) {
@@ -78,7 +79,7 @@ const getList = (arr, obj = []) => {
     // 全员猎寻
     // if (element?.meta?.hireJob) data.hireJob = true
     if (element?.children) {
-      getList(element.children, data.children)
+      getList(element.children, data.children, path + '/')
     }
     obj.push(data)
   })
@@ -94,7 +95,7 @@ const getList = (arr, obj = []) => {
   // 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')
+  if (import.meta.env.VITE_NODE_ENV === 'production') obj = obj.filter(e => !e.path.includes('/recruit/enterprise/newlyAppointed'))
   return obj
 }
 

+ 1 - 1
src/layout/company/slider.vue

@@ -23,7 +23,7 @@ const router = useRouter()
 const list = [
   { mdi: 'mdi-arrow-up-bold', tips: '返回顶部' },
   { mdi: 'mdi-qrcode', tips: '微信公众号', showImg: 'https://minio.citupro.com/dev/menduner/official-account-code4.jpg' },
-  { mdi: 'mdi-bell-outline', tips: '消息', path: '/recruit/enterprise/chatTools' }
+  { mdi: 'mdi-bell-outline', tips: '消息', path: '/recruit/enterprise/invite/chatTools' }
 ]
 
 const handleClick = (item, index) => {

+ 22 - 8
src/permission.js

@@ -22,6 +22,7 @@ const ENTERPRISE_PATH = '/recruit/enterprise'
 router.beforeEach(async (to, from, next) => {
   start()
   // 个人端 404 处理
+  // debugger
   if (to.path === '/404') {
     next()
     return
@@ -70,12 +71,21 @@ router.beforeEach(async (to, from, next) => {
           return
         }
         if (to.path === ENTERPRISE_PATH) {
-          const firstPath = routes[0]
-          if (!firstPath.children) {
-            next(firstPath.path)
-          } else {
-            // 查找二级路由
-            next(routes[0].children[0].path)
+          next(findPath(routes))
+          // const firstPath = routes[0]
+          // if (!firstPath.children) {
+          //   next(firstPath.path)
+          // } else {
+          //   // 查找二级路由
+          //   next(routes[0].children[0].path)
+          // }
+          function findPath (nodes, root = '') {
+            const first = nodes[0]
+            const path = root + first.path
+            if (!first.children || !first.children.length) {
+              return path
+            }
+            return findPath(first.children, path + '/')
           }
         }
         next({ ...to, replace: true })
@@ -112,19 +122,21 @@ router.beforeEach(async (to, from, next) => {
       }
     }
     if (to.fullPath === '/login') {
-      next({ path: '/recruitHome' })
+      next('/recruitHome')
+      return
     }
     // 获取字典信息
     // const dictStore = useDictStore()
     // dictStore.getDictTypeData()
     next()
+    return
   }
   if (to.meta?.loginType === 'personalCommon' || to.meta?.loginType === 'common') { // 路由不重定向
     next()
     return
   }
   if (to.meta?.loginType === 'enterprise') { // 没有企业token->去个人首页
-    next({ path: '/recruitHome' })
+    next('/recruitHome')
     return
   }
   next(`/login?redirect=${to.fullPath}`) // 否则全部重定向到登录页
@@ -139,6 +151,8 @@ router.afterEach((to) => {
 
 function hasRoute (path) {
   const routes = router.getRoutes()
+  // console.log(routes.filter(item => item.path.includes('/recruit/enterprise')))
+  // debugger
   return routeFlattening(routes).some(_path => {
     if (_path.includes(':')) {
       const change = path.split('/')

+ 6 - 4
src/store/enterprise.js

@@ -60,13 +60,14 @@ export const useEnterpriseStore = defineStore('enterpriseStore',
   
           if (item.type === MENU_TYPE.MENU) {
             const index = modulesRoutesKeys.findIndex((ev) => ev.includes(data.component))
+            // console.log(modules[modulesRoutesKeys[index]])
             if (index > -1) {
-              data.component = defineAsyncComponent(modules[modulesRoutesKeys[index]])
+              data.component = modules[modulesRoutesKeys[index]]
             }
             data.name = data.componentName
-            if (data.path[0] !== '/') {
-              data.path = '/' + data.path
-            }
+            // if (data.path[0] !== '/') {
+            //   data.path = '/' + data.path
+            // }
           }
 
           // 如果有子菜单,递归调用  
@@ -82,6 +83,7 @@ export const useEnterpriseStore = defineStore('enterpriseStore',
     }  
 
     return {
+      menuType: MENU_TYPE,
       enterpriseMenu,
       assignEnterpriseMenu,
       clearEnterpriseMenu,

+ 9 - 0
src/store/system.js

@@ -33,6 +33,7 @@ export const useSystem = defineStore('system',
     const breadcrumbs = ref([])
 
     const setBreadcrumbs = (matched, fullPath) => {
+      console.log('1111', matched, fullPath)
       const _fullPath = fullPath.split('/')
       const arr = matched.map((item, index) => {
         // 重组路径
@@ -43,6 +44,14 @@ export const useSystem = defineStore('system',
           text,
           to: _path.map((e, i) => _fullPath[i]).join('/')
         }
+        if (item.children && item.children.length) {
+          if (!item.children.find(e => e.path === 'index')) {
+            obj.to += `/${item.children[0].path}`
+            return obj
+          }
+          obj.to += '/index'
+          return obj
+        }
         return obj
       }).filter(e => e) || []
       if (arr?.length) {

+ 3 - 3
src/store/user.js

@@ -219,17 +219,17 @@ export const useUserStore = defineStore('user',
         try {
           const data = await getEnterpriseBaseInfo()
           if (data?.first === null || data?.first === false) { // null或者为false才弹
-            localStorage.setItem('checkEnterpriseBaseInfoFalseHref', '/recruit/enterprise/entInfoSetting')
+            localStorage.setItem('checkEnterpriseBaseInfoFalseHref', '/recruit/enterprise/systemManagement/entInfoSetting')
           }
           if (!data?.bizFlag) {  // 企业登录免费职位广告提示,除了true都弹窗
             localStorage.setItem('positionAd', 'showPositionAd')
           }
           // // 检验必填信息
           // const keyArr = ['industryId', 'financingStatus', 'scale', 'introduce', 'logoUrl'] // 必填信息列表
-          // let href = '/recruit/enterprise/entInfoSetting'
+          // let href = '/recruit/enterprise/systemManagement/entInfoSetting'
           // const valid = Object.keys(data).length && keyArr.every(e => {
           //   const bool = data[e] && data[e] !== 0
-          //   if (!bool && e === 'logoUrl') href = '/recruit/enterprise/entInfoSetting?tabKey=2'
+          //   if (!bool && e === 'logoUrl') href = '/recruit/enterprise/systemManagement/entInfoSetting?tabKey=2'
           //   return bool
           // })
           // if (!valid) {

+ 1 - 1
src/views/recruit/components/message/index.vue

@@ -709,7 +709,7 @@ const handleSubmit = async () => {
 
 const router = useRouter()
 const handleToInterviewManagement = () => {
-  router.push('/recruit/enterprise/interviewManagement')
+  router.push('/recruit/enterprise/invite/interviewManagement')
 }
 
 // 企业-求简历

+ 1 - 1
src/views/recruit/enterprise/hirePosition/components/add.vue

@@ -125,7 +125,7 @@ if (route.query && route.query.id) {
 // 取消
 const handleCancel = () => {
   itemData.value = {}
-  router.push({ path: '/recruit/enterprise/hirePosition' })
+  router.push({ path: '/recruit/enterprise/hirePosition/index' })
   // 新增职位发布需更新账户信息
   if (route.query && !route.query?.id) {
     setTimeout(async () => {

+ 1 - 1
src/views/recruit/enterprise/hirePosition/components/item.vue

@@ -186,7 +186,7 @@ const handleDetail = async (val) => {
 
 // 查看职位投递简历
 const handleToResume = (val) => {
-  router.push(`/recruit/enterprise/resume?id=${val.id}&hire=1`)
+  router.push(`/recruit/enterprise/invite/resume?id=${val.id}&hire=1`)
 }
 </script>
 

+ 1 - 1
src/views/recruit/enterprise/jobFair/editJob/index.vue

@@ -157,7 +157,7 @@ const afterAdd = async (jobId) => {
       jobId
     })
     Snackbar.success(t('common.publishSuccessMsg'))
-    router.push(`/recruit/enterprise/jobFair/details/${route.params.id}`)
+    router.push(`/recruit/enterprise/jobFair/details/${route.params.id}/index`)
   } catch (error) {
     console.error(error)
     Snackbar.error(error)

+ 1 - 1
src/views/recruit/enterprise/jobFair/index.vue

@@ -36,7 +36,7 @@ getList()
 const handleBlockEnterprise = async (id) => {
   const data = await getCheckJobFairPermission(id)
   if (!data) return Snackbar.warning('您没有权限参加该招聘会') // 只有返回true才能进入双选会
-  router.push(`/recruit/enterprise/jobFair/details/${id}`)
+  router.push(`/recruit/enterprise/jobFair/details/${id}/index`)
 }
 </script>
 

+ 1 - 1
src/views/recruit/enterprise/membershipPackage/dynamic/balance.vue

@@ -304,7 +304,7 @@ const remainderCalc = () => {
 }
 
 const handleToOrder = () => {
-  router.push('/recruit/enterprise/tradingOrder?key=tab_recharge')
+  router.push('/recruit/enterprise/financialCenter/tradingOrder?key=tab_recharge')
 }
 
 const mlArr = [119, 344, 567, 791, 1298, 1298, 1298, 1298]

+ 2 - 2
src/views/recruit/enterprise/membershipPackage/dynamic/package-copy.vue

@@ -179,8 +179,8 @@ const fromName = ref(route.query?.fromName || '')
 const callBackUrl = () => {
   // if (!fromName.value) return
   const urls = {
-    position: '/recruit/enterprise/position',
-    positionPay: '/recruit/enterprise/position?tab=0',
+    position: '/recruit/enterprise/position/index',
+    positionPay: '/recruit/enterprise/position/index?tab=0',
   }
   const texts = {
     position: '职位管理页面',

+ 2 - 2
src/views/recruit/enterprise/membershipPackage/dynamic/package.vue

@@ -152,8 +152,8 @@ const updateAccountInfo = async (init = false) => {
 const fromName = ref(route.query?.fromName || '')
 const callBackUrl = () => {
   const urls = {
-    position: '/recruit/enterprise/position',
-    positionPay: '/recruit/enterprise/position?tab=0',
+    position: '/recruit/enterprise/position/index',
+    positionPay: '/recruit/enterprise/position/index?tab=0',
   }
   const texts = {
     position: '职位管理页面',

+ 2 - 2
src/views/recruit/enterprise/positionManagement/components/add.vue

@@ -164,7 +164,7 @@ const handlePayClose = () => {
   Snackbar.warning('您已取消支付')
   itemData.value = {}
   showConfirmPaymentDialog.value = false
-  router.push({ path: '/recruit/enterprise/position', query: { key: 0 }})
+  router.push({ path: '/recruit/enterprise/position/index', query: { key: 0 }})
 }
 
 // 获取编辑的职位详情
@@ -183,7 +183,7 @@ if (route.query && route.query.id) {
 const handleCancel = () => {
   itemData.value = {}
   const currentPage = router.currentRoute.value.path
-  router.push({ path: currentPage.indexOf('jobFair') !== -1 ? '/recruit/enterprise/jobFair' : '/recruit/enterprise/position' })
+  router.push({ path: currentPage.indexOf('jobFair') !== -1 ? '/recruit/enterprise/jobFair/index' : '/recruit/enterprise/position/index' })
   // 新增职位发布需更新账户信息
   if (route.query && !route.query?.id) {
     setTimeout(async () => {

+ 1 - 1
src/views/recruit/enterprise/positionManagement/components/item.vue

@@ -290,7 +290,7 @@ const handleDetail = async (val) => {
 
 // 查看职位投递简历
 const handleToResume = (val) => {
-  router.push(`/recruit/enterprise/resume?id=${val.id}`)
+  router.push(`/recruit/enterprise/invite/resume?id=${val.id}`)
 }
 </script>
 

+ 1 - 1
src/views/recruit/enterprise/positionManagement/index.vue

@@ -17,7 +17,7 @@
       </div>
       <div class="color-666 font-size-14">
         <span>可发布职位数 <strong class="color-primary">{{ baseInfo?.entitlement?.publishJobCount || 0 }}</strong> 个, </span>
-        <span class="color-primary border-bottom-primary cursor-pointer" @click="router.push('/recruit/enterprise/membershipPackage?fromName=position')">可发布职位数不够用?点击去购买</span>
+        <span class="color-primary border-bottom-primary cursor-pointer" @click="router.push('/recruit/enterprise/membershipPackage/index?fromName=position')">可发布职位数不够用?点击去购买</span>
       </div>
       
       <div class="mt-3">

+ 2 - 2
src/views/recruit/enterprise/resume/components/table.vue

@@ -216,7 +216,7 @@ const handleToCommunicate = async (item) => {
   if (item?.jobClosed) return // 职位已关闭
   const userId = item.userId
   await talkToUser({userId, text: defaultTextEnt})
-  let url = `/recruit/enterprise/chatTools?id=${userId}`
+  let url = `/recruit/enterprise/invite/chatTools?id=${userId}`
   router.push(url)
 }
 
@@ -249,7 +249,7 @@ const handleSettlement = async (item) => {
 }
 
 const handleToInterviewManagement = () => {
-  router.push('/recruit/enterprise/interviewManagement')
+  router.push('/recruit/enterprise/invite/interviewManagement')
 }
 
 // 下载附件

+ 2 - 2
src/views/recruit/enterprise/search/recommend/index.vue

@@ -177,7 +177,7 @@ const handleCommunicate = async (item) => {
   const userId = item.userId
   if (!userId) return
   await talkToUser({userId, text: defaultTextEnt})
-  let url = `/recruit/enterprise/chatTools?id=${userId}`
+  let url = `/recruit/enterprise/invite/chatTools?id=${userId}`
   router.push(url)
 }
 
@@ -188,7 +188,7 @@ const handleToPersonDetail = ({ userId }) => {
 }
 
 const handleToInterviewManagement = () => {
-  router.push('/recruit/enterprise/interviewManagement')
+  router.push('/recruit/enterprise/invite/interviewManagement')
 }
 
 const badgeColor = computed(() => (item) => {

+ 2 - 2
src/views/recruit/enterprise/search/retrieval/index.vue

@@ -405,7 +405,7 @@ const handleCommunicate = async (item) => {
   const userId = item.userId
   if (!userId) return
   await talkToUser({userId, text: defaultTextEnt})
-  let url = `/recruit/enterprise/chatTools?id=${userId}`
+  let url = `/recruit/enterprise/invite/chatTools?id=${userId}`
   router.push(url)
 }
 
@@ -436,7 +436,7 @@ const handleSubmit = async () => {
 }
 
 const handleToInterviewManagement = () => {
-  router.push('/recruit/enterprise/interviewManagement')
+  router.push('/recruit/enterprise/invite/interviewManagement')
 }
 
 // 人才详情

+ 1 - 1
src/views/recruit/enterprise/staffInfoSetting/index.vue

@@ -19,7 +19,7 @@
       </template>
     </CtForm>
     <v-btn class="buttons mt-5" color="primary" @click.stop="handleSubmit">{{ $t('common.save') }}</v-btn>
-    <v-btn class="mt-3" color="primary" variant="text" to="/recruit/enterprise/staffChangePassword">修改登录密码</v-btn>
+    <v-btn class="mt-3" color="primary" variant="text" to="/recruit/enterprise/systemManagement/staffChangePassword">修改登录密码</v-btn>
   </v-card>
 
   <Loading :visible="overlay"></Loading>

+ 1 - 1
src/views/recruit/enterprise/talentPool/components/details.vue

@@ -115,7 +115,7 @@ const handleCommunicate = async (item) => {
   const userId = cvData.value.person.userId
   if (!userId) return
   await talkToUser({userId, text: defaultTextEnt})
-  let url = `/recruit/enterprise/chatTools?id=${userId}`
+  let url = `/recruit/enterprise/invite/chatTools?id=${userId}`
   router.push(url)
 }