Showing
3 changed files
with
22 additions
and
2 deletions
1 | import { FormSchema } from '/@/components/Table'; | 1 | import { FormSchema } from '/@/components/Table'; |
2 | -import { phoneRule, emailRule } from '/@/utils/rules'; | 2 | +import { phoneRule, emailRule, chineseAndEnlishRule } from '/@/utils/rules'; |
3 | 3 | ||
4 | export const formSchema: FormSchema[] = [ | 4 | export const formSchema: FormSchema[] = [ |
5 | { | 5 | { |
@@ -12,6 +12,7 @@ export const formSchema: FormSchema[] = [ | @@ -12,6 +12,7 @@ export const formSchema: FormSchema[] = [ | ||
12 | maxLength: 10, | 12 | maxLength: 10, |
13 | placeholder: '请输入用户昵称', | 13 | placeholder: '请输入用户昵称', |
14 | }, | 14 | }, |
15 | + rules: chineseAndEnlishRule, | ||
15 | }, | 16 | }, |
16 | { | 17 | { |
17 | field: 'phoneNumber', | 18 | field: 'phoneNumber', |
@@ -20,6 +20,23 @@ export const numberRule: Rule[] = [ | @@ -20,6 +20,23 @@ export const numberRule: Rule[] = [ | ||
20 | ]; | 20 | ]; |
21 | export const phoneRegexp = /^[1][3,4,5,6,7,8,9][0-9]{9}$/; | 21 | export const phoneRegexp = /^[1][3,4,5,6,7,8,9][0-9]{9}$/; |
22 | 22 | ||
23 | +//中英文正则 | ||
24 | +export const chineseAndEnlishRule: Rule[] = [ | ||
25 | + { | ||
26 | + required: true, | ||
27 | + validator: (_, value: string) => { | ||
28 | + const reg = /^[a-zA-Z\u4e00-\u9fa5]+$/; | ||
29 | + if (value === '') { | ||
30 | + return Promise.reject('请输入'); | ||
31 | + } else if (!reg.test(value)) { | ||
32 | + return Promise.reject('格式不正确'); | ||
33 | + } | ||
34 | + return Promise.resolve(); | ||
35 | + }, | ||
36 | + validateTrigger: 'blur', | ||
37 | + }, | ||
38 | +]; | ||
39 | + | ||
23 | // 手机号验证 | 40 | // 手机号验证 |
24 | export const phoneRule: Rule[] = [ | 41 | export const phoneRule: Rule[] = [ |
25 | { | 42 | { |
@@ -41,7 +58,7 @@ export const phoneRule: Rule[] = [ | @@ -41,7 +58,7 @@ export const phoneRule: Rule[] = [ | ||
41 | export const emailRule: Rule[] = [ | 58 | export const emailRule: Rule[] = [ |
42 | { | 59 | { |
43 | validator: (_, value: string) => { | 60 | validator: (_, value: string) => { |
44 | - const reg = /^[a-zA-Z0-9_.-]+@[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)*\.[a-zA-Z0-9]{2,6}$/; | 61 | + const reg = /^[a-zA-Z0-9]+([-_.][A-Za-zd]+)*@([a-zA-Z0-9]+[-.])+[A-Za-zd]{2,5}$/; |
45 | if (!value) { | 62 | if (!value) { |
46 | return Promise.resolve(); | 63 | return Promise.resolve(); |
47 | } else if (!reg.test(value)) { | 64 | } else if (!reg.test(value)) { |
@@ -18,6 +18,7 @@ | @@ -18,6 +18,7 @@ | ||
18 | import { UserDTO } from '/@/api/tenant/tenantInfo'; | 18 | import { UserDTO } from '/@/api/tenant/tenantInfo'; |
19 | import { ChineseRegexp, EmailRegexp, emailRule, phoneRule } from '/@/utils/rules'; | 19 | import { ChineseRegexp, EmailRegexp, emailRule, phoneRule } from '/@/utils/rules'; |
20 | // import { isAccountExist } from '/@/api/system/system'; | 20 | // import { isAccountExist } from '/@/api/system/system'; |
21 | + import { chineseAndEnlishRule } from '/@/utils/rules'; | ||
21 | 22 | ||
22 | export default defineComponent({ | 23 | export default defineComponent({ |
23 | name: 'TenantAdminFormDrawer', | 24 | name: 'TenantAdminFormDrawer', |
@@ -88,6 +89,7 @@ | @@ -88,6 +89,7 @@ | ||
88 | componentProps: { | 89 | componentProps: { |
89 | maxLength: 255, | 90 | maxLength: 255, |
90 | }, | 91 | }, |
92 | + rules: chineseAndEnlishRule, | ||
91 | }, | 93 | }, |
92 | { | 94 | { |
93 | field: 'phoneNumber', | 95 | field: 'phoneNumber', |