loulijun2021
2022-06-15 8e51e2713e358aade30db570b0cb8a4877022cf9
1.递交
已添加5个文件
已修改10个文件
306 ■■■■ 文件已修改
.env.development 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
.env.production 3 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
package.json 3 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/api/user.js 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/layout/components/Sidebar/index.vue 97 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/permission.js 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/router/index.js 79 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/utils/auth.js 26 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/utils/request.js 23 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/sbgl/sbqd.vue 11 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/wlgl/ckdy.vue 11 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/wlgl/kwdy.vue 11 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/zzmx/chda.vue 11 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/zzmx/wllx.vue 11 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
vue.config.js 13 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
.env.development
@@ -3,3 +3,4 @@
# base api
VUE_APP_BASE_API = 'http://121.196.36.24:8001/api/'
.env.production
@@ -2,5 +2,6 @@
ENV = 'production'
# base api
VUE_APP_BASE_API = '/prod-api'
#VUE_APP_BASE_API = './'
VUE_APP_BASE_API = 'http://121.196.36.24:8001/api/'
package.json
@@ -49,7 +49,8 @@
    "serve-static": "1.13.2",
    "svg-sprite-loader": "4.1.3",
    "svgo": "1.2.2",
    "vue-template-compiler": "2.6.10"
    "vue-template-compiler": "2.6.10",
    "webpack-dev-server": "^3.0.0"
  },
  "browserslist": [
    "> 1%",
src/api/user.js
@@ -7,11 +7,10 @@
    params: data
  })
}
export function LoginMenu(data) {
export function LoginMenu() {
  return request({
    url: 'Login/LoginMenu',
    method: 'get',
    params: data
    method: 'get'
  })
}
src/layout/components/Sidebar/index.vue
@@ -13,14 +13,14 @@
        :collapse-transition="false"
        mode="vertical"
      >
        <!--        <sidebar-item-->
        <!--          v-for="route in routes"-->
        <!--          :key="route.path"-->
        <!--          class="el-scrollbar-menu"-->
        <!--          :item="route"-->
        <!--          :base-path="route.path"-->
        <!--        />-->
        <sidebar-item v-for="route in permission_routes" :key="route.path" :item="route" :base-path="route.path" />
        <sidebar-item
          v-for="route in routes"
          :key="route.path"
          class="el-scrollbar-menu"
          :item="route"
          :base-path="route.path"
        />
        <!--        <sidebar-item v-for="route in permission_routes" :key="route.path" :item="route" :base-path="route.path" />-->
      </el-menu>
    </el-scrollbar>
@@ -36,16 +36,95 @@
import Logo from './Logo'
import SidebarItem from './SidebarItem'
import variables from '@/styles/variables.scss'
import { LoginMenu } from '@/api/user'
export default {
  components: { SidebarItem, Logo },
  data() {
    return {
      routers: []
    }
  },
  async created() {
    // const arr = [
    //   {
    //     name: '系统首页'
    //   },
    //   {
    //     name: '基础设置',
    //     children: [
    //       { name: '组织架构' },
    //       { name: '角色清单' },
    //       { name: '用户清单' }
    //     ]
    //   },
    //   {
    //     name: '制造模型',
    //     children: [
    //       { name: '公益路线' },
    //       { name: '节拍工价' },
    //       { name: '存货档案' }
    //     ]
    //   }
    // ]
    // this.routers = arr
    const res = await LoginMenu()
    console.log(res, 999)
  },
  computed: {
    ...mapGetters([
      'permission_routes',
      'sidebar'
    ]),
    routes() {
      return this.$router.options.routes
      // console.log(this.$router.options.routes, 111)
      // this.$router.options.routes.forEach((item, index) => {
      //   if (item.name === 'jcsz') {
      //     this.$router.options.routes.slice(index, 1)
      //   }
      // })
      // return this.$router.options.routes.filter(item => {
      //   console.log(item)
      //   return item.name === 'jcsz'
      // })
      console.log(this.routers, 99)
      console.log(this.$router.options.routes, 11)
      const newArr = []
      this.routers.forEach(item => {
        if (item.name) {
          newArr.push(item.name)
          if (item.children) {
            item.children.forEach(it => {
              if (it.name) {
                newArr.push(it.name)
              }
            })
          }
        }
      })
      console.log(newArr, 333)
      const arr = this.$router.options.routes
      const arr2 = []
      arr.forEach((item, index) => {
        console.log(newArr.includes(item.name), 222)
        if (newArr.includes(item.name) && item.children.length === 1) {
          arr2.push(item)
        } else if (newArr.includes(item.name) && item.children.length > 1) {
          const a = []
          item.children.forEach((it, ind) => {
            if (newArr.includes(it.name)) {
              a.push(it)
            }
          })
          item.children = a
          arr2.push(item)
        }
      })
      return arr2
    },
    activeMenu() {
      const route = this.$route
src/permission.js
@@ -52,6 +52,7 @@
          // if (s) {
          //   console.log(s)
          // }
          next()
          // next({ ...to, replace: true })
        } catch (error) {
src/router/index.js
@@ -57,6 +57,7 @@
    path: '/',
    component: Layout,
    redirect: '/index',
    name: '系统首页',
    children: [{
      path: 'index',
      name: 'index',
@@ -68,29 +69,69 @@
    path: '/jcsz',
    component: Layout,
    redirect: '/jcsz/zzjg',
    name: 'jcsz',
    name: '基础设置',
    meta: { title: '基础设置', icon: 'el-icon-setting' },
    children: [
      {
        path: 'zzjg',
        name: 'Table',
        name: '组织架构',
        component: () => import('@/views/jcsz/zzjg'),
        meta: { title: '组织架构', icon: '' }
      }, {
        path: 'jsqd',
        name: 'jsqd',
        name: '角色清单',
        component: () => import('@/views/jcsz/jsqd'),
        meta: { title: '角色清单', icon: '' }
      }, {
        path: 'yhqd',
        name: 'yhqd',
        name: '用户清单',
        component: () => import('@/views/jcsz/yhqd'),
        meta: { title: '用户清单', icon: '' }
      }, {
        path: 'wldw',
        name: 'wldw',
        name: '往来单位',
        component: () => import('@/views/jcsz/wldw'),
        meta: { title: '往来单位', icon: '' }
      }
    ]
  }, {
    path: '/sbgl',
    component: Layout,
    redirect: '/sbgl/sbqd',
    name: '设备管理',
    meta: { title: '设备管理', icon: 'el-icon-setting' },
    children: [
      {
        path: 'sbqd',
        name: '设备清单',
        component: () => import('@/views/sbgl/sbqd'),
        meta: { title: '设备清单', icon: '' }
      }
      // {
      //   path: 'sblxsz',
      //   name: '角色清单',
      //   component: () => import('@/views/jcsz/jsqd'),
      //   meta: { title: '角色清单', icon: '' }
      // },
    ]
  }, {
    path: '/wlgl',
    component: Layout,
    redirect: '/wlgl/ckdy',
    name: '物料管理',
    meta: { title: '物料管理', icon: 'el-icon-setting' },
    children: [
      {
        path: 'ckdy',
        name: '仓库定义',
        component: () => import('@/views/wlgl/ckdy'),
        meta: { title: '仓库定义', icon: '' }
      },
      {
        path: 'kwdy',
        name: '库位定义',
        component: () => import('@/views/wlgl/kwdy'),
        meta: { title: '库位定义', icon: '' }
      }
    ]
  },
@@ -98,23 +139,35 @@
    path: '/zzmx',
    component: Layout,
    redirect: '/zzmx/gylx',
    name: 'zzmx',
    name: '制造模型',
    meta: { title: '制造模型', icon: 'el-icon-s-help' },
    children: [
      {
        path: 'gylx',
        name: 'gylx',
        name: '公益路线',
        component: () => import('@/views/zzmx/gylx'),
        meta: { title: '公益路线', icon: 'table' }
        meta: { title: '公益路线', icon: '' }
      },
      {
        path: 'jpgj',
        name: 'jpgj',
        name: '节拍工价',
        component: () => import('@/views/zzmx/jpgj'),
        meta: { title: '节拍工价', icon: 'tree' }
        meta: { title: '节拍工价', icon: '' }
      }, {
        path: 'wllx',
        name: '物料类型',
        component: () => import('@/views/zzmx/wllx'),
        meta: { title: '物料类型', icon: '' }
      },
      {
        path: 'chda',
        name: '存货档案',
        component: () => import('@/views/zzmx/chda'),
        meta: { title: '存货档案', icon: '' }
      }
    ]
  }
  },
  { path: '*', redirect: '/404', hidden: true }
]
// export const constantRoutesxxxxxx = [
@@ -207,8 +260,8 @@
//     ]
//   },
//
//   // 404 page must be placed at the end !!!
//   { path: '*', redirect: '/404', hidden: true }
// 404 page must be placed at the end !!!
// , {path: '*', redirect: '/404', hidden: true}
// ]
const createRouter = () => new Router({
src/utils/auth.js
@@ -14,14 +14,32 @@
  return Cookies.remove(TokenKey)
}
export function getCookie(key) {
  return Cookies.get(key)
export function getCookie(c_name) {
  // document.cookie = escape(key) + ';path=/'
  if (document.cookie.length > 0) {
    let c_start = document.cookie.indexOf(c_name + '=')
    if (c_start != -1) {
      c_start = c_start + c_name.length + 1
      let c_end = document.cookie.indexOf(';', c_start)
      if (c_end == -1) {
        c_end = document.cookie.length
      }
      return unescape(document.cookie.substring(c_start, c_end))
    }
  }
  return ''
  // return Cookies.get(key)
}
export function setCookie(key, value) {
  return Cookies.set(key, value)
  var date = new Date()
  date.setSeconds(date.getSeconds() + 10000)
  document.cookie = key + '=' + escape(value) + '; expires=' + date.toGMTString() + ';path=/'
  // return Cookies.set(key, value)
}
export function removeCookie(key) {
  return Cookies.remove(key)
  setCookie(key, '', -1)
  // return Cookies.remove(key)
}
src/utils/request.js
@@ -1,13 +1,13 @@
import axios from 'axios'
import { MessageBox, Message } from 'element-ui'
import store from '@/store'
import { getToken } from '@/utils/auth'
import { getCookie, getToken } from '@/utils/auth'
// create an axios instance
const service = axios.create({
  baseURL: process.env.VUE_APP_BASE_API, // url = base url + request url
  // withCredentials: true, // send cookies when cross-domain requests
  withCredentials: true, // send cookies when cross-domain requests
  timeout: 5000 // request timeout
})
// request interceptor
@@ -15,12 +15,17 @@
  config => {
    // do something before request is sent
    if (store.getters.token) {
      // let each request carry token
      // ['X-Token'] is a custom headers key
      // please modify it according to the actual situation
      config.headers['X-Token'] = getToken()
    if (getCookie('admin')) {
    // let each request carry token
    // ['X-Token'] is a custom headers key
    // please modify it according to the actual situation
    // config.headers['X-Token'] = getToken()
    //   config.headers['Authorization'] = 'admin=' + getCookie('admin') + ';navTabId=' + getCookie('navTabId')
      config.headers['Cookie'] = 'admin=' + getCookie('admin') + ';navTabId=' + getCookie('navTabId')
    //   document.cookie = 'admin=' + getCookie('admin') + ';navTabId=' + getCookie('navTabId')
    //   document.cookie = 'admin'
    }
    console.log(config, 1)
    return config
  },
  error => {
@@ -35,7 +40,7 @@
  /**
   * If you want to get http information such as headers or status
   * Please return  response => response
  */
   */
  /**
   * Determine the request status by custom code
src/views/sbgl/sbqd.vue
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,11 @@
<template />
<script>
export default {
  name: 'Sbqd'
}
</script>
<style scoped>
</style>
src/views/wlgl/ckdy.vue
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,11 @@
<template />
<script>
export default {
  name: 'Ckdy'
}
</script>
<style scoped>
</style>
src/views/wlgl/kwdy.vue
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,11 @@
<template />
<script>
export default {
  name: 'Wldy'
}
</script>
<style scoped>
</style>
src/views/zzmx/chda.vue
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,11 @@
<template />
<script>
export default {
  name: 'Chda'
}
</script>
<style scoped>
</style>
src/views/zzmx/wllx.vue
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,11 @@
<template />
<script>
export default {
  name: 'Wllx'
}
</script>
<style scoped>
</style>
vue.config.js
@@ -24,7 +24,7 @@
   * In most cases please use '/' !!!
   * Detail: https://cli.vuejs.org/config/#publicpath
   */
  publicPath: '/',
  publicPath: './',
  outputDir: 'dist',
  assetsDir: 'static',
  lintOnSave: process.env.NODE_ENV === 'development',
@@ -36,7 +36,16 @@
      warnings: false,
      errors: true
    },
    before: require('./mock/mock-server.js')
    proxy: {
      [process.env.VUE_APP_BASE_API]: {
        target: process.env.VUE_APP_BASE_API, // è¯·æ±‚的第三⽅接⼝地址
        changeOrigin: true, // è¯·æ±‚跨域时,需配置此项
        pathRewrite: { // è·¯å¾„重写,替换target中的请求地址
          ['^' + process.env.VUE_APP_BASE_API]: ''
        }
      }
    }
    // before: require('./mock/mock-server.js')
  },
  configureWebpack: {
    // provide the app's title in webpack's name field, so that