From 4bfe21c4b5ddc089ae5a95f4b10f6cff148b690d Mon Sep 17 00:00:00 2001 From: 高章伟 <gaozhangwei@prec-tech.com> Date: 星期五, 18 三月 2022 18:27:34 +0800 Subject: [PATCH] NFM606fix --- force-app/main/default/pages/ConsumTrialPDF.page | 168 +++++++++++++++++++++++++++++++++++++++++++++++++++++--- 1 files changed, 159 insertions(+), 9 deletions(-) diff --git a/force-app/main/default/pages/ConsumTrialPDF.page b/force-app/main/default/pages/ConsumTrialPDF.page index 89e1d83..aead67a 100644 --- a/force-app/main/default/pages/ConsumTrialPDF.page +++ b/force-app/main/default/pages/ConsumTrialPDF.page @@ -1,5 +1,5 @@ -<apex:page applyHtmlTag="false" Controller="ConsumTrialPDFController" showHeader="false" sidebar="false" id="allPage" action="{!init}" renderAs="pdf"> -<!-- renderAs="pdf" --> +<apex:page applyHtmlTag="false" Controller="ConsumTrialPDFController" showHeader="false" sidebar="false" id="allPage" action="{!init}"> +<!-- renderAs="pdf" --> <html> <head> <style type="text/css" media="print"> @@ -39,16 +39,66 @@ } </style> + <style> + /* 20220221 PI鏀归�� by 寰愪寒 start */ + body { + font-family: Arial Unicode MS; + page-break-inside: auto; + font-size: 14px; + } + table { + border-collapse: collapse; + width: 100%; + } + table, th, td { + border: 1px solid black; + text-align: left; + } + table.headTable tr td { + font-size: 13px; + } + table.deliInfoTable tr td { + font-size: 13px; + } + table.detailListTable tr td { + font-size: 8px; + text-align: left; + box-sizing:border-box; + padding: 1px; + } + table.tailTable tr td { + font-size: 12px; + } + body{margin: 0 auto;width: 920px;font-size: 14px;} + #title1{height: 30px;} + #title2{height: 80px;} + #pdf-wrapper {position: relative;} + #pdf-wrapper table{width: 100%;border-spacing: 0px;border-collapse: collapse; border: none;} + #pdf-wrapper table th,td{border-bottom: 1px #000 solid;} + /* 20220221 PI鏀归�� by 寰愪寒 end */ + </style> + <!-- 20220221 PI鏀归�� by 寰愪寒 start --> + <apex:includeScript value="{! URLFOR($Resource.AWSService, 'AWSService.js') }" /> + <script src="../../soap/ajax/53.0/connection.js" type="text/javascript"></script> + <apex:stylesheet value="{!URLFOR($Resource.blockUIcss)}"/> + <apex:includeScript value="{!URLFOR($Resource.jquery183minjs)}"/> + <apex:includeScript value="{!URLFOR($Resource.PleaseWaitDialog)}"/> + <apex:includeScript value="{!URLFOR($Resource.jspdf)}"/> + <apex:includeScript value="{!URLFOR($Resource.html2canvas)}"/> + + <!-- 20220221 PI鏀归�� by 寰愪寒 end --> </head> <body> + <div id="pdf-wrapper"> + <div id="title1"></div> <!-- 椤电爜 --> <apex:variable value="{!1}" var="pageCnt" /> <!-- 鍊熺敤鑰楁潗澶囧搧鍙戣揣娓呭崟 --> <!-- 搴忓彿 --> <apex:variable value="{!1}" var="lineCnt" /> <apex:repeat value="{!pdfPageList}" var="eachPdfPage"> - <img style="float:left;width:79px;height:79px;padding:0px;margin-top:1px;z-index:999;position:relative;" - src="{!'/servlet/servlet.FileDownload?file=' + targetConsumApply.QRId__c}" /> + <img style="width:79px;height:79px;padding:0px;margin-top:1px;z-index:999;position:absolute;" + src="{!QRSrc}" /> <!-- 琛ㄥご --> <table class="headTable" style="position:relative;"> <colgroup> @@ -197,10 +247,10 @@ </colgroup> <apex:outputPanel layout="none" rendered="{!eachPdfPage.equipSetDetailList.size > 0}"> <tr> - <th style="text-align:center;" colspan="14" height="25">鍊熺敤鑰楁潗澶囧搧鍙戣揣娓呭崟</th> + <th style="text-align:center;" colspan="12" height="25">鍊熺敤鑰楁潗澶囧搧鍙戣揣娓呭崟</th> </tr> <tr> - <th style="text-align:center; font-size:10px;" colspan="14" height="25">鍏辫鑰楁潗澶囧搧锛坽!consumApplySetDetailListSize}锛変欢</th> + <th style="text-align:center; font-size:10px;" colspan="12" height="25">鍏辫鑰楁潗澶囧搧锛坽!consumApplySetDetailListSize}锛変欢</th> </tr> <tr> <td style="text-align: center;"><c:PDFWbr targetStr="搴忓彿"/></td> @@ -254,7 +304,7 @@ <!-- 鐥呬緥/鍔ㄧ墿鑴忓櫒 --> <td><c:PDFWbr targetStr="{!eachEquipSetDetail.Case_OR_animal_organ__c}"/></td> <!-- 璇曠敤鑰呯洊绔� --> - <td><c:PDFWbr targetStr="{!eachEquipSetDetail.Trial_User__c}"/></td> + <td aws-data-id="{!eachEquipSetDetail.AWS_Data_Id__c}"><c:PDFWbr targetStr="{!eachEquipSetDetail.Trial_User__c}"/></td> <!-- 璺熷彴鑰呯洊绔� --> <td><c:PDFWbr targetStr="{!eachEquipSetDetail.Follower_User__r.Name}"/></td> <!-- 澶囩敤 --> @@ -283,8 +333,7 @@ <!-- 20211210 ljh SFDC-C923SR add --> <tr> <td colspan="2" style=" border: none;"> - <img align="left" src="{!'/servlet/servlet.FileDownload?file=' + targetConsumApply.BRId__c}" /> - + <img align="left" src="{!BRSrc}" /> </td> </tr> <!-- 20211210 ljh SFDC-C923SR end --> @@ -294,6 +343,107 @@ </apex:outputPanel> <apex:variable value="{!pageCnt + 1}" var="pageCnt" /> </apex:repeat> + </div> </body> + <!-- 20220221 PI鏀归�� by 寰愪寒 start --> +<script> + AWSService.sfSessionId = '{!GETSESSIONID()}'; + var staticResource = JSON.parse('{!staticResource}'); + function Fun(pdf){ + var iframe = document.createElement('iframe'); + iframe.setAttribute('style', 'position:absolute;right:0; top:0; bottom:0; height:100%; width:100%'); + document.body.appendChild(iframe); + iframe.src = pdf.output('datauristring'); + for(let e of document.body.childNodes){ + if( e != iframe && e.style){ + e.style.display = 'none'; + } + } + } + + let id = "pdf-wrapper"; + var target = document.getElementById(id); + function jsPdfDownload(){ + let pdfName = "娴嬭瘯"; + let id = "pdf-wrapper"; + var target = document.getElementById(id); + target.style.background = "#FFFFFF"; + if(pdfName==''||pdfName==undefined) pdfName= getNowFormatDate(); + + html2canvas(target, { + scale: 2, + onrendered:function(canvas) { + var contentWidth = canvas.width; + var contentHeight = canvas.height; + + //涓�椤祊df鏄剧ずhtml椤甸潰鐢熸垚鐨刢anvas楂樺害; + var pageHeight = contentWidth / 592.28 * 841.89; + //鏈敓鎴恜df鐨刪tml椤甸潰楂樺害 + var leftHeight = contentHeight; + //椤甸潰鍋忕Щ + var position = 0; + //a4绾哥殑灏哄[595.28,841.89]锛宧tml椤甸潰鐢熸垚鐨刢anvas鍦╬df涓浘鐗囩殑瀹介珮 + var imgWidth = 515.28;//595.28//宸﹀彸杈硅窛20 + var imgHeight = 515.28/contentWidth * contentHeight;//宸﹀彸杈硅窛20 + + var pageData = canvas.toDataURL('image/jpeg', 1.0); + + var pdf = new jsPDF('', 'pt', 'a4'); + + //鏈変袱涓珮搴﹂渶瑕佸尯鍒嗭紝涓�涓槸html椤甸潰鐨勫疄闄呴珮搴︼紝鍜岀敓鎴恜df鐨勯〉闈㈤珮搴�(841.89) + //褰撳唴瀹规湭瓒呰繃pdf涓�椤垫樉绀虹殑鑼冨洿锛屾棤闇�鍒嗛〉 + if (leftHeight < pageHeight) { + pdf.addImage(pageData, 'JPEG', 40, 0, imgWidth, imgHeight );//宸﹀彸杈硅窛20 + } else { + while(leftHeight > 0) { + pdf.addImage(pageData, 'JPEG', 40, position, imgWidth, imgHeight)//宸﹀彸杈硅窛20 + leftHeight -= pageHeight; + position -= 841.89; + //閬垮厤娣诲姞绌虹櫧椤� + if(leftHeight > 0) { + pdf.addPage(); + } + } + } + Fun(pdf); + } + }) + } + + blockme(); + document.body.onload = function(){ + let aws_ids = []; + j$("[aws-data-id]").each(function(i,e){ + let id = j$(e).attr('aws-data-id'); + if (id) { + aws_ids.push(id); + } + + }) + + + AWSService.search(staticResource.searchUrl, JSON.stringify({ + dataIds:aws_ids + }), function(data){ + unblockUI(); + if (data && data.object && data.object.length > 0) { + for (const d of data.object) { + j$("[aws-data-id='"+d.dataId +"']").html(d.trialUser); + } + } + //document.getElementById("Responsible_Person_HP__c").innerHTML = data.object.responsiblePersonHP; + //document.getElementById("Caller_phone__c").innerHTML = data.object.callerPhone; + + setTimeout(() => { + jsPdfDownload(); + }, 1500); + }, staticResource.token); + + } + document.body.onclick = function(){ + //jsPdfDownload(); + } +</script> +<!-- 20220221 PI鏀归�� by 寰愪寒 end --> </html> </apex:page> \ No newline at end of file -- Gitblit v1.9.1