黄千龙
2023-07-18 428f42fab44b654c69fbc461513203830743d7de
force-app/main/default/lwc/lexCreateRepair/lexCreateRepair.js
@@ -2,9 +2,18 @@
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';
export default class lexCreateRepair extends LightningElement {
/*
 * @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;
@@ -29,11 +38,11 @@
    UseFailProductFinish='';
    failuerSituation='';
    sourceOnCall='';
    hospitalId='';
    departmentClassId='';
    hospitalId1;
    departmentClassId;
    hospitalDepartment='';
    nonyushohinId='';
    ownerId='';
    nonyushohinId;
    ownerId;
    faliourdate='';
    sourceforrepair='';
    repairSalesPointProvinceChina='';
@@ -55,6 +64,16 @@
    hospitalDepartmentname = '';
    nonyushohinIdname = '';
    sourceOnCallname = '';
    oneFSE = '';
    twoOCSM = '';
    huxi = '';
    xiaohua = '';
    eT = '';
    puwai = '';
    miniao = '';
    fuke = '';
    erbihou = '';
    qita = '';
   @wire(CurrentPageReference)
     getStateParameters(currentPageReference) {
@@ -76,8 +95,19 @@
        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;
@@ -90,7 +120,7 @@
               this.sourceOnCallname = result.sourceOnCallname;
            }
            this.name = result.name;
            this.hospitalId = result.hospitalId;
            this.hospitalId1 = result.hospitalId;
            this.hospitalname = result.hospitalname;
            this.departmentClassname = result.departmentClassname;
            this.departmentClassId = result.departmentClassId;
@@ -119,17 +149,17 @@
            this.accParentParentFSEGIMainLeaderWorkLocation = result.accParentParentFSEGIMainLeaderWorkLocation;
            this.accParentParentFSESPMainLeader = result.accParentParentFSESPMainLeader;
            this.accParentParentFSESPMainLeaderWorkLocation = result.accParentParentFSESPMainLeaderWorkLocation;
            if (this.qisRecordTypeId != '01210000000RLWc' && this.qisRecordTypeId != '01210000000RLWh') {
            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 == '01210000000QemL' || this.accrecordId == '01210000000QezZ' || this.accrecordId == '01210000000QemQ') {
                    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 == '01210000000Qeze' || this.accrecordId == '01210000000Qezj' || this.accrecordId == '01210000000Qezt'|| this.accrecordId == '01210000000Qezo'|| this.accrecordId == '01210000000Qezy'){
                    }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;
                     }
@@ -162,48 +192,51 @@
               if ('使用前准备' == this.failuerSituation) {
                  this.failuerSituation = '使用前准备-患者未麻醉';
               }
               var url = '';
                  url = "/a0J/e?" +
                  "CF00N10000002FIJU_lkid="+this.sourceOnCall+"&" +
                  "CF00N10000002FIJU="+this.sourceOnCallname+"&" +
                  "CF00N10000002FIJZ_lkid="+this.qisReportId+"&" +
                  "CF00N10000002FIJZ="+this.name+"&" +
                  "CF00N10000002Dx66_lkid="+this.hospitalId+"&" +
                  "CF00N10000002Dx66="+this.hospitalname+"&" +
                  "CF00N10000002Dx5t_lkid="+this.departmentClassId+"&" +
                  "CF00N10000002Dx5t="+this.departmentClassname+"&" +
                  "CF00N10000002Dx5n_lkid="+this.hospitalDepartment+"&" +
                  "CF00N10000002Dx5n="+this.hospitalDepartmentname+"&" +
                  "CF00N10000002Dx1X_lkid="+this.nonyushohinId+"&" +
                  "CF00N10000002Dx1X="+this.nonyushohinIdname+"&" +
                  "CF00N10000002EMHw_lkid="+this.ownerId+"&" +
                  "CF00N10000002EMHw="+this.ownername+"&" +
                  "00N10000002Dx5y="+this.faliourdate+"&" +
                  "00N10000002Dx6I="+this.comment+"&" +
                  "00N10000002FH86="+this.sourceforrepair+"&" +
                  "00N10000006P6Rn="+this.repairSalesPointProvinceChina+"&" +
                  "00N10000008rsVQ="+this.trableoccurdaYcollect+"&" +
                  "00N10000008rsW7="+this.damageForDocOrPat+"&"+
                  "00N10000008rsVw="+this.relationWithTheProblem+"&"+
                  "00N10000008rsW2="+this.reportForGoz+"&"+
                  "00N10000008rsW6="+this.whichProject+"&"+
                  "00N10000008rsVk="+this.operaName+"&" +
                  "00N10000008rsVN="+this.breakORFallOff+"&"+
                  "00N10000008rsW4="+this.setusageproduct+"&" +
                  "00N10000008rsVL="+this.afterFailureInformation+"&" +
                  "00N10000008rsVR="+this.delay15Min+"&"+
                  "00N10000008rsVZ="+this.informationFrom+"&"+
                  "00N10000008rsVT="+this.failureQInHospital+"&" +
                  "00N10000008rsVv="+this.failuerSituation+"&"+
                  "00N10000008rsW5="+this.UseFailProductFinish+ "&" +
                  "00N10000006P6SM="+this.WorkLocation+ "&" +
                  "retURL=%2F"+this.qisReportId;
                  window.open(url, "_blank");
                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 : '该QIS不能新建修理',
                        message: '',
                        title : '',
                        message: '该QIS不能新建修理',
                        variant: 'error'
                    });
                    this.dispatchEvent(evt);
@@ -213,8 +246,8 @@
        }).catch(error => {
            
            const evt = new ShowToastEvent({
                        title : '发生错误',
                        message: '',
                        title : '',
                        message: '发生错误',
                        variant: 'error'
                    });
                    this.dispatchEvent(evt);