|
@@ -8,7 +8,8 @@
|
|
|
ref="loginForm"
|
|
|
:model="loginForm"
|
|
|
:rules="loginRules"
|
|
|
- class="login-form">
|
|
|
+ class="login-form"
|
|
|
+ >
|
|
|
<el-row>
|
|
|
<el-col :span="12" class="comlogo"></el-col>
|
|
|
<el-col :span="12">
|
|
@@ -16,8 +17,7 @@
|
|
|
· 工业应用引擎
|
|
|
<!-- 智能制造平台 -->
|
|
|
</div>
|
|
|
- </el-col
|
|
|
- >
|
|
|
+ </el-col>
|
|
|
</el-row>
|
|
|
<el-row class="rowww">
|
|
|
<el-col :span="12" class="text" prop="username">用户名</el-col>
|
|
@@ -60,7 +60,7 @@
|
|
|
</el-col>
|
|
|
<el-col :span="4" :offset="1">
|
|
|
<div class="login-code">
|
|
|
- <img :src="codeUrl" @click="getCode" class="login-code-img"/>
|
|
|
+ <img :src="codeUrl" @click="getCode" class="login-code-img" />
|
|
|
</div>
|
|
|
</el-col>
|
|
|
</el-row>
|
|
@@ -71,9 +71,8 @@
|
|
|
<img :src="codeUrl" @click="getCode" class="login-code-img" />
|
|
|
</div> -->
|
|
|
<el-checkbox v-model="loginForm.rememberMe" class="aaa"
|
|
|
- >在这个设备上记住我
|
|
|
- </el-checkbox
|
|
|
- >
|
|
|
+ >在这个设备上记住我
|
|
|
+ </el-checkbox>
|
|
|
</el-row>
|
|
|
|
|
|
<el-row>
|
|
@@ -81,19 +80,18 @@
|
|
|
class="logg"
|
|
|
:loading="loading"
|
|
|
@click.native.prevent="handleLogin"
|
|
|
- >登录
|
|
|
- </el-col
|
|
|
- >
|
|
|
+ >登录
|
|
|
+ </el-col>
|
|
|
</el-row>
|
|
|
</el-form>
|
|
|
</div>
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
-import {getCodeImg, isTenantExist} from "@/api/login";
|
|
|
-import {changeDatasource} from "@/api/dataEngine";
|
|
|
+import { getCodeImg, isTenantExist } from "@/api/login";
|
|
|
+import { changeDatasource } from "@/api/dataEngine";
|
|
|
import Cookies from "js-cookie";
|
|
|
-import {encrypt, decrypt} from "@/utils/jsencrypt";
|
|
|
+import { encrypt, decrypt } from "@/utils/jsencrypt";
|
|
|
|
|
|
export default {
|
|
|
name: "Login",
|
|
@@ -110,16 +108,16 @@ export default {
|
|
|
rememberMe: false,
|
|
|
code: "",
|
|
|
uuid: "",
|
|
|
- tenantID: ""
|
|
|
+ tenantID: "",
|
|
|
},
|
|
|
loginRules: {
|
|
|
username: [
|
|
|
- {required: true, trigger: "blur", message: "请输入您的账号"},
|
|
|
+ { required: true, trigger: "blur", message: "请输入您的账号" },
|
|
|
],
|
|
|
password: [
|
|
|
- {required: true, trigger: "blur", message: "请输入您的密码"},
|
|
|
+ { required: true, trigger: "blur", message: "请输入您的密码" },
|
|
|
],
|
|
|
- code: [{required: true, trigger: "blur", message: "请输入验证码"}],
|
|
|
+ code: [{ required: true, trigger: "blur", message: "请输入验证码" }],
|
|
|
},
|
|
|
loading: true,
|
|
|
// 验证码开关
|
|
@@ -140,49 +138,44 @@ export default {
|
|
|
},
|
|
|
},
|
|
|
created() {
|
|
|
- this.validateTenantId()
|
|
|
+ this.validateTenantId();
|
|
|
},
|
|
|
methods: {
|
|
|
handleBlur(event) {
|
|
|
- if (event.target.value.toLowerCase() === 'admin') {
|
|
|
- this.loginForm.username = '';
|
|
|
- this.$message.warning("请使用当前租户下的账号登录!")
|
|
|
+ if (event.target.value.toLowerCase() === "admin") {
|
|
|
+ this.loginForm.username = "";
|
|
|
+ this.$message.warning("请使用当前租户下的账号登录!");
|
|
|
}
|
|
|
- if (event.target.value.toLowerCase() === 'Admin') {
|
|
|
- this.loginForm.username = '';
|
|
|
- this.$message.warning("请使用当前租户下的账号登录!")
|
|
|
+ if (event.target.value.toLowerCase() === "Admin") {
|
|
|
+ this.loginForm.username = "";
|
|
|
+ this.$message.warning("请使用当前租户下的账号登录!");
|
|
|
}
|
|
|
},
|
|
|
// 校验url
|
|
|
validateTenantId() {
|
|
|
- let tenantCode = this.$route.query['tenantCode']
|
|
|
- console.log("租户登录", tenantCode);
|
|
|
+ let tenantCode = this.$route.query["tenantCode"];
|
|
|
if (tenantCode != null) {
|
|
|
// 得到tenantId 查询裤中是否存在该租户
|
|
|
- isTenantExist({tenantCode: tenantCode}).then(res => {
|
|
|
- if (res.data?.tenantId) { // 判断当前编号是否存在库中
|
|
|
+ isTenantExist({ tenantCode: tenantCode }).then((res) => {
|
|
|
+ if (res == undefined) {
|
|
|
+ this.$router.push({ path: "/401" });
|
|
|
+ } else if (res.data?.tenantId) {
|
|
|
+ // 判断当前编号是否存在库中
|
|
|
this.tenantId = res.data.tenantId;
|
|
|
this.loginForm.tenantID = this.tenantId;
|
|
|
- // 得到租户的信息
|
|
|
- this.config = res.data.loginPageConfiguration
|
|
|
- this.setConfig();
|
|
|
- // 如果当前租户没有配置登录页面则不可访问
|
|
|
- if (this.config == null && this.config == undefined) {
|
|
|
- // this.$router.push({path: "/404"})
|
|
|
- this.getCode();
|
|
|
- this.getCookie();
|
|
|
- } else {
|
|
|
- this.getCode();
|
|
|
- this.getCookie();
|
|
|
+ if (res.data.loginPageConfiguration != null) {
|
|
|
+ // 得到租户的信息
|
|
|
+ this.config = res.data.loginPageConfiguration;
|
|
|
+ this.setConfig();
|
|
|
}
|
|
|
} else {
|
|
|
+ console.log("租户有问题!");
|
|
|
// 当前访问链接中的租户编号不存在
|
|
|
- this.$router.push({path: "/404"})
|
|
|
+ this.$router.push({ path: "/401" });
|
|
|
}
|
|
|
- })
|
|
|
+ });
|
|
|
} else {
|
|
|
- console.log('跳转')
|
|
|
- this.$router.push({path: "/404"})
|
|
|
+ this.$router.push({ path: "/401" });
|
|
|
}
|
|
|
},
|
|
|
setConfig() {
|
|
@@ -202,10 +195,6 @@ export default {
|
|
|
loginBgDom[0].style.backgroundImage = `url(${
|
|
|
process.env.VUE_APP_BASE_IMG_API + loginPageBackgroundImage
|
|
|
})`;
|
|
|
-
|
|
|
- console.log("" + `url(${
|
|
|
- process.env.VUE_APP_BASE_IMG_API + loginPageBackgroundImage
|
|
|
- })`)
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -237,7 +226,6 @@ export default {
|
|
|
if (loginPageDescription) {
|
|
|
this.config.pageDescription = loginPageDescription;
|
|
|
}
|
|
|
-
|
|
|
},
|
|
|
getCode() {
|
|
|
getCodeImg().then((res) => {
|
|
@@ -266,7 +254,7 @@ export default {
|
|
|
if (valid) {
|
|
|
this.loading = true;
|
|
|
if (this.loginForm.rememberMe) {
|
|
|
- Cookies.set("username", this.loginForm.username, {expires: 30});
|
|
|
+ Cookies.set("username", this.loginForm.username, { expires: 30 });
|
|
|
Cookies.set("password", encrypt(this.loginForm.password), {
|
|
|
expires: 30,
|
|
|
});
|
|
@@ -280,18 +268,20 @@ export default {
|
|
|
}
|
|
|
let form = {
|
|
|
...this.loginForm,
|
|
|
- tenantID: this.tenantId
|
|
|
- }
|
|
|
- this.$store.dispatch("Login", form).then(() => {
|
|
|
- // changeDatasource(); //切换数据源
|
|
|
- this.$router.push({path: this.redirect || "/"}).catch(() => {
|
|
|
+ tenantID: this.tenantId,
|
|
|
+ };
|
|
|
+ this.$store
|
|
|
+ .dispatch("Login", form)
|
|
|
+ .then(() => {
|
|
|
+ // changeDatasource(); //切换数据源
|
|
|
+ this.$router.push({ path: this.redirect || "/" }).catch(() => {});
|
|
|
+ })
|
|
|
+ .catch(() => {
|
|
|
+ this.loading = false;
|
|
|
+ if (this.captchaEnabled) {
|
|
|
+ this.getCode();
|
|
|
+ }
|
|
|
});
|
|
|
- }).catch(() => {
|
|
|
- this.loading = false;
|
|
|
- if (this.captchaEnabled) {
|
|
|
- this.getCode();
|
|
|
- }
|
|
|
- });
|
|
|
}
|
|
|
});
|
|
|
},
|
|
@@ -349,9 +339,9 @@ export default {
|
|
|
opacity: 1;
|
|
|
border-radius: 27px;
|
|
|
background: linear-gradient(
|
|
|
- 135deg,
|
|
|
- rgba(79, 138, 255, 1) 0%,
|
|
|
- rgba(75, 94, 255, 1) 100%
|
|
|
+ 135deg,
|
|
|
+ rgba(79, 138, 255, 1) 0%,
|
|
|
+ rgba(75, 94, 255, 1) 100%
|
|
|
);
|
|
|
box-shadow: 0px 4px 16px rgba(179, 192, 231, 1);
|
|
|
color: #fff;
|