Li Jun
2022-04-08 ac719375874fd50fad5a11f8e04ac3329081bd0b
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
<?xml version="1.0" encoding="UTF-8"?>
<WebLink xmlns="http://soap.sforce.com/2006/04/metadata">
    <fullName>Loaner_arranged_e_mail</fullName>
    <availability>online</availability>
    <displayType>button</displayType>
    <linkType>javascript</linkType>
    <masterLabel>####出库指示</masterLabel>
    <openType>onClickJavaScript</openType>
    <protected>false</protected>
    <url>{!RequireScript(&quot;/soap/ajax/51.0/connection.js&quot;)} 
{!RequireScript(&quot;/soap/ajax/51.0/apex.js&quot;)}
//2021-10-22 gwy 版本更改为51.0
var buttons = document.getElementsByName(&apos;loaner_arranged_e_mail&apos;);
for (var i=0; i&lt;buttons.length; i++)
{
    buttons[i].className = &quot;btnDisabled&quot;;
    buttons[i].disabled = true;
}
 
var campaignStatus = &apos;&apos;;  
 
var raliveryGood = new Array();
reliveryGood = sforce.connection.query(&quot;select Id,Campaign__c,Repair__c,Status__c, Demo_purpose1__c,Contract_pdf_updated__c,Repair_Final_Inspection_Date_F__c,RC_return_to_office__c from Rental_ApplyConsum__c where Name=&apos;{!Consum_Apply_Equipment_Set__c.Consum_Apply__c}&apos;&quot;); 
var rarecords= reliveryGood.getArray(&quot;records&quot;);
var RentalApply = rarecords[0];
 
if(RentalApply.Campaign__c != &apos;&apos; &amp;&amp; RentalApply.Campaign__c != null) { 
var DeliveryGood = new Array();
DeliveryGood = sforce.connection.query(&quot;select Status, Rental_Apply_Flag__c from Campaign where id =&apos;&quot; + RentalApply.Campaign__c +  &quot;&apos;&quot;); 
var records= DeliveryGood.getArray(&quot;records&quot;); 
 
campaignStatus = records[0].Status; 
 
}
if(&quot;{!Consum_Apply__c.Wei_Assigned_Cnt__c}&quot; &gt; &quot;0&quot;) { 
    alert(&quot;申请单内存在未分配的耗材,请分配或分割申请单&quot;); 
}else if(campaignStatus == &apos;取消&apos;){ 
    alert(&quot;学会取消,不可出库指示&quot;);  
}else if (&quot;{!Consum_Apply_Equipment_Set__c.Assigned_Not_Shipment__c}&quot; == &quot;0&quot;) {
    alert(&quot;没有可以出库指示的明细&quot;);
} else if (RentalApply.Demo_purpose1__c == &quot;长期耗材&quot; &amp;&amp; RentalApply.Contract_pdf_updated__c == &quot;0&quot;) {
    alert(&quot;长期耗材时,必须先上传契约书&quot;);
} else if(RentalApply.Repair__c != &apos;&apos; &amp;&amp; RentalApply.Repair__c != null &amp;&amp; (RentalApply.Repair_Final_Inspection_Date_F__c != null &amp;&amp; RentalApply.Repair_Final_Inspection_Date_F__c != &apos;&apos;) || (RentalApply.RC_return_to_office__c != null &amp;&amp; RentalApply.RC_return_to_office__c != &apos;&apos;)) { 
    alert(&quot;修理有最终检测日或修理品返送日,不可出库指示&quot;);
} else {
    sforce.connection.sessionId = &quot;{!GETSESSIONID()}&quot;; 
    var raid = RentalApply.Id; 
    var rs1 = sforce.apex.execute(&quot;RentalApplyWebService&quot;, &quot;approvalCheck&quot;, {rentalApplyId: raid}); 
    if (rs1 != &apos;1&apos;) {
        alert(rs1);
    } else {
//bp2        var rs2 = sforce.apex.execute(&quot;RentalApplyWebService&quot;, &quot;reserve&quot;, {rentalApplyId: raid}); 
//bp2        if (rs2 != &apos;1&apos;) {
//bp2            alert(rs2);
//bp2        } else {
 
               sforce.apex.execute(&quot;RentalApplyWebService&quot;, &quot;setRaesShipment_request&quot;, {raesid: &quot;{!Consum_Apply_Equipment_Set__c.Id}&quot;},function(res) {
            if (res == &quot;状态更新到已出库指示&quot;) {
                alert(&quot;状态更新到已出库指示&quot;);
                print();
                setTimeout(function() {
                        location.href = &quot;/{!Consum_Apply__c.Id}&quot;;
                    }
                    , 100
                );
            } else {
                alert(res);
            }
        });
//bp2        }
    }
}
function print(){
var sql;
if(&apos;{!Consum_Apply__c.Bollow_Date__c}&apos; != &apos;&apos;){
    sql = &quot;select Id from Rental_Apply_Equipment_SetConsum__c where Rental_ApplyConsum__c = &apos;&quot; + RentalApply.Id +  &quot;&apos; and Shippment_loaner_time2__c != null and RAES_Status__c != &apos;已分配&apos; and RAES_Status__c != &apos;取消分配&apos;&quot;;
}else{
    sql = &quot;select Id from Rental_Apply_Equipment_SetConsum__c where Rental_ApplyConsum__c = &apos;&quot; + RentalApply.Id +  &quot;&apos; and RAES_Status__c != &apos;已分配&apos; and RAES_Status__c != &apos;取消分配&apos;&quot;;
}
var sqlResult = sforce.connection.query(sql);
var records = sqlResult.getArray(&quot;records&quot;);
var size =records.length;
var length = size%10 ==0? size/10 : parseInt(size/10) +1;
for(var i =0;i&lt;length;i++){
    window.open(&apos;/apex/FixtureRentalPDF?raid=&apos; + RentalApply.Id + &apos;&amp;page=&apos; + i);
}
}
 
 
function fixTime(time){
   if(time &lt; 10) {time = &quot;0&quot; + time};
   return time;
}
function fixDate(date){
  var Month = fixTime(date.getMonth() + 1);
  var Day = fixTime(date.getDate());
  var UTC = date.toUTCString();
  var Time = UTC.substring(UTC.indexOf(&apos;:&apos;)-2, UTC.indexOf(&apos;:&apos;)+6);
  var Minutes = fixTime(date.getMinutes());
  var Seconds = fixTime(date.getSeconds());
  return date.getFullYear() + &quot;-&quot; +  Month + &quot;-&quot; + Day + &quot;T&quot; + Time;  
}</url>
</WebLink>