@@ -51,7 +51,7 @@ | |||||
</el-col> | </el-col> | ||||
<el-col :span="12"> | <el-col :span="12"> | ||||
<s-form-item label="年龄" prop="age"> | <s-form-item label="年龄" prop="age"> | ||||
<s-input v-model="userInfo.age" type="number" min="1"></s-input> | |||||
<s-input v-model="userInfo.age" type="number" min="1" max="100"></s-input> | |||||
</s-form-item> | </s-form-item> | ||||
</el-col> | </el-col> | ||||
</el-row> | </el-row> | ||||
@@ -42,6 +42,14 @@ const sysUserProps = reactive<FormProps.Base<SysUserPersonnel.SysUserPerInfo>>({ | |||||
record: {}, | record: {}, | ||||
disabled: false | 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({ | const rules = reactive({ | ||||
@@ -51,7 +59,8 @@ const rules = reactive({ | |||||
phone: [ | phone: [ | ||||
{ required: true, message: "请输入手机号", trigger: "blur" }, | { required: true, message: "请输入手机号", trigger: "blur" }, | ||||
{ validator: checkPhoneNumber, trigger: "blur" } | { validator: checkPhoneNumber, trigger: "blur" } | ||||
] | |||||
], | |||||
age: [{ validator: checkAgeNumber, trigger: "blur" }] | |||||
}); | }); | ||||
/** | /** | ||||
@@ -73,7 +73,7 @@ | |||||
</el-col> | </el-col> | ||||
<el-col :span="12"> | <el-col :span="12"> | ||||
<s-form-item label="年龄" prop="age"> | <s-form-item label="年龄" prop="age"> | ||||
<s-input v-model="userInfo.age"></s-input> | |||||
<s-input v-model="userInfo.age" type="number" max="100" min="1"></s-input> | |||||
</s-form-item> | </s-form-item> | ||||
</el-col> | </el-col> | ||||
</el-row> | </el-row> | ||||
@@ -43,7 +43,14 @@ const sysUserProps = reactive<FormProps.Base<SysUserPersonnel.SysUserPerInfo>>({ | |||||
record: {}, | record: {}, | ||||
disabled: false | 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({ | const rules = reactive({ | ||||
name: [required("请输入姓名")], | name: [required("请输入姓名")], | ||||
@@ -53,9 +60,8 @@ const rules = reactive({ | |||||
{ required: true, message: "请输入手机号", trigger: "blur" }, | { required: true, message: "请输入手机号", trigger: "blur" }, | ||||
{ validator: checkPhoneNumber, trigger: "blur" } | { validator: checkPhoneNumber, trigger: "blur" } | ||||
], | ], | ||||
// depId: [required("请选择系部")], | |||||
// majorId: [required("请选择专业")], | |||||
personSetId: [required("请选择班级")] | |||||
personSetId: [required("请选择班级")], | |||||
age: [{ validator: checkAgeNumber, trigger: "blur" }] | |||||
}); | }); | ||||
/** | /** | ||||