Example #1
0
        public IActionResult JQueryTreeGrid(string id)
        {
            if (!CurrentAdmin.SysAdmin)
            {
                return(JQueryTreeGrid2(id));
            }

            try
            {
                var dal = new FunctionDal();
                IList <FunctionDefinition> list = dal.Query();
                var tree = from item in list
                           where item.ParentId == id
                           orderby item.Postion
                           select new
                {
                    functionId = item.FunctionId,
                    name       = item.Name,
                    state      = list.FirstOrDefault(o => o.ParentId == item.FunctionId) == null ? "open" : "closed",
                    parentId   = item.ParentId,
                    parentName = list.FirstOrDefault(o => o.FunctionId == item.ParentId) == null ? ""
                               : list.FirstOrDefault(o => o.FunctionId == item.ParentId).Name,
                    page    = item.Page,
                    display = item.Display ? "显示" : "隐藏",
                    postion = item.Postion,
                    op      = "<ahref=\"/function/Delete?id=" + item.FunctionId + "\" onclick=\"return confirm('您确认要删除该记录吗?');\">删除</a>"
                };
                return(Json(tree));
            }
            catch (Exception ex)
            {
                return(Json(ex.Message));
            }
        }
Example #2
0
 public IActionResult JQueryTreeGridAndCommand(string id)
 {
     try
     {
         var dal = new FunctionDal();
         IList <FunctionDefinition> list = dal.Query();
         var tree = from item in list
                    where item.ParentId == id
                    orderby item.Postion
                    select new
         {
             functionId = item.FunctionId,
             name       = item.Name,
             state      = list.FirstOrDefault(o => o.ParentId == item.FunctionId) == null ? "open" : "closed",
             parentId   = item.ParentId,
             parentName = list.FirstOrDefault(o => o.FunctionId == item.ParentId) == null ? ""
                        : list.FirstOrDefault(o => o.FunctionId == item.ParentId).Name,
             CommandIds = GetCommandIdAndName(item.FunctionId),
         };
         return(Json(tree));
     }
     catch (Exception ex)
     {
         return(Json(ex.Message));
     }
 }
Example #3
0
        public IActionResult JQueryLeftTree2(string id)
        {
            var dal = new FunctionDal();
            var roleAndFunctionDal  = new RoleAndFunctionDal();
            var roleAndFunctionList = roleAndFunctionDal.QueryByRoleId(CurrentAdmin.RoleId);

            IList <FunctionDefinition> list = dal.Query();
            var tree = from item in list
                       join roleAndFunction in roleAndFunctionList on item.FunctionId equals roleAndFunction.FunctionId
                       where item.ParentId == id && item.Display
                       //where item.Display
                       orderby item.Postion
                       select new
            {
                id         = item.FunctionId,
                text       = item.Name,
                state      = list.FirstOrDefault(o => o.ParentId == item.FunctionId) == null ? "open" : "closed",
                attributes = new
                {
                    page = item.Page
                }
            };

            return(Json(tree));
        }
Example #4
0
        public IActionResult JQueryLeftTree(string id)
        {
            if (!CurrentAdmin.SysAdmin)
            {
                return(JQueryLeftTree2(id));
            }

            var dal = new FunctionDal();
            IList <FunctionDefinition> list = dal.Query();
            var tree = from item in list
                       where item.ParentId == id && item.Display
                       //where item.Display
                       orderby item.Postion
                       select new
            {
                id         = item.FunctionId,
                text       = item.Name,
                state      = list.FirstOrDefault(o => o.ParentId == item.FunctionId) == null ? "open" : "closed",
                attributes = new
                {
                    page = item.Page
                }
            };

            return(Json(tree));
        }