liuyn
2024-03-11 a87f1c3df03078814ee97ad0c8ac200a232419e9
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
public with sharing class buttonAccountCtl {
 
    @AuraEnabled
    public static InitData init(String recordId){
        InitData res = new initData();
        try{
            String mcServiceRecordTypeId = [select Id,DeveloperName from RecordType where  SobjectType = 'Maintenance_Contract__c' and DeveloperName = 'NewMaintenance_Contract'].Id;
            Account report =  [SELECT Hospital__r.IFTradeComplianceIntercept__c ,Department_Class__r.Id,Hospital__r.Id,
                                Hospital__r.Name,// WYL 贸易合规2期 add
                                Department_Class__c,Hospital__c,Id FROM Account WHERE Id =: recordId LIMIT 1];
            System.debug(LoggingLevel.INFO, '*** opp: ' + report);
            res.Id = report.Id;
            res.HospitalC = report.Hospital__c;
            res.HospitalId = report.Hospital__r.Id;
            res.DepartmentClassC = report.Department_Class__c;
            res.DepartmentClassId = report.Department_Class__r.Id;
            res.IFTradeComplianceIntercept = report.Hospital__r.IFTradeComplianceIntercept__c;
            res.Name = report.Hospital__r.Name;// WYL 贸易合规2期 add
            res.recordTypeId = mcServiceRecordTypeId;
 
            res.userID = UserInfo.getUserId();
 
            System.debug(LoggingLevel.INFO, '*** res: ' + res);
        }catch(Exception e){
            System.debug(LoggingLevel.INFO, '*** e: ' + e);
        }
        return res;
    }   
 
       // 查找UserName
       @AuraEnabled
       public static List<User> initUserName(String userId){
           List<User> res = new List<User>();
           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;
       }
 
       @AuraEnabled
     public static List<Account> selecctAccountByAccountId(String AccountId){
         try {
           List<Account> 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,Parent.Parent.FSE_GI_Main_Leader__r.Work_Location__c,Parent.Parent.FSE_SP_Main_Leader__r.Work_Location__c FROM Account WHERE ID=:AccountId];
           return accounts;
       } catch (Exception e) {
             throw new AuraHandledException(e.getMessage());
          }
      }
 
    public class InitData{
        @AuraEnabled
        public String Id;
        @AuraEnabled
        public String HospitalC;
        @AuraEnabled
        public String HospitalId;
        @AuraEnabled
        public String DepartmentClassC;
        @AuraEnabled
        public String DepartmentClassId;
        @AuraEnabled
        public String Name;
        @AuraEnabled
        public String userID;
        @AuraEnabled
        public String recordTypeId;
        @AuraEnabled
        public String IFTradeComplianceIntercept;
     }
}