LoginAzureAD.vue 1.72 KB
<template>
</template>

<script>
import {postAction} from '@/api/manage'
import {mapActions} from 'vuex'

export default {
  name: 'LoginAzureAD',
  data() {
    return {}
  },
  methods: {
    ...mapActions(['AzureADLogin']),
    handleLogin(rememberMe) {
      this.validateFields([], (err) => {
        if (!err) {
          let loginParams = {
            warehouseCode: 'CS0001',
            checkKey: this.currdatetime,
            remember_me: rememberMe,
          }
          this.AzureADLogin(loginParams).then((res) => {
            this.$emit('success', res.result)
            this.$router.push({path: "/dashboard/analysis"})
          }).catch((err) => {
            this.$emit('fail', err)
            if (err.code == 499) {
              this.$router.push({path: "/user/systemTokenModal"})
            }
          });
        } else {
          this.$emit('validateFail')
        }
      })
    },
    /**
     * 验证字段
     * @param arr
     * @param callback
     */
    validateFields(arr, callback) {
      let promiseArray = []
      for (let item of arr) {
        let p = new Promise((resolve, reject) => {
          this.$refs['form'].validateField(item, (err) => {
            if (!err) {
              resolve();
            } else {
              reject(err);
            }
          })
        });
        promiseArray.push(p)
      }
      Promise.all(promiseArray).then(() => {
        callback()
      }).catch(err => {
        callback(err)
      })
    },
    cmsFailed(err) {
      this.$notification['error']({
        message: '获取验证码失败',
        description: err,
        duration: 4,
      });
    },
  }

}
</script>

<style scoped>
.getCaptcha {
  display: block;
  width: 100%;
  height: 40px;
}
</style>