添加项目文件。

This commit is contained in:
zgf committed 2023-07-25 19:20:18 +08:00
1 parent 05e131ca4e
commit 514d6f5255
1162 files changed
+81255

No files matched your search

@@ -0,0 +1,228 @@
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using System;
using WalkingTec.Mvvm.Core;
using WalkingTec.Mvvm.Mvc;
using WalkingTec.Mvvm.Core.Extensions;
using HHWMS.Web;
namespace HHWMS.Web.Controllers
{
[Area("report")]
[ActionDescription("报表设计")]
public partial class ReportDesignController : BaseController
{
private readonly IUnitWork _unitwork;
public ReportDesignController(IUnitWork unitwork)
{
_unitwork = unitwork;
}
#region Search
[ActionDescription("Sys.Search")]
public ActionResult Index()
{
var vm = Wtm.CreateVM<ReportDesignListVM>();
return PartialView(vm);
}
[ActionDescription("Sys.Search")]
[HttpPost]
public string Search(ReportDesignSearcher searcher)
{
var vm = Wtm.CreateVM<ReportDesignListVM>(passInit: true);
if (ModelState.IsValid)
{
vm.Searcher = searcher;
return vm.GetJson(false);
}
else
{
return vm.GetError();
}
}
#endregion
#region Create
[ActionDescription("Sys.Create")]
public ActionResult Create()
{
var vm = Wtm.CreateVM<ReportDesignVM>();
return PartialView(vm);
}
[HttpPost]
[ActionDescription("Sys.Create")]
public ActionResult Create(ReportDesignVM vm)
{
vm.Entity.Params = vm.Entity.Params.Replace("&quot;", "\"");
if (!ModelState.IsValid)
{
return PartialView(vm);
}
else
{
vm.DoAdd();
if (!ModelState.IsValid)
{
vm.DoReInit();
return PartialView(vm);
}
else
{
return FFResult().CloseDialog().RefreshGrid();
}
}
}
#endregion
#region Edit
[ActionDescription("Sys.Edit")]
public ActionResult Edit(string id)
{
var vm = Wtm.CreateVM<ReportDesignVM>(id);
return PartialView(vm);
}
[ActionDescription("Sys.Edit")]
[HttpPost]
[ValidateFormItemOnly]
public ActionResult Edit(ReportDesignVM vm)
{
if (!ModelState.IsValid)
{
return PartialView(vm);
}
else
{
vm.DoEdit();
if (!ModelState.IsValid)
{
vm.DoReInit();
return PartialView(vm);
}
else
{
return FFResult().CloseDialog().RefreshGridRow(vm.Entity.ID);
}
}
}
#endregion
#region Delete
[ActionDescription("Sys.Delete")]
public ActionResult Delete(string id)
{
var vm = Wtm.CreateVM<ReportDesignVM>(id);
return PartialView(vm);
}
[ActionDescription("Sys.Delete")]
[HttpPost]
public ActionResult Delete(string id, IFormCollection nouse)
{
var vm = Wtm.CreateVM<ReportDesignVM>(id);
vm.DoDelete();
if (!ModelState.IsValid)
{
return PartialView(vm);
}
else
{
return FFResult().CloseDialog().RefreshGrid();
}
}
#endregion
#region Details
[ActionDescription("Sys.Details")]
public ActionResult Details(string id)
{
var vm = Wtm.CreateVM<ReportDesignVM>(id);
return PartialView(vm);
}
#endregion
#region BatchEdit
[HttpPost]
[ActionDescription("Sys.BatchEdit")]
public ActionResult BatchEdit(string[] IDs)
{
var vm = Wtm.CreateVM<ReportDesignBatchVM>(Ids: IDs);
return PartialView(vm);
}
[HttpPost]
[ActionDescription("Sys.BatchEdit")]
public ActionResult DoBatchEdit(ReportDesignBatchVM vm, IFormCollection nouse)
{
if (!ModelState.IsValid || !vm.DoBatchEdit())
{
return PartialView("BatchEdit",vm);
}
else
{
return FFResult().CloseDialog().RefreshGrid().Alert(Localizer["Sys.BatchEditSuccess", vm.Ids.Length]);
}
}
#endregion
#region BatchDelete
[HttpPost]
[ActionDescription("Sys.BatchDelete")]
public ActionResult BatchDelete(string[] IDs)
{
var vm = Wtm.CreateVM<ReportDesignBatchVM>(Ids: IDs);
return PartialView(vm);
}
[HttpPost]
[ActionDescription("Sys.BatchDelete")]
public ActionResult DoBatchDelete(ReportDesignBatchVM vm, IFormCollection nouse)
{
if (!ModelState.IsValid || !vm.DoBatchDelete())
{
return PartialView("BatchDelete",vm);
}
else
{
return FFResult().CloseDialog().RefreshGrid().Alert(Localizer["Sys.BatchDeleteSuccess", vm.Ids.Length]);
}
}
#endregion
#region Import
[ActionDescription("Sys.Import")]
public ActionResult Import()
{
var vm = Wtm.CreateVM<ReportDesignImportVM>();
return PartialView(vm);
}
[HttpPost]
[ActionDescription("Sys.Import")]
public ActionResult Import(ReportDesignImportVM vm, IFormCollection nouse)
{
if (vm.ErrorListVM.EntityList.Count > 0 || !vm.BatchSaveData())
{
return PartialView(vm);
}
else
{
return FFResult().CloseDialog().RefreshGrid().Alert(Localizer["Sys.ImportSuccess", vm.EntityList.Count.ToString()]);
}
}
#endregion
#region Export
[ActionDescription("Sys.Export")]
[HttpPost]
public IActionResult ExportExcel(ReportDesignListVM vm)
{
return vm.GetExportData();
}
#endregion
}
}
@@ -0,0 +1,47 @@
using System.Linq;
using HHWMS.Web.Models;
using Microsoft.AspNetCore.Mvc;
using Newtonsoft.Json;
using WalkingTec.Mvvm.Core;
using WalkingTec.Mvvm.Mvc;
namespace HHWMS.Web.Controllers
{
[Area("report")]
[ActionDescription("报表查看")]
public partial class ReportViewController : BaseController
{
private readonly IUnitWork _unitwork;
public ReportViewController(IUnitWork unitwork)
{
_unitwork = unitwork;
}
#region Search
[ActionDescription("Sys.Search")]
public ActionResult Index()
{
var vm = Wtm.CreateVM<ReportDesignVM>();
return PartialView(vm);
}
[HttpPost]
public string QueryData(string name, string filter)
{
var vm = Wtm.CreateVM<ReportDesignVM>();
var result = vm.QueryData(name, filter);
return JsonConvert.SerializeObject(result);
}
[HttpPost]
public IActionResult GetReportParams(string id)
{
var data = _unitwork.Find<ReportDesign>(x => x.Name == id).FirstOrDefault();
return JsonMore(data?.Params);
}
#endregion Search
}
}
@@ -0,0 +1,24 @@
using HHWMS.Web.Models;
using WalkingTec.Mvvm.Core;
namespace HHWMS.Web
{
public partial class ReportDesignBatchVM : BaseBatchVM<ReportDesign, ReportDesign_BatchEdit>
{
public ReportDesignBatchVM()
{
ListVM = new ReportDesignListVM();
LinkedVM = new ReportDesign_BatchEdit();
}
}
/// <summary>
/// Class to define batch edit fields
/// </summary>
public class ReportDesign_BatchEdit : BaseVM
{
protected override void InitVM()
{
}
}
}
@@ -0,0 +1,29 @@
using System.ComponentModel.DataAnnotations;
using HHWMS.Web.Models;
using WalkingTec.Mvvm.Core;
namespace HHWMS.Web
{
public partial class ReportDesignTemplateVM : BaseTemplateVM
{
[Display(Name = "ReportDesign.Name")]
public ExcelPropety Name_Excel = ExcelPropety.CreateProperty<ReportDesign>(x => x.Name);
[Display(Name = "ReportDesign.Sql")]
public ExcelPropety Sql_Excel = ExcelPropety.CreateProperty<ReportDesign>(x => x.Sql);
[Display(Name = "ReportDesign.Params")]
public ExcelPropety Params_Excel = ExcelPropety.CreateProperty<ReportDesign>(x => x.Params);
[Display(Name = "_Admin.Remark")]
public ExcelPropety Remark_Excel = ExcelPropety.CreateProperty<ReportDesign>(x => x.Remark);
protected override void InitVM()
{
}
}
public class ReportDesignImportVM : BaseImportVM<ReportDesignTemplateVM, ReportDesign>
{
}
}
@@ -0,0 +1,58 @@
using System.Collections.Generic;
using System.Linq;
using HHWMS.Web.Models;
using WalkingTec.Mvvm.Core;
using WalkingTec.Mvvm.Core.Extensions;
namespace HHWMS.Web
{
public partial class ReportDesignListVM : BasePagedListVM<ReportDesign_View, ReportDesignSearcher>
{
protected override List<GridAction> InitGridAction()
{
return new List<GridAction>
{
this.MakeStandardAction("ReportDesign", GridActionStandardTypesEnum.Create, Localizer["Sys.Create"],"report", dialogWidth: 800),
this.MakeStandardAction("ReportDesign", GridActionStandardTypesEnum.Edit, Localizer["Sys.Edit"], "report", dialogWidth: 800),
this.MakeStandardAction("ReportDesign", GridActionStandardTypesEnum.Delete, Localizer["Sys.Delete"], "report", dialogWidth: 800),
this.MakeStandardAction("ReportDesign", GridActionStandardTypesEnum.Details, Localizer["Sys.Details"], "report", dialogWidth: 800),
this.MakeStandardAction("ReportDesign", GridActionStandardTypesEnum.BatchEdit, Localizer["Sys.BatchEdit"], "report", dialogWidth: 800),
this.MakeStandardAction("ReportDesign", GridActionStandardTypesEnum.BatchDelete, Localizer["Sys.BatchDelete"], "report", dialogWidth: 800),
this.MakeStandardAction("ReportDesign", GridActionStandardTypesEnum.Import, Localizer["Sys.Import"], "report", dialogWidth: 800),
this.MakeStandardAction("ReportDesign", GridActionStandardTypesEnum.ExportExcel, Localizer["Sys.Export"], "report"),
};
}
protected override IEnumerable<IGridColumn<ReportDesign_View>> InitGridHeader()
{
return new List<GridColumn<ReportDesign_View>>{
this.MakeGridHeader(x => x.Name),
this.MakeGridHeader(x => x.Sql),
this.MakeGridHeader(x => x.Params),
this.MakeGridHeader(x => x.Remark),
this.MakeGridHeaderAction(width: 200)
};
}
public override IOrderedQueryable<ReportDesign_View> GetSearchQuery()
{
var query = DC.Set<ReportDesign>()
.CheckContain(Searcher.Name, x => x.Name)
.CheckContain(Searcher.Remark, x => x.Remark)
.Select(x => new ReportDesign_View
{
ID = x.ID,
Name = x.Name,
Sql = x.Sql,
Params = x.Params,
Remark = x.Remark,
})
.OrderBy(x => x.ID);
return query;
}
}
public class ReportDesign_View : ReportDesign
{
}
}
@@ -0,0 +1,25 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Threading.Tasks;
using WalkingTec.Mvvm.Core;
using WalkingTec.Mvvm.Core.Extensions;
using HHWMS.Web;
namespace HHWMS.Web
{
public partial class ReportDesignSearcher : BaseSearcher
{
[Display(Name = "ReportDesign.Name")]
public String Name { get; set; }
[Display(Name = "_Admin.Remark")]
public String Remark { get; set; }
protected override void InitVM()
{
}
}
}
@@ -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("&quot;", "\""));
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);
}
}
}
@@ -0,0 +1,12 @@
@model HHWMS.Web.ReportDesignBatchVM
@inject IStringLocalizer<Program> Localizer;
<wt:form vm="@Model">
<wt:quote>@Localizer["Sys.BatchDeleteConfirm"]</wt:quote>
<wt:hidden field="Ids" />
<wt:grid vm="ListVM" use-local-data="true" height="300" hidden-checkbox="true" hidden-panel="true"/>
<wt:row align="AlignEnum.Right">
<wt:submitbutton theme=" ButtonThemeEnum.Warm" text="@Localizer["Sys.Delete"]"/>
<wt:closebutton />
</wt:row>
</wt:form>
@@ -0,0 +1,14 @@
@model HHWMS.Web.ReportDesignBatchVM
@inject IStringLocalizer<Program> Localizer;
<wt:form vm="@Model">
<div style="margin-bottom:10px">@Localizer["Sys.BatchEditConfirm"] </div>
<wt:row items-per-row="ItemsPerRowEnum.Two">
</wt:row>
<wt:hidden field="Ids" />
<wt:grid vm="ListVM" use-local-data="true" height="300" hidden-checkbox="true" hidden-panel="true"/>
<wt:row align="AlignEnum.Right">
<wt:submitbutton />
<wt:closebutton />
</wt:row>
</wt:form>
@@ -0,0 +1,70 @@
@model HHWMS.Web.ReportDesignVM
@inject IStringLocalizer<Program> Localizer;
<wt:form vm="@Model">
<wt:row items-per-row="ItemsPerRowEnum.Two">
<wt:textbox field="Entity.Name" />
<wt:textbox field="Entity.Remark" />
<wt:textarea field="Entity.Sql" empty-text="请输入SQL语句 例:SELECT * FROM TableName WHERE A = {@@ Where1} AND B = '{@@Where2}'" />
<wt:textbox field="Entity.Params" />
</wt:row>
<wt:row align="AlignEnum.Right">
<wt:submitbutton />
<wt:closebutton />
</wt:row>
</wt:form>
<div class="layui-row" id="ConfigParams1" hidden>
</div>
<style>
.layui-form-pane .layui-form-label {
width: 40% !important
}
</style>
<script>
// 动态渲染 参数输入
$('#ReportDesignVM_Entity_Params').on('click', function () {
var DictKey = $('#ReportDesignVM_Entity_Sql').val();
if (DictKey != undefined && DictKey != null && DictKey != "") {
LoadParams(DictKey);
$('#ReportDesignVM_Entity_Params').val(GetParams());
}
});
function LoadParams(DictKey) {
var oldobj = {};
var params = $('#ReportDesignVM_Entity_Params').val();
if (params != undefined && params != null && params != "") {
oldobj = JSON.parse(params);
}
$("#ConfigParams").html("");
var Params = DictKey.match(/\{[^\}]+\}/g);
if (Params != null) {
var dom = '';
for (var i = 0; i < Params.length; i++) {
console.log(Params[i])
var value = Params[i];
var oldvalue = '';
if (oldobj[value] !== undefined) {
oldvalue = oldobj[value];
}
dom += '<div class="layui-col-sm12">';
dom += '<label class="layui-form-label">' + value + '</label>';
dom += '<div class="layui-input-inline layui-col-sm7">';
dom += '<input data-model="' + value + '" class="layui-input ParamsKey" type="text" autocomplete="off" lay-verify="" value="' + oldvalue + '">'
dom += '</div></div>';
}
$("#ConfigParams").html(dom);
layui.form.render();
}
}
function GetParams() {
var Params = {};
$.each($(".ParamsKey"), function (key, value) {
Params[$(this).data("model")] = $(this).val();
});
return JSON.stringify(Params);
}
</script>
@@ -0,0 +1,17 @@
@model HHWMS.Web.ReportDesignVM
@inject IStringLocalizer<Program> Localizer;
<wt:form vm="@Model">
<wt:quote>@Localizer["Sys.DeleteConfirm"]</wt:quote>
<wt:row items-per-row="ItemsPerRowEnum.Two">
<wt:display field="Entity.Name" />
<wt:display field="Entity.Sql" />
<wt:display field="Entity.Params" />
<wt:display field="Entity.Remark" />
</wt:row>
<wt:hidden field="Entity.ID" />
<wt:row align="AlignEnum.Right">
<wt:submitbutton theme=" ButtonThemeEnum.Warm" text="@Localizer["Sys.Delete"]"/>
<wt:closebutton />
</wt:row>
</wt:form>
@@ -0,0 +1,14 @@
@model HHWMS.Web.ReportDesignVM
@inject IStringLocalizer<Program> Localizer;
<wt:form vm="@Model">
<wt:row items-per-row="ItemsPerRowEnum.Two">
<wt:display field="Entity.Name" />
<wt:display field="Entity.Sql" />
<wt:display field="Entity.Params" />
<wt:display field="Entity.Remark" />
</wt:row>
<wt:row align="AlignEnum.Right">
<wt:closebutton />
</wt:row>
</wt:form>
@@ -0,0 +1,16 @@
@model HHWMS.Web.ReportDesignVM
@inject IStringLocalizer<Program> Localizer;
<wt:form vm="@Model">
<wt:row items-per-row="ItemsPerRowEnum.Two">
<wt:textbox field="Entity.Name" />
<wt:textbox field="Entity.Sql" />
<wt:textbox field="Entity.Params" />
<wt:textbox field="Entity.Remark" />
</wt:row>
<wt:hidden field="Entity.ID" />
<wt:row align="AlignEnum.Right">
<wt:submitbutton />
<wt:closebutton />
</wt:row>
</wt:form>
@@ -0,0 +1,14 @@
@model HHWMS.Web.ReportDesignImportVM
@inject IStringLocalizer<Program> Localizer;
<wt:form vm="@Model">
<wt:row align="AlignEnum.Right">
<wt:downloadTemplateButton vm="@Model" />
</wt:row>
<wt:upload field="UploadFileId" label-text="@Model.Localizer["Sys.UploadTemplate"]" upload-type="ExcelFile" />
<wt:grid vm="ErrorListVM" use-local-data="true" hidden-checkbox="true" hidden-grid-index="true" hidden-panel="true" height="300"/>
<wt:row align="AlignEnum.Right">
<wt:submitbutton />
<wt:closebutton />
</wt:row>
</wt:form>
@@ -0,0 +1,12 @@
@model HHWMS.Web.ReportDesignListVM
@inject IStringLocalizer<Program> Localizer;
<wt:searchpanel vm="@Model" reset-btn="true">
<wt:row items-per-row="ItemsPerRowEnum.Three">
<wt:textbox field="Searcher.Name" />
<wt:textbox field="Searcher.Remark" />
</wt:row>
</wt:searchpanel>
<wt:grid vm="@Model" url="/report/ReportDesign/Search"/>
<div class="layui-row" id="ConfigParams" hidden>
</div>
@@ -0,0 +1,123 @@
@model HHWMS.Web.ReportDesignVM
@inject IStringLocalizer<Program> Localizer;
<wt:form vm="@Model" width="600">
<wt:combobox field="Entity.Name" items="ReportNames" change-func="GetReportParams(data)" />
<wt:textbox field="Entity.Params" id="params"/>
<wt:row align="AlignEnum.Right">
<wt:submitbutton text="查询" click="QueryData()"/>
</wt:row>
</wt:form>
<table id="demo" lay-filter="test"></table>
<div class="layui-row" id="ConfigParams" hidden>
</div>
<style>
.layui-form-pane .layui-form-label {
width: 40% !important
}
</style>
<script>
var name = "";
// 参数赋值
function GetReportParams(data) {
name = data.arr[0].value;
$.ajax({
url: "/report/ReportView/GetReportParams",
async: true,
type: "post",
data: { id: data.arr[0].value },
dataType: "json",
success: function (result) {
$('#params').val(result.Data);
}
});
}
// 动态渲染 参数输入
$('#params').on('click', function () {
var DictKey = $('#params').val();
if (DictKey != undefined && DictKey != null && DictKey != "") {
LoadParams(DictKey);
layer.open({
title: '参数',
area: ["500px", "300px"],
type: 1,
shade: 0,
content: $('#ConfigParams'),
btn: ['save', 'close'],
success: function (layero, index) {
},
yes: function (index) {
$('#params').val(GetParams());
layer.close(index);
$("#ConfigParams").html("");
},
btn2: function (index) {
layer.close(index);
$("#ConfigParams").html("");
}
});
}
});
function LoadParams(DictKey) {
var oldobj = {};
if (DictKey != undefined && DictKey != null && DictKey != "") {
oldobj = JSON.parse(DictKey);
}
$("#ConfigParams").html("");
var dom = '';
for (var item in oldobj) {
var value = item;
var oldvalue = '';
if (oldobj[value] !== undefined) {
oldvalue = oldobj[value];
}
dom += '<div class="layui-col-sm12">';
dom += '<label class="layui-form-label">' + value + '</label>';
dom += '<div class="layui-input-inline layui-col-sm7">';
dom += '<input data-model="' + value + '" class="layui-input ParamsKey" type="text" autocomplete="off" lay-verify="" value="' + oldvalue + '">'
dom += '</div></div>';
}
$("#ConfigParams").html(dom);
}
function GetParams() {
var Params = {};
$.each($(".ParamsKey"), function (key, value) {
Params[$(this).data("model")] = $(this).val();
});
return JSON.stringify(Params);
}
// 获取数据
function QueryData() {
$.ajax({
url: "/report/ReportView/QueryData",
async: true,
type: "post",
data: { name: name, filter: $('#params').val() },
dataType: "json",
success: function (result) {
layui.table.render({
elem: '#demo'
, page: { layout: ['count'] }
, limit: Number.MAX_VALUE
, toolbar: true
, defaultToolbar: ['filter','exports']
, height: 'full'
, cols: [result.Data[0]]
, data: result.Data[1]
});
}
});
};
</script>