loulijun2021
2022-06-17 20c96f3dab1a3d9e10996a0580ef157293d45e06
修改路由匹配code  显示后端返回name值
已修改2个文件
114 ■■■■ 文件已修改
src/layout/components/Sidebar/index.vue 44 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/router/index.js 70 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/layout/components/Sidebar/index.vue
@@ -25,7 +25,9 @@
      </el-menu>
    </el-scrollbar>
    <div style="position: absolute;bottom: 20px;left: 30px;">
      <div><el-button type="text">新凯迪制造V1.0.01</el-button></div>
      <div>
        <el-button type="text">新凯迪制造V1.0.01</el-button>
      </div>
    </div>
  </div>
@@ -49,7 +51,7 @@
  async created() {
    const { data: res } = await LoginMenu()
    this.routers = res
    this.routers.unshift({ name: '系统首页' })
    this.routers.unshift({ code: '1000', name: '系统设置' })
  },
  computed: {
    ...mapGetters([
@@ -57,14 +59,17 @@
      'sidebar'
    ]),
    routes() {
      const newArr = []
      const newCodeArr = []
      const newCodeNameArr = []
      this.routers.forEach(item => {
        if (item.name) {
          newArr.push(item.name)
        if (item.code) {
          newCodeArr.push(item.code)
          newCodeNameArr.push({ code: item.code, title: item.name })
          if (item.children) {
            item.children.forEach(it => {
              if (it.name) {
                newArr.push(it.name)
              if (it.code) {
                newCodeArr.push(it.code)
                newCodeNameArr.push({ code: it.code, title: it.name })
              }
            })
          }
@@ -73,13 +78,23 @@
      const arr = this.$router.options.routes
      const arr2 = []
      arr.forEach((item, index) => {
        if (newArr.includes(item.name) && item.children.length === 1) {
        if (newCodeArr.includes(item.code) && item.children.length === 1) {
          arr2.push(item)
        } else if (newArr.includes(item.name) && item.children.length > 1) {
        } else if (newCodeArr.includes(item.code) && item.children.length > 1) {
          newCodeNameArr.forEach(it1 => { // 替换接口中的name为菜单名称
            if (it1.code === item.code) {
              item.meta.title = it1.title
            }
          })
          const a = []
          item.children.forEach((it, ind) => {
            if (newArr.includes(it.name)) {
              a.push(it)
          item.children.forEach((it2, ind) => { // 遍历
            if (newCodeArr.includes(it2.code)) {
              newCodeNameArr.forEach(it1 => { // 替换接口中的name为菜单名称
                if (it2.code === it1.code) {
                  it2.meta.title = it1.title
                }
              })
              a.push(it2)
            }
          })
          item.children = a
@@ -115,6 +130,7 @@
  color: white ;
  font-size: 18px ;
}
#app .sidebar-container .el-submenu .el-menu-item {
  background-color: transparent !important;
}
@@ -123,6 +139,7 @@
  background: $main_color !important;
  color: #fff !important;
}
#app .sidebar-container .el-submenu .el-menu-item:hover{
  background: $main_color !important;
  //color: #fff !important;
@@ -135,12 +152,15 @@
.sub-el-icon::before{
  color: $main_color;
}
.svg-icon{
  color: $main_color;
}
.submenu-title-noDropdown{
  font-weight: bolder;
}
.router-link-exact-active>.submenu-title-noDropdown{
  color: $main_color !important;
}
src/router/index.js
@@ -58,6 +58,7 @@
    component: Layout,
    redirect: '/index',
    name: '系统首页',
    code: '1000',
    children: [{
      path: 'index',
      name: 'index',
@@ -70,31 +71,37 @@
    component: Layout,
    redirect: '/jcsz/zzjg',
    name: '基础设置',
    code: '1001',
    meta: { title: '基础设置', icon: 'tree' },
    children: [
      {
        path: 'zzjg',
        name: '组织架构',
        code: '1010',
        component: () => import('@/views/jcsz/zzjg'),
        meta: { title: '组织架构', icon: '' }
      }, {
        path: 'jsqd',
        name: '角色清单',
        component: () => import('@/views/jcsz/jsqd'),
        meta: { title: '角色清单', icon: '' }
      }, {
        path: 'yhqd',
        name: '用户清单',
        code: '1011',
        component: () => import('@/views/jcsz/yhqd'),
        meta: { title: '用户清单', icon: '' }
      }, {
        path: 'jsqd',
        name: '角色清单',
        code: '1012',
        component: () => import('@/views/jcsz/jsqd'),
        meta: { title: '角色清单', icon: '' }
      }, {
        path: 'wldw',
        name: '往来单位',
        code: '1013',
        component: () => import('@/views/jcsz/wldw'),
        meta: { title: '往来单位', icon: '' }
      }, {
        path: 'adsz',
        name: '安灯设置',
        code: '1014',
        component: () => import('@/views/jcsz/adsz'),
        meta: { title: '安灯设置', icon: '' }
      }
@@ -105,63 +112,74 @@
    component: Layout,
    redirect: '/sbgl/sblx',
    name: '设备管理',
    code: '1002',
    meta: { title: '设备管理', icon: 'example' },
    children: [
      {
        path: 'sblx',
        name: '设备类型',
        code: '1020',
        component: () => import('@/views/sbgl/sblx'),
        meta: { title: '设备类型', icon: '' }
      },
      {
        path: 'wxjl',
        code: '1029',
        name: '维修记录',
        component: () => import('@/views/sbgl/wxjl'),
        meta: { title: '维修记录', icon: '' }
      }, {
        path: 'sbz',
        name: '设备组',
        code: '1021',
        component: () => import('@/views/sbgl/sbz'),
        meta: { title: '设备组', icon: '' }
      }, {
        path: 'sbqd',
        name: '设备清单',
        code: '1022',
        component: () => import('@/views/sbgl/sbqd'),
        meta: { title: '设备清单', icon: '' }
      },
      {
        path: 'djbz',
        name: '点检标准',
        code: '1023',
        component: () => import('@/views/sbgl/djbz'),
        meta: { title: '点检标准', icon: '' }
      },
      {
        path: 'djbw',
        name: '点检部位',
        code: '1024',
        component: () => import('@/views/sbgl/djbw'),
        meta: { title: '点检部位', icon: '' }
      },
      {
        path: 'bybz',
        name: '保养标准',
        code: '1025',
        component: () => import('@/views/sbgl/bybz'),
        meta: { title: '保养标准', icon: '' }
      },
      {
        path: 'bybw',
        name: '保养部位',
        code: '1026',
        component: () => import('@/views/sbgl/bybw'),
        meta: { title: '保养部位', icon: '' }
      },
      {
        path: 'djjl',
        name: '点检记录',
        code: '1027',
        component: () => import('@/views/sbgl/djjl'),
        meta: { title: '点检记录', icon: '' }
      },
      {
        path: 'byjl',
        name: '保养记录',
        code: '1028',
        component: () => import('@/views/sbgl/byjl'),
        meta: { title: '保养记录', icon: '' }
      }
@@ -172,61 +190,73 @@
    component: Layout,
    redirect: '/gzgl/gzlx',
    name: '工装管理',
    code: '1003',
    meta: { title: '工装管理', icon: 'component' },
    children: [
      {
        path: 'gzlx',
        name: '工装类型',
        code: '1030',
        component: () => import('@/views/gzgl/gzlx'),
        meta: { title: '工装类型', icon: '' }
      }, {
        path: 'sjxj',
        name: '上机下机',
        code: '1039',
        component: () => import('@/views/gzgl/sjxj'),
        meta: { title: '上机下机', icon: '' }
      }, {
        path: 'ckrk',
        name: '出库入库',
        code: '1040',
        component: () => import('@/views/gzgl/ckrk'),
        meta: { title: '出库入库', icon: '' }
      }, {
        path: 'gzqd',
        name: '工装清单',
        code: '1031',
        component: () => import('@/views/gzgl/gzqd'),
        meta: { title: '工装清单', icon: '' }
      }, {
        path: 'djbz',
        name: '点检标准',
        code: '1032',
        component: () => import('@/views/gzgl/djbz'),
        meta: { title: '点检标准', icon: '' }
      }, {
        path: 'djbw',
        name: '点检部位',
        code: '1033',
        component: () => import('@/views/gzgl/djbw'),
        meta: { title: '点检部位', icon: '' }
      }, {
        path: 'bybz',
        name: '保养标准',
        code: '1034',
        component: () => import('@/views/gzgl/bybz'),
        meta: { title: '保养标准', icon: '' }
      }, {
        path: 'bybw',
        name: '保养部位',
        code: '1035',
        component: () => import('@/views/gzgl/bybw'),
        meta: { title: '保养部位', icon: '' }
      }, {
        path: 'djjl',
        name: '点检记录',
        code: '1036',
        component: () => import('@/views/gzgl/djjl'),
        meta: { title: '点检记录', icon: '' }
      }, {
        path: 'byjl',
        name: '保养记录',
        code: '1037',
        component: () => import('@/views/gzgl/byjl'),
        meta: { title: '保养记录', icon: '' }
      }, {
        path: 'gzwx',
        name: '工装维修',
        code: '1038',
        component: () => import('@/views/gzgl/gzwx'),
        meta: { title: '工装维修', icon: '' }
      }
@@ -237,37 +267,44 @@
    component: Layout,
    redirect: '/wlgl/ckdy',
    name: '物料管理',
    code: '1004',
    meta: { title: '物料管理', icon: 'table' },
    children: [
      {
        path: 'ckdy',
        name: '仓库定义',
        code: '1050',
        component: () => import('@/views/wlgl/ckdy'),
        meta: { title: '仓库定义', icon: '' }
      },
      {
        path: 'kwdy',
        name: '库位定义',
        code: '1051',
        component: () => import('@/views/wlgl/kwdy'),
        meta: { title: '库位定义', icon: '' }
      }, {
        path: 'rqlx',
        name: '容器类型',
        code: '1052',
        component: () => import('@/views/wlgl/rqlx'),
        meta: { title: '容器类型', icon: '' }
      }, {
        path: 'rqqd',
        name: '容器清单',
        code: '1053',
        component: () => import('@/views/wlgl/rqqd'),
        meta: { title: '容器清单', icon: '' }
      }, {
        path: 'crkjl',
        name: '出入库记录',
        code: '1054',
        component: () => import('@/views/wlgl/crkjl'),
        meta: { title: '出入库记录', icon: '' }
      }, {
        path: 'kccx',
        name: '库存查询',
        code: '1055',
        component: () => import('@/views/wlgl/kccx'),
        meta: { title: '库存查询', icon: '' }
      }
@@ -278,39 +315,46 @@
    component: Layout,
    redirect: '/zzmx/gylx',
    name: '制造模型',
    code: '1005',
    meta: { title: '制造模型', icon: 'icu' },
    children: [
      {
        path: 'wllx',
        name: '物料类型',
        code: '1060',
        component: () => import('@/views/zzmx/wllx'),
        meta: { title: '物料类型', icon: '' }
      },
      {
        path: 'chda',
        name: '存货档案',
        code: '1061',
        component: () => import('@/views/zzmx/chda'),
        meta: { title: '存货档案', icon: '' }
      }, {
        path: 'wlqd',
        name: '物料清单',
        code: '1062',
        component: () => import('@/views/zzmx/wlqd'),
        meta: { title: '物料清单', icon: '' }
      },
      {
        path: 'gylx',
        name: '工艺路线',
        code: '1063',
        component: () => import('@/views/zzmx/gylx'),
        meta: { title: '工艺路线', icon: '' }
      }, {
        path: 'gxdy',
        name: '工序定义',
        code: '1064',
        component: () => import('@/views/zzmx/gxdy'),
        meta: { title: '工序定义', icon: '' }
      },
      {
        path: 'jpgj',
        name: '节拍工价',
        code: '1065',
        component: () => import('@/views/zzmx/jpgj'),
        meta: { title: '节拍工价', icon: '' }
      }
@@ -321,26 +365,31 @@
    component: Layout,
    redirect: '/scgl/scdd',
    name: '生产管理',
    code: '1006',
    meta: { title: '生产管理', icon: 'production' },
    children: [
      {
        path: 'scdd',
        name: 'ERP生产订单',
        code: '1070',
        component: () => import('@/views/scgl/scdd'),
        meta: { title: 'ERP生产订单', icon: '' }
      }, {
        path: 'gd',
        name: 'MES工单',
        code: '1071',
        component: () => import('@/views/scgl/gd'),
        meta: { title: 'MES工单', icon: '' }
      }, {
        path: 'gdpg',
        name: '工单派工',
        code: '1072',
        component: () => import('@/views/scgl/gdpg'),
        meta: { title: '工单派工', icon: '' }
      }, {
        path: 'sckbg',
        name: '生产开报工',
        code: '1073',
        component: () => import('@/views/scgl/sckbg'),
        meta: { title: '生产开报工', icon: '' }
      }
@@ -351,31 +400,37 @@
    component: Layout,
    redirect: '/zlgl/zjbz',
    name: '质量管理',
    code: '1007',
    meta: { title: '质量管理', icon: 'quality' },
    children: [
      {
        path: 'zjbz',
        name: '质检标准',
        code: '1080',
        component: () => import('@/views/zlgl/zjbz'),
        meta: { title: '质检标准', icon: '' }
      }, {
        path: 'qxdy',
        name: '缺陷定义',
        code: '1081',
        component: () => import('@/views/zlgl/qxdy'),
        meta: { title: '缺陷定义', icon: '' }
      }, {
        path: 'gxjy',
        name: '工序检验',
        code: '1082',
        component: () => import('@/views/zlgl/gxjy'),
        meta: { title: '工序检验', icon: '' }
      }, {
        path: 'wljy',
        name: '物流检验',
        code: '1083',
        component: () => import('@/views/zlgl/wljy'),
        meta: { title: '物流检验', icon: '' }
      }, {
        path: 'qxsj',
        name: '缺陷统计',
        code: '1084',
        component: () => import('@/views/zlgl/qxsj'),
        meta: { title: '缺陷统计', icon: '' }
      }
@@ -386,26 +441,31 @@
    component: Layout,
    redirect: '/xtsz/bmgz',
    name: '系统设置',
    code: '1009',
    meta: { title: '系统设置', icon: 'xtsz' },
    children: [
      {
        path: 'bmgz',
        name: '编码规则',
        code: '1101',
        component: () => import('@/views/xtsz/bmgz'),
        meta: { title: '编码规则', icon: '' }
      }, {
        path: 'mmxg',
        name: '密码修改',
        code: '1102',
        component: () => import('@/views/xtsz/mmxg'),
        meta: { title: '密码修改', icon: '' }
      }, {
        path: 'xtrz',
        name: '系统日志',
        code: '1103',
        component: () => import('@/views/xtsz/xtrz'),
        meta: { title: '系统日志', icon: '' }
      }, {
        path: 'sc',
        name: 'SOP上传',
        code: '1104',
        component: () => import('@/views/xtsz/sc'),
        meta: { title: 'SOP上传', icon: '' }
      }