ShowForm打开单据详情/单据列表,如何进行传参以及参数获取原创
金蝶云社区-Running
Running
28人赞赏了该文章 786次浏览 未经作者许可,禁止转载编辑于2024年01月02日 19:57:41

1、应用场景

    不少二开场景中,均需要ShowForm打开对应单据的单据详情或是单据列表界面,同时需要将当前单据特定字段值或是变量,传递到目标单据上,借由表单或是列表插件进行读取,从而进行相关的计算或是赋值。

    本文将演示跨单之间如何进行参数值的传递及获取


2、案例演示

    币别打开物料详情界面,传递自定义参数至物料界面,物料表单插件获取该参数后进行展示。

image.png


    币别打开物料列表界面,传递自定义参数至物料界面,物料列表获取该参数后进行展示。

image.png


3、示例代码

    币别表单插件,ShowForm打开物料详情及物料列表示例代码:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using Kingdee.BOS.Core.Bill;
using Kingdee.BOS.Core.Bill.PlugIn;
using Kingdee.BOS.Core.DynamicForm.PlugIn.Args;
using Kingdee.BOS.Core.List;
using Kingdee.BOS.Util;

namespace Running.Sample.PlugIn.BusinessPlugIn.Bill
{
    [Description("测试ShowForm传参"), HotUpdate]
    public class P20240102ShowFormEdit : AbstractBillPlugIn
    {
        public override void BarItemClick(BarItemClickEventArgs e)
        {
            //打开单据详情
            if (e.BarItemKey.EqualsIgnoreCase("tbBtnEdit"))
            {
                BillShowParameter showParam = new BillShowParameter();
                showParam.FormId = "BD_MATERIAL";
                showParam.PKey = "100462";
                //传递自定义参数
                showParam.CustomParams.Add("TestShowParamEdit", "1");
                this.View.ShowForm(showParam);
            }
            //打开单据列表
            else if (e.BarItemKey.EqualsIgnoreCase("tbBtnList"))
            {
                ListShowParameter showParam = new ListShowParameter();
                showParam.FormId = "BD_MATERIAL";
                //传递自定义参数
                showParam.CustomParams.Add("TestShowParamList", "2");
                this.View.ShowForm(showParam);
            }
        }
    }
}


    物料表单插件,获取币别传递过来的自定义参数:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using Kingdee.BOS.Core.Bill.PlugIn;
using Kingdee.BOS.Util;

namespace Running.Sample.PlugIn.BusinessPlugIn.Bill
{
    [Description("测试参数读取,表单插件"), HotUpdate]
    public class P20240102GetCustomParamsValueEdit : AbstractBillPlugIn
    {
        public override void AfterBindData(EventArgs e)
        {
            object res = this.View.OpenParameter.GetCustomParameter("TestShowParamEdit");
            this.View.ShowMessage(string.Format("自定义参数,参数标识 TestShowParamEdit 的对应值是:{0}", res.GetString()));
        }
    }
}


    物料列表插件,获取币别传递过来的自定义参数:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using Kingdee.BOS.Core.List.PlugIn;
using Kingdee.BOS.Util;

namespace Running.Sample.PlugIn.BusinessPlugIn.List
{
    [Description("测试参数读取,表单插件"), HotUpdate]
    public class P20240102GetCustomParamsValueList : AbstractListPlugIn
    {
        public override void AfterBindData(EventArgs e)
        {
            object res = this.View.OpenParameter.GetCustomParameter("TestShowParamList");
            this.View.ShowMessage(string.Format("自定义参数,参数标识 TestShowParamList 的对应值是:{0}", res.GetString()));
        }
    }
}


赞 28