<?xml version="1.0" encoding="UTF-8"?> 
 | 
<WebLink xmlns="http://soap.sforce.com/2006/04/metadata"> 
 | 
    <fullName>NewTransferApply</fullName> 
 | 
    <availability>online</availability> 
 | 
    <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 raId = '{!Rental_Apply__c.Id}'; 
 | 
var raName = '{!Rental_Apply__c.Name}'; 
 | 
var saveURL= '/apex/TransferApplySelectDetail?raId='+raId; 
 | 
var sql = "SELECT Id,Name,Lost_item_giveup__c,Arrival_in_wh__c,Arrival_wh_Result_Agency__c ,Rental_Apply_Equipment_Set__r.First_RAESD__r.Arrival_in_wh__c,"; 
 | 
    sql +=  " Rental_Apply__r.RecordType.DeveloperName,Lost_Item_return__c,Is_Body__c,Asset__c,Rental_Apply__c,OneToOne_Flag__c "; 
 | 
    sql +=  ",Rental_Apply_Equipment_Set__r.First_RAESD__r.Arrival_wh_Result_Agency__c "; 
 | 
    sql += ",Rental_Apply_Equipment_Set__r.First_RAESD__r.Lost_item_giveup__c"; 
 | 
    sql += ",Check_lost_Item__c,Check_lost_Item_Final__c,Rental_Apply_Equipment_Set__r.First_You_Xiao_Ku_Cun__c"; 
 | 
    sql += ",Rental_Apply_Equipment_Set__r.First_RAESD__r.Arrival_wh_time__c,Arrival_wh_time__c  "; 
 | 
    sql += " FROM Rental_Apply_Equipment_Set_Detail__c WHERE Rental_Apply__c = '"+raId+"'  AND Cancel_Select__c = false"; 
 | 
var result = sforce.connection.query(sql); 
 | 
var raesdList = result.getArray("records"); 
 | 
var IsCanCreateTransfer = false; 
 | 
if(raesdList.length >0){ 
 | 
    if(raesdList[0].Rental_Apply__r.RecordType.DeveloperName!= 'AgencyRequest' ){ 
 | 
        alert('此记录类型不支持新建调拨单'); 
 | 
    }else{ 
 | 
        for(var i = 0;i<raesdList.length;i++){ 
 | 
            if(raesdList[i].Asset__c != null){ 
 | 
                //画面默认且仅显示符合调拨要求的数据(①欠品断念后找回的主体 ②(主体上架ok)欠品断念后找回的附属品 ③主体待修理的整个配套 ④(主体上架ok)待修理的附属品)⑤主体断念后单独的附属品 
 | 
                if(raesdList[i].Is_Body__c == 'true'){ 
 | 
                    //①欠品断念后找回的主体 
 | 
                    if(raesdList[i].Lost_item_giveup__c == 'true'){ 
 | 
                        IsCanCreateTransfer = true; break; 
 | 
                    } 
 | 
                    //③主体待修理的整个配套 
 | 
                    if(raesdList[i].Arrival_wh_Result_Agency__c != null && (raesdList[i].Arrival_wh_Result_Agency__c == '待修理' || raesdList[i].Arrival_wh_Result_Agency__c == '移至报废区' )){ 
 | 
                        IsCanCreateTransfer = true; break; 
 | 
                    } 
 | 
                }else{ 
 | 
                    //③主体待修理的整个配套(不是欠品的附属品) 
 | 
                    if(raesdList[i].Rental_Apply_Equipment_Set__r.First_RAESD__r.Arrival_wh_Result_Agency__c != null && 
 | 
                    (raesdList[i].Rental_Apply_Equipment_Set__r.First_RAESD__r.Arrival_wh_Result_Agency__c == '待修理' || 
 | 
                    raesdList[i].Rental_Apply_Equipment_Set__r.First_RAESD__r.Arrival_wh_Result_Agency__c == '移至报废区' ) && 
 | 
                    raesdList[i].OneToOne_Flag__c == 'true' && 
 | 
                    raesdList[i].Arrival_wh_Result_Agency__c != null 
 | 
                    ){ 
 | 
                        IsCanCreateTransfer = true; break; 
 | 
                    } 
 | 
                    //②主体欠品断念后的整个配套(不是欠品的附属品) 
 | 
                    //有主体得是一对一附属品 
 | 
                    if(raesdList[i].Rental_Apply_Equipment_Set__r.First_RAESD__r.Lost_item_giveup__c == 'true' && 
 | 
                    raesdList[i].OneToOne_Flag__c == 'true' && 
 | 
                    raesdList[i].Arrival_wh_Result_Agency__c != null){ 
 | 
                        IsCanCreateTransfer = true; break; 
 | 
                    } 
 | 
                    //④(主体上架ok)待修理的附属品 
 | 
                    if(raesdList[i].Rental_Apply_Equipment_Set__r.First_RAESD__r.Arrival_wh_Result_Agency__c !=null && 
 | 
                    raesdList[i].Rental_Apply_Equipment_Set__r.First_RAESD__r.Arrival_wh_Result_Agency__c == 'OK'  && 
 | 
                    raesdList[i].OneToOne_Flag__c == 'true' && 
 | 
                    raesdList[i].Arrival_wh_Result_Agency__c != null && (raesdList[i].Arrival_wh_Result_Agency__c == '待修理' || raesdList[i].Arrival_wh_Result_Agency__c == '移至报废区')){ 
 | 
                        IsCanCreateTransfer = true; break; 
 | 
                    } 
 | 
                    //⑤ 断念后的附属品 
 | 
                    if(raesdList[i].Lost_item_giveup__c == 'true'){ 
 | 
                        IsCanCreateTransfer = true; break; 
 | 
                    } 
 | 
                    if(raesdList[i].Rental_Apply_Equipment_Set__r.First_You_Xiao_Ku_Cun__c <= 0 
 | 
                        && raesdList[i].OneToOne_Flag__c  && raesdList[i].Check_lost_Item__c != null && raesdList[i].Check_lost_Item_Final__c !=null && raesdList[i].Check_lost_Item__c == '欠品' && raesdList[i].Check_lost_Item_Final__c == 'OK' 
 | 
                        && raesdList[i].Arrival_in_wh__c == 'true' 
 | 
                        && raesdList[i].Arrival_wh_time__c != raesdList[i].Rental_Apply_Equipment_Set__r.First_RAESD__r.Arrival_wh_time__c ){ 
 | 
                        IsCanCreateTransfer = true; break; 
 | 
                    } 
 | 
                } 
 | 
            } 
 | 
        } 
 | 
        if(IsCanCreateTransfer){ 
 | 
            var tasql = "SELECT Id, Name, DeveloperName, isActive FROM RecordType  WHERE DeveloperName = 'AgencyToCenter' AND SobjectType = 'TransferApply__c' AND isActive = true"; 
 | 
            var result = sforce.connection.query(tasql); 
 | 
            var recordList = result.getArray("records"); 
 | 
            var RecordTypeId = recordList[0].Id 
 | 
            //%2Fa44%2Fo 
 | 
            var url = '/a4C/e?retURL=%2F'+raId+'&saveURL='+saveURL+'&RecordType='+RecordTypeId+'&Name=*&CF00N100000098vzy_lkid='+raId+'&CF00N100000098vzy='+raName; 
 | 
            window.open(url); 
 | 
        }else{ 
 | 
            alert('该申请没有符合条件的借出备品配套一览明细!'); 
 | 
        } 
 | 
    } 
 | 
}else{ 
 | 
    alert('该申请没有符合条件的借出备品配套一览明细!'); 
 | 
}</url> 
 | 
</WebLink> 
 |