using learun.util; using Microsoft.AspNetCore.Mvc; using System; using System.Collections.Generic; namespace EC.Web.Areas.LR_CodeDemo.Controllers { /// /// 版 本 EasyCode EC管理后台 /// Copyright (c) 2019-present EC管理有限公司 /// 创建人:tobin /// 日 期:2019.09.27 /// 描 述:gantt图演示 /// [Area("LR_CodeDemo")] public class GanttDemoController : MvcControllerBase { #region 视图功能 /// /// 显示静态本地数据 /// /// [HttpGet] public IActionResult Index1() { return View(); } /// /// 显示树形数据 /// /// [HttpGet] public IActionResult Index2() { return View(); } /// /// 动态加载后台数据 /// /// [HttpGet] public IActionResult Index3() { return View(); } /// /// 分页显示 /// /// [HttpGet] public IActionResult Index4() { return View(); } #endregion 视图功能 #region 获取数据 /// /// 获取数据 /// /// 分页参数 /// [HttpGet] [AjaxOnly] public IActionResult GetTimeList(string keyword, string parentId) { List list = new List(); if (string.IsNullOrEmpty(parentId) || parentId == "0") { // 根节点 for (int i = 0; i < 10; i++) { List timeList = new List(); timeList.Add(new { beginTime = DateTime.Now.ToString("yyyy-MM-dd"), endTime = DateTime.Now.AddDays(8).ToString("yyyy-MM-dd"), color = "#3286ed", overtime = false, text = "执行时间9天" }); var data = new { id = Guid.NewGuid().ToString(), text = "计划任务" + (i + 1), isexpand = false, complete = false, timeList = timeList, hasChildren = true }; if (!string.IsNullOrEmpty(keyword)) { if (data.text.IndexOf(keyword) != -1) { list.Add(data); } } else { list.Add(data); } } } else { // 子节点 for (int i = 0; i < 2; i++) { List timeList = new List(); if (i == 0) { timeList.Add(new { beginTime = DateTime.Now.ToString("yyyy-MM-dd"), endTime = DateTime.Now.AddDays(3).ToString("yyyy-MM-dd"), color = "#1bb99a", overtime = false, text = "执行时间4天" }); } else { timeList.Add(new { beginTime = DateTime.Now.AddDays(4).ToString("yyyy-MM-dd"), endTime = DateTime.Now.AddDays(8).ToString("yyyy-MM-dd"), color = "#E4474D", overtime = true, text = "执行时间5天" }); } var data = new { id = Guid.NewGuid().ToString(), text = "子任务" + (i + 1), isexpand = false, complete = true, timeList = timeList, hasChildren = false }; list.Add(data); } } return Success(list); } /// /// /// /// /// /// [HttpGet] [AjaxOnly] public IActionResult GetPageList(string pagination, string keyword) { List list = new List(); // 根节点 for (int i = 0; i < 100; i++) { List timeList = new List(); timeList.Add(new { beginTime = DateTime.Now.ToString("yyyy-MM-dd"), endTime = DateTime.Now.AddDays(8).ToString("yyyy-MM-dd"), color = "#3286ed", overtime = false, text = "执行时间9天" }); var data = new { id = Guid.NewGuid().ToString(), text = "计划任务" + (i + 1), isexpand = false, complete = false, timeList = timeList, hasChildren = true }; if (!string.IsNullOrEmpty(keyword)) { if (data.text.IndexOf(keyword) != -1) { list.Add(data); } } else { list.Add(data); } } Pagination paginationobj = pagination.ToObject(); int _index = (paginationobj.page - 1) * paginationobj.rows; int _cont = paginationobj.rows; if (_cont > list.Count - _index) { _cont = list.Count - _index; } var res = list.GetRange(_index, _cont); paginationobj.records = list.Count; var jsonData = new { rows = res, total = paginationobj.total, page = paginationobj.page, records = paginationobj.records, }; return Success(jsonData); } #endregion 获取数据 } }