二开案例.点击明细行,显示附件列表原创
金蝶云社区-齐111
齐111
14人赞赏了该文章 259次浏览 未经作者许可,禁止转载编辑于2024年08月23日 14:57:52

实现效果:点击单据体明细行,在右侧显示该行的附件列表。

image.png

1、在单据上添加面板,ID为FPanelAttachmentList,用于显示附件列表



image.png


2、插件代码

using Kingdee.BOS.Core;
using Kingdee.BOS.Core.Attachment;
using Kingdee.BOS.Core.Bill.PlugIn;
using Kingdee.BOS.Core.DynamicForm;
using Kingdee.BOS.Core.DynamicForm.PlugIn.Args;
using Kingdee.BOS.Core.List;
using Kingdee.BOS.Core.Metadata;
using Kingdee.BOS.Core.Metadata.EntityElement;
using Kingdee.BOS.Core.Metadata.FieldElement;
using Kingdee.BOS.Core.Metadata.FormElement;
using Kingdee.BOS.Resource;
using Kingdee.BOS.ServiceHelper;
using System;

namespace Test202408
{
    [Kingdee.BOS.Util.HotUpdate]
    public class 显示单据体附件列表 : AbstractBillPlugIn
    {
        string targetPanelKey = "FPanelAttachmentList";
        string attachmentPageId = Guid.NewGuid().ToString();
        public override void EntityRowClick(EntityRowClickEventArgs e)
        {
            var interId = this.View.Model.GetEntryPKValue(e.Key, e.Row).ToString();
            ShowEntityAttachmentList(e.Key, interId, targetPanelKey);
        }

        private void ShowEntityAttachmentList(string entityKey, string entryInterID, string targetPanelKey)
        {
            var view = this.View;
            try
            {
                var attachmentView = view.GetView(attachmentPageId);
                if (attachmentView != null)
                {
                    attachmentView.Close();
                    this.View.SendAynDynamicFormAction(attachmentView);
                    attachmentPageId = Guid.NewGuid().ToString();
                }
            }
            catch { }

            Form frm = this.View.BillBusinessInfo.GetForm();
            var pk = this.View.Model.GetPKValue().ToString();
            AttachmentKey attachmentKey = new AttachmentKey()
            {
                BillType = frm.Id,
                BillNo = "",
                BillInterID = pk,
                EntryKey = entityKey,
                EntryInterID = entryInterID,
                OperationStatus = OperationStatus.EDIT,
                ForceEnableAttachOperate = true
            };
            #region  获取附件数Key
            Entity ty = view.BillBusinessInfo.GetEntity(attachmentKey.EntryKey);
            foreach (Field f in ty.Fields)
            {
                if (f is AttachmentCountField)
                {
                    attachmentKey.AttachmentCountFieldKeys.Add(f.Key);
                }
            }
            #endregion

            string filter = BusinessDataServiceHelper.GetAttachmentListFilter(view.Context, attachmentKey, view.BillBusinessInfo);
            ListShowParameter listpara = new ListShowParameter();
            listpara.IsLookUp = false;
            listpara.CustomParams.Add(KeyConst.AttachmentKey, AttachmentKey.ConvertToString(attachmentKey));
            listpara.Caption = ResManager.LoadKDString("附件管理", "002012030003226", SubSystemType.BOS);
            listpara.FormId = FormIdConst.BOS_Attachment;
            listpara.MultiSelect = true;
            listpara.PageId = attachmentPageId;// string.Format("{0}_{1}_F7", view.PageId, listpara.FormId);
            listpara.OpenStyle.TagetKey = targetPanelKey;
            listpara.OpenStyle.ShowType = ShowType.InContainer;
            listpara.ListFilterParameter.Filter = filter;
            listpara.IsShowQuickFilter = false;

            view.ShowForm(listpara, delegate (FormResult result)
            {
                foreach (string key in attachmentKey.AttachmentCountFieldKeys)
                {
                    view.UpdateView(key, attachmentKey.RowIndex);
                }
            });
        }

    }
}


图标赞 14
14人点赞
还没有人点赞,快来当第一个点赞的人吧!
图标打赏
0人打赏
还没有人打赏,快来当第一个打赏的人吧!