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.
596 lines
22 KiB
596 lines
22 KiB
using System;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using System.Data;
|
|
using System.Linq;
|
|
using System.Web;
|
|
using System.Web.Mvc;
|
|
using System.Web.Mvc.Html;
|
|
using QMFrameWork.Common.Serialization;
|
|
using QMFrameWork.Data;
|
|
using QMFrameWork.WebUI.Util;
|
|
using QMFrameWork.WebUI.Attribute;
|
|
using QMFrameWork.WebUI.DataSource;
|
|
using QMAPP.Entity.Sys.Entity;
|
|
using QMAPP.Entity.Sys;
|
|
using QMAPP.Common.Web.Controllers;
|
|
using QMAPP.Common.Web.Models;
|
|
using QMAPP.Web.Models.Sys;
|
|
using QMAPP.Common.Web.Util;
|
|
using QMAPP.ServicesAgent;
|
|
|
|
namespace QMAPP.Web.Controllers
|
|
{
|
|
/// <summary>
|
|
/// 委托授权
|
|
/// </summary>
|
|
public class EntrustController : QController
|
|
{
|
|
#region 列表页面加载
|
|
|
|
/// <summary>
|
|
/// 列表页面加载
|
|
/// </summary>
|
|
/// <returns>结果</returns>
|
|
[HandleException]
|
|
public ActionResult List(bool? callBack)
|
|
{
|
|
UserEntrustModel seachModel = new UserEntrustModel();
|
|
|
|
if (callBack == true)
|
|
TryGetSelectBuffer<UserEntrustModel>(out seachModel);
|
|
|
|
seachModel.rownumbers = false;
|
|
seachModel.url = "/Entrust/GetList";
|
|
|
|
return View("UserEntrustList", seachModel);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 获取列表数据
|
|
/// </summary>
|
|
/// <param name="callBack">是否回调</param>
|
|
/// <returns>用户列表</returns>
|
|
[HandleException]
|
|
public ActionResult GetList(bool? callBack)
|
|
{
|
|
UserEntrustModel seachModel = null;
|
|
DataPage page = new DataPage();
|
|
UserEntrust condition = null;
|
|
try
|
|
{
|
|
//获取查询对象
|
|
seachModel = GetModel<UserEntrustModel>();
|
|
|
|
#region 获取缓存值
|
|
if (callBack != null)
|
|
{
|
|
TryGetSelectBuffer<UserEntrustModel>(out seachModel);
|
|
}
|
|
else
|
|
{
|
|
//保存搜索条件
|
|
SetSelectBuffer<UserEntrustModel>(seachModel);
|
|
}
|
|
|
|
#endregion
|
|
|
|
//获取前台分页设置信息
|
|
page = this.GetDataPage(seachModel);
|
|
|
|
condition = CopyToModel<UserEntrust, UserEntrustModel>(seachModel);
|
|
|
|
if (string.IsNullOrEmpty(seachModel.STARTDATE) == false)
|
|
{
|
|
condition.STARTTIME = DateTime.Parse(seachModel.STARTDATE);
|
|
}
|
|
if (string.IsNullOrEmpty(seachModel.ENDDATE) == false)
|
|
{
|
|
condition.STARTTIME = DateTime.Parse(seachModel.ENDDATE);
|
|
}
|
|
|
|
QMAPP.ServicesAgent.ServiceAgent agent = this.GetServiceAgent();
|
|
|
|
page = agent.InvokeServiceFunction<DataPage>("UserEntrustBLL_GetList", condition, page);
|
|
|
|
DataGridResult<UserEntrust> result = new DataGridResult<UserEntrust>();
|
|
result.Total = page.RecordCount;
|
|
result.Rows = JsonConvertHelper.GetDeserialize<List<UserEntrust>>(page.Result.ToString());
|
|
|
|
return Content(result.GetJsonSource());
|
|
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw ex;
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region 编辑载入
|
|
|
|
/// <summary>
|
|
/// 编辑载入
|
|
/// </summary>
|
|
/// <returns>处理结果</returns>
|
|
[HandleException]
|
|
public ActionResult Edit()
|
|
{
|
|
UserEntrustModel model = new UserEntrustModel();
|
|
string id = Request.QueryString["id"];
|
|
UserEntrust info = new UserEntrust();
|
|
try
|
|
{
|
|
|
|
if (string.IsNullOrEmpty(id) == false)
|
|
{
|
|
//修改获取原数据
|
|
info.PID = id;
|
|
QMAPP.ServicesAgent.ServiceAgent agent = this.GetServiceAgent();
|
|
info = agent.InvokeServiceFunction<UserEntrust>("UserEntrustBLL_Get",info);
|
|
|
|
model = CopyToModel<UserEntrustModel, UserEntrust>(info);
|
|
}
|
|
|
|
return View("UserEntrustEdit", model);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw ex;
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region 保存
|
|
|
|
/// <summary>
|
|
/// 保存
|
|
/// </summary>
|
|
/// <param name="model"></param>
|
|
/// <returns>处理结果</returns>
|
|
[HttpPost]
|
|
[HandleException]
|
|
public ActionResult Save(UserEntrustModel saveModel)
|
|
{
|
|
UserEntrust info = null;
|
|
try
|
|
{
|
|
info=CopyToModel<UserEntrust, UserEntrustModel>(saveModel);
|
|
|
|
info.AuthorityList = saveModel.SelectedPowers;
|
|
|
|
QMAPP.ServicesAgent.ServiceAgent agent = this.GetServiceAgent();
|
|
if (string.IsNullOrEmpty(info.PID) == true)
|
|
{
|
|
//新增
|
|
agent.InvokeServiceFunction("UserEntrustBLL_Insert", info);
|
|
}
|
|
else
|
|
{
|
|
//修改
|
|
agent.InvokeServiceFunction("UserEntrustBLL_Update", info);
|
|
}
|
|
|
|
return this.GetJsViewResult(string.Format("parent.List(1);parent.showTitle('{0}');parent.closeAppWindow1();"
|
|
, AppResource.SaveMessge));
|
|
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw ex;
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region 删除
|
|
|
|
/// <summary>
|
|
/// 删除用户
|
|
/// </summary>
|
|
/// <returns>结果</returns>
|
|
[HttpPost]
|
|
[HandleException]
|
|
public ActionResult Delete()
|
|
{
|
|
string selectKey = Request.Form["selectKey"];
|
|
string[] list = selectKey.Split(":".ToCharArray());
|
|
ArrayList infos = new ArrayList();
|
|
QMAPP.ServicesAgent.ServiceAgent agent = this.GetServiceAgent();
|
|
try
|
|
{
|
|
//删除
|
|
foreach (string id in list)
|
|
{
|
|
infos.Add(id);
|
|
}
|
|
|
|
agent.InvokeServiceFunction("UserEntrustBLL_DeleteList", infos);
|
|
|
|
SetMessage(AppResource.DeleteMessage);
|
|
|
|
return List(true);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw ex;
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region 权限信息树
|
|
/// <summary>
|
|
/// 权限信息树
|
|
/// </summary>
|
|
/// <returns>处理结果</returns>
|
|
public ActionResult GetTreePowers()
|
|
{
|
|
List<TreeNodeResult> list = new List<TreeNodeResult>();
|
|
List<PowerInfo> allPowers = null;
|
|
PowerUtil pu = new PowerUtil();
|
|
List<string> userPowers=new List<string>();
|
|
pu.OwnPowers = new List<PowerInfo>();
|
|
string userID = Request.Params["userID"];
|
|
string id = Request.Params["id"];
|
|
try
|
|
{
|
|
|
|
if (string.IsNullOrEmpty(userID) == true)
|
|
{
|
|
return Content(TreeNodeResult.GetResultJosnS(list.ToArray()));
|
|
}
|
|
if (string.IsNullOrEmpty(id) == false)
|
|
{
|
|
UserEntrust ue = new UserEntrust();
|
|
ue.PID = id;
|
|
ue.ENTRUSTUSERID = userID;
|
|
|
|
//获取委托授权信息
|
|
QMAPP.ServicesAgent.ServiceAgent agent = this.GetServiceAgent();
|
|
ue = agent.InvokeServiceFunction<UserEntrust>("UserEntrustBLL_Get", ue);
|
|
|
|
//设置代理权限
|
|
foreach (UserAuthority power in ue.EUAuthoritys)
|
|
{
|
|
userPowers.Add(power.AuthorityID);
|
|
}
|
|
|
|
//设置已授权权限
|
|
foreach (T_QM_ENTRUSTAUTHORITY power in ue.Authoritys)
|
|
{
|
|
pu.OwnPowers.Add(new PowerInfo { PowerID = power.AUTHORITYID });
|
|
}
|
|
}
|
|
else
|
|
{
|
|
//获取用户信息
|
|
User info = new User();
|
|
info.UserID = userID;
|
|
QMAPP.ServicesAgent.ServiceAgent agent = this.GetServiceAgent();
|
|
info = agent.InvokeServiceFunction<User>("UserManageBLL_Get", info);
|
|
|
|
//设置代理权限
|
|
foreach (UserAuthority power in info.Authoritys)
|
|
{
|
|
userPowers.Add(power.AuthorityID);
|
|
}
|
|
}
|
|
|
|
|
|
//获取当前登录系统的用户,全部权限信息
|
|
allPowers = new List<PowerInfo>();
|
|
List<string> files = new List<string> { "Main" };
|
|
//List<string> files = new List<string> { "Main", "MainData", "Report" };
|
|
foreach (string f in files)
|
|
{
|
|
List<PowerInfo> powers = pu.GetAllPowerInfos(MvcApplication.PhysicsRootPath + @"App_Data\"+f+"Power.xml");
|
|
allPowers.AddRange(powers);
|
|
}
|
|
|
|
allPowers = allPowers.Where(p => userPowers.IndexOf(p.PowerID) >= 0).ToList();
|
|
|
|
foreach (PowerInfo info in allPowers)
|
|
{
|
|
TreeNodeResult node = new TreeNodeResult();
|
|
node.Tid = info.PowerID;
|
|
node.Ttext = info.PowerDes;
|
|
node.TChecked = info.Selected;
|
|
//添加子权限
|
|
this.BuildChildItems(node, info.ChildPowers, pu);
|
|
|
|
list.Add(node);
|
|
}
|
|
return Content(TreeNodeResult.GetResultJosnS(list.ToArray()));
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw ex;
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// 创建子权限
|
|
/// </summary>
|
|
/// <param name="parentNode">父节点</param>
|
|
/// <param name="childPowers">子权限</param>
|
|
/// <param name="pu">已经选中的权限列表</param>
|
|
private void BuildChildItems(TreeNodeResult parentNode, List<PowerInfo> childPowers, PowerUtil pu)
|
|
{
|
|
foreach (PowerInfo info in childPowers)
|
|
{
|
|
TreeNodeResult node = new TreeNodeResult();
|
|
node.Tid = info.PowerID;
|
|
node.Ttext = info.PowerDes;
|
|
node.TChecked = info.Selected;
|
|
if (info.ChildPowers != null)
|
|
{
|
|
//添加子权限
|
|
this.BuildChildItems(node, info.ChildPowers, pu);
|
|
}
|
|
parentNode.AddchildNode(node);
|
|
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region 业务权限设置页面加载
|
|
|
|
[HandleException]
|
|
public ActionResult SetBusiPower()
|
|
{
|
|
UserEntrustPowerModel model = new UserEntrustPowerModel();
|
|
string id = Request.QueryString["id"];
|
|
UserEntrustBusiPower info = new UserEntrustBusiPower();
|
|
int seq = 0;
|
|
if (string.IsNullOrEmpty(id) == false)
|
|
{
|
|
//修改获取原数据
|
|
info.PID = id;
|
|
QMAPP.ServicesAgent.ServiceAgent agent = this.GetServiceAgent();
|
|
info = agent.InvokeServiceFunction<UserEntrustBusiPower>("UserEntrustBLL_GetBusiInfo", info);
|
|
|
|
model = CopyToModel<UserEntrustPowerModel, UserEntrustBusiPower>(info);
|
|
|
|
|
|
//仓库权限
|
|
DateGridResult<UserCorpModel> corpResult = new DateGridResult<UserCorpModel>();
|
|
corpResult.Total = info.CorpPowers.Count;
|
|
corpResult.Rows = new List<UserCorpModel>();
|
|
seq = 1;
|
|
model.SelectedCorp = "";
|
|
foreach (UserCorpPower corp in info.CorpPowers)
|
|
{
|
|
model.SelectedCorp += "," + corp.CORPID;
|
|
corpResult.Rows.Add(new UserCorpModel { Seq = seq, CORPID = corp.CORPID, CORPCODE = corp.CORPCODE, CORPNAME = corp.CORPNAME, DeleteAction = "deleteCorp('" + corp.CORPID + "')" });
|
|
seq++;
|
|
}
|
|
if (model.SelectedCorp != "")
|
|
model.SelectedCorp = model.SelectedCorp.Substring(1);
|
|
model.CorpList = corpResult.GetJsonSource();
|
|
|
|
//路线权限
|
|
DateGridResult<UserLineModel> lineResult = new DateGridResult<UserLineModel>();
|
|
lineResult.Total = info.LinePowers.Count;
|
|
lineResult.Rows = new List<UserLineModel>();
|
|
seq = 1;
|
|
foreach (UserLinePower line in info.LinePowers)
|
|
{
|
|
lineResult.Rows.Add(new UserLineModel { Seq = seq, CORPID = line.CORPID, CORPNAME = line.CORPNAME, LINEID = line.LINEID, LINENO = line.LINENO, LINENAME = line.LINENAME, DeleteAction = "deleteLine('" + line.LINEID + "')" });
|
|
seq++;
|
|
}
|
|
model.LineList = lineResult.GetJsonSource();
|
|
|
|
//零件类别权限
|
|
DateGridResult<UserMatSortModel> matSortResult = new DateGridResult<UserMatSortModel>();
|
|
matSortResult.Total = info.MatSortPowers.Count;
|
|
matSortResult.Rows = new List<UserMatSortModel>();
|
|
seq = 1;
|
|
foreach (UserMatSortPower matSort in info.MatSortPowers)
|
|
{
|
|
matSortResult.Rows.Add(new UserMatSortModel { Seq = seq, MATSORTID = matSort.MATSORTID, MATSORTNO = matSort.MATSORTNO, MATSORTNAME = matSort.MATSORTNAME, DeleteAction = "deleteMatSort('" + matSort.MATSORTID + "')" });
|
|
seq++;
|
|
}
|
|
model.MatSortList = matSortResult.GetJsonSource();
|
|
|
|
//要货地权限
|
|
DateGridResult<UserReqPlaceModel> reqPlaceResult = new DateGridResult<UserReqPlaceModel>();
|
|
reqPlaceResult.Total = info.ReqPlacePowers.Count;
|
|
reqPlaceResult.Rows = new List<UserReqPlaceModel>();
|
|
seq = 1;
|
|
foreach (UserReqPlacePower reqPlace in info.ReqPlacePowers)
|
|
{
|
|
reqPlaceResult.Rows.Add(new UserReqPlaceModel { Seq = seq, PLACEDISID = reqPlace.PLACEDISID, PLACEDISNO = reqPlace.PLACEDISNO, DESCRIBE_SITE = reqPlace.DESCRIBE_SITE, DeleteAction = "deleteReqPlace('" + reqPlace.PLACEDISID + "')" });
|
|
seq++;
|
|
}
|
|
model.RequestPlaceList = reqPlaceResult.GetJsonSource();
|
|
|
|
//发货地权限
|
|
DateGridResult<UserSendPlaceModel> sendPlaceResult = new DateGridResult<UserSendPlaceModel>();
|
|
sendPlaceResult.Total = info.SendPlacePowers.Count;
|
|
sendPlaceResult.Rows = new List<UserSendPlaceModel>();
|
|
seq = 1;
|
|
foreach (UserSendPlacePower sendPlace in info.SendPlacePowers)
|
|
{
|
|
sendPlaceResult.Rows.Add(new UserSendPlaceModel { Seq = seq, SENDPLACEID = sendPlace.SENDPLACEID, SENDPLACENO = sendPlace.SENDPLACENO, SENDPLACENAME = sendPlace.SENDPLACENAME, DeleteAction = "deleteSendPlace('" + sendPlace.SENDPLACEID + "')" });
|
|
seq++;
|
|
}
|
|
model.SendPlaceList = sendPlaceResult.GetJsonSource();
|
|
}
|
|
|
|
return View(model);
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region 保存业务权限
|
|
|
|
/// <summary>
|
|
/// 保存业务权限
|
|
/// </summary>
|
|
/// <param name="model">业务权限信息</param>
|
|
/// <returns></returns>
|
|
[ValidateInput(false)]
|
|
[HandleException]
|
|
public ActionResult BusiPowerSave(UserEntrustPowerModel model)
|
|
{
|
|
List<UserCorpModel> corps = null;
|
|
List<UserLineModel> lines = null;
|
|
List<UserMatSortModel> matSorts = null;
|
|
List<UserReqPlaceModel> reqPlaces = null;
|
|
List<UserSendPlaceModel> sendPlaces = null;
|
|
ServiceAgent wcfAgent = this.GetServiceAgent();
|
|
UserEntrustBusiPower info = new UserEntrustBusiPower();
|
|
try
|
|
{
|
|
info = CopyToModel<UserEntrustBusiPower, UserEntrustPowerModel>(model);
|
|
info.BusinessPowers = new List<ParaAuthorityPort>();
|
|
|
|
//绑定仓库权限
|
|
corps = JsonConvertHelper.GetDeserialize<List<UserCorpModel>>(model.CorpList);
|
|
foreach (UserCorpModel corp in corps)
|
|
{
|
|
ParaAuthorityPort c = new ParaAuthorityPort();
|
|
c.PARATYPE = "1";
|
|
c.PARAVALUE = corp.CORPID;
|
|
info.BusinessPowers.Add(c);
|
|
}
|
|
|
|
//绑定路线权限
|
|
lines = JsonConvertHelper.GetDeserialize<List<UserLineModel>>(model.LineList);
|
|
foreach (UserLineModel line in lines)
|
|
{
|
|
ParaAuthorityPort l = new ParaAuthorityPort();
|
|
l.PARATYPE = "2";
|
|
l.PARAVALUE = line.LINEID;
|
|
info.BusinessPowers.Add(l);
|
|
}
|
|
|
|
//绑定零件类别权限
|
|
matSorts = JsonConvertHelper.GetDeserialize<List<UserMatSortModel>>(model.MatSortList);
|
|
foreach (UserMatSortModel matSort in matSorts)
|
|
{
|
|
ParaAuthorityPort m = new ParaAuthorityPort();
|
|
m.PARATYPE = "3";
|
|
m.PARAVALUE = matSort.MATSORTID;
|
|
info.BusinessPowers.Add(m);
|
|
}
|
|
|
|
//绑定要货地权限
|
|
reqPlaces = JsonConvertHelper.GetDeserialize<List<UserReqPlaceModel>>(model.RequestPlaceList);
|
|
foreach (UserReqPlaceModel reqPlace in reqPlaces)
|
|
{
|
|
ParaAuthorityPort m = new ParaAuthorityPort();
|
|
m.PARATYPE = "4";
|
|
m.PARAVALUE = reqPlace.PLACEDISID;
|
|
info.BusinessPowers.Add(m);
|
|
}
|
|
|
|
//绑定发货地权限
|
|
sendPlaces = JsonConvertHelper.GetDeserialize<List<UserSendPlaceModel>>(model.SendPlaceList);
|
|
foreach (UserSendPlaceModel sendPlace in sendPlaces)
|
|
{
|
|
ParaAuthorityPort m = new ParaAuthorityPort();
|
|
m.PARATYPE = "5";
|
|
m.PARAVALUE = sendPlace.SENDPLACEID;
|
|
info.BusinessPowers.Add(m);
|
|
}
|
|
|
|
wcfAgent.InvokeServiceFunction("UserEntrustBLL_SaveBusinessPower", info);
|
|
|
|
return this.GetJsViewResult(string.Format("parent.List(1);parent.showTitle('{0}');parent.closeAppWindow1();"
|
|
, AppResource.SaveMessge));
|
|
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw ex;
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region 导出excel
|
|
|
|
/// <summary>
|
|
/// 导出excel
|
|
/// </summary>
|
|
/// <returns>结果</returns>
|
|
[HttpPost]
|
|
[HandleException]
|
|
public ActionResult ExportExcel()
|
|
{
|
|
UserEntrustModel seachModel = null;
|
|
UserEntrust condition = null;
|
|
DataTable exportDt = new DataTable();
|
|
ServiceAgent wcfAgent = this.GetServiceAgent();
|
|
PowerUtil pu = new PowerUtil();
|
|
string selectKey = Request.Form["selectKey"];
|
|
try
|
|
{
|
|
//获取查询对象
|
|
seachModel = GetModel<UserEntrustModel>();
|
|
condition = CopyToModel<UserEntrust, UserEntrustModel>(seachModel);
|
|
|
|
//获取数据
|
|
exportDt = wcfAgent.InvokeServiceFunction<DataTable>("UserEntrustBLL_GetExportData", condition);
|
|
|
|
//根据所选信息进行导出
|
|
if (!String.IsNullOrEmpty(selectKey))
|
|
{
|
|
DataView dv = new DataView(exportDt);
|
|
string strWhere = "";
|
|
string[] list = selectKey.Split(":".ToCharArray());
|
|
foreach (string ID in list)
|
|
{
|
|
strWhere += " PID='" + ID + "' or";
|
|
}
|
|
if (strWhere != "")
|
|
{
|
|
strWhere = strWhere.Remove((strWhere.Length - 2), 2);
|
|
}
|
|
dv.RowFilter = strWhere;
|
|
exportDt = dv.ToTable();
|
|
}
|
|
|
|
|
|
//设置导出的时间格式.
|
|
exportDt.Columns.Add("CREATEDATESHOW");
|
|
exportDt.Columns.Add("UPDATEDATESHOW");
|
|
exportDt.Columns.Add("STARTTIMESHOW");
|
|
exportDt.Columns.Add("ENDTIMESHOW");
|
|
foreach (DataRow dr in exportDt.Rows)
|
|
{
|
|
if (dr["CREATEDATE"] != null)
|
|
{
|
|
dr["CREATEDATESHOW"] = Convert.ToDateTime(dr["CREATEDATE"]).ToString("yyyy-MM-dd hh:mm:ss");
|
|
}
|
|
if (dr["UPDATEDATE"] != null)
|
|
{
|
|
dr["UPDATEDATESHOW"] = Convert.ToDateTime(dr["UPDATEDATE"]).ToString("yyyy-MM-dd hh:mm:ss");
|
|
}
|
|
if (dr["STARTTIME"] != null)
|
|
{
|
|
dr["STARTTIMESHOW"] = Convert.ToDateTime(dr["STARTTIME"]).ToString("yyyy-MM-dd hh:mm:ss");
|
|
}
|
|
if (dr["ENDTIME"] != null)
|
|
{
|
|
dr["ENDTIMESHOW"] = Convert.ToDateTime(dr["ENDTIME"]).ToString("yyyy-MM-dd hh:mm:ss");
|
|
}
|
|
}
|
|
|
|
//导出
|
|
QMFrameWork.WebUI.Util.IEFileTool efTool = new QMFrameWork.WebUI.Util.IEFileTool();
|
|
return efTool.GetExcelFileResult("EntrustList", "委托信息.xls", exportDt);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw ex;
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
}
|
|
}
|
|
|