261 lines
10 KiB
C#
261 lines
10 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Web.Mvc;
|
|
using WX.CRM.Common;
|
|
using WX.CRM.IBLL.Soft;
|
|
using WX.CRM.WebHelper;
|
|
|
|
namespace WX.CRM.WEB.Controllers.Soft
|
|
{
|
|
public class ModuleController : BaseController
|
|
{
|
|
//
|
|
// GET: /Module/
|
|
private readonly ISOFT_MODULE _module;
|
|
private readonly ISOFT_MODULE_Q _module_q;
|
|
private readonly ISOFT_ACTIVEMODULE_Q _productModule_q;
|
|
ValidationErrors errors = new ValidationErrors();
|
|
public ModuleController(
|
|
ISOFT_MODULE module,
|
|
ISOFT_MODULE_Q module_q,
|
|
ISOFT_ACTIVEMODULE_Q productModule_q
|
|
)
|
|
{
|
|
this._module = module;
|
|
this._module_q = module_q;
|
|
this._productModule_q = productModule_q;
|
|
}
|
|
[AuthorizeRedirect(Roles = InitRights.CONST_产品模块列表)]
|
|
public ActionResult Index()
|
|
{
|
|
//ToolBar
|
|
ToolBar tool = new ToolBar();
|
|
string[] toolbtn = new ToolButtonView().ToolButtonRight(InitRights.产品模块列表, userRightId);
|
|
tool.AllowButton(toolbtn);
|
|
// tool.AllowButton("Create", "Edit");
|
|
ViewBag.ToolBar = tool;
|
|
//table
|
|
//Pager pager = new Pager() { page = 1, rows = 10 };
|
|
string tableId = "tablist";
|
|
Table tab = new Table(tableId);
|
|
tab.AddHeadCol("MODULEID", "8%", "模块ID");
|
|
tab.AddHeadCol("Map_MODULENAME", "15%", "模块名称");
|
|
tab.AddHeadCol("Map_DEFAULTDAYS", "15%", "默认天数");
|
|
tab.AddHeadCol("Map_CTIME", "15%", "创建时间");
|
|
tab.AddHeadCol("Map_CREATEUSER", "15%", "创建人");
|
|
tab.AddHeadCol("Map_UTIME", "15%", "修改时间");
|
|
tab.AddHeadCol("Map_UPDATEUSER", "", "修改人");
|
|
tab.AddHeadRow();
|
|
ViewBag.List = tab.GetTable();
|
|
|
|
return View();
|
|
}
|
|
[HttpPost]
|
|
/// <summary>
|
|
/// 按照条件获取数据
|
|
/// </summary>
|
|
/// <param name="pager"></param>
|
|
/// <param name="queryStr"></param>
|
|
/// <returns></returns>
|
|
[AuthorizeRedirect(Roles = InitRights.CONST_产品模块列表)]
|
|
public JsonResult GetHtmlList(string moduleName, string columns)
|
|
{
|
|
try
|
|
{
|
|
List<WX.CRM.Model.Entity.SOFT_MODULE> list = _module_q.GetModuleList(moduleName);
|
|
Table table = new Table(columns, true);
|
|
//table.gridPager = pager;
|
|
foreach (WX.CRM.Model.Entity.SOFT_MODULE model in list)
|
|
{
|
|
table.AddCol(model.MODULEID);
|
|
table.AddCol(model.Map_MODULENAME);
|
|
table.AddCol(model.Map_DEFAULTDAYS);
|
|
table.AddCol(model.Map_CTIME);
|
|
table.AddCol(InnerUserHelper.Instance.EidAndName(model.Map_CREATEUSER));
|
|
table.AddCol(model.Map_UTIME);
|
|
table.AddCol(InnerUserHelper.Instance.EidAndName(model.Map_UPDATEUSER));
|
|
table.AddRow();
|
|
}
|
|
var json = new
|
|
{
|
|
rowsList = table.GetRows()
|
|
};
|
|
return Json(json, JsonRequestBehavior.AllowGet);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogHelper.Error("ModuleController_GetHtmlList:" + ex.Message + ex.StackTrace);
|
|
return JsonHandler.ManageMessage(ex.Message, false);
|
|
}
|
|
}
|
|
#region 编辑
|
|
[HttpGet]
|
|
[AuthorizeToolBar(InitRights.CONST_产品模块列表, InitToolBar.CONST_Edit)]
|
|
public ActionResult Edit(string id)
|
|
{
|
|
WX.CRM.Model.Entity.SOFT_MODULE model = new WX.CRM.Model.Entity.SOFT_MODULE();
|
|
model.Map_DEFAULTDAYS = 60;
|
|
if (!string.IsNullOrEmpty(id))
|
|
{
|
|
model = _module_q.GetModuleById(Convert.ToDecimal(id));
|
|
}
|
|
return View(model);
|
|
}
|
|
[HttpPost]
|
|
[AuthorizeToolBar(InitRights.CONST_产品模块列表, InitToolBar.CONST_Edit)]
|
|
public JsonResult Edit(WX.CRM.Model.Entity.SOFT_MODULE model)
|
|
{
|
|
if (!ModelState.IsValid)
|
|
{
|
|
|
|
return JsonHandler.JsonResultSerialize(ModelState);
|
|
}
|
|
try
|
|
{
|
|
if (model.PKID == 0)
|
|
{
|
|
model.Map_CREATEUSER = UserId;
|
|
model.Map_CTIME = DateTime.Now;
|
|
bool result = _module.Create(ref errors, model);
|
|
return JsonHandler.InsertMessage(errors, result);
|
|
}
|
|
else
|
|
{
|
|
model.Map_UTIME = DateTime.Now;
|
|
model.Map_UPDATEUSER = UserId;
|
|
bool result = _module.Update(ref errors, model);
|
|
return JsonHandler.UpdateMessage(errors, result);
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogHelper.Error("ModuleController_Edit:" + ex.Message + ex.StackTrace);
|
|
return JsonHandler.ManageMessage(ex.Message, false);
|
|
}
|
|
}
|
|
#endregion
|
|
#region 产品模块关联
|
|
public ActionResult ModuleByProduct(string productId)
|
|
{
|
|
|
|
string tableId = "Modulelist";
|
|
Table tab = new Table(tableId);
|
|
//tab.isCheckbox = true;
|
|
tab.AddHeadCol("Map_Select", "20%", "选择");
|
|
tab.AddHeadCol("Map_MODULEID", "20%", "模块Id");
|
|
tab.AddHeadCol("Map_MODULENAME", "20%", "模块名称");
|
|
tab.AddHeadCol("Map_DEFAULTDAYS", "", "天数");
|
|
tab.AddHeadRow();
|
|
ViewBag.List = tab.GetTable();
|
|
ViewBag.ProductId = productId;
|
|
return View();
|
|
}
|
|
[HttpPost]
|
|
/// <summary>
|
|
/// 按照条件获取数据
|
|
/// </summary>
|
|
/// <param name="pager"></param>
|
|
/// <param name="queryStr"></param>
|
|
/// <returns></returns>
|
|
public JsonResult GetModuleList(string productId, string columns)
|
|
{
|
|
try
|
|
{
|
|
decimal _productId;
|
|
decimal.TryParse(productId, out _productId);
|
|
List<WX.CRM.Model.Entity.SOFT_ACTIVEMODULE> moduleByProductId = _productModule_q.GetModuleByProductId(_productId);
|
|
List<WX.CRM.Model.Entity.SOFT_MODULE> list = _module_q.GetAllModule();
|
|
Table table = new Table(columns, true);
|
|
// table.isCheckbox = true;
|
|
//table.gridPager = pager;
|
|
foreach (WX.CRM.Model.Entity.SOFT_MODULE model in list)
|
|
{
|
|
var moduleProduct = moduleByProductId.FirstOrDefault(p => p.MODULEID == model.MODULEID);
|
|
decimal days = model.Map_DEFAULTDAYS;
|
|
if (null != moduleProduct)
|
|
{
|
|
days = moduleProduct.Map_DAYS;
|
|
table.AddCol(string.Format("<input type='checkbox' checked='checked' name='ModuleSelect' Module=\"{0}\"/>", model.Map_MODULEID.ToString()));
|
|
}
|
|
else
|
|
{
|
|
table.AddCol(string.Format("<input type='checkbox' name='ModuleSelect' Module=\"{0}\"/>", model.Map_MODULEID.ToString()));
|
|
}
|
|
table.AddCol(model.Map_MODULEID);
|
|
table.AddCol(model.Map_MODULENAME);
|
|
table.AddCol("text-align:left;padding-left:10px;", "36%", string.Format("<input type='text' class='number' name='Days' value=\"{0}\" id=\"{1}\"/>", days, "module" + model.Map_MODULEID.ToString()));
|
|
table.AddRow();
|
|
}
|
|
var json = new
|
|
{
|
|
rowsList = table.GetRows()
|
|
};
|
|
return Json(json, JsonRequestBehavior.AllowGet);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogHelper.Error("ModuleController_ModuleList:" + ex.Message + ex.StackTrace);
|
|
return JsonHandler.ManageMessage(ex.Message, false);
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region 客户资料活动模块
|
|
public ActionResult ActiveModule(string productId)
|
|
{
|
|
|
|
string tableId = "ActiveModulelist";
|
|
Table tab = new Table(tableId);
|
|
tab.AddHeadCol("Map_MODULENAME", "60%", "模块名称");
|
|
tab.AddHeadCol("Map_DEFAULTDAYS", "", "天数");
|
|
tab.AddHeadRow();
|
|
ViewBag.ModuleList = tab.GetTable();
|
|
ViewBag.ProductId = productId;
|
|
return View();
|
|
}
|
|
[HttpPost]
|
|
/// <summary>
|
|
/// 按照条件获取数据
|
|
/// </summary>
|
|
/// <param name="pager"></param>
|
|
/// <param name="queryStr"></param>
|
|
/// <returns></returns>
|
|
public JsonResult GetActiveModuleList(string productId, string columns)
|
|
{
|
|
try
|
|
{
|
|
decimal _productId;
|
|
decimal.TryParse(productId, out _productId);
|
|
List<WX.CRM.Model.Entity.SOFT_ACTIVEMODULE> moduleByProductId = _productModule_q.GetModuleByProductId(_productId);
|
|
List<WX.CRM.Model.Entity.SOFT_MODULE> list = _module_q.GetAllModule();
|
|
Table table = new Table(columns, true);
|
|
// table.isCheckbox = true;
|
|
//table.gridPager = pager;
|
|
foreach (WX.CRM.Model.Entity.SOFT_ACTIVEMODULE model in moduleByProductId)
|
|
{
|
|
WX.CRM.Model.Entity.SOFT_MODULE module = list.FirstOrDefault(p => p.MODULEID == model.MODULEID);
|
|
table.AddCol(module == null ? "" : module.Map_MODULENAME);
|
|
table.AddCol(model.DAYS);
|
|
table.AddRow();
|
|
}
|
|
var json = new
|
|
{
|
|
rowsList = table.GetRows()
|
|
};
|
|
return Json(json, JsonRequestBehavior.AllowGet);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogHelper.Error("ModuleController_ActiveModuleList:" + ex.Message + ex.StackTrace);
|
|
var json = new
|
|
{
|
|
errorMessag = "系统错误:" + ex.Message
|
|
};
|
|
return Json(json, JsonRequestBehavior.AllowGet);
|
|
}
|
|
}
|
|
#endregion
|
|
}
|
|
}
|