| | |
| | | <h3 class="title">RuoYi-Vue-Plus多租户管理系统</h3> |
| | | <el-form-item prop="tenantId" v-if="tenantEnabled"> |
| | | <el-select v-model="loginForm.tenantId" filterable placeholder="请选择/输入公司名称" style="width: 100%"> |
| | | <el-option v-for="item in tenantList" :key="item.tenantId" :label="item.companyName" |
| | | :value="item.tenantId"></el-option> |
| | | <el-option v-for="item in tenantList" :key="item.tenantId" :label="item.companyName" :value="item.tenantId"></el-option> |
| | | <template #prefix><svg-icon icon-class="company" class="el-input__icon input-icon" /></template> |
| | | </el-select> |
| | | </el-form-item> |
| | |
| | | </el-input> |
| | | </el-form-item> |
| | | <el-form-item prop="password"> |
| | | <el-input v-model="loginForm.password" type="password" size="large" auto-complete="off" placeholder="密码" |
| | | @keyup.enter="handleLogin"> |
| | | <el-input v-model="loginForm.password" type="password" size="large" auto-complete="off" placeholder="密码" @keyup.enter="handleLogin"> |
| | | <template #prefix><svg-icon icon-class="password" class="el-input__icon input-icon" /></template> |
| | | </el-input> |
| | | </el-form-item> |
| | | <el-form-item prop="code" v-if="captchaEnabled"> |
| | | <el-input v-model="loginForm.code" size="large" auto-complete="off" placeholder="验证码" style="width: 63%" |
| | | @keyup.enter="handleLogin"> |
| | | <el-input v-model="loginForm.code" size="large" auto-complete="off" placeholder="验证码" style="width: 63%" @keyup.enter="handleLogin"> |
| | | <template #prefix><svg-icon icon-class="validCode" class="el-input__icon input-icon" /></template> |
| | | </el-input> |
| | | <div class="login-code"> |
| | |
| | | import { encrypt, decrypt } from '@/utils/jsencrypt'; |
| | | import { useUserStore } from '@/store/modules/user'; |
| | | import { LoginData, TenantVO } from '@/api/types'; |
| | | import { ElForm, FormRules } from 'element-plus'; |
| | | import { to } from 'await-to-js'; |
| | | import { HttpStatus } from "@/enums/RespEnum"; |
| | | |
| | | const userStore = useUserStore(); |
| | | const router = useRouter(); |
| | | |
| | | const loginForm = ref<LoginData>({ |
| | | tenantId: "000000", |
| | | tenantId: '000000', |
| | | username: 'admin', |
| | | password: 'admin123', |
| | | rememberMe: false, |
| | |
| | | uuid: '' |
| | | }); |
| | | |
| | | const loginRules: FormRules = { |
| | | const loginRules: ElFormRules = { |
| | | tenantId: [{ required: true, trigger: "blur", message: "请输入您的租户编号" }], |
| | | username: [{ required: true, trigger: 'blur', message: '请输入您的账号' }], |
| | | password: [{ required: true, trigger: 'blur', message: '请输入您的密码' }], |
| | |
| | | // 注册开关 |
| | | const register = ref(false); |
| | | const redirect = ref(undefined); |
| | | const loginRef = ref(ElForm); |
| | | const loginRef = ref<ElFormInstance>(); |
| | | // 租户列表 |
| | | const tenantList = ref<TenantVO[]>([]); |
| | | |
| | | const handleLogin = () => { |
| | | loginRef.value.validate(async (valid: boolean, fields: any) => { |
| | | loginRef.value?.validate(async (valid: boolean, fields: any) => { |
| | | if (valid) { |
| | | loading.value = true; |
| | | // 勾选了需要记住密码设置在 cookie 中设置记住用户名和密码 |
| | |
| | | Cookies.remove('rememberMe'); |
| | | } |
| | | // 调用action的登录方法 |
| | | // prittier-ignore |
| | | const [err] = await to(userStore.login(loginForm.value)); |
| | | if (!err) { |
| | | await router.push({ path: redirect.value || '/' }); |
| | |
| | | */ |
| | | const doSocialLogin = (type: string) => { |
| | | authBinding(type).then((res: any) => { |
| | | if (res.code === 200) { |
| | | window.location.href = res.msg; |
| | | if (res.code === HttpStatus.SUCCESS) { |
| | | // 获取授权地址跳转 |
| | | window.location.href = res.data; |
| | | } else { |
| | | ElMessage.error(res.msg); |
| | | } |