123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Web;
- using System.Web.Mvc;
- using Bowin.Web.Controls.Mvc;
- using Bowin.Common.Utility;
- using Bowin.Common.Data;
- using EMIS.CommonLogic.SystemSetting;
- using EMIS.ViewModel;
- using EMIS.Web.Controls;
- using EMIS.ViewModel.SystemSetting;
- namespace EMIS.Web.Controllers.SystemManage.SystemSetting
- {
- [Authorization]
- public class DictionaryController : Controller
- {
- public Lazy<IDictionaryServices> DictionaryServices { get; set; }
- /// <summary>
- /// 字典类型页面
- /// </summary>
- /// <returns></returns>
- [HttpGet]
- 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 isEditable = pararms.getExtraInt("DictionaryIsEditable") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionaryIsEditable");
-
- return base.Json(DictionaryServices.Value.GetDictionaryViewGird(configuretView,
- isEditable, (int)pararms.page, (int)pararms.rows));
- }
- /// <summary>
- /// 编辑(修改)
- /// </summary>
- /// <param name="dictionaryCode"></param>
- /// <returns></returns>
- [HttpGet]
- public ActionResult Edit(string dictionaryCode)
- {
- DictionaryView dictionaryView = new DictionaryView();
- if (!string.IsNullOrEmpty(dictionaryCode))
- {
- dictionaryView = DictionaryServices.Value.GetDictionaryView(dictionaryCode);
- }
- else
- {
- dictionaryView.IsEditable = true;
- }
- return View(dictionaryView);
- }
- /// <summary>
- /// 编辑(修改)
- /// </summary>
- /// <param name="dictionaryView"></param>
- /// <returns></returns>
- [HttpPost]
- public ActionResult Edit(DictionaryView dictionaryView)
- {
- try
- {
- DictionaryServices.Value.DictionaryEdit(dictionaryView);
- return Json(new ReturnMessage()
- {
- IsSuccess = true,
- Message = "保存成功。"
- });
- }
- catch (Exception ex)
- {
- return Json(new ReturnMessage()
- {
- IsSuccess = false,
- Message = "保存失败:" + ex.Message
- });
- }
- }
- /// <summary>
- /// 删除
- /// </summary>
- /// <param name="dictionaryCodes"></param>
- /// <returns></returns>
- [HttpPost]
- public ActionResult Delete(string dictionaryCodes)
- {
- try
- {
- var list = dictionaryCodes.Split(',').Where(x => !string.IsNullOrEmpty(x))
- .Select(x => x).ToList();
- DictionaryServices.Value.DictionaryDelete(list);
- return Json(new ReturnMessage()
- {
- IsSuccess = true,
- Message = "删除成功。"
- });
- }
- catch (Exception ex)
- {
- return Json(new ReturnMessage()
- {
- IsSuccess = false,
- Message = "删除失败:" + ex.Message
- });
- }
- }
- /// <summary>
- /// Excel导出
- /// </summary>
- /// <returns></returns>
- [HttpPost]
- public ActionResult Excel()
- {
- NpoiExcelHelper neh = new NpoiExcelHelper();
- ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(null);
- //可否编辑
- var isEditable = Request.Form["DictionaryIsEditable"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["DictionaryIsEditable"].ParseStrTo<int>();
-
- var dt = DictionaryServices.Value.GetDictionaryViewList(configuretView, isEditable)
- .Select(x => new
- {
- x.OrderNo,
- x.DictionaryCode,
- x.DictionaryName,
- x.IsEditableName
- }).ToTable();
- string[] liststring = {
- "序号 ", "类型代码 ", "类型名称 ", "可否编辑"
- };
- neh.Export(dt, liststring, "字典类型信息" + DateTime.Now.ToString("yyyyMMdd"));
- return Json(new ReturnMessage()
- {
- IsSuccess = true,
- Message = "导出成功。"
- });
- }
- }
- }
|