using System;
|
using System.Collections.Generic;
|
using System.Linq;
|
using System.Text;
|
using AutoMapper;
|
using AngleSharp.Html.Parser;
|
using DTO;
|
using IServices;
|
using Microsoft.AspNetCore.Http;
|
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.Bot.Builder.Integration.AspNet.Core;
|
using Microsoft.Extensions.Logging;
|
using Newtonsoft.Json;
|
using System.Net.Http;
|
using System.Threading.Tasks;
|
using zhengcaioa.Models;
|
using zhengcaioa.IService;
|
using CommonToolsCore;
|
using Services;
|
using System.Transactions;
|
|
namespace zhengcaioa.Controllers.admin
|
{
|
[CheckLogin]
|
public class AdmDocDocController : Controller
|
{
|
private readonly ILogger<AdmDocDocController> _logger;
|
private readonly ILiaotianService _liaotianService;
|
private readonly IAdmDocDocService _admDocDocService;
|
private readonly IHrDeptService _hrDeptService;
|
private readonly IAdmDocBaseService _admDocBaseService;
|
|
|
public AdmDocDocController(ILogger<AdmDocDocController> logger, ILiaotianService liaotianService, IAdmDocDocService admDocDocService, IHrDeptService hrDeptService, IAdmDocBaseService admDocBaseService)
|
{
|
_logger = logger;
|
_liaotianService = liaotianService;
|
_admDocDocService = admDocDocService;
|
_hrDeptService = hrDeptService;
|
_admDocBaseService = admDocBaseService;
|
|
}
|
|
public IActionResult Index()
|
{
|
var curentuser = JsonConvert.DeserializeObject<PltUser>(HttpContext.Session.GetString("User"));
|
ViewData["curentuser"] = curentuser;
|
List<ActionEntity> actionlist = new List<ActionEntity>();
|
ActionEntity actionEntity = new ActionEntity();
|
actionEntity.OpenType = 0;
|
actionEntity.ActionUrl = "";
|
actionEntity.ActionFun = "Search";
|
actionEntity.PageIco = "fa fa-search";
|
actionEntity.ActionName = "查询";
|
actionlist.Add(actionEntity);
|
ActionEntity actionEntity1 = new ActionEntity();
|
actionEntity1.OpenType = 0;
|
actionEntity1.ActionUrl = "";
|
actionEntity1.ActionFun = "Add";
|
actionEntity1.PageIco = "fa fa-plus";
|
actionEntity1.ActionName = "新增";
|
actionlist.Add(actionEntity1);
|
ViewData["ActionInfo"] = actionlist;
|
|
|
|
ViewBag.DocDept = _hrDeptService.GetList().Select(x => new { code = x.Id, label = x.DeptName }).ToList();
|
|
|
ViewBag.DocType = _admDocBaseService.GetList().Select(x => new { code = x.Id, label = x.DocName }).ToList();
|
|
|
|
return View();
|
|
}
|
|
|
|
|
public IActionResult GetList(AdmDocDocDTOSearch search)
|
{
|
var curentuser = JsonConvert.DeserializeObject<PltUser>(HttpContext.Session.GetString("User"));
|
ViewData["curentuser"] = curentuser;
|
//JsonResult jsonResult = new JsonResult(_liaotianService.SearchByPaging(search), new Newtonsoft.Json.Serialization.DefaultContractResolver());
|
return new JsonResult(_admDocDocService.SearchByPaging(search));
|
}
|
|
public IActionResult Edit(string id = null)
|
{
|
var curentuser = JsonConvert.DeserializeObject<PltUser>(HttpContext.Session.GetString("User"));
|
ViewData["curentuser"] = curentuser;
|
|
AdmDocDocDTO dto = new AdmDocDocDTO();
|
if (!String.IsNullOrEmpty(id))
|
{
|
dto = _admDocDocService.Get(id);
|
}
|
else
|
{
|
dto.PublishTime = DateTime.Now;
|
|
}
|
|
|
|
ViewBag.DocDept = _hrDeptService.GetList();
|
|
|
ViewBag.DocType = _admDocBaseService.GetList();
|
|
ViewBag.PrintStatus = _liaotianService.GetSYScode("system", "shifou");
|
|
|
|
|
|
|
ViewData.Model = dto;
|
return View();
|
}
|
|
|
/// <summary>
|
/// 保存
|
/// </summary>
|
/// <param name="data">岗位实体类对象</param>
|
/// <returns></returns>
|
///
|
[HttpPost]
|
public IActionResult Save(AdmDocDocDTO data)
|
{
|
// data.DocContent = data.DocContent.Replace(";", ";");
|
ResultEntity resultEntity = new ResultEntity();
|
using (TransactionScope scope = new TransactionScope())
|
{
|
var curentuser = JsonConvert.DeserializeObject<PltUser>(HttpContext.Session.GetString("User"));
|
ViewData["curentuser"] = curentuser;
|
data.RecStatus = "A";
|
if (string.IsNullOrEmpty(data.PrintStatus))
|
{
|
data.PrintStatus = "D";
|
}
|
if (String.IsNullOrEmpty(data.Id))
|
{
|
data.Creater = curentuser.Id;
|
data.Createtime = DateTime.Now;
|
}
|
data.Modifier = curentuser.Id;
|
data.Modifytime = DateTime.Now;
|
|
resultEntity = _admDocDocService.save(data);
|
scope.Complete();
|
}
|
|
|
return new JsonResult(resultEntity);
|
}
|
|
|
/// <summary>
|
/// 删除主信息
|
/// </summary>
|
/// <param name="info">实体</param>
|
/// <returns></returns>
|
///
|
public IActionResult Nullify(string Id = "")
|
{
|
var curentuser = JsonConvert.DeserializeObject<PltUser>(HttpContext.Session.GetString("User"));
|
ViewData["curentuser"] = curentuser;
|
return new JsonResult(_admDocDocService.ModifyStatus(Id, curentuser.Id));
|
}
|
|
|
public IActionResult Print(string id)
|
{
|
var curentuser = JsonConvert.DeserializeObject<PltUser>(HttpContext.Session.GetString("User"));
|
ViewData["curentuser"] = curentuser;
|
|
AdmDocDocDTO dto = _admDocDocService.Get(id);
|
|
if (!String.IsNullOrEmpty(dto.DocDept))
|
{
|
|
dto.DocDeptName = _hrDeptService.Get(dto.DocDept).DeptName;
|
|
}
|
|
if (!String.IsNullOrEmpty(dto.DocType))
|
{
|
var docBaseDTO = _admDocBaseService.Get(dto.DocType);
|
|
dto.DocTypeName = docBaseDTO.DocName;
|
dto.DocTypeNameName = docBaseDTO.DocLuokuan;
|
}
|
|
dto.PublishTimeName = dto.PublishTime.ToString("yyyy-MM-dd");
|
|
|
ViewData.Model = dto;
|
return View();
|
}
|
}
|
}
|