表单插件.二开案例.单据复制指定字段

栏目:云星空知识作者:金蝶来源:金蝶云社区发布:2024-09-23浏览:1

表单插件.二开案例.单据复制指定字段

【场景】单据复制时,支持二开复制指定字段 【案例】源单编号在普通复制时不携带,通过插件自行复制携带 ![image.webp](/download/0100c9b61d09182342829e20ad4667dccfe7.webp) ```chsarp using Kingdee.BOS.Core.Bill.PlugIn; using Kingdee.BOS.Core.Bill.PlugIn.Args; using Kingdee.BOS.Core.Metadata.EntityElement; using Kingdee.BOS.Core.Metadata.FieldElement; using Kingdee.BOS.Orm.DataEntity; using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace DynamicFormPlugIn.Test { [Kingdee.BOS.Util.HotUpdate] [System.ComponentModel.Description("复制源单编号")] public class BillPlugIn_CopySrcBillNo : AbstractBillPlugIn { /// <summary> /// 单据复制后事件 /// </summary> /// <param name="e"></param> public override void AfterCopyData(CopyDataEventArgs e) { if (e.SrcDataObject == null || e.DataObject == null) return; //复制源单编号、源单类型该字段 List<Field> copyFieldList = View.BillBusinessInfo.GetFieldList().Where(x => x is SourceBillNoField || x is SourceBillTypeField).ToList(); if (copyFieldList == null || copyFieldList.Count <= 0) return; foreach(var copyField in copyFieldList) { CopyField(e.SrcDataObject, e.DataObject, copyField); } } private void CopyField(DynamicObject srcDataObj, DynamicObject tgtDataObj, Field copyField) { //简单拷贝处理 Action<DynamicObject, DynamicObject> copyAct = (srcObj, tgtObj) => { if (!tgtObj.DynamicObjectType.Properties.ContainsKey(copyField.PropertyName)) return; tgtObj[copyField.PropertyName] = srcObj[copyField.PropertyName]; }; var entity = copyField.Entity; if (entity is HeadEntity) { //单据头字段处理 copyAct(srcDataObj, tgtDataObj); } else if (entity is EntryEntity) { //单据体字段处理 if (!tgtDataObj.DynamicObjectType.Properties.ContainsKey(entity.EntryName)) return; DynamicObjectCollection tgtEntityRows = tgtDataObj[entity.EntryName] as DynamicObjectCollection; if (tgtEntityRows == null || tgtEntityRows.Count <= 0) return; DynamicObjectCollection srcEntityRows = srcDataObj[entity.EntryName] as DynamicObjectCollection; if (srcEntityRows.Count != tgtEntityRows.Count) return; for (int i = 0, cnt = tgtEntityRows.Count; i < cnt; ++i) { DynamicObject srcRowObj = srcEntityRows[i]; DynamicObject tgtRowObj = tgtEntityRows[i]; copyAct(srcRowObj, tgtRowObj); } } } } } ``` 【效果】支持通过普通复制操作,实现有源单编号但没有上游的情况 ![1679907327283.webp](/download/01008b3bcf6e10b046c3a43074866b1d1733.webp)

表单插件.二开案例.单据复制指定字段

【场景】单据复制时,支持二开复制指定字段【案例】源单编号在普通复制时不携带,通过插件自行复制携带![image.webp](/download/0100c9b61d...
点击下载文档
确认删除?
回到顶部
客服QQ
  • 客服QQ点击这里给我发消息