146 lines
5.4 KiB
C#
146 lines
5.4 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Web;
|
|
using System.Web.Mvc;
|
|
|
|
namespace Mini.Web.Areas.Admin.Controllers
|
|
{
|
|
public class BasParameterGroupController : BaseController
|
|
{
|
|
// GET: Admin/BasParameterGroup
|
|
private readonly IBas_ParameterGroupService _basParameterGroupService;
|
|
private readonly IBasInnerUserService _basInnerUserService;
|
|
private ValidationErrors errors = new ValidationErrors();
|
|
public BasParameterGroupController(IBas_ParameterGroupService basParameterGroupService, IBasInnerUserService basInnerUserService)
|
|
{
|
|
this._basParameterGroupService = basParameterGroupService;
|
|
this._basInnerUserService = basInnerUserService;
|
|
}
|
|
[AuthorizeRedirect(Roles = InitRights.CONST_参数分组配置)]
|
|
public ActionResult Index()
|
|
{
|
|
ToolBar tool = new ToolBar();
|
|
string[] toolbtn = new ToolButtonView().ToolButtonRight(InitRights.参数分组配置, userRightId);
|
|
tool.AllowButton(toolbtn);
|
|
ViewBag.ToolBar = tool;
|
|
|
|
Pager gp = new Pager() { page = 1, rows = 10 };
|
|
string tableId = "tablist";
|
|
Table tab = new Table(tableId);
|
|
tab.AddHeadCol("groupID", "20%", "分组ID");
|
|
tab.AddHeadCol("groupName", "", "分组名称");
|
|
tab.AddHeadCol("ctime", "20%", "创建时间");
|
|
tab.AddHeadCol("createuser", "20%", "创建人");
|
|
tab.AddHeadRow();
|
|
ViewBag.GroupList = tab.GetTable() + Pagination.GetPage(gp, tableId, "15,20,25,30");
|
|
|
|
return View();
|
|
}
|
|
#region 查询数据
|
|
[HttpPost]
|
|
[AuthorizeRedirect(Roles = InitRights.CONST_参数分组配置)]
|
|
public JsonResult GetHtmlList(Pager pg, string columns)
|
|
{
|
|
string id = Request.Form["parameterGroupId"];
|
|
string name = Request.Form["parameterGroupName"];
|
|
string stime = Request.Form["STime"];
|
|
string etime = Request.Form["ETime"];
|
|
|
|
List<Bas_ParameterGroup> list = _basParameterGroupService.GetList(ref pg, id, name, stime, etime);
|
|
|
|
Table tb = new Table(columns, true);
|
|
tb.gridPager = pg;
|
|
foreach (Bas_ParameterGroup model in list)
|
|
{
|
|
tb.AddCol(model.GroupId);
|
|
tb.AddCol(model.GroupName);
|
|
tb.AddCol(model.Ctime.ToUnityString(1));
|
|
tb.AddCol(_basInnerUserService.GetBasInnerUser(model.CreateUser).uname);
|
|
tb.AddRow();
|
|
}
|
|
var json = new
|
|
{
|
|
totalPages = pg.totalPages,
|
|
totalRows = pg.totalRows,
|
|
rowsList = tb.GetRows()
|
|
};
|
|
return Json(json, JsonRequestBehavior.AllowGet);
|
|
}
|
|
#endregion
|
|
#region 详细
|
|
[AuthorizeToolBar(InitRights.CONST_参数分组配置, InitToolBar.CONST_Details)]
|
|
public ActionResult Details(string id)
|
|
{
|
|
Bas_ParameterGroup bpg = new Bas_ParameterGroup();
|
|
if (!string.IsNullOrEmpty(id))
|
|
{
|
|
bpg = _basParameterGroupService.Get(id);
|
|
}
|
|
|
|
Bas_ParameterGroupView model = new Bas_ParameterGroupView()
|
|
{
|
|
CreateUser=bpg.CreateUser,
|
|
CreateUserName=_basInnerUserService.GetBasInnerUser(bpg.CreateUser).uname,
|
|
Ctime=bpg.Ctime,
|
|
GroupId=bpg.GroupId,
|
|
GroupName=bpg.GroupName
|
|
};
|
|
return View(model);
|
|
}
|
|
#endregion
|
|
#region 删除
|
|
[AuthorizeToolBar(InitRights.CONST_参数分组配置, InitToolBar.CONST_Delete)]
|
|
public JsonResult Delete(string id)
|
|
{
|
|
if (!string.IsNullOrEmpty(id))
|
|
{
|
|
return JsonHandler.DeleteMessage(errors, _basParameterGroupService.Delete(id,ref errors));
|
|
}
|
|
else
|
|
{
|
|
return JsonHandler.ManageMessage("删除失败!", false);
|
|
}
|
|
}
|
|
#endregion
|
|
#region 显示修改页面
|
|
[HttpGet]
|
|
[AuthorizeToolBar(InitRights.CONST_参数分组配置, InitToolBar.CONST_Edit)]
|
|
public ActionResult Edit(string id)
|
|
{
|
|
Bas_ParameterGroup model = new Bas_ParameterGroup();
|
|
if (!string.IsNullOrEmpty(id))
|
|
{
|
|
model = _basParameterGroupService.Get(id);
|
|
}
|
|
return View(model);
|
|
}
|
|
#endregion
|
|
|
|
#region 提交 新增/修改
|
|
[HttpPost]
|
|
[AuthorizeToolBar(InitRights.CONST_参数分组配置, InitToolBar.CONST_Edit)]
|
|
public JsonResult Edit(Bas_ParameterGroup model)
|
|
{
|
|
if (ModelState.IsValid)
|
|
{
|
|
string op = Request.Form["hid_option"];
|
|
if (op == "add")
|
|
{
|
|
model.CreateUser = UserId;
|
|
model.Ctime = DateTime.Now;
|
|
return JsonHandler.InsertMessage(errors, _basParameterGroupService.Create(model, ref errors));
|
|
}
|
|
else
|
|
{
|
|
return JsonHandler.UpdateMessage(errors, _basParameterGroupService.Update(model, ref errors));
|
|
}
|
|
}
|
|
else
|
|
{
|
|
return JsonHandler.ValidateFailMessage();
|
|
}
|
|
}
|
|
#endregion
|
|
}
|
|
} |