GWY
2022-05-16 a9baff8a4508c1850e650f68831d857b953eace4
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
<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>
    <table style="border: 2px solid black; width: 100%;border-collapse:collapse;" border="solid">
        <tr>
            <td align="right" width="100px"><apex:outputText value="申请日期:" /></td>
            <td width="600"><apex:outputField value="{!la.Approval_Date__c}"/></td>
            <td align="right" width="100"><apex:outputText value="借用编号:"/></td>
            <td width="300"><apex:outputText value="{!la.loaner_request_number__c}"/></td>
        </tr>
        <tr>
        
            <td align="right">借用方:</td>
 
            <apex:outputPanel rendered="{!IF(la.CreatorUserType__c == 'PowerPartner', 'true', 'false')}" layout="none">
                <td><apex:outputText value="{!agentName}"/></td>
            </apex:outputPanel>
 
            <apex:outputPanel rendered="{!IF(la.CreatorUserType__c != 'PowerPartner', 'true', 'false')}" layout="none">
                <td><apex:outputText value="{!la.Applicant_department__c}"/></td>
            </apex:outputPanel>
            
            <td align="right">借用担当:</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>
            <td><apex:outputText value="{!lab.ladate}"/></td>
            <td align="right">借用期限:</td>
            <td><apex:outputText value="{!lab.ladateNumS}"/></td>
        </tr>
        <tr>
            <td align="right">借用目的:</td>
            <td ><apex:outputText value="{!la.Demo_purpose__c}"/></td>
            <td align="right">样机库存地:</td>
            <td><apex:outputText value="{!la.loaner_place__c}"/></td>
            
        </tr>
        <tr>
             
            
            <apex:outputPanel rendered="{!IF(la.Equipment_Type__c == 'BS', false , true)}" layout="none">
                <td align="right">备注:</td>
                <td colspan="3"><apex:outputText value="{!la.loaner_Remark__c}"/></td>
            </apex:outputPanel>
            <apex:outputPanel rendered="{!IF(la.Equipment_Type__c == 'BS', true , false)}" layout="none">
                <td align="right">备注:</td>
                <td ><apex:outputText value="{!la.loaner_Remark__c}"/></td>
                <td align="right">CRM编号:</td>
                <td ><apex:outputText value="{!OCM_Number}"/></td>
            </apex:outputPanel>
        </tr>
    </table>
    <br style="height: 0.5em;" />
 
 
    <table style="border: 2px solid black; width: 100%;border-collapse:collapse;" border="solid">
        <tr>
            <td align="right" width="90">寄送方式:</td>
            <td colspan="3">
                &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                <apex:outputPanel rendered="{!isSelf}" layout="none"> <img src="/img/checkbox_checked.gif"/></apex:outputPanel>
                <apex:outputPanel rendered="{!IF(isSelf,'false','true')}" layout="none"> <img src="/img/checkbox_unchecked.gif"/></apex:outputPanel>
                自提 
                &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                <apex:outputPanel rendered="{!isExpress}" layout="none"> <img src="/img/checkbox_checked.gif"/></apex:outputPanel>
                <apex:outputPanel rendered="{!IF(isExpress,'false','true')}" layout="none"> <img src="/img/checkbox_unchecked.gif"/></apex:outputPanel> 
                快递
                &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                <apex:outputPanel rendered="{!isRenew}" layout="none"> <img src="/img/checkbox_checked.gif"/></apex:outputPanel>
                <apex:outputPanel rendered="{!IF(isRenew,'false','true')}" layout="none"> <img src="/img/checkbox_unchecked.gif"/></apex:outputPanel>
                续借
            </td>
        </tr>
 
        <tr>
            
            <td width="90">&nbsp;&nbsp;</td>
            <td colspan="3">&nbsp;&nbsp;</td>
 
        </tr>
 
        <tr>
            
            <td align="right" width="90">寄送地址:</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><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"><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>
 
    </table>
    <br/>
    <table style="border: 2px solid black; width: 100%;border-collapse:collapse;" border="solid">
        
        <caption style="text-align: left;font-size: 15px;">用户信息:</caption>
 
        <colgroup>
            <col width="50%" />
            <col width="20%" />
            <col width="10%" />
            <col width="20%" />
        </colgroup>
        <tr>
            <th style="text-align: center; border-bottom-style: ridge;">客户名称</th>
            <th style="text-align: center; border-bottom-style: ridge;">客户部门</th>
            <th style="text-align: center; border-bottom-style: ridge;">联系人</th>
            <apex:outputPanel rendered="{!IF(la.Equipment_Type__c == 'BS', true , false)}" layout="none">
                <th style="text-align: center; border-bottom-style: ridge;">联系电话</th>
            </apex:outputPanel>
            <apex:outputPanel rendered="{!IF(la.Equipment_Type__c == 'BS', false , true)}" layout="none">
                <th style="text-align: center; border-bottom-style: ridge;">借用时间</th>
            </apex:outputPanel>
        </tr>
        <apex:repeat value="{!luData}" var="luLine" id="lus">
        <tr>
            <td class="dataCell" style="text-align: center;">
                <apex:outputText styleClass="Customer__r.Name" value="{!luLine.lu.Customer__r.Name}"/>
            </td>
            <td class="dataCell" style="text-align: center;">
                <apex:outputText styleClass="Customer__r.DivisionName__c" value="{!luLine.lu.Customer__r.DivisionName__c}"/>
            </td>
            <td class="dataCell" style="text-align: center;">
                <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;">
                    <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">
                <td class="dataCell" style="text-align: center;">
                    <apex:outputText value="{!luLine.borrowDate}"/>
                </td>
            </apex:outputPanel>
            
        </tr>
        </apex:repeat>
 
    </table>
    <br/>
    <table style="border:2px solid black; width: 100%;border-collapse: collapse; " border="solid">
        <caption style="text-align: left;font-size: 15px;" >配置清单:</caption>
 
        <tr>
            
            <th style="text-align: center; border-bottom-style: ridge;">序号</th>
            <apex:outputPanel rendered="{!IF(la.Equipment_Type__c == 'NDT' || la.Equipment_Type__c == 'ANI', true , false)}" layout="none">
                <th style="text-align: center; border-bottom-style: ridge;">样机名称</th>
            </apex:outputPanel>
            <th style="text-align: center; border-bottom-style: ridge;">EC Code</th>
            <apex:outputPanel rendered="{!IF(la.Equipment_Type__c == 'BS', true , false)}" layout="none">
                <th style="text-align: center; border-bottom-style: ridge;">描述</th>
            </apex:outputPanel>
            <apex:outputPanel rendered="{!IF(la.Equipment_Type__c == 'BS', false , true)}" layout="none">
                <th style="text-align: center; border-bottom-style: ridge;">序列号</th>
            </apex:outputPanel>
            <th style="text-align: center; border-bottom-style: ridge;">数量</th>
            <apex:outputPanel rendered="{!IF(la.Equipment_Type__c == 'BS', true , false)}" layout="none">
                <th style="text-align: center; border-bottom-style: ridge;">机身号</th>
                <th style="text-align: center; border-bottom-style: ridge;">机身号1</th>
                <th style="text-align: center; border-bottom-style: ridge;">资产编号</th>
            </apex:outputPanel>
            <apex:outputPanel rendered="{!IF(la.Equipment_Type__c == 'IE' || la.Equipment_Type__c == 'RVI', true , false)}" layout="none">
                <th style="text-align: center; border-bottom-style: ridge;">样机库位</th>
            </apex:outputPanel>
   
            
            <th style="text-align: center; border-bottom-style: ridge;">备注</th>
        </tr>
        <apex:variable value="{!1}" var="cnt" />
        <apex:repeat value="{!dataLines}" var="line" id="lines">
       
            <tr>
                <td class="dataCell" style="text-align: center;">
                    <apex:outputText value="{!cnt}"/>
                </td>
                <apex:outputPanel rendered="{!IF(la.Equipment_Type__c == 'NDT' || la.Equipment_Type__c == 'ANI', true , false)}" layout="none">
                    <td class="dataCell" style="text-align: center;">
                        <apex:outputText value="{!line.lad.LOANER__r.Name}"/>
                    </td>
                </apex:outputPanel> 
                <td class="dataCell" style="text-align: center;">
                    <apex:outputText value="{!line.lad.ECCode__c}"/>
                </td>
                <apex:outputPanel rendered="{!IF(la.Equipment_Type__c == 'BS', true , false)}" layout="none">
                    <td class="dataCell" style="text-align: center;">
                        <apex:outputText value="{!line.lad.LOANER__r.Description}"/>
                    </td>
                </apex:outputPanel>
                <apex:outputPanel rendered="{!IF(la.Equipment_Type__c == 'BS', false , true)}" layout="none">
                    <td class="dataCell" style="text-align: center;">
                        <apex:outputText value="{!line.lad.SerialNumber__c}"/>
                    </td>
                </apex:outputPanel>
                <td class="dataCell" style="text-align: center;">
                    <apex:outputText value="{!line.num}"/>
                </td>
                <apex:outputPanel rendered="{!IF(la.Equipment_Type__c == 'BS', true , false)}" layout="none">
                     <td class="dataCell" style="text-align: center;">
                        <apex:outputText value="{!line.lad.LOANER__r.SerialNumber}"/>
                    </td>
                     <td class="dataCell" style="text-align: center;">
                        <apex:outputText value="{!line.lad.LOANER__r.SerialNumber1__c}"/>
                    </td>
                     <td class="dataCell" style="text-align: center;">
                        <apex:outputText value="{!line.lad.LOANER__r.Internal_Asset_number__c}"/>
                    </td>
                </apex:outputPanel>
                <apex:outputPanel rendered="{!IF(la.Equipment_Type__c == 'IE' || la.Equipment_Type__c == 'RVI', true , false)}" layout="none">
                    <td class="dataCell" style="text-align: center;">
                        <apex:outputText value="{!line.lad.LOANER__r.Description}"/>
                    </td>
                </apex:outputPanel>
                <td class="dataCell" style="text-align: center;">
                    <apex:outputText value="{!line.lad.Remark__c}"/>
                </td>
                
            </tr>
 
            <!-- <apex:outputPanel rendered="{!cnt == 32}" layout="none">
                <div style="page-break-after: always;"/> 
                
            </apex:outputPanel>  -->
        <apex:variable value="{!cnt + 1}" var="cnt" />
        
        </apex:repeat>
 
 
    </table>
    <br/>
 
     <apex:outputPanel rendered="{!IF((rowNum > 26 && rowNum <34) || (rowNum > 80 && rowNum < 87),'true','false')}" layout="none">
         <div style="page-break-after: always;"/>
     </apex:outputPanel>
 
    <table style="border: 2px solid black;width: 100%;">
        <caption style="text-align: left;font-size: 15px;" >样机(备品)借用须知:</caption>
        <tr><td>1.请清点及验收样机(备品)后在此协议书上签字或盖章。</td></tr>
        <tr><td>2.请将样机(备品)于贵方确认之期限内归还。</td></tr>
        <apex:outputPanel rendered="{!IF(la.Equipment_Type__c == 'BS', true , false)}" layout="none"> 
            <tr><td>3.如借用之样机(备品)在借用期间损坏(含私拆零部件),我方有权要求贵方按相应金额赔偿或承担维修费用。</td></tr>
        </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>
    </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>