From 179dca9007adbda59e57058faa2217e24ab59692 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E5=A4=A9=E9=AA=84?= <5307576@qq.com> Date: Wed, 17 Jun 2026 15:43:02 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E8=A7=A3=E5=86=B3=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E5=9B=9E=E6=98=BE=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/CasesView.vue | 79 ++++++++++++++++++++++++++++++++++------- 1 file changed, 67 insertions(+), 12 deletions(-) diff --git a/src/views/CasesView.vue b/src/views/CasesView.vue index 40e0dd62..2b4c9fcf 100644 --- a/src/views/CasesView.vue +++ b/src/views/CasesView.vue @@ -1514,7 +1514,7 @@ function fillCaseFormFromImportedPdf(result: ImportCasePdfResult) { caseForm.chief_complaint = getImportString(record, ['chief_complaint', 'chiefComplaint']) caseForm.description = getImportString(record, ['description', 'summary', 'content']) caseForm.patient_age = getImportNumber(record, ['patient_age', 'patientAge']) ?? undefined - caseForm.patient_gender = normalizeImportGender(getImportString(record, ['patient_gender', 'patientGender'])) + caseForm.patient_gender = normalizeImportGender(getImportFirst(record, ['patient_gender', 'patientGender'])) caseForm.tags = getImportStringList(record, ['tags', 'tag_list', 'tagList']).join(', ') caseForm.icd_codes = getImportStringList(record, ['icd_codes', 'icdCodes', 'icd_list', 'icdList']).join(', ') caseForm.estimated_minutes = getImportNumber(record, ['estimated_minutes', 'estimatedMinutes']) ?? undefined @@ -1551,7 +1551,7 @@ function fillDetailForm(row: CaseListItem, fullData: unknown) { detailForm.chief_complaint = getImportString(record, ['chief_complaint', 'chiefComplaint'], row.chiefComplaint) detailForm.description = getImportString(record, ['description', 'summary', 'content']) detailForm.patient_age = getImportNumber(record, ['patient_age', 'patientAge']) ?? undefined - detailForm.patient_gender = normalizeImportGender(getImportString(record, ['patient_gender', 'patientGender'])) + detailForm.patient_gender = normalizeImportGender(getImportFirst(record, ['patient_gender', 'patientGender'])) detailForm.tags = getImportStringList(record, ['tags', 'tag_list', 'tagList']).join(', ') detailForm.icd_codes = getImportStringList(record, ['icd_codes', 'icdCodes', 'icd_list', 'icdList']).join(', ') detailForm.estimated_minutes = getImportNumber(record, ['estimated_minutes', 'estimatedMinutes']) ?? row.estimatedMinutes ?? undefined @@ -1690,11 +1690,17 @@ function normalizeImportCaseType(value: string, fallback: DraftCaseType): DraftC return value === 'teaching' ? 'teaching' : fallback } -function normalizeImportGender(value: string) { - if (value === '男') return 'male' - if (value === '女') return 'female' - if (value === '未知') return 'unknown' - return ['male', 'female', 'unknown'].includes(value) ? value : '' +function normalizeImportGender(value: unknown) { + if (value === undefined || value === null) { + return '' + } + + const normalized = String(value).trim().toLowerCase() + if (['male', 'm', 'man', '1', '男'].includes(normalized)) return 'male' + if (['female', 'f', 'woman', '2', '女'].includes(normalized)) return 'female' + if (['unknown', 'unknow', '0', '未知', '不详'].includes(normalized)) return 'unknown' + + return '' } function createDetailDisplay(row: CaseListItem | null, fullData: unknown) { @@ -1725,16 +1731,65 @@ function createDetailDisplay(row: CaseListItem | null, fullData: unknown) { } function getDetailRecord(value: unknown): Record { - if (!value || typeof value !== 'object' || Array.isArray(value)) { - return {} + return findDetailRecord(value) || {} +} + +function findDetailRecord(value: unknown, depth = 0): Record | null { + if (!value || typeof value !== 'object' || Array.isArray(value) || depth > 4) { + return null } const record = value as Record - if (record.data && typeof record.data === 'object' && !Array.isArray(record.data)) { - return record.data as Record + if (hasCaseDetailFields(record)) { + return record } - return record + const preferredKeys = [ + 'data', + 'case', + 'case_detail', + 'caseDetail', + 'case_info', + 'caseInfo', + 'detail', + 'full', + 'result', + 'record', + 'item' + ] + for (const key of preferredKeys) { + const found = findDetailRecord(record[key], depth + 1) + if (found) { + return found + } + } + + for (const child of Object.values(record)) { + const found = findDetailRecord(child, depth + 1) + if (found) { + return found + } + } + + return null +} + +function hasCaseDetailFields(record: Record) { + return [ + 'title', + 'case_title', + 'caseTitle', + 'case_type', + 'caseType', + 'chief_complaint', + 'chiefComplaint', + 'patient_age', + 'patientAge', + 'patient_gender', + 'patientGender', + 'publish_status', + 'publishStatus' + ].some(key => record[key] !== undefined && record[key] !== null) } function getDetailString(record: Record, keys: string[]) {