diff --git a/src/store/modules/permission.ts b/src/store/modules/permission.ts index d58407ca..b1de8ada 100644 --- a/src/store/modules/permission.ts +++ b/src/store/modules/permission.ts @@ -168,6 +168,53 @@ export const usePermissionStore = defineStore({ } return newPath; }; + const childRoute = (childData) => { + const modules = import.meta.glob('../../views/**/**/**/index.vue'); + childData.forEach((element) => { + // 菜单里配置带参数,但没有单独的主路由,先注册主路由 + if (element.item.status == 1 && element.item.url.indexOf('@') > 0) { + const path = element.item.url.substring(0, element.item.url.indexOf('@')); + router.addRoute('Root', { + path: path, + name: element.item.code, + meta: { + title: element.item.name, + icon: element.item.iconName, + hideChildrenInMenu: true, + elements: element.item.elements, + }, + component: LAYOUT, + children: [ + { + path: path + '/:id', + name: element.item.url.replaceAll('/', ''), + meta: { + title: element.item.name, + icon: element.item.iconName, + elements: element.item.elements, + }, + component: modules['../../views/demo' + path + '/index.vue'], + }, + ], + }); + } else if (element.item.code && element.item.status == 1) { + router.addRoute(element.item.code, { + path: element.item.url, + name: element.item.url.replaceAll('/', ''), + meta: { + title: element.item.name, + icon: element.item.iconName, + elements: element.item.elements, + }, + // component: () => import('../../views/demo' + element.item.url + '/index.vue') + component: modules['../../views/demo' + element.item.url + '/index.vue'], + }); + } + if (element.children && element.children.length > 0) { + childRoute(element.children); + } + }); + }; // 注册路由 const registeredRoute = (data) => { const modules = import.meta.glob('../../views/**/**/**/index.vue'); @@ -185,7 +232,7 @@ export const usePermissionStore = defineStore({ }); } else { // 正常菜单 - if (data.children.length == 0 && data.item.parentId == 0 && data.item.status == 1) { + if (data.children.length == 0 && data.item.status == 1) { // 没有子菜单 if (data.item.url.indexOf('@') > 0) { //给带参数的路由先注册主路由 @@ -257,51 +304,11 @@ export const usePermissionStore = defineStore({ : modules['../../views/demo' + data.item.url + '/index.vue'], }); if (data.children && data.children.length > 0) { - data.children.forEach((element) => { - // 菜单里配置带参数,但没有单独的主路由,先注册主路由 - if (element.item.status == 1 && element.item.url.indexOf('@') > 0) { - const path = element.item.url.substring(0, element.item.url.indexOf('@')); - router.addRoute('Root', { - path: path, - name: element.item.code, - meta: { - title: element.item.name, - icon: element.item.iconName, - hideChildrenInMenu: true, - elements: element.item.elements, - }, - component: LAYOUT, - children: [ - { - path: path + '/:id', - name: element.item.url.replaceAll('/', ''), - meta: { - title: element.item.name, - icon: element.item.iconName, - elements: element.item.elements, - }, - component: modules['../../views/demo' + path + '/index.vue'], - }, - ], - }); - } else if (element.item.code && element.item.status == 1) { - router.addRoute(element.item.code, { - path: element.item.url, - name: element.item.url.replaceAll('/', ''), - meta: { - title: element.item.name, - icon: element.item.iconName, - elements: element.item.elements, - }, - // component: () => import('../../views/demo' + element.item.url + '/index.vue') - component: modules['../../views/demo' + element.item.url + '/index.vue'], - }); - } - }); + childRoute(data.children); } } } - // console.log(router.getRoutes()) + // console.log(router.getRoutes()); }; //通过后端获取菜单 diff --git a/src/views/demo/task/completed/index.vue b/src/views/demo/task/completed/index.vue index 8c39c793..8e2e2b7f 100644 --- a/src/views/demo/task/completed/index.vue +++ b/src/views/demo/task/completed/index.vue @@ -56,7 +56,7 @@ const processId = ref(''); const route = useRoute(); // searchInfo.category = route.query.category; - searchInfo.category = route.params?.id; + searchInfo.category = route.params?.id == 'all' ? '' : route.params?.id; const [registerTable, { reload }] = useTable({ api: getLoadMyCompletedPage, diff --git a/src/views/demo/task/uncompleted/index.vue b/src/views/demo/task/uncompleted/index.vue index 40aa5848..57fbf30c 100644 --- a/src/views/demo/task/uncompleted/index.vue +++ b/src/views/demo/task/uncompleted/index.vue @@ -75,7 +75,7 @@ const childRecord = ref(); const route = useRoute(); // searchInfo.category = route.query.category; - searchInfo.category = route.params?.id; + searchInfo.category = route.params?.id == 'all' ? '' : route.params?.id; const [registerTable, { reload }] = useTable({ api: getLoadMyUncompletedPage, columns: [