From d29552c455b1c0acca4ecb11c95864df86e95efc Mon Sep 17 00:00:00 2001 From: falcon <9504402@qq.com> Date: Thu, 28 May 2020 15:53:33 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E6=9C=8D=E5=8A=A1=E5=99=A8?= =?UTF-8?q?=E6=97=B6=E9=97=B4=E6=9F=A5=E8=AF=A2API=E3=80=82=E4=B8=BB?= =?UTF-8?q?=E8=A6=81=E7=94=A8=E4=BA=8E=E6=8A=A5=E8=A1=A8=E6=98=BE=E7=A4=BA?= =?UTF-8?q?=E7=AD=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ReportService/Controllers/api/ReportApiController.cs | 12 +++++++++++- ReportService/wwwroot/js/site.js | 6 ++++++ ReportService/wwwroot/report/报表1.rpt.html | 10 ++++++++++ 3 files changed, 27 insertions(+), 1 deletion(-) 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: { }