import { createRouter, createWebHashHistory } from 'vue-router'; import SviLayout from '@/layouts/index-svi.vue' import { useRouteStore } from '@/stores/modules/router'; // 基础路由,不需要权限控制的路由 const baseRoutes = [ { path: '/', name: 'index', component: () => import('@views/main/index.vue'), meta: {title: '空白 '}, }, { path: '/big-screen', name: 'BigScreen', component: () => import('@views/big-screen/bigdata.vue'), meta: {title: '大屏'}, }, { path: '/svi', name: 'Svi', component: SviLayout, meta: {title: '布局'}, children: [ { path: 'index', name: 'SviIndex', component: () => import('@views/main/svi.vue'), meta: { title: '首页', }, }, ], }, { path: '/example', name: 'Example', component: SviLayout, meta: {title: '示例'}, children: [ { path: 'index', name: 'Example1Index', component: () => import('@views/example/example1/index.vue'), meta: { title: '示例', }, }, { path: 'example-business-table', name: 'ExampleBusinessTableIndex', component: () => import('@views/example/example-businesss-table/index.vue'), meta: { title: '业务表格示例', }, }, ], }, { path: '/jbts/login', name: '_jbts_login', component: () => import('@views/jbts/login.vue'), meta: { title: '登录', target: '_blank', openInNewTab: true }, beforeEnter: (to) => { const inNewTab = to.query._nw === '1' if (to.meta && to.meta.openInNewTab && !inNewTab) { const newUrl = `${window.location.origin}${window.location.pathname}#${to.fullPath}${to.fullPath.includes('?') ? '&' : '?'}_nw=1` window.open(newUrl, '_blank') return false } return true } }, { path: '/dtsjygl', name: 'dtsjygl', component: SviLayout, meta: {title: '动态数据管理'}, children: [ { path: 'dtsjk', name: '_dtsjk', component: () => import('@views/dtsjygl/qyxxgl.vue'), meta: { title: '企业信息管理', }, }, { path: 'qyxxcx', name: '_qyxxcx', component: () => import('@views/dtsjygl/qyxxcx.vue'), meta: { title: '企业信息查询', }, }, { path: 'qyxxsb', name: '_qyxxsb', component: () => import('@views/dtsjygl/qyxxsb.vue'), meta: { title: '企业信息上报审核', }, }, { path: 'qyfjfl', name: '_qyfjfl', component: () => import('@views/dtsjygl/qyfjfl.vue'), meta: { title: '企业分级分类', }, }, { path: 'qyxxtj', name: '_qyxxtj', component: () => import('@views/dtsjygl/qyxxtj.vue'), meta: { title: '企业信息统计', }, }, ], }, // 执法机构管理 { path: '/zfjgl', name: 'zfjgl', component: SviLayout, meta: {title: '执法机构管理'}, children: [ { path: 'jgrl', name: '_jgrl', component: () => import('@views/zfjgl/jgrl/index.vue'), meta: { title: '执法机构管理', menuId: 'A-610100000000-0005_0197', icon: 'zyyy_rzzx' }, }, { path: 'zfrygl', name: '_zfrygl', component: () => import('@views/zfjgl/zfrygl.vue'), meta: { title: '执法人员管理', }, }, { path: 'zfzbgl', name: '_zfjgl_zfzbgl', component: () => import('@views/zbgl/zfzbgl.vue'), meta: { title: '执法装备管理' } }, { path: 'zfclgl', name: '_zfjgl_zfclgl', component: () => import('@views/zbgl/zfclgl.vue'), meta: { title: '执法车辆管理' } }, { path: 'jcbgl', name: '_zfjgl_jcbgl', component: () => import('@views/xzzfgl/jcbgl.vue'), meta: { title: '检查表管理', }, }, { path: 'jcsxgl', name: '_zfjgl_jcsxgl', component: () => import('@views/xzzfgl/jcsxgl.vue'), meta: { title: '自定义检查事项', }, }, ], }, { path: '/xzzfgl', name: 'xzzfgl', component: SviLayout, meta: {title: '行政执法'}, children: [ { path: 'zfxxgl', name: '_zfxxgl', component: () => import('@views/xzzfgl/zfxxgl.vue'), meta: { title: '执法案件资源池', }, }, { path: 'zfjc', name: '_zfj', meta: { title: '行政检查', }, children: [ { path: 'dzjcfa', name: '_dzjcfa', component: () => import('@views/xzzfgl/dzjcfa.vue'), meta: { title: '定制检查方案', }, }, { path: 'fasp', name: '_fasp', component: () => import('@views/xzzfgl/fasp.vue'), meta: { title: '方案审批', }, }, { path: 'zfjc', name: '_zfjc_menu', component: () => import('@views/xzzfgl/zfjc.vue'), meta: { title: '现场检查', }, }, { path: 'zgfc', name: '_zgfc_menu', component: () => import('@views/xzzfgl/zgfc.vue'), meta: { title: '整改复查', }, }, { path: 'xcclcs', name: '_xcclcs_menu', component: () => import('@views/xzzfgl/xcclcs.vue'), meta: { title: '现场处理措施', }, }, { path: 'xzjccl', name: '_xzjccl_menu', component: () => import('@views/xzzfgl/xzjccl.vue'), meta: { title: '行政检查处理', }, }, ] }, { path: 'xzcf', name: '_xzcf', meta: { title: '行政处罚', }, children: [ { path: 'zfla', name: '_zfla', component: () => import('@views/xzzfgl/zfla.vue'), meta: { title: '立案', }, }, { path: 'dcqz', name: '_dcqz', component: () => import('@views/xzzfgl/caseInquiry.vue'), meta: { title: '调查取证', }, }, { path: 'fxyp', name: '_fxyp', component: () => import('@views/xzzfgl/fxyp.vue'), meta: { title: '审理', }, }, { path: 'cssbhtz', name: '_cssbhtz', component: () => import('@views/xzzfgl/cssbhtz.vue'), meta: { title: '陈述申辩或听证', }, }, { path: 'gz', name: '_gz', component: () => import('@views/xzzfgl/caseInform.vue'), meta: { title: '告知', }, }, { path: 'fzsh', name: '_fzsh', component: () => import('@views/xzzfgl/fzshjzfjd.vue'), meta: { title: '法制审核', }, }, { path: 'jttl', name: '_jttl', component: () => import('@views/xzzfgl/jttl.vue'), meta: { title: '集体讨论', }, }, { path: 'zfjd', name: '_zfjd', component: () => import('@views/xzzfgl/zfjd.vue'), meta: { title: '决定', }, }, { path: 'zfzx', name: '_zfzx', component: () => import('@views/xzzfgl/zfzx.vue'), meta: { title: '执行', }, }, { path: 'zfja', name: '_zfja', component: () => import('@views/xzzfgl/zfja.vue'), meta: { title: '结案', }, }, ] }, { path: 'zdzfjh', name: '_zdzfjh', meta: { title: '监督检查计划', }, children: [ { path: 'zdjcqyqd', name: '_zdjcqyqd', component: () => import('@views/xzzfgl/zdjcqyqd.vue'), meta: { title: '年度监督检查计划', }, }, { path: 'scssjygkqd', name: '_scssjygkqd', component: () => import('@views/xzzfgl/scssjygkqd.vue'), meta: { title: '双随机一公开计划', }, }, { path: 'zfjhrwgl', name: '_zfjhrwgl', component: () => import('@views/xzzfgl/zfjhrwgl.vue'), meta: { title: '计划审批', }, }, ] }, { path: 'ddjcjh', name: '_ddjcjh', meta: { title: '督导检查计划', }, children: [ { path: 'ddjc', name: 'ddjc', component: () => import('@views/xzzfgl/ddjc.vue'), meta: { title: '督导检查', }, }, { path: 'ddjcsp', name: 'ddjcsp', component: () => import('@views/xzzfgl/ddjcsp.vue'), meta: { title: '督导检查审批', }, }, { path: 'ddjcrwgl', name: '_ddjcrwgl', component: () => import('@views/xzzfgl/ddjcrwgl.vue'), meta: { title: '督导检查任务管理', }, }, ] }, { path: 'jbhcxx', name: '_jbhcxx', component: () => import('@views/xzzfgl/jbhcxx.vue'), meta: { title: '举报核查', }, }, { path: 'jchcjh', name: '_jchcjh', meta: { title: '交叉检查计划', }, children: [ { path: 'jchc', name: '_jchc', component: () => import('@views/xzzfgl/jchc.vue'), meta: { title: '交叉检查', }, }, { path: 'jchcrwgl', name: '_jchcrwgl', component: () => import('@views/xzzfgl/jchcrwgl.vue'), meta: { title: '交叉检查任务管理', }, }, ] }, // { // path: 'smrq', // name: '_smrq', // component: () => import('@views/xzzfgl/smrq.vue'), // meta: { // title: '扫码入企', // }, // }, { path: 'jcbgl', name: '_jcbgl', component: () => import('@views/xzzfgl/jcbgl.vue'), meta: { title: '检查表管理', }, }, { path: 'jcsxgl', name: '_jcsxgl', component: () => import('@views/xzzfgl/jcsxgl.vue'), meta: { title: '自定义检查事项', }, }, { path: 'zfwsgl', name: '_zfwsgl', component: () => import('@views/xzzfgl/zfwsgl.vue'), meta: { title: '执法文书管理', }, }, { path: 'caseList', name: '_caseList', component: () => import('@views/xzzfgl/caseList.vue'), meta: { title: '案卷资料清单', }, }, ], }, { path: '/fxczfgl', name: 'fxczfgl', component: SviLayout, meta: {title: '非现场执法'}, children: [ { path: 'index', name: '_index', component: () => import('@views/fxczfgl/index.vue'), meta: { title: '非现场执法管理' } }, { path: 'zxxcxx', name: '_zxxcxx', component: () => import('@views/fxczfgl/zxxcxx.vue'), meta: { title: '在线巡查信息' } }, { path: 'zxxcqd', name: '_zxxcqd', meta: { title: '在线巡查启动' }, children: [ { path: 'sjzxxc', name: '_sjzxxc', component: () => import('@views/fxczfgl/sjzxxc.vue'), meta: { title: '随机在线巡查', }, }, { path: 'dzzxxc', name: '_dzzxxc', component: () => import('@views/fxczfgl/dzzxxc.vue'), meta: { title: '定制在线巡查', }, } ] }, { path: 'zxxcsp', name: '_zxxcsp', component: () => import('@views/fxczfgl/zxxcsp.vue'), meta: { title: '在线巡查结果' } }, { path: 'fxczftj', name: '_fxczftj', component: () => import('@views/fxczfgl/fxczftj.vue'), meta: { title: '非现场执法统计' } } ], }, { path: '/zfwssd', name: 'zfwssd', component: SviLayout, meta: {title: '执法文书'}, children: [ { path: 'sdfsgl', name: '_sdfsgl', component: () => import('@views/zfwssd/sdfsgl.vue'), alias: '/xzzfgl/wssd/sdfsgl', meta: { title: '送达方法管理' } }, { path: 'ssdrgl', name: '_ssdrgl', component: () => import('@views/zfwssd/ssdrgl.vue'), alias: '/xzzfgl/wssd/ssdrgl', meta: { title: '受送达人管理' } }, { path: 'zfwsxx', name: '_zfwsxx', component: () => import('@views/zfwssd/zfwsxx.vue'), alias: '/xzzfgl/wssd/zfwsxx', meta: { title: '执法文书管理' } }, { path: 'sdywtj', name: '_sdywtj', component: () => import('@views/zfwssd/sdywtj.vue'), alias: '/xzzfgl/wssd/sdywtj', meta: { title: '送达业务统计' } }, ], }, { path: '/dagl', name: 'dagl', component: SviLayout, meta: {title: '档案管理'}, children: [ { path: 'xzjcdagl', name: '_xzjcdagl', component: () => import('@views/xzzfgl/xzjcdagl.vue'), alias: '/xzzfgl/ljgd/xzjcdagl', meta: { title: '行政检查档案' } }, { path: 'xzcfdagl', name: '_xzcfdagl', component: () => import('@views/xzzfgl/xzcfdagl.vue'), alias: '/xzzfgl/ljgd/xzcfdagl', meta: { title: '行政执法档案' } }, { path: 'caseList', name: '_caseList', component: () => import('@views/xzzfgl/caseList.vue'), alias: '/xzzfgl/ljgdl/caseList', meta: { title: '案卷资料清单', }, }, ], }, { path: '/zbgl', name: 'zbgl', component: SviLayout, meta: {title: '装备管理'}, children: [ { path: 'zfzbgl', name: '_zfzbgl', component: () => import('@views/zbgl/zfzbgl.vue'), meta: { title: '执法装备管理' } }, { path: 'zsfzgl', name: '_zsfzgl', component: () => import('@views/zbgl/zsfzgl.vue'), meta: { title: '制式服装管理' } }, { path: 'zfclgl', name: '_zfclgl', component: () => import('@views/zbgl/zfclgl.vue'), meta: { title: '执法车辆管理' } }, ], }, { path: '/tztg', name: 'tztg', component: SviLayout, meta: {title: '通知公告'}, children: [ { path: 'tztggl', name: '_tztggl', component: () => import('@views/tztggl/NoticeManager.vue'), meta: { title: '执法装备管理' } } ], }, { path: '/tjbb', name: 'tjbb', component: SviLayout, meta: {title: '统计分析'}, children: [ { path: 'qxtjsb', name: '_qxtjsb', meta: { title: '区县统计上报', }, children: [ { path: 'zflasb', name: '_zflasb', component: () => import('@views/dtsjygl/zflasb.vue'), meta: { title: '执法立案上报', }, }, { path: 'zfjcsb', name: '_zfjcsb', component: () => import('@views/dtsjygl/zfjcsb.vue'), meta: { title: '执法检查上报', }, }, { path: 'lszfsb', name: '_lszfsb', component: () => import('@views/dtsjygl/lszfjlsb.vue'), meta: { title: '历史执法信息上报', }, } ] }, { path: 'qxtjsbsp', name: '_qxtjsbsp', meta: { title: '区县统计上报审核', }, children: [ { path: 'zflasbsp', name: '_zflasbsp', component: () => import('@views/dtsjygl/zflasbsp.vue'), meta: { title: '执法立案上报审核', }, }, { path: 'zfjcsbsp', name: '_zfjcsbsp', component: () => import('@views/dtsjygl/zfjcsbsp.vue'), meta: { title: '执法检查上报审核', }, }, { path: 'lszfjlsbsp', name: '_lszfjlsbsp', component: () => import('@views/dtsjygl/lszfjlsbsp.vue'), meta: { title: '历史执法信息上报审核', }, } ] }, { path: 'zflatj', name: '_zflatj', component: () => import('@views/dtsjygl/zflatj.vue'), meta: { title: '执法立案统计' } }, { path: 'zfjcqktj', name: '_zfjcqktj', component: () => import('@views/dtsjygl/zfjcqktj.vue'), meta: { title: '检查情况统计' } }, { path: 'zfsjzbb', name: '_zfsjzbb', component: () => import('@views/dtsjygl/zfsjzbb.vue'), meta: { title: '执法数据周报表' } }, { path: 'zfsjjbb', name: '_zfsjjbb', component: () => import('@views/dtsjygl/zfsjjbb.vue'), meta: { title: '执法数据季报表' } }, { path: 'qyxxStatice', name: '_qyxxStatice', component: () => import('@views/dtsjygl/qyxxtj.vue'), meta: { title: '企业信息统计', }, }, { path: 'fxczfStatice', name: '_fxczfStatice', component: () => import('@views/fxczfgl/fxczftj.vue'), meta: { title: '非现场执法统计' } } , { path: 'wssdtj', name: '_wssdtj', component: () => import('@views/zfwssd/sdywtj.vue'), meta: { title: '送达业务统计' } }, ], }, // 投诉举报 { path: '/jbts', name: 'jbts', component: SviLayout, meta: {title: '举报投诉'}, children: [ { path: 'tsjbkb', name: '_tsjbkb', component: () => import('@views/jbts/ComplaintReportBoard.vue'), meta: { title: '投诉举报看板' } }, { path: 'jbhcxx', name: '_jbhcxx', component: () => import('@views/xzzfgl/jbhcxx.vue'), meta: { title: '举报核查' } } ] }, ] // 创建路由实例 const router = createRouter({ history: createWebHashHistory(), routes: baseRoutes }) // 标记路由是否已经初始化 let routesInitialized = false // 动态添加路由方法 export function addDynamicRoutes() { const routeStore = useRouteStore(); // 确保路由存储已初始化默认路由 if (routeStore.defaultRoutes.length === 0) { routeStore.initDefaultRoutes(); } const dynamicRoutes = routeStore.defaultRoutes || []; console.log('开始加载动态路由,当前路由表:', router.getRoutes().map(r => r.path)); console.log('动态路由数据:', JSON.stringify(dynamicRoutes, null, 2)); // 先清除所有非基础路由 router.getRoutes().forEach(route => { if (!baseRoutes.some(r => r.name === route.name)) { router.removeRoute(route.name); } }); // 如果有动态路由,添加到路由表中 if (dynamicRoutes && dynamicRoutes.length > 0) { dynamicRoutes.forEach(route => { console.log('正在添加路由:', route.path, route.name); try { if (!router.hasRoute(route.name)) { router.addRoute(route); console.log('成功添加路由:', route.path); } else { console.log('路由已存在,跳过:', route.path); } } catch (error) { console.error('添加路由失败:', route.path, error); } }); console.log('动态路由加载完成,更新后的路由表:', router.getRoutes().map(r => r.path)); // 标记路由已初始化 routesInitialized = true; } else { console.warn('没有可用的动态路由数据!'); } return dynamicRoutes; } // 全局前置导航守卫,在路由跳转前进行检查 router.beforeEach(async (to, from, next) => { console.log('路由跳转:', from.path, '->', to.path); console.log('当前路由表:', router.getRoutes().map(r => r.path)); // 直接放行 next(); }); export function setupRouter(app) { // 创建路由实例 app.use(router); // 在路由初始化时就加载所有路由 try { // 强制加载动态路由,无论是否已经初始化 // addDynamicRoutes(); // 打印当前路由表信息 console.log('路由初始化完成,当前路由表:', router.getRoutes().map(r => r.path)); // 确保路由已初始化 routesInitialized = true; } catch (error) { console.error('路由初始化错误:', error); } }