public async Task <IActionResult> GetTreeData(int?parentId) { var tempParentId = parentId == 0 ? null : parentId; var departments = await _departmentAppService.GetAllAsync(tempParentId); var treedata = departments.Select(a => new TreeViewModel { Id = a.Id, Name = a.Name, IsParent = a.Children.Count > 0 }).ToList(); if (parentId == null) { var treeDataWithRoot = new TreeViewModel { Id = 0, Name = "机构树", Open = true, IsParent = true, Children = treedata }; return(Json(treeDataWithRoot)); } return(Json(treedata)); }
public async Task <IActionResult> GetDepartmentsForStatistics() { var departments = await _departmentAppService.GetAllAsync(); var json = departments.Select(a => new SelectViewModel { Id = a.Id, Text = a.FullName }); return(Json(json)); }
public async Task <IActionResult> GetGroupDetails(int id) { var departments = await _departmentAppService.GetAllAsync(); var groupDetails = await _groupAppService.GetGroupDetails(id); var json = departments.Select(a => new SimpleTreeViewModel { Id = a.Id, ParentId = a.ParentId, Name = a.Name, Checked = groupDetails.Any(b => b.DepartmentId == a.Id) }); return(Json(json)); }