szhtest 发表于 2024-4-20 13:51:43

人员控件 排除脚本 如何一次性剔除部门下属的人

本帖最后由 szhtest 于 2024-4-22 10:37 编辑

this.define("getOrgUserList", function(departments) {
    let allResults = [];// 用于存储所有处理后的结果

    for (let dept of departments) {
      var userList = this.org.listIdentityWithUnit(dept.orgName);
      var returnUserList = [];

      if (userList.length > 0 && dept.exceptUserList.length > 0) {
            returnUserList = userList.filter(user => !dept.exceptUserList.includes(user.distinguishedName));
      } else {
            returnUserList = userList;
      }

      // 将处理后的用户名添加到结果数组
      allResults.push(...returnUserList.map(user => user.distinguishedName));
    }

    return allResults;
}, true);

//设置数字化经办人
var szh_distinguishedNames = this.org.listIdentityWithPerson(['admin','S2726','S2004']).map(identity => identity.distinguishedName);
//设置品管经办人
var pg_distinguishedNames = this.org.listIdentityWithPerson(['S1888','S0244','S0932']).map(identity => identity.distinguishedName);




var departmentData = [
    { orgName: 'Z', exceptUserList: szh_distinguishedNames },
    { orgName: 'C', exceptUserList: pg_distinguishedNames }

];


var results = this.getOrgUserList(departmentData);
return results



目前是在人员控件的排除脚本中写出了如上代码,现在传入部门唯一编码、想保留的员工的唯一标识后,就能正常剔除departmentData外每个部门的其他人。
但现在发现一个问题,但凡人员A是属于整个部门下面的1组,该部门就没有剔除他,如何解决?我该如何修改我的代码使部门下级的人,也能当做是此部门的人员做正常剔除?有些部门下属有组,有些部门下属是没有的


已解决:
页: [1]
查看完整版本: 人员控件 排除脚本 如何一次性剔除部门下属的人