高章伟
2022-03-18 4bfe21c4b5ddc089ae5a95f4b10f6cff148b690d
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
<apex:page standardController="Repair__c">
 
<script src="/soap/ajax/51.0/connection.js" type="text/javascript"></script>
<script src="/soap/ajax/51.0/apex.js" type="text/javascript"></script>
 
<div id="ivtDifferenceDetail"  style="position: relative; margin-top: 20px; margin-left: 20px;font-size: 23px;"></div>
<div id="ivtDifferenceDetailBack"  style="position: relative; display:none; margin-top: 20px; margin-left: 20px;font-size: 23px;">
    <a style="font-size: 18px;">请点击</a>
    <a href="javascript: history.go(-1)" style="color: blue;font-size: 20px;">返回</a><br/>
</div>
 
<script type="text/javascript">
    var message;
    
    var Status = '{!Repair__c.Status__c}';
    var FSE = '{!Repair__c.FSE_ApplyForRepair_time__c}';
    var SAP = '{!Repair__c.SAP_Transfer_time__c}';
    var cre = '{!Repair__c.CreatedById}';
    var Rep = '{!Repair__c.Repair_Ordered_Date__c}';
    var acc = '{!Repair__c.Acc_OwnerId__c}';
    var fSE = '{!Repair__c.FSE_ownerid__c}';
 
    if (Status != null && Status.length > 0) {
        if (Status != "草案中"&& Status != "1.受理完毕(SAP待发送)"&& Status != "4.修理品返送阶段") {
            message = "不是草案中,不能删除";
            document.getElementById('ivtDifferenceDetail').innerHTML = message;
            document.getElementById("ivtDifferenceDetailBack").style.display = "block";
 
        }
        else if (Status == "0.申请完毕"&& (FSE != "")) {
            message = "FSE已经申请,不能删除";
            document.getElementById('ivtDifferenceDetail').innerHTML = message;
            document.getElementById("ivtDifferenceDetailBack").style.display = "block";
        }
        else if (Status == "4.修理品返送阶段"&& (SAP != "" || Rep!= "")){
            message = "已经发送过SAP,不能删除";
            document.getElementById('ivtDifferenceDetail').innerHTML = message;
            document.getElementById("ivtDifferenceDetailBack").style.display = "block";
        }
        else if ("{!$User.Id}".substring(0,15) != cre.substring(0,15) && "{!$User.Id}".substring(0,15) != acc.substring(0,15)&& "{!$User.Id}".substring(0,15) != fSE.substring(0,15)) {
            message = "不是所有人、创建人或FSE主负责人,不能删除";
            document.getElementById('ivtDifferenceDetail').innerHTML = message;
            document.getElementById("ivtDifferenceDetailBack").style.display = "block";
        }
        else {
            
            sforce.connection.sessionId = '{!$Api.Session_ID}';
            var rtn=sforce.apex.execute("ControllerUtil","deleteRepair",{rid:'{!Repair__c.Id}'});
            if (rtn == "OK") {
                reload();
            } else {
                alert(rtn);
 
            }
        }
    }
 
    function reload(){
        var str="";
        if(getParam('retURL')!==null){
            str +=getParam('retURL');
        }
        window.open(str,'_self');
    }
 
    function getParam(paramName) {
        paramValue = "", isFound = !1;
        if (this.location.search.indexOf("?") == 0 && this.location.search.indexOf("=") > 1) {
            arrSource = unescape(this.location.search).substring(1, this.location.search.length).split("&"), i = 0;
            while (i < arrSource.length && !isFound) arrSource[i].indexOf("=") > 0 && arrSource[i].split("=")[0].toLowerCase() == paramName.toLowerCase() && (paramValue = arrSource[i].split("=")[1], isFound = !0), i++
        }
    return paramValue == "" && (paramValue = null), paramValue
}
</script>
</apex:page>