public with sharing class lexLostCancelReportController { @AuraEnabled public static InitData initSubmitReportButton(String recordId){ InitData res = new InitData(); try { Lost_Cancel_Report__c report = [ select Opportunity__c from Lost_Cancel_Report__c where Id =: recordId ]; Opportunity opp = [ select Cnt_Lost_cancel_report__c, Cnt_Lost_cancel_Draft__c from Opportunity where Id =: report.Opportunity__c ]; res.cntLostCancelDraft = opp.Cnt_Lost_cancel_Draft__c; res.cntLostCancelReport = opp.Cnt_Lost_cancel_report__c; } catch (Exception e) { } return res; } @AuraEnabled public static InitData initForEditCancelReport(String recordId){ InitData res = new InitData(); try { Lost_cancel_report__c report = [ select Id, RecordTypeId, Opportunity__c, LostType__c , Report_Status__c from Lost_cancel_report__c where id =: recordId ]; res.recordTypeId = report.RecordTypeId; res.lostType = report.LostType__c; res.reportStatus = report.Report_Status__c; } catch (Exception e) { } return res; } @AuraEnabled public static string updateSubmitReportButton(String recordId){ Savepoint sp = Database.setSavepoint(); Lost_cancel_report__c report = new Lost_cancel_report__c(); try { report.Id = recordId; report.Report_Status__c = '提交'; update report; // Approval.ProcessSubmitRequest psr = new Approval.ProcessSubmitRequest(); // psr.setObjectId(report.Id); // Approval.ProcessResult submitResult = Approval.process(psr); return null; } catch (Exception e) { Database.rollback(sp); return e.getDmlMessage(0); } } public class InitData { @AuraEnabled public Decimal cntLostCancelReport; @AuraEnabled public Decimal cntLostCancelDraft; @AuraEnabled public String recordTypeId; @AuraEnabled public String lostType; @AuraEnabled public String reportStatus; } }