Esempio n. 1
0
        /// <summary>
        /// Asynchronouses the get nodes.
        /// </summary>
        /// <param name="compNum">The comp number.</param>
        /// <param name="myappId">The myapp identifier.</param>
        /// <param name="isClick">if set to <c>true</c> [is click].</param>
        /// <param name="id">The identifier.</param>
        /// <returns>List&lt;Node&gt;.</returns>
        public List<Node> AsyncGetNodes(string compNum, int myappId, bool? click, int? id)
        {
            var filters =
                FunFilterDao.GetList(
                    f => f.MyappId == myappId && (f.CompNum == compNum || f.FilIsSys == 1) && f.ParentId == (id ?? 0))
                    .OrderBy(f => f.FilOrder);
            var nodes = new List<Node>();
            //将filters转换为nodes
            foreach (var filter in filters)
            {
                var node = new Node();
                node.id = filter.Id;
                node.pId = (int) filter.ParentId;
                node.name = filter.FilName;
                node.content = filter.FilWhere;
                node.compNum = compNum;
                node.myappId = myappId;
                node.click = click ?? true;

                bool isHasChild =
                    FunFilterDao.ExistsEntity(
                        f => f.MyappId == myappId && f.ParentId == node.id && (f.CompNum == compNum || f.FilIsSys == 1));
                if (isHasChild)
                {
                    node.isParent = true;
                }

                nodes.Add(node);
            }
            return nodes;
        }
        /// <summary>
        /// 获取树形节点
        /// </summary>
        /// <param name="compNum"></param>
        /// <param name="id"></param>
        /// <returns></returns>
        public List<Node> AsyncGetNodes(string compNum, int? id)
        {
            var departments =
                SysDepartmentDao.GetList(d => d.CompNum == compNum && d.ParentId == (id ?? 0)).OrderBy(d => d.DepOrder);
            var nodes = new List<Node>();
            //将departments转换为nodes
            foreach (var department in departments)
            {
                var node = new Node();
                node.id = department.Id;
                node.pId = department.ParentId;
                node.name = department.DepName;

                bool isHasChild = SysDepartmentDao.ExistsEntity(d => d.ParentId == node.id && d.CompNum == compNum);
                if (isHasChild)
                {
                    node.isParent = true;
                }

                nodes.Add(node);
            }
            return nodes;
        }
Esempio n. 3
0
 public ActionResult AsyncGetNodes(int? id, string type)
 {
     var compNum = Session[teaCRMKeys.SESSION_USER_COMPANY_INFO_NUM].ToString();
     var nodes = SysDepartmentService.AsyncGetNodes(compNum, id);
     //加入根节点
     if (type == "select")
     {
         Node node = new Node()
         {
             id = 0,
             isParent = false,
             name = "顶级分类",
             pId = 0
         };
         nodes.Insert(0, node);
     }
     return Json(nodes);
 }