diff --git a/openhis-ui-vue3/src/views/charge/outpatientregistration/components/patientAddDialog.vue b/openhis-ui-vue3/src/views/charge/outpatientregistration/components/patientAddDialog.vue index a4211d62..2d4f2d98 100644 --- a/openhis-ui-vue3/src/views/charge/outpatientregistration/components/patientAddDialog.vue +++ b/openhis-ui-vue3/src/views/charge/outpatientregistration/components/patientAddDialog.vue @@ -372,6 +372,23 @@ const validateIdCard = (rule, value, callback) => { callback(); // 校验通过 } +// 监护人信息条件验证函数 +const validateGuardianInfo = (rule, value, callback) => { + // 只有当年龄小于18岁时才验证监护人信息 + if (form.value.age) { + // 提取年龄数字部分 + const ageMatch = form.value.age.toString().match(/\d+/); + if (ageMatch) { + const age = parseInt(ageMatch[0]); + // 如果年龄小于18岁,监护人信息必须填写 + if (age < 18 && !value) { + return callback(new Error('年龄小于18岁的患者必须填写监护人信息')); + } + } + } + // 18岁及以上患者或年龄未填写时,跳过验证 + callback(); +} const data = reactive({ isViewMode: false, @@ -393,7 +410,12 @@ const data = reactive({ { validator: validateIdCard, trigger: 'blur' }, { validator: validateUniquePatient, trigger: 'blur' } ], - birthDate: [{ required: false, message: '请选择出生日期', trigger: 'change' }], + birthDate: [{ required: false, message: '请选择出生日期', trigger: 'change' }], + // 监护人信息条件验证规则 + guardianName: [{ validator: validateGuardianInfo, trigger: 'blur' }], + guardianRelation: [{ validator: validateGuardianInfo, trigger: 'blur' }], + guardianPhone: [{ validator: validateGuardianInfo, trigger: 'blur' }], + guardianIdNo: [{ validator: validateGuardianInfo, trigger: 'blur' }], }, }); @@ -583,13 +605,16 @@ function submitForm() { form.value.idCard.toString().substring(12, 14); console.log(form.value.birthDate, 123); } + // 进行表单验证 proxy.$refs['patientRef'].validate((valid) => { if (valid) { - // 使用 + // 提交表单前的处理 if (!form.value.identifierNo) { form.value.typeCode = undefined; } form.value.address = getAddress(form); + + // 提交新增患者请求 addPatient(form.value).then((response) => { proxy.$modal.msgSuccess('新增成功'); getPatientInfo(response.data.idCard); diff --git a/openhis-ui-vue3/src/views/charge/outpatientregistration/index.vue b/openhis-ui-vue3/src/views/charge/outpatientregistration/index.vue index 9f2b6ff4..a8cfa5b8 100644 --- a/openhis-ui-vue3/src/views/charge/outpatientregistration/index.vue +++ b/openhis-ui-vue3/src/views/charge/outpatientregistration/index.vue @@ -3,46 +3,7 @@ - + @@ -67,6 +28,44 @@ + + + 新建 + + + 查询 + + + 电子凭证 + + + 身份证 + + + 医保卡 + + + @@ -351,6 +350,12 @@ + + 清空 + 保存挂号 +