public string GetRootTree() { IList <ComboTreeNode> nodeList = new List <ComboTreeNode>(); var rootModuleList = _model.SysModule.Where(c => c.IsDel == 0 && c.ParentId == "0").OrderBy(c => c.Sort).ToList(); ComboTreeNode mainNode = null; ComboTreeNode rootNode = new ComboTreeNode(); rootNode.level = 0; rootNode.id = "0"; rootNode.state = "closed"; rootNode.text = "模块资源"; rootModuleList.Each(c => { mainNode = new ComboTreeNode(); mainNode.id = c.ModuleId.ToString(); mainNode.text = c.ModuleName; mainNode.level = c.ModuleLevel; if (HasChildren(c.ModuleId)) { mainNode.state = "closed"; } rootNode.children.Add(mainNode); }); nodeList.Add(rootNode); return(nodeList.ToJson()); }
/// <summary> /// 获取下级模块资源 /// </summary> /// <param name="id">下级模块资源主键</param> /// <returns></returns> public string GetNode(string id) { //int parentId = Int32.Parse(id); var moduleList = _model.SysModule.Where(c => c.ParentId == id && c.IsDel == 0 && c.ModuleLevel != 3).OrderBy(c => c.Sort).ToList(); IList <ComboTreeNode> nodeList = new List <ComboTreeNode>(); moduleList.Each(c => { ComboTreeNode mainNode = new ComboTreeNode(); mainNode.id = c.ModuleId.ToString(); mainNode.text = c.ModuleName; mainNode.level = c.ModuleLevel; if (HasChildrenNoBtn(c.ModuleId)) { mainNode.state = "closed"; } nodeList.Add(mainNode); }); return(nodeList.ToJson()); }