From 428f42fab44b654c69fbc461513203830743d7de Mon Sep 17 00:00:00 2001
From: 黄千龙 <huangqianlong@prec-tech.com>
Date: 星期二, 18 七月 2023 10:55:50 +0800
Subject: [PATCH] hql20230718更新lightning按钮

---
 force-app/main/default/lwc/lexCreateRepair/lexCreateRepair.js |  247 +++++++++++++++++++++++++++---------------------
 1 files changed, 139 insertions(+), 108 deletions(-)

diff --git a/force-app/main/default/lwc/lexCreateRepair/lexCreateRepair.js b/force-app/main/default/lwc/lexCreateRepair/lexCreateRepair.js
index 8a2f637..750332d 100644
--- a/force-app/main/default/lwc/lexCreateRepair/lexCreateRepair.js
+++ b/force-app/main/default/lwc/lexCreateRepair/lexCreateRepair.js
@@ -1,20 +1,26 @@
 import { LightningElement,wire,track,api} from 'lwc';
 import { CurrentPageReference } from "lightning/navigation";
 import { CloseActionScreenEvent } from 'lightning/actions';
-import { NavigationMixin } from 'lightning/navigation';
 import { ShowToastEvent } from 'lightning/platformShowToastEvent';
+import { NavigationMixin } from 'lightning/navigation';
+import { encodeDefaultFieldValues } from 'lightning/pageReferenceUtils';
 import init  from '@salesforce/apex/QISReportController.initForlexCreateRepairButton';
-import UserInfo_Owner from '@salesforce/apex/TaskFeedbackController.UserInfo_Owner';
-import { updateRecord } from 'lightning/uiRecordApi';
 
-export default class lexCreateRepair extends LightningElement {
-	@api recordId;
-	IsLoading = true;
-	typeflag = false;
-	newflag = false;
-	qisReportId='';
-	name='';
-	qisRecordTypeId='';
+/*
+ * @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='';
@@ -32,11 +38,11 @@
     UseFailProductFinish='';
     failuerSituation='';
     sourceOnCall='';
-    hospitalId='';
-    departmentClassId='';
+    hospitalId1;
+    departmentClassId;
     hospitalDepartment='';
-    nonyushohinId='';
-    ownerId='';
+    nonyushohinId;
+    ownerId;
     faliourdate='';
     sourceforrepair='';
     repairSalesPointProvinceChina='';
@@ -58,8 +64,18 @@
     hospitalDepartmentname = '';
     nonyushohinIdname = '';
     sourceOnCallname = '';
+    oneFSE = '';
+    twoOCSM = '';
+    huxi = '';
+    xiaohua = '';
+    eT = '';
+    puwai = '';
+    miniao = '';
+    fuke = '';
+    erbihou = '';
+    qita = '';
 
-	@wire(CurrentPageReference)
+    @wire(CurrentPageReference)
      getStateParameters(currentPageReference) {
              console.log(111);
              console.log(currentPageReference);
@@ -79,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;
@@ -89,11 +116,11 @@
             this.accParentId = result.accParentId;
             this.comment = result.comment;
             if (result.sourceOnCall!=null) {
-            	this.sourceOnCall = result.sourceOnCall;
-            	this.sourceOnCallname = result.sourceOnCallname;
+                this.sourceOnCall = result.sourceOnCall;
+                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;
@@ -122,108 +149,112 @@
             this.accParentParentFSEGIMainLeaderWorkLocation = result.accParentParentFSEGIMainLeaderWorkLocation;
             this.accParentParentFSESPMainLeader = result.accParentParentFSESPMainLeader;
             this.accParentParentFSESPMainLeaderWorkLocation = result.accParentParentFSESPMainLeaderWorkLocation;
-         	if (this.qisRecordTypeId != '01210000000RLWc' && this.qisRecordTypeId != '01210000000RLWh') {
-         		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.accParentParentFSEGIMainLeader != null) {
-         					this.WorkLocation = this.accParentParentFSEGIMainLeaderWorkLocation;
-         				}
-         			}else if(this.accrecordId == '01210000000Qeze' || this.accrecordId == '01210000000Qezj' || this.accrecordId == '01210000000Qezt'|| this.accrecordId == '01210000000Qezo'|| this.accrecordId == '01210000000Qezy'){
-         				if (this.accParentParentFSESPMainLeader != null) {
-         					this.WorkLocation = this.accParentParentFSESPMainLeaderWorkLocation;
-         				}
-         			}
-         		}
-         	}
-         	if ((this.oCMjudgement == '璐ㄩ噺闂' && this.nextaction == '鏃犲伩缁翠慨') ||
-         		(this.oCMjudgement == '璐ㄩ噺闂' && this.nextaction == '鏈夊伩缁翠慨' && this.specialfollow == '0') || 
-         		(this.oCMjudgement == '闈炶川閲忛棶棰�' && this.nextaction == '鏃犲伩缁翠慨' && this.specialfollow == '1') || 
-         		(this.oCMjudgement == '闈炶川閲忛棶棰�' && this.nextaction == '鏈夊伩缁翠慨' && this.specialfollow == '0') || 
-         		(this.oCMjudgement == '璐ㄩ噺闂+闈炶川閲忛棶棰�' && this.nextaction == '鏃犲伩缁翠慨' && this.specialfollow == '1') || 
-         		(this.oCMjudgement == '璐ㄩ噺闂+闈炶川閲忛棶棰�' && this.nextaction == '鏈夊伩缁翠慨+鏃犲伩缁翠慨' && this.specialfollow == '0') || 
-         		(this.oCMjudgement == '鐜拌薄鏈彂鐜�' && this.nextaction == '鏃犲伩缁翠慨' && this.specialfollow == '1') || 
-         		(this.oCMjudgement == '鐜拌薄鏈彂鐜�' && this.nextaction == '鏈夊伩缁翠慨' && this.specialfollow == '0')) {
-         		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-鐢ㄦ浛浠e搧瀹屾垚浜�'){
-         			this.UseFailProductFinish = '鍚�-鐢ㄦ浛浠e搧瀹屾垚';
-         		}else if(this.isUsedForTheOpera == 'NO-鐢ㄥ叾浠栧叕鍙哥殑鍚岀被浜у搧瀹屾垚浜�'){
-         			this.UseFailProductFinish = '鍚�-鐢ㄥ叾浠栧叕鍙哥殑鍚岀被浜у搧瀹屾垚';
-         		}else if(this.isUsedForTheOpera == 'NO-鎵嬫湳涓'){
-         			this.UseFailProductFinish = '鍚�-鎵嬫湳涓';
-         		}
-         		if ('浣跨敤鍓嶅噯澶�' == this.failuerSituation) {
-         			this.failuerSituation = '浣跨敤鍓嶅噯澶�-鎮h�呮湭楹婚唹';
-         		}
-         		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");
-						this.dispatchEvent(new CloseActionScreenEvent());
-         	}else{
-         		const evt = new ShowToastEvent({
-                        title : '璇IS涓嶈兘鏂板缓淇悊',
-                        message: '',
+            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-鐢ㄦ浛浠e搧瀹屾垚浜�'){
+                    this.UseFailProductFinish = '鍚�-鐢ㄦ浛浠e搧瀹屾垚';
+                }else if(this.isUsedForTheOpera == 'NO-鐢ㄥ叾浠栧叕鍙哥殑鍚岀被浜у搧瀹屾垚浜�'){
+                    this.UseFailProductFinish = '鍚�-鐢ㄥ叾浠栧叕鍙哥殑鍚岀被浜у搧瀹屾垚';
+                }else if(this.isUsedForTheOpera == 'NO-鎵嬫湳涓'){
+                    this.UseFailProductFinish = '鍚�-鎵嬫湳涓';
+                }
+                if ('浣跨敤鍓嶅噯澶�' == this.failuerSituation) {
+                    this.failuerSituation = '浣跨敤鍓嶅噯澶�-鎮h�呮湭楹婚唹';
+                }
+                
+                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: '璇IS涓嶈兘鏂板缓淇悊',
                         variant: 'error'
                     });
                     this.dispatchEvent(evt);
                 this.dispatchEvent(new CloseActionScreenEvent());
-         		return;
-         	}
+                return;
+            }
         }).catch(error => {
             
             const evt = new ShowToastEvent({
-                        title : '鍙戠敓閿欒',
-                        message: '',
+                        title : '',
+                        message: '鍙戠敓閿欒',
                         variant: 'error'
                     });
                     this.dispatchEvent(evt);
 
             this.dispatchEvent(new CloseActionScreenEvent());
             console.log('error='+error);
-         	return;
+            return;
         }).finally(() => {
             
         }); 

--
Gitblit v1.9.1