魏志佳 4 gadi atpakaļ
vecāks
revīzija
592701136c
7 mainītis faili ar 157 papildinājumiem un 57 dzēšanām
  1. BIN
      dist.zip
  2. 1 1
      src/Layout.vue
  3. 9 4
      src/router/index.js
  4. 12 2
      src/store/user.js
  5. 25 25
      src/utils/api/request.js
  6. 108 23
      src/views/OKRpage.vue
  7. 2 2
      vue.config.js

BIN
dist.zip


+ 1 - 1
src/Layout.vue

@@ -65,7 +65,7 @@ import Vue from 'vue'
               localStorage.removeItem('Login_Userinfo');
               localStorage.removeItem('Access-Token');
               this.Logout();
-              this.$router.replace({path:'/login'})
+              // this.$router.replace({path:'/login'})
           },
           handleCommand(command) {
             if(command=='username'){

+ 9 - 4
src/router/index.js

@@ -57,12 +57,12 @@ const routes = [
         path: '/login',
         name: 'Login',       
         component: () => import(/* webpackChunkName: "about" */ '../views/Login.vue')
-     },
-      {
+    },
+    {
         path: '/transfer-local',
         name: 'transferLocal',       
         component: () => import(/* webpackChunkName: "about" */ '../views/TransferLocal.vue')
-     }
+    }
   // {
   //   path: '/about',
   //   name: 'About',
@@ -81,7 +81,12 @@ const router = new VueRouter({
 })
 
 router.beforeEach((to,from,next)=>{
-  let userInfo=JSON.parse(localStorage.getItem('Login_Userinfo'))
+  let Login_Userinfo=localStorage.getItem('Login_Userinfo');
+  let userInfo=null;
+  if(Login_Userinfo){
+     userInfo=JSON.parse(Login_Userinfo)
+     console.log(userInfo)
+  }
   console.log(to,from,userInfo)
   if(to.matched.some(res=>res.meta.isLogin)){//判断是否需要登录
       if (userInfo) {

+ 12 - 2
src/store/user.js

@@ -3,6 +3,8 @@ import {login, logout, phoneLogin} from "@/utils/api/login"
 import {ACCESS_TOKEN, USER_NAME, USER_INFO, USER_AUTH, SYS_BUTTON_AUTH} from "./mutation-types"
 import {welcome} from "@/utils/util"
 import {queryPermissionsByUser} from '@/utils/api/login'
+import router from 'vue-router'
+
 
 const user = {
   state: {
@@ -120,14 +122,22 @@ const user = {
     Logout({commit, state}) {
       return new Promise((resolve) => {
         let logoutToken = state.token;
-        commit('SET_TOKEN', '')
+        console.log(logoutToken)
+        // commit('SET_TOKEN', '')
         commit('SET_PERMISSIONLIST', [])
         Vue.ls.remove(ACCESS_TOKEN)
         localStorage.removeItem("roleCode")
+
         //console.log('logoutToken: '+ logoutToken)
-        logout(logoutToken).then(() => {
+        logout(logoutToken).then((res) => {
+          // console.log(res)
+          // route.replace({path:'/login'})
+          localStorage.removeItem('Login_Userinfo')        
           resolve()
+          
         }).catch(() => {
+          // route.replace({path:'/login'})
+          localStorage.removeItem('Login_Userinfo')       
           resolve()
         })
       })

+ 25 - 25
src/utils/api/request.js

@@ -2,9 +2,9 @@ import Vue from 'vue'
 import axios from 'axios'
 import store from '@/store'
 import {Plugin as VueAxios} from '@/plugins/axios'
-import {Modal, Notification} from 'element-ui'
+import {Modal, MessageBox ,Notification} from 'element-ui'
 import {ACCESS_TOKEN} from "@/store/mutation-types"
-
+import router from 'vue-router'
 // 创建 axios 实例
 
 if (process.env.NODE_ENV == 'development') { 
@@ -25,45 +25,44 @@ const service = axios.create({
 
 
 const err = (error) => {
-  if (error.esponse) {
+  if (error.response) {
     let data = error.response.data
     const token = Vue.ls.get(ACCESS_TOKEN)
     console.log("------异常响应------", token)
     console.log("------异常响应------", error.response.status)
     switch (error.response.status) {
       case 403:
-        Notification.error({message: '系统提示', description: '拒绝访问', duration: 4})
+        Notification.error({title: '系统提示', message: '拒绝访问', duration: 4})
         break
       case 500:
         //notification.error({ message: '系统提示', description:'Token失效,请重新登录!',duration: 4})
-        if (token && data.message == "Token失效,请重新登录") {
+        if (token && data.code == -1) {
           // update-begin- --- author:scott ------ date:20190225 ---- for:Token失效采用弹框模式,不直接跳转----
           // store.dispatch('Logout').then(() => {
           //     window.location.reload()
           // })
-          Modal.error({
-            title: '登录已过期',
-            content: '很抱歉,登录已过期,请重新登录',
-            okText: '重新登录',
-            mask: false,
-            onOk: () => {
-              store.dispatch('Logout').then(() => {
-                Vue.ls.remove(ACCESS_TOKEN)
+          // Notification.error({title: '登录已过期', message: '很抱歉,登录已过期,请重新登录', duration: 4})
+          if (token) {
+            store.dispatch('Logout').then(() => {
+              setTimeout(() => {
                 window.location.reload()
-              })
-            }
-          })
+                // router.replace('/login')
+              }, 1500)
+            })
+          }
+          break
+         
           // update-end- --- author:scott ------ date:20190225 ---- for:Token失效采用弹框模式,不直接跳转----
         }
         break
       case 404:
-        Notification.error({message: '系统提示', description: '很抱歉,资源未找到!', duration: 4})
+        Notification.error({title: '系统提示', message: '很抱歉,资源未找到!', duration: 4})
         break
       case 504:
-        Notification.error({message: '系统提示', description: '网络超时'})
+        Notification.error({title: '系统提示', message: '网络超时'})
         break
       case 401:
-        Notification.error({message: '系统提示', description: '未授权,请重新登录', duration: 4})
+        Notification.error({title: '系统提示', message: '未授权,请重新登录', duration: 4})
         if (token) {
           store.dispatch('Logout').then(() => {
             setTimeout(() => {
@@ -74,8 +73,8 @@ const err = (error) => {
         break
       default:
         Notification.error({
-          message: '系统提示',
-          description: data.message,
+          title: '系统提示',
+          message: data.message,
           duration: 4
         })
         break
@@ -109,10 +108,11 @@ service.interceptors.response.use((response) => {
   return response.data
 }, (error) => {
   console.log(error)
-      Notification.error({
-        title: '系统提示',
-        message: '网络超时,请刷新页面'
-      })
+    err(error)
+      // Notification.error({
+      //   title: '系统提示',
+      //   message: '网络超时,请刷新页面'
+      // })
     return 
   })
 

+ 108 - 23
src/views/OKRpage.vue

@@ -16,15 +16,27 @@
                 center
                 :before-close="OKRhandleClose">
                 <span>
-                    <p>
-                        <span>现有同步人:</span>
-                        <span v-for="(item,index) in selectedPeople" :key='index' style="margin-right:5px">
-                            <el-link type="success">{{item.label}} </el-link>
-                        </span>
-                    </p>
+                    <div class="nowSelect">
+                        <div class="nowSelectLeft">现有同步人:</div>
+                        <div class="nowSelectRight">
+                            <span v-for="(item,index) in selectedPeople" :key='index' style="margin-right:10px" class="nowSelectItem">
+                            <el-link type="success" style="margin-top:-3px" class="nowSelectItemLink">
+                                 {{item.label}} 
+                                <el-popconfirm
+                                title="确定移除该同步人吗?"
+                                @onConfirm='deletePeople(item)'
+                                >
+                                <span slot="reference" class="deleteSelectedPeople" ><i class="el-icon-circle-close" ></i></span>
+                                </el-popconfirm>
+                            </el-link>
+
+                            </span>
+                        </div>
+                       
+                    </div>
                     
 
-                    <span>重选同步人:</span>
+                    <span>添加同步人:</span>
                     <el-select v-model="syncPeopleValue" filterable placeholder="请选择需要同步的人" :multiple='true' style="width:60%">
                         <el-option
                             v-for="item in syncPeopleOptions"
@@ -585,23 +597,49 @@ import {postAction , getAction} from '@/utils/api/http.js'
             
         },
         methods: {
+            // 删除当前同步人
+            deletePeople(item){
+                console.log(item);
+                postAction('/okr/okr/deleteOkrMember',{
+                    memberId:item.value
+                }).then(res=>{
+                    console.log(res);
+                    if(res.success){
+                        this.$message.success('同步人删除成功!');
+                        //请求已经同步的人
+                        postAction('/okr/okr/getMemberListByUserId',{
+
+                        }).then((res)=>{
+                            this.selectedPeople=[]
+                            // console.log(res);
+                            res.result.forEach((item)=>{
+                                this.selectedPeople.push({
+                                        label:item.name,
+                                        value:item.userId
+                                })
+                            })
+                        })
+                    }else{
+                        this.$message.success('同步人删除失败,稍后再试')
+                    }
+                })
+            },
             // okr同步事件
             okrSync(){
                 this.okrVisible=true;
-                 this.syncPeopleOptions=[];
-                 //请求所有的公司人
-                postAction('/okr/qywx/getUserListByName',{
-
+                this.syncPeopleOptions=[];
+                //请求所有的公司人
+                postAction('/okr/qywx/getUserListByName',{                   
                 }).then((res)=>{                    
                     // console.log(res)
                     this.syncPeopleOptions=[]
                     if(res.success){
                         // this.syncPeopleOptions=res.result
                         res.result.forEach((item)=>{
-                             this.syncPeopleOptions.push({
-                                 label:item.name,
-                                 value:item.userId
-                             })
+                            this.syncPeopleOptions.push({
+                                label:item.name,
+                                value:item.userId
+                            })
                         })
                     }
                     
@@ -621,14 +659,22 @@ import {postAction , getAction} from '@/utils/api/http.js'
                 })
             },
             syncOK(){
-                postAction('/okr/okr/saveOkrMember',{
-                    userIdList:this.syncPeopleValue
-                }).then((res)=>{
-                    // console.log(res)
-                    if(res.success){
-                        this.okrVisible = false
-                    }
-                })
+                if(this.syncPeopleValue.length>0){
+                    postAction('/okr/okr/saveOkrMember2',{
+                        userIdList:this.syncPeopleValue
+                    }).then((res)=>{
+                        // console.log(res)
+                        if(res.success){
+                            this.okrVisible = false;
+                            this.syncPeopleValue=[]
+                        }else{
+                            this.$message.error('同步失败!')
+                        }
+                    })
+                }else{
+                    this.okrVisible = false;
+                }
+                
             },
             OKRhandleClose(done) {
                 this.$confirm('当前内容并未保存,确定关闭么?')
@@ -1018,6 +1064,7 @@ import {postAction , getAction} from '@/utils/api/http.js'
         mounted() {
             //请求list
             this.getOkrPageList();
+            
         },
     }
 </script>
@@ -1034,6 +1081,44 @@ ul,li{
     background:#CC9966;
     box-sizing: border-box;
     position: relative;
+    .nowSelect{
+        // display: flex;
+        padding-top: 5px;
+        margin-bottom: 15px;
+        overflow: hidden;
+    }
+    .nowSelectLeft{
+        width: 84px;
+        float: left;
+        // display: inline-block;
+    }
+    .nowSelectRight{
+       float: left;
+       width: 400px;
+       
+    }
+    .nowSelectItem{
+        position: relative;       
+        // width: 70px;
+        text-align: center;
+        display: inline-block;
+        margin-bottom: 6px;
+        
+    }
+    .nowSelectItemLink{
+        position: relative;
+        padding-right: 15px;
+    }
+    .deleteSelectedPeople{
+        display: none;
+        position: absolute;
+        right: -1px;
+        top: -3px;
+        font-size: 13px;
+    }
+    .nowSelectItem:hover .deleteSelectedPeople{
+        display: block;
+    }
     .topBox{
         height: 41px;
     }

+ 2 - 2
vue.config.js

@@ -3,8 +3,8 @@ module.exports = {
         port: 3000,
         proxy: {
             "/api": {
-                // target: 'http://192.168.0.230:8910', // 要访问的接口域名
-                target: 'http://okrapi.c-top.com.cn', // 要访问的接口域名
+                target: 'http://192.168.1.94:8910', // 要访问的接口域名
+                // target: 'http://okrapi.c-top.com.cn', // 要访问的接口域名
                 ws: true, // 是否启用websockets
                 changeOrigin: true, //开启代理:在本地会创建一个虚拟服务端,然后发送请求的数据,并同时接收请求的数据,这样服务端和服务端进行数据的交互就不会有跨域问题
                 pathRewrite: {