| | |
| | | <apex:page controller="DeliveryConfirmPDFController" showHeader="false" sidebar="false" id="allPage" action="{!init}" renderAs="pdf"> <!-- renderAs="pdf" --> |
| | | <apex:page controller="DeliveryConfirmPDFController" showHeader="false" sidebar="false" id="allPage" action="{!init}" > <!-- renderAs="pdf" --> |
| | | <html> |
| | | <head> |
| | | <style> |
| | | @page { |
| | | margin: 1mm 1mm 1mm 1mm; |
| | | } |
| | | /* 20220221 PI改造 by 徐亮 start */ |
| | | body{margin: 0 auto; |
| | | width: 780px;} |
| | | #pdf-wrapper{position: relative;} |
| | | #title1{height: 30px;} |
| | | #title2{height: 110px;} |
| | | /* 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 style="font-family: Arial Unicode MS; page-break-inside: auto;font-size: 10px;"> |
| | | <div id="pdf-wrapper"> |
| | | <div id="title1"></div> |
| | | <apex:image value="{!URLFOR($Resource.pdfSign)}" width="80" style="position:absolute; left:300px; top:100px;"/> |
| | | <p style="text-align: center; display: block;font-size: 25px;">仪景通样机借用单</p> |
| | | <p style="text-align: center; display: block;font-size: 25px;">奥林巴斯样机借用单</p> |
| | | <table style="border: 2px solid black; width: 100%;border-collapse:collapse;" border="solid"> |
| | | <tr> |
| | | <td align="right" width="100px"><apex:outputText value="申请日期:" /></td> |
| | |
| | | </apex:outputPanel> |
| | | |
| | | <td align="right">借用担当:</td> |
| | | <td><apex:outputText value="{!la.Loaner_Ser__c}"/></td> |
| | | <td><span aws-obj="loaner_application__c" aws-api="loanerSer" aws-id="{!la.AWS_Data_Id__c}">{!la.Loaner_Ser__c}</span></td> |
| | | </tr> |
| | | <tr> |
| | | <td align="right">借用日期:</td> |
| | |
| | | <tr> |
| | | |
| | | <td align="right" width="90">寄送地址:</td> |
| | | <td colspan="3"><apex:outputField value="{!la.direct_shippment_address__c}"/></td> |
| | | <td colspan="3"><span aws-obj="loaner_application__c" aws-api="directShippmentAddress" aws-id="{!la.AWS_Data_Id__c}">{!la.direct_shippment_address__c}</span> </td> |
| | | </tr> |
| | | |
| | | <tr> |
| | | |
| | | <td align="right" width="90">联系人:</td> |
| | | <td><apex:outputField value="{!la.Loaner_receive_staff__c}"/></td> |
| | | <td><span aws-obj="loaner_application__c" aws-api="loanerReceiveStaff" aws-id="{!la.AWS_Data_Id__c}">{!la.Loaner_receive_staff__c}</span></td> |
| | | <td align="right" width="90">联系电话:</td> |
| | | <td width="200"><apex:outputField value="{!la.Loaner_receive_staff_phone__c}"/></td> |
| | | <td width="200"><span aws-obj="loaner_application__c" aws-api="loanerReceiveStaffPhone" aws-id="{!la.AWS_Data_Id__c}">{!la.Loaner_receive_staff_phone__c}</span></td> |
| | | |
| | | </tr> |
| | | |
| | |
| | | <apex:repeat value="{!luData}" var="luLine" id="lus"> |
| | | <tr> |
| | | <td class="dataCell" style="text-align: center;"> |
| | | <apex:outputText value="{!luLine.lu.Customer__r.Name}"/> |
| | | <apex:outputText styleClass="Customer__r.Name" value="{!luLine.lu.Customer__r.Name}"/> |
| | | </td> |
| | | <td class="dataCell" style="text-align: center;"> |
| | | <apex:outputText value="{!luLine.lu.Customer__r.DivisionName__c}"/> |
| | | <apex:outputText styleClass="Customer__r.DivisionName__c" value="{!luLine.lu.Customer__r.DivisionName__c}"/> |
| | | </td> |
| | | <td class="dataCell" style="text-align: center;"> |
| | | <apex:outputText value="{!luLine.lu.Contact__r.Name}"/> |
| | | <span aws-obj="Contact" aws-api="lastName" aws-id="{!la.AWS_Data_Id__c}">{!luLine.lu.Contact__r.Name}</span> |
| | | </td> |
| | | <apex:outputPanel rendered="{!IF(la.Equipment_Type__c == 'BS', true , false)}" layout="none"> |
| | | <td class="dataCell" style="text-align: center;"> |
| | | <apex:outputText value="{!luLine.lu.Contact__r.Phone}"/> |
| | | <span aws-obj="Contact" aws-api="phone" aws-id="{!la.AWS_Data_Id__c}">{!luLine.lu.Contact__r.Phone}</span> |
| | | </td> |
| | | </apex:outputPanel> |
| | | <apex:outputPanel rendered="{!IF(la.Equipment_Type__c == 'BS', false , true)}" layout="none"> |
| | |
| | | <tr><td>3.如借用之样机(备品)在借用期间损坏,我方有权要求贵方按相应金额赔偿或承担维修费用。</td></tr> |
| | | </apex:outputPanel> |
| | | <tr><td>4.借出样机在未征得我方的许可,贵方不得转借第三方使用,否则将中止借用并追究责任。</td></tr> |
| | | <tr><td>5.仪景通有权根据需要随时收回借出的样机。</td></tr> |
| | | <tr><td>5.奥林巴斯有权根据需要随时收回借出的样机。</td></tr> |
| | | </table> |
| | | |
| | | </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) { |
| | | let landscape = false; |
| | | let pw = 595.28; |
| | | let ph = 841.89; |
| | | const marginw = 40; |
| | | |
| | | let orientation = ''; |
| | | if (landscape) { |
| | | let temp =ph; |
| | | ph = pw; |
| | | pw = temp; |
| | | orientation = 'l'; |
| | | } |
| | | |
| | | |
| | | var contentWidth = canvas.width; |
| | | var contentHeight = canvas.height; |
| | | |
| | | //一页pdf显示html页面生成的canvas高度; |
| | | var pageHeight = contentWidth / pw * ph; |
| | | //未生成pdf的html页面高度 |
| | | var leftHeight = contentHeight; |
| | | //页面偏移 |
| | | var position = 0; |
| | | //a4纸的尺寸[595.28,841.89],html页面生成的canvas在pdf中图片的宽高 |
| | | var imgWidth = pw-2*marginw;//595.28//左右边距20 |
| | | var imgHeight = imgWidth/contentWidth * contentHeight;//左右边距20 |
| | | |
| | | var pageData = canvas.toDataURL('image/jpeg', 1.0); |
| | | |
| | | var pdf = new jsPDF(orientation, 'pt', 'a4');// 第一个参数填字母l,注意不是数字1,为横向pdf |
| | | |
| | | //有两个高度需要区分,一个是html页面的实际高度,和生成pdf的页面高度(841.89) |
| | | //当内容未超过pdf一页显示的范围,无需分页 |
| | | if (leftHeight < pageHeight) { |
| | | pdf.addImage(pageData, 'JPEG', marginw, 0, imgWidth, imgHeight );//左右边距20 |
| | | } else { |
| | | while(leftHeight > 0) { |
| | | pdf.addImage(pageData, 'JPEG', marginw, position, imgWidth, imgHeight)//左右边距20 |
| | | leftHeight -= pageHeight; |
| | | position -= ph; |
| | | //避免添加空白页 |
| | | if(leftHeight > 0) { |
| | | pdf.addPage(); |
| | | } |
| | | } |
| | | } |
| | | Fun(pdf); |
| | | } |
| | | }) |
| | | } |
| | | |
| | | |
| | | var aws_data = {}; |
| | | |
| | | function Decrypt(r,dataIds){ |
| | | let Foo = function(){ |
| | | for (const id of dataIds) { |
| | | if (aws_data.hasOwnProperty(id)) { |
| | | let d = aws_data[id]; |
| | | let $e =j$("[aws-id='"+d.dataId+ "']"); |
| | | $e.each((i,e)=>{ |
| | | j$(e).html(d[j$(e).attr("aws-api")]); |
| | | }); |
| | | //.find(".decrypt") |
| | | |
| | | } |
| | | } |
| | | unblockUI(); |
| | | } |
| | | let ids = []; |
| | | for (const id of dataIds) { |
| | | if (!aws_data.hasOwnProperty(id)) { |
| | | ids.push(id); |
| | | } |
| | | } |
| | | if (ids.length > 0) { |
| | | blockme(); |
| | | AWSService.search(r.searchUrl,JSON.stringify({ |
| | | "dataIds":ids |
| | | }),function(data){ |
| | | unblockUI(); |
| | | if(data.object && data.object.length > 0){ |
| | | |
| | | for(let d of data.object){ |
| | | if(d.dataId){ |
| | | aws_data[d.dataId] = d; |
| | | } |
| | | } |
| | | Foo(); |
| | | } |
| | | },r.token); |
| | | }else{ |
| | | Foo(); |
| | | } |
| | | } |
| | | |
| | | function DecryptAll(){ |
| | | let dataIds = []; |
| | | j$('[aws-id][aws-obj="loaner_application__c"]').each((i,e)=>{ |
| | | let v = j$(e).attr('aws-id'); |
| | | if (v) { |
| | | dataIds.push(v); |
| | | } |
| | | }); |
| | | Decrypt(staticResource,dataIds); |
| | | } |
| | | |
| | | j$(function(){ |
| | | //DecryptAll(); |
| | | |
| | | }) |
| | | |
| | | document.body.onclick = function(){ |
| | | jsPdfDownload(); |
| | | } |
| | | </script> |
| | | <!-- 20220221 PI改造 by 徐亮 end --> |
| | | </html> |
| | | </apex:page> |