结合论坛老师的帖子,增加岗位获取的内容,仅获取主任岗。如果代码复制格式不对,可以下载附件来参考。
#参考代码,F_KDXV_PERSON
#引入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 *
empId = 0;
deptId = 0;
postId = 0;
def OnInitialize(e):
userID=str(this.Context.UserId);
sqlGetEmpId = ("""SELECT E.FID,DPL.FDEPTID AS DEPTID,POST.FPOSTID AS POSTID FROM T_SEC_USER U
INNER JOIN T_HR_EMPINFO E ON (U.FLINKOBJECT = E.FPERSONID)
INNER JOIN T_HR_EMPINFO_L EL ON (EL.FID = E.FID AND EL.FLOCALEID = 2052)
INNER JOIN T_BD_STAFF ST ON ST.FEMPINFOID = EL.FID
INNER JOIN T_BD_STAFFPOSTINFO STPP ON STPP.FSTAFFID = ST.FSTAFFID
INNER JOIN T_BD_DEPARTMENT_L DPL ON DPL.FDEPTID = ST.FDEPTID
INNER JOIN T_ORG_POST POST ON POST.FPOSTID = ST.FPOSTID WHERE STPP.FISFIRSTPOST=1
AND U.FUserId={0} """).format(userID);
global empId, deptId,postId;
DataSet = DBServiceHelper.ExecuteDataSet(this.Context,sqlGetEmpId).Tables[0];
empId=DataSet.Rows[0]["FID"] if DataSet.Rows.Count>0 else 0;
deptId=DataSet.Rows[0]["DEPTID"] if DataSet.Rows.Count>0 else 0;
postId=DataSet.Rows[0]["POSTID"] if DataSet.Rows.Count>0 else 0;
def AfterCreateNewData(e):
global empId,deptId;
this.Model.SetItemValueByID("F_KDXV_PERSON", empId, 0); #申请人,需根据表单字段做相应修改
this.Model.SetItemValueByID("F_KDXV_DEPT", deptId, 0); #申请人申请部门,需根据表单字段做相应修改
this.Model.SetItemValueByID("F_KDXV_POSITION", postId, 0); #申请人岗位,需根据表单字段做相应修改
this.View.InvokeFieldUpdateService("F_KDXV_PERSON", 0);
新增单据根据用户获取员工岗位部门.rar(1.11KB)
推荐阅读