'+ currentPage +'_' + assortName + '
\n' + + ''+ currentPage +'_' + assortName + '
\n'; + $("#page_" + currentPage).html(newHtml); + } else { + // 新增HTML内容 + $("#rightContentHtml").append(rightContentHtml); + } + //放入数据 + assortIdArray.push(assortId); + assortTexteArray.push(currentPage +'_' + assortName) + pageDataArray.push(currentPage); + } else { + toastr.warning("请先上传pdf文件") + } + } +} +async function getBlobAsBase64(blobUrl) { + const response = await fetch(blobUrl); + const blob = await response.blob(); + return new Promise((resolve, reject) => { + const reader = new FileReader(); + reader.onloadend = () => resolve(reader.result); + reader.onerror = reject; + reader.readAsDataURL(blob); + }); +} +function backPage(){ + Common.confirm({ + title: "提示", + message: "是否要回上一页?", + operate: function (result) { + if (result) { + pageNum = pageNum - 2; + currentPage--; + turningPage(assortName,true); + } + } + }) +} +function submitIndex(){ + if(base64DataArray.length == 0){ + return toastr.warning("索引分类为空,请先对图像进行索引分类") + } + var patientId = $("#patientId").val(); + Common.confirm({ + title: "提示", + message: "确认提交以上索引分类吗?", + operate: function (result) { + if (result) { + $.ajax({ + type: 'post', + contentType: 'application/json; charset=utf-8', // 设置内容类型为 application/json + url: path+'/commom/savePdfPage', + data: JSON.stringify({ + base64Data: base64DataArray, + assortIdData: assortIdArray, + pageData: pageDataArray, + patientId: patientId + }), + success:function(data){ + if(data.code == 0){ + toastr.warning("合并成功!") + //记录已提交的索引分类 + //saveSubmitAssort(patientId); + } + } + }) + } + } + }) +} +function saveSubmitAssort(patientId){ + $.ajax({ + type: 'post', + contentType: 'application/json; charset=utf-8', // 设置内容类型为 application/json + url: path+'/commom/saveSubmitAssortLog', + data: JSON.stringify({ + patientId: patientId, + assortIdData: assortIdArray, + assortTexteData: assortTexteArray, + pageData: pageDataArray, + }), + success:function(data){ + + } + }) +} \ No newline at end of file diff --git a/src/main/webapp/static/js/recordManage/commomSearch/showMegerRecordIframeBlood.js b/src/main/webapp/static/js/recordManage/commomSearch/showMegerRecordIframeBlood.js new file mode 100644 index 0000000..62ace67 --- /dev/null +++ b/src/main/webapp/static/js/recordManage/commomSearch/showMegerRecordIframeBlood.js @@ -0,0 +1,90 @@ +let pdfUrl = ''; +let pageNum = 1; +$().ready(function (data) { + document.getElementById('pdf-file-input').addEventListener('change', function(event) { + const file = event.target.files[0]; + if (file) { + const fileReader = new FileReader(); + fileReader.onload = function() { + pdfUrl = URL.createObjectURL(new Blob([this.result], { type: 'application/pdf' })); + document.getElementById('showMegerPdfIframe').src = `${pdfUrl}#page=${pageNum}×tamp=${Date.now()}`; + //updatePage(); + }; + fileReader.readAsArrayBuffer(file); + } + }); + + // document.getElementById('download-page').addEventListener('click', function() { + // const iframe = document.getElementById('iframe1'); + // const pdfUrl = iframe.src; + // const pageNum = getSelectedPageNumber(); // 假设有一个函数getSelectedPageNumber()来获取当前页码 + // + // if (pdfUrl) { + // getBlobAsBase64(pdfUrl).then(base64Data => { + // fetch(path + '/commom/savePdfPage', { + // method: 'POST', + // headers: { + // 'Content-Type': 'application/json' + // }, + // body: JSON.stringify({ base64Data, pageNum }) + // }) + // .then(response => response.json()) + // .then(data => { + // if(data.status == 'success'){ + // toastr.success(data.message); + // } + // }) + // .catch(error => { + // toastr.error(error); + // }); + // }) + // } + // }); + + // document.getElementById('next-page-btn').addEventListener('click', function() { + // pageNum++; + // updatePage(); + // }); + // + // document.getElementById('prev-page-btn').addEventListener('click', function() { + // if (pageNum > 1) { + // pageNum--; + // updatePage(); + // } + // }); +}); + +function updatePage() { + if (pdfUrl) { + document.getElementById('current-page').textContent = pageNum; + const iframe = document.getElementById('showMegerPdfIframe'); + // 重新创建 iframe 元素以强制重新加载 + const newIframe = document.createElement('iframe'); + newIframe.id = 'showMegerPdfIframe'; + newIframe.width = '100%'; + newIframe.height = '100%'; + newIframe.src = `${pdfUrl}#page=${pageNum}×tamp=${Date.now()}`; + // 替换旧的 iframe 元素 + iframe.parentNode.replaceChild(newIframe, iframe) + } +} + +var iframe = document.getElementById("showMegerPdfIframe"); +if (iframe.attachEvent) { + iframe.attachEvent("onreadystatechange", function () { + //此事件在内容没有被载入时候也会被触发,所以我们要判断状态 + //有时候会比较怪异 readyState状态会跳过 complete 所以我们loaded状态也要判断 + if (iframe.readyState === "complete" || iframe.readyState == "loaded") { + //代码能执行到这里说明已经载入成功完毕了 + //要清除掉事件 + iframe.detachEvent("onreadystatechange", arguments.callee); + //这里是回调函数 + } + }); +} else { + iframe.addEventListener("load", function () { + $("#iframeLoad").val(1); + //代码能执行到这里说明已经载入成功完毕了 + this.removeEventListener("load", arguments.call, false); + }, false); +} \ No newline at end of file diff --git a/src/main/webapp/static/js/recordManage/commomSearch/showRecordIframeBlood.js b/src/main/webapp/static/js/recordManage/commomSearch/showRecordIframeBlood.js index 9e34739..04e32b7 100644 --- a/src/main/webapp/static/js/recordManage/commomSearch/showRecordIframeBlood.js +++ b/src/main/webapp/static/js/recordManage/commomSearch/showRecordIframeBlood.js @@ -147,55 +147,6 @@ function onloadPdfMethod() { //加载pdf按钮功能 function onloadPdf(scanPages, sources) { - /*var batchSize = 10; // 每批处理10个PDF文件 - var scanPagesArray = scanPages.split(','); - var sourcesArray = sources.split(','); - var totalFiles = scanPagesArray.length; - var batches = Math.ceil(totalFiles / batchSize); - function processBatch(batchIndex){ - var start = batchIndex * batchSize; - var end = Math.min(start + batchSize, totalFiles); - var batchScanPages = scanPagesArray.slice(start, end) + ""; - var batchSources = sourcesArray.slice(start, end) + ""; - - $("#iframeLoad").val(""); - $("#printPicLoaded").val(""); - var patientId = $("#patientId").val(); - //根目录字段识别名称 - var flag = parent.$("#flag").val(); - $.ajax({ - type: 'post', - url: path + "/commom/showRecordContentBlood", - data: { - patientId: patientId, - scanPages: batchScanPages, - flag: flag, - sources: batchSources, - batchIndex: batchIndex - }, - datType: 'json', - success: function (data) { - if (data.code == 0) { - var str = path + "/commom/getRecordContentBlood?patientId=" + patientId + "&batchIndex=" + batchIndex; - if (sources.includes("99") ||sources.includes("服务") ||sources.includes("null")||sources.includes("pacs")||sources.includes("扫描上传")) { - $("#iframe1").attr("src", path + "/static/pdfjs/web/viewer.html?file=" + encodeURIComponent(str)) - } else { - $("#iframe1").attr("src", path + "/static/pdfjs/web/viewer2.html?file=" + encodeURIComponent(str)) - var rootPaths = parent.$("#rootPaths").val(); - var print = $("#print").val(); - if (print == 1) { - selectPrintPic(patientId, rootPaths, scanPages, sources); - } - } - } - } - }) - } - // 处理每个批次 - for (var i = 0; i < batches; i++) { - processBatch(i); - }*/ - $("#iframeLoad").val(""); $("#printPicLoaded").val(""); var patientId = $("#patientId").val(); diff --git a/src/main/webapp/static/pdfjs/web/viewer2.html b/src/main/webapp/static/pdfjs/web/viewer2.html index 316a0b6..6644876 100644 --- a/src/main/webapp/static/pdfjs/web/viewer2.html +++ b/src/main/webapp/static/pdfjs/web/viewer2.html @@ -97,6 +97,16 @@ http://sourceforge.net/adobe/cmap/wiki/License/ opacity: 1; } + .a4-image { + display: block; + width: 90vw; + height: auto; + max-height: 90vh; + object-fit: contain; + margin: 10px auto; + page-break-after: auto; + } + /* 设置打印时的样式 */ @media print { body { @@ -113,10 +123,9 @@ http://sourceforge.net/adobe/cmap/wiki/License/ } .a4-image { - max-width: 100%; /* 图像最大宽度为容器宽度 */ - max-height: 100%; /* 图像最大高度为容器高度 */ - height: auto; /* 保持图像比例 */ - width: auto; /* 保持图像比例 */ + width: 850px !important; + height: 1190px !important; + page-break-after: always; } } @@ -490,7 +499,6 @@ http://sourceforge.net/adobe/cmap/wiki/License/ height: 100%; width: 100%; z-index: 9999999; - display: block; text-align: center; background-color: rgba(0, 0, 0, 0.5);