diff --git a/healthlink-his-server/healthlink-his-application/src/main/java/com/healthlink/his/web/patientmanage/dto/FlexibleDateDeserializer.java b/healthlink-his-server/healthlink-his-application/src/main/java/com/healthlink/his/web/patientmanage/dto/FlexibleDateDeserializer.java new file mode 100644 index 000000000..6c5074b09 --- /dev/null +++ b/healthlink-his-server/healthlink-his-application/src/main/java/com/healthlink/his/web/patientmanage/dto/FlexibleDateDeserializer.java @@ -0,0 +1,42 @@ +package com.healthlink.his.web.patientmanage.dto; + +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.databind.DeserializationContext; +import com.fasterxml.jackson.databind.JsonDeserializer; + +import java.io.IOException; +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.Date; + +/** + * 支持多种日期格式的反序列化器 + * 兼容 yyyy-MM-dd HH:mm:ss 和 yyyy/MM/dd HH:mm:ss 等格式 + */ +public class FlexibleDateDeserializer extends JsonDeserializer { + + private static final String[] DATE_FORMATS = { + "yyyy-MM-dd HH:mm:ss", + "yyyy/MM/dd HH:mm:ss", + "yyyy/M/d HH:mm:ss", + "yyyy-MM-dd'T'HH:mm:ss", + "yyyy-MM-dd'T'HH:mm:ss.SSS", + "yyyy-MM-dd", + "yyyy/MM/dd" + }; + + @Override + public Date deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { + String dateStr = p.getValueAsString(); + if (dateStr == null || dateStr.isEmpty()) { + return null; + } + for (String pattern : DATE_FORMATS) { + try { + return new SimpleDateFormat(pattern).parse(dateStr); + } catch (ParseException ignored) { + } + } + throw new IOException("无法解析日期: " + dateStr + ",支持格式: yyyy-MM-dd HH:mm:ss 或 yyyy/MM/dd HH:mm:ss"); + } +} diff --git a/healthlink-his-server/healthlink-his-application/src/main/java/com/healthlink/his/web/patientmanage/dto/PatientBaseInfoDto.java b/healthlink-his-server/healthlink-his-application/src/main/java/com/healthlink/his/web/patientmanage/dto/PatientBaseInfoDto.java index 0db97a1ab..101b57014 100755 --- a/healthlink-his-server/healthlink-his-application/src/main/java/com/healthlink/his/web/patientmanage/dto/PatientBaseInfoDto.java +++ b/healthlink-his-server/healthlink-his-application/src/main/java/com/healthlink/his/web/patientmanage/dto/PatientBaseInfoDto.java @@ -1,6 +1,7 @@ package com.healthlink.his.web.patientmanage.dto; import com.fasterxml.jackson.annotation.JsonFormat; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.fasterxml.jackson.databind.annotation.JsonSerialize; import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; import com.healthlink.his.common.annotation.Dict; @@ -144,7 +145,7 @@ public class PatientBaseInfoDto { /** * 死亡时间 */ - @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss") + @JsonDeserialize(using = FlexibleDateDeserializer.class) private Date deceasedDate; /** diff --git a/healthlink-his-ui/src/views/charge/outpatientregistration/components/patientAddDialog.vue b/healthlink-his-ui/src/views/charge/outpatientregistration/components/patientAddDialog.vue index 1991eb608..c4022fdac 100755 --- a/healthlink-his-ui/src/views/charge/outpatientregistration/components/patientAddDialog.vue +++ b/healthlink-his-ui/src/views/charge/outpatientregistration/components/patientAddDialog.vue @@ -702,12 +702,26 @@ const getGenderOptions = async () => { const getEducationLevelOptions = async () => { try { // 从字典管理获取文化程度数据 - const response = await getDicts('education_level'); + const response = await getDicts('educational_level'); console.log('获取到的文化程度原始数据:', response); - // 确保数据是数组 - if (!response || response.code !== 200 || !Array.isArray(response.data)) { - console.error('文化程度数据格式错误:', response); + // 确保数据是数组且非空 + if (!response || response.code !== 200 || !Array.isArray(response.data) || response.data.length === 0) { + console.warn('文化程度数据为空或格式错误,使用默认数据:', response); + // 降级方案:使用默认的文化程度选项,按编码顺序排列 + educationLevelList.value = [ + { value: '1', info: '大学本科' }, + { value: '2', info: '硕士研究生' }, + { value: '3', info: '博士研究生' }, + { value: '4', info: '初中毕业' }, + { value: '5', info: '大学专科结业' }, + { value: '6', info: '技工学院结业' }, + { value: '7', info: '职业高中结业' }, + { value: '8', info: '小学毕业' }, + { value: '9', info: '普通高中结业' }, + { value: '10', info: '中等专科结业' }, + { value: '99', info: '其他' } + ]; return; } const educationDict = response.data; @@ -743,17 +757,18 @@ const getEducationLevelOptions = async () => { console.error('获取文化程度字典数据失败:', error); // 降级方案:使用默认的文化程度选项,按编码顺序排列 educationLevelList.value = [ - { value: '3912', info: '大学本科' }, - { value: '3913', info: '硕士研究生' }, - { value: '3914', info: '博士研究生' }, - { value: '3915', info: '初中毕业' }, - { value: '3916', info: '大学毕业' }, - { value: '3917', info: '技工学校毕业' }, - { value: '3918', info: '职业高中毕业' }, - { value: '3919', info: '小学毕业' }, - { value: '3920', info: '普通高中毕业' }, - { value: '3921', info: '中等专科毕业' } - ].sort((a, b) => parseInt(a.value) - parseInt(b.value)); // 确保默认选项也按编码排序 + { value: '1', info: '大学本科' }, + { value: '2', info: '硕士研究生' }, + { value: '3', info: '博士研究生' }, + { value: '4', info: '初中毕业' }, + { value: '5', info: '大学专科结业' }, + { value: '6', info: '技工学院结业' }, + { value: '7', info: '职业高中结业' }, + { value: '8', info: '小学毕业' }, + { value: '9', info: '普通高中结业' }, + { value: '10', info: '中等专科结业' }, + { value: '99', info: '其他' } + ]; } }; const options = ref(pcas); // 地区数据 @@ -1523,6 +1538,18 @@ function submitForm() { if (!form.value.identifierNo) { form.value.typeCode = undefined; } + // 修复死亡时间日期格式:确保 yyyy-MM-dd HH:mm:ss 格式 + if (form.value.deceasedDate) { + const d = form.value.deceasedDate; + if (d instanceof Date) { + const pad = (n) => String(n).padStart(2, '0'); + form.value.deceasedDate = d.getFullYear() + '-' + pad(d.getMonth() + 1) + '-' + pad(d.getDate()) + ' ' + pad(d.getHours()) + ':' + pad(d.getMinutes()) + ':' + pad(d.getSeconds()); + } else if (typeof d === 'string') { + // 将任何非标准格式转为 yyyy-MM-dd HH:mm:ss + const normalized = d.replace(/\//g, '-').replace(/T/, ' ').replace(/\.\d+Z?$/, '').trim(); + form.value.deceasedDate = normalized; + } + } // 拼接完整地址用于提交,但不覆写表单字段(避免弹窗关闭前显示全地址) const submitData = { ...form.value, address: getAddress(form) };