fix:优化医疗类型处理和时间字段解析逻辑
This commit is contained in:
parent
37b79742f3
commit
4e0218bc27
@ -113,6 +113,35 @@ const showItems = computed(() => {
|
||||
|
||||
const formRef = ref(null);
|
||||
|
||||
function normalizeMedicalType(raw) {
|
||||
const s = String(raw || '').trim();
|
||||
if (!s) return '';
|
||||
const lower = s.toLowerCase();
|
||||
if (lower.includes('preconsultationrecord')) return 'preConsultationRecord';
|
||||
if (lower.includes('preconsult') || (lower.includes('pre') && lower.includes('consult'))) return 'preConsultationRecord';
|
||||
if (lower === 'outpatient' || lower === 'out_patient' || lower === 'out-patient') return 'outpatient';
|
||||
if (lower === 'inhospital' || lower === 'in_hospital' || lower === 'in-hospital' || lower === 'inpatient') return 'inhospital';
|
||||
if (lower === 'physicalexaminationtemplate' || lower === 'physicalexamination' || lower === 'physical_examination') return 'physicalExaminationTemplate';
|
||||
if (s === 'outPatient') return 'outpatient';
|
||||
if (s === 'inHospital') return 'inhospital';
|
||||
if (s === 'preConsultation') return 'preConsultationRecord';
|
||||
if (s === 'preConsultationRecord') return 'preConsultationRecord';
|
||||
if (s === 'physicalExaminationTemplate') return 'physicalExaminationTemplate';
|
||||
return s;
|
||||
}
|
||||
|
||||
function resolveSortTimeKey() {
|
||||
const ui = normalizeMedicalType(templateType.value);
|
||||
// 预问诊:时间字段固定使用 consultationDate,避免被模板配置覆盖,且与列表展示一致
|
||||
if (ui === 'preConsultationRecord') return 'consultationDate';
|
||||
const t = temp.value || {};
|
||||
if (t?.service?.timeTitle) return String(t.service.timeTitle);
|
||||
if (ui === 'outpatient') return 'visitTime';
|
||||
if (ui === 'inhospital') return 'inhosDate';
|
||||
if (ui === 'physicalExaminationTemplate') return 'inspectDate';
|
||||
return '';
|
||||
}
|
||||
|
||||
function ensureFilesField() {
|
||||
if (form.files !== undefined) return;
|
||||
if (detail.value && detail.value.files !== undefined) return;
|
||||
@ -151,7 +180,7 @@ onLoad(async (options) => {
|
||||
ensureFilesField();
|
||||
|
||||
// 默认填充模板时间字段
|
||||
const timeKey = temp.value?.service?.timeTitle || '';
|
||||
const timeKey = resolveSortTimeKey();
|
||||
if (timeKey && !form[timeKey]) form[timeKey] = dayjs().format('YYYY-MM-DD');
|
||||
}
|
||||
|
||||
@ -237,7 +266,7 @@ async function save() {
|
||||
}
|
||||
|
||||
// sortTime:使用模板中的时间字段
|
||||
const sortTimeKey = temp.value?.service?.timeTitle || '';
|
||||
const sortTimeKey = resolveSortTimeKey();
|
||||
if (sortTimeKey) {
|
||||
const sortTimeValue = forms.value?.[sortTimeKey];
|
||||
if (sortTimeValue && dayjs(sortTimeValue).isValid()) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user