procedure TMainForm.ShowOperatorInOrg;
var
lContextCurrent: TContextCurrent;
lOrgUnit: TOrgUnit;
lBizNode: TBizNode;
lBizURL: TBizURL;
begin
// 取当前登陆者机构
lContextCurrent := Business.Model.TContextCurrent.Create(Self.Context);
try
lOrgUnit := OrgSys.OrgSystem.GetUnit(lContextCurrent.Organ.ID, '', '');
lBizURL := lOrgUnit.BizURL; // 取得机构的URL
finally
lContextCurrent.Free;
end;
OrgTreeView1.StartWithNodes.Clear; // 清除机构树
// 找出机构对应节点作为树根
lBizNode := BizTree.BizTreeStructure.FindNodeByBizURL(lBizURL);
if lBizNode <> nil then
OrgTreeView1.StartWithNodes.AddObject(lBizNode.GUID, lBizNode);
OrgTreeView1.ReloadTree;
//只显示到岗位,在ReloadTree前加一句:
OrgTreeView1.ShowOptions := OrgTreeView1.ShowOptions -[TBizObjectKind.boPersonMember];
//只显示到部门:
OrgTreeView1.ShowOptions := OrgTreeView1.ShowOptions -
[TBizObjectKind.boPositionMember, TBizObjectKind.boPersonMember];
end; |