TG.WXCRM.V4/WEB/Controllers/HgComplaint/HgComplaintController.cs

111 lines
4.6 KiB
C#

using Newtonsoft.Json;
using Ninject;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web;
using System.Web.Mvc;
using WX.CRM.BLL.Util;
using WX.CRM.Common;
using WX.CRM.Common.StockHelper;
using WX.CRM.IBLL.Util;
using WX.CRM.Model.DTO;
using WX.CRM.WebHelper;
namespace WX.CRM.WEB.Controllers.HgComplaint
{
public class HgComplaintController : BaseController
{
[Inject]
public ICACHE_Q cacheQ { get; set; }
public readonly string apiPath = new CACHE_BL().GetValue_Parameter("HgActionUrl") + "Api";
public HgComplaintController()
{
//apiPath = "https://localhost:7263/Api";
}
[AuthorizeRedirect(Roles = InitRights.CONST_潜在风险投诉客户)]
public ActionResult Index()
{
//ToolBar
ToolBar tool = new ToolBar();
string[] toolbtn = new ToolButtonView().ToolButtonRight(InitRights., userRightId);
tool.AllowButton(toolbtn);
tool.AddOtherButton("Other1", "人工标记", "icon-detail", "ChatRecord_Click", true);
tool.AddOtherButton("Other2", "修改状态", "icon-group", "OuterUser_Click", true);
tool.AddOtherButton("Other3", "批量分配员工", "icon-group", "", true);
tool.AddOtherButton("Other4", "导出", "icon-group", "", true);
ViewBag.ToolBar = tool;
var allChannel = cacheQ.GetDeptDownList();
ViewBag.AllChannel = JsonHelper.ObjDivertToJson(allChannel);
ViewBag.apiPath = apiPath;
ViewBag.Appid = System.Configuration.ConfigurationManager.AppSettings["appid"];
return View();
}
[HttpGet]
[AuthorizeToolBar(InitRights.CONST_潜在风险投诉客户, InitToolBar.CONST_Other2)]
public ActionResult ChangeStatus(int? udid)
{
ViewBag.udid = udid;
ViewBag.apiPath = apiPath;
ViewBag.eid = Eid;
ViewBag.Uname = UserName;
return View();
}
public ActionResult ComplaintInfo(int complaintLogId)
{
ViewBag.apiPath = apiPath;
ViewBag.complaintLogId = complaintLogId;
ViewBag.eid = Eid;
ViewBag.Uname = UserName;
ViewBag.WwMessage_Url = cacheQ.GetValue_Parameter("WwMessage_Url");
ViewBag.Appid = System.Configuration.ConfigurationManager.AppSettings["appid"];
return View();
}
[HttpGet]
[AuthorizeToolBar(InitRights.CONST_潜在风险投诉客户, InitToolBar.CONST_Other1)]
public ActionResult Add()
{
ViewBag.apiPath = apiPath;
var allChannel = cacheQ.GetDeptDownList();
ViewBag.AllChannel = JsonHelper.ObjDivertToJson(allChannel);
ViewBag.eid = Eid;
ViewBag.Uname = UserName;
return View();
}
[HttpGet]
[AuthorizeToolBar(InitRights.CONST_潜在风险投诉客户, InitToolBar.CONST_Other4)]
public ActionResult Export(HgComplaintRequest dto)
{
var url = $"{apiPath}/Complaint/page";
var para = $"Deptid={dto.DeptId}&ResId={dto.ResId}" +
$"&UName={dto.UName}&Source={dto.Source}&SignType={dto.SignType}" +
$"&SignWay={dto.SignWay}&Status={dto.Status}&STime={dto.STime}" +
$"&ETime={dto.ETime}&Txt_groupIds={dto.Txt_groupIds}&Txt_deptId={dto.Txt_deptId}&HasOrder={dto.HasOrder}" +
$"&HasAssign={dto.HasAssign}&Txt_userId={dto.Txt_userId}" +
$"&Content={dto.Content}&PageIndex=1&PageSize=100000";
Dictionary<string, string> header = new Dictionary<string, string>();
var appid = System.Configuration.ConfigurationManager.AppSettings["appid"];
header.Add("appid", appid);
var result = Utility.GetData(url, para, header, Encoding.UTF8);
var data = JsonConvert.DeserializeObject<WX.CRM.Common.Employee.ApiResult<PageResult<HgComplaintResponse>>>(result);
if (data.code == 0)
{
string checkedFilds = PageRequest.GetQueryString("checkedFilds").Replace("[]", "");
string checkedTitles = PageRequest.GetQueryString("checkedTitles");
return File(ExcelHelper.ExportListModelToExcel<HgComplaintResponse>(data.data.Data.ToList(), "潜在风险客户列表", 10000, checkedFilds, checkedTitles, null), "application/ms-excel", PageRequest.GetDlownLoadName("潜在风险客户列表.xls"));
}
return Json(new { message = "数据获取错误!" }, JsonRequestBehavior.AllowGet);
}
}
}