public with sharing class LexOpdCommitApprovalController {
    @AuraEnabled
    public static CancelPostponePlan__c init(String recordId){
        CancelPostponePlan__c res = new CancelPostponePlan__c();
        try{
            res = [Select Id,Status__c,CancelOPDPlan__c
                FROM CancelPostponePlan__c
                    WHERE  Id = : recordId];
        }
        catch(Exception e){
            System.debug(LoggingLevel.INFO, '*** e: ' + e);
        }
        return res;
    }

    @AuraEnabled
    public static String  newUpdateCancelPostponePlan(String Id,String Status){
        CancelPostponePlan__c res = new CancelPostponePlan__c();
        try{
            res.Id=Id;
            if(Status == '取消'){
                res.Status__c ='提交';
            }
            else if (Status == '延期报告'){
                res.Status__c ='延期提交';
            }
            update res;
            return 'success';
        }
        catch (Exception e) {
            String messageText='';
            if(e.getMessage().contains(':')){
                String eMessage =e.getMessage();
                Integer left = eMessage.indexOf(',')+1;
                Integer right= eMessage.lastIndexOf('：')+1;
                if(right>eMessage.length()||right<=left){
                    right=eMessage.length();
                }
                String mes=eMessage.substring(left,right);
                messageText = mes;
                return messageText;
            }else{
                messageText=e.getMessage();
                return messageText;
            }  
        }

    } 
}