buli
2022-03-11 02ddc35714cbd1688b7cb057f770f1410de79dab
force-app/main/default/pages/FixtureRentalPDF.page
@@ -1,4 +1,4 @@
<apex:page applyHtmlTag="false" Controller="FixtureRentalPDFController" showHeader="false" sidebar="false" id="allPage" action="{!init}" renderAs="pdf" ><!-- renderAs="pdf" -->
<apex:page applyHtmlTag="false" Controller="FixtureRentalPDFController" showHeader="false" sidebar="false" id="allPage" action="{!init}" ><!-- renderAs="pdf" -->
<html>
    <head>
         <style type="text/css" media="print">
@@ -12,16 +12,31 @@
            }*/
        </style>
            <style>
                body{margin: 0 auto;
                    width: 780px;}
                    #title1{height: 30px;}
                    #title2{height: 110px;}
            </style>
            <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)}"/>
    </head>
    
<body style="font-family: Arial Unicode MS; page-break-inside: auto;font-size: 14px">
            <div id="pdf-wrapper">
<apex:outputPanel id="showhidden" rendered="true">
    <!-- 20201119 LJH OCSM_BP5-61 update start 现地管理和现地管理的主单不显示-->
    <!-- <apex:outputText style="float:left;font-size:22px;margin-top: 25px;" value="{!centreAddress}" /> -->
    <apex:outputText style="float:left;font-size:22px;margin-top: 25px;" value="{!IF(IsShowLU,centreAddress,'')}" />
    <!-- 20201119 LJH OCSM_BP5-61 update end 现地管理和现地管理的主单不显示-->
    <img style="float: right; width: 55px; height: 55px;padding: 0px;margin-top: 12px;" src="{!'/servlet/servlet.FileDownload?file=' + ApplyHeadShow.QRId__c}" />
                    <img style="float: right; width: 55px; height: 55px;padding: 0px;margin-top: 12px;" src="{!qrcode}" />
    <table border="1" width="100%" style="border-collapse: collapse;margin-top: 18mm;">
        <colgroup>
            <col width="50%" />
@@ -77,7 +92,7 @@
            <td style="text-align:left;" >科室名</td> <td  style="text-align:left;font-size: 13px"><apex:outputText value="{!ApplyHeadShow.Account__r.Department_Name__c}" /></td>
        </tr>
        <tr>
            <td style="text-align:left;" rowspan="3" >发货地址</td> <td colspan="2" rowspan="3" style="text-align:left;font-size: 13px"> <apex:outputText value="{!Shippmentadress}" /></td>
                            <td style="text-align:left;" rowspan="3" >发货地址</td> <td colspan="2" rowspan="3" style="text-align:left;font-size: 13px"> <apex:outputText id="Shippmentadress" value="{!Shippmentadress}" /></td>
            <td style="text-align:left;" colspan="1">邮编</td> <td  style="text-align:left;"> <apex:outputText value="{!IF(ApplyHeadShow.Shipment_address__r.Post_Code__c==null,ApplyHeadShow.Post_Code__c,ApplyHeadShow.Shipment_address__r.Post_Code__c)}" /></td>
        </tr>
        <tr>
@@ -252,7 +267,7 @@
            </td>
            <td style="box-sizing: border-box;text-align:center;font-size:13px;border-left: solid 1px;"  rowspan="2">医疗机构</td>
            <!-- 20220124 ljh SFDC-C4U3PH update colspan="4"  -->
            <td style="box-sizing: border-box;text-align:left;font-size: 13px;"  colspan="5"  rowspan="2">
                            <td style="box-sizing: border-box;text-align:left;font-size: 13px;"  colspan="4"  rowspan="2">
                <apex:outputText value="{!HospitalName}" />
            </td>
        </tr>
@@ -269,7 +284,7 @@
            </td>
            <td style="box-sizing: border-box;text-align:center;font-size:13px;border-left: solid 1px;"  rowspan="2">发货地址</td>
            <!-- 20220124 ljh SFDC-C4U3PH update colspan="4"  -->
            <td style="box-sizing: border-box;text-align:left;font-size: 13px;"  colspan="5"  rowspan="2">
                            <td style="box-sizing: border-box;text-align:left;font-size: 13px;"  colspan="4"  rowspan="2">
                <apex:outputText value="{!if(isblank(ApplyHeadShow.Shippment_adress_detail__c), ApplyHeadShow.direct_shippment_address__c, ApplyHeadShow.Shippment_adress_detail__c)}" />
            </td>
        </tr>
@@ -281,13 +296,13 @@
        </tr>
        <tr>
            <!-- 20220124 ljh SFDC-C4U3PH update colspan="8" -->
            <th style="text-align:center;font-size:13px;height: 7pt;" colspan="9" >借用备品发货清单</th>
                            <th style="text-align:center;font-size:13px;height: 7pt;" colspan="8" >借用备品发货清单</th>
        </tr>
        <tr>
            <td rowspan="2" style="box-sizing: border-box;text-align:center;font-size: 11px;">序号</td>
            <td rowspan="2" style="box-sizing: border-box;text-align:center;font-size: 11px;">管理编号</td>
            <!-- 20220124 ljh SFDC-C4U3PH update colspan="6" -->
            <td colspan="7" style="box-sizing: border-box;text-align:center;font-size: 11px;">明细</td>
                            <td colspan="6" style="box-sizing: border-box;text-align:center;font-size: 11px;">明细</td>
        </tr>
        <tr>
            <!-- <td style="text-align:center;">序号</td>
@@ -345,6 +360,87 @@
</apex:repeat>
</apex:outputPanel>
            </div>
</body>
        <script>
            console.log('----start----')
            console.log('----{!ApplyHeadShow.AWS_Data_Id__c}----')
            AWSService.sfSessionId = '{!GETSESSIONID()}';
            //sforce.connection.sessionId = '{!GETSESSIONID()}';
            var staticResources = JSON.parse('{!staticResource}');
            blockme();
            document.body.onload = function(){
                console.log('document.body.onload')
                AWSService.query(staticResources.queryUrl, '{!ApplyHeadShow.AWS_Data_Id__c}', function(data){
                    console.log('data----------')
                    console.log(data);
                    unblockUI();
                    document.getElementById("allPage:Shippmentadress").innerHTML = data.object.directShippmentAddress;
                    //document.getElementById("Caller_phone__c").innerHTML = data.object.callerPhone;
                    setTimeout(() => {
                        jsPdfDownload();
                    }, 1500);
                }, staticResources.token);
            }
            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;
                        //一页pdf显示html页面生成的canvas高度;
                        var pageHeight = contentWidth / 592.28 * 841.89;
                        //未生成pdf的html页面高度
                        var leftHeight = contentHeight;
                        //页面偏移
                        var position = 0;
                        //a4纸的尺寸[595.28,841.89],html页面生成的canvas在pdf中图片的宽高
                        var imgWidth = 565.28;//595.28//左右边距20
                        var imgHeight = 605.28/contentWidth * contentHeight;//左右边距20
                        var pageData = canvas.toDataURL('image/jpeg', 1.0);
                        var pdf = new jsPDF('', 'pt', 'a4');
                        //有两个高度需要区分,一个是html页面的实际高度,和生成pdf的页面高度(841.89)
                        //当内容未超过pdf一页显示的范围,无需分页
                        if (leftHeight < pageHeight) {
                            pdf.addImage(pageData, 'JPEG', 15, 0, imgWidth, imgHeight );//左右边距7.5
                        } else {
                            while(leftHeight > 0) {
                                pdf.addImage(pageData, 'JPEG', 15, position, imgWidth, imgHeight)//左右边距7.5
                                leftHeight -= pageHeight;
                                position -= 841.89;
                                //避免添加空白页
                                if(leftHeight > 0) {
                                    pdf.addPage();
                                }
                            }
                        }
                        Fun(pdf);
                    }
                })
            }
            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';
                    }
                }
            }
        </script>
</html>
</apex:page>