public with sharing class buttonOnCallCtl { public buttonOnCallCtl() { } @AuraEnabled public static InitData init(String recordId){ InitData res = new initData(); try{ On_Call__c report = [SELECT Id,Name,Oncall_Equipment__r.Id,segment__r.Id,segment__c,HP__c,HospitalId__c,Salesdepartment_HP_ID__c,Salesdepartment_HP__c,Oncall_Equipment__c,Trable_occur_daY_collect_c__c FROM On_Call__c WHERE Id =: recordId LIMIT 1]; System.debug(LoggingLevel.INFO, '*** opp: ' + report); res.Id = report.Id; res.Name = report.Name; res.SegmentC = report.segment__c; res.SegmentId = report.segment__r.Id; res.HPC = report.HP__c; res.HospitalIdC = report.HospitalId__c; res.SalesdepartmentHPIDC = report.Salesdepartment_HP_ID__c; res.SalesdepartmentHPC = report.Salesdepartment_HP__c; res.OncallEquipmentC = report.Oncall_Equipment__c; res.OncallEquipmentId = report.Oncall_Equipment__r.Id; res.TrableOccurdaYCollectC = report.Trable_occur_daY_collect_c__c; res.userID = UserInfo.getUserId(); System.debug(LoggingLevel.INFO, '*** res: ' + res); }catch(Exception e){ System.debug(LoggingLevel.INFO, '*** e: ' + e); } return res; } @AuraEnabled public static List selecctAccountBySegmentId(String segmentId){ List accounts = new List(); try { accounts = [SELECT ParentId,Parent.RecordTypeId,Parent.RecordType_DeveloperName__c ,Parent.Parent.FSE_GI_Main_Leader__c, Parent.Parent.FSE_GI_Main_Leader__r.Name,Parent.Parent.FSE_SP_Main_Leader__r.Name,Parent.Parent.FSE_SP_Main_Leader__c FROM Account WHERE Id=: segmentId]; } catch (Exception e) { System.debug(LoggingLevel.INFO, '*** e: ' + e); } return accounts; } @AuraEnabled public static List selecctAccountBySegmentId02(String segmentId){ List accounts = new List(); try { accounts = [SELECT id,ParentId,Parent.RecordTypeId,Parent.RecordType_DeveloperName__c, Parent.Parent.FSE_GI_Main_Leader__r.Work_Location__c,Parent.Parent.FSE_SP_Main_Leader__r.Work_Location__c FROM Account WHERE Id=: segmentId]; } catch (Exception e) { System.debug(LoggingLevel.INFO, '*** e: ' + e); } return accounts; } // 查找UserName @AuraEnabled public static List initUserName(String userId){ List res = new List(); try{ res = [SELECT Id,name,RepairSalesPoint_Province_China__c,Employee_No__c FROM User WHERE Id=: userId ]; }catch(Exception e){ System.debug(LoggingLevel.INFO, '*** e: ' + e); } return res; } public class InitData{ @AuraEnabled public String Id; @AuraEnabled public String Name; @AuraEnabled public String SegmentC; @AuraEnabled public String HPC; @AuraEnabled public String HospitalIdC; @AuraEnabled public String SalesdepartmentHPIDC; @AuraEnabled public String SalesdepartmentHPC; @AuraEnabled public String OncallEquipmentC; @AuraEnabled public Date TrableOccurdaYCollectC; @AuraEnabled public String userID; @AuraEnabled public String SegmentId; @AuraEnabled public String OncallEquipmentId; } }