|
|
@@ -1,18 +1,36 @@
|
|
|
<template>
|
|
|
- <div :class="[
|
|
|
- 'login-wrapper',
|
|
|
- ['', 'login-form-right', 'login-form-left'][direction]
|
|
|
- ]">
|
|
|
- <el-form ref="form" size="large" :model="form" :rules="rules" class="login-form ele-bg-white"
|
|
|
- @keyup.enter.native="submit">
|
|
|
+ <div
|
|
|
+ :class="[
|
|
|
+ 'login-wrapper',
|
|
|
+ ['', 'login-form-right', 'login-form-left'][direction]
|
|
|
+ ]"
|
|
|
+ >
|
|
|
+ <el-form
|
|
|
+ ref="form"
|
|
|
+ size="large"
|
|
|
+ :model="form"
|
|
|
+ :rules="rules"
|
|
|
+ class="login-form ele-bg-white"
|
|
|
+ @keyup.enter.native="submit"
|
|
|
+ >
|
|
|
<h4>{{ $t('login.title') }}</h4>
|
|
|
<el-form-item prop="loginName">
|
|
|
- <el-input clearable v-model="form.loginName" prefix-icon="el-icon-user" placeholder="请输入登录账号"/>
|
|
|
+ <el-input
|
|
|
+ clearable
|
|
|
+ v-model="form.loginName"
|
|
|
+ prefix-icon="el-icon-user"
|
|
|
+ placeholder="请输入登录账号"
|
|
|
+ />
|
|
|
</el-form-item>
|
|
|
<el-form-item prop="loginPwd">
|
|
|
- <el-input show-password v-model="form.loginPwd" prefix-icon="el-icon-lock" placeholder="请输入登录密码"/>
|
|
|
+ <el-input
|
|
|
+ show-password
|
|
|
+ v-model="form.loginPwd"
|
|
|
+ prefix-icon="el-icon-lock"
|
|
|
+ placeholder="请输入登录密码"
|
|
|
+ />
|
|
|
</el-form-item>
|
|
|
- <el-form-item prop="captcha">
|
|
|
+ <el-form-item prop="captcha">
|
|
|
<div class="login-input-group">
|
|
|
<el-input
|
|
|
clearable
|
|
|
@@ -32,19 +50,36 @@
|
|
|
<el-checkbox v-model="form.remember">
|
|
|
{{ $t('login.remember') }}
|
|
|
</el-checkbox>
|
|
|
- <el-link type="primary" :underline="false" class="ele-pull-right" @click="$router.push('/forget')">
|
|
|
+ <el-link
|
|
|
+ type="primary"
|
|
|
+ :underline="false"
|
|
|
+ class="ele-pull-right"
|
|
|
+ @click="$router.push('/forget')"
|
|
|
+ >
|
|
|
忘记密码
|
|
|
</el-link>
|
|
|
</div>
|
|
|
<div class="el-form-item">
|
|
|
- <el-button size="large" type="primary" class="login-btn" :loading="loading" @click="submit">
|
|
|
+ <el-button
|
|
|
+ size="large"
|
|
|
+ type="primary"
|
|
|
+ class="login-btn"
|
|
|
+ :loading="loading"
|
|
|
+ @click="submit"
|
|
|
+ >
|
|
|
{{ loading ? $t('login.loading') : $t('login.login') }}
|
|
|
</el-button>
|
|
|
</div>
|
|
|
<div class="ele-text-center" style="margin-bottom: 10px">
|
|
|
- <i class="login-oauth-icon el-icon-_qq" style="background: #3492ed"></i>
|
|
|
- <i class="login-oauth-icon el-icon-_wechat" style="background: #4daf29"></i>
|
|
|
- <i class="login-oauth-icon el-icon-_weibo" style="background: #cf1900"></i>
|
|
|
+ <!-- <i class="login-oauth-icon el-icon-_qq" style="background: #3492ed"></i>
|
|
|
+ <i
|
|
|
+ class="login-oauth-icon el-icon-_wechat"
|
|
|
+ style="background: #4daf29"
|
|
|
+ ></i>
|
|
|
+ <i
|
|
|
+ class="login-oauth-icon el-icon-_weibo"
|
|
|
+ style="background: #cf1900"
|
|
|
+ ></i> -->
|
|
|
</div>
|
|
|
</el-form>
|
|
|
<div class="login-copyright">
|
|
|
@@ -52,10 +87,15 @@
|
|
|
</div>
|
|
|
<!-- 多语言切换 -->
|
|
|
<div style="position: absolute; right: 30px; top: 20px">
|
|
|
- <i18n-icon :icon-style="{ fontSize: '22px', color: '#fff', cursor: 'pointer' }"/>
|
|
|
+ <i18n-icon
|
|
|
+ :icon-style="{ fontSize: '22px', color: '#fff', cursor: 'pointer' }"
|
|
|
+ />
|
|
|
</div>
|
|
|
<!-- 实际项目去掉这段 -->
|
|
|
- <div class="hidden-xs-only" style="position: absolute; right: 30px; bottom: 20px; z-index: 9">
|
|
|
+ <div
|
|
|
+ class="hidden-xs-only"
|
|
|
+ style="position: absolute; right: 30px; bottom: 20px; z-index: 9"
|
|
|
+ >
|
|
|
<el-radio-group v-model="direction" size="mini">
|
|
|
<el-radio-button label="2">居左</el-radio-button>
|
|
|
<el-radio-button label="0">居中</el-radio-button>
|
|
|
@@ -67,15 +107,15 @@
|
|
|
|
|
|
<script>
|
|
|
import I18nIcon from '@/layout/components/i18n-icon.vue';
|
|
|
-import {getToken} from '@/utils/token-util';
|
|
|
-import {login, getCaptcha} from '@/api/login';
|
|
|
-import xyy from '@/assets/xyy.jpg'
|
|
|
-import {getPathAddress} from "@/api/system/file";
|
|
|
+import { getToken } from '@/utils/token-util';
|
|
|
+import { login, getCaptcha } from '@/api/login';
|
|
|
+import xyy from '@/assets/xyy.jpg';
|
|
|
+import { getPathAddress } from '@/api/system/file';
|
|
|
|
|
|
export default {
|
|
|
// eslint-disable-next-line vue/multi-word-component-names
|
|
|
name: 'Login',
|
|
|
- components: {I18nIcon},
|
|
|
+ components: { I18nIcon },
|
|
|
data() {
|
|
|
return {
|
|
|
// 登录框方向, 0居中, 1居右, 2居左
|
|
|
@@ -85,17 +125,22 @@ export default {
|
|
|
loading: false,
|
|
|
// 表单数据
|
|
|
form: {
|
|
|
- loginName: localStorage.getItem('accountInfo') ? JSON.parse(localStorage.getItem('accountInfo')).loginName : '',
|
|
|
- loginPwd: localStorage.getItem('accountInfo') ? JSON.parse(localStorage.getItem('accountInfo')).loginPwd : '',
|
|
|
- remember: localStorage.getItem('accountInfo') ? JSON.parse(localStorage.getItem('accountInfo')).remember : false,
|
|
|
+ loginName: localStorage.getItem('accountInfo')
|
|
|
+ ? JSON.parse(localStorage.getItem('accountInfo')).loginName
|
|
|
+ : '',
|
|
|
+ loginPwd: localStorage.getItem('accountInfo')
|
|
|
+ ? JSON.parse(localStorage.getItem('accountInfo')).loginPwd
|
|
|
+ : '',
|
|
|
+ remember: localStorage.getItem('accountInfo')
|
|
|
+ ? JSON.parse(localStorage.getItem('accountInfo')).remember
|
|
|
+ : false,
|
|
|
captcha: '',
|
|
|
uuid: ''
|
|
|
},
|
|
|
// 验证码base64数据
|
|
|
captcha: '',
|
|
|
// 验证码内容, 实际项目去掉
|
|
|
- text: '',
|
|
|
-
|
|
|
+ text: ''
|
|
|
};
|
|
|
},
|
|
|
computed: {
|
|
|
@@ -120,7 +165,7 @@ export default {
|
|
|
],
|
|
|
|
|
|
captcha: [
|
|
|
- {
|
|
|
+ {
|
|
|
required: true,
|
|
|
message: '验证码不能为空',
|
|
|
type: 'string',
|
|
|
@@ -131,7 +176,7 @@ export default {
|
|
|
}
|
|
|
},
|
|
|
created() {
|
|
|
- this.changeCaptcha()
|
|
|
+ this.changeCaptcha();
|
|
|
if (getToken()) {
|
|
|
this.goHome();
|
|
|
} else {
|
|
|
@@ -151,8 +196,19 @@ export default {
|
|
|
.then(async (res) => {
|
|
|
localStorage.setItem('userId', res.data.userId);
|
|
|
// 用户信息
|
|
|
- const filePath = await getPathAddress()
|
|
|
- res.data.avatarAddress = res.data.avatar && res.data.avatar.length ? filePath + res.data.avatar[0].storePath : xyy
|
|
|
+ if (res.data?.loginChangeGroupVOList.length > 0) {
|
|
|
+ sessionStorage['currentUser'] = JSON.stringify({
|
|
|
+ currentGroupId: res.data.loginChangeGroupVOList[0].groupId,
|
|
|
+ currentRoleId:
|
|
|
+ res.data.loginChangeGroupVOList[0].loginChangeRoleVOList[0]
|
|
|
+ .roleId
|
|
|
+ });
|
|
|
+ }
|
|
|
+ const filePath = await getPathAddress();
|
|
|
+ res.data.avatarAddress =
|
|
|
+ res.data.avatar && res.data.avatar.length
|
|
|
+ ? filePath + res.data.avatar[0].storePath
|
|
|
+ : xyy;
|
|
|
this.$store.commit('user/setUserInfo', res.data);
|
|
|
this.loading = false;
|
|
|
this.$message.success(res.message);
|
|
|
@@ -162,14 +218,13 @@ export default {
|
|
|
} else {
|
|
|
localStorage.removeItem('accountInfo');
|
|
|
}
|
|
|
- console.log('我是登陆');
|
|
|
+
|
|
|
await this.$store.dispatch('user/getCurrentUserAuthorityDept');
|
|
|
await this.$store.dispatch('paramsSetData/setParamsDataInfo');
|
|
|
this.goHome();
|
|
|
-
|
|
|
})
|
|
|
.catch((e) => {
|
|
|
- this.changeCaptcha()
|
|
|
+ this.changeCaptcha();
|
|
|
this.loading = false;
|
|
|
// this.$message.error(e.message);
|
|
|
});
|
|
|
@@ -177,14 +232,13 @@ export default {
|
|
|
},
|
|
|
/* 跳转到首页 */
|
|
|
goHome() {
|
|
|
- this.$router.push(this.$route?.query?.from ?? '/').catch(() => {
|
|
|
- });
|
|
|
+ this.$router.push(this.$route?.query?.from ?? '/').catch(() => {});
|
|
|
},
|
|
|
/* 更换图形验证码 */
|
|
|
changeCaptcha() {
|
|
|
- this.form.uuid = this.generateUUID()
|
|
|
+ this.form.uuid = this.generateUUID();
|
|
|
// 这里演示的验证码是后端返回base64格式的形式, 如果后端地址直接是图片请参考忘记密码页面
|
|
|
- getCaptcha({uuid: this.form.uuid})
|
|
|
+ getCaptcha({ uuid: this.form.uuid })
|
|
|
.then((data) => {
|
|
|
this.captcha = URL.createObjectURL(data.data);
|
|
|
this.$refs?.form?.clearValidate();
|
|
|
@@ -193,25 +247,27 @@ export default {
|
|
|
// this.$message.error(e.message);
|
|
|
});
|
|
|
},
|
|
|
- generateUUID() {
|
|
|
- var d = new Date().getTime(); //Timestamp
|
|
|
- var d2 = (performance && performance.now && (performance.now()*1000)) || 0; //Time in microseconds since page-load or 0 if unsupported
|
|
|
- return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {
|
|
|
- var r = Math.random() * 16; //random number between 0 and 16
|
|
|
- if(d > 0) { //Use timestamp until depleted
|
|
|
- r = (d + r)%16 | 0;
|
|
|
- d = Math.floor(d/16);
|
|
|
- } else { //Use microseconds since page-load if supported
|
|
|
- r = (d2 + r)%16 | 0;
|
|
|
- d2 = Math.floor(d2/16);
|
|
|
+ generateUUID() {
|
|
|
+ var d = new Date().getTime(); //Timestamp
|
|
|
+ var d2 =
|
|
|
+ (performance && performance.now && performance.now() * 1000) || 0; //Time in microseconds since page-load or 0 if unsupported
|
|
|
+ return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(
|
|
|
+ /[xy]/g,
|
|
|
+ function (c) {
|
|
|
+ var r = Math.random() * 16; //random number between 0 and 16
|
|
|
+ if (d > 0) {
|
|
|
+ //Use timestamp until depleted
|
|
|
+ r = (d + r) % 16 | 0;
|
|
|
+ d = Math.floor(d / 16);
|
|
|
+ } else {
|
|
|
+ //Use microseconds since page-load if supported
|
|
|
+ r = (d2 + r) % 16 | 0;
|
|
|
+ d2 = Math.floor(d2 / 16);
|
|
|
+ }
|
|
|
+ return (c === 'x' ? r : (r & 0x3) | 0x8).toString(16);
|
|
|
}
|
|
|
- return (c === 'x' ? r : (r & 0x3 | 0x8)).toString(16);
|
|
|
- });
|
|
|
-}
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
+ );
|
|
|
+ }
|
|
|
}
|
|
|
};
|
|
|
</script>
|
|
|
@@ -348,7 +404,6 @@ export default {
|
|
|
}
|
|
|
|
|
|
@media screen and (max-width: 768px) {
|
|
|
-
|
|
|
.login-form-right .login-form,
|
|
|
.login-form-left .login-form {
|
|
|
left: 50%;
|