liuyn
2024-03-22 e8be4d964c6b336ed39dba5900b1b9a8f3181b96
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
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
import {  LightningElement, wire, api} from 'lwc';
import {  CurrentPageReference} from "lightning/navigation";
import LightningConfirm from 'lightning/confirm';
import { CloseActionScreenEvent} from 'lightning/actions';
import init from '@salesforce/apex/otherButtonMaintenanceContractCtl.init';
// import initCopyData from '@salesforce/apex/otherButtonMaintenanceContractCtl.initCustomNewCopy2';
import { ShowToastEvent} from 'lightning/platformShowToastEvent';
import { NavigationMixin } from 'lightning/navigation';
import { encodeDefaultFieldValues } from 'lightning/pageReferenceUtils';
 
import TradeComplianceStatusFlagFW from '@salesforce/label/c.TradeComplianceStatusFlagFW';
import IFTradeComplianceAlert from '@salesforce/label/c.IFTradeComplianceAlert';
import lwcCSS from '@salesforce/resourceUrl/lwcCSS';
import {loadStyle} from 'lightning/platformResourceLoader';
import IFTradeComplianceAlert2 from '@salesforce/label/c.IFTradeComplianceAlert2'; //sx 贸易合规2期 add
import accSendEmailFW from '@salesforce/apex/OpportunityWebService.accSendEmailFW';
import accSendEmailFW2 from "@salesforce/apex/lexSelectAssetEstimateVMController.accSendEmailFW"; // WYL 贸易合规2期 add
import IFTradeComplianceAlertName from '@salesforce/label/c.IFTradeComplianceAlertName';// WYL 贸易合规2期 add
export default class LexCustomNewCopy2 extends NavigationMixin(LightningElement) {
    @api recordId;
    str;
    IsLoading = true;
    flag;
    Id;
    notRenewC;
    Name;
    accDealerBlacklist;
    Hospital;
    a=IFTradeComplianceAlert;
    b=TradeComplianceStatusFlagFW;
    
    Dealer;
    Department_Class;
    Department;
    Service_Contract_Staff;
    Estimate_Target;
    recordtypeId;
 
 
    Service_contract_target_number;
    PB_Contrant_Cnt;
    PA_Contrant_Cnt;
    Contract_Conclusion_Date;
    Contract_Start_Date;
    Estimate_Trial_Money;
    Contract_End_Date;
    Receipt_Date;
    Recycling_Predetermined_Day;
    Contract_Amount;
    Collect_Date;
    Recoverable_Amount;
    Not_collect_money;
    Sum_repair_price;
    invoice_amount;
    Total_not_collect_amount;
    Description;
    OCM_Print_request;
    HP_Dealer_print;
    Contract_print_completed;
    Submit_contract_to_Financial_dept;
    Received_Date;
    Repair_Cost_Sum;
    Maintenance_Contract_No;
    Last_year_service_contract;
    UserType;
 
    dateF;
 
    //20231120 sx 贸易合规2期 add
    hosTradeComplianceStatus;
    deaTradeComplianceStatus;
    proTradeComplianceStatus;
    violationName;
    @wire(CurrentPageReference)
    getStateParameters(currentPageReference) {
        if (currentPageReference) {
            const urlValue = currentPageReference.state.recordId;
            if (urlValue) {
                let str = `${urlValue}`;
                this.recordId = str;
            }
        }
    }
 
    connectedCallback() {
        Promise.all([
            loadStyle(this, lwcCSS)
        ]);
 
        console.log('测试0');
        init({
            recordId: this.recordId
        }).then(result => {
            
            console.log(result);
            if (result != null) {
                this.IsLoading = false;
                this.Id = result.Id;
                this.notRenewC = result.notRenewC;
                this.Name = result.Name;
                this.Dealer = result.Dealer;
                this.Hospital = result.hospital;
                this.accDealerBlacklist = result.accDealerBlacklist;
                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.EstimateTargetC;
                this.recordtypeId = result.newMcRecordType;
 
                //sx 贸易合规 add start
                this.hosTradeComplianceStatus = result.TradeComplianceStatus__c;
                this.deaTradeComplianceStatus = result.TradeComplianceStatus__c;
                this.proTradeComplianceStatus = result.proTradeComplianceStatus;
                this.violationName = result.violationName;
                //sx 贸易合规 add end
 
                // this.Service_contract_target_number=result.Service_contract_target_number;
                // this.PB_Contrant_Cnt=result.PB_Contrant_Cnt;
                // this.PA_Contrant_Cnt=result.PA_Contrant_Cnt;
                // this.Contract_Conclusion_Date=result.Contract_Conclusion_Date;
                // this.Contract_Start_Date=result.Contract_Start_Date;
                // this.Estimate_Trial_Money=result.Estimate_Trial_Money;
                // this.Contract_End_Date=result.Contract_End_Date;
                // this.Receipt_Date=result.Receipt_Date;
                // this.Recycling_Predetermined_Day=result.Recycling_Predetermined_Day;
                // this.Contract_Amount=result.Contract_Amount;
                // this.Collect_Date=result.Collect_Date;
                // this.Recoverable_Amount=result.Recoverable_Amount;
                // this.Not_collect_money=result.Not_collect_money;
                // this.Sum_repair_price=result.Sum_repair_price;
                // this.invoice_amount=result.invoice_amount;
                // this.Total_not_collect_amount=result.Total_not_collect_amount;
                // this.Description=result.Description;
                // this.OCM_Print_request=result.OCM_Print_request;
                // this.HP_Dealer_print=result.HP_Dealer_print;
                // this.Contract_print_completed=result.Contract_print_completed;
                // this.Submit_contract_to_Financial_dept=result.Submit_contract_to_Financial_dept;
                // this.Received_Date=result.Received_Date;
                // this.Repair_Cost_Sum=result.Repair_Cost_Sum;
                // this.Maintenance_Contract_No=result.Maintenance_Contract_No;
                // this.Last_year_service_contract=result.Last_year_service_contract;
                // this.UserType=result.UserType;
                this.invid();
                // this.CustomNewCopy2();
                // this.dispatchEvent(new CloseActionScreenEvent());
            }
        }).catch(error => {
            console.log(error);
        })
    }
 
    navigateToNewObjectPage() {
 
       /* const defaultFieldValues =encodeDefaultFieldValues({
 
          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,
 
            // Service_contract_target_number__c:this.Service_contract_target_number,
            // PB_Contrant_Cnt__c:this.PB_Contrant_Cnt,
            // PA_Contrant_Cnt__c:this.PA_Contrant_Cnt,
            // Contract_Conclusion_Date__c:this.Contract_Conclusion_Date,
            // Contract_Start_Date__c:this.Contract_Start_Date,
            // Estimate_Trial_Money__c:this.Estimate_Trial_Money,
            // Contract_End_Date__c:this.Contract_End_Date,
            // Receipt_Date__c:this.Receipt_Date,
            // Recycling_Predetermined_Day__c:this.Recycling_Predetermined_Day,
            // Contract_Amount__c:this.Contract_Amount,
            // Collect_Date__c:this.Collect_Date,
            // Recoverable_Amount__c:this.Recoverable_Amount,
            // Not_collect_money__c:this.Not_collect_money,
            // Sum_repair_price__c:this.Sum_repair_price,
            // invoice_amount__c:this.invoice_amount,
            // Total_not_collect_amount__c:this.Total_not_collect_amount,
            // Description__c:this.Description,
            // OCM_Print_request__c:this.OCM_Print_request,
            // HP_Dealer_print__c:this.HP_Dealer_print,
            // Contract_print_completed__c:this.Contract_print_completed,
            // Submit_contract_to_Financial_dept__c:this.Submit_contract_to_Financial_dept,
            // Received_Date__c:this.Received_Date,
            // Repair_Cost_Sum__c:this.Repair_Cost_Sum,
            // Maintenance_Contract_No__c:this.Maintenance_Contract_No,
            // UserType__c:this.UserType,
 
        });*/
        const datas =encodeDefaultFieldValues({
            Name: '',
            CopyFlg__c : true,
            copyOfMc__c:this.recordId,
            Service_contract_target_number__c:'',
            PB_Contrant_Cnt__c:'',
            PA_Contrant_Cnt__c:'',
            Contract_Conclusion_Date__c:'',
            Contract_Start_Date__c:'',
            Estimate_Trial_Money__c:'',
            Contract_End_Date__c:'',
            Receipt_Date__c:'',
            Recycling_Predetermined_Day__c:'',
            Contract_Amount__c:'',
            Collect_Date__c:'',
            Recoverable_Amount__c:'',
            Not_collect_money__c:'',
            Sum_repair_price__c:'',
            invoice_amount__c:'',
            Total_not_collect_amount__c:'',
            Description__c:'',
            OCM_Print_request__c:'',
            HP_Dealer_print__c:'',
            Contract_print_completed__c:'',
            Submit_contract_to_Financial_dept__c:'',
            Received_Date__c:'',
            Repair_Cost_Sum__c:'',
            Maintenance_Contract_No__c:'',
            Last_year_service_contract__c:''
 
        });
        this[NavigationMixin.Navigate]({
                  type: 'standard__objectPage',
                  attributes: {
                      objectApiName: 'Maintenance_Contract__c', // 要新建的对象API
                      actionName: 'clone',
                        recordId: this.recordId
                  },
                  state:{
                      nooverride: '1',
                      defaultFieldValues:datas
                      // +','+defaultFieldValues
                  }
            });
        // initCopyData({
        //     recordId: this.recordId
        // }).then(result => {
        //     console.log('initCopyData:');
        //      console.log(this.dateF+","+result);
        //     this.dateF = result; 
           
 
        // });
 
            
      }
    // 继续新服务合同
    CustomNewCopy2() {
        console.log('测试3=='+this.notRenewC);
        if (this.notRenewC) {
            this.showToast("请联系服务商品部!", "error");
        } else {
            console.log('测试2');
            // 获取协议部分(http、https等)
        const protocol = window.location.protocol;
 
        // 获取主机名部分(域名)
        const hostname = window.location.hostname;
 
        // 获取端口号部分
        const port = window.location.port;
        const urlPrefix = `${protocol}//${hostname}${port ? ':' + port : ''}`;
            // window.open("/" + this.Id + "/e?clone=1&Name=&00N10000002Dx5D=&00N10000002Dx5S=%e5%bc%95%e5%90%88%e4%b8%ad&00NO00000010sDc=&CF00NO00000010hyI=&CF00NO00000010hyI_lkid=&CF00NO00000010hyX=&CF00NO00000010hyX_lkid=&CF00NO00000010hyN=&CF00NO00000010hyN_lkid=&RecordType=01210000000gTYq&00N10000002pmOp=&00N10000006gZDd=&00N10000006gZDe=&00NO00000010hy4=&00N10000002Dx4j=&00N10000002Dx4m=&00N10000002Dx4w=&00N10000002Dx4k=&00N10000002Dx5J=&00N10000002Dx5M=&00N10000002Dx4i=&00N10000002Dx4h=&00N10000002Dx5K=&00N10000003OXdT=&00N100000048zfn=&00N10000002FMsq=&00N10000003OlGF=&00N10000002Dx4r=&00N100000047AY1=&00N100000047AYB=&00N100000047AY6=&00N10000003PCeB=&00N10000005HBNe=&00N10000006plAl=&00N10000002Dx5C=&retURL=%2F{!Maintenance_Contract__c.Id}&saveURL=%2Fapex/SaveMaintenanceByCopy?mid=" + this.Id + "&CF00N100000048Paw=" + this.Name + "&CF00N100000048Paw_lkid=" + this.Id, "_blank");
            // window.open("/" + this.Id + "/e?clone=1&Name=&Management_Code__c=&Status__c=%e5%bc%95%e5%90%88%e4%b8%ad&RecordType=01210000000gTYq&retURL=%2F{!Maintenance_Contract__c.Id}&saveURL=%2Fapex/SaveMaintenanceByCopy?mid=" + this.Id , "_blank");
         var pageurl = '/lightning/cmp/c__LexMaintenanceContractAura?c__isClone=true&c__recordId=' + this.recordId;
 
         console.log('测试3='+urlPrefix+pageurl);
         window.open(urlPrefix+pageurl,'_self');
          
        }
    }
   
    // 弹窗
    showToast(msg, type) {
        if(type == 'success'){
            const event = new ShowToastEvent({
                message: msg,
                variant: type
            });
            this.dispatchEvent(event);
        }else{
            const event = new ShowToastEvent({
                message: msg,
                variant: type,
                mode: 'sticky'
            });
            this.dispatchEvent(event);
        }
    }
 
     invid() {
            console.log('IFTradeComplianceAlert=='+this.a);
            console.log('TradeComplianceStatusFlagFW=='+this.b);
            console.log('accDealerBlacklist=='+this.accDealerBlacklist);
            debugger;
           
            if(this.b=='true'){
                var oppflag=false;
                var oppflag2 = 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;
                    this.flag=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;
                    this.flag=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;
                    this.flag=true;
                }
                // else if(this.accDealerBlacklist==5){
                //     oppflag2 = true;
                //     LightningConfirm.open({
                //         message: '您所选择的医院存在贸易合规警示风险,不建议签订服务合同,请您确认是否继续申请,'+this.a,
                //         variant: 'headerless',
                //         label: 'this is the aria-label value',
                        
                //     }).then(cancel=>{
                //         if(cancel) {
                //             console.log('执行');
                //             // this.navigateToNewObjectPage(); 
                //             this.CustomNewCopy2(); 
 
                //             this.flag=true;
                //         } else {
                //             this.IsLoading=false;
                //             this.dispatchEvent(new CloseActionScreenEvent());
                //             this.flag = false;
                //             return;
                //         }
                        
                //     });
                // }else if(this.accDealerBlacklist==6){
                //     LightningConfirm.open({
                //         message: '您所选择的经销商存在贸易合规警示风险,不建议签订服务合同,请您确认是否继续申请,'+this.a,
                //         variant: 'headerless',
                //         label: 'this is the aria-label value',
                        
                //     }).then(cancel=>{
                //         console.log('6')
                //         if(cancel) {
                //             // this.navigateToNewObjectPage(); 
                //             this.CustomNewCopy2(); 
                //             this.flag=true;
                //         } else {
                //             this.IsLoading=false;
                //             this.dispatchEvent(new CloseActionScreenEvent());
                //             this.flag=false;
                //             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(); 
                //             this.CustomNewCopy2(); 
                //         } else {
                //             this.IsLoading=false;
                //             this.dispatchEvent(new CloseActionScreenEvent());
                //             this.flag=false;
                //             return;
                //         }
                        
                //     });
                // //sx 贸易合规2期 add start
                // }
                 //sx 贸易合规2期 add start
                else if(this.accDealerBlacklist==5 || this.accDealerBlacklist==6 || this.accDealerBlacklist==56 ||this.hosTradeComplianceStatus == '警示名单'  || this.deaTradeComplianceStatus == '警示名单'){
                    if(this.proTradeComplianceStatus == '0'){
                        oppflag2 = true;
                        LightningConfirm.open({
                            message: '您此次申请的业务可能存在贸易合规风险,请联系法务本部贸易合规窗口'+IFTradeComplianceAlertName+'进一步评估(一般需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());
                        })
                    }// WYl 贸易合规2期 update 2024/1/30 start
                    else{
                        this.CustomNewCopy2();
                    }// WYl 贸易合规2期 update 2024/1/30 end
                }
                else{
                    // this.navigateToNewObjectPage(); 
                    this.CustomNewCopy2();
                }
                
                 //sx 贸易合规2期 add end
                console.log('oppflag=='+oppflag);
                console.log('oppflag2=='+oppflag2);
                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);
                    })
                }
                 //wyl 贸易合规2期 add start
                if (oppflag2) {
                    console.info('ID='+this.recordId);
                    accSendEmailFW2({
                        mcid : this.recordId,
                        titles :'【贸易合规】--服务合同继续新服务合同涉及警示产品',
                        type :'2',
                        violationName:this.violationName.slice(0, -1)
                    })
                    .then(result=>{
                        return;
                    }).catch(err=>{
                        console.log(err);
                    })
                }
                //wyl 贸易合规2期 add end
            } 
            else {
                this.CustomNewCopy2();
                // this.navigateToNewObjectPage(); 
 
            }
 
      }
}