添加项目文件。
This commit is contained in:
1 parent
05e131ca4e
commit
514d6f5255
1162 files changed
+81255
No files matched your search
@@ -0,0 +1,92 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Linq;
|
||||
using HHWMS.Web;
|
||||
using HHWMS.Web.Models;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using WalkingTec.Mvvm.Core;
|
||||
using WalkingTec.Mvvm.Core.Extensions;
|
||||
|
||||
namespace HHWMS.Web
|
||||
{
|
||||
public partial class ReportDesignVM : BaseCRUDVM<ReportDesign>
|
||||
{
|
||||
private IUnitWork _unitWork { get; set; }
|
||||
public List<ComboSelectListItem> ReportNames { get; set; }
|
||||
|
||||
public ReportDesignVM()
|
||||
{
|
||||
}
|
||||
|
||||
protected override void InitVM()
|
||||
{
|
||||
_unitWork = new UnitWork(Wtm);
|
||||
ReportNames = _unitWork.Find<ReportDesign>(x => true).Select(x => new ComboSelectListItem
|
||||
{
|
||||
Text = x.Name,
|
||||
Value = x.Name
|
||||
}).ToList();
|
||||
}
|
||||
|
||||
public override void DoAdd()
|
||||
{
|
||||
base.DoAdd();
|
||||
}
|
||||
|
||||
public override void DoEdit(bool updateAllFields = false)
|
||||
{
|
||||
base.DoEdit(updateAllFields);
|
||||
}
|
||||
|
||||
public override void DoDelete()
|
||||
{
|
||||
base.DoDelete();
|
||||
}
|
||||
|
||||
public ResponseResult<dynamic> QueryData(string reportName, string filter)
|
||||
{
|
||||
var report = _unitWork.FindSingle<ReportDesign>(x => x.Name == reportName);
|
||||
var sql = report.Sql;
|
||||
var sFilter = report.Params;
|
||||
|
||||
// 组装查询条件
|
||||
if (!string.IsNullOrEmpty(sFilter))
|
||||
{
|
||||
if (string.IsNullOrEmpty(filter))
|
||||
{
|
||||
return ResponseResult<dynamic>.Error("请填写查询条件!");
|
||||
}
|
||||
JObject json = JObject.Parse(filter.Replace(""", "\""));
|
||||
JObject jsonDefault = JObject.Parse(sFilter);
|
||||
|
||||
foreach (var item in jsonDefault)
|
||||
{
|
||||
if (!json.ContainsKey(item.Key))
|
||||
{
|
||||
return ResponseResult<dynamic>.Error("查询条件不正确!");
|
||||
}
|
||||
}
|
||||
|
||||
foreach (var item in json)
|
||||
{
|
||||
sql = sql.Replace(item.Key, item.Value.ToString());
|
||||
}
|
||||
}
|
||||
var data = DC.RunSQL(sql);
|
||||
|
||||
// result 为返回到前端的值 result[0]为表头、 result[1]为值
|
||||
var result = new List<dynamic>();
|
||||
var colList = new List<dynamic>();
|
||||
foreach (DataColumn item in data.Columns)
|
||||
{
|
||||
// 组装表头
|
||||
colList.Add(new { field = item.ColumnName, title = item.ColumnName });
|
||||
}
|
||||
result.Add(colList);
|
||||
// 添加列表
|
||||
result.Add(data.Rows[0].Table);
|
||||
|
||||
return ResponseResult<dynamic>.Success(result);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user