高章伟
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
public class HpConfirmPageController {
    public  eSignForm__c eSignForm { get; set; }
    public boolean disableInput{get;Set;}
 
    public HpConfirmPageController(ApexPages.StandardController controller) {
    }
    public HpConfirmPageController(){
        
    }
    public void init(){
        String paramId = ApexPages.currentPage().getParameters().get('id');
        list<eSignForm__c> ESignFormList = [Select id,HPSignUpStatus__c,HPAccessoriesQualified__c
                                            ,HPDenyReason__c, HPSignUpDate__c , HPAcceptResult__c
                                            ,
                                            handleOpinionHP__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.HPSignUpStatus__c!= null && eSignForm.HPSignUpStatus__c.equals('申请中')){
           disableInput = false; 
        }else{
            disableInput = true;
        }
        return;
    }
    public PageReference confirm() {
        if(eSignForm.HPAccessoriesQualified__c){
            eSignForm.HPSignUpStatus__c = '已批准';
        }else if(string.isBlank(eSignForm.HPDenyReason__c)){
            ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR, '医院验收附件不合格,请您填写驳回理由!'));
            return null;
            // alert('医院验收附件不合格,请您填写驳回理由!'); 
        }else{
            eSignForm.HPSignUpStatus__c = '不批准';
        }
        try{
            update eSignForm;
            disableInput = true;
            ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR, '确认完毕!'));
        }catch(exception e){
            ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR, e.getMessage()));
 
        }
        return null;
    }
 
    //直销的二次确认check
    public PageReference directSalesConfirm() {
        if(eSignForm.HPAccessoriesQualified__c){
            if(eSignForm.HPAcceptResult__c.equals('全部验收')
              || string.isNotBlank(eSignForm.handleOpinionHP__c)){
            eSignForm.HPSignUpStatus__c = '已批准';
            }else{
                 ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR, '在验收结果不是全部验收时,请您先填写处理意见!'));
                return null;
            }
        }else if(string.isBlank(eSignForm.HPDenyReason__c)){
            ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR, '医院验收附件不合格,请您填写驳回理由!'));
            return null;
        }else{
            eSignForm.HPSignUpStatus__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;
    }
 
}