Ejemplo n.º 1
0
        public ActionResult GetSysDep(string id)
        {
            var model = depService.GetList(r => r.ID == id).Select(r => new SysDepViewModel
            {
                ID          = r.ID,
                Name        = r.Name,
                ParentID    = r.ParentID,
                ParentName  = r.Parent == null ? "" : r.Parent.Name,
                IsAvailable = r.IsAvailable,
                AddBy       = r.AddBy,
                AddDate     = r.AddDate,
                SortNo      = r.SortNo,
            }).FirstOrDefault();

            return(Json(model, JsonRequestBehavior.AllowGet));
        }
Ejemplo n.º 2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="id"></param>
        /// <param name="thisid">此ID对应的部门不包含在返回的树节点里(场景:部门编辑时可以选择上级部门,而这个选择范围不应该包含它自己)</param>
        /// <param name="selectNodeID">当前已选中的部门ID</param>
        /// <returns></returns>
        public ActionResult GetDepTree(string id = "root", string thisid = "", string selectNodeID = "")
        {
            id = string.IsNullOrEmpty(id) || id == "#" ? "root" : id;
            Expression <Func <SysDep, bool> > exp = d => d.DepFullIDPath.Contains(id);
            var  deps            = depService.GetList(exp).OrderBy(d => d.SortNo).ThenByDescending(d => d.AddDate).ToList();
            var  level1          = deps.FirstOrDefault(d => d.ID == id);
            var  level1_disabled = !string.IsNullOrEmpty(thisid) && level1.DepFullIDPath.Contains("/" + thisid + "/");
            bool select          = selectNodeID == level1.ID;
            var  root            = new JsTree3Node()
            {
                id       = level1.ID,
                text     = level1.Name,
                state    = new State(true, level1_disabled, select),
                children = new List <JsTree3Node>()
            };

            GenerateTree(root, deps, selectNodeID, level1_disabled, thisid);
            return(Json(root, JsonRequestBehavior.AllowGet));
        }