From 897afd4da2588952931c0aa6fc43c53c6a5246a6 Mon Sep 17 00:00:00 2001
From: HuangShun <148689675+huabuweixin@users.noreply.github.com>
Date: Tue, 3 Feb 2026 14:55:13 +0800
Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8DBug130=20=E3=80=90=E9=97=A8?=
=?UTF-8?q?=E8=AF=8A=E6=8C=82=E5=8F=B7=E3=80=91-=E3=80=8B=E3=80=90?=
=?UTF-8?q?=E6=96=B0=E5=A2=9E=E6=82=A3=E8=80=85=E3=80=91=E6=80=A7=E5=88=AB?=
=?UTF-8?q?=E8=AE=BE=E7=BD=AE=E6=9C=892=E4=B8=AA=EF=BC=8C=E5=A4=9A?=
=?UTF-8?q?=E4=BA=86=E4=B8=80=E4=B8=AA=EF=BC=9B=E5=B0=86=E9=A1=B5=E9=9D=A2?=
=?UTF-8?q?=E5=9B=9E=E9=80=80=E8=87=B3=E9=9C=80=E6=B1=8237=20=E9=97=A8?=
=?UTF-8?q?=E8=AF=8A=E6=8C=82=E5=8F=B7-=E3=80=8B=E6=96=B0=E5=A2=9E?=
=?UTF-8?q?=E6=82=A3=E8=80=85=20/=E9=A1=B5=E9=9D=A2=EF=BC=8C=E5=B9=B6?=
=?UTF-8?q?=E5=AE=9E=E7=8E=B0=E6=82=A3=E8=80=85=E6=96=B0=E5=BB=BA=E6=82=A3?=
=?UTF-8?q?=E8=80=85=E6=A1=A3=E6=A1=88=E5=B9=B4=E9=BE=84=E6=A0=A1=E9=AA=8C?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../components/patientAddDialog.vue | 278 ++++++++++++------
1 file changed, 182 insertions(+), 96 deletions(-)
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 1ef037d7..ff0780ec 100644
--- a/openhis-ui-vue3/src/views/charge/outpatientregistration/components/patientAddDialog.vue
+++ b/openhis-ui-vue3/src/views/charge/outpatientregistration/components/patientAddDialog.vue
@@ -10,58 +10,8 @@
-
-
-
-
- {{ item.info }}
-
-
-
-
-
-
-
-
- {{ dict.label }}
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 岁
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
@@ -135,7 +145,8 @@
-
+
+
@@ -262,7 +273,7 @@
-
+
{
// 监护人信息条件验证函数
const validateGuardianInfo = (rule, value, callback) => {
- // 只有当年龄小于规定年龄时才验证监护人信息
- if (form.value.age) {
- // 提取年龄数字部分
- const ageMatch = form.value.age.toString().match(/\d+/);
- if (ageMatch) {
- const age = parseInt(ageMatch[0]);
- const guardianAgeValue = parseInt(props.guardianAge) || 16;
- // 如果年龄小于规定年龄,监护人信息必须填写
- if (age < guardianAgeValue && !value) {
- return callback(new Error(`年龄小于${guardianAgeValue}岁的患者必须填写监护人信息`));
+ // 从系统配置获取监护人规定年龄
+ getConfigKey('guardianAge').then(res => {
+ if (res.code === 200) {
+ const guardianAgeValue = parseInt(res.data) || 16; // 默认值为16
+
+ // 提取年龄数字部分
+ const ageMatch = form.value.age.toString().match(/\d+/);
+ if (ageMatch) {
+ const age = parseInt(ageMatch[0]);
+ // 如果年龄小于规定年龄,监护人信息必须填写
+ if (age < guardianAgeValue && !value) {
+ return callback(new Error(`年龄小于${guardianAgeValue}岁的患者必须填写监护人信息`));
+ }
}
}
- }
- callback();
+ callback(); // 如果获取不到配置或出现错误,仍然通过验证
+ }).catch(error => {
+ console.error('获取监护人规定年龄配置失败:', error);
+ callback(); // 获取配置失败时也通过验证
+ });
}
const data = reactive({
isViewMode: false,
form: {
- typeCode: '01',
- tempFlag: '1',
- // genderEnum: 0,
+ typeCode: '08', // 证件类别,默认为'08'(就诊卡)
+ birthDate: undefined,
+ age: undefined,
+ hukouAddressSelect: undefined,
+ hukouAddress: undefined,
+ postalCode: undefined,
+ companyAddress: undefined,
+ patientDerived: undefined,
},
rules: {
name: [{ required: true, message: '姓名不能为空', trigger: 'change' },
@@ -616,7 +639,18 @@ const data = reactive({
genderEnum: [{ required: true, message: '请选择性别', trigger: 'change' }],
age: [{ required: true, message: '年龄不能为空', trigger: 'change' }],
phone: [{ required: true, message: '联系方式不能为空', trigger: 'change' }],
- idCard: [{ required: true, message: '证件号不能为空', trigger: 'change' }],
+ identifierNo: [{ required: true, message: '就诊卡号不能为空', trigger: 'change' }],
+ idCard: [
+ { required: false, message: '证件号码不能为空', trigger: 'change' },
+ { validator: validateIdCard, trigger: 'blur' },
+ { validator: validateUniquePatient, trigger: 'blur' }
+ ],
+ 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' }],
},
});
@@ -1271,22 +1305,74 @@ function cancel() {
visible.value = false;
reset();
}
-// 身份证号失去焦点获取年龄和性别
-const onBlur = () => {
- if (form.value.typeCode === '01') {
- const info = getGenderAndAge(form.value.idCard || '');
- form.value.age = info.age;
- form.value.genderEnum = info.gender;
+// 处理出生日期变化,自动计算年龄
+function handleBirthDateChange() {
+ if (form.value.birthDate) {
+ const birthDate = new Date(form.value.birthDate);
+ const today = new Date();
+
+ let age = today.getFullYear() - birthDate.getFullYear();
+ const monthDiff = today.getMonth() - birthDate.getMonth();
+
+ // 计算精确年龄
+ if (monthDiff < 0 || (monthDiff === 0 && today.getDate() < birthDate.getDate())) {
+ age--;
+ }
+
+ form.value.age = age;
}
-};
-//切换证件类型
-const typeChange = () => {
- if (form.value.typeCode === '01') {
- const info = getGenderAndAge(form.value.idCard || '');
- form.value.age = info.age;
- form.value.genderEnum = info.gender;
+}
+
+// 处理年龄输入,自动计算出生日期
+function handleAgeInput() {
+ // 提取数字部分
+ const ageMatch = form.value.age.match(/\d+/);
+ if (ageMatch) {
+ const age = parseInt(ageMatch[0]);
+ // 移除非数字字符,保留数字和可能的单位
+ form.value.age = age ;
+
+ // 计算出生日期
+ const today = new Date();
+ const birthYear = today.getFullYear() - age;
+ const birthMonth = today.getMonth();
+ const birthDay = today.getDate();
+
+ const birthDate = new Date(birthYear, birthMonth, birthDay);
+
+ // 格式化为YYYY-MM-DD
+ const formattedBirthDate = birthDate.toISOString().split('T')[0];
+ form.value.birthDate = formattedBirthDate;
}
-};
+}
+watch(
+ () => form.value.idCard,
+ (newIdCard) => {
+ if (newIdCard && newIdCard.length === 18) {
+ const birthYear = parseInt(newIdCard.substring(6, 10));
+ const birthMonth = parseInt(newIdCard.substring(10, 12));
+ const birthDay = parseInt(newIdCard.substring(12, 14));
+ // 设置出生日期
+ form.value.birthDate = `${birthYear}-${birthMonth.toString().padStart(2, '0')}-${birthDay.toString().padStart(2, '0')}`;
+ const today = new Date();
+ const currentYear = today.getFullYear();
+ const currentMonth = today.getMonth() + 1;
+ const currentDay = today.getDate();
+
+ let age = currentYear - birthYear;
+
+ // 如果当前月份小于出生月份,或者月份相同但当前日期小于出生日期,则年龄减1
+ if (
+ currentMonth < birthMonth ||
+ (currentMonth === birthMonth && currentDay < birthDay)
+ ) {
+ age--;
+ }
+
+ form.value.age = age ;
+ }
+ }
+);
// 设置查看模式
function setViewMode(isView) {
isViewMode.value = isView;