电脑桌面
添加蚂蚁七词文库到电脑桌面
安装后可以在桌面快捷访问

普通列表批量复制二开示例

来源:金蝶云社区作者:金蝶2024-09-2312

普通列表批量复制二开示例

批量复制的功能,标准产品不提供,是有很多原因,其中就包含了前端显示多个页签问题、复制单据量多出现系统效率低等问题,所以建议谨慎使用。普通的列表(不适用树形列表等)的批量复制单据的二开,不包含权限控制,示例如下:

以采购申请单为例,首先在BOS设计器中找到采购申请单,拓展,然后添加列表菜单“批量复制”。

挂上列表插件。列表插件代码如下:

using Kingdee.BOS.Core;

using Kingdee.BOS.Core.Bill;

using Kingdee.BOS.Core.Const;

using Kingdee.BOS.Core.DynamicForm;

using Kingdee.BOS.Core.List.PlugIn;

using Kingdee.BOS.Core.Metadata;

using Kingdee.BOS.Core.Metadata.FieldElement;

using Kingdee.BOS.JSON;

using Kingdee.BOS.Orm.DataEntity;

using Kingdee.BOS.Util;

using Kingdee.BOS.Core.Util;

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

using Kingdee.BOS.Core.Metadata.FormElement;

using Kingdee.BOS.Core.List;


namespace Kingdee.BOS.Printing.PlugIn.Test

{

    public class CopyListPlugIn : AbstractListPlugIn

    {

        public override void BarItemClick(Core.DynamicForm.PlugIn.Args.BarItemClickEventArgs e)

        {

            base.BarItemClick(e);

            if (e.BarItemKey == "BthBacthCopy")

            {

                var ids = ((IListView)this.View).SelectedRowsInfo.GetPrimaryKeyValues();

                foreach (string id in ids)

                {

                    ListNewOrCopy(id);

                }

            }

        }

private void ListNewOrCopy(string pk)

        {

            BillShowParameter param = new BillShowParameter();

            param.PKey = pk;


            Form form = ((IListView)this.View).BillBusinessInfo.GetForm();

            Appearance ap = ((IListView)this.View).BillLayoutInfo.GetFormAppearance();

            param.FormId = form.Id;

            if (string.IsNullOrEmpty(((IListView)this.View).CurrentSelectedRowInfo.FormID) == false)

            {

                param.FormId = ((IListView)this.View).CurrentSelectedRowInfo.FormID;

            }

            param.CreateFrom = CreateFrom.Copy;

            param.Width = ap.Width;

            param.Height = ap.Height;

            if (IsCopyLinkEntry())

            {

                param.CustomParams.Add("IsCopyLinkEntry", "1");

            }

            SetFormOpenStyle(param);

            param.Status = OperationStatus.ADDNEW;


            //列表发布单据类型参数

            object cusBillType = this.View.OpenParameter.GetCustomParameter(BOSConst.CustomBillTypeID);

            //列表发布视图参数

            object cusLayoutId = this.View.OpenParameter.GetCustomParameter(BOSConst.OpenLayoutId);


            this.SetLayOutId(cusBillType, cusLayoutId, param);


            this.ShowBillNewForm(this.View, param);

        }

protected void SetFormOpenStyle(DynamicFormShowParameter param)

        {

            if (param == null) return;

            if (this.View.ParentFormView != null)

            {

                if (ViewUtils.IsParentViewConsole(this.View))

                {

                    // 主控台使用页签方式

                    param.OpenStyle.ShowType = ShowType.MainNewTabPage;

                }

                else

                {

                    // 根据父窗口风格决定子窗口现实风格

                    OpenStyle openStyle = this.View.OpenParameter.GetCustomParameter("openstyle") as OpenStyle;

                    if (openStyle != null)

                    {

                        if (openStyle.ShowType == ShowType.MainNewTabPage || (openStyle.TagetKey != null && openStyle.TagetKey.ToUpper() == "FMAINTAB"))

                        {

                            param.OpenStyle.ShowType = ShowType.MainNewTabPage;

                        }

                        param.OpenStyle.TagetKey = openStyle.TagetKey;

                    }

                    else

                    {

                        param.OpenStyle.ShowType = ShowType.Default;

                    }

                }

            }

        }

private void SetLayOutId(object cusBillType, object cusLayoutId, DynamicFormShowParameter param)

        {


            //当前选中单据单据类型值

            string billTypeId = ((Kingdee.BOS.Core.List.IListView)this.View).CurrentSelectedRowInfo.BillTypeID;

            //当前选中单据单据类型对应视图的值

            string layoutId = ((Kingdee.BOS.Core.List.IListView)this.View).CurrentSelectedRowInfo.LayoutID;


            if (!cusBillType.IsNullOrEmptyOrWhiteSpace())

            {

                if (billTypeId == cusBillType.ToString())

                {

                    if (null != cusLayoutId)

                    {

                        param.LayoutId = cusLayoutId.ToString();

                    }

                    else

                    {

                        param.LayoutId = layoutId;

                    }

                }

                else

                {

                    param.LayoutId = GetLayoutID(billTypeId);

                }

            }

            else if (!cusLayoutId.IsNullOrEmptyOrWhiteSpace())

            {

                param.LayoutId = cusLayoutId.ToString();

            }

            else

            {

                param.LayoutId = layoutId;

            }

        }

private string GetLayoutID(string de

普通列表批量复制二开示例

批量复制的功能,标准产品不提供,是有很多原因,其中就包含了前端显示多个页签问题、复制单据量多出现系统效率低等问题,所以建议谨慎使用...
点击下载文档文档为doc格式

声明:除非特别标注,否则均为本站原创文章,转载时请以链接形式注明文章出处。如若本站内容侵犯了原著者的合法权益,可联系本站删除。

已经是第一篇
确认删除?
回到顶部
客服QQ
  • 客服QQ点击这里给我发消息
QQ群
  • 答案:my7c点击这里加入QQ群
支持邮箱
微信
  • 微信