using Learun.Application.Base.SystemModule;
using Learun.Application.CRM;
using Learun.Util;
using System.Web.Mvc;
namespace Learun.Application.Web.Areas.LR_CRMModule.Controllers
{
///
/// 版 本 Learun-ADMS-Ultimate V7.0.0 数字化智慧校园
/// Copyright (c) 2013-2018 北京泉江科技有限公司
/// 创 建:超级管理员
/// 日 期:2017-07-11 11:30
/// 描 述:商机管理
///
public class ChanceController : MvcControllerBase
{
private CrmChanceIBLL crmChanceIBLL = new CrmChanceBLL();
private CodeRuleIBLL codeRuleIBLL = new CodeRuleBLL();
#region 视图功能
///
/// 商机列表页面
///
///
[HttpGet]
public ActionResult Index()
{
return View();
}
///
/// 商机表单页面
///
///
[HttpGet]
public ActionResult Form()
{
if (Request["keyValue"] == null)
{
ViewBag.EnCode = codeRuleIBLL.GetBillCode(((int)CodeRuleEnum.CrmChanceCode).ToString());
}
return View();
}
///
/// 商机明细页面
///
///
[HttpGet]
public ActionResult Detail()
{
return View();
}
#endregion
#region 获取数据
///
/// 获取商机列表
///
/// 分页参数
/// 查询参数
/// 返回分页列表Json
[HttpGet]
[AjaxOnly]
public ActionResult GetPageList(string pagination, string queryJson)
{
Pagination paginationobj = pagination.ToObject();
var data = crmChanceIBLL.GetPageList(paginationobj, queryJson);
var jsonData = new
{
rows = data,
total = paginationobj.total,
page = paginationobj.page,
records = paginationobj.records,
};
return JsonResult(jsonData);
}
///
/// 获取商机实体
///
/// 主键值
/// 返回对象Json
[HttpGet]
[AjaxOnly]
public ActionResult GetFormJson(string keyValue)
{
var data = crmChanceIBLL.GetEntity(keyValue);
return ToJsonResult(data);
}
#endregion
#region 验证数据
///
/// 商机名称不能重复
///
/// 名称
/// 主键
///
[HttpGet]
[AjaxOnly]
public ActionResult ExistFullName(string FullName, string keyValue)
{
bool IsOk = crmChanceIBLL.ExistFullName(FullName, keyValue);
return Success(IsOk.ToString());
}
#endregion
#region 提交数据
///
/// 删除商机数据
///
/// 主键值
///
[HttpPost]
[AjaxOnly]
public ActionResult DeleteForm(string keyValue)
{
crmChanceIBLL.DeleteEntity(keyValue);
return Success("删除成功。");
}
///
/// 保存商机表单(新增、修改)
///
/// 主键值
/// 实体对象
///
[HttpPost]
[ValidateAntiForgeryToken]
[AjaxOnly]
public ActionResult SaveForm(string keyValue, CrmChanceEntity entity)
{
crmChanceIBLL.SaveEntity(keyValue, entity);
return Success("操作成功。");
}
///
/// 商机作废
///
/// 主键值
///
[HttpPost]
[AjaxOnly]
public ActionResult Invalid(string keyValue)
{
crmChanceIBLL.Invalid(keyValue);
return Success("作废成功。");
}
///
/// 商机转换客户
///
/// 主键值
///
[HttpPost]
[AjaxOnly]
public ActionResult ToCustomer(string keyValue)
{
string enCode = codeRuleIBLL.GetBillCode(((int)CodeRuleEnum.CrmChanceCode).ToString());
crmChanceIBLL.ToCustomer(keyValue, enCode);
codeRuleIBLL.UseRuleSeed(((int)CodeRuleEnum.CrmChanceCode).ToString());
return Success("转换成功。");
}
#endregion
}
}