前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
社区首页 >专栏 >Salesforce 自定义List Button(三) 嵌套Aura情况下打开Lwc画面

Salesforce 自定义List Button(三) 嵌套Aura情况下打开Lwc画面

原创
作者头像
repick
发布2022-04-05 21:00:08
发布2022-04-05 21:00:08
78100
代码可运行
举报
文章被收录于专栏:SalesforceSalesforce
运行总次数:0
代码可运行

通过前两篇,我们看到跟标准画面不同,打开方式并不是Dialog方式,以下我们通过嵌套Aura情况下,打开Lwc画面。

1.Aura组件做成,Dialog里引用Lwc。

ListVIew数据下,如果需要选择的情报,也可以通过Aura传入Lwc组件中。

newContactInfoAuraComponent.cmp

代码语言:javascript
代码运行次数:0
运行
复制
<aura:component>
    <aura:html tag="style">
        /*control modal width*/
        .slds-modal__container{
            max-width: 180rem !important;
            width:90% !important;
        }
        .modal-footer {
            display: none;

        }
    </aura:html>
    <aura:attribute name="selectedIds" type="List" default="" />
    <section role="dialog" tabindex="-1" aria-labelledby="modal-heading-01" aria-modal="true" aria-describedby="modal-content-id-1" class="slds-modal slds-fade-in-open">
        <div class="slds-modal__container">
            <div class="modal-body scrollable slds-modal__content slds-p-around--medium" style="height: 100%;">
                <c:newContactInfo contactIds="{!v.selectedIds}"></c:newContactInfo>
            </div>
        </div>
    </section>
    <div class="slds-backdrop slds-backdrop_open"></div>
</aura:component>

2.Lwc组件

newContactInfo.js

代码语言:javascript
代码运行次数:0
运行
复制
import { LightningElement, api, track, wire } from 'lwc';
import { getRecord } from 'lightning/uiRecordApi';
import { ShowToastEvent } from 'lightning/platformShowToastEvent';
import { NavigationMixin } from 'lightning/navigation';

export default class NewContactInfo extends NavigationMixin(LightningElement) {

    @api contactIds;

    @track contactId;
    activeSections = ['contactInfo'];

    connectedCallback() {
        console.log('>>>>>>>>>>>>>>>>'+this.contactIds);
    }
    @wire(getRecord, { recordId: '$contactId', fields: ['Contact.Name'] })
    wiredContact({ error, data }) {
        if (data && data.fields) {
            const evt = new ShowToastEvent({
                title: 'Contact Operated Success',
                message: 'Contact updated' + data.fields.Name.value,
                variant: 'success'
            });
            window.location.assign('/003');
        } else if (error) {
            // システムエラー画面に遷移する
        }
    }

    handleSuccess(event) {
        this.contactId = event.detail.id;
    }
    handleClose() {
        window.location.assign('/003');
    }
}

3.Application Aura组件

newContactInfoApp.app

代码语言:javascript
代码运行次数:0
运行
复制
<aura:application access="GLOBAL" extends="ltng:outApp">
    <aura:dependency resource="c:newContactInfoAuraComponent"/>
</aura:application>

4.VfPage组件

这里从直接打开Lwc,改成Aura组件

newContactinfoVf.page

代码语言:javascript
代码运行次数:0
运行
复制
<apex:page standardController="Contact" recordSetVar="Contacts" showHeader="false">
    <apex:includeLightning />
    <div id="lightning" />
    <script>
        var selectedList = [];
    </script>
    <apex:repeat value="{!selected}" var="selectedItem">
        <script>
            selectedList.push('{!selectedItem}');
        </script>
    </apex:repeat>
    <script>
        $Lightning.use("c:newContactInfoApp", function () {
            $Lightning.createComponent("c:newContactInfoAuraComponent",
                { selectedIds: selectedList },
                'lightning',
                function (cmp) {

                }
            );
        });

    </script>
</apex:page>

5.效果展示:

选择三条数据情况下,点击New按钮

通过Log,可以查看选择的数据情况。

登录成功

原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。

如有侵权,请联系 cloudcommunity@tencent.com 删除。

原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。

如有侵权,请联系 cloudcommunity@tencent.com 删除。

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • 1.Aura组件做成,Dialog里引用Lwc。
  • 2.Lwc组件
  • 3.Application Aura组件
  • 4.VfPage组件
  • 5.效果展示:
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档