130 lines
4.0 KiB
C#
130 lines
4.0 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Web.Mvc;
|
|
using WX.CRM.Common;
|
|
using WX.CRM.IBLL.Base;
|
|
using WX.CRM.Model.Entity;
|
|
using WX.CRM.WebHelper;
|
|
|
|
namespace WX.CRM.WEB.Controllers.Base
|
|
{
|
|
public class DailyMemuController : BaseController
|
|
{
|
|
private IBAS_DAILYMEMU dialyMemu;
|
|
private IBAS_DAILYMEMU_Q dialyMemu_Q;
|
|
ValidationErrors errors = new ValidationErrors();
|
|
|
|
public DailyMemuController(IBAS_DAILYMEMU _dialyMemu, IBAS_DAILYMEMU_Q _dialyMemu_Q)
|
|
{
|
|
this.dialyMemu = _dialyMemu;
|
|
this.dialyMemu_Q = _dialyMemu_Q;
|
|
}
|
|
|
|
#region 首页
|
|
public ActionResult Index()
|
|
{
|
|
//table
|
|
string tableId = "tablist";
|
|
Table tab = new Table(tableId);
|
|
tab.AddHiddenHeadCol("PKID", "主键");
|
|
tab.AddHiddenHeadCol("SORTID", "主键");
|
|
tab.AddHeadCol("MENUID", "", "菜单");
|
|
tab.AddHeadRow();
|
|
ViewBag.gridTable = tab.GetHead();
|
|
|
|
return View();
|
|
}
|
|
#endregion
|
|
#region 列表
|
|
[HttpPost]
|
|
/// <summary>
|
|
/// 按照条件获取数据
|
|
/// </summary>
|
|
/// <param name="pager"></param>
|
|
/// <param name="queryStr"></param>
|
|
/// <returns></returns>
|
|
public JsonResult GetHtmlList(string columns)
|
|
{
|
|
List<WX.CRM.Model.Entity.BAS_DAILYMEMU> list = dialyMemu_Q.GetList(UserId);
|
|
Table table = new Table(columns, true);
|
|
List<BAS_LEFTMEMU> cacheMenuList = DataCacheHelper.GetCache().GetList_LeftMemu();
|
|
BAS_LEFTMEMU cacheMeu = null;
|
|
foreach (WX.CRM.Model.Entity.BAS_DAILYMEMU model in list)
|
|
{
|
|
cacheMeu = cacheMenuList.FirstOrDefault(m => m.MENUID == model.MENUID);
|
|
table.AddHiddenCol(model.PKID);
|
|
table.AddHiddenCol(model.SORTID);
|
|
table.AddCol("text-align:left;padding-left:40px;", "", cacheMeu == null ? "" : cacheMeu.MNAME);
|
|
table.AddRow();
|
|
}
|
|
|
|
var json = new
|
|
{
|
|
rowsList = table.GetRows()
|
|
};
|
|
return Json(json, JsonRequestBehavior.AllowGet);
|
|
}
|
|
|
|
#endregion
|
|
/// <summary>
|
|
/// 排序
|
|
/// </summary>
|
|
/// <param name="SortIds">格式:pkid,sorid;pkid,sorid</param>
|
|
/// <returns></returns>
|
|
[HttpPost]
|
|
public JsonResult Sort(string SortIds)
|
|
{
|
|
bool result = dialyMemu.Sort(ref errors, SortIds);
|
|
return JsonHandler.ManageMessage(errors, result);
|
|
}
|
|
|
|
|
|
#region 编辑
|
|
[HttpGet]
|
|
public ActionResult Edit()
|
|
{
|
|
List<WX.CRM.Model.Entity.BAS_DAILYMEMU> memuList = dialyMemu_Q.GetList(UserId);
|
|
string setValue = string.Empty;
|
|
foreach (WX.CRM.Model.Entity.BAS_DAILYMEMU item in memuList)
|
|
{
|
|
setValue += item.MENUID + ",";
|
|
}
|
|
if (setValue.Length > 0)
|
|
setValue = setValue.Substring(0, setValue.Length - 1);
|
|
ViewBag.setValue = setValue;
|
|
WX.CRM.Model.Entity.BAS_DAILYMEMU model = new WX.CRM.Model.Entity.BAS_DAILYMEMU();
|
|
return View(model);
|
|
}
|
|
|
|
[HttpPost]
|
|
public JsonResult Edit(string menuIds)
|
|
{
|
|
|
|
bool result = dialyMemu.Create(ref errors, menuIds, UserId);
|
|
return JsonHandler.InsertMessage(errors, result);
|
|
|
|
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region 删除
|
|
/// <summary>
|
|
/// 删除数据
|
|
/// </summary>
|
|
/// <param name="id"></param>
|
|
/// <returns></returns>
|
|
public JsonResult Delete(string id)
|
|
{
|
|
if (string.IsNullOrWhiteSpace(id))
|
|
{
|
|
return JsonHandler.ManageMessage("参数错误", false);
|
|
}
|
|
bool result = dialyMemu.Delete(ref errors, Convert.ToDecimal(id));
|
|
return JsonHandler.DeleteMessage(errors, result);
|
|
}
|
|
#endregion
|
|
}
|
|
}
|