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/lexCreateRepairFromDepartment/lexCreateRepairFromDepartment.js |   41 ++++++++++++++++++++++++++++++++++++-----
 1 files changed, 36 insertions(+), 5 deletions(-)

diff --git a/force-app/main/default/lwc/lexCreateRepairFromDepartment/lexCreateRepairFromDepartment.js b/force-app/main/default/lwc/lexCreateRepairFromDepartment/lexCreateRepairFromDepartment.js
index 3e6e2aa..a4febf0 100644
--- a/force-app/main/default/lwc/lexCreateRepairFromDepartment/lexCreateRepairFromDepartment.js
+++ b/force-app/main/default/lwc/lexCreateRepairFromDepartment/lexCreateRepairFromDepartment.js
@@ -12,8 +12,14 @@
 import init from '@salesforce/apex/buttonAccountCtl.init';
 import initUserName from '@salesforce/apex/buttonAccountCtl.initUserName';
 import selecctAccountByAccountId from '@salesforce/apex/buttonAccountCtl.selecctAccountByAccountId';
+import {
+    NavigationMixin
+} from 'lightning/navigation';
+import {
+    encodeDefaultFieldValues
+} from 'lightning/pageReferenceUtils';
 
-export default class LexCreateRepairFromDepartment extends LightningElement {
+export default class LexCreateRepairFromDepartment extends NavigationMixin(LightningElement) {
     @api recordId;
     str;
     IsLoading = true;
@@ -43,7 +49,6 @@
         }).then(result => {
             console.log(result);
             if (result != null) {
-                this.IsLoading = false;
                 this.Id = result.Id;
                 this.HospitalC = result.HospitalC == undefined ? "" : result.HospitalC;;
                 this.HospitalId = result.HospitalId == undefined ? "" : result.HospitalId;;
@@ -61,7 +66,6 @@
                     }
                     this.CreateRepairFromDepartment();
                 })
-                this.dispatchEvent(new CloseActionScreenEvent());
             }
         }).catch(error => {
             console.log(error);
@@ -142,8 +146,35 @@
                     Incharge_Staff_id = FSE_SP_Main_Leader__id;
                 }
             }
-            var url = "/a0J/e?CF00N10000002Dx66_lkid=" + this.HospitalId + "&CF00N10000002Dx66=" + this.HospitalC + "&CF00N10000002Dx5t_lkid=" + this.DepartmentClassId + "&CF00N10000002Dx5t=" + this.DepartmentClassC + "&CF00N10000002Dx5n_lkid=" + this.Id + "&CF00N10000002Dx5n=" + this.Name + "&CF00N10000002EMHw_lkid=" + Incharge_Staff_id + "&CF00N10000002EMHw=" + Incharge_Staff + "&00N10000002FH86=%e5%8f%aa%e4%bf%ae%e7%90%86&00N10000006P6Rn=" + this.RepairSalesPointProvinceChinaC + "&00N10000006P6SM=" + encodeURI(Work_Location) + "&retURL=%2F" + this.Id;
-            window.open(url);
+            const url = encodeDefaultFieldValues({
+                Hospital__c: this.HospitalC,
+                Department_Class__c: this.DepartmentClassC,
+                Account__c: this.Id,
+                Incharge_Staff__c: Incharge_Staff_id,
+                SalesOfficeCode_selection__c: encodeURI(Work_Location),
+                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());
+
+            // var url = "/a0J/e?CF00N10000002Dx66_lkid=" + this.HospitalId + "&CF00N10000002Dx66=" + this.HospitalC + 
+            // "&CF00N10000002Dx5t_lkid=" + this.DepartmentClassId + "&CF00N10000002Dx5t=" + this.DepartmentClassC + 
+            // "&CF00N10000002Dx5n_lkid=" + this.Id + "&CF00N10000002Dx5n=" + this.Name + 
+            // "&CF00N10000002EMHw_lkid=" + Incharge_Staff_id + "&CF00N10000002EMHw=" + Incharge_Staff + 
+            // "&00N10000002FH86=%e5%8f%aa%e4%bf%ae%e7%90%86&00N10000006P6Rn=" + this.RepairSalesPointProvinceChinaC + 
+            // "&00N10000006P6SM=" + encodeURI(Work_Location) + "&retURL=%2F" + this.Id;
+            
+            // window.open(url);
         })
     }
 }
\ No newline at end of file

--
Gitblit v1.9.1