组织架构图控件的使用样例(一)

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

组织架构图控件的使用样例(一)

# **效果图:** ![image.webp](/download/0100210f1b54a25a4f24915a81ca7a4f6a65.webp) # 样例代码 ``` JSONObject _defaultCreateOrg = new JSONObject(); JSONObject tempOrgObj = new JSONObject(); public void getRoot() { tempOrgObj = new JSONObject(); tempOrgObj["CorpOrgType"] = "2"; tempOrgObj["Id"] = "1"; tempOrgObj["Number"] = "genNumber"; tempOrgObj["Name"] = "genName"; tempOrgObj["OrgFormID"] = "genOrgFormID"; tempOrgObj["Address"] = "gengenAddress"; tempOrgObj["Contract"] = "genContact"; tempOrgObj["Tel"] = "genTel"; tempOrgObj["PostCode"] = "genPostCode"; tempOrgObj["Description"] = "genDescription"; tempOrgObj["SourceOrgId"] = "genId"; tempOrgObj["OrgFunctions"] = "OrgFunctions"; _defaultCreateOrg = tempOrgObj; } private List _topOrgs = new List(); private void GenOrgPic() { getRoot(); DrawPic(); } private void DrawPic() { JSONObject obj = new JSONObject(); JSONObject OrgChartXml = new JSONObject(); OrgChartXml["PreViewMode"] = "A"; OrgChartXml["ShowMode"] = "A"; OrgChartXml["ForbidExpanedEvent"] = false; OrgChartXml["IsShowLeaderName"] = false; OrgChartXml["IsShowLeaderNo"] = false; OrgChartXml["IsShowLeaderPost"] = false; OrgChartXml["IsShowLeaderPhoto"] = false; OrgChartXml["UpdateDeptNames"] = null; OrgChartXml["UpdatePostName"] = null; OrgChartXml["LeaderPhoto"] = null; OrgChartXml["IsShowPhoto"] = null; JSONArray jarrayChart = new JSONArray(); JSONObject topOrgChart = new JSONObject(); topOrgChart["fdeptid"] = _defaultCreateOrg["Id"]; topOrgChart["fdepth"] = 1; topOrgChart["fisroot"] = 1; topOrgChart["fparentid"] = 0; topOrgChart["fname"] = "根目录"; jarrayChart.Add(topOrgChart); JSONObject orgChart = new JSONObject(); for (int i = 0; i < 2; i++) { orgChart = new JSONObject(); orgChart["fdeptid"] = "Id" + (i + 1); orgChart["fdepth"] = 2;//important orgChart["fisroot"] = 0; orgChart["fparentid"] = _defaultCreateOrg["Id"]; orgChart["fname"] = "Name" + (i + 1); jarrayChart.Insert(0, orgChart); DrawChildPic(orgChart, jarrayChart, 3); } OrgChartXml["OrgChartXml"] = jarrayChart; OrgChartXml["ShowDepth"] = 4;//自动展开多少层级 OrgChartXml["PerImgVisible"] = false; obj["orgchartmetadata"] = OrgChartXml; this.View.GetControl("FFOrgChart").InvokeControlMethod("SetOrgChartXml", obj); this.View.GetControl("FFOrgChart").SetCustomPropertyValue("AllowDrop", false); this.View.GetControl("FFOrgChart").SetCustomPropertyValue("DiagramEnable", false); } private void DrawChildPic(JSONObject parentOrg, JSONArray jarrayChart, int depth) { JSONObject childOrgChart = new JSONObject(); for (int i = 0; i < 2; i++) { childOrgChart = new JSONObject(); childOrgChart["fdeptid"] = Guid.NewGuid(); childOrgChart["fdepth"] = int.Parse(parentOrg["fdepth"].ToString()) + 1; childOrgChart["fisroot"] = 0; childOrgChart["fparentid"] = parentOrg["fdeptid"]; childOrgChart["fname"] = parentOrg["fname"].ToString() + "child" + i; jarrayChart.Insert(0, childOrgChart); DrawChildPicF(childOrgChart, jarrayChart, 4); } } private void DrawChildPicF(JSONObject parentOrg, JSONArray jarrayChart, int depth) { JSONObject childOrgChart = new JSONObject(); for (int i = 0; i < 4; i++) { childOrgChart = new JSONObject(); childOrgChart["fdeptid"] = Guid.NewGuid(); childOrgChart["fdepth"] = int.Parse(parentOrg["fdepth"].ToString()) + 1; childOrgChart["fisroot"] = 0; childOrgChart["fparentid"] = parentOrg["fdeptid"]; childOrgChart["fname"] = parentOrg["fname"].ToString() + "child" + i; jarrayChart.Insert(0, childOrgChart); } } ``` 调用入口:GenOrgPic()即可,其中“FFOrgChart”表示是组织架构图控件

组织架构图控件的使用样例(一)

# **效果图:**![image.webp](/download/0100210f1b54a25a4f24915a81ca7a4f6a65.webp)# 样例代码```JSONObject _defaultCreateOrg = n...
点击下载文档
确认删除?
回到顶部
客服QQ
  • 客服QQ点击这里给我发消息