Exemple #1
0
        public ActionResult GetTreeJson(string value)
        {
            string parentId = value == null ? "ROOT" : value;
            //var filterdata = areaBLL.GetList(parentId).ToList();
            var           filterdata = sysBLL.GetPMR002MorDeptList(parentId).ToList();
            StringBuilder sb         = new StringBuilder();

            sb.Append("[");
            if (filterdata.Count > 0)
            {
                foreach (PMR002MorDeptEntity item in filterdata)
                {
                    bool hasChildren = sysBLL.GetPMR002MorDeptList(item.DEPTID).ToList().Count == 0 ? false : true;
                    sb.Append("{");
                    sb.Append("\"id\":\"" + item.DEPTID + "\",");
                    sb.Append("\"text\":\"" + item.DEPTNAME + "\",");
                    sb.Append("\"value\":\"" + item.DEPTID + "\",");
                    sb.Append("\"isexpand\":false,");
                    sb.Append("\"complete\":false,");
                    sb.Append("\"hasChildren\":" + hasChildren.ToString().ToLower() + "");
                    sb.Append("},");
                }
                sb = sb.Remove(sb.Length - 1, 1);
            }
            sb.Append("]");
            return(Content(sb.ToString()));
        }
Exemple #2
0
        /// <summary>
        /// 科室列表
        /// </summary>
        /// <param name="keyword">关键字</param>
        /// <returns>返回机构+科室树形Json</returns>

        #region 获取数据
        public ActionResult GetMorTreeJson(string value)
        {
            var    mordata      = sysBLL.GetOrgs(null).ToList();
            string parentId     = value == null ? "ROOT" : value;
            var    orgdata      = sysBLL.GetPMR002MorDeptList(parentId).ToList();
            var    organizedata = sysBLL.Get005Orgs(null).ToList();
            var    offiecesdata = sysBLL.GetPMR008OffiecesList();
            var    treeList     = new List <TreeEntity>();

            foreach (PMR001MorEntity item in mordata)
            {
                #region 机构
                TreeEntity tree        = new TreeEntity();
                bool       hasChildren = false;
                if (hasChildren == false)
                {
                    hasChildren = orgdata.Count(t => t.ORGID == item.ORGID) == 0 ? false : true;
                    if (hasChildren == false)
                    {
                        hasChildren = organizedata.FirstOrDefault() != null;
                        if (hasChildren == false)
                        {
                            continue;
                        }
                    }
                }
                tree.id          = item.ORGID;
                tree.text        = item.ORGNAME;
                tree.value       = item.ORGID;
                tree.parentId    = item.PID == "ROOT" ? "0" : item.PID;
                tree.isexpand    = true;
                tree.complete    = true;
                tree.hasChildren = hasChildren;
                tree.Attribute   = "Sort";
                //tree.AttributeValue = "Organize-" + item.ID;
                tree.AttributeValue = "Mor";
                treeList.Add(tree);
                #endregion
            }
            foreach (PMR002MorDeptEntity item in orgdata)
            {
                #region 部门
                TreeEntity tree        = new TreeEntity();
                bool       hasChildren = orgdata.Count(t => t.PARENTDEPT == item.DEPTID) == 0 ? false : true;
                tree.id    = item.DEPTID;
                tree.text  = item.DEPTNAME;
                tree.value = item.DEPTID;
                if (item.PARENTDEPT == "ROOT")
                {
                    tree.parentId = item.ORGID;
                }
                else
                {
                    tree.parentId = item.PARENTDEPT;
                }
                tree.isexpand    = true;
                tree.complete    = true;
                tree.hasChildren = hasChildren;
                tree.Attribute   = "Sort";
                //tree.AttributeValue = "Department-" + item.ORGID;
                tree.AttributeValue = "Department";
                treeList.Add(tree);
                #endregion
            }

            foreach (PMR005OrgEntity item in organizedata)
            {
                #region 机构
                TreeEntity tree        = new TreeEntity();
                bool       hasChildren = organizedata.Count(t => t.PARENTORG == item.ORGCODE) == 0 ? false : true;
                if (hasChildren == false)
                {
                    hasChildren = offiecesdata.Count(t => t.ORGID == item.ORGID) == 0 ? false : true;
                    if (hasChildren == false)
                    {
                        continue;
                    }
                }
                tree.id    = item.ORGCODE;
                tree.text  = item.MANAGERORGNAME;
                tree.value = item.ORGCODE;
                //tree.parentId = item.PARENTORG;
                //tree.parentId = item.PARENTORG == "ROOT" ? "0" : item.PARENTORG;
                if (item.PARENTORG == "ROOT")
                {
                    if (mordata != null && mordata.Count > 0)
                    {
                        tree.parentId = mordata.FirstOrDefault().ORGID;
                    }
                    else
                    {
                        tree.parentId = "0";
                    }
                }
                else
                {
                    tree.parentId = item.PARENTORG;
                }
                tree.isexpand       = true;
                tree.complete       = true;
                tree.hasChildren    = hasChildren;
                tree.Attribute      = "Sort";
                tree.AttributeValue = "Organize";
                treeList.Add(tree);
                #endregion
            }
            foreach (PMR008OffiecesEntity item in offiecesdata)
            {
                #region 部门
                TreeEntity tree        = new TreeEntity();
                bool       hasChildren = false;
                tree.id             = item.ID;
                tree.text           = item.OFFICENAME;
                tree.value          = item.ID;
                tree.parentId       = item.ORGID;
                tree.isexpand       = true;
                tree.complete       = true;
                tree.hasChildren    = hasChildren;
                tree.Attribute      = "Sort";
                tree.AttributeValue = "Department";
                treeList.Add(tree);
                #endregion
            }
            return(Content(treeList.TreeToJson()));
        }