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.
195 lines
6.4 KiB
195 lines
6.4 KiB
4 years ago
|
using System;
|
||
|
using System.Collections.Generic;
|
||
|
using System.Linq;
|
||
|
using System.Web;
|
||
|
using System.Web.Mvc;
|
||
|
using QMFrameWork.Data;
|
||
|
using QMFrameWork.WebUI.Attribute;
|
||
|
using QMFrameWork.WebUI.DataSource;
|
||
|
using QMAPP.Common.Web.Models;
|
||
|
|
||
|
namespace QMAPP.Common.Web.Controllers
|
||
|
{
|
||
|
/// <summary>
|
||
|
/// 智能感知文本控件
|
||
|
/// </summary>
|
||
|
public class PerceptTextController : QController
|
||
|
{
|
||
|
#region 显示智能感知全部数据
|
||
|
|
||
|
/// <summary>
|
||
|
/// 获取智能感知控件数据
|
||
|
/// </summary>
|
||
|
/// <param name="term">感知值</param>
|
||
|
/// <returns>数据</returns>
|
||
|
[HandleException]
|
||
|
public ActionResult ShowPerceptData(string term)
|
||
|
{
|
||
|
string kind = Request.Params["kind"];
|
||
|
List<string> parameters = new List<string>();
|
||
|
string pList = Request.Params["paramList"];
|
||
|
string mode = Request.Params["mode"];
|
||
|
PerceptModel model = new PerceptModel();
|
||
|
try
|
||
|
{
|
||
|
model.rownumbers = false;
|
||
|
model.url = string.Format("/PerceptText/GetPerceptData?kind={0}¶mList={1}&term={2}&mode=list", kind, pList, term);
|
||
|
return View("ShowPerceptList", model);
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
throw ex;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
#endregion
|
||
|
|
||
|
#region 获取智能感知控件数据
|
||
|
|
||
|
/// <summary>
|
||
|
/// 获取智能感知控件数据
|
||
|
/// </summary>
|
||
|
/// <param name="term">感知值</param>
|
||
|
/// <returns>数据</returns>
|
||
|
[HandleException]
|
||
|
public ActionResult GetPerceptData(string term)
|
||
|
{
|
||
|
// 添加:智能感知不区分大小写 李鹏飞 2015-03-12 开始
|
||
|
term = term.ToUpper();
|
||
|
// 添加:智能感知不区分大小写 李鹏飞 2015-03-12 结束
|
||
|
|
||
|
string kind = Request.Params["kind"];
|
||
|
List<QListItem> list = null;
|
||
|
List<string> parameters = new List<string>();
|
||
|
string pList = Request.Params["paramList"];
|
||
|
string mode = Request.Params["mode"];
|
||
|
try
|
||
|
{
|
||
|
if (string.IsNullOrEmpty(pList) == false)
|
||
|
{
|
||
|
//转换参数格式
|
||
|
string[] ps = pList.Split("|".ToCharArray());
|
||
|
foreach (string p in ps)
|
||
|
{
|
||
|
if (p == "none")
|
||
|
{
|
||
|
parameters.Add("");
|
||
|
continue;
|
||
|
}
|
||
|
parameters.Add(p);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
//获取数据
|
||
|
list = new AppDataGeter().GetList(kind, parameters.ToArray()).ToList();
|
||
|
|
||
|
if (string.IsNullOrEmpty(mode) == true)
|
||
|
{
|
||
|
mode = "";
|
||
|
}
|
||
|
|
||
|
foreach (QListItem item in list)
|
||
|
{
|
||
|
if (item.code != item.text)
|
||
|
item.label = item.code + "|" + item.text;
|
||
|
else
|
||
|
item.label = item.text;
|
||
|
}
|
||
|
|
||
|
//过滤
|
||
|
switch (mode)
|
||
|
{
|
||
|
case "":
|
||
|
list = list.Where(p => p.code.IndexOf(term) >= 0).ToList();
|
||
|
break;
|
||
|
case "list":
|
||
|
list = list.Where(p => p.code.IndexOf(term) >= 0).ToList();
|
||
|
break;
|
||
|
case "is":
|
||
|
list = list.Where(p => p.code == term.Trim()).ToList();
|
||
|
break;
|
||
|
}
|
||
|
if (mode == "list")
|
||
|
{
|
||
|
int totalCount = list.Count;
|
||
|
//分页
|
||
|
PerceptModel seachModel = GetModel<PerceptModel>();
|
||
|
|
||
|
//获取前台分页设置信息
|
||
|
DataPage page = this.GetDataPage(seachModel);
|
||
|
|
||
|
list = new DataPageManager().SplitPageByDataTable<QListItem>(list, page);
|
||
|
|
||
|
//格式转换
|
||
|
DataGridResult<PerceptModel> result = new DataGridResult<PerceptModel>();
|
||
|
result.Total = totalCount;
|
||
|
result.Rows = list.Select(t => new PerceptModel { id = t.id, code = t.code, text = t.text }).ToList(); ;
|
||
|
return Content(result.GetJsonSource());
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
return Content(QMFrameWork.Common.Serialization.JsonConvertHelper.GetSerializes(list));
|
||
|
}
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
throw ex;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
#endregion
|
||
|
|
||
|
#region 多条件查询
|
||
|
[HandleException]
|
||
|
public ActionResult ShowQueryMore(string kind, string idName, string contentName)
|
||
|
{
|
||
|
string kind1 = Request.Params["kind"];
|
||
|
List<string> parameters = new List<string>();
|
||
|
string pList = Request.Params["paramList"];
|
||
|
string mode1 = Request.Params["mode"];
|
||
|
QueryMoreModel obj = new QueryMoreModel();
|
||
|
try
|
||
|
{
|
||
|
obj.QueryType = idName;
|
||
|
//obj.HidCom = contentName;
|
||
|
//model.Url = string.Format("/PerceptText/GetPerceptData?kind={0}¶mList={1}&term={2}&mode=list", kind, pList, term);
|
||
|
return View("ShowPerceptList1", obj);
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
throw ex;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
#region 下载模板
|
||
|
|
||
|
/// <summary>
|
||
|
/// 下载导入模板
|
||
|
/// </summary>
|
||
|
/// <returns></returns>
|
||
|
[HttpPost]
|
||
|
public FilePathResult GetTemplate()
|
||
|
{
|
||
|
try
|
||
|
{
|
||
|
string path = AppDomain.CurrentDomain.BaseDirectory + "Temp/";
|
||
|
string fileName = "MoreQuery.xls";
|
||
|
return File(path + fileName, "application/vnd.ms-excel", Url.Encode("多条件查询导入模板.xls"));
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
throw ex;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
#endregion
|
||
|
|
||
|
[HandleException]
|
||
|
public ActionResult BackQueryMore(QueryMoreModel queryMore)
|
||
|
{
|
||
|
return this.GetJsViewResult("");
|
||
|
}
|
||
|
#endregion
|
||
|
}
|
||
|
}
|