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.
222 lines
4.6 KiB
222 lines
4.6 KiB
using learun.util;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
|
|
namespace EC.Web.Areas.LR_CodeDemo.Controllers
|
|
{
|
|
/// <summary>
|
|
/// 版 本 EasyCode EC管理后台
|
|
/// Copyright (c) 2019-present EC管理有限公司
|
|
/// 创建人:tobin
|
|
/// 日 期:2019.09.27
|
|
/// 描 述:gantt图演示
|
|
/// </summary>
|
|
[Area("LR_CodeDemo")]
|
|
public class GanttDemoController : MvcControllerBase
|
|
{
|
|
#region 视图功能
|
|
|
|
/// <summary>
|
|
/// 显示静态本地数据
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
[HttpGet]
|
|
public IActionResult Index1()
|
|
{
|
|
return View();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 显示树形数据
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
[HttpGet]
|
|
public IActionResult Index2()
|
|
{
|
|
return View();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 动态加载后台数据
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
[HttpGet]
|
|
public IActionResult Index3()
|
|
{
|
|
return View();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 分页显示
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
[HttpGet]
|
|
public IActionResult Index4()
|
|
{
|
|
return View();
|
|
}
|
|
|
|
#endregion 视图功能
|
|
|
|
#region 获取数据
|
|
|
|
/// <summary>
|
|
/// 获取数据
|
|
/// </summary>
|
|
/// <param name="parentId">分页参数</param>
|
|
/// <returns></returns>
|
|
[HttpGet]
|
|
[AjaxOnly]
|
|
public IActionResult GetTimeList(string keyword, string parentId)
|
|
{
|
|
List<object> list = new List<object>();
|
|
if (string.IsNullOrEmpty(parentId) || parentId == "0")
|
|
{
|
|
// 根节点
|
|
for (int i = 0; i < 10; i++)
|
|
{
|
|
List<object> timeList = new List<object>();
|
|
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<object> timeList = new List<object>();
|
|
|
|
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);
|
|
}
|
|
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
/// <param name="keyword"></param>
|
|
/// <param name="parentId"></param>
|
|
/// <returns></returns>
|
|
[HttpGet]
|
|
[AjaxOnly]
|
|
public IActionResult GetPageList(string pagination, string keyword)
|
|
{
|
|
List<object> list = new List<object>();
|
|
// 根节点
|
|
for (int i = 0; i < 100; i++)
|
|
{
|
|
List<object> timeList = new List<object>();
|
|
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<Pagination>();
|
|
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 获取数据
|
|
}
|
|
}
|