using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using EMIS.ViewModel;
using EMIS.Web.Controls;
using Bowin.Web.Controls.Mvc;
using EMIS.CommonLogic.CultureplanManage.PlanManagement;
using EMIS.ViewModel.BaseWorkflow;
using Bowin.Common.JSON;
using EMIS.ViewModel.CultureplanManage.PlanManagement;
using Bowin.Common.Utility;
using Bowin.Common.Data;
using EMIS.Utility;
using EMIS.Utility.FormValidate;
namespace EMIS.Web.Controllers.CultureplanManage.PlanManagement
{
[Authorization]
public class PlanApprovalController : Controller
{
public IPlanApplicationServices planApplicationServices { get; set; }
//
// GET: /PlanApproval/
public ActionResult List()
{
return View();
}
///
/// 列表查询
///
///
///
[HttpPost]
public ActionResult List(QueryParamsModel pararms)
{
ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms);
var campusID = pararms.getExtraGuid("CampusDropdown");
var collegeID = pararms.getExtraGuid("CollegeDropdown");
var yearID = pararms.getExtraInt("SchoolyearDictionaryDropDown") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("SchoolyearDictionaryDropDown");
var standardID = pararms.getExtraInt("StandardDictionaryDropDown") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("StandardDictionaryDropDown");
var educationID = pararms.getExtraInt("DictionaryEducation") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionaryEducation");
var learningFormID = pararms.getExtraInt("DictionaryLearningform") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionaryLearningform");
var schoolyear = pararms.getExtraGuid("SchoolyearDropdown");
var grademajorID = pararms.getExtraGuid("GrademajorComboGrid");
var approvalStatus = pararms.getExtraInt("DictionaryApprovalStatus") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionaryApprovalStatus");
var LearnSystem = pararms.getExtraString("DictionaryLearnSystem");
return this.Json(planApplicationServices.GetPlanApprovalViewGrid(configuretView, campusID, collegeID, yearID, standardID, educationID, learningFormID, schoolyear, approvalStatus,grademajorID,LearnSystem, (int)pararms.page, (int)pararms.rows));
}
///
/// 编辑
///
///
///
[HttpGet]
public ActionResult Edit(Guid? planApplicationID)
{
List list = new List();
var user = HttpContext.User as EMIS.Utility.FormValidate.CustomPrincipal;
PlanApplicationView planApplicationView = new PlanApplicationView();
if (planApplicationID.HasValue)
planApplicationView = planApplicationServices.GetPlanApplicationView(planApplicationID);
List listAction = planApplicationServices.GetAuditingActionView((Guid)planApplicationID, user.UserID);
foreach (var item in listAction)
{
DropdownListItem dli = new DropdownListItem { Text = item.ActionName, Value = item.ToJson() };
list.Add(dli);
}
ViewData["listAction"] = list;
return View(planApplicationView);
}
///
/// 编辑
///
///
///
[HttpPost]
public ActionResult Edit(PlanApplicationView planApplicationView)
{
try
{
List list = new List();
string action = Request.Form["ddlAction"];
var user = HttpContext.User as EMIS.Utility.FormValidate.CustomPrincipal;
ActionView actionView = action.JsonToObject();
string comment = Request.Form["txtOpinioncomment"];
list.Add(planApplicationView.PlanApplicationID);
planApplicationServices.ApprovePlanApplicationApply(list, user.UserID, actionView, comment, planApplicationView);
return Json(new ReturnMessage()
{
IsSuccess = true,
Message = "审核成功!"
});
}
catch (Exception ex)
{
return Json(new ReturnMessage()
{
IsSuccess = false,
Message = "审核失败,原因::" + ex.Message
});
}
}
///
/// 审批确定(批量)
///
///
///
///
///
[HttpPost]
public ActionResult Approve(string planApplicationIDs, Guid actionID, string comment)
{
var planApplicationIDList = planApplicationIDs.Split(',').Where(x => !string.IsNullOrEmpty(x)).Select(x => new Guid(x)).ToList();
var curUserID = CustomPrincipal.Current.UserID;
if (planApplicationIDList.Count == 0)
{
return Json(new ReturnMessage { IsSuccess = false, Message = "请选择至少一条记录进行审核。" });
}
try
{
this.planApplicationServices.Approve(planApplicationIDList, curUserID, actionID, comment);
return Json(new ReturnMessage { IsSuccess = true, Message = "审核成功。" });
}
catch (Exception ex)
{
return Json(new ReturnMessage { IsSuccess = false, Message = "审核失败:" + ex.Message });
}
}
///
/// 获取下一步动作
///
///
///
[HttpGet]
public ActionResult ApprovalHandle(string planApplicationIDs)
{
if (string.IsNullOrEmpty(planApplicationIDs))
{
planApplicationIDs = Session["planApplicationIDs"].ToString();
}
var user = HttpContext.User as EMIS.Utility.FormValidate.CustomPrincipal;
if (!string.IsNullOrEmpty(planApplicationIDs))
{
List listguid = new List();
Guid planApplicationID = new Guid(planApplicationIDs.Split(',')[0]);
List listAction = planApplicationServices.GetAuditingActionView(planApplicationID, user.UserID);
List list = new List();
if (listAction.Count == 0)
{
return RedirectToAction("MsgShow", "Common", new
{
WindowID = Request["WindowID"],
msg = "对不起,您无权限进行审核操作。"
});
}
foreach (var item in listAction)
{
DropdownListItem dli = new DropdownListItem { Text = item.ActionName, Value = item.ToJson() };
list.Add(dli);
}
ViewData["planApplicationIDs"] = planApplicationIDs;
ViewData["listAction"] = list;
}
else
{
return RedirectToAction("MsgShow", "Common", new
{
WindowID = Request["WindowID"],
msg = "请选择需要审核的数据。"
});
}
return View();
}
///
///
///
///
[HttpPost]
public ActionResult ApprovalHandle()
{
string planApplicationIDs = Request.Form["planApplicationIDs"].ToString();
Session["planApplicationIDs"] = planApplicationIDs;
return Json("成功", JsonRequestBehavior.AllowGet);
}
///
/// 获取流程步骤详细信息
///
///
///
[HttpPost]
public ActionResult ApproveWorkflowList(Guid? planApplicationID)
{
return base.Json(planApplicationServices.GetWorkflowApproveHistoryView(planApplicationID));
}
///
/// 导出Excel
///
///
[HttpPost]
public ActionResult Excel()
{
NpoiExcelHelper neh = new NpoiExcelHelper();
ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(null);
var campusID = Request.Form["CampusDropdown"].ParseStrTo();
var collegeID = Request.Form["CollegeDropdown"].ParseStrTo();
var yearID = Request.Form["DictionarySchoolyear"].ParseStrTo() == DropdownList.SELECT_ALL ? null : Request.Form["DictionarySchoolyear"].ParseStrTo();
var standardID = Request.Form["DictionaryStandard"].ParseStrTo() == DropdownList.SELECT_ALL ? null : Request.Form["DictionaryStandard"].ParseStrTo();
var educationID = Request.Form["DictionaryEducation"].ParseStrTo() == DropdownList.SELECT_ALL ? null : Request.Form["DictionaryEducation"].ParseStrTo();
var learningFormID = Request.Form["DictionaryLearningform"].ParseStrTo() == DropdownList.SELECT_ALL ? null : Request.Form["DictionaryLearningform"].ParseStrTo();
var schoolyear = Request.Form["SchoolyearDropdown"].ParseStrTo();
var grademajorID = Request.Form["GrademajorComboGrid"].ParseStrTo();
var approvalStatus = Request.Form["DictionaryApprovalStatus"].ParseStrTo() == DropdownList.SELECT_ALL ? null : Request.Form["DictionaryApprovalStatus"].ParseStrTo();
var LearnSystem = "";
//Request.Form["DictionaryLearnSystem"].ToString();
var dt = planApplicationServices.GetPlanApprovalViewList(configuretView, campusID, collegeID, yearID,
standardID, educationID, learningFormID, schoolyear, approvalStatus, grademajorID, LearnSystem).Select(x => new
{
x.SchoolyearCode,
x.GrademajorCode,
x.GrademajorName,
x.CourseCode,
x.CourseName,
x.CourseTypeName,
x.HandleModeName,
x.Totalhours,
x.TheoryCourse,
x.Practicehours,
x.Trialhours,
x.Credit,
x.SchoolcodeName,
x.SchoolyearNumName,
x.StarttermName,
x.CollegeName,
x.CreateTime,
x.ApprovalStatusName
}).ToTable();
string[] liststring = { "学年学期","年级专业代码", "年级专业名称","课程代码", "课程名称", "课程类型","处理方式",
"总学时","理论学时","实践学时", "实验学时","学分","学期","开课学年", "开课学期",
RSL.Get("College"), "申请时间", "审批状态" };
neh.Export(dt, liststring, "计划审核信息");
return Json(new ReturnMessage()
{
IsSuccess = true,
Message = "导出成功!"
});
}
}
}