From dfff58b7cd897b824a129edba6b5cdae20bb1e5c Mon Sep 17 00:00:00 2001
From: unknown <sunxia@prec-tech.com>
Date: 星期三, 23 八月 2023 17:40:58 +0800
Subject: [PATCH] 发起再注册分析并同步SAP

---
 force-app/main/default/lwc/lexCreateRepairFromQIS/lexCreateRepairFromQIS.js |  181 +++++++++++++++++++++++++++++----------------
 1 files changed, 117 insertions(+), 64 deletions(-)

diff --git a/force-app/main/default/lwc/lexCreateRepairFromQIS/lexCreateRepairFromQIS.js b/force-app/main/default/lwc/lexCreateRepairFromQIS/lexCreateRepairFromQIS.js
index 69ef0be..a290a88 100644
--- a/force-app/main/default/lwc/lexCreateRepairFromQIS/lexCreateRepairFromQIS.js
+++ b/force-app/main/default/lwc/lexCreateRepairFromQIS/lexCreateRepairFromQIS.js
@@ -12,8 +12,17 @@
 import init from '@salesforce/apex/buttonQISReportCtl.init';
 import initUserName from '@salesforce/apex/buttonQISReportCtl.initUserName';
 import selecctAccountByAccountId from '@salesforce/apex/buttonQISReportCtl.selecctAccountByAccountId';
+import {
+    NavigationMixin
+} from 'lightning/navigation';
+import {
+    encodeDefaultFieldValues
+} from 'lightning/pageReferenceUtils';
+import {
+    ShowToastEvent
+} from 'lightning/platformShowToastEvent';
 
-export default class LexCreateRepairFromQIS extends LightningElement {
+export default class LexCreateRepairFromQIS extends NavigationMixin(LightningElement) {
     @api recordId;
     str;
     IsLoading = true;
@@ -55,7 +64,6 @@
         }).then(result => {
             console.log(result);
             if (result != null) {
-                this.IsLoading = false;
                 this.Id = result.Id;
                 this.Name = result.Name;
                 this.SourceOnCallId = result.SourceOnCallId == undefined ? "" : result.SourceOnCallId;
@@ -86,7 +94,6 @@
                     this.CreateRepairFromQIS();
                 })
 
-                this.dispatchEvent(new CloseActionScreenEvent());
             }
         }).catch(error => {
             console.log(error);
@@ -95,7 +102,6 @@
 
     //鏂板缓淇悊QIS	
     CreateRepairFromQIS() {
-        console.log("寮�濮�");
         var newflag = false;
         if ((this.OCMJudgementC == '璐ㄩ噺闂' && this.nextAction == '鏃犲伩缁翠慨' && this.SpecialFollow == '0') || (this.OCMJudgementC == '闈炶川閲忛棶棰�' && this.nextAction == '鏃犲伩缁翠慨' && this.SpecialFollow == '1') || (this.OCMJudgementC == '闈炶川閲忛棶棰�' && this.nextAction == '鏈夊伩缁翠慨' && this.SpecialFollow == '0') || (this.OCMJudgementC == '璐ㄩ噺闂+闈炶川閲忛棶棰�' && this.nextAction == '鏃犲伩缁翠慨' && this.SpecialFollow == '1') || (this.OCMJudgementC == '璐ㄩ噺闂+闈炶川閲忛棶棰�' && this.nextAction == '鏈夊伩缁翠慨+鏃犲伩缁翠慨' && this.SpecialFollow == '0')) {
             newflag = true;
@@ -110,73 +116,120 @@
                 var Incharge_Staff = '';
                 var Incharge_Staff_id = '';
                 var Work_Location = '';
-                if (List[0]['ParentId'] != null) {
-                    RecordTypeId = List[0]['Parent']['RecordType_DeveloperName__c'].substring(0, 15);
-                    console.log(RecordTypeId);
-                    var FSE_GI_Main_Leader__id = '';
-                    var FSE_GI_Main_Leader__name = '';
-                    var FSE_SP_Main_Leader__id = '';
-                    var FSE_SP_Main_Leader__name = '';
-                    if (List[0]['Parent']['Parent']['FSE_GI_Main_Leader__c'] != null) {
-                        FSE_GI_Main_Leader__id = List[0]['Parent']['Parent']['FSE_GI_Main_Leader__c'].substring(0, 15);
-                        FSE_GI_Main_Leader__name = List[0]['Parent']['Parent']['FSE_GI_Main_Leader__r']['Name'];
-                    }
-                    if (List[0]['Parent']['Parent']['FSE_SP_Main_Leader__c'] != null) {
-                        FSE_SP_Main_Leader__id = List[0]['Parent']['Parent']['FSE_SP_Main_Leader__c'].substring(0, 15);
-                        FSE_SP_Main_Leader__name = List[0]['Parent']['Parent']['FSE_SP_Main_Leader__r']['Name'];
-                    }
-                    if (List[0]['Parent']['RecordType_DeveloperName__c'] != null || List[0]['Parent']['RecordType_DeveloperName__c'] != undefined) {
-                        var recordId = List[0]['Parent']['RecordType_DeveloperName__c'].substring(0, 15);
-                        if (recordId == 'Department_Class_GI' || recordId == 'Department_Class_BF' || recordId == 'Department_Class_ET') {
-                            if (List[0]['Parent']['Parent']['FSE_GI_Main_Leader__c'] != null) {
-                                Work_Location = List[0]['Parent']['Parent']['FSE_GI_Main_Leader__r']['Work_Location__c'];
-                            }
-                        } else if (recordId == 'Department_Class_GS' || recordId == 'Department_Class_URO' || recordId == 'Department_Class_ENT' || recordId == 'Department_Class_GYN' || recordId == 'Department_Class_OTH') {
-                            if (List[0]['Parent']['Parent']['FSE_SP_Main_Leader__c'] != null) {
-                                Work_Location = List[0]['Parent']['Parent']['FSE_SP_Main_Leader__r']['Work_Location__c'];
-                            }
-
+                if (List.length > 0) {
+                    if (List[0]['ParentId'] != null) {
+                        RecordTypeId = List[0]['Parent']['RecordType_DeveloperName__c'].substring(0, 15);
+                        console.log(RecordTypeId);
+                        var FSE_GI_Main_Leader__id = '';
+                        var FSE_GI_Main_Leader__name = '';
+                        var FSE_SP_Main_Leader__id = '';
+                        var FSE_SP_Main_Leader__name = '';
+                        if (List[0]['Parent']['Parent']['FSE_GI_Main_Leader__c'] != null) {
+                            FSE_GI_Main_Leader__id = List[0]['Parent']['Parent']['FSE_GI_Main_Leader__c'].substring(0, 15);
+                            FSE_GI_Main_Leader__name = List[0]['Parent']['Parent']['FSE_GI_Main_Leader__r']['Name'];
                         }
-                    }
-                    if (RecordTypeId == 'Department_Class_GI') {
-                        Incharge_Staff = FSE_GI_Main_Leader__name;
-                        Incharge_Staff_id = FSE_GI_Main_Leader__id;
-                    }
-                    if (RecordTypeId == 'Department_Class_BF') {
-                        Incharge_Staff = FSE_GI_Main_Leader__name;
-                        Incharge_Staff_id = FSE_GI_Main_Leader__id;
-                    }
-                    if (RecordTypeId == 'Department_Class_ET') {
-                        Incharge_Staff = FSE_GI_Main_Leader__name;
-                        Incharge_Staff_id = FSE_GI_Main_Leader__id;
-                    }
-                    if (RecordTypeId == 'Department_Class_GS') {
-                        Incharge_Staff = FSE_SP_Main_Leader__name;
-                        Incharge_Staff_id = FSE_SP_Main_Leader__id;
-                    }
-                    if (RecordTypeId == 'Department_Class_URO') {
-                        Incharge_Staff = FSE_SP_Main_Leader__name;
-                        Incharge_Staff_id = FSE_SP_Main_Leader__id;
-                    }
-                    if (RecordTypeId == 'Department_Class_ENT') {
-                        Incharge_Staff = FSE_SP_Main_Leader__name;
-                        Incharge_Staff_id = FSE_SP_Main_Leader__id;
-                    }
-                    if (RecordTypeId == 'Department_Class_GYN') {
-                        Incharge_Staff = FSE_SP_Main_Leader__name;
-                        Incharge_Staff_id = FSE_SP_Main_Leader__id;
-                    }
-                    if (RecordTypeId == 'Department_Class_OTH') {
-                        Incharge_Staff = FSE_SP_Main_Leader__name;
-                        Incharge_Staff_id = FSE_SP_Main_Leader__id;
+                        if (List[0]['Parent']['Parent']['FSE_SP_Main_Leader__c'] != null) {
+                            FSE_SP_Main_Leader__id = List[0]['Parent']['Parent']['FSE_SP_Main_Leader__c'].substring(0, 15);
+                            FSE_SP_Main_Leader__name = List[0]['Parent']['Parent']['FSE_SP_Main_Leader__r']['Name'];
+                        }
+                        if (List[0]['Parent']['RecordType_DeveloperName__c'] != null || List[0]['Parent']['RecordType_DeveloperName__c'] != undefined) {
+                            var recordId = List[0]['Parent']['RecordType_DeveloperName__c'].substring(0, 15);
+                            if (recordId == 'Department_Class_GI' || recordId == 'Department_Class_BF' || recordId == 'Department_Class_ET') {
+                                if (List[0]['Parent']['Parent']['FSE_GI_Main_Leader__c'] != null) {
+                                    Work_Location = List[0]['Parent']['Parent']['FSE_GI_Main_Leader__r']['Work_Location__c'];
+                                }
+                            } else if (recordId == 'Department_Class_GS' || recordId == 'Department_Class_URO' || recordId == 'Department_Class_ENT' || recordId == 'Department_Class_GYN' || recordId == 'Department_Class_OTH') {
+                                if (List[0]['Parent']['Parent']['FSE_SP_Main_Leader__c'] != null) {
+                                    Work_Location = List[0]['Parent']['Parent']['FSE_SP_Main_Leader__r']['Work_Location__c'];
+                                }
+
+                            }
+                        }
+                        if (RecordTypeId == 'Department_Class_GI') {
+                            Incharge_Staff = FSE_GI_Main_Leader__name;
+                            Incharge_Staff_id = FSE_GI_Main_Leader__id;
+                        }
+                        if (RecordTypeId == 'Department_Class_BF') {
+                            Incharge_Staff = FSE_GI_Main_Leader__name;
+                            Incharge_Staff_id = FSE_GI_Main_Leader__id;
+                        }
+                        if (RecordTypeId == 'Department_Class_ET') {
+                            Incharge_Staff = FSE_GI_Main_Leader__name;
+                            Incharge_Staff_id = FSE_GI_Main_Leader__id;
+                        }
+                        if (RecordTypeId == 'Department_Class_GS') {
+                            Incharge_Staff = FSE_SP_Main_Leader__name;
+                            Incharge_Staff_id = FSE_SP_Main_Leader__id;
+                        }
+                        if (RecordTypeId == 'Department_Class_URO') {
+                            Incharge_Staff = FSE_SP_Main_Leader__name;
+                            Incharge_Staff_id = FSE_SP_Main_Leader__id;
+                        }
+                        if (RecordTypeId == 'Department_Class_ENT') {
+                            Incharge_Staff = FSE_SP_Main_Leader__name;
+                            Incharge_Staff_id = FSE_SP_Main_Leader__id;
+                        }
+                        if (RecordTypeId == 'Department_Class_GYN') {
+                            Incharge_Staff = FSE_SP_Main_Leader__name;
+                            Incharge_Staff_id = FSE_SP_Main_Leader__id;
+                        }
+                        if (RecordTypeId == 'Department_Class_OTH') {
+                            Incharge_Staff = FSE_SP_Main_Leader__name;
+                            Incharge_Staff_id = FSE_SP_Main_Leader__id;
+                        }
                     }
                 }
 
-                window.open("/a0J/e?CF00N10000002FIJU_lkid=" + this.SourceOnCallId + "&CF00N10000002FIJU=" + this.SourceOnCall + "&CF00N10000002FIJZ_lkid=" + this.Id + "&CF00N10000002FIJZ=" + this.Name + "&CF00N10000002Dx66_lkid=" + this.HospitalId + "&CF00N10000002Dx66=" + this.Hospital + "&CF00N10000002Dx5t_lkid=" + this.DepartmentClassId + "&CF00N10000002Dx5t=" + this.DepartmentClass + "&CF00N10000002Dx5n_lkid=" + this.HospitalDepartmentId + "&CF00N10000002Dx5n=" + this.HospitalDepartment + "&CF00N10000002Dx1X_lkid=" + this.nonyushohinId + "&CF00N10000002Dx1X=" + this.nonyushohin + "&CF00N10000002EMHw_lkid=" + Incharge_Staff_id + "&CF00N10000002EMHw=" + Incharge_Staff + "&00N10000002Dx5y=" + this.TrableOccurDaYCollect + "&00N10000006P6SM=" + encodeURI(Work_Location) + "&00N10000002FH86=" + this.sourceForRepair + "&00N10000006P6Rn=" + this.RepairSalesPointProvinceChinaC + "&retURL=%2F" + this.Id);
+                const url = encodeDefaultFieldValues({
+                    On_Call_ID__c: this.SourceOnCall,
+                    QIS_ID__c: this.Id,
+                    Hospital__c: this.Hospital,
+                    Department_Class__c: this.DepartmentClass,
+                    Account__c: this.HospitalDepartment,
+                    Delivered_Product__c: this.nonyushohin,
+                    Incharge_Staff__c: Incharge_Staff_id,
+                    Failure_Occurrence_Date__c: this.TrableOccurDaYCollect,
+                    SalesOfficeCode_selection__c: encodeURI(Work_Location),
+                    Repair_Source__c: this.sourceForRepair,
+                    work_location_select__c: this.RepairSalesPointProvinceChinaC
+                });
+                this[NavigationMixin.Navigate]({
+                    type: 'standard__objectPage',
+                    attributes: {
+                        objectApiName: 'Repair__c',
+                        actionName: 'new'
+                    },
+                    state: {
+                        nooverride: '1',
+                        defaultFieldValues: url
+                    }
+                });
+                this.dispatchEvent(new CloseActionScreenEvent());
+
+                // window.open("/a0J/e?CF00N10000002FIJU_lkid=" + this.SourceOnCallId + "&CF00N10000002FIJU=" + this.SourceOnCall + 
+                // "&CF00N10000002FIJZ_lkid=" + this.Id + "&CF00N10000002FIJZ=" + this.Name + 
+                // "&CF00N10000002Dx66_lkid=" + this.HospitalId + "&CF00N10000002Dx66=" + this.Hospital + 
+                // "&CF00N10000002Dx5t_lkid=" + this.DepartmentClassId + "&CF00N10000002Dx5t=" + this.DepartmentClass + 
+                // "&CF00N10000002Dx5n_lkid=" + this.HospitalDepartmentId + "&CF00N10000002Dx5n=" + this.HospitalDepartment + 
+                // "&CF00N10000002Dx1X_lkid=" + this.nonyushohinId + "&CF00N10000002Dx1X=" + this.nonyushohin + 
+                // "&CF00N10000002EMHw_lkid=" + Incharge_Staff_id + "&CF00N10000002EMHw=" + Incharge_Staff + 
+                // "&00N10000002Dx5y=" + this.TrableOccurDaYCollect + "&00N10000006P6SM=" + encodeURI(Work_Location) + 
+                // "&00N10000002FH86=" + this.sourceForRepair + "&00N10000006P6Rn=" + this.RepairSalesPointProvinceChinaC + 
+                // "&retURL=%2F" + this.Id);
 
             })
         } else {
-            alert("涓嶈兘鏂板缓淇悊");
+            this.ShowToastEvent("涓嶈兘鏂板缓淇悊", "error");
+            this.dispatchEvent(new CloseActionScreenEvent());
         }
     }
+
+    ShowToastEvent(msg, type) {
+        const event = new ShowToastEvent({
+            title: '',
+            message: msg,
+            variant: type
+        });
+        this.dispatchEvent(event);
+    }
 }
\ No newline at end of file

--
Gitblit v1.9.1