天津投入产出系统后端
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

322 lines
11 KiB

using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using QMFrameWork.Common.Serialization;
using QMFrameWork.WebUI.Attribute;
using QMAPP.Web.Models.Sys;
using QMFrameWork.Data;
using QMAPP.Entity.Sys;
using QMAPP.Common.Web.Util;
using QMAPP.Common.Web.Controllers;
using QMFrameWork.WebUI.DataSource;
using QMAPP.ServicesAgent;
namespace QMAPP.Web.Controllers
{
public class UserOrgaizationController : QController
{
/// <summary>
/// 加载用户列表
/// </summary>
/// <returns>结果</returns>
[HandleException]
public ActionResult UserOrgaList()
{
UserOrgaizationModel seachModel = new UserOrgaizationModel();
TryGetSelectBuffer<UserOrgaizationModel>(out seachModel);
seachModel.rownumbers = false;
seachModel.url = "/UserOrgaization/GetList";
return View("UserOrgaizationList", seachModel);
}
/// <summary>
/// 获取用户信息列表
/// </summary>
/// <param name="callBack">是否回调</param>
/// <returns>用户信息列表</returns>
[HandleException]
public ActionResult GetList(bool? callBack)
{
List<UserOrgaizationModel> users = new List<UserOrgaizationModel>();
UserOrgaizationModel seachModel = null;
DataPage page = new DataPage();
User condition = null;
try
{
//获取查询对象
seachModel = GetModel<UserOrgaizationModel>();
#region 获取缓存值
if (callBack != null)
{
TryGetSelectBuffer<UserOrgaizationModel>(out seachModel);
}
else
{
//保存搜索条件
SetSelectBuffer<UserOrgaizationModel>(seachModel);
}
#endregion
//获取前台分页设置信息
page = this.GetDataPage(seachModel);
condition = CopyToModel<User, UserOrgaizationModel>(seachModel);
if (AccountController.GetLoginInfo().LoginUserID != "admin")
{
condition.Orgas = AccountController.GetLoginInfo().Orgas;
}
condition.CreateUser = AccountController.GetLoginInfo().UserID;
#region 普通三层架构调用
//UserOrgaizationManageBLL UserOrgaizationBll = null;
//UserOrgaizationBll = BLLFactory.CreateBLL<UserOrgaizationManageBLL>();
//page = UserOrgaizationBll.GetList(condition, page);
#endregion
DateGridResult<UserOrgaizationModel> result = new DateGridResult<UserOrgaizationModel>();
result.Total = page.RecordCount;
result.Rows = new List<UserOrgaizationModel>();
#region 普通三层架构调用
List<User> ums= (List<User>)page.Result;
#endregion
List<UserOrgaizationModel> uoml = new List<UserOrgaizationModel>();
foreach (User uom in ums)
{
result.Rows.Add(new UserOrgaizationModel { UserIDPK = uom.UserID, UserID = uom.LoginUserID, UserName = uom.UserName, OrgaID = uom.OrgaID, OrgaDESC = uom.OrgaDESC });
}
return Content(result.GetJsonSource());
}
catch (Exception ex)
{
throw ex;
}
}
#region 单表普通模式
#region 编辑
/// <summary>
/// 编辑载入
/// </summary>
/// <returns>处理结果</returns>
[HandleException]
public ActionResult UserOrgaEdit()
{
UserOrgaizationModel model = new UserOrgaizationModel();
string UserID = Request.Params["UserID"];
User user = new User();
try
{
if (string.IsNullOrEmpty(UserID) == false)
{
//修改获取原数据
user.UserID = UserID;
#region 普通三层架构调用
//UserOrgaizationManageBLL orgaBll = null;
//orgaBll = BLLFactory.CreateBLL<UserOrgaizationManageBLL>();
//user = orgaBll.Get(user);
#endregion
model = CopyToModel<UserOrgaizationModel, User>(user);
model.isEdit = "true";
}
return View("UserOrgaizationEdit", model);
}
catch (Exception ex)
{
throw ex;
}
}
#region 组织机构信息树
/// <summary>
/// 组织机构信息树
/// </summary>
/// <returns>处理结果</returns>
public ActionResult GetTreeOrgas()
{
List<TreeNodeResult> list = new List<TreeNodeResult>();
Role role = new Role();
PowerUtil pu = new PowerUtil();
pu.OwnRoles = new List<Role>();
//选择的用户编号
string userID = Request.Params["userID"];
string orgaID = Request.Params["orgaID"];
ServiceAgent wcfAgent = this.GetServiceAgent();
try
{
if (string.IsNullOrEmpty(userID) == true)
{
userID= AccountController.GetLoginInfo().UserID;
}
//获取组织机构信息
List<Orgaization> userorgas = new List<Orgaization>();
List<Orgaization> orgas = new List<Orgaization>();
//取得所有组织机构
#region 普通三层架构调用
//UserManageBLL userBll = BLLFactory.CreateBLL<UserManageBLL>();
//userorgas = userBll.GetUserOrgaList(userID);
#endregion
//取得全部组织机构
#region 普通三层架构调用
//OrgaizationManageBLL userorgaBll = BLLFactory.CreateBLL<OrgaizationManageBLL>();
//orgas = userorgaBll.GetAllList();
#endregion
bool Selected = false;
foreach (Orgaization singleorga in orgas)
{
//过滤掉当前人员主组织机构
if (singleorga.OrgaID != orgaID)
{
TreeNodeResult node = new TreeNodeResult();
node.Tid = singleorga.OrgaID;
node.Ttext = singleorga.OrgaDESC;
//循环已经存在的组织机构
foreach (Orgaization selected in userorgas)
{
//如果当前组织机构在选中范围内,结束循环,否则继续
if (selected.OrgaID == singleorga.OrgaID)
{
Selected = true;
break;
}
else
{
Selected = false;
}
}
node.TChecked = Selected;
list.Add(node);
}
}
return Content(TreeNodeResult.GetResultJosnS(list.ToArray()));
}
catch (Exception ex)
{
throw ex;
}
}
#endregion
/// <summary>
/// 保存
/// </summary>
/// <param name="model"></param>
/// <returns>处理结果</returns>
[HttpPost]
[HandleException]
public ActionResult UserOrgaSave(UserOrgaizationModel saveModel)
{
UserOrgaization orgaization = null;
ServiceAgent wcfAgent = this.GetServiceAgent();
try
{
orgaization = CopyToModel<UserOrgaization, UserOrgaizationModel>(saveModel);
//处理所选组织机构
string[] orgas = null;
if (saveModel.SelectedOrgas != null)
{
orgas = saveModel.SelectedOrgas.Split(":".ToArray());
orgaization.Orgas = new List<UserOrgaization>();
foreach (string orga in orgas)
{
orgaization.Orgas.Add(new UserOrgaization
{
UserID = saveModel.UserID,
OrgaID = orga,
IsMainOgra="0",
CreateTime = DateTime.Now,
UpdateTime = DateTime.Now,
CreateUser = AccountController.GetLoginInfo().UserID,
UpdateUser = AccountController.GetLoginInfo().UserID
});
}
}
//新增
orgaization.CreateUser = AccountController.GetLoginInfo().UserID;
//修改
orgaization.UpdateUser = AccountController.GetLoginInfo().UserID;
#region 普通三层架构调用
//UserOrgaizationManageBLL orgaBll = BLLFactory.CreateBLL<UserOrgaizationManageBLL>();
//orgaBll.Update(orgaization);
#endregion
return this.GetJsViewResult(string.Format("parent.List(1);parent.showTitle('{0}');parent.closeAppWindow1();"
, AppResource.SaveMessge));
}
catch (Exception ex)
{
throw ex;
}
}
#endregion
#endregion
#region 组织机构信息下拉菜单
public ActionResult GetOrgaList()
{
//UserManageBLL userBll = BLLFactory.CreateBLL<UserManageBLL>();
Orgaization orgaModel = new Orgaization();
List<Orgaization> list = new List<Orgaization>();
//list = userBll.GetUserOrgaList("");
ComboboxResult model = new ComboboxResult();
foreach (Orgaization o in list)
{
model.Add(new ComboboxItem { ID = o.OrgaID, Text = o.OrgaDESC });
}
return Content(model.ToString());
}
#endregion
}
}