涂煌豪
2022-03-30 ae4088132b8d18959452d0ca172f6c004e8c2c82
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
<?xml version="1.0" encoding="UTF-8"?>
<WebLink xmlns="http://soap.sforce.com/2006/04/metadata">
    <fullName>CustomDelete</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-21 gwy 版本更改为51.0
var results = sforce.connection.query(&quot;SELECT Id, Status__c,SAP_Transfer_time__c, Repair_Ordered_Date__c, CreatedById, Acc_OwnerId__c,FSE_ownerid__c,FSE_ApplyForRepair_time__c FROM Repair__c WHERE Id = &apos;{!Repair__c.Id}&apos;&quot;); 
var repList = results.getArray(&quot;records&quot;); 
if (repList != null &amp;&amp; repList.length &gt; 0) {
var rp = repList[0];
if (rp.Status__c != &quot;草案中&quot;
        &amp;&amp; rp.Status__c != &quot;1.受理完毕(SAP待发送)&quot;
        &amp;&amp; rp.Status__c != &quot;4.修理品返送阶段&quot;
) {
    alert(&quot;不是草案中,不能删除&quot;);
}
else if (rp.Status__c == &quot;0.申请完毕&quot;
        &amp;&amp; (rp.FSE_ApplyForRepair_time__c != &quot;&quot;)
) {
    alert(&quot;FSE已经申请,不能删除&quot;);
else if (rp.Status__c == &quot;4.修理品返送阶段&quot;
        &amp;&amp; (rp.SAP_Transfer_time__c != &quot;&quot; || rp.Repair_Ordered_Date__c != &quot;&quot;)
) {
    alert(&quot;已经发送过SAP,不能删除&quot;);
}
else if (&quot;{!$User.Id}&quot;.substring(0,15) != rp.CreatedById.substring(0,15) &amp;&amp; &quot;{!$User.Id}&quot;.substring(0,15) != rp.Acc_OwnerId__c.substring(0,15)&amp;&amp; &quot;{!$User.Id}&quot;.substring(0,15) != rp.FSE_ownerid__c.substring(0,15)) {
    alert(&quot;不是所有人、创建人或FSE主负责人,不能删除&quot;);
else {
 
    if (confirm(&quot;是否确定?&quot;)) {
    var rtn = sforce.apex.execute(&quot;ControllerUtil&quot;,&quot;deleteRepair&quot;,{rid:rp.Id});
    if (rtn == &quot;OK&quot;) {
        window.location.href = &quot;/a0J/o&quot;;
    } else {
        alert(rtn);
    }
   }
}
}</url>
</WebLink>