0

我能够将记录 id 传递给闪电组件(来自 Vf 页面),但在输出页面中我只是得到空表单而没有任何数据填充。[我应该得到当前 Opp 详细信息][1]

我已经看到在控制台中我得到了 Opportunity Id,但是为什么输入字段中没有填充数据 [1]:https ://i.stack.imgur.com/Dee2Q.jpg

Visualforce-页面:

<apex:page standardController="Opportunity" extensions="PassingParaFromVfPageToCmp">
    <apex:includeLightning />
    <div  id="LightningCompContainer" />  <!--Used to display lightning component-->  
    <script>
        $Lightning.use("c:EnrollemetFormApp", function() {
            $Lightning.createComponent("c:EnrollemetForm", {
            OppIdfromVfPage:"{!JSENCODE(Opportunity.Id)}"},
            "LightningCompContainer",
            function(cmp) {
               
            });
        });
    </script>
</apex:page>

**Controller-Method :** 

public class PassingParaFromVfPageToCmp {
   public Id oppId;
public  PassingParaFromVfPageToCmp(Apexpages.StandardController stdcontroller) {
       oppId = Apexpages.currentPage().getParameters().get('id');
    system.debug('OPPPPP' +oppId);
}
}

**Aura-Component :** 

<aura:component  controller="EnrollementFormCmp" implements="force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,forceCommunity:availableForAllPageTypes,force:lightningQuickAction" 
                access="global" >
    <b> Details </b>
    <aura:attribute name="OppIdfromVfPage" type="string"/>
   <aura:handler name="init" value="{!this}" action="{!c.doInit}" />
     <aura:attribute name="Opp" type="Opportunity" default="{'SobjectType' : 'Opportunity'}"/>
    <div class="slds-p-around_Small">
            <lightning:recordEditForm objectApiName="Opportunity"
                                          recordId= '{!v.recordId}'>
                <lightning:messages />
                <lightning:inputField fieldName="Name" value="{!v.Name}" />
                <lightning:inputField fieldName="Actual_Cost__c" value="{!v.Actual_Cost__c}"/>
                <lightning:inputField fieldName="Requested_For_Loan_Assistance__c" value="{!v.Requested_For_Loan_Assistance__c}" />
                 <lightning:inputField fieldName="Account.Name" value="{!v.Account.Name}"/>
                 <lightning:inputField fieldName="Discount__c" value="{!v.Discount__c}" />
                 <lightning:inputField fieldName="Batch__c" value="{!v.Batch__c}" />
                <lightning:inputField fieldName="Course_Interest__c"  value="{!v.Course_Interest__c}"/>
                <center>
               <lightning:button variant="brand" label="Save" title="Brand action" />
                </center>
            </lightning:recordEditForm>
        </div>      
</aura:component>

**Js.Method :**

({
    doInit : function(component, event, helper) {
       var oppFromVfPage =component.get('v.OppIdfromVfPage');
        console.log('aaaaaaaaa'+ oppFromVfPage);
        var action = component.get("c.GetOpportunityDetails");
       action.setParams({ currentOppId : oppFromVfPage });
       $A.enqueueAction(action);
    }
})

**Aura-Enabled Method :**

public class EnrollementFormCmp {
    @AuraEnabled
    public static void  GetOpportunityDetails(Id currentOppId) {
        Opportunity opp = [SELECT Actual_Cost__c, Id,
                           Requested_For_Loan_Assistance__c,
                           Account.Name,
                           Discount__c,
                           Batch__c,Course_Interest__c FROM Opportunity where Id =:currentOppId ];
    }
}

注意:Vf-page 是从 Opportunity Detail 页面的 cutom 按钮调用的。谁能帮我解决这个问题

4

0 回答 0