套打.二开案例.取表体首行、表体尾行、间隔行赋值逻辑

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

套打.二开案例.取表体首行、表体尾行、间隔行赋值逻辑

【场景】表体首行、表体尾行、间隔行赋值逻辑;部分场景下通过聚合字段、脚本无法实现 【数据准备】凭证 ![image.webp](/download/0100d88111b35a0a4e588e9288abbb6d3d38.webp) 【场景一】打印时, 所有行摘要都显示第一行摘要的值; 0)模板配置,增加动态字段 ![image.webp](/download/0100bfe43c8305bc4d07b27e294896027e77.webp) 其中 loadfield 用来加载这个字段,取数用;kd_dynamic 打印时显示字段 调整对应位置绑定动态字段 ![image.webp](/download/010084900f2521cd44999a492a95be0961fd.webp) 1)增加打印表单、列表插件 ![image.webp](/download/01000dde8bf528fb46e7aaaa065a2c9e9a4c.webp) ```python #引入clr运行库 import clr #添加对cloud插件开发的常用组件的引用 clr.AddReference('Kingdee.BOS') clr.AddReference('Kingdee.BOS.Core') #导入cloud基础库中的常用实体对象(分命名空间导入,不会递归导入) from Kingdee.BOS import * from Kingdee.BOS.Core import * from Kingdee.BOS.Util import * from System import * #重载cloud插件模型的主菜单按钮点击事件 def OnPrepareNotePrintData(e): useTemplateId = '';##适用模板ID,如果为空则代表全部适用 ##useTemplateId = '34f514b1-b7d3-40ff-9e3f-a617b320c3b3'; if e.NotePrintTplId is None or useTemplateId == '' or e.NotePrintTplId.Equals(useTemplateId): if not e.DataSourceId == 'FEntity':##关联的表体,如单据体 return; if len(e.DataObjects)==0: return; srcFieldKey = 'FEXPLANATION';##原字段标识 dynamicKey = 'kd_dynamic';##动态字段标识 if not e.DynamicObjectType.Properties.ContainsKey(srcFieldKey): return; if not e.DynamicObjectType.Properties.ContainsKey(dynamicKey): return; firstRowVal = e.DataObjects[0][srcFieldKey];##首行值 lastRowVal = e.DataObjects[len(e.DataObjects)-1][srcFieldKey];##尾行值 ##案例:所有行的值跟首行一样 for index in range(len(e.DataObjects)): if True:##赋值条件,如仅保留奇数行 e.DataObjects[index][dynamicKey] = firstRowVal; ``` 参数说明: useTemplateId:使用此逻辑的模板,为空时代表所有模板 DataSourceId:干预的实体,这里指代的是凭证的明细 srcFieldKey: 拷贝的来源字段,这里指代的是摘要字段 dynamicKey:填入字段,这里指代的是动态字段 firstRowVal:首行值 2)效果 ![image.webp](/download/01006ab04ee5eed542b18cf49e3f32d95a52.webp) 【场景二】打印时, 所有行摘要都显示最后一行摘要的值; 0)同场景一,配置动态字段,调整模板绑定显示字段 1)增加打印表单、列表插件 ```python #引入clr运行库 import clr #添加对cloud插件开发的常用组件的引用 clr.AddReference('Kingdee.BOS') clr.AddReference('Kingdee.BOS.Core') #导入cloud基础库中的常用实体对象(分命名空间导入,不会递归导入) from Kingdee.BOS import * from Kingdee.BOS.Core import * from Kingdee.BOS.Util import * from System import * #重载cloud插件模型的主菜单按钮点击事件 def OnPrepareNotePrintData(e): useTemplateId = '';##适用模板ID,如果为空则代表全部适用 ##useTemplateId = '34f514b1-b7d3-40ff-9e3f-a617b320c3b3'; if e.NotePrintTplId is None or useTemplateId == '' or e.NotePrintTplId.Equals(useTemplateId): if not e.DataSourceId == 'FEntity':##关联的表体,如单据体 return; if len(e.DataObjects)==0: return; srcFieldKey = 'FEXPLANATION';##原字段标识 dynamicKey = 'kd_dynamic';##动态字段标识 if not e.DynamicObjectType.Properties.ContainsKey(srcFieldKey): return; if not e.DynamicObjectType.Properties.ContainsKey(dynamicKey): return; firstRowVal = e.DataObjects[0][srcFieldKey];##首行值 lastRowVal = e.DataObjects[len(e.DataObjects)-1][srcFieldKey];##尾行值 ##案例:所有行的值跟首行一样 for index in range(len(e.DataObjects)): if True:##赋值条件,如仅保留奇数行 e.DataObjects[index][dynamicKey] = lastRowVal; ``` 这里调整的代码逻辑,仅调整了 e.DataObjects[index][dynamicKey] = lastRowVal; 2)效果 ![image.webp](/download/0100ff426683ed7147c685962caa4da4d806.webp) 【场景三】打印时,每页首行显示第一行摘要的值;每页首行等价于第1,6,..行 0)同场景一,配置动态字段,调整模板绑定显示字段 1)增加打印表单、列表插件 ```python #引入clr运行库 import clr #添加对cloud插件开发的常用组件的引用 clr.AddReference('Kingdee.BOS') clr.AddReference('Kingdee.BOS.Core') #导入cloud基础库中的常用实体对象(分命名空间导入,不会递归导入) from Kingdee.BOS import * from Kingdee.BOS.Core import * from Kingdee.BOS.Util import * from System import * #重载cloud插件模型的主菜单按钮点击事件 def OnPrepareNotePrintData(e): useTemplateId = '';##适用模板ID,如果为空则代表全部适用 ##useTemplateId = '34f514b1-b7d3-40ff-9e3f-a617b320c3b3'; if e.NotePrintTplId is None or useTemplateId == '' or e.NotePrintTplId.Equals(useTemplateId): if not e.DataSourceId == 'FEntity':##关联的表体,如单据体 return; if len(e.DataObjects)<=0: return; srcFieldKey = 'FEXPLANATION';##原字段标识 dynamicKey = 'kd_dynamic';##动态字段标识 if not e.DynamicObjectType.Properties.ContainsKey(srcFieldKey): return; if not e.DynamicObjectType.Properties.ContainsKey(dynamicKey): return; firstRowVal = e.DataObjects[0][srcFieldKey];##首行值 lastRowVal = e.DataObjects[len(e.DataObjects)-1][srcFieldKey];##尾行值 ##案例:所有行的值跟首行一样 for index in range(len(e.DataObjects)): if index % 5 == 0:##赋值条件,保留1,6 每5行,注意这里是从0开始算 e.DataObjects[index][dynamicKey] = firstRowVal; ``` 调整代码 if index % 5 == 0:##赋值条件,保留1,6 每5行,注意这里是从0开始算 2)效果 ![image.webp](/download/01000b246d50f6a8422db62d6ad883c771ea.webp) ![image.webp](/download/010016728080fdb3407cb58ba743a79529a5.webp)

套打.二开案例.取表体首行、表体尾行、间隔行赋值逻辑

【场景】表体首行、表体尾行、间隔行赋值逻辑;部分场景下通过聚合字段、脚本无法实现【数据准备】凭证![image.webp](/download/0100d88111...
点击下载文档
确认删除?
回到顶部
客服QQ
  • 客服QQ点击这里给我发消息