高章伟
2022-02-18 8b5f4c6c281cfa548f92de52c8021e37aa81901e
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
public class AgencyConfirmPageController {
    public  eSignForm__c eSignForm { get; set; }
    public boolean disableInput{get;set;}
 
    public AgencyConfirmPageController(ApexPages.StandardController controller) {
    }
    public AgencyConfirmPageController(){
        
    }
    public void init(){
        String paramId = ApexPages.currentPage().getParameters().get('id');
        list<eSignForm__c> ESignFormList = [Select id,agencyAutoSignUpStatus__c, 
                                            AccessoriesQualified__c ,handleOpinionAgency__c, 
                                            agencySignUpDate__c, denyReason__c ,
                                            HPSignUpStatus__c,
                                            agencyAcceptResult__c
                                            from eSignForm__c
                                            where Id = :paramId];
        if( ESignFormList.size() == 0){
            ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR, '找不到对应的签收单!'));
            return;
        }
        eSignForm = ESignFormList[0];
        if(eSignForm.agencyAutoSignUpStatus__c!= null && eSignForm.agencyAutoSignUpStatus__c.equals('申请中')){
           disableInput = false; 
        }else{
            disableInput = true;
        }
        return;
    }
    public PageReference confirm() {
        if(eSignForm.AccessoriesQualified__c){
            if(eSignForm.agencyAcceptResult__c.equals('全部验收')
              || string.isNotBlank(eSignForm.handleOpinionAgency__c)){
            eSignForm.agencyAutoSignUpStatus__c = '已批准';
            }else{
                 ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR, '在验收结果不是全部验收时,请您先填写处理意见!'));
                return null;
            }
        }else if(string.isBlank(eSignForm.denyReason__c)){
            ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR, '经销商验收附件不合格,请您填写驳回理由!'));
            return null;
        }else{
            eSignForm.agencyAutoSignUpStatus__c = '不批准';
        }
        try{
            update eSignForm;
            
            ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR, '确认完毕!'));
            disableInput = true;
        }catch(exception e){
            ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR, e.getMessage()));
 
        }
        return null;
    }
 
}