Showing
3 changed files
with
22 additions
and
2 deletions
| 1 | 1 | import { FormSchema } from '/@/components/Table'; |
| 2 | -import { phoneRule, emailRule } from '/@/utils/rules'; | |
| 2 | +import { phoneRule, emailRule, chineseAndEnlishRule } from '/@/utils/rules'; | |
| 3 | 3 | |
| 4 | 4 | export const formSchema: FormSchema[] = [ |
| 5 | 5 | { |
| ... | ... | @@ -12,6 +12,7 @@ export const formSchema: FormSchema[] = [ |
| 12 | 12 | maxLength: 10, |
| 13 | 13 | placeholder: '请输入用户昵称', |
| 14 | 14 | }, |
| 15 | + rules: chineseAndEnlishRule, | |
| 15 | 16 | }, |
| 16 | 17 | { |
| 17 | 18 | field: 'phoneNumber', | ... | ... |
| ... | ... | @@ -20,6 +20,23 @@ export const numberRule: Rule[] = [ |
| 20 | 20 | ]; |
| 21 | 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 | 41 | export const phoneRule: Rule[] = [ |
| 25 | 42 | { |
| ... | ... | @@ -41,7 +58,7 @@ export const phoneRule: Rule[] = [ |
| 41 | 58 | export const emailRule: Rule[] = [ |
| 42 | 59 | { |
| 43 | 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 | 62 | if (!value) { |
| 46 | 63 | return Promise.resolve(); |
| 47 | 64 | } else if (!reg.test(value)) { | ... | ... |
| ... | ... | @@ -18,6 +18,7 @@ |
| 18 | 18 | import { UserDTO } from '/@/api/tenant/tenantInfo'; |
| 19 | 19 | import { ChineseRegexp, EmailRegexp, emailRule, phoneRule } from '/@/utils/rules'; |
| 20 | 20 | // import { isAccountExist } from '/@/api/system/system'; |
| 21 | + import { chineseAndEnlishRule } from '/@/utils/rules'; | |
| 21 | 22 | |
| 22 | 23 | export default defineComponent({ |
| 23 | 24 | name: 'TenantAdminFormDrawer', |
| ... | ... | @@ -88,6 +89,7 @@ |
| 88 | 89 | componentProps: { |
| 89 | 90 | maxLength: 255, |
| 90 | 91 | }, |
| 92 | + rules: chineseAndEnlishRule, | |
| 91 | 93 | }, |
| 92 | 94 | { |
| 93 | 95 | field: 'phoneNumber', | ... | ... |