黄千龙
2023-07-18 428f42fab44b654c69fbc461513203830743d7de
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
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';
 
/*
 * @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 = '';
 
    @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 () {
        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;
            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;
            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);
    
            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,
                                  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: {
                            nooverride: '1',
                            defaultFieldValues: defaultFieldValues
                          }
                        });
            this.dispatchEvent(new CloseActionScreenEvent());
            }else{
                const evt = new ShowToastEvent({
                        title : '',
                        message: '该QIS不能新建修理',
                        variant: 'error'
                    });
                    this.dispatchEvent(evt);
                this.dispatchEvent(new CloseActionScreenEvent());
                return;
            }
        }).catch(error => {
            
            const evt = new ShowToastEvent({
                        title : '',
                        message: '发生错误',
                        variant: 'error'
                    });
                    this.dispatchEvent(evt);
 
            this.dispatchEvent(new CloseActionScreenEvent());
            console.log('error='+error);
            return;
        }).finally(() => {
            
        }); 
    }
}