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
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
import { LightningElement,wire,track,api} from 'lwc';
import { CurrentPageReference } from "lightning/navigation";
import { CloseActionScreenEvent } from 'lightning/actions';
import { ShowToastEvent } from 'lightning/platformShowToastEvent';
import { NavigationMixin } from 'lightning/navigation';
import { encodeDefaultFieldValues } from 'lightning/pageReferenceUtils';
import init  from '@salesforce/apex/QISReportController.initForlexCreateRepairButton';
import lwcCSS from '@salesforce/resourceUrl/lwcCSS';
import {loadStyle} from 'lightning/platformResourceLoader';
import LightningConfirm from 'lightning/confirm'; // WYL 贸易合规2期
import accSendEmailFW from '@salesforce/apex/buttonAssetCtl.accSendEmailFW'; // WYL 贸易合规2期 add
import IFTradeComplianceAlertName from '@salesforce/label/c.IFTradeComplianceAlertName';// WYL 贸易合规2期 add
/*
 * @Description: 新建修理
 * @Author: hql
 * @Date: 2023-07-12 09:45:19
 * @LastEditTime: 2023-07-12 15:44:33
 * @LastEditors:  
 */
export default class lexCreateRepair extends NavigationMixin(LightningElement) {
    @api recordId;
    IsLoading = true;
    typeflag = false;
    newflag = false;
    qisReportId='';
    name='';
    qisRecordTypeId='';
    err='';
    accParentId='';
    accParentRecordTypeId='';
    accParentParentFSEGIMainLeader='';
    accParentParentFSEGIMainLeaderWorkLocation='';
    accParentParentFSESPMainLeader='';
    accParentParentFSESPMainLeaderWorkLocation='';
    WorkLocation='';
    accrecordId='';
    oCMjudgement='';
    nextaction='';
    specialfollow='';
    comment='';
    isUsedForTheOpera='';
    UseFailProductFinish='';
    failuerSituation='';
    sourceOnCall='';
    hospitalId1;
    departmentClassId;
    hospitalDepartment='';
    nonyushohinId;
    ownerId;
    faliourdate='';
    sourceforrepair='';
    repairSalesPointProvinceChina='';
    trableoccurdaYcollect='';
    damageForDocOrPat='';
    relationWithTheProblem='';
    reportForGoz='';
    whichProject='';
    operaName='';
    breakORFallOff='';
    setusageproduct='';
    afterFailureInformation='';
    delay15Min='';
    informationFrom='';
    failureQInHospital='';
    ownername='';
    hospitalname = '';
    departmentClassname = '';
    hospitalDepartmentname = '';
    nonyushohinIdname = '';
    sourceOnCallname = '';
    oneFSE = '';
    twoOCSM = '';
    huxi = '';
    xiaohua = '';
    eT = '';
    puwai = '';
    miniao = '';
    fuke = '';
    erbihou = '';
    qita = '';
    // WYL 贸易合规2  start
    hosTradeComplianceStatus; 
    ProductCompliance;
    HospitalN;
    Asset_Model_No;
    state;
    OwnerEmail;
    userEmail;
    // WYL 贸易合规2 end
 
    @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 => {
            console.log('init方法返回');
            this.IsLoading = false;
            this.oneFSE = result.oneFSE;
            this.twoOCSM = result.twoOCSM;
            this.qisReportId = result.Id;
            this.huxi = result.huxi;
            this.xiaohua = result.xiaohua;
            this.eT = result.eT;
            this.puwai = result.puwai;
            this.erbihou = result.erbihou;
            this.miniao = result.miniao;
            this.fuke = result.fuke;
            this.qita = result.qita;
            this.oCMjudgement = result.oCMjudgement;
            this.nextaction = result.nextaction;
            this.ownername = result.ownername;
            this.specialfollow = result.specialfollow;
            this.qisRecordTypeId = result.qisRecordTypeId;
            this.accParentId = result.accParentId;
            this.comment = result.comment;
            if (result.sourceOnCall!=null) {
                this.sourceOnCall = result.sourceOnCall;
                this.sourceOnCallname = result.sourceOnCallname;
            }
            this.name = result.name;
            this.hospitalId1 = result.hospitalId;
            this.hospitalname = result.hospitalname;
            this.departmentClassname = result.departmentClassname;
            this.departmentClassId = result.departmentClassId;
            this.hospitalDepartment = result.hospitalDepartment;
            this.nonyushohinId = result.nonyushohinId;
            //2023 08 25 张赫阳 PIPL按钮改造 start
            this.nonyushohinIdname = result.nonyushohinIdname;
            //2023 08 25 张赫阳 PIPL按钮改造 start
            this.ownerId = result.ownerId;
            this.faliourdate = result.faliourdate;
            this.sourceforrepair = result.sourceforrepair;
            this.repairSalesPointProvinceChina = result.repairSalesPointProvinceChina;
            this.trableoccurdaYcollect = result.trableoccurdaYcollect;
            this.damageForDocOrPat = result.damageForDocOrPat;
            this.relationWithTheProblem = result.relationWithTheProblem;
            this.reportForGoz = result.reportForGoz;
            this.whichProject = result.whichProject;
            this.operaName = result.operaName;
            this.breakORFallOff = result.breakORFallOff;
            this.setusageproduct = result.setusageproduct;
            this.afterFailureInformation = result.afterFailureInformation;
            this.delay15Min = result.delay15Min;
            this.informationFrom = result.informationFrom;
            this.failureQInHospital = result.failureQInHospital;
            this.failuerSituation = result.failuerSituation;
            this.isUsedForTheOpera = result.isUsedForTheOpera;
            this.accParentRecordTypeId = result.accParentRecordTypeId;
            this.accParentParentFSEGIMainLeader = result.accParentParentFSEGIMainLeader;
            this.accParentParentFSEGIMainLeaderWorkLocation = result.accParentParentFSEGIMainLeaderWorkLocation;
            this.accParentParentFSESPMainLeader = result.accParentParentFSESPMainLeader;
            this.accParentParentFSESPMainLeaderWorkLocation = result.accParentParentFSESPMainLeaderWorkLocation;
            this.hosTradeComplianceStatus = result.hosTradeComplianceStatus; // WYL 贸易合规2 
            this.ProductCompliance = result.ProductCompliance; // WYL 贸易合规2 
            this.state = result.state;// WYL 贸易合规2 
            this.Asset_Model_No = result.Asset_Model_No;// WYL 贸易合规2 
            this.HospitalN = result.HospitalN;// WYL 贸易合规2 
            this.OwnerEmail = result.OwnerEmail;// WYL 贸易合规2 
            this.userEmail = result.userEmail;// WYL 贸易合规2期 add
            console.info('state='+this.state+'===>Asset_Model_No='+this.Asset_Model_No);
            if (this.qisRecordTypeId != this.oneFSE && this.qisRecordTypeId != this.twoOCSM) {
                this.typeflag = true;
            }
            if (this.accParentId != null) {
                if (this.accParentRecordTypeId != null) {
                    this.accrecordId = this.accParentRecordTypeId.substring(0,15);
                    if (this.accrecordId == this.huxi || this.accrecordId == this.xiaohua || this.accrecordId == this.eT) {
                        if (this.accParentParentFSEGIMainLeader != null) {
                            this.WorkLocation = this.accParentParentFSEGIMainLeaderWorkLocation;
                        }
                    }else if(this.accrecordId == this.erbihou || this.accrecordId == this.qita || this.accrecordId == this.fuke|| this.accrecordId == this.puwai || this.accrecordId == this.miniao){
                        if (this.accParentParentFSESPMainLeader != null) {
                            this.WorkLocation = this.accParentParentFSESPMainLeaderWorkLocation;
                        }
                    }
                }
            }
            if ((this.oCMjudgement == '质量问题' && this.nextaction == '无偿维修') ||
                (this.oCMjudgement == '质量问题' && this.nextaction == '有偿维修' && this.specialfollow == false) || 
                (this.oCMjudgement == '非质量问题' && this.nextaction == '无偿维修' && this.specialfollow == true) || 
                (this.oCMjudgement == '非质量问题' && this.nextaction == '有偿维修' && this.specialfollow == false) || 
                (this.oCMjudgement == '质量问题+非质量问题' && this.nextaction == '无偿维修' && this.specialfollow == true) || 
                (this.oCMjudgement == '质量问题+非质量问题' && this.nextaction == '有偿维修+无偿维修' && this.specialfollow == false) || 
                (this.oCMjudgement == '现象未发现' && this.nextaction == '无偿维修' && this.specialfollow == true) || 
                (this.oCMjudgement == '现象未发现' && this.nextaction == '有偿维修' && this.specialfollow == false)) {
                this.newflag = true;
            }
            console.log('this.newflag = '+this.newflag);
            console.log('this.typeflag = '+this.typeflag);
            console.log("this.hosTradeComplianceStatus"+ this.hosTradeComplianceStatus);
            // WYL 贸易合规2期 start
            if (this.hosTradeComplianceStatus =='黑名单') {
                const evt = new ShowToastEvent({
                    title : '',
                    message: '黑名单:存在贸易合规风险,无法新建,有问题请联系法务部贸易合规窗口'+IFTradeComplianceAlertName+'。',
                    variant: 'error',
                     mode: 'sticky'
                });
                console.info('发送邮件');
                accSendEmailFW({
                    accname:this.HospitalN,
                    mcid:this.recordId,
                    type:'1',
                    FseEmail : this.OwnerEmail,
                    state:this.state
                    })
                .then(result=>{
                    return;
                }).catch(err=>{
                    console.log('邮件错误'+error);
                })
                this.dispatchEvent(evt);
                this.dispatchEvent(new CloseActionScreenEvent());
                return;
            }else if (this.hosTradeComplianceStatus =='冻结,人工审批中') {
                const evt = new ShowToastEvent({
                    title : '',
                    message: '冻结清单:可能存在贸易合规风险,目前正在评估中(一般需5-10个工作日),暂时无法新建,有问题请联系法务部贸易合规窗口'+IFTradeComplianceAlertName+'。',
                    variant: 'error',
                     mode: 'sticky'
                });
                this.dispatchEvent(evt);
                this.dispatchEvent(new CloseActionScreenEvent());
                return;
            } else if (this.hosTradeComplianceStatus =='警示名单' && this.ProductCompliance == '0') {
                LightningConfirm.open({
                    message: '您此次申请的业务可能存在贸易合规风险,请联系法务本部贸易合规窗口'+IFTradeComplianceAlertName+'进一步评估(一般需5-10个工作日),请确定是否继续进行下面操作',
                    variant: 'headerless',
                    label: 'this is the aria-label value',
                    }).then(res=>{
                        if(res) {
                                if ( this.newflag && this.typeflag) {
                                    if (this.isUsedForTheOpera == 'YES') {
                                        this.UseFailProductFinish = '是';
                                    }else if(this.isUsedForTheOpera == 'NO-用替代品完成了'){
                                        this.UseFailProductFinish = '否-用替代品完成';
                                    }else if(this.isUsedForTheOpera == 'NO-用其他公司的同类产品完成了'){
                                        this.UseFailProductFinish = '否-用其他公司的同类产品完成';
                                    }else if(this.isUsedForTheOpera == 'NO-手术中止'){
                                        this.UseFailProductFinish = '否-手术中止';
                                    }
                                    if ('使用前准备' == this.failuerSituation) {
                                        this.failuerSituation = '使用前准备-患者未麻醉';
                                    }
                                    
                                    const defaultFieldValues =encodeDefaultFieldValues({
                                                      On_Call_ID__c: this.sourceOnCall,
                                                      QIS_ID__c: this.qisReportId,
                                                      Hospital__c: this.hospitalId1,
                                                      Department_Class__c: this.departmentClassId,
                                                      Account__c:this.hospitalDepartment,
                                                      Delivered_Product__c:this.nonyushohinId,
                                                      //2023 08 25 张赫阳 PIPL按钮改造 start
                                                      AssetName:this.nonyushohinIdname,
                                                      //2023 08 25 张赫阳 PIPL按钮改造 start
                                                      Incharge_Staff__c:this.ownerId,
                                                      Failure_Occurrence_Date__c:this.faliourdate,
                                                      Repair_Detail__c:this.comment,
                                                      Repair_Source__c:this.sourceforrepair,
                                                      DateReceiptQuestions__c:this.trableoccurdaYcollect,
                                                      ifDeadHurt__c:this.damageForDocOrPat,
                                                      ProductFailureRelated__c:this.relationWithTheProblem,
                                                      ReportAdverseEvents__c:this.reportForGoz,
                                                      WhatProject__c:this.whichProject,
                                                      OperationOrExaminationName__c:this.operaName,
                                                      BreakORFallOff__c:this.breakORFallOff,
                                                      SupportingProducts__c:this.setusageproduct,
                                                      Delay15Min__c:this.delay15Min,
                                                      AfterFailureInformation__c:this.afterFailureInformation,
                                                      InformationFrom__c:this.informationFrom,
                                                      FailureQInHospital__c:this.failureQInHospital,
                                                      ProblemOccurred__c:this.failuerSituation,
                                                      UseFailProductFinish__c:this.UseFailProductFinish,
                                                      SalesOfficeCode_selection__c:this.WorkLocation
                                                    });
                    
                                            this[NavigationMixin.Navigate]({
                                              type: 'standard__objectPage',
                                              attributes: {
                                                objectApiName: 'Repair__c',
                                                actionName: 'new'
                                              },
                                              state: {
                                                //update by 王雪琴 2023/08/09 Start
                                                // nooverride: '1',
                                                //update by 王雪琴 2023/08/09 End
                                                defaultFieldValues: defaultFieldValues
                                              }
                                            });
                                this.dispatchEvent(new CloseActionScreenEvent());
                            }else{
                                const evt = new ShowToastEvent({
                                        title : '',
                                        message: '该QIS不能新建修理',
                                        variant: 'error',
                                         mode: 'sticky'
                                    });
                                    this.dispatchEvent(evt);
                                this.dispatchEvent(new CloseActionScreenEvent());
                                return;
                            }
                        }else{
                            this.dispatchEvent(new CloseActionScreenEvent());
                            return;
                        }                 
                    });
                    console.info('发送邮件');
                    accSendEmailFW({
                        accname:this.HospitalN,
                        mcid:this.recordId,
                        type:'7',
                        state:this.state,
                        useremail : this.userEmail,
                        Asset_Model_No:this.Asset_Model_No
                        })
                    .then(result=>{
                        return;
                    }).catch(err=>{
                        console.log('邮件错误'+error);
                    })
        // WYL 贸易合规2期 end
            }// WYL 贸易合规2期 end
            else if ( this.newflag && this.typeflag) {
                if (this.isUsedForTheOpera == 'YES') {
                    this.UseFailProductFinish = '是';
                }else if(this.isUsedForTheOpera == 'NO-用替代品完成了'){
                    this.UseFailProductFinish = '否-用替代品完成';
                }else if(this.isUsedForTheOpera == 'NO-用其他公司的同类产品完成了'){
                    this.UseFailProductFinish = '否-用其他公司的同类产品完成';
                }else if(this.isUsedForTheOpera == 'NO-手术中止'){
                    this.UseFailProductFinish = '否-手术中止';
                }
                if ('使用前准备' == this.failuerSituation) {
                    this.failuerSituation = '使用前准备-患者未麻醉';
                }
                
                const defaultFieldValues =encodeDefaultFieldValues({
                                  On_Call_ID__c: this.sourceOnCall,
                                  QIS_ID__c: this.qisReportId,
                                  Hospital__c: this.hospitalId1,
                                  Department_Class__c: this.departmentClassId,
                                  Account__c:this.hospitalDepartment,
                                  Delivered_Product__c:this.nonyushohinId,
                                  //2023 08 25 张赫阳 PIPL按钮改造 start
                                  AssetName:this.nonyushohinIdname,
                                  //2023 08 25 张赫阳 PIPL按钮改造 start
                                  Incharge_Staff__c:this.ownerId,
                                  Failure_Occurrence_Date__c:this.faliourdate,
                                  Repair_Detail__c:this.comment,
                                  Repair_Source__c:this.sourceforrepair,
                                  DateReceiptQuestions__c:this.trableoccurdaYcollect,
                                  ifDeadHurt__c:this.damageForDocOrPat,
                                  ProductFailureRelated__c:this.relationWithTheProblem,
                                  ReportAdverseEvents__c:this.reportForGoz,
                                  WhatProject__c:this.whichProject,
                                  OperationOrExaminationName__c:this.operaName,
                                  BreakORFallOff__c:this.breakORFallOff,
                                  SupportingProducts__c:this.setusageproduct,
                                  Delay15Min__c:this.delay15Min,
                                  AfterFailureInformation__c:this.afterFailureInformation,
                                  InformationFrom__c:this.informationFrom,
                                  FailureQInHospital__c:this.failureQInHospital,
                                  ProblemOccurred__c:this.failuerSituation,
                                  UseFailProductFinish__c:this.UseFailProductFinish,
                                  SalesOfficeCode_selection__c:this.WorkLocation
                                });
 
                        this[NavigationMixin.Navigate]({
                          type: 'standard__objectPage',
                          attributes: {
                            objectApiName: 'Repair__c',
                            actionName: 'new'
                          },
                          state: {
                            //update by 王雪琴 2023/08/09 Start
                            // nooverride: '1',
                            //update by 王雪琴 2023/08/09 End
                            defaultFieldValues: defaultFieldValues
                          }
                        });
            this.dispatchEvent(new CloseActionScreenEvent());
            }else{
                const evt = new ShowToastEvent({
                        title : '',
                        message: '该QIS不能新建修理',
                        variant: 'error',
                         mode: 'sticky'
                    });
                    this.dispatchEvent(evt);
                this.dispatchEvent(new CloseActionScreenEvent());
                return;
            }
        }).catch(error => {
            
            const evt = new ShowToastEvent({
                        title : '',
                        message: '发生错误',
                        variant: 'error',
                         mode: 'sticky'
                    });
                    this.dispatchEvent(evt);
 
            this.dispatchEvent(new CloseActionScreenEvent());
            console.log('error='+error);
            return;
        }).finally(() => {
            
        }); 
    }
}