[前端] 修改按鈕問題

This commit is contained in:
dev02 2023-07-03 11:07:07 +08:00
parent 9b0ad0fbd6
commit dd2eea50d1

View File

@ -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;
}
</script>