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
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
import { LightningElement, track, wire ,api} from 'lwc';
import LightningConfirm from 'lightning/confirm';
import jquery183minjs from '@salesforce/resourceUrl/jquery183minjs';
import PleaseWaitDialog from '@salesforce/resourceUrl/PleaseWaitDialog';
import { ShowToastEvent } from 'lightning/platformShowToastEvent';
import { NavigationMixin } from 'lightning/navigation';
import { encodeDefaultFieldValues } from 'lightning/pageReferenceUtils';
import { CurrentPageReference } from 'lightning/navigation';
import { CloseActionScreenEvent } from 'lightning/actions';
import TradeComplianceStatusFlagFW from '@salesforce/label/c.TradeComplianceStatusFlagFW';
import IFTradeComplianceAlert from '@salesforce/label/c.IFTradeComplianceAlert';
    
import init  from "@salesforce/apex/lexMaintenanceContractUrlController.lexCustomNewContract";
import accSendEmailFW  from "@salesforce/apex/OpportunityWebService.accSendEmailFW";
import lwcCSS from '@salesforce/resourceUrl/lwcCSS';
import {loadStyle} from 'lightning/platformResourceLoader';
import IFTradeComplianceAlert2 from '@salesforce/label/c.IFTradeComplianceAlert2'; //sx 贸易合规2期 add
import accSendEmailFW2 from "@salesforce/apex/lexSelectAssetEstimateVMController.accSendEmailFW"; // WYL  贸易合规2期 add
import IFTradeComplianceAlertName from '@salesforce/label/c.IFTradeComplianceAlertName'; // WYL 贸易合规2期 add
export default class lexCustomNewContract extends NavigationMixin(LightningElement) {
    @api recordId;
    IsLoading=true;
    name;
    Hospital;
    Department_Class;
    Department;
    Service_Contract_Staff;
    Estimate_Target;
    Dealer;
    recordtypeId;
    accDealerBlacklist;
    a=IFTradeComplianceAlert;
    b=TradeComplianceStatusFlagFW;
    //20231120 sx 贸易合规2期 add
    proTradeComplianceStatus;
    violationName;
 
@wire(CurrentPageReference)
     getStateParameters(currentPageReference) {
             console.log(111);
             console.log(currentPageReference);
 
         if (currentPageReference) {
           const urlValue = currentPageReference.state.recordId;
           if (urlValue) {
             let str = `${urlValue}`;
             console.log("str");
             console.log(str);
             this.recordId = str;
           }
         }
     }
      connectedCallback(){
          Promise.all([
            loadStyle(this, lwcCSS)
        ]);
        init({
            recordId: this.recordId
        }).then(result => {
           
            if (result != null) {
                this.IsLoading = false;
                this.name = result.name;
                this.Hospital = result.hospital;
                this.Department_Class = result.department_Class;
                this.Service_Contract_Staff = result.service_Contract_Staff;
                this.Department = result.department;
                this.Estimate_Target = result.estimate_Target;
                this.Dealer = result.dealer;
                this.recordtypeId = result.recordtypeId;
                this.accDealerBlacklist = result.accDealerBlacklist;
                //sx 贸易合规 add start
                this.proTradeComplianceStatus = result.proTradeComplianceStatus;
                this.violationName =  result.violationName;
                //sx 贸易合规 add end
                this.invid();
            }
        }).catch(error => {
            console.log(error);
        })
           
    }
    navigateToNewObjectPage() {
        // console.log('RepairApplicantName=='+this.RepairApplicantName);
        // console.log('this.id=='+this.id);
        const defaultFieldValues =encodeDefaultFieldValues({
 
          Name: 'Copy of '+this.name,
          Hospital__c: this.Hospital,
          Department_Class__c: this.Department_Class,
          Service_Contract_Staff__c: this.Service_Contract_Staff,
          Department__c: this.Department,
          Estimate_Target__c:this.Estimate_Target,
          Dealer__c:this.Dealer,
          Last_year_service_contract__c:this.recordId,
          CopyFlg__c : true,
          NotUse_Oxygenated_Water__c : false,
          copyOfMc__c:this.recordId
        });
         console.log('合同名='+this.name);
            this[NavigationMixin.Navigate]({
              type: 'standard__objectPage',
              attributes: {
                objectApiName: 'Maintenance_Contract__c',
                actionName: 'new'
              },
              state: {
                nooverride: '1',
                defaultFieldValues: defaultFieldValues,
                recordTypeId: this.recordtypeId
              }
            });
        this.dispatchEvent(new CloseActionScreenEvent());
      }
      invid() {
            console.log('IFTradeComplianceAlert=='+this.a);
            console.log('TradeComplianceStatusFlagFW=='+this.b);
            console.log('accDealerBlacklist=='+this.accDealerBlacklist);
            if(this.b=='true'){
                var oppflag=false;
                if(this.accDealerBlacklist==1){
                    const evt = new ShowToastEvent({
                        title : '您所选择的医院存在贸易合规风险,无法签订服务合同,建议您向客户做好不签约说明,'+this.a,
                        message: '',
                        variant: 'error',
                         mode: 'sticky'
                    });
                    this.dispatchEvent(evt);
                    this.dispatchEvent(new CloseActionScreenEvent());
                    oppflag=true;
                }else if(this.accDealerBlacklist==2){
                    const evt = new ShowToastEvent({
                        title : '您所选择的医院存在贸易合规风险,无法签订服务合同,建议您向客户做好不签约说明,'+this.a,
                        message: '',
                        variant: 'error',
                         mode: 'sticky'
                    });
                    this.dispatchEvent(evt);
                    this.dispatchEvent(new CloseActionScreenEvent());
                    oppflag=true;
                }else if(this.accDealerBlacklist==12){
                    const evt = new ShowToastEvent({
                        title : '您所选择的医院和经销商存在贸易合规风险,无法签订服务合同,建议您向客户做好不签约说明,'+this.a,
                        message: '',
                        variant: 'error',
                         mode: 'sticky'
                    });
                    this.dispatchEvent(evt);
                    this.dispatchEvent(new CloseActionScreenEvent());
                    oppflag=true;
                }else if(this.accDealerBlacklist==5 || this.accDealerBlacklist==6 || this.accDealerBlacklist==56){
                    console.log('IFTradeComplianceAlert2=='+IFTradeComplianceAlert2);
                    console.log(this.proTradeComplianceStatus);
                    if(this.proTradeComplianceStatus == '0'){
            accSendEmailFW2({
              mcid : this.recordId,
              titles :'【贸易合规】--多年保修合同新建新服务合同涉及警示产品',
              type :'2',
              violationName:this.violationName.slice(0, -1)
          })
          .then(result=>{
              return;
          }).catch(err=>{
              console.log('邮件错误'+err);
          })
                        LightningConfirm.open({
                            //message: '您所选择的医院存在贸易合规警示风险,不建议签订服务合同,请您确认是否继续申请,'+this.a,
                            message: '您此次申请的业务可能存在贸易合规风险,请联系法务本部贸易合规窗口'+IFTradeComplianceAlertName+'进一步评估(一般需5-10个工作日)',
                            variant: 'headerless',
                            label: 'this is the aria-label value',                
                        }).then(cancel=>{
                            if(cancel) {
                                this.navigateToNewObjectPage(); 
                            } else {
                                this.IsLoading=false;
                                this.dispatchEvent(new CloseActionScreenEvent());
                                return;
                            }
                            
                        });
                    }else{
                        this.navigateToNewObjectPage(); 
                    }
                }
                // else if(this.accDealerBlacklist==6){
                //     LightningConfirm.open({
                //         message: '您所选择的经销商存在贸易合规警示风险,不建议签订服务合同,请您确认是否继续申请,'+this.a,
                //         variant: 'headerless',
                //         label: 'this is the aria-label value',
                        
                //     }).then(cancel=>{
                //         if(cancel) {
                //             this.navigateToNewObjectPage(); 
                //         } else {
                //             this.IsLoading=false;
                //             this.dispatchEvent(new CloseActionScreenEvent());
                //             return;
                //         }
                        
                //     });
                // }else if(this.accDealerBlacklist==56){
                //     LightningConfirm.open({
                //         message: '您所选择的医院和经销商存在贸易合规警示风险,不建议签订服务合同,请您确认是否继续申请,'+this.a,
                //         variant: 'headerless',
                //         label: 'this is the aria-label value',
                        
                //     }).then(cancel=>{
                //         if(cancel) {
                //             this.navigateToNewObjectPage(); 
                //         } else {
                //             this.IsLoading=false;
                //             this.dispatchEvent(new CloseActionScreenEvent());
                //             return;
                //         }
                        
                //     });
                // }
                //20231211 贸易合规二期 add start
                // else if(this.hosTradeComplianceStatus == '警示名单' || this.deaTradeComplianceStatus == '警示名单'){
        //             if(result.proTradeComplianceStatus == '0'){
        //                 LightningConfirm.open({
        //                     message: '您所选择的客户/经销商和最新报价里的产品,存在贸易合规警示风险,不建议做授权申请,请您确认是否继续申请,'+IFTradeComplianceAlert2+'(一般需5-10个工作日)。',
        //                     variant: 'headerless',
        //                     label: 'this is the aria-label value',
        //                 }).then(confirm=>{
        //                     if(confirm){
        //                         this.navigateToNewObjectPage();
        //                     }else{
        //                         this.IsLoading=false;
        //                         this.dispatchEvent(new CloseActionScreenEvent());
        //                         return;
        //                     }
        //                 }).catch(err=>{
        //                     console.log('贸易合规2err====='+err.getMessage());
        //                 })
        //             }
        //         }//20231211 贸易合规二期 add end
                else{
                    this.navigateToNewObjectPage(); 
                }
                console.log('oppflag=='+oppflag);
                if(oppflag){
                    var FSEStr1 = new Array();
                    accSendEmailFW({
                        AccDealerBlacklist:this.accDealerBlacklist,
                        accname:this.Hospital,
                        angency:this.Dealer,
                        mcid:this.recordId,
                        sendalert:'Main_Con',
                        FSEStr:FSEStr1
                        })
                    .then(result=>{
                        return;
                    }).catch(err=>{
                        console.log(error);
                    })
                }
            } else {
                this.navigateToNewObjectPage(); 
 
            }
            
 
      }
 
}