Jelajahi Sumber

Merge branch 'feature/special_subscription_suppliers' of Epans/modernDairy into master

duanxiaoduan 1 tahun lalu
induk
melakukan
acda3916cf
5 mengubah file dengan 128 tambahan dan 137 penghapusan
  1. 0 0
      dist/index.html
  2. 16 21
      src/permission.js
  3. 81 66
      src/store/modules/user.js
  4. 2 2
      src/views/custom/subscribe/index.vue
  5. 29 48
      src/views/login/index.vue

File diff ditekan karena terlalu besar
+ 0 - 0
dist/index.html


+ 16 - 21
src/permission.js

@@ -4,9 +4,10 @@ import { Message } from 'element-ui'
 import NProgress from 'nprogress' // progress bar
 import 'nprogress/nprogress.css' // progress bar style
 import { getToken,removeToken } from '@/utils/auth' // get token from cookie
-
+import Cookies from 'js-cookie'
 import getPageTitle from '@/utils/get-page-title'
-
+// 1为单点登录,其他不是
+Cookies.set('sso',0)
 NProgress.configure({ showSpinner: false }) // NProgress Configuration
 
 const whiteList = ['/login'] // no redirect whitelist
@@ -74,28 +75,22 @@ router.beforeEach(async(to, from, next) => {
 
       next({ path: '/login' })
       NProgress.done()
-       // next({ path: '/login' })
-      // 构建要跳转的URL
-      // const url = window.location.protocol + "//"+window.location.host + '/'
-      // const url = 'http://192.168.61.41/'
-      // const url = 'http://tmrwatch.cn:8082/'
-      var url = process.env.VUE_APP_BASE_API
-      //获取当前url
-      
-      if(url.indexOf('/')==0 && url.length==1){
-        url= window.location.protocol + "//"+window.location.host+url
+      if(Cookies.get('sso') == 1){
+        // 单点登录
+        // 构建要跳转的URL
+        var url = process.env.VUE_APP_BASE_API
+        console.log(url,'url')
+        //获取当前url
+        if(url.indexOf('/')==0 && url.length==1){
+          url= window.location.protocol + "//"+window.location.host+url
+        }
+        const externalURL = "https://id.xiandaimuye.com/api/v1/oauth2/authorize?response_type=code&client_id=fTBm64I4k3kqHYtoFTUpvirCDxxCfx7I&redirect_uri="+url+'api/v1/oauth2/token';
+        // 使用 $router.push 进行页面跳转
+        // 注意: 这里的跳转是在当前窗口进行的,如果需要在新标签页打开,可以使用 window.open(externalURL)
+        window.open(externalURL, "_self");
       }
-      //        const externalURL = "https://id.xiandaimuye.com/api/v1/oauth2/authorize?response_type=code&client_id=fTBm64I4k3kqHYtoFTUpvirCDxxCfx7I&redirect_uri=http://tmrwatch.cn:8082/api/v1/oauth2/token";
-      const externalURL = "https://id.xiandaimuye.com/api/v1/oauth2/authorize?response_type=code&client_id=fTBm64I4k3kqHYtoFTUpvirCDxxCfx7I&redirect_uri="+url+'api/v1/oauth2/token';
-      // 使用 $router.push 进行页面跳转
-      // 注意: 这里的跳转是在当前窗口进行的,如果需要在新标签页打开,可以使用 window.open(externalURL)
-      window.open(externalURL, "_self");
     }
   }
-
-  // 使用 $router.push 进行页面跳转
-  // 注意: 这里的跳转是在当前窗口进行的,如果需要在新标签页打开,可以使用 window.open(externalURL)
-  // window.open(url1, "_self");
 })
 
 router.afterEach(() => {

+ 81 - 66
src/store/modules/user.js

@@ -99,20 +99,20 @@ const actions = {
     const { username, password } = userInfo
     return new Promise((resolve, reject) => {
       login({ username: username.trim(), password: password }).then(response => {
-        // =============================
-        const fullURL = window.location.href;
-        // 使用正则表达式提取code参数的值
-        const codeMatch = fullURL.match(/[\?&]access=([^&]+)/);
-        console.log('codeMatch===>',codeMatch)
-        if (codeMatch) {
-          // 如果匹配成功,将code的值存储在组件的data中
-          var code = codeMatch[1];
-            //TODO 保存token
-            // 去除后面的#/login
-          if ( code &&  code.includes("#/login")) {
-            code =  code.replace("#/login", "");
-          }
-          console.log('token',code)
+        if(Cookies.get('sso') == 1){
+        // 单点登录=============================
+          const fullURL = window.location.href;
+          // 使用正则表达式提取code参数的值
+          const codeMatch = fullURL.match(/[\?&]access=([^&]+)/);
+          console.log('codeMatch===>',codeMatch)
+          if (codeMatch) {
+            // 如果匹配成功,将code的值存储在组件的data中
+            var code = codeMatch[1];
+              //TODO 保存token
+              // 去除后面的#/login
+            if ( code &&  code.includes("#/login")) {
+              code =  code.replace("#/login", "");
+            }
            //base64解密this.cose
             console.log('解密token',atob(code))
             let token = atob(code)
@@ -125,21 +125,23 @@ const actions = {
             window.open(jmpurl, "_self");
           }
         // =============================
-        // const { data, msg } = response
-        // if (msg !== 'ok') {
-        //   Message({
-        //     message: data,
-        //     type: 'error',
-        //     duration: 5 * 1000
-        //   })
-        //   reject(data)
-        // }
-        // commit('SET_TOKEN', data.token)
-        // if (Cookies == null) {
-        //   console.log(1)
-        // }
-        // setToken(data.token)
-        // resolve()
+        }else{
+          const { data, msg } = response
+          if (msg !== 'ok') {
+            Message({
+              message: data,
+              type: 'error',
+              duration: 5 * 1000
+            })
+            reject(data)
+          }
+          commit('SET_TOKEN', data.token)
+          if (Cookies == null) {
+            console.log(1)
+          }
+          setToken(data.token)
+          resolve()
+        }
       }).catch(error => {
         reject(error)
       })
@@ -162,31 +164,31 @@ const actions = {
         if (!role || role.length <= 0) {
           reject('该用户未分配角色!')
           console.log('no=============')
-          setTimeout(()=>{
-            commit('SET_BUTTONS', [])
-            // console.log('-------------', state)
-            commit('SET_TOKEN', '')
-            commit('SET_ROLES', [])
-            Cookies.remove('employename')
-            Cookies.remove('employeid')
-            Cookies.remove('pastureid')
-            removeToken()
-            resetRouter()
-            resolve()
-            // const url = process.env.VUE_APP_BASE_API
-            // const url = 'http://192.168.61.41/'
-            // const url = 'http://tmrwatch.cn:8082/'
-            var url = process.env.VUE_APP_BASE_API
-            //获取当前url
+          if(Cookies.get('sso') == 1){
+            setTimeout(()=>{
+              commit('SET_BUTTONS', [])
+              // console.log('-------------', state)
+              commit('SET_TOKEN', '')
+              commit('SET_ROLES', [])
+              Cookies.remove('employename')
+              Cookies.remove('employeid')
+              Cookies.remove('pastureid')
+              removeToken()
+              resetRouter()
+              resolve()
+              // 单点登录
+              var url = process.env.VUE_APP_BASE_API
+              //获取当前url
 
-            if(url.indexOf('/')==0 && url.length==1){
-              url= window.location.protocol + "//"+window.location.host+url
-            }
-            const externalURL = "https://id.xiandaimuye.com/api/v1/logout?redirect_url="+url+ '&client_id=fTBm64I4k3kqHYtoFTUpvirCDxxCfx7I';
-            // 使用 $router.push 进行页面跳转
-            // 注意: 这里的跳转是在当前窗口进行的,如果需要在新标签页打开,可以使用 window.open(externalURL)
-            window.open(externalURL, "_self");
-          },2000)
+              if(url.indexOf('/')==0 && url.length==1){
+                url= window.location.protocol + "//"+window.location.host+url
+              }
+              const externalURL = "https://id.xiandaimuye.com/api/v1/logout?redirect_url="+url+ '&client_id=fTBm64I4k3kqHYtoFTUpvirCDxxCfx7I';
+              // 使用 $router.push 进行页面跳转
+              // 注意: 这里的跳转是在当前窗口进行的,如果需要在新标签页打开,可以使用 window.open(externalURL)
+              window.open(externalURL, "_self");
+            },2000)
+          }
         }
 
         GetDataByName({ 'name': 'getUserPCButtons', 'parammaps': { 'jwt_username': username }}).then(response => {
@@ -274,20 +276,33 @@ const actions = {
         removeToken()
         resetRouter()
         resolve()
-        // const url = process.env.VUE_APP_BASE_API
-        // const url = 'http://192.168.61.41/'
-        // const url = 'http://tmrwatch.cn:8082/'
-        var url = process.env.VUE_APP_BASE_API
-        //获取当前url
-        
-        if(url.indexOf('/')==0 && url.length==1){
-          url= window.location.protocol + "//"+window.location.host+url
+        if(Cookies.get('sso') == 1){
+        // 单点登录
+          var url = process.env.VUE_APP_BASE_API
+          console.log(url,'url')
+          //获取当前url
+
+          if(url.indexOf('/')==0 && url.length==1){
+            url= window.location.protocol + "//"+window.location.host+url
+          }
+          const externalURL = "https://id.xiandaimuye.com/api/v1/logout?redirect_url=" + url + '&client_id=fTBm64I4k3kqHYtoFTUpvirCDxxCfx7I';
+          // 使用 $router.push 进行页面跳转
+          // 注意: 这里的跳转是在当前窗口进行的,如果需要在新标签页打开,可以使用 window.open(externalURL)
+          window.open(externalURL, "_self");
+          // location.reload()
+        }else{
+          commit('SET_BUTTONS', [])
+          // console.log('-------------', state)
+          commit('SET_TOKEN', '')
+          commit('SET_ROLES', [])
+          Cookies.remove('employename')
+          Cookies.remove('employeid')
+          Cookies.remove('pastureid')
+          removeToken()
+          resetRouter()
+          resolve()
+          location.reload()
         }
-        const externalURL = "https://id.xiandaimuye.com/api/v1/logout?redirect_url=" + url + '&client_id=fTBm64I4k3kqHYtoFTUpvirCDxxCfx7I';
-        // 使用 $router.push 进行页面跳转
-        // 注意: 这里的跳转是在当前窗口进行的,如果需要在新标签页打开,可以使用 window.open(externalURL)
-        window.open(externalURL, "_self");
-        // location.reload()
       }).catch(error => {
         reject(error)
       })

+ 2 - 2
src/views/custom/subscribe/index.vue

@@ -188,7 +188,7 @@
             </el-col>
             <el-col v-if="dialogStatus==='special' && createTemp.purchaseType == '1' || createTemp.purchaseType == '3'" :span="8">
               <el-form-item label="供应商:" prop="providerId">
-                <el-select v-model="createTemp.providerId" placeholder="供应商" class="filter-item" style="width:100%" :disabled="dialogStatus==='update'">
+                <el-select v-model="createTemp.providerId" filterable placeholder="供应商" class="filter-item" style="width:100%" :disabled="dialogStatus==='update'">
                   <el-option v-for="item in providerList" :key="item.id" :label="item.providerName" :value="item.id" />
                 </el-select>
               </el-form-item>
@@ -2208,7 +2208,7 @@ export default {
     getProviderList(){
       let data = {
         "name":"getProviderList",
-        "page":1,"offset":1,"pagecount":100,
+        "page":1,"offset":1,"pagecount":0,
         "returntype":"Map","parammaps":{"providerName":""}
       }
       GetDataByName(data).then(response => {

+ 29 - 48
src/views/login/index.vue

@@ -1,5 +1,6 @@
 <template>
-  <!-- <div class="login-container">
+  <div v-if="isdisplay == 1"></div>
+  <div class="login-container" v-else>
     <div class="content">
       <div class="content-l"></div>
       <div class="login">
@@ -29,7 +30,8 @@
         </el-form>
       </div>
     </div>
-  </div> -->
+  </div>
+  
 </template>
 
 <script>
@@ -73,7 +75,8 @@ export default {
       },
       loading: false,
       passwordType: 'password',
-      redirect: undefined
+      redirect: undefined,
+      isdisplay:Cookies.get('sso')
     }
   },
   watch: {
@@ -93,7 +96,10 @@ export default {
     //     that.handleLogin('ruleForm2') // 登录函数 (handleSubmit2('ruleForm2')-登录按钮的点击事件)
     //   }
     // }
+    // 单点登录
+    if(Cookies.get('sso') == 1){
      this.getcodeList()
+    }
   },
   methods: {
     showPwd() {
@@ -106,56 +112,31 @@ export default {
         this.$refs.password.focus()
       })
     },
-    // handleLogin() {
-    //   this.$refs.loginForm.validate(valid => {
-    //     if (valid) {
-    //       this.$store.dispatch('user/login', this.loginForm) .then(() => {
-    //         // const re = new RegExp(`^(?=.*[a-z])(?=.*\\d)(?=.*\\W)[^]{8,32}$`)
-    //         // if (!re.test(this.loginForm.password)) {
-    //         //   this.$router.push('/console/Changpwd')
-    //         //   console.log('密码不符合要求')
-    //         // }
-    //         this.$router.push({ path: this.redirect || '/' })
-    //         this.loading = false
-    //       }).catch(() => {
-    //         this.loading = false
-    //       })
-    //     } else {
-    //       console.log('error submit!!')
-    //       return false
-    //     }
-    //   })
-    // }
+    handleLogin() {
+      this.$refs.loginForm.validate(valid => {
+        if (valid) {
+          this.$store.dispatch('user/login', this.loginForm) .then(() => {
+            // const re = new RegExp(`^(?=.*[a-z])(?=.*\\d)(?=.*\\W)[^]{8,32}$`)
+            // if (!re.test(this.loginForm.password)) {
+            //   this.$router.push('/console/Changpwd')
+            //   console.log('密码不符合要求')
+            // }
+            this.$router.push({ path: this.redirect || '/' })
+            this.loading = false
+          }).catch(() => {
+            this.loading = false
+          })
+        } else {
+          console.log('error submit!!')
+          return false
+        }
+      })
+    },
     getcodeList(){
       this.$store.dispatch('user/login', this.loginForm) .then(() => {
-        
       }).catch(() => {
         this.loading = false
       })
-      // // 获取完整的URL
-      // const fullURL = window.location.href;
-      // // 使用正则表达式提取code参数的值
-      // const codeMatch = fullURL.match(/[\?&]access=([^&]+)/);
-      // if (codeMatch) {
-      //   // 如果匹配成功,将code的值存储在组件的data中
-      //   this.code = codeMatch[1];
-      //   console.log(this.code)
-      //     //TODO 保存token
-      //     // 去除后面的#/login
-      //   if ( this.code &&  this.code.includes("#/login")) {
-      //      this.code =  this.code.replace("#/login", "");
-      //   }
-      //    console.log(this.code)
-      //    //base64解密this.cose
-      //     // atob(this.code)
-      //     console.log( atob(this.code))
-      //     let token = atob(this.code)
-      //     setToken(token)
-          
-      // } else {
-      //   console.log('error submit!!')
-      //   return false
-      // }
     }
   }
 }

Beberapa file tidak ditampilkan karena terlalu banyak file yang berubah dalam diff ini