二开干预套打取数
需求:取子单据体上字段,拼接进行打印输出
开发步骤:
在套打上定义名字为“FMODELNO”的动态字
插件代码进行取数赋值
(列表打印和单据打印是分开的。如果需要单据打印生效,则需要继承AbstractBilPlugIn基类,在OnPrepareNotePrintData实现干预套打取数的逻辑。列表同理。)
列表插件
public override void OnPrepareNotePrintData(PreparePrintDataEventArgs e) { base.OnPrepareNotePrintData(e); if (e.DataSourceId.Equals("FBillHead", StringComparison.OrdinalIgnoreCase)) { if (e.DataObjects != null) { List<long> lstId = new List<long>(); foreach (var data in e.DataObjects) { lstId.Add(Convert.ToInt32(data["FID"])); } Dictionary<long, string> myDictionary = new Dictionary<long, string>(); foreach (long billId in lstId) { FormMetadata meta = MetaDataServiceHelper.Load(this.Context, "BAS_PreBaseDataOne") as FormMetadata; DynamicObject pgd = BusinessDataServiceHelper.LoadSingle(this.Context, billId, meta.BusinessInfo.GetDynamicObjectType()); if (pgd != null) { DynamicObject entity = (pgd["F_JDSL_Entity"] as DynamicObjectCollection).FirstOrDefault(); var names = (entity["F_JDSL_SubEntity"] as DynamicObjectCollection).Select(P => (P["F_JDSL_SubOperator"] as DynamicObject)["Name"]); myDictionary[billId] = string.Join("、", names); } } //注册临时字段 DynamicObjectType dot = e.DataObjects[0].DynamicObjectType; dot.RegisterSimpleProperty("FMyself", typeof(object), attributes: new SimplePropertyAttribute() { Alias = "FVOUCHERGROUPNO" }); for (int i = 0; i < e.DataObjects.Length; i++) { DynamicObject obj = new DynamicObject(dot); foreach (var p in dot.Properties) { obj[p] = e.DataObjects[i][p]; } //动态字段赋值 obj["FMODELNO"] = myDictionary[Convert.ToInt64(e.DataObjects[i]["FID"])]; e.DataObjects[i] = obj; } } } }
表单插件
public class DeliverNoticePrintList :AbstractListPlugIn { public override void OnPrepareNotePrintData(PreparePrintDataEventArgs e) { base.OnPrepareNotePrintData(e); if (e.NotePrintTplId == "8c80e77b-fdcf-4a41-bb87-cb1588b04eaa") { if (e.DataSourceId.Equals("FEntity", StringComparison.OrdinalIgnoreCase)) { if (e.DataObjects != null) { DynamicObjectType dataType = e.DataObjects[0].DynamicObjectType; dataType.RegisterSimpleProperty("FMODELNO", typeof(object), attributes: new SimplePropertyAttribute() { Alias = "FMODELNO" }); for (int i = 0; i < e.DataObjects.Length; i++) { DynamicObject obj = new DynamicObject(dataType); foreach (var p in dataType.Properties) { obj[p] = e.DataObjects[i][p]; } obj["FMODELNO"] = getModelName((obj["F_NEST_BGDL_FName1"] as List<LocaleValue>)[0].ToString(), i+1); e.DataObjects[i] = obj; } } } } } }
参考链接:二开干预套打取数示例(动态字段使用)
能否讲讲如何动态注册字段,即实现 动态的行转列
二开干预套打取数
需求:取子单据体上字段,拼接进行打印输出开发步骤:在套打上定义名字为“FMODELNO”的动态字插件代码进行取数赋值(列表打印和单据打印是...
点击下载文档
本文2024-09-16 17:17:17发表“云星空知识”栏目。
本文链接:https://wenku.my7c.com/article/kingdee-k3cloud-14736.html
您需要登录后才可以发表评论, 登录登录 或者 注册
最新文档
热门文章