打印时,图片或pdf的显示

This commit is contained in:
yy2205 2025-05-23 10:23:08 +08:00
parent 868b0c73ae
commit 6d229f92d2

View File

@ -517,7 +517,7 @@
<div>
<div style="text-align: right">
<el-button
v-if="true"
v-if="imagebase64_new && !imagebase64_new.toLowerCase().endsWith('.pdf')"
type="primary"
style="width: 90px"
v-print="{ id: 'printMe_ecg' }"
@ -529,7 +529,20 @@
<el-divider style="margin-top: 8px; margin-bottom: 1px" />
</div>
<div id="printMe_ecg">
<el-image :src="imagebase64_new" style="width: 100%; height: 100%;" />
<div v-loading="!imagebase64_new" element-loading-text="加载中...">
<iframe
v-if="imagebase64_new && imagebase64_new.toLowerCase().endsWith('.pdf')"
:src="imagebase64_new"
style="width: 100%; height: calc(100vh - 150px); border: none;"
frameborder="0"
></iframe>
<el-image
v-else-if="imagebase64_new"
:src="imagebase64_new"
style="width: 100%; height: calc(100vh - 150px); object-fit: contain;"
fit="contain"
/>
</div>
</div>
</el-dialog>
<div style="position: fixed; top: 0; left: 0; z-index: -1100">
@ -954,7 +967,15 @@ function print() {
setTimeout(async () => {
if (applyFormVO.value.pdfurl) {
const fileUrl = applyFormVO.value.pdfurl.trim()
// PDF
const isPdf = fileUrl.toLowerCase().endsWith('.pdf')
if (isPdf) {
// PDF使iframe
imagebase64_new.value = fileUrl
} else {
// 使el-image
imagebase64_new.value = fileUrl
}
}
}, 100)
})