金蝶云 python脚本 维度关联字段赋值之辅助属性
1.操作Model逐个维度进行赋值
引用库存在多余的引用不影响功能,自行选择是否删除。
import clr
clr.AddReference("System")
clr.AddReference("System.Data")
clr.AddReference("System.XML")
clr.AddReference("System.Web.Extensions")
#clr.AddReference("Kingdee.BOS")
clr.AddReference("Kingdee.BOS.Core")
clr.AddReference("Kingdee.BOS.DataEntity")
clr.AddReference("Kingdee.BOS.ServiceHelper")
clr.AddReference("Newtonsoft.Json")
clr.AddReference("Kingdee.BOS.Contracts")
clr.AddReference("Kingdee.BOS.App")
clr.AddReference("System.Web")
clr.AddReference("Kingdee.BOS.WebApi.Client")
clr.AddReference("Kingdee.BOS.Model")
import sys
from System import *
from System.IO import *
from System.Net import *
from System.Web import *
from System.Text import *
from System.Threading import *
from System.Globalization import *
from System.Security.Cryptography import *
from System.Web.Script.Serialization import *
from System.Collections.Generic import List as syslist
from System.Collections.Generic import Dictionary
from Newtonsoft.Json.Linq import *
from Kingdee.BOS.Contracts import *
from Kingdee.BOS.Core.List import *
from Kingdee.BOS.Core.CommonFilter import *
from Kingdee.BOS.Contracts.Report import *
from Kingdee.BOS.Core.Report import ISysReportView
from Kingdee.BOS.Core.Report import ReportTitles
from Kingdee.BOS.App import ServiceHelper as ServiceHelperAPP
from Kingdee.BOS.Orm.Metadata.DataEntity import *
#from Kingdee.BOS import *
from Kingdee.BOS.Model.DynamicForm import *
from Kingdee.BOS.WebApi.Client import *
from Kingdee.BOS.Core.List.PlugIn import *
from Kingdee.BOS.Core.Log import *
from Kingdee.BOS.Core import *
from Kingdee.BOS.Core.DynamicForm import *
from Kingdee.BOS.Orm import OperateOption
from Kingdee.BOS.Core import *
from Kingdee.BOS.Core.DynamicForm import *
from Kingdee.BOS.DataEntity import *
from Kingdee.BOS.Orm.DataEntity import *
from Kingdee.BOS.Core.Bill import *
from Kingdee.BOS.Core.Bill.PlugIn import *
from Kingdee.BOS.ServiceHelper import *
from Kingdee.BOS.Core.Interaction import KDInteractionException
from Kingdee.BOS.Core.Metadata.EntityElement import *
from Kingdee.BOS.Core.Metadata import BusinessInfo
from Kingdee.BOS.Core.Metadata import SelectorItemInfo ##字段选择实体类
from Kingdee.BOS.Core.SqlBuilder import QueryBuilderParemeter ##查询参数实体类
from Kingdee.BOS.Core.DynamicForm.PlugIn import *
from Kingdee.BOS.Core.DynamicForm.PlugIn.Args import *
from Kingdee.BOS.Orm.Metadata.DataEntity import *
from Kingdee.BOS.Core.Metadata import *
from Kingdee.BOS.Core.Metadata.FieldElement import *
#修改默认编码为utf8
reload(sys)
sys.setdefaultencoding('utf-8')
def _Zstr(a):
return ("" if a==None else (a if isinstance(a,str) else str(a)));
def DataChanged(e):
try:
if e.Field.Key.upper()=="F_SHText".upper() or e.Field.Key.upper()=="F_LHText".upper() or e.Field.Key.upper()=="F_CDText".upper() or e.Field.Key.upper()=="F_DTGGText".upper():
#单据体
F_SHText=this.View.Model.GetValue("F_SHText",e.Row)
F_LHText=this.View.Model.GetValue("F_LHText",e.Row)
F_CDText=this.View.Model.GetValue("F_CDText",e.Row)
F_DTGGText=this.View.Model.GetValue("F_DTGGText",e.Row)
#this.View.Model.SetItemValueByIDFromClient("$$FBAUXPROPID__FF100001","" if F_SHText==None else F_SHText,e.Row);
##this.View.Model.SetItemValueByIDFromClient("$$FBAUXPROPID__FF100002","" if F_LHText==None else F_LHText,e.Row);
#this.View.Model.SetItemValueByIDFromClient("$$FBAUXPROPID__FF100003","" if F_CDText==None else F_CDText,e.Row);
#this.View.Model.SetItemValueByIDFromClient("$$FBAUXPROPID__FF100004","" if F_DTGGText==None else F_DTGGText,e.Row);
this.Model.SetFlexValue(this.View.BillBusinessInfo.GetField("FBAUXPROPID"), "$$FBAUXPROPID__FF100001", "" if F_SHText==None else F_SHText, e.Row);
this.Model.SetFlexValue(this.View.BillBusinessInfo.GetField("FBAUXPROPID"), "$$FBAUXPROPID__FF100002", "" if F_LHText==None else F_LHText, e.Row);
this.Model.SetFlexValue(this.View.BillBusinessInfo.GetField("FBAUXPROPID"), "$$FBAUXPROPID__FF100003", "" if F_CDText==None else F_CDText, e.Row);
this.Model.SetFlexValue(this.View.BillBusinessInfo.GetField("FBAUXPROPID"), "$$FBAUXPROPID__FF100004", "" if F_DTGGText==None else F_DTGGText, e.Row);
this.View.UpdateView("$$FBAUXPROPID__FF100001", e.Row);
this.View.UpdateView("$$FBAUXPROPID__FF100002", e.Row);
this.View.UpdateView("$$FBAUXPROPID__FF100003", e.Row);
this.View.UpdateView("$$FBAUXPROPID__FF100004", e.Row);
this.View.UpdateView("FBAUXPROPID", e.Row);
except Exception as e:
raise Exception("错误:"+e.ToString());