public async Task <IActionResult> Index() { var deptRoot = new DeptDto { DeptID = 0, DeptName = "全部", ParentID = -1 }; var deptList = await _deptService.GetListAsnyc(); deptList.Add(deptRoot); ViewBag.deptList = JsonConvert.SerializeObject(deptList); return(View()); }
public async Task <IActionResult> Form(int id = 0) { var model = _deptService.Init(id).Data; var list = await _deptService.GetListAsnyc(); if (id != 0) { var listRemove = new List <DeptDto>(); _deptService.GetDeptByParentId(listRemove, id); //removeChild list.RemoveAll(item => listRemove.Any(p => p.DeptID == item.DeptID)); //removeSelf list.RemoveAll(p => p.DeptID == model.DeptID); } ViewBag.deptList = JsonConvert.SerializeObject(list); return(View(model)); }