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
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
public class BidAnnouncementController {
 
    @AuraEnabled
    public static InitData BidAnnouncementController (String recordId){
        InitData res = new initData();
        try{
            Bid_Announcement__c report = [SELECT     Id FROM Bid_Announcement__c WHERE Id = :recordId LIMIT 1];
            res.Id = report.Id;
            System.debug(LoggingLevel.INFO, '*** res: ' + res);
        }catch(Exception e){
            System.debug(LoggingLevel.INFO, '*** e: ' + e);
        }
        return res;
    }
 
    //中标通知书 申请
    @AuraEnabled
    public static String ApplyFor(String recordId) {
        String messageText = '';
        // Bid_Announcement__c Bid_Announcement = new Bid_Announcement__c();
        try {
        Bid_Announcement__c Bid_Announcement = [SELECT     Id,Status__c,Request_flag__c,Request_user__c,Request_date__c FROM Bid_Announcement__c WHERE Id = :recordId LIMIT 1];
        Bid_Announcement.Id = Bid_Announcement.Id;
        Bid_Announcement.Status__c = LightingButtonConstant.STATUS_Bid_Announcement_ApplyFor;
        Bid_Announcement.Request_flag__c = true;
        Bid_Announcement.Request_user__c = Userinfo.getUserId();
        Bid_Announcement.Request_date__c = Datetime.now();
        update Bid_Announcement;
        messageText = '1';
        return messageText;
        } catch (Exception e) {
        // System.debug(LoggingLevel.INFO, '*** ApplyForXu: ' + ex);
        // messageText = ex.getMessage();
        // return 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;
            }
        }
    }
 
        //中标通知书 同意
        @AuraEnabled
        public static String ConSent(String recordId) {
            String messageText = '';
            try {
            Bid_Announcement__c Bid_Announcement = [SELECT     Id,Status__c,Complete__c,Agree_user__c,Complete_date__c FROM Bid_Announcement__c WHERE Id = :recordId LIMIT 1];
            Bid_Announcement.Id = Bid_Announcement.Id;
            Bid_Announcement.Status__c = LightingButtonConstant.STATUS_Bid_Announcement_Consent;
            Bid_Announcement.Complete__c = true;
            Bid_Announcement.Agree_user__c = Userinfo.getUserId();
            Bid_Announcement.Complete_date__c = Datetime.now();
            update Bid_Announcement;
            messageText = '1';
            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;
                }
            }
        }
 
    //中标通知书 驳回
    @AuraEnabled
    public static String Reject(String recordId) {
        String messageText = '';
        try {
        Bid_Announcement__c Bid_Announcement = [SELECT     Id,Status__c,Complete__c,Agree_user__c,Complete_date__c,Request_flag__c,Request_user__c,Request_date__c FROM Bid_Announcement__c WHERE Id = :recordId LIMIT 1];
        Bid_Announcement.Id = Bid_Announcement.Id;
        Bid_Announcement.Status__c = LightingButtonConstant.STATUS_Bid_Announcement_Reject;
        Bid_Announcement.Complete__c = false;
        Bid_Announcement.Agree_user__c = null;
        Bid_Announcement.Complete_date__c = null;
        Bid_Announcement.Request_flag__c = false;
        Bid_Announcement.Request_user__c = null;
        Bid_Announcement.Request_date__c = null;
        update Bid_Announcement;
        messageText = '1';
        return messageText;
        } catch (Exception e) {
        // System.debug(LoggingLevel.INFO, '*** Reject: ' + ex);
        // messageText = ex.getMessage();
        // return 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;
        }
        }
    }
 
 
    //获取当前登录人的 id
    @AuraEnabled
    public static UserResult UserInfo_Owner() {
        UserResult result = new UserResult();
        ID myUserID = UserInfo.getUserId();
        try { 
            User tempUser =
                [select id,BidCancel__c from user where id = : myUserID ];
            result.id = tempUser.id;
            result.BidCancel = tempUser.BidCancel__c;
        } catch (exception e) {
            
            result.result = e.getMessage();
        }
        return result;
    }
 
    public class InitData{
        @AuraEnabled
        public String Id;
    }
    public class UserResult {
        @AuraEnabled
        public string result;
        public UserResult( ) {
            result = 'Success';
        }
        @AuraEnabled
        public string id;
        @AuraEnabled
        public Boolean BidCancel;
    }
}
 
 
//同意
// var Bid_Announcement = new sforce.SObject("Bid_Announcement__c");
// Bid_Announcement.Id = "{!Bid_Announcement__c.Id}";
// Bid_Announcement.Status__c = "处理完毕";
// Bid_Announcement.Complete__c = "true";
// Bid_Announcement.Agree_user__c = "{!$User.Id}";
// var serverTimestamp = sforce.connection.getServerTimestamp();
// Bid_Announcement.Complete_date__c = serverTimestamp.timestamp;
 
// var result = sforce.connection.update([Bid_Announcement]);
// var messages = getConnectDMLErrorMessages(result);
// if (messages.length > 0) {
// alert(messages.join("\n"));
// }
// location.reload();
 
 
//驳回
// if ('{!$User.BidCancel__c}' == 'false') {
//     alert("没有驳回的权限");
//     } else {
//     var Bid_Announcement = new sforce.SObject("Bid_Announcement__c");
//     Bid_Announcement.Id = "{!Bid_Announcement__c.Id}";
//     Bid_Announcement.Status__c = "草案中";
//     Bid_Announcement.Complete__c = "false";
//     Bid_Announcement.Agree_user__c = null;
//     Bid_Announcement.Complete_date__c = null;
//     Bid_Announcement.Request_flag__c = "false";
//     Bid_Announcement.Request_user__c = null;
//     Bid_Announcement.Request_date__c = null;
    
//     var result = sforce.connection.update([Bid_Announcement]);
//     var messages = getConnectDMLErrorMessages(result);
//     if (messages.length > 0) {
//     alert(messages.join("\n"));
//     }
//     location.reload();
//     }
 
 
 
//申请
// var Bid_Announcement = new sforce.SObject("Bid_Announcement__c");
// Bid_Announcement.Id = "{!Bid_Announcement__c.Id}";
// Bid_Announcement.Status__c = "申请中";
// Bid_Announcement.Request_flag__c = "true";
// Bid_Announcement.Request_user__c = "{!$User.Id}";
// var serverTimestamp = sforce.connection.getServerTimestamp();
// Bid_Announcement.Request_date__c = serverTimestamp.timestamp;
 
// var result = sforce.connection.update([Bid_Announcement]);
// var messages = getConnectDMLErrorMessages(result);
// if (messages.length > 0) {
// alert(messages.join("\n"));
// }
// location.reload();