diff --git a/ReportService/Controllers/api/ReportApiController.cs b/ReportService/Controllers/api/ReportApiController.cs index 50a9e61..0b4e134 100644 --- a/ReportService/Controllers/api/ReportApiController.cs +++ b/ReportService/Controllers/api/ReportApiController.cs @@ -6,6 +6,7 @@ using Microsoft.AspNetCore.Mvc; using Microsoft.EntityFrameworkCore.Internal; using Microsoft.Extensions.Logging; using ReportService.Database; +using ReportService.Models; namespace ReportService.Controllers.api { @@ -22,7 +23,7 @@ namespace ReportService.Controllers.api /// public string ReportPath { get { - return Path.Combine(this.Env.ContentRootPath,"wwwroot/report"); + return Path.Combine(this.Env.ContentRootPath,"wwwroot\\report"); } } @@ -50,6 +51,37 @@ namespace ReportService.Controllers.api return result; } /// + /// 获取树状架构的报表列表 + /// + /// 报表结构 + public ReportListModel GetReportList(string rootPath = null) { + var result = new ReportListModel(); + var cPath = Path.Combine(this.ReportPath,rootPath ?? ""); + var dirs = Directory.GetDirectories(cPath); + foreach(var d in dirs) { + var sd = new ReportItem { + Name = d.Substring(d.LastIndexOf('\\') + 1), + Path = rootPath ?? "", + Type = ItemType.group, + }; + result.Sub.Add(sd); + sd.Sub.AddRange(GetReportList(Path.Combine(sd.Path,sd.Name)).Sub); + } + var files = Directory.GetFiles(cPath,"*.html"); + foreach(var f in files) { + var file = new System.IO.FileInfo(f); + if(file.Name.ToLower().EndsWith(".rpt.html")) { + continue; + } + result.Sub.Add(new ReportItem { + Name = file.Name.Substring(0,file.Name.IndexOf('.')), + Path = rootPath, + Type = ItemType.file, + }); + } + return result; + } + /// /// 获取模板内容显示模板页面 /// /// 模板文件名 diff --git a/ReportService/Models/ReportListModel.cs b/ReportService/Models/ReportListModel.cs new file mode 100644 index 0000000..ba3fa00 --- /dev/null +++ b/ReportService/Models/ReportListModel.cs @@ -0,0 +1,53 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using System.Text; +using System.Text.Json.Serialization; + +namespace ReportService.Models +{ + public class ReportListModel + { + [JsonPropertyName("s")] + public List Sub { get; set; } = new List(); + } + /// + /// 报表项 + /// + public class ReportItem + { + /// + /// 项类型 + /// + [JsonPropertyName("t")] + public ItemType Type{ get; set; } + /// + /// 项名称 + /// + [JsonPropertyName("n")] + public string Name { get; set; } + /// + /// 项路径 + /// + [JsonPropertyName("p")] + public string Path { get; set; } + + [JsonPropertyName("s")] + public List Sub { get; set; } = new List(); + } + /// + /// 项目类型 + /// + public enum ItemType + { + /// + /// 一个报表分组 + /// + group = 1, + /// + /// 报表文件 + /// + file = 2, + } +} diff --git a/ReportService/Views/Home/Index.cshtml b/ReportService/Views/Home/Index.cshtml index 5775744..20ac727 100644 --- a/ReportService/Views/Home/Index.cshtml +++ b/ReportService/Views/Home/Index.cshtml @@ -5,39 +5,63 @@ } -
- -
+
+
+
+
+ {{g.n}} +
+
+
+ +
+
+
+
+
+ +
+
+ diff --git a/ReportService/wwwroot/js/site.js b/ReportService/wwwroot/js/site.js index a732032..977f07f 100644 --- a/ReportService/wwwroot/js/site.js +++ b/ReportService/wwwroot/js/site.js @@ -2,6 +2,7 @@ var myjs = { urls: { files: "/api/ReportApi/getreportfiles", + reportList: "/api/ReportApi/GetReportList", fileContentUrl: "/api/ReportApi/GetHtml", reportUrl: "/api/ReportApi/GetPrint", getresult: "/api/ReportApi/GetResult", diff --git a/ReportService/wwwroot/lib/bootstrap-collapse/bootstrap-collapse.js b/ReportService/wwwroot/lib/bootstrap-collapse/bootstrap-collapse.js new file mode 100644 index 0000000..4479f28 --- /dev/null +++ b/ReportService/wwwroot/lib/bootstrap-collapse/bootstrap-collapse.js @@ -0,0 +1,136 @@ +/* ============================================================= + * bootstrap-collapse.js v2.0.1 + * http://twitter.github.com/bootstrap/javascript.html#collapse + * ============================================================= + * Copyright 2012 Twitter, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================ */ + +!function ($) { + + "use strict" + + var Collapse = function (element, options) { + this.$element = $(element) + this.options = $.extend({}, $.fn.collapse.defaults, options) + + if (this.options["parent"]) { + this.$parent = $(this.options["parent"]) + } + + this.options.toggle && this.toggle() + } + + Collapse.prototype = { + + constructor: Collapse + + , dimension: function () { + var hasWidth = this.$element.hasClass('width') + return hasWidth ? 'width' : 'height' + } + + , show: function () { + var dimension = this.dimension() + , scroll = $.camelCase(['scroll', dimension].join('-')) + , actives = this.$parent && this.$parent.find('.in') + , hasData + + if (actives && actives.length) { + hasData = actives.data('collapse') + actives.collapse('hide') + hasData || actives.data('collapse', null) + } + + this.$element[dimension](0) + this.transition('addClass', 'show', 'shown') + this.$element[dimension](this.$element[0][scroll]) + + } + + , hide: function () { + var dimension = this.dimension() + this.reset(this.$element[dimension]()) + this.transition('removeClass', 'hide', 'hidden') + this.$element[dimension](0) + } + + , reset: function (size) { + var dimension = this.dimension() + + this.$element + .removeClass('collapse') + [dimension](size || 'auto') + [0].offsetWidth + + this.$element.addClass('collapse') + } + + , transition: function (method, startEvent, completeEvent) { + var that = this + , complete = function () { + if (startEvent == 'show') that.reset() + that.$element.trigger(completeEvent) + } + + this.$element + .trigger(startEvent) + [method]('in') + + $.support.transition && this.$element.hasClass('collapse') ? + this.$element.one($.support.transition.end, complete) : + complete() + } + + , toggle: function () { + this[this.$element.hasClass('in') ? 'hide' : 'show']() + } + + } + + /* COLLAPSIBLE PLUGIN DEFINITION + * ============================== */ + + $.fn.collapse = function (option) { + return this.each(function () { + var $this = $(this) + , data = $this.data('collapse') + , options = typeof option == 'object' && option + if (!data) $this.data('collapse', (data = new Collapse(this, options))) + if (typeof option == 'string') data[option]() + }) + } + + $.fn.collapse.defaults = { + toggle: true + } + + $.fn.collapse.Constructor = Collapse + + + /* COLLAPSIBLE DATA-API + * ==================== */ + + $(function () { + $('body').on('click.collapse.data-api', '[data-toggle=collapse]', function (e) { + var $this = $(this), href + , target = $this.attr('data-target') + || e.preventDefault() + || (href = $this.attr('href')) && href.replace(/.*(?=#[^\s]+$)/, '') //strip for ie7 + , option = $(target).data('collapse') ? 'toggle' : $this.data() + $(target).collapse(option) + }) + }) + +}(window.jQuery); \ No newline at end of file diff --git a/ReportService/wwwroot/report/儿童登记报表/儿童登记报表_1.html b/ReportService/wwwroot/report/儿童登记报表/儿童登记报表_1.html new file mode 100644 index 0000000..f6cb6e0 --- /dev/null +++ b/ReportService/wwwroot/report/儿童登记报表/儿童登记报表_1.html @@ -0,0 +1,85 @@ +
+
+ + + + + + + + + + +
+ + + +
+ +
+
+ + + + + + + + + + + + + + + + + + + + +
姓名年龄性别登录用户编号登录用户名
{{i.name}}{{i.age}}{{i.sex}}{{i.uid}}{{i.Uname}}
+ +
+
+ + diff --git a/ReportService/wwwroot/report/儿童登记报表/儿童登记报表_2.html b/ReportService/wwwroot/report/儿童登记报表/儿童登记报表_2.html new file mode 100644 index 0000000..942f29f --- /dev/null +++ b/ReportService/wwwroot/report/儿童登记报表/儿童登记报表_2.html @@ -0,0 +1,82 @@ +
+
+ + + + + + + + + + + + + +
+
+ + + + + + + + + + + + + + + + + + + + +
姓名年龄性别登录用户编号登录用户名
{{i.name}}{{i.age}}{{i.sex}}{{i.uid}}{{i.Uname}}
+ +
+
+ + diff --git a/ReportService/wwwroot/report/绩效考核/绩效考核_1.html b/ReportService/wwwroot/report/绩效考核/绩效考核_1.html new file mode 100644 index 0000000..942f29f --- /dev/null +++ b/ReportService/wwwroot/report/绩效考核/绩效考核_1.html @@ -0,0 +1,82 @@ +
+
+ + + + + + + + + + + + + +
+
+ + + + + + + + + + + + + + + + + + + + +
姓名年龄性别登录用户编号登录用户名
{{i.name}}{{i.age}}{{i.sex}}{{i.uid}}{{i.Uname}}
+ +
+
+ + diff --git a/ReportService/wwwroot/report/绩效考核/绩效考核_2.html b/ReportService/wwwroot/report/绩效考核/绩效考核_2.html new file mode 100644 index 0000000..942f29f --- /dev/null +++ b/ReportService/wwwroot/report/绩效考核/绩效考核_2.html @@ -0,0 +1,82 @@ +
+
+ + + + + + + + + + + + + +
+
+ + + + + + + + + + + + + + + + + + + + +
姓名年龄性别登录用户编号登录用户名
{{i.name}}{{i.age}}{{i.sex}}{{i.uid}}{{i.Uname}}
+ +
+
+ +