diff --git a/src/router/index.js b/src/router/index.js index a67e7af..b295903 100644 --- a/src/router/index.js +++ b/src/router/index.js @@ -1,7 +1,6 @@ -import { createRouter, createWebHashHistory } from "vue-router"; - +import { createWebHistory, createRouter } from 'vue-router' /* Layout */ -import Layout from "@/layout"; +import Layout from '@/layout' /** * Note: 路由配置项 @@ -28,204 +27,149 @@ import Layout from "@/layout"; // 公共路由 export const constantRoutes = [ { - path: "/redirect", + path: '/redirect', component: Layout, hidden: true, children: [ { - path: "/redirect/:path(.*)", - component: () => import("@/views/redirect"), - }, - ], + path: '/redirect/:path(.*)', + component: () => import('@/views/redirect/index.vue') + } + ] }, { - path: "/login", - component: () => import("@/views/login"), - hidden: true, + path: '/login', + component: () => import('@/views/login'), + hidden: true }, { - path: "/register", - component: () => import("@/views/register"), - hidden: true, + path: '/register', + component: () => import('@/views/register'), + hidden: true }, { - path: "/404", - component: () => import("@/views/error/404"), - hidden: true, + path: "/:pathMatch(.*)*", + component: () => import('@/views/error/404'), + hidden: true }, { - path: "/401", - component: () => import("@/views/error/401"), - hidden: true, + path: '/401', + component: () => import('@/views/error/401'), + hidden: true }, { - path: "", + path: '', component: Layout, hidden: true, - redirect: "index", + redirect: '/index', children: [ { - path: "index", - component: () => import("@/views/index"), - name: "Index", - meta: { title: "首页", icon: "dashboard", affix: true }, - }, - // { - // path: 'assetsAuth', - // component: () => import('@/views/auditPages/assetsManagement/assetsAuth'), - // name: 'AssetsAuth', - // // meta: { title: '新增资产', icon: 'user', activeMenu: "/assets" } - // meta: { title: '新增资产', icon: 'user', activeMenu: "/assetsManage/assets" } - // } - { - path: "/auditPages/assetsType", - name: "assetsType1", - component: () => import("@/views/components/assetsType/index_v1.vue"), - // meta: { title: '新增资产', icon: 'user', activeMenu: "/assetsManage/assets" } - }, - { - path: "taskInfo", - component: () => import("@/views/taskManagement/info"), - name: "TaskInfo", - meta: { title: "任务详情", icon: "user", activeMenu: "/task2" }, - }, - { - path: "taskAudit", - component: () => import("@/views/auditPages/taskManagement/auditList"), - name: "taskAudit", - meta: { title: "任务审核", icon: "user", activeMenu: "/task" }, - }, - { - path: "taskAuditInfo", - component: () => import("@/views/auditPages/taskManagement/audit"), - name: "taskAuditInfo", - meta: { title: "资产审核", icon: "user", activeMenu: "/task" }, - }, - { - path: "taskAuditInfolishichakan", - component: () => import("@/views/auditPages/taskManagement/audit"), - name: "taskAuditInfolishichakan", - meta: { title: "资产提交记录", icon: "user", activeMenu: "/task" }, - }, - { - path: 'mytaskInfo', - component: () => import('@/views/myTask/info'), - name: 'mytaskInfo', - meta: { title: '任务详情', icon: 'user', activeMenu: "/myTask2" } - }, - { - path: "unitAuth", - component: () => import("@/views/auditPages/unitManagement/index"), - name: "UnitAuth", - meta: { title: "新增单位", icon: "user", activeMenu: "/unit" }, - }, - { - path: "unitAssetsAuth", - component: () => - import("@/views/auditPages/unitAutonomicFill/assetsAuth"), - name: "unitAssetsAuth", - meta: { title: "资产修改", icon: "user", activeMenu: "/unitFill" }, - }, - ], + path: '/index', + component: () => import('@/views/index'), + name: 'Index', + meta: { title: '首页', icon: 'dashboard', affix: true } + } + ] }, { - path: "/user", + path: '/user', component: Layout, hidden: true, - redirect: "noredirect", + redirect: 'noredirect', children: [ { - path: "profile", - component: () => import("@/views/system/user/profile/index"), - name: "Profile", - meta: { title: "个人中心", icon: "user" }, - }, - ], - }, -]; + path: 'profile/:activeTab?', + component: () => import('@/views/system/user/profile/index'), + name: 'Profile', + meta: { title: '个人中心', icon: 'user' } + } + ] + } +] // 动态路由,基于用户权限动态去加载 export const dynamicRoutes = [ { - path: "/system/user-auth", + path: '/system/user-auth', component: Layout, hidden: true, - permissions: ["system:user:edit"], + permissions: ['system:user:edit'], children: [ { - path: "role/:userId(\\d+)", - component: () => import("@/views/system/user/authRole"), - name: "AuthRole", - meta: { title: "分配角色", activeMenu: "/system/user" }, - }, - ], + path: 'role/:userId(\\d+)', + component: () => import('@/views/system/user/authRole'), + name: 'AuthRole', + meta: { title: '分配角色', activeMenu: '/system/user' } + } + ] }, { - path: "/system/role-auth", + path: '/system/role-auth', component: Layout, hidden: true, - permissions: ["system:role:edit"], + permissions: ['system:role:edit'], children: [ { - path: "user/:roleId(\\d+)", - component: () => import("@/views/system/role/authUser"), - name: "AuthUser", - meta: { title: "分配用户", activeMenu: "/system/role" }, - }, - ], + path: 'user/:roleId(\\d+)', + component: () => import('@/views/system/role/authUser'), + name: 'AuthUser', + meta: { title: '分配用户', activeMenu: '/system/role' } + } + ] }, { - path: "/system/dict-data", + path: '/system/dict-data', component: Layout, hidden: true, - permissions: ["system:dict:list"], + permissions: ['system:dict:list'], children: [ { - path: "index/:dictId(\\d+)", - component: () => import("@/views/system/dict/data"), - name: "Data", - meta: { title: "字典数据", activeMenu: "/system/dict" }, - }, - ], + path: 'index/:dictId(\\d+)', + component: () => import('@/views/system/dict/data'), + name: 'Data', + meta: { title: '字典数据', activeMenu: '/system/dict' } + } + ] }, { - path: "/monitor/job-log", + path: '/monitor/job-log', component: Layout, hidden: true, - permissions: ["monitor:job:list"], + permissions: ['monitor:job:list'], children: [ { - path: "index/:jobId(\\d+)", - component: () => import("@/views/monitor/job/log"), - name: "JobLog", - meta: { title: "调度日志", activeMenu: "/monitor/job" }, - }, - ], + path: 'index/:jobId(\\d+)', + component: () => import('@/views/monitor/job/log'), + name: 'JobLog', + meta: { title: '调度日志', activeMenu: '/monitor/job' } + } + ] }, { - path: "/tool/gen-edit", + path: '/tool/gen-edit', component: Layout, hidden: true, - permissions: ["tool:gen:edit"], + permissions: ['tool:gen:edit'], children: [ { - path: "index/:tableId(\\d+)", - component: () => import("@/views/tool/gen/editTable"), - name: "GenEdit", - meta: { title: "修改生成配置", activeMenu: "/tool/gen" }, - }, - ], - }, -]; + path: 'index/:tableId(\\d+)', + component: () => import('@/views/tool/gen/editTable'), + name: 'GenEdit', + meta: { title: '修改生成配置', activeMenu: '/tool/gen' } + } + ] + } +] -// 创建路由 const router = createRouter({ - history: createWebHashHistory(), - scrollBehavior: () => ({ top: 0 }), + history: createWebHistory(), routes: constantRoutes, -}); - -// 防止连续点击多次路由报错的方法在Vue Router 4中不再需要, -// 因为它已经内置处理了这种情况 + scrollBehavior(to, from, savedPosition) { + if (savedPosition) { + return savedPosition + } + return { top: 0 } + }, +}) -export default router; +export default router diff --git a/src/views/assetsManage2/gzhZC-info/index.vue b/src/views/assetsManage2/gzhZC-info/index.vue index 1ec5af5..61c1ab1 100644 --- a/src/views/assetsManage2/gzhZC-info/index.vue +++ b/src/views/assetsManage2/gzhZC-info/index.vue @@ -668,6 +668,7 @@ const ruleFormRef = ref(null); // 从route获取参数 const pageType = route.query.pageType || route.params.pageType; const id = route.query.id || route.params.id; +const routeName = route.query.name; const queryData = route.query || route.params; const loading = ref(false); @@ -799,7 +800,7 @@ async function newAssets() { } function sendBack() { - router.push({ path: "/assetsManage2/gzhZC", params: queryData }); + router.go(-1); } onMounted(async () => { diff --git a/src/views/assetsManage2/gzhZC/index.vue b/src/views/assetsManage2/gzhZC/index.vue index 138d9b1..d985b0b 100644 --- a/src/views/assetsManage2/gzhZC/index.vue +++ b/src/views/assetsManage2/gzhZC/index.vue @@ -592,6 +592,7 @@ const handleAdd = () => { router.push({ path: "/assetsManage2/gzhZC-info", query: { + name: "GzhZC", pageType: "add", type: 2, parentName: "/assetsManage2/gzhZC", @@ -606,6 +607,7 @@ const goInfo = (row, id) => { router.push({ path: "/assetsManage2/gzhZC-info", query: { + name: "GzhZC", pageType: "look", type: 2, id: row.id, @@ -618,6 +620,7 @@ const goInfo = (row, id) => { router.push({ path: "/assetsManage2/gzhZC-info", query: { + name: "GzhZC", pageType: "change", type: 2, id: row.id, diff --git a/src/views/assetsManage2/xcxZC-info/index.vue b/src/views/assetsManage2/xcxZC-info/index.vue index f4e02d2..73ea42a 100644 --- a/src/views/assetsManage2/xcxZC-info/index.vue +++ b/src/views/assetsManage2/xcxZC-info/index.vue @@ -427,6 +427,7 @@ const loading = ref(false); const disabled = ref(false); const pageType = ref(route.query.pageType || ""); const id = ref(route.query.id || ""); +const routeName = route.query.name; const queryData = ref(route.query.queryData || {}); // Rules @@ -482,7 +483,7 @@ const handleSelect = (item) => { }; const sendBack = () => { - router.push({ path: "/assetsManage2/xcxZC", params: queryData }); + router.push({ name: routeName, params: queryData }); }; const newAssets = async () => { diff --git a/src/views/assetsManage2/xcxZC/index.vue b/src/views/assetsManage2/xcxZC/index.vue index 41b2cac..6727dc8 100644 --- a/src/views/assetsManage2/xcxZC/index.vue +++ b/src/views/assetsManage2/xcxZC/index.vue @@ -60,7 +60,7 @@ @@ -134,7 +134,9 @@
- 资产列表(蓝色为单位新增资产) + 资产列表(蓝色为单位新增资产) @@ -404,7 +406,7 @@ +const handleRedirect = () => { + if (hasRedirected.value) return; + + // 从 permissionStore 获取路由 + const routes = permissionStore.defaultRoutes || []; + console.log("当前路由数据:", routes); + + const validRoutes = routes.filter( + (item) => !item.hidden && item.path && item.path !== "/" + ); + + if (validRoutes.length === 0) { + return; + } - + const firstChild = validRoutes[0]?.children?.[0]; + if (!firstChild?.path) { + return; + } + hasRedirected.value = true; + const formatPath = (path) => { + return path.startsWith("/") ? path.slice(1) : path; + }; + + const targetPath = userStore.roles.includes("unit") + ? `/${formatPath(firstChild.path)}` + : `/${formatPath(validRoutes[0].path)}/${formatPath(firstChild.path)}`; + + console.log("跳转至:", targetPath); + router.push(targetPath).catch((err) => { + console.error("路由跳转异常:", err); + }); +}; + +watch( + () => permissionStore.defaultRoutes || [], + (newVal) => { + if (newVal.length > 0) handleRedirect(); + }, + { immediate: true, deep: true } +); + diff --git a/src/views/myAssets/myOfficialAccount/index.vue b/src/views/myAssets/myOfficialAccount/index.vue index f25351e..254a156 100644 --- a/src/views/myAssets/myOfficialAccount/index.vue +++ b/src/views/myAssets/myOfficialAccount/index.vue @@ -311,28 +311,45 @@ function handleExport() { `公众号资产${new Date().getTime()}.xlsx` ); } -function handleAdd() { +const handleAdd = () => { + proxy.setActiveMenu("/myAssets2/myOfficialAccount"); router.push({ - name: "myAssetsAuth", + path: "/assetsManage2/xcxZC-info", query: { pageType: "add", - type: 2, - }, - }); -} -// 查看/编辑详情 -const goInfo = (row, id) => { - router.push({ - name: "myAssetsAuth", - query: { - pageType: id === 1 ? "look" : "change", - type: 2, - id: row.id, - queryData: formInline.value, + type: 1, + queryData: formInline, name: "MyOfficialAccount", }, }); }; +const goInfo = (row, id) => { + if (id === 1) { + proxy.setActiveMenu("/myAssets2/myOfficialAccount"); + router.push({ + path: "/assetsManage2/xcxZC-info", + query: { + name: "MyOfficialAccount", + pageType: "look", + type: 1, + id: row.id, + queryData: formInline.value, + }, + }); + } else if (id === 2) { + proxy.setActiveMenu("/myAssets2/myOfficialAccount"); + router.push({ + path: "/assetsManage2/xcxZC-info", + query: { + name: "MyOfficialAccount", + pageType: "change", + type: 1, + id: row.id, + queryData: formInline.value, + }, + }); + } +}; // 表格行样式 const tableRowClassName = ({ rowIndex }) => { diff --git a/src/views/myAssets/myProgram/index.vue b/src/views/myAssets/myProgram/index.vue index ebfa43a..787637f 100644 --- a/src/views/myAssets/myProgram/index.vue +++ b/src/views/myAssets/myProgram/index.vue @@ -1,6 +1,12 @@ \ No newline at end of file + window.removeEventListener("resize", cancalDebounce); +}); + diff --git a/src/views/myTask/index.vue b/src/views/myTask/index.vue index e3001a8..ce480d0 100644 --- a/src/views/myTask/index.vue +++ b/src/views/myTask/index.vue @@ -316,7 +316,6 @@ const rules = { const tabclicklist = ref([]); // 方法定义 - // 获取列表 function getInfo() { loading.value = true; @@ -416,7 +415,6 @@ function cancalDebounce() { const header = document.getElementById("L-header"); const paginationEl = document.getElementById("L-pagination"); if (!element || !header || !paginationEl) return; - const elementHeight = element.offsetHeight; const headerHeight = header.offsetHeight; const paginationtHeight = paginationEl.offsetHeight; diff --git a/src/views/myTask/info.vue b/src/views/myTask/info.vue index 151bac6..99870cf 100644 --- a/src/views/myTask/info.vue +++ b/src/views/myTask/info.vue @@ -1,538 +1,23 @@ -