From 6ef3204589f66daa467a18ee69ffd7b0368c2b71 Mon Sep 17 00:00:00 2001
From: lichuanyang <1176537920@qq.com>
Date: Thu, 19 Dec 2024 15:05:58 +0800
Subject: [PATCH] =?UTF-8?q?=E9=98=B3=E6=80=A7=E7=BB=9F=E8=AE=A1=E3=80=81?=
=?UTF-8?q?=E5=8D=B1=E6=80=A5=E5=80=BC=E9=A1=B5=E9=9D=A2=E4=BF=AE=E6=94=B9?=
=?UTF-8?q?=20ecg=E4=BF=9D=E5=AD=98=E7=94=9F=E6=88=90pdf=E4=BF=AE=E6=94=B9?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/utils/htmlPdf.js | 83 ++++++-------
src/views/ECG/ECGForm.vue | 110 +++++++++++-------
src/views/ECG/ECGPositiveStatistics/index.vue | 41 +------
.../ECG/warningStatisticsReport/index.vue | 33 +++++-
.../reportPrintStatistics/ReportInfoECG.vue | 40 +++++--
5 files changed, 171 insertions(+), 136 deletions(-)
diff --git a/src/utils/htmlPdf.js b/src/utils/htmlPdf.js
index 65f2567f..6bcd1c3b 100644
--- a/src/utils/htmlPdf.js
+++ b/src/utils/htmlPdf.js
@@ -147,8 +147,10 @@ const htmlToPdf = {
// 使用html2canvas捕捉div内容
html2Canvas(divElement, {
+ width: divElement.offsetWidth + 4,
+ height: divElement.offsetHeight + 6,
dpi: 300, // 设置300DPI
- scale: 3.125, // 保持原始比例
+ scale: 2.4, // 保持原始比例
useCORS: true, // 如果内容包含跨域图片,需要设置为true
allowTaint: false // 是否允许跨域图片导致画布被污染
})
@@ -162,10 +164,10 @@ const htmlToPdf = {
orientation: 'l',
unit: 'px',
format: [canvas.width, canvas.height]
- });
+ })
// 将canvas转换为图片数据URL
- const imgData = canvas.toDataURL('image/jpeg', 1) // 1.0表示最高质量
- // pdf.addImage(imgData, 'JPEG', 0, 0, canvas.width, canvas.height);
+ const imgData = canvas.toDataURL('image/jpeg', 1) // 1.0表示最高质量
+ // pdf.addImage(imgData, 'JPEG', 0, 0, canvas.width, canvas.height);
// // 设置 PDF 页面尺寸
// // pdf.addImage(imgData, 'JPEG', 10, 10, 1920, 820)
// const link = document.createElement('a');
@@ -174,7 +176,7 @@ const htmlToPdf = {
// link.click();
// pdf.save('111.pdf')
// 解决Promise并返回图片的base64字符串
- // pdf.save(`${divId}-content.pdf`);
+ // pdf.save(`${divId}-content.pdf`);
resolve(imgData)
})
.catch((error) => {
@@ -185,52 +187,51 @@ const htmlToPdf = {
},
createPdfFromBase64(base64Image) {
return new Promise((resolve, reject) => {
- // 使用html2canvas捕捉div内容(这里不需要,但保留以备后续使用)
- // html2Canvas(divElement, { ... }).then(canvas => {
- // 将base64字符串转换为Blob对象
- const blob = base64ToBlob(base64Image);
+ // 使用html2canvas捕捉div内容(这里不需要,但保留以备后续使用)
+ // html2Canvas(divElement, { ... }).then(canvas => {
+ // 将base64字符串转换为Blob对象
+ const blob = base64ToBlob(base64Image)
- // 创建一个URL对象
- const url = URL.createObjectURL(blob);
+ // 创建一个URL对象
+ const url = URL.createObjectURL(blob)
- // 创建一个新的Image对象
- const img = new Image();
- img.onload = () => {
- // 创建PDF对象
- const pdf = new jsPDF({
- orientation: 'l',
- unit: 'px',
- format: [img.width, img.height]
- });
+ // 创建一个新的Image对象
+ const img = new Image()
+ img.onload = () => {
+ // 创建PDF对象
+ const pdf = new jsPDF({
+ orientation: 'l',
+ unit: 'px',
+ format: [img.width, img.height]
+ })
- // 将图片添加到PDF
- pdf.addImage(img, 'JPEG', 0, 0, img.width, img.height);
+ // 将图片添加到PDF
+ pdf.addImage(img, 'JPEG', 0, 0, img.width, img.height)
- // 获取PDF的base64字符串
- const pdfBase64 = pdf.output('datauristring');
+ // 获取PDF的base64字符串
+ const pdfBase64 = pdf.output('datauristring')
- // 解决Promise并返回PDF的base64字符串
- resolve(pdfBase64);
-
- // 清理URL对象
- URL.revokeObjectURL(url);
- };
- img.onerror = (error) => {
- console.error('图片加载失败:', error);
- reject(error);
- };
- img.src = url;
- });
-}
+ // 解决Promise并返回PDF的base64字符串
+ resolve(pdfBase64)
+ // 清理URL对象
+ URL.revokeObjectURL(url)
+ }
+ img.onerror = (error) => {
+ console.error('图片加载失败:', error)
+ reject(error)
+ }
+ img.src = url
+ })
+ }
}
// 辅助函数:将base64字符串转换为Blob对象
function base64ToBlob(base64) {
- const binary = atob(base64.split(',')[1]);
- const array = [];
+ const binary = atob(base64.split(',')[1])
+ const array = []
for (let i = 0; i < binary.length; i++) {
- array.push(binary.charCodeAt(i));
+ array.push(binary.charCodeAt(i))
}
- return new Blob([new Uint8Array(array)], { type: 'image/jpeg' });
+ return new Blob([new Uint8Array(array)], { type: 'image/jpeg' })
}
export default htmlToPdf
diff --git a/src/views/ECG/ECGForm.vue b/src/views/ECG/ECGForm.vue
index 1d0cb36f..dd6e1d63 100644
--- a/src/views/ECG/ECGForm.vue
+++ b/src/views/ECG/ECGForm.vue
@@ -532,22 +532,25 @@
@@ -627,7 +630,7 @@ const open = async (row: any) => {
orgid.value = row.orgId
rowinfo.value = row
// console.log( rowinfo.value)
- const data = await EcganalysisparasApi.getexamIDdata('MZCF0191729074962197_44',orgid.value)
+ const data = await EcganalysisparasApi.getexamIDdata('MZCF0191729074962197_44', orgid.value)
queryParams.value = data
snapshotTime.value = formattedDate(queryParams.value.snapshotTime)
await getlogininfo()
@@ -718,42 +721,51 @@ async function save() {
const ret = await EcganalysisparasApi.SaveEcganalysisparas(saveFormVO.value)
if (ret) {
//进行生成pdf
- const data = await EcganalysisparasApi.getexamIDdata('MZCF0191729074962197_44',orgid.value)
+ const data = await EcganalysisparasApi.getexamIDdata('MZCF0191729074962197_44', orgid.value)
queryParams.value = data
message.alertSuccess('保存成功')
- isprintimage.value = true
- nextTick(async () => {
- setTimeout(async () => {
- try {
- //生成PDF
- htmlToPdf
- .createPdfFromBase64(imagebase64.value)
- .then((pdfBase64) => {
- //生成PDF
- PatientexamlistApi.ftppdf({
- id: Primarykey.value,
- imagebase: pdfBase64,
- model: '0',
- folderPath: 'C:\\work\\pacs' + '\\' + Primarykey.value
- })
- })
- .catch((error) => {
- console.log(error)
- })
- } finally {
- isprintimage.value = false
- imagebase64.value = ''
- }
- }, 1000)
- })
+ //ElMessage.info('开始保存pdf')
+ setTimeout(() => {
+ isprintimage.value = true
+ }, 900)
}
}
+
//展示图片
function updateimagebase(newValue) {
imagebase64.value = newValue
}
+const updateimagebase_new = async () => {
+ try {
+ const image_base64 = await htmlToPdf.getDivContentAsBase64('#ecg_pdf')
+ try {
+ //生成PDF
+ htmlToPdf
+ .createPdfFromBase64(image_base64)
+ .then((pdfBase64) => {
+ PatientexamlistApi.ftppdf({
+ id: Primarykey.value,
+ imagebase: pdfBase64,
+ model: '0',
+ folderPath: 'C:\\work\\pacs' + '\\' + Primarykey.value
+ })
+ ElMessage.info('pdf保存成功')
+ })
+ .catch((error) => {
+ console.log(error)
+ })
+ } finally {
+ }
+ } catch {
+ } finally {
+ nextTick(() => {
+ isprintimage.value = false
+ })
+ }
+}
+
//重置数据
function resetForm() {
Isgrid.value = 1 //是否显示网格 1显示 0不显示
@@ -794,7 +806,7 @@ function openreprotdiag() {
}
//对比弹窗
function opencomparediag() {
- ECGCompare.value.opencomparediag(rowinfo.value,queryParams.value.snapshotTime)
+ ECGCompare.value.opencomparediag(rowinfo.value, queryParams.value.snapshotTime)
}
//纠错
function iscorrect() {
@@ -996,11 +1008,19 @@ defineExpose({ open }) // 提供 open 方法,用于打开弹窗
.page-item-ecg {
padding: 1mm 0.8mm 1mm 0.6mm;
max-width: 1184px;
- margin: 6vh auto 0 auto;
+ margin: 3vh auto 0 auto;
border: 2px solid #ccc;
border-radius: 8px;
}
+.page-pdf-ecg {
+ border-width: 0;
+ padding: 0 0.8mm 0 0.8mm;
+ width: 294mm;
+ height: 206mm;
+ page-break-after: always;
+}
+
@media print {
.ignore-print {
display: none;
diff --git a/src/views/ECG/ECGPositiveStatistics/index.vue b/src/views/ECG/ECGPositiveStatistics/index.vue
index 73e93b4b..1f21e906 100644
--- a/src/views/ECG/ECGPositiveStatistics/index.vue
+++ b/src/views/ECG/ECGPositiveStatistics/index.vue
@@ -130,44 +130,11 @@
/>
-
-
-
- 阴性
- 阳性
- 重大阳性
- 暂无
-
-
+
@@ -192,7 +159,7 @@
reportInfoType = ''
activeTabName = ''
activeDrawerModal = true
- activeDrawerSize = '74%'
+ activeDrawerSize = '48%'
}
"
>
@@ -257,7 +224,7 @@ const message = useMessage()
const { t } = useI18n()
const activeDrawer = ref(false)
const activeDrawerModal = ref(true)
-const activeDrawerSize = ref('74%')
+const activeDrawerSize = ref('48%')
const activeTabName = ref('diagnosisInfo')
const reportInfoType = ref('') //us、ct
const diagnosisInfo_readonly = ref(true)
diff --git a/src/views/ECG/warningStatisticsReport/index.vue b/src/views/ECG/warningStatisticsReport/index.vue
index 60fee6dd..35fe53c3 100644
--- a/src/views/ECG/warningStatisticsReport/index.vue
+++ b/src/views/ECG/warningStatisticsReport/index.vue
@@ -152,7 +152,7 @@
-
+
-
+
+
+
+
+
+
+
+
+
+
+
+
@@ -229,7 +254,7 @@ const { t } = useI18n()
const activeDrawer = ref(false)
const activeDrawerModal = ref(true)
const activeDrawerSize = ref('440px')
-const activeTabName = ref('diagnosisInfo')
+const activeTabName = ref('warningTimelineInfo')
const reportInfoType = ref('') //us、ct
const age = ref('')
const examItemNameEdit = ref('')
@@ -396,7 +421,7 @@ const handleRowClick = async (row) => {
reportInfoType.value = 'csh1'
else reportInfoType.value = 'ct'
}
- activeTabName.value = 'diagnosisInfo'
+ activeTabName.value = 'warningTimelineInfo'
activeDrawer.value = true
}
diff --git a/src/views/applyregistration/reportPrintStatistics/ReportInfoECG.vue b/src/views/applyregistration/reportPrintStatistics/ReportInfoECG.vue
index 1983ea2d..eba1e0db 100644
--- a/src/views/applyregistration/reportPrintStatistics/ReportInfoECG.vue
+++ b/src/views/applyregistration/reportPrintStatistics/ReportInfoECG.vue
@@ -1,5 +1,9 @@
-
+
@@ -165,8 +169,17 @@ defineOptions({ name: 'ReportInfoECG' })
* ReportInfoECG
**/
/** 导入内容 **/
-const emits = defineEmits(['update:image'])
const infoParams = defineProps({
+ isBackend: {
+ required: false,
+ type: Boolean,
+ default: false
+ },
+ createPdf: {
+ required: false,
+ type: Function,
+ default: null
+ },
lineratio: {
required: false,
type: Number,
@@ -546,7 +559,7 @@ const fetchData = async () => {
width: targetWidth,
height: targetHeight,
dpi: 300, //将分辨率提高到特定的DPI 提高四倍
- scale: 1.2 //按比例增加分辨率
+ scale: 1.4 //按比例增加分辨率
} as any
const canvas = await html2canvas(ecgCenter, options)
if (canvas) {
@@ -562,15 +575,25 @@ const fetchData = async () => {
ecgCenter.style.zIndex = ''
ecgCenter_parent.append(ecgCenter)
ecg_loading.value = false
- nextTick(() => {
- createImage()
- })
}
})
} catch (error) {
+ ecg_loading.value = false
console.error('获取数据时出错:', error)
}
}
+watch(
+ ecg_loading,
+ (ecg_loading_new, ecg_loading_old) => {
+ if (!ecg_loading_new)
+ setTimeout(() => {
+ nextTick(() => {
+ createImage()
+ })
+ }, 100)
+ },
+ { deep: true }
+)
const sliderValue = ref(0) // 初始化滑块值
const previousValue = ref(0) // 记录上一个滑块值
@@ -613,8 +636,7 @@ const moveCanvas = (direction, count) => {
}
const createImage = async () => {
- const imagebase64 = await htmlToPdf.getDivContentAsBase64('#PDF')
- emits('update:image', imagebase64)
+ if (infoParams.createPdf) infoParams.createPdf()
}
/** 钩子方法 **/
@@ -627,7 +649,7 @@ onMounted(async () => {
//heightoff.value = (leftCanvas.value.height - 100) / 6
heightoff.value = (618 - 0) / 6
- await fetchData()
+ fetchData()
})
/** 导出内容 **/