PYTHON 根据单据体字段自定义套打原创
金蝶云社区-zg_d1v
zg_d1v
6人赞赏了该文章 1077次浏览 未经作者许可,禁止转载编辑于2020年08月09日 13:18:45

#引入clr运行库

import clr

#添加对cloud插件开发的常用组件的引用

clr.AddReference('System')

clr.AddReference('Kingdee.BOS')

clr.AddReference('Kingdee.BOS.Core')

clr.AddReference('Kingdee.BOS.DataEntity')

clr.AddReference('Kingdee.BOS.Contracts')

clr.AddReference("Kingdee.BOS.ServiceHelper")


from System import *  

from System.ComponentModel import *

from Kingdee.BOS.Core.BusinessFlow.PlugIn import *

from Kingdee.BOS.Core.Bill.PlugIn import *

from Kingdee.BOS.Core.Metadata.EntityElement import *

from Kingdee.BOS.Orm.DataEntity import *

from Kingdee.BOS.Orm.Metadata.DataEntity import *

from Kingdee.BOS.Core.DynamicForm.PlugIn.Args import *

from Kingdee.BOS.ServiceHelper import * 


#def OnLoad(e):

# this.View.ShowMessage("helloworld!" + str(DateTime.Today));#注意缩进,用tab键即可

 

#def EntityRowClick(e): 

# entity = this.Model.BillBusinessInfo.GetEntity("FEntity")

# row = this.Model.GetEntityDataObject(entity, e.Row)

# val = row["F_CSG_PRODNAME"]

# this.View.ShowMessage(str(val["FNumber"]))

#def DataChanged(e):

# if(e.Field.Key.upper()=="F_CSG_REDAMOUNT" or e.Field.Key.upper()=="F_CSG_BASEAMOUNT" or e.Field.Key.upper()=="F_CSG_CK"):

# this.Model.SetValue("F_CSG_AMOUNTSUM",999)

# printtype=int(this.Model.GetValue("F_CSG_CK", e.Row)) 

def BeforeSave(e):

this.Model.SetValue("F_CSG_Decimal",0)

rows=this.Model.GetEntryRowCount("FEntity")

amountsum=0

for irow in range(0,rows):

if(int(this.Model.GetValue("F_CSG_CK", irow))==0):

amountsum=amountsum+float(this.Model.GetValue("F_CSG_BASEAMOUNT", irow)) 

if(int(this.Model.GetValue("F_CSG_CK", irow))==1):

amountsum=amountsum+float(this.Model.GetValue("F_CSG_REDAMOUNT", irow)) 

this.Model.SetValue("F_CSG_AMOUNTSUM",amountsum)

def OnPrepareNotePrintData(e):

if (e.DataSourceId.Equals("FEntity", StringComparison.OrdinalIgnoreCase)):

_count =  e.DataObjects.Count

entity = this.Model.BillBusinessInfo.GetEntity("FEntity")

dot = e.DataObjects[0].DynamicObjectType

dot.RegisterSimpleProperty("CSGPRICE", float,None,False,[])

dot.RegisterSimpleProperty("CSGAMOUNT", float,None,False,[]) 

for i in range(0,_count):

obj = DynamicObject(dot)

for p in  e.DataObjects[i].DynamicObjectType.Properties:

obj[p] = e.DataObjects[i][p]

printtype=int(this.Model.GetEntityDataObject(entity, i)["F_CSG_CK"]) 

redprice=float(this.Model.GetEntityDataObject(entity, i)["F_CSG_REDPRICE"]) 

redamount=float(this.Model.GetEntityDataObject(entity, i)["F_CSG_REDAMOUNT"]) 

baseprice=float(this.Model.GetEntityDataObject(entity, i)["F_CSG_BASEPRICE"]) 

baseamount=float(this.Model.GetEntityDataObject(entity, i)["F_CSG_BASEAMOUNT"]) 

# this.View.ShowMessage(str(printtype))

if(printtype==0):

obj["CSGPRICE"]=baseprice

obj["CSGAMOUNT"]=baseamount

if(printtype==1):

obj["CSGPRICE"]=redprice

obj["CSGAMOUNT"]=redamount

e.DataObjects[i] = obj


赞 6