fix: 解决病例回填不显示问题

This commit is contained in:
王天骄
2026-06-18 10:35:48 +08:00
parent d4820fa94e
commit af326f43d0
2 changed files with 105 additions and 6 deletions
+45 -2
View File
@@ -482,8 +482,9 @@ function fillDetailForm(row: CaseListItem, fullData: unknown) {
resetReviewDetailForm()
const record = getDetailRecord(fullData)
const traditional = getRecord(getFirst(record, ['traditional']))
const teaching = getRecord(getFirst(record, ['teaching']))
const contentSources = [record, fullData]
const traditional = findRecord(['traditional', 'traditional_case', 'traditionalCase'], contentSources) ?? {}
const teaching = findRecord(['teaching', 'teaching_case', 'teachingCase'], contentSources) ?? {}
const scoringRules = getScoringRules(fullData, record)
const examItems = getExamItems(fullData, record)
@@ -724,6 +725,48 @@ function findArray(keys: string[], sources: unknown[]) {
return undefined
}
function findRecord(keys: string[], sources: unknown[]) {
for (const source of sources) {
const found = findRecordInSource(source, keys)
if (found) {
return found
}
}
return undefined
}
function findRecordInSource(value: unknown, keys: string[], depth = 0): Record<string, unknown> | undefined {
if (!value || typeof value !== 'object' || Array.isArray(value) || depth > 5) {
return undefined
}
const record = value as Record<string, unknown>
for (const key of keys) {
const nested = record[key]
if (nested && typeof nested === 'object' && !Array.isArray(nested)) {
return nested as Record<string, unknown>
}
}
const preferredKeys = ['data', 'case', 'case_detail', 'caseDetail', 'case_info', 'caseInfo', 'detail', 'full', 'result', 'record', 'item']
for (const key of preferredKeys) {
const found = findRecordInSource(record[key], keys, depth + 1)
if (found) {
return found
}
}
for (const child of Object.values(record)) {
const found = findRecordInSource(child, keys, depth + 1)
if (found) {
return found
}
}
return undefined
}
function findArrayInSource(value: unknown, keys: string[], depth = 0): unknown[] | undefined {
if (!value || typeof value !== 'object' || Array.isArray(value) || depth > 5) {
return undefined