From c97947169c21878b6d209494af422fb8fd0c7530 Mon Sep 17 00:00:00 2001 From: suyanyan <1321717064@qq.com> Date: Sun, 29 Sep 2024 10:16:32 +0800 Subject: [PATCH] =?UTF-8?q?=E7=A6=85=E9=81=93bug=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../keyPersonnel/components/form/form_basic.vue | 2 +- .../keyPersonnel/components/form/index.vue | 11 ++++++++++- .../personnel/components/form/form_basic.vue | 2 +- .../userManage/personnel/components/form/index.vue | 14 ++++++++++---- 4 files changed, 22 insertions(+), 7 deletions(-) diff --git a/SafeCampus.WEB/src/views/userManage/keyPersonnel/components/form/form_basic.vue b/SafeCampus.WEB/src/views/userManage/keyPersonnel/components/form/form_basic.vue index a0320f6..380eace 100644 --- a/SafeCampus.WEB/src/views/userManage/keyPersonnel/components/form/form_basic.vue +++ b/SafeCampus.WEB/src/views/userManage/keyPersonnel/components/form/form_basic.vue @@ -51,7 +51,7 @@ - + diff --git a/SafeCampus.WEB/src/views/userManage/keyPersonnel/components/form/index.vue b/SafeCampus.WEB/src/views/userManage/keyPersonnel/components/form/index.vue index 407bd69..1c9cb8f 100644 --- a/SafeCampus.WEB/src/views/userManage/keyPersonnel/components/form/index.vue +++ b/SafeCampus.WEB/src/views/userManage/keyPersonnel/components/form/index.vue @@ -42,6 +42,14 @@ const sysUserProps = reactive>({ record: {}, disabled: false }); +const checkAgeNumber = (rule: any, value: any, callback: any) => { + if (value === "") callback("请输入年龄"); + if (value > 100 || value < 0) { + callback(new Error("请输入正确的年龄(年龄范围1-100岁)")); + } else { + return callback(); + } +}; // 表单验证规则 const rules = reactive({ @@ -51,7 +59,8 @@ const rules = reactive({ phone: [ { required: true, message: "请输入手机号", trigger: "blur" }, { validator: checkPhoneNumber, trigger: "blur" } - ] + ], + age: [{ validator: checkAgeNumber, trigger: "blur" }] }); /** diff --git a/SafeCampus.WEB/src/views/userManage/personnel/components/form/form_basic.vue b/SafeCampus.WEB/src/views/userManage/personnel/components/form/form_basic.vue index 119a694..f38cb8e 100644 --- a/SafeCampus.WEB/src/views/userManage/personnel/components/form/form_basic.vue +++ b/SafeCampus.WEB/src/views/userManage/personnel/components/form/form_basic.vue @@ -73,7 +73,7 @@ - + diff --git a/SafeCampus.WEB/src/views/userManage/personnel/components/form/index.vue b/SafeCampus.WEB/src/views/userManage/personnel/components/form/index.vue index cb438b1..8271add 100644 --- a/SafeCampus.WEB/src/views/userManage/personnel/components/form/index.vue +++ b/SafeCampus.WEB/src/views/userManage/personnel/components/form/index.vue @@ -43,7 +43,14 @@ const sysUserProps = reactive>({ record: {}, disabled: false }); - +const checkAgeNumber = (rule: any, value: any, callback: any) => { + if (value === "") callback("请输入年龄"); + if (value > 100 || value < 0) { + callback(new Error("请输入正确的年龄(年龄范围1-100岁)")); + } else { + return callback(); + } +}; // 表单验证规则 const rules = reactive({ name: [required("请输入姓名")], @@ -53,9 +60,8 @@ const rules = reactive({ { required: true, message: "请输入手机号", trigger: "blur" }, { validator: checkPhoneNumber, trigger: "blur" } ], - // depId: [required("请选择系部")], - // majorId: [required("请选择专业")], - personSetId: [required("请选择班级")] + personSetId: [required("请选择班级")], + age: [{ validator: checkAgeNumber, trigger: "blur" }] }); /**