<?xml version="1.0" encoding="UTF-8"?> 
 | 
<WebLink xmlns="http://soap.sforce.com/2006/04/metadata"> 
 | 
    <fullName>All_Delivery_btn</fullName> 
 | 
    <availability>online</availability> 
 | 
    <description>一键发货,有错就会滚</description> 
 | 
    <displayType>button</displayType> 
 | 
    <linkType>javascript</linkType> 
 | 
    <masterLabel>全部发货</masterLabel> 
 | 
    <openType>onClickJavaScript</openType> 
 | 
    <protected>false</protected> 
 | 
    <url>{!RequireScript("/soap/ajax/51.0/connection.js")}  
 | 
{!RequireScript("/soap/ajax/51.0/apex.js")}  
 | 
{!RequireScript("/resource/CommonUtilJs")} 
 | 
//2021-10-22 gwy 版本更改为51.0 
 | 
var foo = function() { 
 | 
    sforce.connection.sessionId = '{!$Api.Session_ID}';  
 | 
var DeliveryGood = new Array();  
 | 
if('{!Rental_Apply__c.Campaign__c}' != '') {  
 | 
DeliveryGood = sforce.connection.query("select Status, Rental_Apply_Flag__c from Campaign where id ='{!Rental_Apply__c.CampaignId__c}'");  
 | 
var records= DeliveryGood.getArray("records");  
 | 
var campaignStatus = records[0].Status;  
 | 
if(campaignStatus == '取消'){  
 | 
alert("学会取消,不可发货");  
 | 
return;  
 | 
} } 
 | 
if('{!Rental_Apply__c.Repair__c}' != '')  { 
 | 
DeliveryGood = sforce.connection.query("select Repair_Final_Inspection_Date__c, Repair_Shipped_Date__c from Repair__c where id ='{!Rental_Apply__c.RepairId__c}'");  
 | 
var records= DeliveryGood.getArray("records");  
 | 
if(records[0].Repair_Final_Inspection_Date__c != null || records[0].Repair_Shipped_Date__c != null){  
 | 
alert("修理有最终检测日或修理品返送日,不可发货");  
 | 
return; 
 | 
} } 
 | 
    var raid = '{!Rental_Apply__c.Id}';  
 | 
    var rtn = sforce.apex.execute("RentalApplyWebService", "DeliverAll", {raid: raid}); 
 | 
    if (rtn == 'Fin') {  
 | 
         alert("全部发货成功");  
 | 
         location.href = "/{!Rental_Apply__c.Id}"; 
 | 
    } else { 
 | 
         alert(rtn); 
 | 
    } 
 | 
} 
 | 
foo();</url> 
 | 
</WebLink> 
 |