二开案例.单据头超链接显示附件数,点击打开附件列表原创
3人赞赏了该文章
22次浏览
编辑于2024年11月15日 10:25:56
1、在单据上增加附件数和超链接字段,ID分别是F_UNW_AttachmentCount_qtr、F_UNW_Link_83g
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.Resource; using Kingdee.BOS.ServiceHelper; using Kingdee.BOS.Util; using System; namespace Test202411 { [Kingdee.BOS.Util.HotUpdate] public class 附件数超链接 : AbstractBillPlugIn { public override void AfterBindData(EventArgs e) { UpdataAttachementLinkText(); } public override void DataChanged(DataChangedEventArgs e) { if (e.Key.EqualsIgnoreCase("F_UNW_AttachmentCount_qtr")) { UpdataAttachementLinkText(); } } void UpdataAttachementLinkText() { var link = this.View.GetControl("F_UNW_Link_83g"); var attachmentCount = this.Model.GetValue("F_UNW_AttachmentCount_qtr"); link.SetCustomPropertyValue("Text", string.Format("附件数:{0}", attachmentCount)); } public override void ButtonClick(ButtonClickEventArgs e) { if (e.Key.EqualsIgnoreCase("F_UNW_Link_83g")) { //调用附件管理操作 this.View.InvokeFormOperation("AttachmentMgr"); return; //或使用下面的代码,自行弹出附件列表 var view = this.View; var billNoField = view.BillBusinessInfo.GetBillNoField(); AttachmentKey attachmentKey = new AttachmentKey() { BillType = view.BusinessInfo.GetForm().Id, BillNo = (view.Model.DataObject[billNoField.PropertyName] ?? "").ToString(), BillInterID = this.View.Model.GetPKValue().ToString(), EntryKey = null, EntryInterID = "-1", OperationStatus = OperationStatus.EDIT, ForceEnableAttachOperate = true }; 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.ListFilterParameter.Filter = filter; listpara.IsShowQuickFilter = false; view.ShowForm(listpara, delegate (FormResult result) { foreach (string key in attachmentKey.AttachmentCountFieldKeys) { view.UpdateView(key, attachmentKey.RowIndex); } }); } } } }
3、实现效果:点击超链接,打开附件列表(附件数字段可设置为隐藏,只显示超链接)
赞 3
3人点赞
还没有人点赞,快来当第一个点赞的人吧!
打赏
1人打赏
还没有人打赏,快来当第一个打赏的人吧!
推荐阅读