当我们在单据上加了员工字段后,需要在打开单据新增界面时自动带出当前用户对应的员工,可按照以下方法实现。
实现方法:
1.在BOS中打开对应的单据。
2.在【表单插件】中注册Python脚本。
网页复制代码会有格式问题,如需复制,请下载附件!
#参考代码
#引入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基础库中的常用实体对象(分命名空间导入,不会递归导入)
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 System.Data import *
from Kingdee.BOS.App.Data import *
from System.Collections.Generic import List
from Kingdee.BOS.ServiceHelper import *
#重载cloud插件模型的主菜单按钮点击事件
empId = 0;
def OnInitialize(e):
userID=str(this.Context.UserId);
sqlGetEmpId = (""" select E.FID, E_L.FNAME, P.FPERSONID, U.FUSERID, U.FNAME
from T_SEC_USER U
inner join t_BD_Person P ON (u.FLINKOBJECT = P.FPERSONID)
inner join T_HR_EmpInfo E ON (P.FPERSONID = E.FPERSONID)
left join T_HR_EmpInfo_L E_L ON (E.FID = E_L.FID AND E_L.FLOCALEID = 2052)
where U.FUserId ={0} """).format(userID);
global empId;
ds = DBServiceHelper.ExecuteDataSet(this.Context,sqlGetEmpId);
tab = ds.Tables[0];
empId=tab.Rows[0]["FID"] if tab.Rows.Count>0 else 0;
def AfterCreateNewData(e):
global empId;
this.Model.SetItemValueByID("F_EmpId", empId, 0);#根据实际情况在此修改员工字段标识
获取当前用户对应的员工.rar(0.90KB)