139 lines
5.3 KiB
C#
139 lines
5.3 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Web.Mvc;
|
|
using WX.CRM.Common;
|
|
using WX.CRM.IBLL.Base;
|
|
using WX.CRM.IBLL.Util;
|
|
using WX.CRM.WebHelper;
|
|
|
|
namespace WX.CRM.WEB.Controllers.Base
|
|
{
|
|
public class GroupLeaderController : BaseController
|
|
{
|
|
IBAS_GROUPLEADER groupLeaderBiz;
|
|
IBAS_GROUPLEADER_Q groupLeaderBiz_Q;
|
|
private ICACHE_Q _cacheQ;
|
|
|
|
public GroupLeaderController(IBAS_GROUPLEADER _groupLeaderBiz, IBAS_GROUPLEADER_Q _groupLeaderBiz_Q, ICACHE_Q cacheQ)
|
|
{
|
|
groupLeaderBiz = _groupLeaderBiz;
|
|
groupLeaderBiz_Q = _groupLeaderBiz_Q;
|
|
_cacheQ = cacheQ;
|
|
}
|
|
|
|
ValidationErrors errors = new ValidationErrors();
|
|
#region 首页列表
|
|
[AuthorizeRedirect(Roles = InitRights.CONST_销售组领导管理)]
|
|
public ActionResult Index()
|
|
{
|
|
ToolBar tool = new ToolBar();
|
|
string[] toolbtn = new ToolButtonView().ToolButtonRight(InitRights.销售组领导管理, userRightId);
|
|
tool.AllowButton(toolbtn);
|
|
//tool.AllowButton("Create", "Delete");
|
|
ViewBag.ToolBar = tool;
|
|
|
|
|
|
Pager pager = new Pager() { order = "companyId", page = 1, rows = 10 };
|
|
string tableId = "tablist";
|
|
Table tab = new Table(tableId);
|
|
tab.AddHeadCol("gName", "20%", "部门或工作组");
|
|
tab.AddHeadCol("uName", "20%", "管理者");
|
|
tab.AddHeadCol("uName", "20%", "类型");
|
|
tab.AddHeadCol("eID", "", "工号");
|
|
tab.AddHiddenHeadCol("inneruserId", "员工ID");
|
|
tab.AddHiddenHeadCol("innerGroupId", "组ID");
|
|
tab.AddHeadRow();
|
|
ViewBag.gridTable = tab.GetTable();
|
|
return View();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 按照条件获取数据
|
|
/// </summary>
|
|
/// <param name="pager">分页信息</param>
|
|
/// <returns></returns>
|
|
[AuthorizeRedirect(Roles = InitRights.CONST_销售组领导管理)]
|
|
public JsonResult GetHtmlList(string columns)
|
|
{
|
|
string roleId = Request.Form["roleId"];
|
|
string gName = Request.Form["gName"];
|
|
string eID = Request.Form["eID"];
|
|
|
|
List<WX.CRM.Model.Entity.BAS_GROUPLEADER> list = groupLeaderBiz_Q.GetList(gName, eID);
|
|
Table table = new Table(columns, true);
|
|
Dictionary<int, string> groupLeadeType = OperationUtil.GetDicFromEnum<WX.CRM.Model.Enum.GroupLeaderType>();
|
|
foreach (WX.CRM.Model.Entity.BAS_GROUPLEADER model in list)
|
|
{
|
|
table.AddCol(model.map_gName);
|
|
table.AddCol(model.map_uName);
|
|
if (model.LEADERTYPE != null)
|
|
table.AddCol(groupLeadeType[Convert.ToInt32(model.LEADERTYPE.Value)]);
|
|
else
|
|
table.AddCol("");
|
|
table.AddCol(model.map_EID);
|
|
table.AddHiddenCol(model.map_INNERUSERID);
|
|
table.AddHiddenCol(model.map_INNERGROUPID);
|
|
table.AddRow();
|
|
}
|
|
var json = new
|
|
{
|
|
rowsList = table.GetRows()
|
|
};
|
|
return Json(json, JsonRequestBehavior.AllowGet);
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region 删除
|
|
/// <summary>
|
|
/// 删除数据
|
|
/// </summary>
|
|
/// <param name="id"></param>
|
|
/// <returns></returns>
|
|
[AuthorizeToolBar(InitRights.CONST_销售组领导管理, InitToolBar.CONST_Delete)]
|
|
public JsonResult Delete(string inneruserId, string innerGroupId)
|
|
{
|
|
if (!string.IsNullOrWhiteSpace(inneruserId) && !string.IsNullOrWhiteSpace(innerGroupId))
|
|
{
|
|
|
|
if (groupLeaderBiz.Delete(ref errors, Convert.ToDecimal(inneruserId), Convert.ToDecimal(innerGroupId)))
|
|
return Json(JsonHandler.CreateMessage(1, Suggestion.DeleteSucceed), JsonRequestBehavior.AllowGet);
|
|
else
|
|
return Json(JsonHandler.CreateMessage(0, Suggestion.DeleteFail + errors.Error), JsonRequestBehavior.AllowGet);
|
|
}
|
|
else
|
|
{
|
|
return Json(JsonHandler.CreateMessage(0, Suggestion.DeleteFail), JsonRequestBehavior.AllowGet);
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region 新增
|
|
[AuthorizeToolBar(InitRights.CONST_销售组领导管理, InitToolBar.CONST_Add)]
|
|
public ActionResult Create()
|
|
{
|
|
return View();
|
|
}
|
|
[HttpPost]
|
|
[AuthorizeToolBar(InitRights.CONST_销售组领导管理, InitToolBar.CONST_Add)]
|
|
public ActionResult Create(WX.CRM.Model.Entity.BAS_GROUPLEADER model)
|
|
{
|
|
if (string.IsNullOrEmpty(model.map_DEPTID))
|
|
{
|
|
errors.Add("请选择对应的部门或者组");
|
|
return JsonHandler.InsertMessage(errors, false);
|
|
}
|
|
model.map_DEPTID = model.map_DEPTID.Replace("sale_", "").Replace("com_", "");
|
|
model.map_INNERGROUPID = Convert.ToDecimal(model.map_DEPTID);
|
|
if (!ModelState.IsValid)
|
|
return JsonHandler.ValidateFailMessage();
|
|
model.CREATEUSER = UserId;
|
|
model.CTIME = DateTime.Now;
|
|
bool result = groupLeaderBiz.Create(ref errors, model);
|
|
return JsonHandler.InsertMessage(errors, result);
|
|
}
|
|
#endregion
|
|
|
|
}
|
|
}
|