表单插件
#引入clr运行库
import clr
#添加对cloud插件开发的常用组件的引用
clr.AddReference('System')
clr.AddReference('System.Data')
clr.AddReference('Kingdee.BOS')
clr.AddReference('Kingdee.BOS.DataEntity')
clr.AddReference('Kingdee.BOS.Core')
clr.AddReference('Kingdee.BOS.App')
clr.AddReference('Kingdee.BOS.App.Core')
clr.AddReference('Kingdee.BOS.ServiceHelper')
#导入cloud基础库中的常用实体对象(分命名空间导入,不会递归导入)
from Kingdee.BOS import *
from Kingdee.BOS.Core import *
from Kingdee.BOS.Core.DependencyRules 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 System.Data import *
from Kingdee.BOS.App.Data import *
from System.Collections.Generic import List
from Kingdee.BOS.ServiceHelper import *
from Kingdee.BOS.Core.DynamicForm import *
from Kingdee.BOS.Core.Metadata.EntityElement import *
from Kingdee.BOS.Core.Metadata.FieldElement import *
from Kingdee.BOS.Orm.DataEntity import *
def EntryBarItemClick(e):
key=e.BarItemKey.ToUpperInvariant();
if(key=="tbBtnToClose".ToUpperInvariant()):
#msg=("单据体菜单[{0}]点击事件捕捉到了,可以继续菜单的功能啦!").format(key);
#this.View.ShowMessage(msg);
#rownum = this.View.Model.GetEntryCurrentRowIndex("FTreeEntity")
#this.View.ShowMessage(str(type(rownum)));
rownum = this.View.GetControl("FTreeEntity").GetSelectedRows();
idList=list()
for i in rownum:
#this.View.ShowMessage(str(i));
idList.append(this.View.Model.DataObject["TreeEntity"][i]["Id"])
this.View.ShowMessage(((','.join(str(j) for j in idList))));
#this.View.Session["MoEntryId"] = ','.join(str(j) for j in idList);
sql = ("""/*dialect*/SELECT FCLOSEREASON FROM T_PRD_MOENTRY_L WHERE FENTRYID={0} """).format('103879')
ds = DBUtils.ExecuteDataSet(this.Context, sql)
#prMeNum =ds.Tables[0].Rows[0]["FNUMBER"]
# prControl = ds.Tables[0].Rows[0]["F_ORA_PRCONTROL"]
# prLimits = ds.Tables[0].Rows[0]["F_ORA_PRLIMITS"]
# prQty = ds.Tables[0].Rows[0]["F_ORA_PRQTY"]
if ds.Tables[0].Rows.Count <1:
#this.View.ShowWarnningMessage("error, no data return!")
#return
#DBUtils.Execute(this.Context, "UPDATE T_PRD_MOENTRY_L SET FCLOSEREASON='aha数据被修改了--' where FENTRYID='103879' ");
DBUtils.Execute(this.Context, "INSERT INTO T_PRD_MOENTRY_L(FPKID, FLOCALEID, FENTRYID, FMEMO, FCLOSEREASON) VALUES((SELECT max(FPKID)+1 FROM T_PRD_MOENTRY_L),'2052','103879', '','aha数据被修改了--') ");
DBUtils.Execute(this.Context, "UPDATE T_PRD_MOENTRY_L SET FCLOSEREASON='lsq修改了数据--' where FENTRYID='103879' ");
this.View.Session["MoEntryId"] = ','.join(str(j) for j in idList);
列表插件
#引入clr运行库
import clr
#添加对cloud插件开发的常用组件的引用
clr.AddReference('System')
clr.AddReference('System.Data')
clr.AddReference('Kingdee.BOS')
clr.AddReference('Kingdee.BOS.Core')
clr.AddReference('Kingdee.BOS.App')
clr.AddReference('Kingdee.BOS.ServiceHelper')
#导入cloud基础库中的常用实体对象(分命名空间导入,不会递归导入)
#clr.AddReference('Kingdee.BOS.KDSReportEntity')
#clr.AddReference('Kingdee.BOS.App.KDSService')
clr.AddReference('Newtonsoft.Json')
#导入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 Kingdee.BOS.Core.List.PlugIn import *
from Kingdee.BOS.Util import *
#from Kingdee.BOS.Web.List import *
from System import *
from System.Data import *
from Kingdee.BOS.App.Data import *
from System.Collections.Generic import List
from System.ComponentModel import *
from Kingdee.BOS.ServiceHelper import *
from Kingdee.BOS.JSON import *
from Newtonsoft.Json.Linq import *
def BarItemClick(e):
# 读取执行时间参数
#btnKey = e.BarItemKey.ToUpper();
dic = {};
dic["clickKey"] = 0
#原文链接:https://vip.kingdee.com/article/109696617229657856?productLineId=1&isKnowledge=2
formId = this.View.BillBusinessInfo.GetForm().Id.ToString()
if (formId == 'PRD_MO'):
#if (FormTitle == "生产订单"):
#sqlTable= 'T_PRD_MOENTRY_L'
dic["billtype"] = 0
#elif (FormTitle == "委外订单"):
elif (formId == 'SUB_SUBREQORDER'):
#sqlTable=1
dic["billtype"] = 1
key=e.BarItemKey.ToUpperInvariant();
if(key=="tbBtnToClose".ToUpperInvariant()):
execDateType = ReadUserParameter("DateGenerateType")
if execDateType <> 1 :
isOk = WriteUserParameter("DateGenerateType", 1)
if not isOk:
raise Exception("用户参数保存失败")
this.ListView.Refresh()
#raise Exception(str(ReadUserParameter("DateGenerateType")))
#formId = this.View.BillBusinessInfo.GetForm().Id
#this.View.ShowMessage(str(formId))
#return
#e.Cancel = True;
selectedRowsInfo = this.ListView.SelectedRowsInfo;
listEntryId=selectedRowsInfo.GetPrimaryKeyValues();
#raise Exception(str(type(listEntryId)))
#datas = this.ListModel.GetData(selectedRowsInfo);
#if (datas.Count <= 0):
# return;
#listEntryId=List[str]();
#for row in selectedRowsInfo:
#selectEntryId=str(row.EntryPrimaryKeyValue);
#entityKey=str(row.EntryEntityKey);
#if(selectEntryId=="" or selectEntryId==None or entityKey<>"FTreeEntity"):
# this.View.ShowWarnningMessage("请在过滤里面显示单据体[FTreeEntity]!");
# return;
#listEntryId.Add(selectEntryId);
#dic["entryId"] = str.Join(",", listEntryId.ToArray());
#raise Exception(str.Join(",", listEntryId))
#raise Exception(str(listEntryId.Count))
if listEntryId.Count >0:
dic["entryId"] = str.Join(",", listEntryId)
#raise Exception(str.Join(",", listEntryId))
this.View.ShowMessage(dic["entryId"])
dic["clickKey"] = 1
this.View.Session["MoEntryId"] = dic
#if (e.BarItemKey == "tbReadUserParameter"):
# auxMustInput = ReadUserParameter("AuxMustInput");
#// var auxMustInput = ReadUserParameter2("AuxMustInput"); // 另一种读取用户参数的方法
# this.View.ShowMessage("用户参数【辅助属性必录】:" + str(auxMustInput));
# return;
#if (e.BarItemKey == "tbWriteUserParameter"):
# isOk = WriteUserParameter("AuxMustInput", True);
# this.View.ShowMessage( "用户参数保存成功" if isOk else "用户参数保存失败");
# return;
def ReadUserParameter(parameterName):
#// 获取用户参数的业务对象标识
formId = this.View.BillBusinessInfo.GetForm().ParameterObjectId;
if (formId == None or formId.Trim().Length == 0):
formId = FormIdConst.BOS_BillUserParameter;
formMetadata = FormMetaDataCache.GetCachedFormMetaData(this.Context, formId);
#// 读取用户参数包
parameterData = UserParamterServiceHelper.Load(this.Context, formMetadata.BusinessInfo, this.Context.UserId, this.View.BillBusinessInfo.GetForm().Id, KeyConst.USERPARAMETER_KEY);
#// 从用户参数包中获取某一个参数
if (parameterData != None and parameterData.DynamicObjectType.Properties.Contains(parameterName)):
return parameterData[parameterName];
return ;
def WriteUserParameter(parameterName, parameterValue):
#// 获取用户参数的业务对象标识
formId = this.View.BillBusinessInfo.GetForm().ParameterObjectId;
if (formId == None or formId.Trim().Length == 0):
formId = FormIdConst.BOS_BillUserParameter;
formMetadata = FormMetaDataCache.GetCachedFormMetaData(this.Context, formId);
#// 读取用户参数包
parameterData = UserParamterServiceHelper.Load(this.Context, formMetadata.BusinessInfo, this.Context.UserId, this.View.BillBusinessInfo.GetForm().Id, KeyConst.USERPARAMETER_KEY);
#// 从用户参数包中获取某一个参数
if (parameterData != None and parameterData.DynamicObjectType.Properties.Contains(parameterName)):
#// 保存用户参数
parameterData[parameterName] = parameterValue;
return UserParamterServiceHelper.Save(this.Context, formMetadata.BusinessInfo, parameterData, this.View.BillBusinessInfo.GetForm().Id, this.Context.UserId, KeyConst.USERPARAMETER_KEY);
return false;
设置执行时间插件
import clr
clr.AddReference("Kingdee.BOS")
clr.AddReference("Kingdee.BOS.Core")
clr.AddReference("Kingdee.BOS.App")
from Kingdee.BOS.App.Data import *
from Kingdee.BOS import *
from System import *
global execflag
def AfterBindData(e):
global execflag
#obj = this.View.Session
#moentryId = 1
reciveList = {}
reciveList=this.View.ParentFormView.Session["MoEntryId"]
#moentryId = reciveList["entryId"]
execflag = (reciveList["clickKey"]).ToString()
#raise Exception(str(execflag))
#obj = this.View.ParentFormView.Session
#if (obj.ContainsKey("MoEntryId")):
#if (ojb.TryGetValue("MoEntryId", moentryId))
# execflag = 1
#else:
if (execflag == '0'):
#raise Exception("没有传递MoEntryId")
this.View.GetControl("F_ora_CloseReason").Visible = False
def ButtonClick(e):
global execflag
key=e.Key.ToUpperInvariant();
selectedDate = this.Model.GetValue("FDate")
reciveList = {}
if(key=="FButton".ToUpperInvariant() and execflag == '1'):
#reciveList=this.View.ParentFormView.Session["MoEntryId"]
#moentryId = reciveList["entryId"]
#exeAction = reciveList["clickKey"]
#reciveList = {}
reciveList=this.View.ParentFormView.Session["MoEntryId"]
moentryId = reciveList["entryId"]
exeAction = reciveList["clickKey"]
closeReason = this.View.Model.GetValue("F_ora_CloseReason").ToString()
billType = reciveList["billtype"]
if (billType == 0):
sqlTable= 'T_PRD_MOENTRY'
#fieldRemarks = 'FMEMO'
elif (billType == 1):
sqlTable= 'T_SUB_REQORDERENTRY'
#fieldRemarks = 'FDESCRIPTION'
#moentryId=this.View.ParentFormView.Session["MoEntryId"]
selectedRowsNum = len(str(moentryId).split(','))
idList = moentryId.split(',')
#this.View.ShowWarnningMessage(str(type(moentryId)))
#moentryId = ','.join(idList)
if 1 ==1 :
#sql = ("""/*dialect*/SELECT FCLOSEREASON FROM T_PRD_MOENTRY_L WHERE FENTRYID={0} """).format('103879')
#maxLineSql = ("""/*dialect*/SELECT max(FPKID) FROM T_PRD_MOENTRY_L """
#maxlineDs = DBUtils.ExecuteScalar(this.Context, """/*dialect*/SELECT max(FPKID) FROM {0} """.format(sqlTable), 0)
#this.View.ShowMessage(str(maxlineDs))
#sqlTable="T_PRD_MOENTRY";
sql = ("""/*dialect*/SELECT FID, FENTRYID FROM {1} WHERE FENTRYID in ({0}) """).format(str(moentryId), sqlTable)
ds = DBUtils.ExecuteDataSet(this.Context, sql)
markedNum = ds.Tables[0].Rows.Count
#prMeNum =ds.Tables[0].Rows[0]["FNUMBER"]
# prControl = ds.Tables[0].Rows[0]["F_ORA_PRCONTROL"]
# prLimits = ds.Tables[0].Rows[0]["F_ORA_PRLIMITS"]
# prQty = ds.Tables[0].Rows[0]["F_ORA_PRQTY"]
updateList = list()
#insertList = list()
if markedNum >0:
#this.View.ShowWarnningMessage("error, no data return!")
#return
#iLst=''
#this.View.ShowMessage(str(markedNum))
for j in range(0,markedNum):
updateList.append(str(ds.Tables[0].Rows[j]["FENTRYID"]))
#this.View.ShowMessage(str(markedNum) + ','.join(updateList))
DBUtils.Execute(this.Context, ("UPDATE {2} SET F_ORA_CLOSEREASON='---{0}--' where FENTRYID in ({1}) ").format(closeReason, ','.join(updateList), sqlTable));
#DBUtils.Execute(this.Context, ("UPDATE T_PRD_MOENTRY_L SET F_THRI_CLOSEREASON='{0}' where FENTRYID in ({1}) ").format('|'.join(idList), ','.join(idList)));
#DBUtils.Execute(this.Context, ("""/*dialect*/INSERT INTO T_PRD_MOENTRY_L(FPKID, FLOCALEID, FENTRYID, FMEMO, FCLOSEREASON,F_THRI_CLOSEREASON) VALUES {0} """).format(','.join(insertValues)))
#
#insertList = list(set(idList).difference(set(updateList)))
#if len(insertList) > 0:
# insertValues = list()
# for v in insertList:
# maxlineDs = maxlineDs + 1
# insertValues.append("('{0}','2052', '{1}', '', '', '{2}')".format(maxlineDs, v,closeReason))
#this.View.ShowMessage('|'.join(insertValues))
# DBUtils.Execute(this.Context, ("""/*dialect*/INSERT INTO {1}(FPKID, FLOCALEID, FENTRYID,{2}, FCLOSEREASON,F_ORA_CLOSEREASON) VALUES {0} """).format(','.join(insertValues), sqlTable, fieldRemarks))
#this.View.ShowWarnningMessage
this.View.ReturnToParentWindow(selectedDate)
#this.View.ReturnToParentWindow(executeRemarks)