using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.Mvc; using QMFrameWork.WebUI.Attribute; using QMAPP.Web.Models.Sys; using QMFrameWork.Data; using QMAPP.Entity.Sys; using QMAPP.Common.Web.Controllers; using QMFrameWork.WebUI.DataSource; namespace QMAPP.Web.Controllers { public class ParaAuthorityPortController : QController { /// /// 加载参数列表 /// /// 结果 [HandleException] public ActionResult ParaList() { ParaAuthorityPortModel seachModel = new ParaAuthorityPortModel(); TryGetSelectBuffer(out seachModel); seachModel.rownumbers = false; seachModel.url = "/ParaAuthorityPort/GetList"; return View("ParaList", seachModel); } /// /// 获取用户信息列表 /// /// 是否回调 /// 用户信息列表 [HandleException] public ActionResult GetList(bool? callBack) { List paras = new List(); ParaAuthorityPortModel seachModel = null; DataPage page = new DataPage(); //ParaAuthorityPortManageBLL paraBll = null; ParaAuthorityPort condition = null; try { //获取查询对象 seachModel = GetModel(); #region 获取缓存值 if (callBack != null) { TryGetSelectBuffer(out seachModel); } else { //保存搜索条件 SetSelectBuffer(seachModel); } #endregion //获取前台分页控件的分页大小 page = this.GetDataPage(seachModel); condition = CopyToModel(seachModel); //paraBll = BLLFactory.CreateBLL(); if (AccountController.GetLoginInfo().LoginUserID != "admin") { //condition.OrgaID = AccountController.GetLoginInfo().OrganID; } //page = paraBll.GetList(condition, page); DataGridResult result = new DataGridResult(); result.Total = page.RecordCount; result.Rows = (List)page.Result; foreach (ParaAuthorityPort pap in result.Rows) { //if (pap.ParaType.ToString() == "1") //{ // pap.ParaType = "仓库"; //} //if (pap.ParaType.ToString() == "2") //{ // pap.ParaType = "物料类型"; //} } return Content(result.GetJsonSource()); } catch (Exception ex) { throw ex; } } #region 编辑 /// /// 编辑载入 /// /// 处理结果 [HandleException] public ActionResult ParaEdit() { ParaAuthorityPortModel model = new ParaAuthorityPortModel(); string paraID = Request.Params["ParaID"]; ParaAuthorityPort pap = new ParaAuthorityPort(); //ParaAuthorityPortManageBLL paraBll = null; try { if (string.IsNullOrEmpty(paraID) == false) { //修改获取原数据 //pap.ParaID = paraID; //paraBll = BLLFactory.CreateBLL(); //pap = paraBll.Get(pap); model = CopyToModel(pap); model.isEdit = "true"; } return View(model); } catch (Exception ex) { throw ex; } } #region 组织机构信息树 /// /// 组织机构信息树 /// /// 处理结果 [HandleException] public ActionResult OrgaizationTree() { ParaAuthorityPortModel model = new ParaAuthorityPortModel(); model.ParaID = Request.Form["ParaID"].Split(new Char[] { ',' })[0].ToString(); model.ParaDESC = Request.Form["ParaDESC"]; model.UserID = Request.Form["UserID"]; model.UserName = Request.Form["UserName"]; model.OrgaID = Request.Form["OrgaID"]; model.OrgaDESC = Request.Form["OrgaDESC"]; model.isEdit = Request.Form["isEdit"]; model.UpdateTime = Convert.ToDateTime(Request.Form["UpdateTime"]); model.CreateTime = Convert.ToDateTime(Request.Form["CreateTime"]); model.CreateUser = Request.Form["CreateUser"]; return View(model); } public ActionResult GetTreeData() { //OrgaizationManageBLL orgaBll = BLLFactory.CreateBLL(); List list = new List(); OrgaizationModel orgaModel = new OrgaizationModel(); Orgaization orga = new Orgaization(); orga.OrgaParent = "0"; //orgaModel.OrgaList = orgaBll.GetSubTreeList(orga); //添加第一级机构 foreach (Orgaization child in orgaModel.OrgaList) { TreeNodeResult treenode = new TreeNodeResult(); treenode.Tid = child.OrgaID.ToString(); treenode.Ttext = child.OrgaDESC.ToString(); //添加子机构 this.BuildChildItems(child, treenode, list); list.Add(treenode); } return Content(TreeNodeResult.GetResultJosnS(list.ToArray())); } /// /// 创建子组织机构 /// /// 父节点 /// 子权限 private void BuildChildItems(Orgaization orga, TreeNodeResult tnr, List list) { //OrgaizationManageBLL orgaBll = BLLFactory.CreateBLL(); Orgaization corga = new Orgaization(); OrgaizationModel corgaModel = new OrgaizationModel(); corga.OrgaParent = orga.OrgaID; //corgaModel.OrgaList = orgaBll.GetSubTreeList(corga); if (corgaModel.OrgaList.Count > 0) { foreach (Orgaization child in corgaModel.OrgaList) { TreeNodeResult cTreeNode = new TreeNodeResult(); cTreeNode.Tid = child.OrgaID.ToString(); cTreeNode.Ttext = child.OrgaDESC.ToString(); tnr.AddchildNode(cTreeNode); //添加子菜单 this.BuildChildItems(child, cTreeNode, list); } } } /// /// 保存树结构数据 /// /// [HttpPost] public ActionResult SaveTree() { ParaAuthorityPortModel model = new ParaAuthorityPortModel(); model.isEdit = Request.Form["isEdit"]; model.UserID = Request.Form["UserID"]; model.ParaID = Request.Form["ParaID"]; model.ParaDESC = Request.Form["ParaDESC"]; model.UserName = Request.Form["UserName"]; model.OrgaID = Request.Form["selectKey"].Split(new Char[] { ':' })[0].ToString(); model.OrgaDESC = Request.Form["selectKey"].Split(new Char[] { ':' })[1].ToString(); model.UpdateTime = Convert.ToDateTime(Request.Form["UpdateTime"]); model.CreateTime = Convert.ToDateTime(Request.Form["CreateTime"]); model.CreateUser = Request.Form["CreateUser"]; return View("ParaEdit", model); } #endregion /// /// 保存 /// /// /// 处理结果 [HttpPost] [HandleException] public ActionResult ParaSave(ParaAuthorityPortModel saveModel) { ParaAuthorityPort pap = null; //ParaAuthorityPortManageBLL paraBll = null; try { pap = CopyToModel(saveModel); //paraBll = BLLFactory.CreateBLL(); //pap.ParaDESC = pap.ParaDESC.Split(new Char[] { ',' })[0].ToString(); if (string.IsNullOrEmpty(saveModel.isEdit) == true) { //新增 //paraBll.Insert(pap); } else { //修改 //paraBll.Update(pap); } return this.GetJsViewResult(string.Format("parent.List(1);parent.showTitle('{0}');parent.closeAppWindow1();" , AppResource.SaveMessge)); } catch (Exception ex) { throw ex; } } #endregion #region 删除 /// /// 删除用户信息 /// /// 结果 [HttpPost] [HandleException] public ActionResult ParaDelete() { string selectKey = Request.Form["selectKey"]; string[] list = selectKey.Split(":".ToCharArray()); //ParaAuthorityPortManageBLL papBll = null; try { //papBll = BLLFactory.CreateBLL(); //papBll.Delete(list); SetMessage(AppResource.DeleteMessage); return ParaList(); } catch (Exception ex) { throw ex; } } #endregion } }