From af7f2ebba1ca53c05ad1c47361c889afd53a9765 Mon Sep 17 00:00:00 2001
From: zhangqian <zhangqian@prec-tech.com>
Date: 星期四, 10 八月 2023 17:26:26 +0800
Subject: [PATCH] 耗材备品

---
 force-app/main/default/lwc/lexTenderingIntentionButton/lexTenderingIntentionButton.js |   71 ++++++++++++++---------------------
 1 files changed, 28 insertions(+), 43 deletions(-)

diff --git a/force-app/main/default/lwc/lexTenderingIntentionButton/lexTenderingIntentionButton.js b/force-app/main/default/lwc/lexTenderingIntentionButton/lexTenderingIntentionButton.js
index 49140bd..a10ac7e 100644
--- a/force-app/main/default/lwc/lexTenderingIntentionButton/lexTenderingIntentionButton.js
+++ b/force-app/main/default/lwc/lexTenderingIntentionButton/lexTenderingIntentionButton.js
@@ -1,15 +1,13 @@
 import { LightningElement,wire,track,api} from 'lwc';
-import { CurrentPageReference } from "lightning/navigation";
+import { CurrentPageReference ,NavigationMixin} from "lightning/navigation";
 import { CloseActionScreenEvent } from 'lightning/actions';
-import { NavigationMixin } from 'lightning/navigation';
 import  init  from '@salesforce/apex/TenderingButtonController.initTenderingController';
-import { updateRecord } from 'lightning/uiRecordApi';
 import { ShowToastEvent } from 'lightning/platformShowToastEvent';
-export default class lexTenderingIntentionButton extends LightningElement {
+import { encodeDefaultFieldValues } from 'lightning/pageReferenceUtils';
+export default class lexTenderingIntentionButton extends NavigationMixin(LightningElement) {
     @api recordId;//褰撳墠杩欐潯鏁版嵁鐨刬d
     id;//杩斿洖鍊肩殑id  Tender_information__c鎷涙爣椤圭洰鐨刬d
     IsLoading = true;
-
     @wire(CurrentPageReference)
      getStateParameters(currentPageReference) {
          if (currentPageReference) {
@@ -21,55 +19,42 @@
            }
          }
      }
-    
-
+    //鎷涙爣椤圭洰鏂板缓鎰忓悜
     connectedCallback(){
         init({
             recordId: this.recordId
         }).then(result => {
-            if (result != null) {
                 this.IsLoading = false;
                 this.id = result.Id;
-                this.IntentionButton();
-                this.dispatchEvent(new CloseActionScreenEvent());
-            }
-        }).catch(error => {
-            console.log("error"+error);
-        }).finally(() => {
-            
-        });        
+                // alert('濉啓澶卞崟鎶ュ憡璇风洿鎺ョ偣鍑绘嫑鏍囬〉闈€�愬け鍗曘�戞寜閽�');
+                this.showToast('濉啓澶卞崟鎶ュ憡璇风洿鎺ョ偣鍑绘嫑鏍囬〉闈€�愬け鍗曘�戞寜閽�','success');
+                // var url = '/apex/NewAndEditLead?' + '00N10000009HKS5=' + this.id
+                // + '&LeadSource=鎷涙爣缃�' + '&RecordTypeId=01210000000QiRf' + '&retURL=%2F' + this.id ;
+                // window.open(url);
+                const defaultValues = encodeDefaultFieldValues({
+                    Tender_information__c :this.id,
+                    LeadSource:'鎷涙爣缃�',
+                    RecordTypeId:result.NewDaily_Report,
+
+                });
+                this[NavigationMixin.Navigate]({
+                    type: 'standard__objectPage',
+                    attributes: {
+                        objectApiName: 'Lead',
+                        actionName: 'new'
+                    },
+                    state:{
+                        defaultFieldValues: defaultValues
+                    }
+                }); 
+            this.dispatchEvent(new CloseActionScreenEvent());               
+        })       
     }
-
-    //鎷涙爣椤圭洰鏂板缓鎰忓悜
-    IntentionButton(){
-            // alert('濉啓澶卞崟鎶ュ憡璇风洿鎺ョ偣鍑绘嫑鏍囬〉闈€�愬け鍗曘�戞寜閽�');
-            this.showToast('濉啓澶卞崟鎶ュ憡璇风洿鎺ョ偣鍑绘嫑鏍囬〉闈€�愬け鍗曘�戞寜閽�','success');
-            var url = '/apex/NewAndEditLead?' + '00N10000009HKS5=' + this.id
-            + '&LeadSource=鎷涙爣缃�' + '&RecordTypeId=01210000000QiRf' + '&retURL=%2F' + this.id ;
-            window.open(url);
-    }
-
-
-    updateRecordView() {
-        updateRecord({fields: { Id: this.recordId }});
-    }
-
     showToast(msg,type) {
-        console.log(msg,type);
         const event = new ShowToastEvent({
-            // title: title,
             message: msg,
             variant: type
         });
         this.dispatchEvent(event);
     }
-}
-
-
-// var foo = function(){
-//     alert('濉啓澶卞崟鎶ュ憡璇风洿鎺ョ偣鍑绘嫑鏍囬〉闈€�愬け鍗曘�戞寜閽�');
-//     var url = '/apex/NewAndEditLead?' + '00N10000009HKS5=' + '{!Tender_information__c.Id}'
-//     + '&LeadSource=鎷涙爣缃�' + '&RecordTypeId=01210000000QiRf' + '&retURL=%2F' + '{!Tender_information__c.Id}' ;
-//     window.open(url);
-//     }
-//     foo();
\ No newline at end of file
+}
\ No newline at end of file

--
Gitblit v1.9.1