index.js 5.98 KB
import Vue from 'vue'
import Router from 'vue-router'

Vue.use(Router)
/* Layout */
import Layout from '@/layout'

/* Router Modules */
// import componentsRouter from './modules/components'

export const constantRoutes = [
  {
    path: '/redirect',
    component: Layout,
    hidden: true,
    children: [
      {
        path: '/redirect/:path(.*)',
        component: () => import('@/views/redirect/index')
      }
    ]
  },
  {
    path: '/404',
    component: () => import('@/views/error-page/404'),
    hidden: true
  },
  { path: '*', redirect: '/404', hidden: true }
]

/**
 * asyncRoutes
 * the routes that need to be dynamically loaded based on user roles
 */
export const asyncRoutes = [
  {
    path: '/',
    component: Layout,
    redirect: '/home',
    meta: { title: '首页', icon: 'fykf' },
    children: [
      {
        path: 'home',
        component: () => import('@/views/home/index'),
        name: 'Dashboard',
        meta: { title: '工作台', icon: 'dashboard', affix: true }
      }
    ]
  },
  {
    path: '/ywbl',
    id: '3',
    parentId: null,
    component: Layout,
    meta: { title: '业务办理', icon: 'fykf' },
    redirect: '/ywbl/ywsq',
    alwaysShow: true,
    name: 'ywbl',
    children: [
      {
        path: 'ywsq',
        id: '4',
        parentId: '3',
        component: () => import('@/views/ywbl/ywsq.vue'),
        name: 'ywsq',
        meta: { title: '业务申请' }
      },
      {
        path: 'dbx',
        id: '5',
        parentId: '3',
        component: () => import('@/views/ywbl/dbx.vue'),
        name: 'dbx',
        meta: { title: '待办箱' }
      },
      {
        path: 'ybx',
        id: '6',
        parentId: '3',
        component: () => import('@/views/ywbl/ybx.vue'),
        name: 'ybx',
        meta: { title: '已办箱' }
      }
    ]
  },
  {
    path: '/sqcx',
    id: '9',
    parentId: null,
    component: Layout,
    meta: { title: '申请查询', icon: 'fykf' },
    redirect: '/sqcx/jtfc',
    alwaysShow: true,
    name: 'sqcx',
    children: [
      {
        path: 'jtfc',
        id: '10',
        parentId: '9',
        component: () => import('@/views/sqcx/jtfc.vue'),
        name: 'jtfc',
        meta: { title: '家庭房产' }
      },
      {
        path: 'dydjb',
        id: '12',
        parentId: '9',
        component: () => import('@/views/sqcx/dydjb.vue'),
        name: 'dydjb',
        meta: { title: '打印登记薄' }
      },
      {
        path: 'cxjl',
        id: '11',
        parentId: '9',
        component: () => import('@/views/sqcx/cxjl.vue'),
        name: 'cxjl',
        meta: { title: '查询记录' }
      }
    ]
  },
  {
    path: '/zhcx',
    id: '13',
    parentId: null,
    component: Layout,
    meta: { title: '综合查询', icon: 'fykf' },
    redirect: '/zhcx/jdcx',
    alwaysShow: true,
    name: 'zhcx',
    children: [
      {
        path: 'jdcx',
        id: '14',
        parentId: '13',
        component: () => import('@/views/zhcx/jdcx.vue'),
        name: 'jdcx',
        meta: { title: '进度查询' }
      },
      {
        path: 'djbcx',
        id: '15',
        parentId: '13',
        component: () => import('@/views/zhcx/djbcx.vue'),
        name: 'djbcx',
        meta: { title: '登记簿查询' }
      },
      {
        path: 'lpcx',
        id: '16',
        parentId: '13',
        component: () => import('@/views/zhcx/lpcx.vue'),
        name: 'lpcx',
        meta: { title: '楼盘查询' }
      }
    ]
  },
  {
    path: '/zsgl',
    id: '17',
    parentId: null,
    component: Layout,
    meta: { title: '证书管理', icon: 'fykf' },
    redirect: '/zsgl/zsrk',
    alwaysShow: true,
    name: 'zsgl',
    children: [
      {
        path: 'zsrk',
        id: '18',
        parentId: '17',
        component: () => import('@/views/zsgl/zsrk.vue'),
        name: 'zsrk',
        meta: { title: '证书入库' }
      },
      {
        path: 'zsff',
        id: '19',
        parentId: '17',
        component: () => import('@/views/zsgl/zsff.vue'),
        name: 'zsff',
        meta: { title: '证书分发' }
      },
      {
        path: 'zssyjl',
        id: '20',
        parentId: '17',
        component: () => import('@/views/zsgl/zssyjl.vue'),
        name: 'zssyjl',
        meta: { title: '证书使用记录' }
      }
    ]
  },
  {
    path: '/system',
    id: '21',
    parentId: null,
    component: Layout,
    meta: { title: '系统管理', icon: 'fykf' },
    redirect: '/system/dictionaries',
    alwaysShow: true,
    name: 'system',
    children: [
      {
        path: 'dictionaries',
        id: '22',
        parentId: '21',
        component: () => import('@/views/system/dictionaries.vue'),
        name: 'dictionaries',
        meta: { title: '字典管理' }
      },
      {
        path: 'menu',
        id: '24',
        parentId: '21',
        component: () => import('@/views/system/menu.vue'),
        name: 'menu',
        meta: { title: '菜单管理' }
      },
      {
        path: 'userOpinion',
        id: '23',
        parentId: '21',
        component: () => import('@/views/system/userOpinion.vue'),
        name: 'userOpinion',
        meta: { title: '用户意见管理' }
      },
      {
        path: 'businessRule',
        id: '23',
        parentId: '21',
        component: () => import('@/views/system/businessRule.vue'),
        name: 'businessRule',
        meta: { title: '业务规则配置' }
      },
      {
        path: 'registrationMaterial',
        id: '23',
        parentId: '21',
        component: () => import('@/views/system/registrationMaterial.vue'),
        name: 'registrationMaterial',
        meta: { title: '登记材料配置' }
      }
    ]
  }
]

const createRouter = () =>
  new Router({
    scrollBehavior: () => ({ y: 0 }),
    routes: [...constantRoutes, ...asyncRoutes]
  })

const router = createRouter()
// Detail see: https://github.com/vuejs/vue-router/issues/1234#issuecomment-357941465
export function resetRouter () {
  const newRouter = createRouter()
  router.matcher = newRouter.matcher // reset router
}

export default router