|
|
using Estsh.Core.Controllers;
|
|
|
using Estsh.Core.IRepositories;
|
|
|
using Estsh.Core.IServices;
|
|
|
using Estsh.Core.Models;
|
|
|
using Estsh.Core.Util;
|
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
using System.Collections;
|
|
|
using System.Text;
|
|
|
|
|
|
/***************************************************************************************************
|
|
|
*
|
|
|
* 更新人:sitong.dong
|
|
|
* 描述:部门管理
|
|
|
* 修改时间:2022.06.22
|
|
|
* 修改日志:系统迭代升级
|
|
|
*
|
|
|
**************************************************************************************************/
|
|
|
namespace Estsh.Core.Web.Controllers
|
|
|
{
|
|
|
//[Route("[controller]")]
|
|
|
//[ApiController]
|
|
|
public class DeptController : BaseController
|
|
|
{
|
|
|
private IDeptService service;
|
|
|
public DeptController(IDeptService _service)
|
|
|
{
|
|
|
service = _service;
|
|
|
}
|
|
|
|
|
|
//[HttpGet("index")]
|
|
|
public IActionResult Index()
|
|
|
{
|
|
|
return View();
|
|
|
}
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
/// 获取部门管理列表数据
|
|
|
/// </summary>
|
|
|
/// <param name="DeptName">菜单名称</param>
|
|
|
/// <param name="pager">分页</param>
|
|
|
/// <param name="direction">排序方式</param>
|
|
|
/// <param name="sort">排序列</param>
|
|
|
/// <returns></returns>
|
|
|
//[HttpPost("getDeptListByPage")]
|
|
|
public ActionResult getDeptListByPage(string deptName,Pager pager, String direction, String sort, String enabled = "Y")
|
|
|
{
|
|
|
Hashtable result = new Hashtable();
|
|
|
result.Add("pager.pageNo", pager.pageNo);
|
|
|
Hashtable dataHt = this.service.getDeptListByPage(deptName, enabled, pager, direction, sort);
|
|
|
result.Add("rows", dataHt["dataList"]);
|
|
|
result.Add("pager.totalRows", dataHt["totalCount"]);
|
|
|
result.Add("sort", sort);
|
|
|
result.Add("direction", direction);
|
|
|
return Json(result);
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 新增跳转
|
|
|
/// </summary>
|
|
|
/// <returns></returns>
|
|
|
public ActionResult AddDept()
|
|
|
{
|
|
|
return View("EditDept");
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 保存数据
|
|
|
/// </summary>
|
|
|
/// <returns></returns>
|
|
|
//[HttpPost("saveDept")]
|
|
|
public ActionResult saveDept([FromForm] SysDept dept1, string editType1)
|
|
|
{
|
|
|
SysDept dept = new SysDept();
|
|
|
String editType = Request.Form["editType"].ToString();
|
|
|
|
|
|
dept.DeptCode = Request.Form["deptCode"].ToString();
|
|
|
dept.DeptName = Request.Form["deptName"].ToString();
|
|
|
dept.DeptDesc = Request.Form["deptDesc"].ToString();
|
|
|
|
|
|
String message = "";
|
|
|
if (editType != null && editType.Trim().Equals("edit"))
|
|
|
{
|
|
|
try
|
|
|
{
|
|
|
if (!string.IsNullOrEmpty(Request.Form["deptId"].ToString()))
|
|
|
{
|
|
|
dept.DeptId = int.Parse(Request.Form["deptId"]);
|
|
|
}
|
|
|
dept.UpdateUserId = CurrentEmp.EmpId;
|
|
|
this.service.updateDept(dept);
|
|
|
message = "修改成功";
|
|
|
}
|
|
|
catch (Exception e)
|
|
|
{
|
|
|
message = "修改失败!";
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
try
|
|
|
{
|
|
|
dept.CreateUserId =CurrentEmp.EmpId;
|
|
|
dept.Guid = System.Guid.NewGuid().ToString();
|
|
|
this.service.saveDept(dept);
|
|
|
message = "添加成功";
|
|
|
}
|
|
|
catch (Exception e)
|
|
|
{
|
|
|
message = "添加失败!";
|
|
|
}
|
|
|
}
|
|
|
|
|
|
Hashtable result = new Hashtable();
|
|
|
result.Add("message", message);
|
|
|
return Json(result);
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 查看详情
|
|
|
/// </summary>
|
|
|
/// <param name="ruid"></param>
|
|
|
/// <returns></returns>
|
|
|
//[HttpGet("getDept")]
|
|
|
public ActionResult getDept(String deptId)
|
|
|
{
|
|
|
List<SysDept> DeptInfo = service.getDept(deptId);
|
|
|
if (DeptInfo != null && DeptInfo.Count > 0)
|
|
|
{
|
|
|
ViewData.Add("deptCode", DeptInfo[0].DeptCode);
|
|
|
ViewData.Add("deptName", DeptInfo[0].DeptName);
|
|
|
ViewData.Add("deptDesc", DeptInfo[0].DeptDesc);
|
|
|
}
|
|
|
return View("ViewDept");
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 编辑
|
|
|
/// </summary>
|
|
|
/// <param name="ruid"></param>
|
|
|
/// <returns></returns>
|
|
|
//[HttpPost("editDept")]
|
|
|
public ActionResult EditDept(String deptId)
|
|
|
{
|
|
|
if (!string.IsNullOrEmpty(deptId))
|
|
|
{
|
|
|
List<SysDept> DeptInfo = this.service.getDept(deptId);
|
|
|
SysDept htDeptInfo = DeptInfo[0];
|
|
|
ViewData.Add("editType", "edit");
|
|
|
ViewData.Add("deptCode", htDeptInfo.DeptCode);
|
|
|
ViewData.Add("deptName", htDeptInfo.DeptName);
|
|
|
ViewData.Add("deptDesc", htDeptInfo.DeptDesc);
|
|
|
ViewData.Add("deptId", htDeptInfo.DeptId);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
ViewData.Add("editType", "new");
|
|
|
}
|
|
|
|
|
|
return View();
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 删除
|
|
|
/// </summary>
|
|
|
/// <param name="ids"></param>
|
|
|
/// <returns></returns>
|
|
|
public ActionResult deleteDept(String ids)
|
|
|
{
|
|
|
int delCount = 0;
|
|
|
try
|
|
|
{
|
|
|
delCount = this.service.deleteDept(ids);
|
|
|
}
|
|
|
catch (Exception e)
|
|
|
{
|
|
|
delCount = -1;
|
|
|
}
|
|
|
Hashtable result = new Hashtable();
|
|
|
result.Add("status", delCount);
|
|
|
return Json(result);
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 启用
|
|
|
/// </summary>
|
|
|
/// <param name="ids"></param>
|
|
|
/// <returns></returns>
|
|
|
public ActionResult onEnable(String ids)
|
|
|
{
|
|
|
int delCount = 0;
|
|
|
try
|
|
|
{
|
|
|
delCount = this.service.EnableData(ids);
|
|
|
}
|
|
|
catch (Exception e)
|
|
|
{
|
|
|
delCount = -1;
|
|
|
}
|
|
|
Hashtable result = new Hashtable();
|
|
|
result.Add("status", delCount);
|
|
|
return Json(result);
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 禁用
|
|
|
/// </summary>
|
|
|
/// <param name="ids"></param>
|
|
|
/// <returns></returns>
|
|
|
public ActionResult onDisable(String ids)
|
|
|
{
|
|
|
int delCount = 0;
|
|
|
try
|
|
|
{
|
|
|
delCount = this.service.DisableData(ids);
|
|
|
}
|
|
|
catch (Exception e)
|
|
|
{
|
|
|
delCount = -1;
|
|
|
}
|
|
|
Hashtable result = new Hashtable();
|
|
|
result.Add("status", delCount);
|
|
|
return Json(result);
|
|
|
}
|
|
|
}
|
|
|
}
|