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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
public class OppSubmitController {
    @AuraEnabled
    public static InitData initSubmitButton (String recordId){
        InitData res = new initData();
        try{
            // Request_tedner_doc__c report = [SELECT     OwnerId,Id,Product_discription__c,Status__c FROM Request_tedner_doc__c WHERE Id = :recordId LIMIT 1];
            Request_tedner_doc__c report = [SELECT     OwnerId,Id,RecordTypeId FROM Request_tedner_doc__c WHERE Id = :recordId LIMIT 1];
            res.OwnerId = report.OwnerId;
            res.Id = report.Id;
            res.RecordTypeId = report.RecordTypeId;
            System.debug(LoggingLevel.INFO, '*** res: ' + res);
        }catch(Exception e){
            System.debug(LoggingLevel.INFO, '*** e: ' + e);
        }
        return res;
    }
 
    //授权申请的提交按钮
    @AuraEnabled
    public static String submit(String recordId) {
        String messageText = '';
       try {
        // Request_tedner_doc__c rac = [SELECT     Id,Status__c,Submit_check_flag__c,RecordTypeId,Submit_time__c,Request_target__c,Document_format__c,Bid_distributor__c,Product_discription__c,Tedner_date__c,Tender_active_day__c,tender_inactive_date__c,Tender_request_reason__c FROM Request_tedner_doc__c WHERE Id = :recordId LIMIT 1];
        Request_tedner_doc__c rac = [SELECT     Id,Status__c,Submit_check_flag__c,RecordTypeId,Submit_time__c FROM Request_tedner_doc__c WHERE Id = :recordId LIMIT 1];
        rac.Status__c = LightingButtonConstant.STATUS_Application_Submitted;
        rac.RecordTypeId = Schema.SObjectType.Request_tedner_doc__c.getRecordTypeInfosByName().get(LightingButtonConstant.RECORD_TYPE_NAME_Application+LightingButtonConstant.STATUS_Application_Submitted).getRecordTypeId();
        rac.Submit_check_flag__c = true;
        rac.Submit_time__c = Datetime.now();
        update rac;
        messageText = '1';
        return messageText;
       } catch (Exception e) {
        if(e.getMessage().contains(':')){
        //kk 20231009  报错信息中含有api 错误解决  start
            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;
            messageText = OppSubmitController.removeUnChinese(messageText);
            return messageText;
        }else{
            messageText=e.getMessage();
            return messageText;
        }
        // return ex.getMessage().split(',')[1];
       } finally {
 
       }
    }
 
 
    //去掉字符串中的英语字符
    public static String removeUnChinese(String str) {      
        return  str.replaceAll('[a-zA-Z]', '');
    }
    //kk 20231009  报错信息中含有api 错误解决  end
 
 
    //授权申请的取消提交按钮
    @AuraEnabled
    public static String submitCancel(String recordId) {
        String messageText = '';
       try {
        Request_tedner_doc__c report = [SELECT     Id,Status__c,Submit_check_flag__c,RecordTypeId,Submit_time__c FROM Request_tedner_doc__c WHERE Id = :recordId LIMIT 1];
        report.Status__c = LightingButtonConstant.STATUS_Application_CancelSubmit;
        report.RecordTypeId = Schema.SObjectType.Request_tedner_doc__c.getRecordTypeInfosByName().get(LightingButtonConstant.RECORD_TYPE_NAME_Application).getRecordTypeId();
        report.Submit_check_flag__c = false;
        report.Submit_time__c = null;
        messageText = '1';
        update report;
        return messageText;
       } catch (Exception e) {
        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;
        }
       } finally {
 
       }
    }
    //获取当前登录人的 id
    @AuraEnabled
    public static UserResult UserInfo_Owner() {
        UserResult result = new UserResult();
        ID myUserID = UserInfo.getUserId();
        
        try { 
            User tempUser =
                [select id from user where id = : myUserID ];
            result.id = tempUser.id;
        } catch (exception e) {
            
            result.result = e.getMessage();
        }
        return result;
    }
    
    public class InitData{
        @AuraEnabled
        public String Id;
        @AuraEnabled
        public String OwnerId;
        @AuraEnabled
        public String RecordTypeId;
    }
    public class UserResult {
        @AuraEnabled
        public string result;
        public UserResult( ) {
            result = 'Success';
        }
        @AuraEnabled
        public string id;
        //20210105 CHAN-BWX3YU you end
    }
}
 
    // if("{!Request_tedner_doc__c.OwnerId}" == "{!$User.Id}") {
    //     var rac = new sforce.SObject("Request_tedner_doc__c");
    //     rac.Id = "{!Request_tedner_doc__c.Id}";
    //     rac.Status__c = "已提交";
    //     rac.Submit_check_flag__c = "true";
    //     rac.RecordTypeId = "01210000000RNXn";
    //     var serverTimestamp = sforce.connection.getServerTimestamp();
    //     rac.Submit_time__c = serverTimestamp.timestamp;