From 06d0e8478266415b4c20fa13ffc59c2b68ac50c3 Mon Sep 17 00:00:00 2001 From: dev02 Date: Mon, 28 Nov 2022 16:51:11 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=8C=AF=E5=87=BA=E6=B5=81?= =?UTF-8?q?=E7=A8=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Frontend/_historyData.html | 33 +++++++++++------- .../ApiControllers/HistoryController.cs | 3 +- FrontendWebApi/Models/HistoryClass.cs | 3 ++ .../wwwroot/excel/history/廠商資料.xlsx | Bin 5702 -> 0 bytes 4 files changed, 26 insertions(+), 13 deletions(-) delete mode 100644 FrontendWebApi/wwwroot/excel/history/廠商資料.xlsx diff --git a/Frontend/_historyData.html b/Frontend/_historyData.html index f98eedc..9e6f02c 100644 --- a/Frontend/_historyData.html +++ b/Frontend/_historyData.html @@ -84,6 +84,7 @@ initApp.buildNavigation($('#js_nested_list')); loadTable(null); + $(`[onclick="setDateType('today')"]`).click(); }); function initList() { @@ -186,12 +187,12 @@ var edt = new Date(new Date().setDate(sdt.getDate() + 1)); start = start ?? sdt.toLocaleDateString(); end = end ?? edt.toLocaleDateString(); - getHistoryDataByBaja(pageAct.deviceNumber + "_" + pageAct.deviceItem, - new Date(start).getTime(), - new Date(end).getTime(), - pageAct.deviceName, - "Mitsubishi_Sup", - callBackFromHistory); + // getHistoryDataByBaja(pageAct.deviceNumber + "_" + pageAct.deviceItem, + //new Date(start).getTime(), + //new Date(end).getTime(), + //pageAct.deviceName, + // "Mitsubishi_Sup", + // callBackFromHistory); } function callBackFromHistory(res) { @@ -262,7 +263,7 @@ if (pageAct.dateType == "day") end = new Date(new Date().setDate(start.getDate() + 1)); - else if (pageAct.dateType == "month") { + else if (pageAct.dateType == "month") { start = new Date($('#getmonth').val()); end = new Date(new Date().setDate(start.getDate() + 30)); } @@ -290,7 +291,7 @@ let column_defs = [ { "targets": [0], "width": "20%", "sortable": true }, { "targets": [1], "width": "20%", "sortable": true }, - { "targets": [2], "width": "20%", "sortable": true }, + { "targets": [2], "width": "20%", "sortable": true } ]; let columns = [ @@ -308,17 +309,25 @@ "render": function (date) { return displayDate(date, "datetime"); } - }, + } ]; - + historyTable = new YourTeam.JqDataTables.getTableByStatic(tag, data, columns, column_defs, null, null, null, null, "tpi"); } function exportExcel() { let url = baseApiUrl + "/History/OpeExportExcel"; - objSendData.Data = $('#historyTable').dataTable().fnGetData();; + objSendData.Data = $('#historyTable').dataTable().fnGetData(); + + $.each(objSendData.Data, function (i, v) { + v.starttime = (pageAct.dateType == "month" ? new Date($('#getmonth').val()) : new Date($('#startdate').val())); + v.endtime = $('#enddate input').val() === "" ? null : new Date($('#enddate input').val()); + v.dateType = pageAct.dateType; + }); + ytAjax = new YourTeam.Ajax(url, objSendData, function (rel) { - location.href = baseApiUrl + "/api/df?fileName=" + rel.data + "&token=" + localStorage.getItem("JWT-Authorization"); + if (rel.code == "0000") + location.href = baseApiUrl + "/api/df?fileName=" + rel.data + "&token=" + localStorage.getItem("JWT-Authorization"); }, null, "POST").send(); } \ No newline at end of file diff --git a/FrontendWebApi/ApiControllers/HistoryController.cs b/FrontendWebApi/ApiControllers/HistoryController.cs index a876641..ee5d6a7 100644 --- a/FrontendWebApi/ApiControllers/HistoryController.cs +++ b/FrontendWebApi/ApiControllers/HistoryController.cs @@ -55,7 +55,8 @@ namespace FrontendWebApi.ApiControllers try { - var fileName = "廠商資料.xlsx"; + var fileDateName = lhe.FirstOrDefault().dateType == "month" ? lhe.FirstOrDefault().starttime.ToString("yyyy-MM") : lhe.FirstOrDefault().endtime == null ? lhe.FirstOrDefault().starttime.ToString("yyyy-MM-dd") : lhe.FirstOrDefault().starttime.ToString("yyyy-MM-dd") + "_" + ((DateTime)lhe.FirstOrDefault().endtime).ToString("yyyy-MM-dd"); + var fileName = "廠商資料_"+fileDateName+".xlsx"; var filePath = Path.Combine(Directory.GetCurrentDirectory(), "wwwroot", "excel", "history"); if (!System.IO.Directory.Exists(filePath)) diff --git a/FrontendWebApi/Models/HistoryClass.cs b/FrontendWebApi/Models/HistoryClass.cs index c823fa4..d9a08b4 100644 --- a/FrontendWebApi/Models/HistoryClass.cs +++ b/FrontendWebApi/Models/HistoryClass.cs @@ -268,5 +268,8 @@ namespace FrontendWebApi.Models public string deviceName { get; set; } public int value { get; set; } public DateTime timestamp { get; set; } + public DateTime starttime { get; set; } + public DateTime? endtime { get; set; } + public string dateType { get; set; } } } diff --git a/FrontendWebApi/wwwroot/excel/history/廠商資料.xlsx b/FrontendWebApi/wwwroot/excel/history/廠商資料.xlsx deleted file mode 100644 index bd5d5178a8f0fa8bbe6e50375c63f3439b6d1cb4..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 5702 zcmbtYcRZVW-%hQfs7+&ZptWi=Vw6&|Mr#y7jUa@GRa~-1n6~u5WT*zwht9ukU53M@hvF003wKE4G2A z(mJUutK@G(6ac^p@)_#o=;|#gad<2pRMl^hVy5mdG5;u+$QjODJkE&zoq39)JxdT` zALnRrCL@OW+7!LHT3C(fvuFvogYA&$?Vtm5j|(b~xUP>H8G2a^-?Wu-uy#)7t+jaH zwFuvT^njG`CNtV1DgH_FLh3Z%Raw3}nPO4gU3%)BNQsWOYHu+k7he~bdz@MHf77Cm ztZ z)~zNaHpL$NIX%)dE2nRQfHPwCuF(9py#fZxKB0Avu_>o8$eIVW#U zAUp+70u28mO)Fmis@5?8AejmPU?WRosqW$K!8Xyy7q1A*c;MX%^YqJzF8kuD0JR9~|ha1>^C4oc>z;ald-;a1UKW-vzu<}qb*@^X78vNqZZtS7R(C_rDY*vQ?(g)*CG=_ z+35Yg0ZZLlPjEiE?yk9>7fOemX2WY#(o{ayU4PEoolkcsK~1AG!rs3pCHGlzDNV04 zpC$bl;3=uV8EtKcPlX%$ubAj!3twaxd7qARjSo}Y?kY)DpNrPAFJn!0(%oa6>I^{9 zB{c)@SsCwjeY6ZuVa#YyJzaNlpL1{l96mbw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