|
|
|
@ -17,6 +17,17 @@ |
|
|
|
|
|
|
|
<a-form layout="vertical" :model="state.formInline" @submit.prevent="handleSubmit"> |
|
|
|
<a-form-item> |
|
|
|
<a-input |
|
|
|
v-model:value="state.formInline.account" |
|
|
|
size="large" |
|
|
|
:placeholder="!state.isRegister ? '请输入账号' : '账号长度5-30个字符,仅限英文字母'" |
|
|
|
class="custom-input" |
|
|
|
> |
|
|
|
<template #prefix><user-outlined /></template> |
|
|
|
</a-input> |
|
|
|
</a-form-item> |
|
|
|
<!-- 用户名 --> |
|
|
|
<a-form-item v-if="state.isRegister"> |
|
|
|
<a-input |
|
|
|
v-model:value="state.formInline.username" |
|
|
|
size="large" |
|
|
|
@ -116,6 +127,7 @@ |
|
|
|
isRegister: false, // 新增:控制是否为注册模式 |
|
|
|
captcha: '', |
|
|
|
formInline: { |
|
|
|
account: '', |
|
|
|
username: '', |
|
|
|
password: '', |
|
|
|
company: '', // 新增:公司名称字段 |
|
|
|
@ -132,6 +144,7 @@ |
|
|
|
// 新增:切换登录/注册模式 |
|
|
|
const toggleMode = () => { |
|
|
|
state.isRegister = !state.isRegister; |
|
|
|
state.formInline.account = ''; |
|
|
|
state.formInline.username = ''; |
|
|
|
state.formInline.password = ''; |
|
|
|
state.formInline.confirmPassword = ''; |
|
|
|
@ -141,9 +154,9 @@ |
|
|
|
|
|
|
|
// 修改:处理表单提交 |
|
|
|
const handleSubmit = async () => { |
|
|
|
const { username, password, confirmPassword } = state.formInline; |
|
|
|
const { account, username, password, confirmPassword } = state.formInline; |
|
|
|
|
|
|
|
if (username.trim() === '' || password.trim() === '') { |
|
|
|
if (account.trim() === '' || password.trim() === '') { |
|
|
|
return message.warning('用户名或密码不能为空!'); |
|
|
|
} |
|
|
|
|
|
|
|
@ -151,6 +164,14 @@ |
|
|
|
if (password !== confirmPassword) { |
|
|
|
return message.warning('两次输入的密码不一致!'); |
|
|
|
} |
|
|
|
if (username.trim() === '') { |
|
|
|
return message.warning('用户名不能为空!'); |
|
|
|
} |
|
|
|
// 限制用户名不得超过100个字符 |
|
|
|
if (username.length > 100) { |
|
|
|
return message.warning('用户名不得超过100个字符!'); |
|
|
|
} |
|
|
|
|
|
|
|
if (state.formInline.email.trim() === '') { |
|
|
|
return message.warning('邮箱不能为空!'); |
|
|
|
} |
|
|
|
@ -160,17 +181,28 @@ |
|
|
|
if (state.formInline.company.trim() === '') { |
|
|
|
return message.warning('公司名称不能为空!'); |
|
|
|
} |
|
|
|
// 限制公司名称不得超过100个字符 |
|
|
|
if (state.formInline.company.length > 100) { |
|
|
|
return message.warning('公司名称不得超过100个字符!'); |
|
|
|
} |
|
|
|
// 限制长度 5-30位 且仅限英文字母 |
|
|
|
if (state.formInline.account.length < 5 || state.formInline.account.length > 30) { |
|
|
|
return message.warning('账号长度需为5到30个字母!'); |
|
|
|
} |
|
|
|
if (!/^[a-zA-Z]+$/.test(state.formInline.account)) { |
|
|
|
return message.warning('账号仅限英文字母!'); |
|
|
|
} |
|
|
|
|
|
|
|
// TODO: 调用注册接口 |
|
|
|
state.loading = true; |
|
|
|
try { |
|
|
|
await register({ |
|
|
|
...state.formInline, |
|
|
|
account: state.formInline.username, |
|
|
|
sex: 1, |
|
|
|
}); |
|
|
|
message.success('注册成功,请联系系统管理员通过审核'); |
|
|
|
setTimeout(() => { |
|
|
|
state.isRegister = false; // 注册成功后切换到登录模式 |
|
|
|
toggleMode(); |
|
|
|
}, 1000); |
|
|
|
} catch (err: any) { |
|
|
|
Modal.error({ |
|
|
|
|