From 4661adc43f549036f4e6e44debe92521c5793083 Mon Sep 17 00:00:00 2001
From: 19626 <1962676589@qq.com>
Date: 星期二, 06 六月 2023 11:06:36 +0800
Subject: [PATCH] 修改页面以及按钮

---
 force-app/main/default/lwc/lexNewOpportunityAgency/lexNewOpportunityAgency.js |   81 +++++++++++++++++++++++++++-------------
 1 files changed, 54 insertions(+), 27 deletions(-)

diff --git a/force-app/main/default/lwc/lexNewOpportunityAgency/lexNewOpportunityAgency.js b/force-app/main/default/lwc/lexNewOpportunityAgency/lexNewOpportunityAgency.js
index c5dbd36..f038f63 100644
--- a/force-app/main/default/lwc/lexNewOpportunityAgency/lexNewOpportunityAgency.js
+++ b/force-app/main/default/lwc/lexNewOpportunityAgency/lexNewOpportunityAgency.js
@@ -7,7 +7,9 @@
 import queryForRecords from '@salesforce/apex/OpportunityLightingButtonController.queryForNewOpportunityAgencyButtonToRecords';
 import queryForRecTypeList from '@salesforce/apex/OpportunityLightingButtonController.queryForNewOpportunityAgencyButtonToRecTypeList';
 import queryForRecords2 from '@salesforce/apex/OpportunityLightingButtonController.queryForNewOpportunityAgencyButtonToRecords2';
-export default class LexNewOpportunityAgency extends LightningElement {
+import { NavigationMixin } from 'lightning/navigation';
+import { encodeDefaultFieldValues } from 'lightning/pageReferenceUtils';
+export default class LexNewOpportunityAgency extends NavigationMixin(LightningElement) {
     @api recordId;
     agency1Id;
     agencyOpportunity;
@@ -178,32 +180,57 @@
                                         var ahl = records[0];
                                         
                                         try {
-                                            var url = "/a2Y/e?retURL=%2F" 
-                                            + this.recordId 
-                                            + "&Name='(OLYMPUS)'"  
-                                            + encodeURIComponent(this.name)
-                                            + "&RecordType=" + recTypeId  + "&" + fId_Close_Forecasted_Date__c + "=" 
-                                            + encodeURIComponent(this.closeForecastedDate)
-                                            + "&" + fId_Bid_Planned_Date__c + "=" 
-                                            + encodeURIComponent(this.bidPlannedDate)
-                                            + "&" + fId_OCM_Change_To_Opportunity_Flg__c + "=1" + "&CF" + fId_Agency_Hospital__c + "_lkid=" + ahl.Id + "&CF" + fId_Agency_Hospital__c + "=" + encodeURIComponent(ahl.Name) + "&" + fId_Amount__c + "=" 
-                                            + encodeURIComponent(this.dealerFinalPrice)
-                                            + "&" + fId_OCMSale_Price__c + "=" 
-                                            + encodeURIComponent(this.wholesalePrice)
-                                            + "&CF" + fId_Agency__c + "_lkid=" 
-                                            + encodeURIComponent(this.agency1Id) 
-                                            + "&CF" + fId_Agency__c + "=" 
-                                            + encodeURIComponent(this.agency1Name)
-                                            + "&" + fId_StageName__c + "=" 
-                                            + encodeURIComponent(this.opportunityStage) 
-                                            + "&CF" + fId_Change_To_Opportunity__c + "_lkid=" 
-                                            + encodeURIComponent(this.recordId )
-                                            + "&CF" + fId_Change_To_Opportunity__c + "=" 
-                                            + encodeURIComponent(this.name )
-                                            + "&" + fId_Department_Cateogy__c + "=" 
-                                            + encodeURIComponent(this.opportunityCategory);
-                                            console.log(url);
-                                            window.open(url);
+                                            // var url = "/a2Y/e?retURL=%2F" 
+                                            // + this.recordId 
+                                            // + "&Name='(OLYMPUS)'"  
+                                            // + encodeURIComponent(this.name)
+                                            // + "&RecordType=" + recTypeId  + "&" + fId_Close_Forecasted_Date__c + "=" 
+                                            // + encodeURIComponent(this.closeForecastedDate)
+                                            // + "&" + fId_Bid_Planned_Date__c + "=" 
+                                            // + encodeURIComponent(this.bidPlannedDate)
+                                            // + "&" + fId_OCM_Change_To_Opportunity_Flg__c + "=1" + "&CF" + fId_Agency_Hospital__c + "_lkid=" + ahl.Id + "&CF" + fId_Agency_Hospital__c + "=" + encodeURIComponent(ahl.Name) + "&" + fId_Amount__c + "=" 
+                                            // + encodeURIComponent(this.dealerFinalPrice)
+                                            // + "&" + fId_OCMSale_Price__c + "=" 
+                                            // + encodeURIComponent(this.wholesalePrice)
+                                            // + "&CF" + fId_Agency__c + "_lkid=" 
+                                            // + encodeURIComponent(this.agency1Id) 
+                                            // + "&CF" + fId_Agency__c + "=" 
+                                            // + encodeURIComponent(this.agency1Name)
+                                            // + "&" + fId_StageName__c + "=" 
+                                            // + encodeURIComponent(this.opportunityStage) 
+                                            // + "&CF" + fId_Change_To_Opportunity__c + "_lkid=" 
+                                            // + encodeURIComponent(this.recordId )
+                                            // + "&CF" + fId_Change_To_Opportunity__c + "=" 
+                                            // + encodeURIComponent(this.name )
+                                            // + "&" + fId_Department_Cateogy__c + "=" 
+                                            // + encodeURIComponent(this.opportunityCategory);
+                                            // console.log(url);
+                                            // window.open(url);
+                                            const defaultValues = encodeDefaultFieldValues({
+                                                Name: '(OLYMPUS)',
+                                                Close_Forecasted_Date__c: this.closeForecastedDate,
+                                                Bid_Planned_Date__c: this.bidPlannedDate,
+                                                OCM_Change_To_Opportunity_Flg__c: '1',
+                                                Agency_Hospital__c: ahl.Id,
+                                                Amount__c: this.dealerFinalPrice,
+                                                OCMSale_Price__c: this.wholesalePrice,
+                                                Agency__c: this.agency1Id,
+                                                StageName__c: this.opportunityStage,
+                                                Change_To_Opportunity__c: this.recordId,
+                                                Department_Cateogy__c: this.opportunityCategory,
+                                                RecordTypeId: recTypeId
+                                            });
+                                            this[NavigationMixin.Navigate]({
+                                                type: 'standard__objectPage',
+                                                attributes: {
+                                                    objectApiName: 'Agency_Opportunity__c',
+                                                    actionName: 'new'
+                                                },
+                                                state: {
+                                                    nooverride: '1',
+                                                    defaultFieldValues: defaultValues,
+                                                }
+                                            });
                                             this.dispatchEvent(new CloseActionScreenEvent());
                                         } catch (error) {
                                             console.log(error)

--
Gitblit v1.9.1