routes.js 4.89 KB
import layoutHeaderAside from '@/layout/header-aside'

// 由于懒加载页面太多的话会造成webpack热更新太慢,所以开发环境不使用懒加载,只有生产环境使用懒加载
const _import = require('@/libs/util.import.' + process.env.NODE_ENV)

/**
 * 在主框架内显示(children 由后台返回资源点集合 从 resources 中动态过滤加载)
 */
const frameIn = [{
  path: '/',
  redirect: {
    name: 'index'
  },
  component: layoutHeaderAside,
  children: []
}]
/**
 * 首页
 * icon:element-ui
 */
export const home = {
  path: '/index',
  name: 'index',
  icon: 's-home',
  meta: {
    title: '预录客户',
    authId: '901',
    parentId: '1',
    cache: true
  },
  component: _import('flow/editCustomer')
}
export const sys = [
  // 刷新页面 必须保留
  {
    path: '/refresh',
    name: 'refresh',
    hidden: true,
    component: _import('system/function/refresh')
  },
  // 页面重定向 必须保留
  {
    path: 'redirect/:route*',
    name: 'redirect',
    hidden: true,
    component: _import('system/function/redirect')
  }
]

/**
 * 所有需动态过滤的资源点
 * 101 - 工作台
 * 102 - 流量管理
 * 103 - 商品库
 * 104 - 订单管理
 * 105 - 财务管理
 * 106 - 系统设置
 */
export const resources = {
  '903': {
    path: '/goods',
    name: 'goods',
    icon: 'document',
    meta: {
      title: '商品库',
      authId: '903',
      parentId: '1',
      cache: true
    }
  },
  '90301': {
    path: '/product',
    name: 'product',
    icon: 'document',
    meta: {
      title: '产品管理',
      authId: '90301',
      parentId: '903',
      cache: true
    },
    auth: [{
      authId: '9030101',
      parentId: '90301',
      label: '新增商品',
      category: 'Button',
      type: 'primary',
      handle: 'handleAdd'
    },
    // {
    //   authId: '1030102',
    //   parentId: '10301',
    //   label: '导出',
    //   category: 'Button',
    //   handle: 'handleExport'
    // },
    {
      authId: '9030102',
      parentId: '90301',
      label: '修改',
      handle: 'handleEdit'
    }],
    component: _import('goods/product')
  },
  '90304': {
    path: '/editProduct',
    name: 'editProduct',
    icon: 'document',
    meta: {
      title: '产品编辑',
      authId: '90304',
      parentId: '903',
      cache: true,
      sideHidden: true
    },
    component: _import('goods/editProduct')
  },
  '90302': {
    path: '/commodity',
    name: 'commodity',
    icon: 'document',
    meta: {
      title: '商品管理',
      authId: '90302',
      parentId: '903',
      cache: true
    },
    auth: [{
      authId: '9030201',
      parentId: '90302',
      label: '新增商品',
      category: 'Button',
      type: 'primary',
      handle: 'handleAdd'
    }, {
      authId: '9030202',
      parentId: '90302',
      label: '导出',
      category: 'Button',
      handle: 'handleExport'
      // rule:{0: '上架',}
    }, {
      authId: '9030203',
      parentId: '90302',
      label: '编辑',
      handle: 'handleEdit'
    }, {
      authId: '9030204',
      parentId: '90302',
      label: '查看门店',
      handle: 'handleDetail'
    }],
    component: _import('goods/commodity')
  },
  '90305': {
    path: '/editCommodity',
    name: 'editCommodity',
    icon: 'document',
    meta: {
      title: '商品编辑',
      authId: '90305',
      parentId: '903',
      // cache: true,
      sideHidden: true
    },
    component: _import('goods/editCommodity')
  },
  '906': {
    path: '/systemConfig',
    name: 'systemConfig',
    icon: 'document',
    meta: {
      title: '系统设置',
      authId: '906',
      parentId: '1',
      cache: true
    }
  },
  '90601': {
    path: '/personalInfo',
    name: 'personalInfo',
    icon: 'document',
    meta: {
      title: '个人信息',
      authId: '90601',
      parentId: '906',
      cache: true
    },
    component: _import('systemConfig/personalInfo')
  },
  '90602': {
    path: '/serviceStore',
    name: 'serviceStore',
    icon: 'document',
    meta: {
      title: '服务4s店',
      authId: '90602',
      parentId: '906',
      cache: true
    },
    auth: [{
      authId: '9060201',
      parentId: '90602',
      label: '新增服务门店',
      category: 'Button',
      type: 'primary',
      handle: 'handleAdd'
    }, {
      authId: '9060202',
      parentId: '90602',
      label: '删除',
      handle: 'handleDelete'
    }],
    component: _import('systemConfig/serviceStore')
  }
}

/**
 * 在主框架之外显示
 */
const frameOut = [
  // 登录
  {
    path: '/login',
    name: 'login',
    component: _import('system/login')
  }
]

/**
 * 错误页面
 */
export const errorPage = {
  path: '*',
  name: '404',
  component: _import('system/error/404')
}

// 导出需要显示菜单的
export const frameInRoutes = frameIn

export const localRoutes = {
  ...resources, [home.meta.authId]: home
}

// 重新组织后导出
export default [
  ...frameOut,
  errorPage
]