You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

207 lines
6.7 KiB

  1. using Learun.Util;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Web.Mvc;
  5. namespace Learun.Application.Web.Areas.LR_CodeDemo.Controllers
  6. {
  7. /// <summary>
  8. /// 版 本 Learun-ADMS V7.0.3 力软敏捷开发框架
  9. /// Copyright (c) 2013-2018 上海力软信息技术有限公司
  10. /// 创建人:力软-框架开发组
  11. /// 日 期:2018.011.23
  12. /// 描 述:甘特图演示
  13. /// </summary>
  14. public class GanttDemoController : MvcControllerBase
  15. {
  16. #region 视图功能
  17. /// <summary>
  18. /// 显示静态本地数据
  19. /// </summary>
  20. /// <returns></returns>
  21. [HttpGet]
  22. public ActionResult Index1()
  23. {
  24. return View();
  25. }
  26. /// <summary>
  27. /// 显示树形数据
  28. /// </summary>
  29. /// <returns></returns>
  30. [HttpGet]
  31. public ActionResult Index2()
  32. {
  33. return View();
  34. }
  35. /// <summary>
  36. /// 动态加载后台数据
  37. /// </summary>
  38. /// <returns></returns>
  39. [HttpGet]
  40. public ActionResult Index3()
  41. {
  42. return View();
  43. }
  44. /// <summary>
  45. /// 分页显示
  46. /// </summary>
  47. /// <returns></returns>
  48. [HttpGet]
  49. public ActionResult Index4()
  50. {
  51. return View();
  52. }
  53. #endregion
  54. #region 获取数据
  55. /// <summary>
  56. /// 获取数据
  57. /// </summary>
  58. /// <param name="parentId">分页参数</param>
  59. /// <returns></returns>
  60. [HttpGet]
  61. [AjaxOnly]
  62. public ActionResult GetTimeList(string keyword, string parentId)
  63. {
  64. List<object> list = new List<object>();
  65. if (string.IsNullOrEmpty(parentId) || parentId == "0")
  66. {
  67. // 根节点
  68. for (int i = 0; i < 10; i++) {
  69. List<object> timeList = new List<object>();
  70. timeList.Add(new {
  71. beginTime = DateTime.Now.ToString("yyyy-MM-dd"),
  72. endTime = DateTime.Now.AddDays(8).ToString("yyyy-MM-dd"),
  73. color = "#3286ed",
  74. overtime = false,
  75. text = "执行时间9天"
  76. });
  77. var data = new {
  78. id = Guid.NewGuid().ToString(),
  79. text = "计划任务" + (i + 1),
  80. isexpand = false,
  81. complete = false,
  82. timeList = timeList,
  83. hasChildren = true
  84. };
  85. if (!string.IsNullOrEmpty(keyword))
  86. {
  87. if (data.text.IndexOf(keyword) != -1)
  88. {
  89. list.Add(data);
  90. }
  91. }
  92. else
  93. {
  94. list.Add(data);
  95. }
  96. }
  97. }
  98. else {
  99. // 子节点
  100. for (int i = 0; i < 2; i++)
  101. {
  102. List<object> timeList = new List<object>();
  103. if (i == 0)
  104. {
  105. timeList.Add(new
  106. {
  107. beginTime = DateTime.Now.ToString("yyyy-MM-dd"),
  108. endTime = DateTime.Now.AddDays(3).ToString("yyyy-MM-dd"),
  109. color = "#1bb99a",
  110. overtime = false,
  111. text = "执行时间4天"
  112. });
  113. }
  114. else {
  115. timeList.Add(new
  116. {
  117. beginTime = DateTime.Now.AddDays(4).ToString("yyyy-MM-dd"),
  118. endTime = DateTime.Now.AddDays(8).ToString("yyyy-MM-dd"),
  119. color = "#E4474D",
  120. overtime = true,
  121. text = "执行时间5天"
  122. });
  123. }
  124. var data = new
  125. {
  126. id = Guid.NewGuid().ToString(),
  127. text = "子任务" + (i + 1),
  128. isexpand = false,
  129. complete = true,
  130. timeList = timeList,
  131. hasChildren = false
  132. };
  133. list.Add(data);
  134. }
  135. }
  136. return Success(list);
  137. }
  138. /// <summary>
  139. ///
  140. /// </summary>
  141. /// <param name="keyword"></param>
  142. /// <param name="parentId"></param>
  143. /// <returns></returns>
  144. [HttpGet]
  145. [AjaxOnly]
  146. public ActionResult GetPageList(string pagination,string keyword)
  147. {
  148. List<object> list = new List<object>();
  149. // 根节点
  150. for (int i = 0; i < 100; i++)
  151. {
  152. List<object> timeList = new List<object>();
  153. timeList.Add(new
  154. {
  155. beginTime = DateTime.Now.ToString("yyyy-MM-dd"),
  156. endTime = DateTime.Now.AddDays(8).ToString("yyyy-MM-dd"),
  157. color = "#3286ed",
  158. overtime = false,
  159. text = "执行时间9天"
  160. });
  161. var data = new
  162. {
  163. id = Guid.NewGuid().ToString(),
  164. text = "计划任务" + (i + 1),
  165. isexpand = false,
  166. complete = false,
  167. timeList = timeList,
  168. hasChildren = true
  169. };
  170. if (!string.IsNullOrEmpty(keyword))
  171. {
  172. if (data.text.IndexOf(keyword) != -1)
  173. {
  174. list.Add(data);
  175. }
  176. }
  177. else
  178. {
  179. list.Add(data);
  180. }
  181. }
  182. Pagination paginationobj = pagination.ToObject<Pagination>();
  183. int _index = (paginationobj.page - 1) * paginationobj.rows;
  184. int _cont = paginationobj.rows;
  185. if (_cont > list.Count - _index) {
  186. _cont = list.Count - _index;
  187. }
  188. var res = list.GetRange(_index, _cont);
  189. paginationobj.records = list.Count;
  190. var jsonData = new
  191. {
  192. rows = res,
  193. total = paginationobj.total,
  194. page = paginationobj.page,
  195. records = paginationobj.records,
  196. };
  197. return Success(jsonData);
  198. }
  199. #endregion
  200. }
  201. }