From 50ce6a5e5ae7ac6ce3e6281acca9a0db568306e6 Mon Sep 17 00:00:00 2001
From: unknown <sunxia@prec-tech.com>
Date: 星期三, 23 八月 2023 14:54:59 +0800
Subject: [PATCH] Merge branch 'LEX_dev' of http://47.92.229.245:8089/r/lightningupdate into LEX_dev

---
 force-app/main/default/lwc/lexCreateNewServiceContract/lexCreateNewServiceContract.js |   44 ++++++++++++++++++++++++++++++--------------
 1 files changed, 30 insertions(+), 14 deletions(-)

diff --git a/force-app/main/default/lwc/lexCreateNewServiceContract/lexCreateNewServiceContract.js b/force-app/main/default/lwc/lexCreateNewServiceContract/lexCreateNewServiceContract.js
index 0f54a7c..e49d936 100644
--- a/force-app/main/default/lwc/lexCreateNewServiceContract/lexCreateNewServiceContract.js
+++ b/force-app/main/default/lwc/lexCreateNewServiceContract/lexCreateNewServiceContract.js
@@ -10,8 +10,14 @@
     CloseActionScreenEvent
 } from 'lightning/actions';
 import init from '@salesforce/apex/buttonAccountCtl.init';
+import {
+    NavigationMixin
+} from 'lightning/navigation';
+import {
+    encodeDefaultFieldValues
+} from 'lightning/pageReferenceUtils';
 
-export default class LexCreateNewServiceContract extends LightningElement {
+export default class LexCreateNewServiceContract extends NavigationMixin(LightningElement) {
     @api recordId;
     str;
     IsLoading = true;
@@ -57,21 +63,31 @@
 
     // 鏂板缓鏂版湇鍔″悎鍚�	
     CreateNewServiceContract() {
-        var Hospital = this.HospitalC;
-        var Hospitalid = this.HospitalIdC;
-        var Department = this.DepartmentClassC;
-        var Departmentid = this.DepartmentClassIdC;
-        var accountname = this.Name;
-        var accountid = this.Id;
+        const url = encodeDefaultFieldValues({
+            Hospital__c: this.HospitalC,
+            Department_Class__c: this.DepartmentClassC,
+            Department__c: this.Id
+        });
+        this[NavigationMixin.Navigate]({
+            type: 'standard__objectPage',
+            attributes: {
+                objectApiName: 'Maintenance_Contract__c',
+                actionName: 'new'
+            },
+            state: {
+                nooverride: '1',
+                defaultFieldValues: url
+            }
+        });
+        this.dispatchEvent(new CloseActionScreenEvent());
 
+        // var url = 'a0H/e?CF00N10000002Dx56=' + Hospital + '&CF00N10000002Dx56_lkid=' +
+        //     Hospitalid + '&CF00N10000002Dx4p=' + Department + '&CF00N10000002Dx4p_lkid=' +
+        //     Departmentid + '&CF00N10000002Dx4q=' + accountname + '&CF00N10000002Dx4q_lkid=' +
+        //     accountid + '&RecordType=01210000000gTYq';
 
-        var url = 'a0H/e?CF00N10000002Dx56=' + Hospital + '&CF00N10000002Dx56_lkid=' +
-            Hospitalid + '&CF00N10000002Dx4p=' + Department + '&CF00N10000002Dx4p_lkid=' +
-            Departmentid + '&CF00N10000002Dx4q=' + accountname + '&CF00N10000002Dx4q_lkid=' +
-            accountid + '&RecordType=01210000000gTYq';
+        //     console.log(url);
 
-            console.log(url);
-
-        window.top.location.href = url;
+        // window.top.location.href = url;
     }
 }
\ No newline at end of file

--
Gitblit v1.9.1