|
|
|
|
@ -47,6 +47,12 @@ export default { |
|
|
|
|
if (!this.templateContent || !this.report) return ""; |
|
|
|
|
let content = this.templateContent; |
|
|
|
|
const data = this.report; |
|
|
|
|
console.log(data) |
|
|
|
|
console.log(data.patient_age + data.patient_age_type |
|
|
|
|
? this.patientAgeTypeList.find( |
|
|
|
|
(i) => i.value == data.patient_age_type |
|
|
|
|
).label || "" |
|
|
|
|
: "" || "") |
|
|
|
|
// 占位符映射 + 空值兜底 |
|
|
|
|
const mappings = { |
|
|
|
|
$$logo$$: this.renderLogo(), |
|
|
|
|
@ -61,9 +67,9 @@ export default { |
|
|
|
|
"", |
|
|
|
|
$$age$$: |
|
|
|
|
data.patient_age + data.patient_age_type |
|
|
|
|
? this.patientAgeTypeList.find( |
|
|
|
|
? `${data.patient_age}${this.patientAgeTypeList.find( |
|
|
|
|
(i) => i.value == data.patient_age_type |
|
|
|
|
).label || "" |
|
|
|
|
).label || ""}` |
|
|
|
|
: "" || "", |
|
|
|
|
$$examroom$$: data.exam_rooms.map((item) => item.name).join(", "), |
|
|
|
|
$$requestdoctor$$: data.request_doctor || "", |
|
|
|
|
@ -77,12 +83,20 @@ export default { |
|
|
|
|
$$reportor_sig$$: this.renderSignature(), |
|
|
|
|
$$createtime$$: data.create_time || "", |
|
|
|
|
$$creati$$: data.create_time || "", |
|
|
|
|
$$user_comment$$: data.user_comment || "", |
|
|
|
|
}; |
|
|
|
|
// 转义$符号,安全全局替换 |
|
|
|
|
Object.keys(mappings).forEach((key) => { |
|
|
|
|
const reg = new RegExp(key.replace(/\$/g, "\\$"), "g"); |
|
|
|
|
content = content.replace(reg, mappings[key]); |
|
|
|
|
}); |
|
|
|
|
// 专家意见:user_comment 为空则移除整个区块 |
|
|
|
|
if (!data.user_comment) { |
|
|
|
|
content = content.replace( |
|
|
|
|
/<!--expert_section_start-->[\s\S]*?<!--expert_section_end-->/g, |
|
|
|
|
"" |
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|
return content; |
|
|
|
|
}, |
|
|
|
|
}, |
|
|
|
|
|