Browse Source

前后:链接iam登录

dubch 5 years ago
parent
commit
aef4d10d95

+ 1 - 0
src/dashoo.cn/backend/api/controllers/base.go

@@ -347,6 +347,7 @@ func (this *BaseController) Prepare() {
 		"/api/register/getCode",
 		"/api/register/updatepassword",
 		"/api/bankapi/get-icbc-gfgl2019-token",
+		"/api/iam/iamlogin",
 	}
 	for _, v := range urls {
 		fmt.Println("**this.Ctx.Input.URL()**", this.Ctx.Input.URL())

+ 7 - 0
src/dashoo.cn/backend/api/routers/router.go

@@ -8,6 +8,7 @@ import (
 	"dashoo.cn/backend/api/controllers/bankapi"
 	"dashoo.cn/backend/api/controllers/casbin"
 	"dashoo.cn/backend/api/controllers/document"
+	"dashoo.cn/backend/api/controllers/iamlogin"
 	"dashoo.cn/backend/api/controllers/oilcontract"
 	"dashoo.cn/backend/api/controllers/oilsupplier"
 	"dashoo.cn/backend/api/controllers/register"
@@ -514,6 +515,12 @@ func init() {
 				&oilcontract.OilContractAnnualListenerController{},
 			),
 		),
+		// iam登录
+		beego.NSNamespace("/iam",
+			beego.NSInclude(
+				&iamlogin.IamLoginController{},
+			),
+		),
 	)
 	beego.AddNamespace(ns)
 }

+ 9 - 0
src/dashoo.cn/frontend_web/src/api/iamlogin/iamlogin.js

@@ -0,0 +1,9 @@
+export default {
+  iamlogin (params, myAxios) {
+    return myAxios({
+      url: '/iam/iamlogin',
+      method: 'post',
+      data: params
+    })
+  }
+}

+ 18 - 14
src/dashoo.cn/frontend_web/src/components/workflow/wfhistory.vue

@@ -96,20 +96,22 @@
         })
           .then(res => {
             // console.log('历史任务', res.data)
-            this.tmp_historyTask = res.data.items
-            let useridstr = ''
-            for (let i = 0; i < this.tmp_historyTask.length; i++) {
-              if (this.tmp_historyTask[i].assignee !== '') {
-                useridstr = useridstr + this.tmp_historyTask[i].assignee + ','
+            if (res.data.items) {
+              this.tmp_historyTask = res.data.items
+              let useridstr = ''
+              for (let i = 0; i < this.tmp_historyTask.length; i++) {
+                if (this.tmp_historyTask[i].assignee !== '') {
+                  useridstr = useridstr + this.tmp_historyTask[i].assignee + ','
+                }
+                if (this.tmp_historyTask[i].users !== '') {
+                  useridstr = useridstr + this.tmp_historyTask[i].users + ','
+                }
               }
-              if (this.tmp_historyTask[i].users !== '') {
-                useridstr = useridstr + this.tmp_historyTask[i].users + ','
+              if (useridstr) {
+                useridstr = useridstr.substring(0, useridstr.length - 1)
+                this.getuserlist(useridstr)
               }
             }
-            if (useridstr) {
-              useridstr = useridstr.substring(0, useridstr.length - 1)
-              this.getuserlist(useridstr)
-            }
           })
           .catch(err => {
             // handle error
@@ -117,9 +119,11 @@
           })
       },
       assigneeToAssignee (val) {
-        for (let i = 0; i < this.userlist.length; i++) {
-          if (val == this.userlist[i].Id) {
-            return this.userlist[i].Realname
+        if (this.userlist) {
+          for (let i = 0; i < this.userlist.length; i++) {
+            if (val == this.userlist[i].Id) {
+              return this.userlist[i].Realname
+            }
           }
         }
       },

+ 152 - 148
src/dashoo.cn/frontend_web/src/components/workflow/wfmultihistory.vue

@@ -39,172 +39,176 @@
 </template>
 
 <script>
-  import {
-    mapGetters
-  } from 'vuex'
+import {
+  mapGetters
+} from 'vuex'
 
-  export default {
-    name: 'wfmultihistory',
-    props: {
-      visible: {
-        type: Boolean,
-        default: false
-      },
-      entryinfo: {}
-    },
-    created () {
-      this.getHistoryTask()
-    },
-    computed: {
-      ...mapGetters({
-        session: 'session'
-      })
-    },
-    watch: {
-      entryinfo: {
-        handler: function (newVal, oldVal) {
-          this.getHistoryTask()
-        },
-        deep: true
-      }
+export default {
+  name: 'wfmultihistory',
+  props: {
+    visible: {
+      type: Boolean,
+      default: false
     },
-
-    data () {
-      return {
-        baseurl: process.env.baseURL,
-        process: '',
-        business: '',
-        instance: '',
-        selfVisible: this.visible, // 避免vue双向绑定警告
-        historyTask: [],
-        userlist: []
-      }
-    },
-    methods: {
-      getHistoryTask () {
-        let _this = this
-        this.$axios.get('/audithistory/list?id=' + this.entryinfo.business)
-          .then(res => {
-            let instanceIds = ''
-            console.log('单-多历史任务', res.data)
-            for (let idx in res.data.item) {
-              instanceIds += res.data.item[idx].WorkflowId + ','
-            }
-            instanceIds += _this.entryinfo.instance + ','
-            _this.getHistoryMultiTask(instanceIds)
-          })
-          .catch(err => {
-            // handle error
-            console.error(err)
-          })
+    entryinfo: {}
+  },
+  created () {
+    this.getHistoryTask()
+  },
+  computed: {
+    ...mapGetters({
+      session: 'session'
+    })
+  },
+  watch: {
+    entryinfo: {
+      handler: function (newVal, oldVal) {
+        this.getHistoryTask()
       },
-      getHistoryMultiTask (instanceIds) {
-        let _this = this
-        const params = {
-          process: _this.entryinfo.process,
-          business: _this.entryinfo.business,
-          instance: instanceIds
-        }
-        this.$axios.get('/workflow/historymultitask', {
-          params
+      deep: true
+    }
+  },
+
+  data () {
+    return {
+      baseurl: process.env.baseURL,
+      process: '',
+      business: '',
+      instance: '',
+      selfVisible: this.visible, // 避免vue双向绑定警告
+      historyTask: [],
+      userlist: []
+    }
+  },
+  methods: {
+    getHistoryTask () {
+      let _this = this
+      this.$axios.get('/audithistory/list?id=' + this.entryinfo.business)
+        .then(res => {
+          let instanceIds = ''
+          console.log('单-多历史任务', res.data)
+          for (let idx in res.data.item) {
+            instanceIds += res.data.item[idx].WorkflowId + ','
+          }
+          instanceIds += _this.entryinfo.instance + ','
+          _this.getHistoryMultiTask(instanceIds)
+        })
+        .catch(err => {
+          // handle error
+          console.error(err)
         })
-          .then(res => {
-            console.log('多-多历史任务', res.data)
-            // _this.historyTask = res.data.items
-            this.tmp_historyTask = res.data.items
-            let useridstr = ''
-            for (let i = 0; i < this.tmp_historyTask.length; i++) {
-              if (this.tmp_historyTask[i].assignee !== '') {
-                useridstr = useridstr + this.tmp_historyTask[i].assignee + ','
-              }
-              if (this.tmp_historyTask[i].users !== '') {
-                useridstr = useridstr + this.tmp_historyTask[i].users + ','
-              }
+    },
+    getHistoryMultiTask (instanceIds) {
+      let _this = this
+      const params = {
+        process: _this.entryinfo.process,
+        business: _this.entryinfo.business,
+        instance: instanceIds
+      }
+      this.$axios.get('/workflow/historymultitask', {
+        params
+      })
+        .then(res => {
+          console.log('多-多历史任务', res.data)
+          console.log('22222222222')
+          // _this.historyTask = res.data.items
+          this.tmp_historyTask = res.data.items
+          let useridstr = ''
+          for (let i = 0; i < this.tmp_historyTask.length; i++) {
+            if (this.tmp_historyTask[i].assignee !== '') {
+              useridstr = useridstr + this.tmp_historyTask[i].assignee + ','
             }
-            if (useridstr) {
-              useridstr = useridstr.substring(0, useridstr.length - 1)
-              this.getuserlist(useridstr)
+            if (this.tmp_historyTask[i].users !== '') {
+              useridstr = useridstr + this.tmp_historyTask[i].users + ','
             }
-          })
-          .catch(err => {
-            // handle error
-            console.error(err)
-          })
-      },
-      assigneeToAssignee (val) {
+          }
+          if (useridstr) {
+            console.log(useridstr.length, '22222222222')
+            useridstr = useridstr.substring(0, useridstr.length - 1)
+            this.getuserlist(useridstr)
+          }
+        })
+        .catch(err => {
+          // handle error
+          console.error(err)
+        })
+    },
+    assigneeToAssignee (val) {
+      if (this.userlist) {
         for (let i = 0; i < this.userlist.length; i++) {
           if (val == this.userlist[i].Id) {
             return this.userlist[i].Realname
           }
         }
-      },
-      assigneeToUsers (users) {
-        let userNames = ''
-        let userArr = users.split(',')
-        for (let idx = 0; idx < userArr.length; idx++) {
-          let val = userArr[idx]
-          for (let i = 0; i < this.userlist.length; i++) {
-            if (parseInt(val) == parseInt(this.userlist[i].Id)) {
-              userNames += this.userlist[i].Realname + ', '
-            }
+      }
+    },
+    assigneeToUsers (users) {
+      let userNames = ''
+      let userArr = users.split(',')
+      for (let idx = 0; idx < userArr.length; idx++) {
+        let val = userArr[idx]
+        for (let i = 0; i < this.userlist.length; i++) {
+          if (parseInt(val) == parseInt(this.userlist[i].Id)) {
+            userNames += this.userlist[i].Realname + ', '
           }
         }
-        if (userNames.length > 0) {
-          userNames = userNames.substring(0, userNames.length - 2)
-        }
-        return userNames
-      },
-      getuserlist (val) {
-        this.$axios.post('workflow/userlist_post?userids=' + val)
-          .then(res => {
-            // response
-            this.userlist = res.data.items
-            this.historyTask = this.tmp_historyTask
-          })
-          .catch(err => {
-            // handle error
-            console.error(err)
-          })
-      },
-      timestampToTime (val) {
-        var date = new Date(val) // 时间戳为10位需*1000,时间戳为13位的话不需乘1000
-        var Y = date.getFullYear() + '-'
-        var M = (date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1) + '-'
-        var D = date.getDate() + ' '
-        var h = date.getHours() + ':'
-        var m = date.getMinutes() + ':'
-        var s = date.getSeconds()
-        return Y + M + D + h + m + s
-      },
-      jstimehandle (val) {
-        if (val === '') {
-          return '----'
-        } else if (val === '0001-01-01T08:00:00+08:00') {
-          return '----'
-        } else if (val === '5000-01-01T23:59:59+08:00') {
-          return '永久'
-        } else if (val === '1970-01-01 8:0:0') {
-          return '----'
-        } else if (val === '1970-01-1 8:0:0') {
-          return '----'
-        } else {
-          val = val.replace('T', ' ')
-          return val.substring(0, 19)
-        }
+      }
+      if (userNames.length > 0) {
+        userNames = userNames.substring(0, userNames.length - 2)
+      }
+      return userNames
+    },
+    getuserlist (val) {
+      this.$axios.post('workflow/userlist_post?userids=' + val)
+        .then(res => {
+          // response
+          this.userlist = res.data.items
+          this.historyTask = this.tmp_historyTask
+        })
+        .catch(err => {
+          // handle error
+          console.error(err)
+        })
+    },
+    timestampToTime (val) {
+      var date = new Date(val) // 时间戳为10位需*1000,时间戳为13位的话不需乘1000
+      var Y = date.getFullYear() + '-'
+      var M = (date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1) + '-'
+      var D = date.getDate() + ' '
+      var h = date.getHours() + ':'
+      var m = date.getMinutes() + ':'
+      var s = date.getSeconds()
+      return Y + M + D + h + m + s
+    },
+    jstimehandle (val) {
+      if (val === '') {
+        return '----'
+      } else if (val === '0001-01-01T08:00:00+08:00') {
+        return '----'
+      } else if (val === '5000-01-01T23:59:59+08:00') {
+        return '永久'
+      } else if (val === '1970-01-01 8:0:0') {
+        return '----'
+      } else if (val === '1970-01-1 8:0:0') {
+        return '----'
+      } else {
+        val = val.replace('T', ' ')
+        return val.substring(0, 19)
       }
     }
   }
+}
 </script>
 
 <style>
-  .samplerecoveope .el-radio {
-    padding: 8px 15px 0 0;
-    margin-left: -2px;
-  }
-  .dialog-footer img{
-    position: relative;
-    width: 100%;
-    height: 100%;
-  }
+.samplerecoveope .el-radio {
+  padding: 8px 15px 0 0;
+  margin-left: -2px;
+}
+.dialog-footer img{
+  position: relative;
+  width: 100%;
+  height: 100%;
+}
 
 </style>

+ 27 - 0
src/dashoo.cn/frontend_web/src/pages/login.vue

@@ -133,8 +133,10 @@ import Vue from 'vue'
 import Component from 'class-component'
 import Sticky from '@/components/Sticky'
 import api from '@/api/rtxservice/rtx'
+import Iam from '@/api/iamlogin/iamlogin'
 import documentApi from '@/api/oilsupplier/document'
 import SIdentify from '@/components/VCode.vue'
+import Cookies from 'js-cookie'
 // import {mapGetters} from 'vuex'
 @Component({
   data () {
@@ -219,6 +221,7 @@ import SIdentify from '@/components/VCode.vue'
   //   }
   // },
   created () {
+    this.iamLoginByAccountName()
     this.initNoticeListData()
     this.initFileListData()
     this.identifyCode = ''
@@ -232,6 +235,30 @@ import SIdentify from '@/components/VCode.vue'
     SIdentify
   },
   methods: {
+    iamLoginByAccountName () {
+      const iamCode = this.$route.query.code
+      console.log(iamCode, 'iam----------')
+      if (!iamCode) {
+        return false
+      }
+      let params = {
+        appCode: 'SCGLDBWUrsaCL',
+        secret: 'HFxEwaX7YQpgVxTrEBpg',
+        code: '234'
+      }
+      Iam.iamlogin(params, this.$axios).then(res => {
+        console.log(res, '2222')
+        if (res && res.data.token) {
+          // this.$cookie.set('iamCode', iamCode)
+          // this.$cookies.set('token', res.data.token)
+          Cookies.set('token', res.data.token)
+          // Cookies.set('iamCode', iamCode)
+          this.$router.replace({ path: '/' })
+        }
+      }).catch(err => {
+        console.error(err)
+      })
+    },
     datadownload () {
       this.$router.push({ path: '/documentdown' })
     },