【金蝶云星空插件二开】Python表单插件获取当前用户对应的员工、部门、岗位信息

栏目:云星空知识作者:金蝶来源:金蝶云社区发布:2024-09-16浏览:2

【金蝶云星空插件二开】Python表单插件获取当前用户对应的员工、部门、岗位信息

需求:在开发过程中往往会有根据当前用户所属部门这个条件来处理一些业务,那么如何获取呢? 参考: [Python表单插件获取用户对应的员工和部门](https://wenku.my7c.com/article/228220205460000768?productLineId=1&lang=zh-CN) [Python根据用户获取员工,岗位,部门](https://wenku.my7c.com/article/259391473269731584) 表单插件注册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 * empId = 0 deptId = 0 def OnInitialize(e): userID = str(this.Context.UserId) sqlGetEmpId = ( """SELECT E.FID,DPL.FDEPTID AS DEPTID 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 ZG ON ZG.FSTAFFID=ST.FSTAFFID INNER JOIN T_BD_DEPARTMENT_L DPL ON DPL.FDEPTID = ST.FDEPTID WHERE ZG.FISFIRSTPOST='1' AND U.FUserId={0} """ ).format(userID) global empId, deptId 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 def AfterCreateNewData(e): global empId, deptId # 申请人,需根据表单字段做相应修改 (单据上的字段) this.Model.SetItemValueByID("F_EmpId", empId, 0) # 申请部门,需根据表单字段做相应修改(单据上的字段) this.Model.SetItemValueByID("F_DeptId", deptId, 0) ```

【金蝶云星空插件二开】Python表单插件获取当前用户对应的员工、部门、岗位信息

需求:在开发过程中往往会有根据当前用户所属部门这个条件来处理一些业务,那么如何获取呢?参考:[Python表单插件获取用户对应的员工和部...
点击下载文档
确认删除?
回到顶部
客服QQ
  • 客服QQ点击这里给我发消息