binxie
2024-01-16 4d3febe8045eb0fa0283af3c53b0c48344b8664d
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
<?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;)}
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 foo = function() {
var campaignStatus = &apos;&apos;; 
var records = null;  // 20220217 ljh  OBPM市场活动联动 
var statusSting = &quot;{!$Label.StatusProcessState}&quot;; // 20220322 ljh add
var statusList = statusSting.split(&apos;,&apos;);
if(&apos;{!Rental_Apply__c.Campaign__c}&apos; != &apos;&apos;) { 
var DeliveryGood = new Array();
// 20220217 ljh update OBPM市场活动联动 start
// DeliveryGood = sforce.connection.query(&quot;select Status, Rental_Apply_Flag__c from Campaign where id =&apos;{!Rental_Apply__c.CampaignId__c}&apos;&quot;);
// var records= DeliveryGood.getArray(&quot;records&quot;);
DeliveryGood = sforce.connection.query(&quot;select Status, Rental_Apply_Flag__c,IF_Approved__c,Meeting_Approved_No__c,Approved_Status__c from Campaign where id =&apos;{!Rental_Apply__c.CampaignId__c}&apos;&quot;);  
records = DeliveryGood.getArray(&quot;records&quot;); 
// 20220217 ljh update OBPM市场活动联动 end
campaignStatus = records[0].Status; 
 
}
 
//贸易合规 you
var AccDealerBlacklist = &apos;{!Rental_Apply__c.AccDealerBlacklist__c}&apos;;//判断客户/经销商是否为黑名单
//var EquipmentGuaranteeFlg = &apos;{!Rental_Apply__c.EquipmentGuaranteeFlg__c}&apos;;
var TradeComplianceStatusFlagBP = &quot;{!$Label.TradeComplianceStatusFlagBP}&quot;;//贸易合规开关
var IFTradeComplianceAlertBP = &quot;{!$Label.IFTradeComplianceAlertBP}&quot;;//贸易合规提醒
if(TradeComplianceStatusFlagBP==&apos;true&apos;){
//if(EquipmentGuaranteeFlg==false){
if(AccDealerBlacklist==&apos;1&apos;){
alert(&apos;&apos;+IFTradeComplianceAlertBP);
return;
}
//}
}
//贸易合规 you
 
if(&quot;{!Rental_Apply__c.Wei_Assigned_Cnt__c}&quot; &gt; &quot;0&quot;) {
    alert(&quot;申请单内存在未分配的配套,请分配备品或分割申请单&quot;);
// 20230220 ljh DB202301265636 start
// }else if(campaignStatus == &apos;取消&apos;){ 
//     alert(&quot;学会取消,不可出库指示&quot;);
}else if(campaignStatus == &apos;取消&apos; || campaignStatus == &apos;取消申请中&apos;){ 
    alert(&quot;学会取消申请中或者已取消,不可出库指示&quot;); 
// 20230220 ljh DB202301265636 end 
}else if (&quot;{!Rental_Apply__c.Status__c}&quot; == &quot;已出库指示&quot; &amp;&amp; &quot;{!Rental_Apply__c.Assigned_Not_Shipment__c}&quot; == &quot;0&quot;) {
    alert(&quot;所有的借出备品Set一览都进行过出库指示了&quot;);
} else if (&quot;{!Rental_Apply__c.Assigned_Not_Shipment__c}&quot; == &quot;0&quot;) {
    alert(&quot;没有可以出库指示的明细&quot;);
} else if (&quot;{!Rental_Apply__c.Demo_purpose1__c}&quot; == &quot;长期借出&quot; &amp;&amp; &quot;{!Rental_Apply__c.Contract_pdf_updated__c}&quot; == &quot;0&quot;) {
    alert(&quot;长期借出时,必须先上传契约书&quot;);
} else if(&apos;{!Rental_Apply__c.Repair__c}&apos; != &apos;&apos; &amp;&amp; (&apos;{!Rental_Apply__c.Repair_Final_Inspection_Date_F__c}&apos; != null &amp;&amp; &apos;{!Rental_Apply__c.Repair_Final_Inspection_Date_F__c}&apos; != &apos;&apos;) || (&apos;{!Rental_Apply__c.RC_return_to_office__c}&apos; != null &amp;&amp; &apos;{!Rental_Apply__c.RC_return_to_office__c}&apos; != &apos;&apos;)) { 
    alert(&quot;修理有最终检测日或修理品返送日,不可出库指示&quot;);
// 20220217 ljh add OBPM市场活动联动 start
} else if (records != null &amp;&amp; records[0].IF_Approved__c == &quot;true&quot; &amp;&amp; (records[0].Meeting_Approved_No__c == null || records[0].Meeting_Approved_No__c == &quot;&quot;) ) {
    alert(&quot;没有决裁号的,暂不能出借,请更新裁决信息。&quot;);
} else if (records != null &amp;&amp; records[0].IF_Approved__c == &quot;true&quot; &amp;&amp; records[0].Meeting_Approved_No__c != &quot;&quot; &amp;&amp;  statusList.indexOf(records[0].Approved_Status__c) != -1 ) {
    alert(&quot;已申请决裁但决裁状态不符合条件。&quot;);
// 20220217 ljh add OBPM市场活动联动 end
} else {
    sforce.connection.sessionId = &quot;{!GETSESSIONID()}&quot;; 
    var raid = &quot;{!Rental_Apply__c.Id}&quot;; 
    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 {
            //var rs1 = sforce.apex.execute(&quot;RentalApplyWebService&quot;, &quot;setShipment_request&quot;, {raid : &quot;{!Rental_Apply__c.Id}&quot;});
 
        sforce.apex.execute(&quot;RentalApplyWebService&quot;, &quot;setShipment_request&quot;, {raid: &quot;{!Rental_Apply__c.Id}&quot;},function(res) {
       // if(event.status) {
            if (res == &quot;状态更新到已出库指示&quot;) {
                alert(&quot;状态更新到已出库指示&quot;);
                print();
                setTimeout(function() {
                        location.href = &quot;/{!Rental_Apply__c.Id}&quot;;
                    }
                    , 100
                );
            } else {
                alert(res);
            }
       // } else {
        //    alert(event.message);
       // }
    });
 
//bp2        }
    }
}}
function print(){
var sql;
if(&apos;{!Rental_Apply__c.Bollow_Date__c}&apos; != &apos;&apos;){
    sql = &quot;select Id from Rental_Apply_Equipment_Set__c where Rental_Apply__c = &apos;{!Rental_Apply__c.Id}&apos; and Shippment_loaner_time__c != null and RAES_Status__c != &apos;已分配&apos; and RAES_Status__c != &apos;取消分配&apos;&quot;;
}else{
    sql = &quot;select Id from Rental_Apply_Equipment_Set__c where Rental_Apply__c = &apos;{!Rental_Apply__c.Id}&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={!Rental_Apply__c.Id}&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;  
}foo();</url>
</WebLink>