Example #1
0
        /// <summary>
        /// 科室列表
        /// </summary>
        /// <param name="keyword">关键字</param>
        /// <returns>返回机构+科室树形Json</returns>
        public ActionResult GetOrganizeTreeJson(string keyword)
        {
            //var organizedata = organizeCache.GetList();
            var organizedata = sysBLL.Get005Orgs(null).ToList();
            //var departmentdata = departmentBLL.GetList();
            var offiecesdata = sysBLL.GetPMR008OffiecesList();
            var treeList     = new List <TreeEntity>();

            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;
                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 = departmentdata.Count(t => t.ParentId == item.DepartmentId) == 0 ? false : true;
                bool hasChildren = false;
                tree.id    = item.ID;
                tree.text  = item.OFFICENAME;
                tree.value = item.ID;
                //if (item.ParentId == "0")
                //{
                //tree.parentId = item.OrganizeId;
                tree.parentId = item.ORGID;
                //}
                //else
                //{
                //    tree.parentId = item.ParentId;
                //}
                tree.isexpand       = true;
                tree.complete       = true;
                tree.hasChildren    = hasChildren;
                tree.Attribute      = "Sort";
                tree.AttributeValue = "Department";
                treeList.Add(tree);
                #endregion
            }
            if (!string.IsNullOrEmpty(keyword))
            {
                treeList = treeList.TreeWhere(t => t.text.Contains(keyword), "id", "parentId");
            }
            return(Content(treeList.TreeToJson()));
        }
Example #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()));
        }