From 2dbb363b007623714d8c8b808eadec309bf74560 Mon Sep 17 00:00:00 2001 From: gexinzhineng/gxzn27 <1348660141@qq.com> Date: Mon, 10 Apr 2023 10:48:56 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AF=86=E7=A0=81=E6=A0=A1=E9=AA=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/system/user/user.data.ts | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/src/views/system/user/user.data.ts b/src/views/system/user/user.data.ts index 2ea4d268..fd8a3677 100644 --- a/src/views/system/user/user.data.ts +++ b/src/views/system/user/user.data.ts @@ -13,11 +13,31 @@ const validateMobile = (rule: any, value: any, callback: any) => { } } } +const validatePassword = (rule: any, value: any, callback: any) => { + const reg = /^(?! +$).+/ + if (value === '') { + callback(new Error('请输入用户密码')) + } else { + if (!reg.test(value)) { + callback(new Error('名称不能为空或空字符串')) + } else { + callback() + } + } +} // 表单校验 export const rules = reactive({ username: [required], nickname: [required], - password: [required], + password: [ + { + min: 4, + max: 16, + trigger: 'blur', + message: '密码长度为 4-16 位' + }, + { validator: validatePassword, trigger: 'blur' } + ], deptId: [required], email: [ { required: true, message: t('profile.rules.mail'), trigger: 'blur' },