123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265 |
- 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.SystemSetting;
- using EMIS.ViewModel.SystemView;
- using Bowin.Common.Utility;
- using Bowin.Common.Data;
- namespace EMIS.Web.Controllers.SystemManage.SystemSetting
- {
- [Authorization]
- public class DictionaryItemController : Controller
- {
- public Lazy<IDictionaryItemServices> DictionaryItemServices { get; set; }
- /// <summary>
- /// 数据字典(字典元素)页面
- /// </summary>
- /// <returns></returns>
- public ActionResult List()
- {
- return View();
- }
- /// <summary>
- /// 数据字典列表查询
- /// </summary>
- /// <param name="pararms"></param>
- /// <returns></returns>
- [HttpPost]
- public ActionResult List(QueryParamsModel pararms)
- {
- ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms);
- //类型名称
- var dictionaryCode = pararms.getExtraString("DictionaryDropdown");
- //可否编辑
- var isEditable = pararms.getExtraInt("DictionaryIsEditable") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionaryIsEditable");
- //可否显示
- var isVisible = pararms.getExtraInt("DictionaryIsVisible") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionaryIsVisible");
- return base.Json(DictionaryItemServices.Value.GetDictionaryItemViewGird(configuretView, dictionaryCode,
- isEditable, isVisible, (int)pararms.page, (int)pararms.rows));
- }
- /// <summary>
- /// 复制新增
- /// </summary>
- /// <param name="dictionaryItemID"></param>
- /// <returns></returns>
- public ActionResult CopyAdd(Guid dictionaryItemID)
- {
- DictionaryItemView dictionaryItemView = new DictionaryItemView();
- dictionaryItemView = DictionaryItemServices.Value.GetDictionaryItemView(dictionaryItemID);
- return View("Edit", dictionaryItemView);
- }
- /// <summary>
- /// 复制新增
- /// </summary>
- /// <param name="dictionaryItemView"></param>
- /// <returns></returns>
- [HttpPost]
- public ActionResult CopyAdd(DictionaryItemView dictionaryItemView)
- {
- dictionaryItemView.DictionaryItemID = Guid.Empty;
- return this.Edit(dictionaryItemView);
- }
- /// <summary>
- /// 编辑(新增、修改,业务主键:类型代码、元素值-Value)
- /// </summary>
- /// <param name="dictionaryItemID"></param>
- /// <returns></returns>
- [HttpGet]
- public ActionResult Edit(Guid? dictionaryItemID)
- {
- ViewBag.Type = Request.Params["Type"];//临时性加参数控制、屏蔽列表进入无保存按钮权限
- DictionaryItemView dictionaryItemView = new DictionaryItemView();
- if (dictionaryItemID.HasValue && dictionaryItemID != Guid.Empty)
- {
- dictionaryItemView = DictionaryItemServices.Value.GetDictionaryItemView(dictionaryItemID);
- }
- else
- {
- dictionaryItemView.IsEditable = true;
- dictionaryItemView.IsVisible = true;
- }
- return View(dictionaryItemView);
- }
- /// <summary>
- /// 编辑(新增、修改,业务主键:类型代码、元素值-Value)
- /// </summary>
- /// <param name="dictionaryItemView"></param>
- /// <returns></returns>
- [HttpPost]
- public ActionResult Edit(DictionaryItemView dictionaryItemView)
- {
- try
- {
- DictionaryItemServices.Value.DictionaryItemEdit(dictionaryItemView);
- return Json(new ReturnMessage()
- {
- IsSuccess = true,
- Message = "保存成功。"
- });
- }
- catch (Exception ex)
- {
- return Json(new ReturnMessage()
- {
- IsSuccess = false,
- Message = "保存失败,原因:" + ex.Message
- });
- }
- }
- /// <summary>
- /// 删除(只可删除可编辑的信息)
- /// </summary>
- /// <param name="dictionaryItemIDs"></param>
- /// <returns></returns>
- [HttpPost]
- public ActionResult Delete(string dictionaryItemIDs)
- {
- try
- {
- List<Guid?> list = dictionaryItemIDs.Split(',').Where(x => !string.IsNullOrEmpty(x))
- .Select(x => (Guid?)new Guid(x)).ToList();
- DictionaryItemServices.Value.DictionaryItemDelete(list);
- return Json(new ReturnMessage()
- {
- IsSuccess = true,
- Message = "删除成功。"
- });
- }
- catch (Exception ex)
- {
- return Json(new ReturnMessage()
- {
- IsSuccess = false,
- Message = "删除失败,原因:" + ex.Message
- });
- }
- }
- /// <summary>
- /// 数据字典下拉列表
- /// </summary>
- /// <param name="pararms"></param>
- /// <param name="dictionaryCode"></param>
- /// <returns></returns>
- [HttpPost]
- public ActionResult ComboGridList(QueryParamsModel pararms, string dictionaryCode = null)
- {
- ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms);
- //避开全选值
- if (string.IsNullOrEmpty(dictionaryCode))
- {
- dictionaryCode = pararms.getExtraString("DictionaryDropdown");
- }
- if (configuretView.Attribute == DropdownList.SELECT_ALL.ToString())
- {
- configuretView.Attribute = "";
- }
- return base.Json(DictionaryItemServices.Value.GetDictionaryViewComboGrid(configuretView, dictionaryCode, (int)pararms.page, (int)pararms.rows));
- }
- /// <summary>
- /// 数据字典下拉列表(市)
- /// </summary>
- /// <param name="pararms"></param>
- /// <returns></returns>
- [HttpPost]
- public ActionResult CityComboGridList(QueryParamsModel pararms)
- {
- ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms);
- var proviceCode = pararms.getExtraString("ProviceCode");
- if (configuretView.Attribute == DropdownList.SELECT_ALL.ToString())
- {
- configuretView.Attribute = "";
- }
- return base.Json(DictionaryItemServices.Value.GetCityComboGrid(configuretView,
- (int)pararms.page, (int)pararms.rows, proviceCode));
- }
- /// <summary>
- /// 数据字典下拉列表(县、区)
- /// </summary>
- /// <param name="pararms"></param>
- /// <returns></returns>
- [HttpPost]
- public ActionResult DistrictComboGridList(QueryParamsModel pararms)
- {
- ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms);
- var cityCode = pararms.getExtraString("CityCode");
- if (configuretView.Attribute == DropdownList.SELECT_ALL.ToString())
- {
- configuretView.Attribute = "";
- }
- return base.Json(DictionaryItemServices.Value.GetDistrictComboGrid(configuretView,
- (int)pararms.page, (int)pararms.rows, cityCode));
- }
- /// <summary>
- /// Excel导出
- /// </summary>
- /// <returns></returns>
- [HttpPost]
- public ActionResult Excel()
- {
- NpoiExcelHelper neh = new NpoiExcelHelper();
- ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(null);
- //类型名称
- var dictionaryCode = Request.Form["DictionaryDropdown"].ToString();
- //可否编辑
- var isEditable = Request.Form["DictionaryIsEditable"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["DictionaryIsEditable"].ParseStrTo<int>();
- //可否显示
- var isVisible = Request.Form["DictionaryIsVisible"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["DictionaryIsVisible"].ParseStrTo<int>();
- var dt = DictionaryItemServices.Value.GetDictionaryItemViewList(configuretView, dictionaryCode, isEditable, isVisible)
- .Select(x => new
- {
- x.DictionaryCode,
- x.DictionaryName,
- x.OrderNo,
- x.Code,
- x.Name,
- x.Value,
- x.IsEditableName,
- x.IsVisibleName
- }).ToTable();
- string[] liststring = {
- "类型代码 ", "类型名称 ", "序号 ", "元素代码 ",
- "元素名称 ", "元素值 ", "可否编辑", "可否显示"
- };
- neh.Export(dt, liststring, "数据字典信息" + DateTime.Now.ToString("yyyyMMdd"));
- return Json(new ReturnMessage()
- {
- IsSuccess = true,
- Message = "导出成功。"
- });
- }
- }
- }
|