Li Jun
2022-04-19 2f183a6b0a83ec3f7d35375d5d25d200efc2a3e1
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
<?xml version="1.0" encoding="UTF-8"?>
<WebLink xmlns="http://soap.sforce.com/2006/04/metadata">
    <fullName>Select_Substitute</fullName>
    <availability>online</availability>
    <displayType>massActionButton</displayType>
    <linkType>javascript</linkType>
    <masterLabel>分配代替品</masterLabel>
    <openType>onClickJavaScript</openType>
    <protected>false</protected>
    <requireRowSelection>true</requireRowSelection>
    <url>{!RequireScript(&quot;/soap/ajax/51.0/connection.js&quot;)} 
{!RequireScript(&quot;/soap/ajax/51.0/apex.js&quot;)}
{!RequireScript(&quot;/resource/CommonUtilJs&quot;)} 
//2021-10-22 gwy 版本更改为51.0
var records = {!GETRECORDIDS($ObjectType.Consum_Apply_Equipment_Set__c)};
 
if (records.length &lt; 1) {
    alert(&quot;请选择一条耗材备品一览记录&quot;);
} else if (records.length &gt; 1) {
    alert(&quot;只能选择一条记录&quot;);
} else {
 
    // 可分配代替品前提1 -- 备品耗材申请的状态:“已批准”到“已出库指示”
    if(&apos;{!Consum_Apply__c.Status__c}&apos; != &apos;已批准&apos; &amp;&amp; &apos;{!Consum_Apply__c.Status__c}&apos; != &apos;已出库指示&apos;) {
        alert(&apos;申请书状态不符合分配代替品条件,请确认申请的状态&apos;);
    } else {
        // 可分配代替品前提2 -- 所选耗材备品配套一览的状态:‘已批准’到‘出库前已检测’
        var soql = &quot;select Cancel_Select__c,Irreplaceable_flag__c,RAES_Status__c,Shippment_loaner_time2__c from Rental_Apply_Equipment_SetConsum__c where Id=&apos;&quot; 
 + records[0] + &quot;&apos;&quot;;
        var soqlRecords = sforce.connection.query(soql).getArray(&quot;records&quot;);
        var status = soqlRecords[0].RAES_Status__c;  
        var irreplaceable = soqlRecords[0].Irreplaceable_flag__c;
        var shipTime = soqlRecords[0].Shippment_loaner_time2__c;
 
        if(status == &quot;草案中&quot; || status == &quot;申请中&quot; || shipTime != null) {
            alert(&quot;一览的状态不符合分配替代品条件&quot;);
        } else if(irreplaceable==&quot;true&quot;) {
            alert(&quot;申请人勾选了代替品不可&quot;);
        } else {
            window.open(&quot;/apex/RentalFixtureSetSelect?pt_recid={!Consum_Apply__c.Id}&amp;raesid=&quot;+records[0]);
        }    
    }
    
}</url>
</WebLink>