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

单据转换.二开案例.列表整单下推默认按照列表选中行顺序整单排序

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

单据转换.二开案例.列表整单下推默认按照列表选中行顺序整单排序

【逻辑】系统默认逻辑:整单转换不会排序 在没有强制排序时,最终是什么顺序最终依赖数据库的返回 【场景】列表整单下推默认按照列表选中行顺序整单排序 【案例】采购申请单下推采购订单 (0)数据准备 ![image.webp](/download/010083c7343151e94314b1dd4a84ac862fd7.webp) 默认下推效果,设置了按照物料编码升序 ![image.webp](/download/010009f7df08b91a4b3686ae8db29c24d6b8.webp) (1)插件排序,整单转换时按照选中行单据顺序 + 分录序号排序 ![image.webp](/download/01007ab818a09689408b869df7e3b4fa01b5.webp) ```csharp using Kingdee.BOS.Core.List; using Kingdee.BOS.Core.Metadata.ConvertElement.PlugIn; using Kingdee.BOS.Core.Metadata.ConvertElement.PlugIn.Args; using Kingdee.BOS.Util; using System; using System.Collections.Generic; using System.Linq; namespace DynamicFormPlugIn.BillConvert { [Kingdee.BOS.Util.HotUpdate] public class ConvertServicePlugIn_SortSourceBill : AbstractConvertPlugIn { /* * 当单据转换是整单转换时,按照列表选中行 + 实体序号排序 */ public override void OnGetSourceData(GetSourceDataEventArgs e) { if (e.SourceData == null || e.SourceData.Count <= 1) return; string srcEntryKey; Option.TryGetVariableValue("SourceEntryKey", out srcEntryKey); if (string.IsNullOrEmpty(srcEntryKey)) return; ListSelectedRow[] selectRows; Option.TryGetVariableValue("SelectedRows", out selectRows); if (selectRows == null || selectRows.Length <= 1) return; if (IsGetByEntry(srcEntryKey, selectRows)) { //分录下推 return; } //整单下推 //按照单据编号和序号排序 string pkFieldName = e.SourceBusinessInfo.GetForm().PkFieldName; var entity = e.SourceBusinessInfo.GetEntity(srcEntryKey) as Kingdee.BOS.Core.Metadata.EntityElement.Entity; if (entity == null) return; string entityFieldName = string.Concat(entity.Key, "_", entity.EntryPkFieldName); if (string.IsNullOrWhiteSpace(entity.SeqFieldKey)) { entityFieldName = string.Concat(entity.Key, "_", entity.SeqFieldKey); } //取选中行的主键和序号 Dictionary<string, string> pkIdx = new Dictionary<string, string>(); for (int i = 0; i < selectRows.Length; ++i) { string pk = selectRows[i].PrimaryKeyValue; if (pkIdx.ContainsKey(pk)) continue; pkIdx[pk] = i.ToString("000000"); } e.SourceData.Sort(x => { return string.Format("{0}_{1}", pkIdx.ContainsKey(x[pkFieldName].ToString()) ? pkIdx[x[pkFieldName].ToString()] : "999999", ObjectUtils.Object2Int(x[entityFieldName]).ToString("000000")); }); } private bool IsGetByEntry(string srcEntryKey, ListSelectedRow[] selectRows) { var firstRow = selectRows.First(); if (string.IsNullOrEmpty(firstRow.EntryPrimaryKeyValue)) return false; if (!srcEntryKey.Equals(firstRow.EntryEntityKey, StringComparison.OrdinalIgnoreCase)) return false; bool SelectByBillId = false; Option.TryGetVariableValue("SelectByBillId", out SelectByBillId);

单据转换.二开案例.列表整单下推默认按照列表选中行顺序整单排序

【逻辑】系统默认逻辑:整单转换不会排序在没有强制排序时,最终是什么顺序最终依赖数据库的返回【场景】列表整单下推默认按照列表选中行顺...
点击下载文档文档为doc格式

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

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