using dccdc.BLL; using dccdc.Models; using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.Mvc; using static dccdc.Controllers.DictionariesController; namespace dccdc.Controllers { public class sqController : Controller { List fylyD = new List() { new Droplist { Value = "1", Title = "自有资金" }, new Droplist { Value = "2", Title = "项目经费" }, new Droplist { Value = "3", Title = "三重一大" } }; List ztD = new List() { new Droplist { Value = "1", Title = "等待科室领导审批" }, new Droplist { Value = "2", Title = "等待分管领导审批" }, new Droplist { Value = "3", Title = "等待财务领导审批" }, new Droplist { Value = "4", Title = "等待中心领导审批" }, new Droplist { Value = "5", Title = "审核完成" }, new Droplist { Value = "-1", Title = "科室领导驳回" }, new Droplist { Value = "-2", Title = "分管领导驳回" }, new Droplist { Value = "-3", Title = "财务领导驳回" }, new Droplist { Value = "-4", Title = "中心领导驳回" } }; List zfD = new List() { new Droplist { Value = "1", Title = "已支付" }, new Droplist { Value = "0", Title = "未支付" } }; List rkD = new List() { new Droplist { Value = "0", Title = "未入库" }, new Droplist { Value = "1", Title = "已入库" } }; List sortD = new List() { new Droplist { Value = "其他采购支出", Title = "其他采购支出" }, new Droplist { Value = "物资采购支出", Title = "物资采购支出" } , new Droplist { Value = "设备维修支出", Title = "设备维修支出" }, new Droplist { Value = "公务接待支出", Title = "公务接待支出" }, new Droplist { Value = "其他报销支出", Title = "其他报销支出" } }; // GET: sq public ActionResult Index() { return View(); } #region 公共 //科室领导 分管领导 财务领导 中心主任 //string[] zws = new string[] { "科室领导", "分管领导", "财务领导", "中心主任" }; private List getZW() { var user = Session["loginUser"] as Models.ERPUser; //string[] zws = user.ZhiWei.Split(','); string[] zws = new string[] { "科室领导", "分管领导", "财务领导", "中心主任" }; List zwss = new List(); if (zws.Contains("科室领导")) zwss.Add("1"); if (zws.Contains("分管领导")) zwss.Add("2"); if (zws.Contains("财务领导")) zwss.Add("3"); if (zws.Contains("中心主任")) zwss.Add("4"); return zwss; } private string getZWOne(string current) { var user = Session["loginUser"] as Models.ERPUser; //string[] zws = user.ZhiWei.Split(','); string[] zws = new string[] { "科室领导", "分管领导", "财务领导", "中心主任" }; List zwss = new List(); if (zws.Contains("科室领导") && current== "1") return "1"; if (zws.Contains("分管领导") && current == "2") return "2"; if (zws.Contains("财务领导") && current == "3") return "3"; if (zws.Contains("中心主任") && current == "4") return "4"; return ""; } //得到所有子科室id private string getChildrenKsid(int ksid) { var bll = new BLL.ERPBuMenBll(); List result = bll.GetAllChildren(ksid.ToString()); string result2 = string.Join(",", result); return " (" + result2 + ")"; } #endregion #region 查看审批过程 public ActionResult chooseSqshView(string type, string sqid) { ViewBag.type = type; ViewBag.sqid = sqid; return View(); } public JsonResult getSqsh(string type, string sqid) { var bll = new BLL.sqshBll(); var models = bll.GetListByKey(type, sqid); return Json(new { Total = 0, Rows = models }); } #endregion #region 申请采购 public ActionResult sqcg() { return View(); } public ActionResult sqcgMessage(string id) { ViewBag.fylyD = new SelectList(fylyD, "value", "title"); ViewBag.ztD = new SelectList(ztD, "value", "title"); if (!string.IsNullOrEmpty(id)) { var bll = new BLL.sqcgBll(); var model = bll.GetAllList(id).First(); return View(model); } else { var user = Session["loginUser"] as Models.ERPUser; sqcgModel model = new sqcgModel(); model.sqr = user.TrueName; model.sqdh = "后台生成"; model.ksmc = user.Department; model.fyly = 1; model.zt = 1; return View(model); } } public JsonResult getsqcgPage(int page, int pagesize, string key) { var user = Session["loginUser"] as Models.ERPUser; string where = " sqrid=" + user.ID; var bll = new BLL.sqcgBll(); int count = bll.getCountLevel(where); var models = bll.getPageLevel(page, pagesize, where); return Json(new { Total = count, Rows = models }); } public JsonResult savesqcg(string id, string je, string fyly, string fydh, string bz, string items) { var user = Session["loginUser"] as Models.ERPUser; var bll = new BLL.sqcgBll(); if (id == "" || id == "0") return Json(bll.opSave(id, user.ksid, user.Department, items, user.ID, user.TrueName, je, fyly, fydh, bz)); else return Json(bll.opSave2(id, user.ksid, user.Department, items, user.ID, user.TrueName, je, fyly, fydh, bz)); } public JsonResult deletesqcg(string id) { if (string.IsNullOrEmpty(id)) return Json(null); return Json(new BLL.sqcgBll().delete(id)); } public JsonResult getxm4(string key, string key1, string id) { var bllmx = new BLL.sqcgmxBll(); var modelmx = bllmx.GetListByParent(id); return Json(new { Rows = modelmx }); } #endregion #region 申请采购审核 public ActionResult sqcgsh() { return View(); } public ActionResult sqcgshMessage(string id) { ViewBag.fylyD = new SelectList(fylyD, "value", "title"); ViewBag.ztD = new SelectList(ztD, "value", "title"); if (!string.IsNullOrEmpty(id)) { var bll = new BLL.sqcgBll(); var model = bll.GetAllList(id).First(); ViewBag.zw = getZWOne(model.zt.ToString()); return View(model); } else { return View(); } } public JsonResult getsqcgshPage(int page, int pagesize, string key) { var user = Session["loginUser"] as Models.ERPUser; List zws = getZW(); //非职务人员 if (zws.Count == 0) return Json(null); string where = "1=2"; foreach (string zw in zws) { switch (zw) { case "1": where += " or (zt=1 and ksid=" + user.ksid + ")"; break; case "2": where += " or (zt=2 and ksid in" + getChildrenKsid(user.ksid) + ")"; break; case "3": where += " or (zt=3)"; break; //财务全部科室 case "4": where += " or (zt=4 and ksid in" + getChildrenKsid(user.ksid) + ")"; break; } } var bll = new BLL.sqcgBll(); int count = bll.getCountLevel(where); var models = bll.getPageLevel(page, pagesize, where); return Json(new { Total = count, Rows = models }); } public JsonResult savesqcgsh(string id, string yj, string ty) { var user = Session["loginUser"] as Models.ERPUser; var model = new sqshModel(); model.type = "采购申请"; model.sqid = Convert.ToInt32(id); model.spr = user.TrueName; model.sptime = DateTime.Now; model.spnr = yj; model.zt = (ty == "1") ? "通过" : "不通过"; new BLL.sqshBll().Add(model); var bll = new BLL.sqcgBll(); return Json(bll.opSp(id, user.TrueName, yj, (ty == "1") ? true : false)); } #endregion #region 申请采购查询 public ActionResult sqcgcx() { ViewBag.ztD = new SelectList(ztD, "value", "title"); ViewBag.rkD = new SelectList(rkD, "value", "title"); return View(); } public JsonResult getsqcgcxPage(int page, int pagesize, string start, string end, string zt, string rk) { string where = "1=1"; if (!string.IsNullOrEmpty(start)) { where += " and sqsj >='" + start + "'"; } if (!string.IsNullOrEmpty(start)) { where += " and sqsj <='" + end + " 23:59:59'"; } if (!string.IsNullOrEmpty(zt)) { where += " and zt=" + zt; } //if (!string.IsNullOrEmpty(rk)) //{ // if (rk == "1") // where += " and rkr is not null"; // else // where += " and rkr is null"; //} var bll = new BLL.sqcgBll(); int count = bll.getCountLevel(where); var models = bll.getPageLevel(page, pagesize, where); return Json(new { Total = count, Rows = models }); } #endregion #region 申请采购打印 [AllowAnonymous] public string sqcgdy(string id) { var bll = new sqcgBll(); if (string.IsNullOrEmpty(id)) return ""; return Newtonsoft.Json.JsonConvert.SerializeObject(bll.GetAllList(id)); } [AllowAnonymous] public string sqcgdymx(string sqdid) { var bll = new sqcgmxBll(); if (string.IsNullOrEmpty(sqdid)) return ""; return Newtonsoft.Json.JsonConvert.SerializeObject(bll.GetListByParent(sqdid)); } #endregion } }