139 lines
4.8 KiB
C#
139 lines
4.8 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Web.Mvc;
|
|
using WX.CRM.Common;
|
|
using WX.CRM.IBLL.Base;
|
|
using WX.CRM.WebHelper;
|
|
|
|
namespace WX.CRM.WEB.Controllers.Base
|
|
{
|
|
public class InnerDepartmentController : BaseController
|
|
{
|
|
|
|
private IBAS_INNERDEPARTMENT_Q innerDepartmentBiz_Q;
|
|
private IBAS_INNERDEPARTMENT innerDepartmentBiz;
|
|
ValidationErrors errors = new ValidationErrors();
|
|
|
|
public InnerDepartmentController(IBAS_INNERDEPARTMENT_Q _innerdepartmentBiz_Q, IBAS_INNERDEPARTMENT _innerdepartmentBiz)
|
|
{
|
|
this.innerDepartmentBiz_Q = _innerdepartmentBiz_Q;
|
|
this.innerDepartmentBiz = _innerdepartmentBiz;
|
|
}
|
|
|
|
#region 首页
|
|
[AuthorizeRedirect(Roles = InitRights.CONST_部门管理)]
|
|
public ActionResult Index()
|
|
{
|
|
//ToolBar
|
|
ToolBar tool = new ToolBar();
|
|
string[] toolbtn = new ToolButtonView().ToolButtonRight(InitRights.部门管理, userRightId);
|
|
List<string> listBtn = new List<string>(toolbtn);
|
|
List<string> Buttons = new List<string>();
|
|
Buttons.Add("Other1");
|
|
Buttons.Add("Other2");
|
|
Buttons.AddRange(listBtn);
|
|
tool.AllowButton(Buttons.ToArray());
|
|
// tool.AllowButton("Other1", "Other2", toolbtn);
|
|
tool.AddOtherButton("Other1", "展开全部", "icon-flag", "ExpandAll_Click", true);
|
|
tool.AddOtherButton("Other2", "折叠全部", "icon-show", "CollapseAll_Click", true);
|
|
ViewBag.ToolBar = tool;
|
|
return View();
|
|
}
|
|
#endregion
|
|
|
|
|
|
|
|
#region 获取combotree数据源
|
|
/// <summary>
|
|
/// 获取tree数据源
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
public JsonResult GetTreeJson(string type)
|
|
{
|
|
return Json(DataCacheHelper.GetCache().GetTreeList_innerDepartment(type), JsonRequestBehavior.AllowGet);
|
|
}
|
|
#endregion
|
|
|
|
#region 获取tree数据源(包括了挂在部门的销售组)
|
|
/// <summary>
|
|
/// 获取treegrid数据源
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
public JsonResult GetDeptGroupTreeJson()
|
|
{
|
|
//return Json(DataCacheHelper.GetCache().GetDeptGroupTreeList_DeptGroup(), JsonRequestBehavior.AllowGet);
|
|
return Json(DataCacheHelper.GetCache().GetTreeList_saleDepartMent(), JsonRequestBehavior.AllowGet);
|
|
}
|
|
#endregion
|
|
|
|
|
|
#region 详细
|
|
[AuthorizeToolBar(InitRights.CONST_部门管理, InitToolBar.CONST_Details)]
|
|
public ActionResult Details(string id)
|
|
{
|
|
|
|
if (string.IsNullOrWhiteSpace(id))
|
|
return View(new WX.CRM.Model.Entity.BAS_INNERDEPARTMENT());
|
|
else
|
|
return View(innerDepartmentBiz_Q.GetModel(Convert.ToDecimal(id)));
|
|
|
|
}
|
|
#endregion
|
|
|
|
#region 编辑
|
|
[HttpGet]
|
|
[AuthorizeToolBar(InitRights.CONST_部门管理, InitToolBar.CONST_Edit)]
|
|
public ActionResult Edit(string id)
|
|
{
|
|
WX.CRM.Model.Entity.BAS_INNERDEPARTMENT model = new WX.CRM.Model.Entity.BAS_INNERDEPARTMENT();
|
|
if (!string.IsNullOrWhiteSpace(id))
|
|
{
|
|
model = innerDepartmentBiz_Q.GetModel(Convert.ToDecimal(id));
|
|
}
|
|
string fid = Request.QueryString["fid"];
|
|
model.PARENTID = Convert.ToDecimal((model.DEPTID == 0 ? fid : model.PARENTID.ToString()));
|
|
return View(model);
|
|
}
|
|
|
|
[HttpPost]
|
|
[AuthorizeToolBar(InitRights.CONST_部门管理, InitToolBar.CONST_Edit)]
|
|
public JsonResult Edit(WX.CRM.Model.Entity.BAS_INNERDEPARTMENT model)
|
|
{
|
|
if (!ModelState.IsValid)
|
|
{
|
|
return JsonHandler.ValidateFailMessage();
|
|
}
|
|
if (model.DEPTID == 0)
|
|
{
|
|
model.CREATEUSER = UserId;
|
|
model.CTIME = DateTime.Now;
|
|
bool result = innerDepartmentBiz.Create(ref errors, model);
|
|
return JsonHandler.InsertMessage(errors, result);
|
|
}
|
|
else
|
|
{
|
|
model.UPDATEUSER = UserId;
|
|
model.UTIME = DateTime.Now;
|
|
bool result = innerDepartmentBiz.Update(ref errors, model);
|
|
return JsonHandler.UpdateMessage(errors, result);
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region 删除
|
|
[AuthorizeToolBar(InitRights.CONST_部门管理, InitToolBar.CONST_Delete)]
|
|
public JsonResult Delete(string id)
|
|
{
|
|
if (string.IsNullOrWhiteSpace(id))
|
|
{
|
|
return JsonHandler.ManageMessage("删除失败", false);
|
|
}
|
|
bool result = innerDepartmentBiz.Delete(ref errors, Convert.ToDecimal(id));
|
|
return JsonHandler.DeleteMessage(errors, result);
|
|
}
|
|
#endregion
|
|
|
|
|
|
}
|
|
}
|