From dd2eea50d12c35e85d06058b4e848aca78d1255e Mon Sep 17 00:00:00 2001 From: dev02 Date: Mon, 3 Jul 2023 11:07:07 +0800 Subject: [PATCH] =?UTF-8?q?[=E5=89=8D=E7=AB=AF]=20=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E6=8C=89=E9=88=95=E5=95=8F=E9=A1=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Frontend/_historyData.html | 127 ++++++++++++++++++++----------------- 1 file changed, 70 insertions(+), 57 deletions(-) diff --git a/Frontend/_historyData.html b/Frontend/_historyData.html index 2c959c7..ab20694 100644 --- a/Frontend/_historyData.html +++ b/Frontend/_historyData.html @@ -324,7 +324,20 @@ else if (deviceItem != null && deviceItem != undefined) { pageAct.devicePoiName = $(elem).text(); pageAct.deviceItem = deviceItem; - getData(); + + let start = new Date($('#his_startdate').val()); + let end = new Date(new Date().setDate(new Date($('#his_enddate input').val()).getDate() + 1)); + + if (pageAct.dateType == "today" || pageAct.dateType == "day" || pageAct.dateType == "ytd") + end = new Date(new Date().setDate(start.getDate() + 1)); + else if (pageAct.dateType == "month") { + start = new Date($('#getmonth').val()); + end = new Date(new Date().setDate(start.getDate() + 30)); + } + else if (pageAct.dateType != "range") + getData(); + + getData(formatDate(start, "date", true), formatDate(end, "date", true)); } } @@ -385,7 +398,7 @@ let start = new Date($('#his_startdate').val()); let end = new Date(new Date().setDate(new Date($('#his_enddate input').val()).getDate() + 1)); - if (pageAct.dateType == "day") + if (pageAct.dateType == "today" || pageAct.dateType == "day" || pageAct.dateType == "ytd") end = new Date(new Date().setDate(start.getDate() + 1)); else if (pageAct.dateType == "month") { start = new Date($('#getmonth').val()); @@ -416,43 +429,43 @@ v.type = pageAct.devicePoiName.split(" ")[0]; }); - let tag = "#historyTable"; + let tag = "#historyTable"; - let column_defs = [ - { "targets": [0], "width": "20%", "sortable": true }, - { "targets": [1], "width": "20%", "sortable": true }, - { "targets": [2], "width": "20%", "sortable": true } - ]; + let column_defs = [ + { "targets": [0], "width": "20%", "sortable": true }, + { "targets": [1], "width": "20%", "sortable": true }, + { "targets": [2], "width": "20%", "sortable": true } + ]; - let columns = [ - { - "title": "類別", - "data": "type" - }, - { - "title": "設備名稱", - "data": "deviceName", - }, - { - "title": "數值", - "data": "value", - "render": function (data) { - if (isNaN(data.toString())) { - return data - } - return data.roundDecimal(2); - } - }, - { - "title": "紀錄時間", - "data": "timestamp", - "render": function (data) { - return displayDate(data, "datetime"); - } - } - ]; + let columns = [ + { + "title": "類別", + "data": "type" + }, + { + "title": "設備名稱", + "data": "deviceName", + }, + { + "title": "數值", + "data": "value", + "render": function (data) { + if (isNaN(data.toString())) { + return data + } + return data.roundDecimal(2); + } + }, + { + "title": "紀錄時間", + "data": "timestamp", + "render": function (data) { + return displayDate(data, "datetime"); + } + } + ]; - historyTable = new YourTeam.JqDataTables.getTableByStatic(tag, data, columns, column_defs, null, null, null, null, "tpi"); + historyTable = new YourTeam.JqDataTables.getTableByStatic(tag, data, columns, column_defs, null, null, null, null, "tpi"); } } @@ -472,29 +485,29 @@ $(loadEle).Loading("close"); }, () => { $(loadEle).Loading("close"); - }, "POST",true).send(); + }, "POST", true).send(); } //選擇棟別 - function SelectBuild(e, building_tag) { - $(loadEle).Loading("start"); - checkIsSelectedBuilding(); - } - - function checkIsSelectedBuilding() { - let result = false; - let buildingRadios = $("[name=buildingRadio]:checked"); - buildingTag = null; - if (buildingRadios && buildingRadios.length > 0) { - $("[name=buildingRadio]").parent().removeClass("btn-info"); - $("[name=buildingRadio]").parent().addClass("btn-secondary"); - $("[name=buildingRadio]:checked").parent().removeClass("btn-secondary"); - $("[name=buildingRadio]:checked").parent().addClass("btn-info"); - buildingTag = buildingRadios.val(); //building tag - pageAct.hisBuiName = buildingRadios.prop('id').split("-")[1]; - initList(); - result = true; + function SelectBuild(e, building_tag) { + $(loadEle).Loading("start"); + checkIsSelectedBuilding(); + } + + function checkIsSelectedBuilding() { + let result = false; + let buildingRadios = $("[name=buildingRadio]:checked"); + buildingTag = null; + if (buildingRadios && buildingRadios.length > 0) { + $("[name=buildingRadio]").parent().removeClass("btn-info"); + $("[name=buildingRadio]").parent().addClass("btn-secondary"); + $("[name=buildingRadio]:checked").parent().removeClass("btn-secondary"); + $("[name=buildingRadio]:checked").parent().addClass("btn-info"); + buildingTag = buildingRadios.val(); //building tag + pageAct.hisBuiName = buildingRadios.prop('id').split("-")[1]; + initList(); + result = true; + } + return result; } - return result; - } \ No newline at end of file