From de448a3e64f556bcfbf6708427f302c335b6c653 Mon Sep 17 00:00:00 2001 From: zhonghua Date: Tue, 24 Mar 2026 16:07:27 +0800 Subject: [PATCH] =?UTF-8?q?feat(=E5=AD=A6=E6=A0=A1=E7=AB=AF):=20=E6=95=99?= =?UTF-8?q?=E5=B8=88/=E5=AE=B6=E9=95=BF=E7=99=BB=E5=BD=95=E8=B4=A6?= =?UTF-8?q?=E5=8F=B7=E6=A0=A1=E9=AA=8C=E4=B8=8E=E7=A7=9F=E6=88=B7=E4=B8=80?= =?UTF-8?q?=E8=87=B4=EF=BC=8C=E6=8A=BD=E5=8F=96=20loginAccount=20=E5=B8=B8?= =?UTF-8?q?=E9=87=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Made-with: Cursor --- .../src/constants/loginAccount.ts | 9 +++++++++ .../src/views/admin/tenants/TenantListView.vue | 12 ++++++++++-- .../views/school/parents/ParentListView.vue | 18 ++++++++++++++---- .../views/school/teachers/TeacherListView.vue | 18 ++++++++++++++---- 4 files changed, 47 insertions(+), 10 deletions(-) create mode 100644 reading-platform-frontend/src/constants/loginAccount.ts diff --git a/reading-platform-frontend/src/constants/loginAccount.ts b/reading-platform-frontend/src/constants/loginAccount.ts new file mode 100644 index 0000000..1e32859 --- /dev/null +++ b/reading-platform-frontend/src/constants/loginAccount.ts @@ -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位字母数字或下划线'; diff --git a/reading-platform-frontend/src/views/admin/tenants/TenantListView.vue b/reading-platform-frontend/src/views/admin/tenants/TenantListView.vue index 010fc8f..590c49e 100644 --- a/reading-platform-frontend/src/views/admin/tenants/TenantListView.vue +++ b/reading-platform-frontend/src/views/admin/tenants/TenantListView.vue @@ -126,7 +126,7 @@ - + @@ -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: [ diff --git a/reading-platform-frontend/src/views/school/parents/ParentListView.vue b/reading-platform-frontend/src/views/school/parents/ParentListView.vue index b1c33f4..d723317 100644 --- a/reading-platform-frontend/src/views/school/parents/ParentListView.vue +++ b/reading-platform-frontend/src/views/school/parents/ParentListView.vue @@ -148,7 +148,7 @@ - + @@ -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({ password: '', }); -const rules: Record = { +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; diff --git a/reading-platform-frontend/src/views/school/teachers/TeacherListView.vue b/reading-platform-frontend/src/views/school/teachers/TeacherListView.vue index 25715f1..5f2f67d 100644 --- a/reading-platform-frontend/src/views/school/teachers/TeacherListView.vue +++ b/reading-platform-frontend/src/views/school/teachers/TeacherListView.vue @@ -152,7 +152,7 @@ - + @@ -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( status: 'ACTIVE', }); -const rules: Record = { +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;