diff --git a/ReportService/Controllers/api/ReportApiController.cs b/ReportService/Controllers/api/ReportApiController.cs index 3ba79a1..50a9e61 100644 --- a/ReportService/Controllers/api/ReportApiController.cs +++ b/ReportService/Controllers/api/ReportApiController.cs @@ -1,4 +1,5 @@ -using System.Collections.Generic; +using System; +using System.Collections.Generic; using System.IO; using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Mvc; @@ -89,5 +90,14 @@ namespace ReportService.Controllers.api return Content(result,"application/json; charset=utf-8"); } + /// + /// 获取系统时间 + /// + /// 时间格式 + /// 时间字符串 + public object GetServerTime(string format) { + format ??= "yyyyMMdd HH:mm:ss"; + return new { str = DateTimeOffset.Now.ToString(format) }; + } } } diff --git a/ReportService/wwwroot/js/site.js b/ReportService/wwwroot/js/site.js index b99ae78..445941c 100644 --- a/ReportService/wwwroot/js/site.js +++ b/ReportService/wwwroot/js/site.js @@ -5,6 +5,7 @@ var myjs = { fileContentUrl: "/api/ReportApi/GetHtml", reportUrl: "/api/ReportApi/GetPrint", getresult: "/api/ReportApi/GetResult", + GetServerTime: "/api/ReportApi/GetServerTime", }, //定义从对象获取请求参数的方法 getParaStr(data) { @@ -77,5 +78,10 @@ var myjs = { }, getSqlStr() { return $.cookie("_SqlString"); + }, + GetServerTime(format, callback) { + this.post(this.urls.GetServerTime, { format: format }, function (r) { + callback(r.str); + }); } }; \ No newline at end of file diff --git a/ReportService/wwwroot/report/报表1.rpt.html b/ReportService/wwwroot/report/报表1.rpt.html index 3f09b0a..cca7a01 100644 --- a/ReportService/wwwroot/report/报表1.rpt.html +++ b/ReportService/wwwroot/report/报表1.rpt.html @@ -32,6 +32,11 @@ 登录用户名 + + + 打印时间:{{printTime}} + + {{i.name}} @@ -50,13 +55,18 @@ data: { url: myjs.urls.getresult, result: [], + printTime: "", }, created() { + var _this = this; var sql = myjs.getSqlStr(); console.log(sql); myjs.post(this.url, { sql: sql }, function (d) { findPersonPrint.result = d; }); + myjs.GetServerTime("yyyy年MM月dd日 HH点", function (r) { + _this.printTime = r; + }); }, methods: { }