之前较多的使用C#实现套打二开字段实现自定义取值,如下图:
对应的代码效果就是实现应收款明细表在表头获取最后一行数据行分录的“远比&期末余额”(FLEFTAMOUNTFOR)的值(表尾当然不必这样处理):
之前用python没有处理过注册属性加二开字段的逻辑,实际上在简单测试下也能够支持到,具体代码如下,效果一致
#引入clr运行库
import clr
#添加对cloud插件开发的常用组件的引用
clr.AddReference('Kingdee.BOS')
clr.AddReference('Kingdee.BOS.Core')
clr.AddReference('Kingdee.BOS.App')
clr.AddReference('Kingdee.BOS.DataEntity')
#导入cloud基础库中的常用实体对象(分命名空间导入,不会递归导入)
from Kingdee.BOS import *
from Kingdee.BOS.Core import *
from Kingdee.BOS.Core.Bill import *
from Kingdee.BOS.Core.DynamicForm.PlugIn import *
from Kingdee.BOS.Core.DynamicForm.PlugIn.ControlModel import *
from System import *
from Kingdee.BOS.Orm.DataEntity import *
from Kingdee.BOS.App.Data import *
#重载cloud插件模型的套打干预数据事件
def OnPrepareNotePrintData(e):
if e.DataObjects == None or e.DataObjects.Length ==0:
return;
if e.DataSourceId.Equals("FLIST",StringComparison.OrdinalIgnoreCase):
if not e.DataObjects[0].DynamicObjectType.Properties.ContainsKey("FLEFTAMOUNTFOR"):
return;
objectType = e.DataObjects[0].DynamicObjectType;
if not objectType.Properties.ContainsKey("KD_LastRowVal"):
objectType.RegisterSimpleProperty("KD_LastRowVal",typeof(string));
val = str(e.DataObjects[e.DataObjects.Length-1]["FLEFTAMOUNTFOR"]);
tempList = e.DataObjects;
for index in range(len(e.DataObjects)):
e.DataObjects[index]["KD_LastRowVal"] = val;