function TRYXX.GetSubordinations: TStrings;
var
i : integer;
s : string;
lOperator : TOPerator;
lPersonMember: TOrgUnit;
lSubs : TStrings;
ResultUrls :Tstrings;
begin
ResultUrls:=TStringlist.Create;//隐式向上转型
try
lOperator := TContextUtils.GetOperator(Context);//取出操作者
for i := 0 to lOperator.PositionCount-1 do //取出操作者所属岗位
begin
lPersonMember := lOperator.Positions.PersonMember;//取出所属岗位对应的人员成员
lSubs := GetSubordinations(lPersonMember);//取出该人员成员对应的管理权限
{1
if lSubs.Count = 1 then
if ResultUrls.IndexOf(lSubs[0]) < 0 then
ResultUrls.Add(lSubs[0]);
if lSubs.Count > 1 then
ResultUrls.AddStrings(lSubs);}
{2}
ResultUrls.AddStrings(lSubs);
lSubs.Free;
end;
finally
{2}
for i := ResultUrls.Count-1 downto 0 do
begin //取出人员成员截取后四位并大写
s := SysUtils.UpperCase(StringUtils.Copy(ResultUrls, Length(ResultUrls)-3, 4));
if (ResultUrls.Count > 1) and (s = '.PSM') then
ResultUrls.Delete(i);
end;
Result := ResultUrls;
end;
end;
function TRYXX.GetSubordinations(APersonMember: TOrgUnit): TStrings;//定义根据人员成员参数获得其管理权限的函数
var
lOrgUnit : TOrgUnit;
lOrgSubordinationItems : TOrgSubordinationItems;
i : integer;
ResultUrls : TStrings;
begin
ResultUrls := TStringList.Create;
lOrgSubordinationItems := TOrgSubordinationItems.Create;//定义TOrgSubordinationItems对象,里面存储一个下属列表
try
OrgSys.OrgSystem.GetAllSubordinationItems(APersonMember, lOrgSubordinationItems);
if lOrgSubordinationItems.Count > 0 then
for i := 0 to lOrgSubordinationItems.Count-1 do
begin
lOrgUnit := OrgSys.OrgSystem.FindUnit(lOrgSubordinationItems.DeptID,
lOrgSubordinationItems.PositionID, lOrgSubordinationItems.PersonID);
ResultUrls.Add(lOrgUnit.BizUrl.URL);
end
else ResultUrls.Add(APersonMember.BizUrl.URL);
finally
lOrgSubordinationItems.Free;
Result := ResultUrls;
end;
end;