Merge branch 'develop' of https://gitea.gentronhealth.com/wangjunping/his into develop
This commit is contained in:
@@ -80,6 +80,19 @@
|
|||||||
<el-input v-model="form.countryCode" clearable :disabled="isViewMode" />
|
<el-input v-model="form.countryCode" clearable :disabled="isViewMode" />
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
</el-col>
|
</el-col>
|
||||||
|
<el-col :span="8">
|
||||||
|
<el-form-item label="出生日期" prop="birthDate">
|
||||||
|
<el-date-picker
|
||||||
|
v-model="form.birthDate"
|
||||||
|
type="date"
|
||||||
|
placeholder="请选择出生日期"
|
||||||
|
format="YYYY年MM月DD日"
|
||||||
|
:disabled="isViewMode"
|
||||||
|
value-format="YYYY-MM-DD"
|
||||||
|
@change="handleBirthDateChange"
|
||||||
|
/>
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
</el-row>
|
</el-row>
|
||||||
<!-- <el-col :span="6">
|
<!-- <el-col :span="6">
|
||||||
<el-form-item label="年龄" prop="age">
|
<el-form-item label="年龄" prop="age">
|
||||||
@@ -109,7 +122,8 @@
|
|||||||
<el-input
|
<el-input
|
||||||
v-model="form.age"
|
v-model="form.age"
|
||||||
:disabled="isViewMode"
|
:disabled="isViewMode"
|
||||||
@input="(value) => (form.age = value.replace(/[^0-9]/g, ''))"
|
@input="handleAgeInput"
|
||||||
|
placeholder="请输入年龄"
|
||||||
/>
|
/>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
</el-col>
|
</el-col>
|
||||||
@@ -320,6 +334,8 @@ const data = reactive({
|
|||||||
isViewMode: false,
|
isViewMode: false,
|
||||||
form: {
|
form: {
|
||||||
typeCode: '08',
|
typeCode: '08',
|
||||||
|
birthDate: undefined,
|
||||||
|
age: undefined,
|
||||||
},
|
},
|
||||||
rules: {
|
rules: {
|
||||||
name: [{ required: true, message: '姓名不能为空', trigger: 'change' }],
|
name: [{ required: true, message: '姓名不能为空', trigger: 'change' }],
|
||||||
@@ -331,6 +347,7 @@ const data = reactive({
|
|||||||
{ required: true, message: '证件号码不能为空', trigger: 'change' },
|
{ required: true, message: '证件号码不能为空', trigger: 'change' },
|
||||||
{ validator: validateIdCard, trigger: 'blur' }
|
{ validator: validateIdCard, trigger: 'blur' }
|
||||||
],
|
],
|
||||||
|
birthDate: [{ required: false, message: '请选择出生日期', trigger: 'change' }],
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -348,6 +365,46 @@ const props = defineProps({
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// 处理出生日期变化,自动计算年龄
|
||||||
|
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 + '岁';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 处理年龄输入,自动计算出生日期
|
||||||
|
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(
|
watch(
|
||||||
() => form.value.idCard,
|
() => form.value.idCard,
|
||||||
(newIdCard) => {
|
(newIdCard) => {
|
||||||
@@ -355,7 +412,8 @@ watch(
|
|||||||
const birthYear = parseInt(newIdCard.substring(6, 10));
|
const birthYear = parseInt(newIdCard.substring(6, 10));
|
||||||
const birthMonth = parseInt(newIdCard.substring(10, 12));
|
const birthMonth = parseInt(newIdCard.substring(10, 12));
|
||||||
const birthDay = parseInt(newIdCard.substring(12, 14));
|
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 today = new Date();
|
||||||
const currentYear = today.getFullYear();
|
const currentYear = today.getFullYear();
|
||||||
const currentMonth = today.getMonth() + 1;
|
const currentMonth = today.getMonth() + 1;
|
||||||
@@ -371,7 +429,7 @@ watch(
|
|||||||
age--;
|
age--;
|
||||||
}
|
}
|
||||||
|
|
||||||
form.value.age = age;
|
form.value.age = age + '岁';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
@@ -464,6 +522,7 @@ function reset() {
|
|||||||
maritalStatusEnum: undefined,
|
maritalStatusEnum: undefined,
|
||||||
busNo: undefined,
|
busNo: undefined,
|
||||||
organizationId: undefined,
|
organizationId: undefined,
|
||||||
|
birthDate: undefined,
|
||||||
};
|
};
|
||||||
proxy.resetForm('patientRef');
|
proxy.resetForm('patientRef');
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user