feat(学校端): 教师/家长登录账号校验与租户一致,抽取 loginAccount 常量
Made-with: Cursor
This commit is contained in:
parent
1751d0e355
commit
de448a3e64
9
reading-platform-frontend/src/constants/loginAccount.ts
Normal file
9
reading-platform-frontend/src/constants/loginAccount.ts
Normal file
@ -0,0 +1,9 @@
|
||||
/**
|
||||
* 登录账号规则(与租户管理、学校端教师/家长创建约定一致)
|
||||
* 字母开头,4-20 位字母、数字或下划线
|
||||
*/
|
||||
export const LOGIN_ACCOUNT_PATTERN = /^[a-zA-Z][a-zA-Z0-9_]{3,19}$/;
|
||||
|
||||
export const LOGIN_ACCOUNT_PLACEHOLDER = '字母开头,4-20位';
|
||||
|
||||
export const LOGIN_ACCOUNT_PATTERN_MESSAGE = '字母开头,4-20位字母数字或下划线';
|
||||
@ -126,7 +126,7 @@
|
||||
<a-input v-model:value="formData.name" placeholder="请输入学校名称" />
|
||||
</a-form-item>
|
||||
<a-form-item v-if="!isEdit" label="登录账号" name="loginAccount">
|
||||
<a-input v-model:value="formData.loginAccount" placeholder="字母开头,4-20位" :disabled="isEdit" />
|
||||
<a-input v-model:value="formData.loginAccount" :placeholder="LOGIN_ACCOUNT_PLACEHOLDER" :disabled="isEdit" />
|
||||
</a-form-item>
|
||||
<a-form-item v-if="!isEdit" label="初始密码" name="password">
|
||||
<a-input-password v-model:value="formData.password" placeholder="留空则默认为 123456" />
|
||||
@ -351,6 +351,11 @@ import {
|
||||
type CourseCollectionResponse,
|
||||
} from '@/api/admin';
|
||||
import { getDiscountTypeText } from '@/api/collections';
|
||||
import {
|
||||
LOGIN_ACCOUNT_PATTERN,
|
||||
LOGIN_ACCOUNT_PATTERN_MESSAGE,
|
||||
LOGIN_ACCOUNT_PLACEHOLDER,
|
||||
} from '@/constants/loginAccount';
|
||||
|
||||
// 搜索表单
|
||||
const searchForm = reactive({
|
||||
@ -414,7 +419,10 @@ const formRules = {
|
||||
name: [{ required: true, message: '请输入学校名称' }],
|
||||
loginAccount: [
|
||||
{ required: true, message: '请输入登录账号' },
|
||||
{ pattern: /^[a-zA-Z][a-zA-Z0-9_]{3,19}$/, message: '字母开头,4-20位字母数字或下划线' },
|
||||
{
|
||||
pattern: LOGIN_ACCOUNT_PATTERN,
|
||||
message: LOGIN_ACCOUNT_PATTERN_MESSAGE,
|
||||
},
|
||||
],
|
||||
contactPerson: [{ required: true, message: '请输入联系人' }],
|
||||
contactPhone: [
|
||||
|
||||
@ -148,7 +148,7 @@
|
||||
</a-input>
|
||||
</a-form-item>
|
||||
<a-form-item label="登录账号" name="loginAccount">
|
||||
<a-input v-model:value="formState.loginAccount" placeholder="请输入登录账号" :disabled="isEdit">
|
||||
<a-input v-model:value="formState.loginAccount" :placeholder="LOGIN_ACCOUNT_PLACEHOLDER" :disabled="isEdit">
|
||||
<template #prefix>
|
||||
<KeyOutlined style="color: #B2BEC3;" />
|
||||
</template>
|
||||
@ -335,6 +335,11 @@ import {
|
||||
getClasses,
|
||||
} from '@/api/school';
|
||||
import type { Parent, CreateParentDto, ParentChild, Student } from '@/api/school';
|
||||
import {
|
||||
LOGIN_ACCOUNT_PATTERN,
|
||||
LOGIN_ACCOUNT_PATTERN_MESSAGE,
|
||||
LOGIN_ACCOUNT_PLACEHOLDER,
|
||||
} from '@/constants/loginAccount';
|
||||
|
||||
// 状态辅助函数
|
||||
const getParentStatusText = (status: string): string => {
|
||||
@ -412,14 +417,19 @@ const formState = reactive<CreateParentDto & { id?: number }>({
|
||||
password: '',
|
||||
});
|
||||
|
||||
const rules: Record<string, any[]> = {
|
||||
const rules = computed(() => ({
|
||||
name: [{ required: true, message: '请输入家长姓名', trigger: 'blur' }],
|
||||
phone: [
|
||||
{ required: true, message: '请输入手机号', trigger: 'blur' },
|
||||
{ pattern: /^1[3-9]\d{9}$/, message: '请输入正确的手机号', trigger: 'blur' },
|
||||
],
|
||||
loginAccount: [{ required: true, message: '请输入登录账号', trigger: 'blur' }],
|
||||
};
|
||||
loginAccount: [
|
||||
{ required: true, message: '请输入登录账号', trigger: 'blur' },
|
||||
...(!isEdit.value
|
||||
? [{ pattern: LOGIN_ACCOUNT_PATTERN, message: LOGIN_ACCOUNT_PATTERN_MESSAGE, trigger: 'blur' }]
|
||||
: []),
|
||||
],
|
||||
}));
|
||||
|
||||
const loadParents = async () => {
|
||||
loading.value = true;
|
||||
|
||||
@ -152,7 +152,7 @@
|
||||
</a-input>
|
||||
</a-form-item>
|
||||
<a-form-item label="登录账号" name="loginAccount">
|
||||
<a-input v-model:value="formState.loginAccount" placeholder="请输入登录账号" :disabled="isEdit">
|
||||
<a-input v-model:value="formState.loginAccount" :placeholder="LOGIN_ACCOUNT_PLACEHOLDER" :disabled="isEdit">
|
||||
<template #prefix>
|
||||
<KeyOutlined style="color: #B2BEC3;" />
|
||||
</template>
|
||||
@ -234,6 +234,11 @@ import {
|
||||
getClasses,
|
||||
} from '@/api/school';
|
||||
import type { Teacher, CreateTeacherDto, ClassInfo } from '@/api/school';
|
||||
import {
|
||||
LOGIN_ACCOUNT_PATTERN,
|
||||
LOGIN_ACCOUNT_PATTERN_MESSAGE,
|
||||
LOGIN_ACCOUNT_PLACEHOLDER,
|
||||
} from '@/constants/loginAccount';
|
||||
|
||||
// 状态辅助函数
|
||||
const getTeacherStatusText = (status: string): string => {
|
||||
@ -301,14 +306,19 @@ const formState = reactive<CreateTeacherDto & { id?: number; status?: string }>(
|
||||
status: 'ACTIVE',
|
||||
});
|
||||
|
||||
const rules: Record<string, any[]> = {
|
||||
const rules = computed(() => ({
|
||||
name: [{ required: true, message: '请输入教师姓名', trigger: 'blur' }],
|
||||
phone: [
|
||||
{ required: true, message: '请输入手机号', trigger: 'blur' },
|
||||
{ pattern: /^1[3-9]\d{9}$/, message: '请输入正确的手机号', trigger: 'blur' },
|
||||
],
|
||||
loginAccount: [{ required: true, message: '请输入登录账号', trigger: 'blur' }],
|
||||
};
|
||||
loginAccount: [
|
||||
{ required: true, message: '请输入登录账号', trigger: 'blur' },
|
||||
...(!isEdit.value
|
||||
? [{ pattern: LOGIN_ACCOUNT_PATTERN, message: LOGIN_ACCOUNT_PATTERN_MESSAGE, trigger: 'blur' }]
|
||||
: []),
|
||||
],
|
||||
}));
|
||||
|
||||
const loadTeachers = async () => {
|
||||
loading.value = true;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user