按钮级别的新版本,多级别的组织架构
loulijun2021
2023-07-27 84ef53c807ec6dddf4a0226b11b0e0f9f6d9cec0
1.项目优化
已修改6个文件
173 ■■■■ 文件已修改
src/layout/components/Sidebar/index.vue 3 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main.js 17 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/permission.js 12 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/store/modules/user.js 28 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/utils/request.js 87 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/login/index.vue 26 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/layout/components/Sidebar/index.vue
@@ -42,7 +42,7 @@
    <div v-if="!$store.state.settings.menuIsHorizontal" style="position: absolute;bottom: 20px;left: 30px;">
      <div>
        <el-button v-if="$store.state.app.sidebar.opened" type="text" style="font-size: 14px;cursor: pointer">
          新凯迪制造V1.6.53
          新凯迪制造V2.0.0
        </el-button>
        <!--        <el-button type="text"><a href="http://www.ykxkd.com/" target="_blank">新凯迪制造V1.0.01</a></el-button>-->
      </div>
@@ -56,7 +56,6 @@
import Logo from './Logo'
import SidebarItem from './SidebarItem'
import variables from '@/styles/variables.scss'
import { LoginMenu } from '@/api/user'
import { removeCookie, setCookie } from '@/utils/auth'
export default {
src/main.js
@@ -70,23 +70,6 @@
// 引用修改过的gantt
Vue.use(vGanttChart)
import { setCookie } from '@/utils/auth' // 引用修改过的gantt
// 判断是否走原平台过来
if (window.location.hash.indexOf('guid') !== -1) {
  setCookie('cloud', true)// 走云平台
  const url = window.location.hash.split('?')[1]
  const arr = url.split('&')
  setCookie('guid', arr[0].split('=')[1])
  setCookie('userid', arr[1].split('=')[1])
  setCookie('admin', arr[2].split('=')[1])
  setCookie('navTabId', arr[2].split('=')[1])
  setCookie('username', decodeURIComponent(arr[3].split('=')[1]))
  setCookie('password', arr[4].split('=')[1])
  setCookie('usertype', arr[5].split('=')[1])
  setCookie('rediskey', arr[6].split('=')[1])
}
new Vue({
  el: '#app',
  router,
src/permission.js
@@ -3,8 +3,9 @@
import { Message } from 'element-ui'
import NProgress from 'nprogress' // progress bar
import 'nprogress/nprogress.css' // progress bar style
import { getCookie, getToken } from '@/utils/auth' // get token from cookie
import { getCookie, getToken, setCookie } from '@/utils/auth' // get token from cookie
import getPageTitle from '@/utils/get-page-title'
import { decode } from 'jsonwebtoken'
NProgress.configure({ showSpinner: false }) // NProgress Configuration
@@ -27,15 +28,20 @@
      next({ path: '/' })
      NProgress.done()
    } else {
      // const hasGetUserInfo = store.getters.name
      const hasGetUserInfo = store.getters.name
      // const hasGetUserInfo = getCookie('usercode')
      if (hasGetUserInfo) {
        next()
      } else {
        try {
          // 拉取info
          // const info = await store.dispatch('user/getInfo')
          // jwt解密获取用户编码
          const jwt = decode(localStorage.getItem('token'))
          setCookie('usercode', jwt.usercode)
          setCookie('stu_torgname', jwt.stu_torgname)
          setCookie('username', jwt.username)
          // 拉取菜单信息表
          const menu = await store.dispatch('user/getMenu')
          // 生成可访问的路由表
src/store/modules/user.js
@@ -94,35 +94,15 @@
  getMenu({ commit, state }) {
    return new Promise((resolve, reject) => {
      console.log('进来了11111')
      // if (getCookie('cloud')) { // 走云
      //   LoginMenuCloud({ enterpriseUserName: getCookie('admin') }).then(res => {
      //     if (res.code === 200) {
      //       commit('SET_NAME', res.msg)
      //       commit('SET_MENU', res.data)
      //       resolve(res.data)
      //     }
      //   }).catch(error => {
      //     reject(error)
      //   })
      // } else {
      // debugger
      // 明天的看下usercode编码动态
      LoginMenu({ usertype: 'PC', usercode: '999' }).then(res => {
      LoginMenu({ usertype: 'PC', usercode: getCookie('usercode') }).then(res => {
        if (res.code === '200') {
          commit('SET_NAME', res.message)
          commit('SET_MENU', res.data)
          resolve(res.data)
        }
        // if (res.code === '303') {
        //   debugger
        //   localStorage.removeItem('token')
        //   // window.location.reload()
        //   // resolve(res.data)
        // }
      }).catch(error => {
        reject(error)
      })
      // }
    })
  },
@@ -158,16 +138,12 @@
          removeCookie('stu_torgcode')
          removeCookie('stu_torgname')
          removeCookie('description')
          removeCookie('guid')
          // reset visited views and cached views
          dispatch('tagsView/delAllViews', null, { root: true })
          sessionStorage.removeItem('tabViews')
          if (getCookie('cloud')) {
            removeCookie('cloud')
            window.location.href = 'http://182.61.13.206/choose'
          }
          commit('RESET_STATE')
          resolve()
src/utils/request.js
@@ -1,32 +1,18 @@
import axios from 'axios'
import { MessageBox, Message } from 'element-ui'
import { Message, Notification } from 'element-ui'
import store from '@/store'
import { getCookie, getToken, removeCookie, setCookie } from '@/utils/auth'
import { handleDatetime } from '@/utils/global'
// create an axios instance
import { removeCookie } from '@/utils/auth'
const service = axios.create({
  baseURL: process.env.VUE_APP_BASE_API, // url = base url + request url
  withCredentials: true, // send cookies when cross-domain requests
  timeout: 10000 // request timeout
})
// axios.defaults.withCredentials = true
// request interceptor
service.interceptors.request.use(
  config => {
    // do something before request is sent
    // 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'
    // }
    config.headers['Token'] = localStorage.getItem('token')
    return config
  },
@@ -54,39 +40,25 @@
    // if the custom code is not 20000, it is judged as an error.
    if (res.code === '300' || res.code === '303') {
      Message({
        message: res.Message || 'Error',
        type: 'error',
        duration: 5 * 1000
      })
      if (res.code === '300') {
        Message({
          message: res.Message || 'Error',
          type: 'error',
          duration: 5 * 1000
        })
      }
      if (res.code === '303') {
        removeCookie('ruleCode')
        removeCookie('username')
        removeCookie('admin')
        removeCookie('navTabId')
        removeCookie('usertype')
        removeCookie('userid')
        removeCookie('rediskey')
        removeCookie('code')
        removeCookie('guid')
        removeCookie('stu_torgcode')
        removeCookie('stu_torgname')
        removeCookie('description')
        // if (getCookie('cloud')) {
        //   removeCookie('cloud')
        //   setTimeout(() => {
        //     sessionStorage.removeItem('tabViews')
        //     window.location.href = 'http://182.61.13.206/choose'
        //   }, 1000 * 2)
        // } else {
        setTimeout(() => {
          localStorage.removeItem('token')
          sessionStorage.removeItem('tabViews')
          window.location.reload()
        }, 1000 * 2)
        // }
        // Notification({
        //   message: res.Message || 'Error',
        //   type: 'error',
        //   duration: 5 * 1000
        // })
        removeCookie('usercode')
        localStorage.removeItem('token')
        sessionStorage.removeItem('tabViews')
        // setTimeout(() => {
        //   window.location.reload()
        // }, 1000)
      }
      // 50008: Illegal token; 50012: Other clients logged in; 50014: Token expired;
      // if (res.code === 50008 || res.code === 50012 || res.code === 50014) {
@@ -103,24 +75,7 @@
      // }
      store.state.app.buttonIsDisabled = false // 将按钮变回可点击
      return Promise.reject(new Error(res.message || 'Error'))
    }
    // else if (res.code === '303') {
    //   console.log(res.code, 888)
    //   Message({
    //     message: res.Message || 'Error',
    //     type: 'error',
    //     duration: 5 * 1000
    //   })
    //   removeCookie('ruleCode')
    //   removeCookie('username')
    //   removeCookie('admin')
    //   removeCookie('navTabId')
    //   removeCookie('usertype')
    //   removeCookie('userid')
    //   removeCookie('code')
    //   this.$router.push({ path: this.redirect || '/' })
    // }
    else {
    } else {
      return res
    }
  },
src/views/login/index.vue
@@ -221,10 +221,6 @@
            if (getCookie('code') === '302') {
              this.dialogVisible = true
            } else {
              // console.log(typeof getCookie('description'))
              // console.log(getCookie('description') === '')
              // this.$store.state.settings.orgType = getCookie('description')// 组织类型
              // console.log(this.$store.state.settings.orgType, 88)
              this.$router.push({ path: this.redirect || '/' })
            }
            this.loading = false
@@ -239,31 +235,9 @@
    },
    dialogVisibleCancel() {
      // removeCookie('username')
      // removeCookie('admin')
      // removeCookie('navTabId')
      // removeCookie('usertype')
      // removeCookie('userid')
      // removeCookie('code')
      // removeCookie('stu_torgcode')
      // removeCookie('stu_torgname')
      // removeCookie('description')
      this.dialogVisible = false
    },
    async dialogVisibleConfirm() {
      // const usercode = getCookie('navTabId')
      // const username = getCookie('admin')
      // const usertype = getCookie('usertype')
      // const userid = getCookie('userid')
      // const stu_torgcode = getCookie('stu_torgcode')
      // const data = {
      //   usercode,
      //   username,
      //   usertype,
      //   userid,
      //   rid: '',
      //   stu_torgcode
      // }
      const data = {
        token: localStorage.getItem('token'),
        rid: ''