LoginAzureAD.vue
1.72 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
<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>