|
|
@@ -8,6 +8,28 @@
|
|
|
:rules="rules"
|
|
|
class="login-form"
|
|
|
>
|
|
|
+ <el-form-item prop="tenantId">
|
|
|
+ <el-select
|
|
|
+ v-model="formInline.tenantId"
|
|
|
+ placeholder="请选择租户"
|
|
|
+ @chnage="tenantIdChange"
|
|
|
+ class="w-full"
|
|
|
+ >
|
|
|
+ <el-option
|
|
|
+ v-for="item in tenantOptions"
|
|
|
+ :key="item.tenantId"
|
|
|
+ :label="item.tenantName"
|
|
|
+ :value="item.tenantId"
|
|
|
+ />
|
|
|
+
|
|
|
+ <template #prefix>
|
|
|
+ <el-icon size="18" color="#808695">
|
|
|
+ <PersonOutline />
|
|
|
+ </el-icon>
|
|
|
+ </template>
|
|
|
+ </el-select>
|
|
|
+ </el-form-item>
|
|
|
+
|
|
|
<el-form-item prop="username">
|
|
|
<el-input v-model="formInline.username" placeholder="请输入用户名">
|
|
|
<template #prefix>
|
|
|
@@ -112,9 +134,9 @@
|
|
|
import { reactive, ref, onMounted } from 'vue';
|
|
|
import { useRoute, useRouter } from 'vue-router';
|
|
|
import { useUserStore } from '@/store/modules/user';
|
|
|
- import { ElMessage } from 'element-plus';
|
|
|
+ import { ElMessage, FormRules } from 'element-plus';
|
|
|
import { ResultEnum } from '@/enums/httpEnum';
|
|
|
- import { initData, captchaBase64 } from '@/api/common/index';
|
|
|
+ import { initData, captchaBase64, tentantList } from '@/api/common/index';
|
|
|
import { CodeOutlined } from '@vicons/antd';
|
|
|
import { PersonOutline, LockClosedOutline, LogoGithub, LogoFacebook } from '@vicons/ionicons5';
|
|
|
import { PageEnum } from '@/enums/pageEnum';
|
|
|
@@ -124,6 +146,7 @@
|
|
|
password: string;
|
|
|
verCode: string;
|
|
|
vercodeType: number;
|
|
|
+ tenantId: number | undefined;
|
|
|
}
|
|
|
|
|
|
const formRef = ref();
|
|
|
@@ -135,16 +158,26 @@
|
|
|
const captchaImgUrl = ref();
|
|
|
const LOGIN_NAME = PageEnum.BASE_LOGIN_NAME;
|
|
|
|
|
|
+ const tenantOptions = ref<{ tenantCode: string; tenantId: number; tenantName: string }[]>([]);
|
|
|
+ const tenantAccounts = [
|
|
|
+ { username: 'bj', password: '123456' },
|
|
|
+ { username: 'sz', password: '123456' },
|
|
|
+ { username: 'gz', password: '123456' },
|
|
|
+ { username: 'sh', password: '123456' },
|
|
|
+ ];
|
|
|
+
|
|
|
const formInline = reactive({
|
|
|
username: 'test',
|
|
|
password: '123456',
|
|
|
verCode: '',
|
|
|
vercodeType: 5,
|
|
|
+ tenantId: undefined,
|
|
|
});
|
|
|
|
|
|
- const rules = {
|
|
|
+ const rules: FormRules = {
|
|
|
username: { required: true, message: '请输入用户名', trigger: 'blur' },
|
|
|
password: { required: true, message: '请输入密码', trigger: 'blur' },
|
|
|
+ tenantId: { required: true, message: '请选择租户', type: 'number', trigger: 'change' },
|
|
|
};
|
|
|
const emit = defineEmits(['goRegister']);
|
|
|
const userStore = useUserStore();
|
|
|
@@ -152,6 +185,25 @@
|
|
|
const router = useRouter();
|
|
|
const route = useRoute();
|
|
|
|
|
|
+ function tenantIdChange() {
|
|
|
+ const tenantId = formInline.tenantId;
|
|
|
+ const index = tenantOptions.value.findIndex((item) => item.tenantId === tenantId);
|
|
|
+ if (index >= 0) {
|
|
|
+ const info = tenantAccounts[index];
|
|
|
+ formInline.username = info.username;
|
|
|
+ formInline.password = info.password;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ function getTentantList() {
|
|
|
+ tentantList().then((res) => {
|
|
|
+ tenantOptions.value = res;
|
|
|
+ if (res.length) {
|
|
|
+ formInline.tenantId = res[0].tenantId;
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
//获取验证码
|
|
|
function getCaptcha() {
|
|
|
const vercodeType = formInline.vercodeType;
|
|
|
@@ -168,7 +220,7 @@
|
|
|
if (!formRef.value) return;
|
|
|
formRef.value.validate(async (valid) => {
|
|
|
if (valid) {
|
|
|
- const { username, password, verCode, vercodeType } = formInline;
|
|
|
+ const { username, password, verCode, vercodeType, tenantId } = formInline;
|
|
|
loading.value = true;
|
|
|
|
|
|
const params: FormState = {
|
|
|
@@ -176,6 +228,7 @@
|
|
|
password,
|
|
|
verCode,
|
|
|
vercodeType,
|
|
|
+ tenantId,
|
|
|
};
|
|
|
|
|
|
try {
|
|
|
@@ -218,6 +271,7 @@
|
|
|
|
|
|
onMounted(() => {
|
|
|
getInitData();
|
|
|
+ getTentantList();
|
|
|
});
|
|
|
</script>
|
|
|
|
|
|
@@ -230,5 +284,10 @@
|
|
|
.el-input {
|
|
|
--el-input-border-radius: 20px !important;
|
|
|
}
|
|
|
+ .el-select {
|
|
|
+ .el-input {
|
|
|
+ --el-input-border-radius: 20px !important;
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
</style>
|