[Frontend] 時間格式統一 Y:M:D H:M:S

This commit is contained in:
Celeste 2023-10-11 11:29:25 +08:00
parent a18152e23a
commit c2bb9cb199
5 changed files with 4661 additions and 4659 deletions

View File

@ -1109,16 +1109,7 @@
title: "發生時間",
data: "timestamp",
render: function (data) {
return (
new Date(data).toLocaleString("zh-tw", {
year: "numeric",
month: "2-digit",
day: "2-digit",
hour: "2-digit",
minute: "2-digit",
}),
displayDate(data, "datetime")
);
return displayDate(data);
},
},
{
@ -1133,9 +1124,7 @@
let btnCol = data == "1" ? "warning" : "info";
return data == "1"
? `<td><button onclick="chgAck('${row.uuid}')" class="btn btn-${btnCol}">${confirm}</button></td>`
: `<td><span>${new Date(row.ackedTime).toLocaleString(
"zh-tw"
)}</span></td>` /*`<td><button class="btn btn-${btnCol}">${confirm}</button></td>`*/;
: `<td><span>${displayDate(row.ackedTime)}</span></td>` /*`<td><button class="btn btn-${btnCol}">${confirm}</button></td>`*/;
},
},
{

View File

@ -917,6 +917,7 @@
{
title: "預計施工時間",
data: "start_time",
className: "text-nowrap",
render: function (data) {
return displayDate(data, "datetime");
},
@ -1099,6 +1100,7 @@
{
title: "預計施工時間",
data: "start_time",
className: "text-nowrap",
render: function (data) {
return displayDate(data, "datetime");
},

View File

@ -1483,7 +1483,9 @@ License: You must have a valid license purchased only from wrapbootstrap.com (li
</div>
<div class="card-body p-2 tab-content w-100">
<div id="state" class="show active w-100" data-tabname="cardTab" data-tabrole="child" >
${drawStateTabBlo(devNum)}
${drawStateTabBlo(
devNum
)}
</div>
<div id="info" data-tabname="cardTab" data-tabrole="child">
@ -1606,30 +1608,41 @@ License: You must have a valid license purchased only from wrapbootstrap.com (li
let tag = "#opeRecTable";
let column_defs = [
{ targets: [0], width: "8%", sortable: true },
{ targets: [1], width: "8%", sortable: true },
{ targets: [2], width: "7%", sortable: true },
{ targets: [3], width: "7%", sortable: true },
{ targets: [0], width: "10%", sortable: true },
{ targets: [1], width: "10%", sortable: true },
{ targets: [2], width: "5%", sortable: true },
{ targets: [3], width: "5%", sortable: true },
];
let columns = [
{
title: "類型",
data: "work_type_name",
className: "text-nowrap",
},
{
title: "項目",
data: "fix_do",
className: "text-nowrap",
},
{
title: "處理人員",
data: "work_person_name",
className: "text-nowrap",
},
{
title: "發生/完成時間",
data: "finishTime",
className: "text-nowrap",
render: function (data, type, row) {
return row.createdAt + "<br>" + (data.includes("0001")? "未完工": data);
return (
displayDate(row.createdAt) +
"<br>" +
(data.includes("0001")
? "未完工"
: displayDate(data)
)
);
},
},
];
@ -1648,6 +1661,7 @@ License: You must have a valid license purchased only from wrapbootstrap.com (li
null,
"<'scrolledTable'tpi>"
);
$("#opeRecTable").DataTable().order([3, "desc"]).draw();
}
function loadLightSchTable(devGuid) {
@ -1766,31 +1780,40 @@ License: You must have a valid license purchased only from wrapbootstrap.com (li
let datas;
let column_defs = [
{ targets: [0], width: "15%", sortable: true },
{ targets: [1], width: "25%", sortable: true },
{ targets: [2], width: "25%", sortable: true },
{ targets: [3], width: "35%", sortable: true },
{ targets: [0], sortable: true },
{ targets: [1], sortable: true },
{ targets: [2], sortable: true },
{ targets: [3], sortable: true },
];
let columns = [
{
title: "異常ID",
data: "uuid",
className: "text-nowrap",
},
{
title: "異常原因",
data: "msgText",
className: "text-nowrap",
},
{
title: "ACK確認",
data: "ackState",
className: "text-nowrap",
render: function (data, type, row) {
return data === 1
? "未確認"
: displayDate(row.ackedTime);
},
},
{
title: "發生時間",
data: "timestamp",
// "render": function (data, type, row) {
// return row.timestamp + "<br>" + data;
// },
className: "text-nowrap",
render: function (data, type, row) {
return displayDate(row.timestamp);
},
},
];
@ -1807,6 +1830,7 @@ License: You must have a valid license purchased only from wrapbootstrap.com (li
null,
"<'scrolledTable'tpi>"
);
$("#errRecTable").DataTable().order([3, "desc"]).draw();
}
//根據 data-type 設置顏色 (判斷後台是否有設定,若無則帶預設)
@ -2345,7 +2369,8 @@ License: You must have a valid license purchased only from wrapbootstrap.com (li
datas[idx].full_name =
allDevices.filter((x) => x.device_number == data.devicePath)[0]
?.full_name || (data.alarmClass === "Sys_Con_AlarmClass"
?.full_name ||
(data.alarmClass === "Sys_Con_AlarmClass"
? `${building_name}_電錶邊緣控制器_${data.split("_")[7]}`
: "");
@ -2390,6 +2415,9 @@ License: You must have a valid license purchased only from wrapbootstrap.com (li
"add_many",
notices.oSort("id").reverse()
);
} else {
$("#noticeBlock").innerHTML = "";
$("#noticeBlock").css({ display: "none", opacity: "0" });
}
});
}

View File

@ -227,46 +227,29 @@ function getOneDeviceAlarmTop10ByBaja(devicePath, callback) {
var _occurrenceTime = new Date(
record.get("timestamp").$cEncStr
).toLocaleString("zh-tw", {
year: "numeric",
month: "2-digit",
day: "2-digit",
hour: "2-digit",
minute: "2-digit",
});
)
// _occurrenceTime += _timestampTemp.getFullYear().toString() + "-" + addzero(_timestampTemp.getMonth() + 1).toString() + "-" + addzero(_timestampTemp.getDate()).toString() + " " + addzero(_timestampTemp.getHours()).toString() + ":" + addzero(_timestampTemp.getMinutes()).toString() + ":" + addzero(_timestampTemp.getSeconds()).toString();
//var _occurrenceTime = _timestamp.format("yyyy-MM-dd hh:mm:ss");//.toLocaleString();
var _ackTime = new Date(
record.get("ackTime").$cEncStr
).toLocaleString("zh-tw", {
year: "numeric",
month: "2-digit",
day: "2-digit",
hour: "2-digit",
minute: "2-digit",
});
)
// _normalTime += _normaltime.getFullYear().toString() + "-" + addzero(_normaltime.getMonth() + 1).toString() + "-" + addzero(_normaltime.getDate()).toString() + " " + addzero(_normaltime.getHours()).toString() + ":" + addzero(_normaltime.getMinutes()).toString() + ":" + addzero(_normaltime.getSeconds()).toString();
var _normalTime = new Date(
record.get("normalTime").$cEncStr
).toLocaleString("zh-tw", {
year: "numeric",
month: "2-digit",
day: "2-digit",
hour: "2-digit",
minute: "2-digit",
});
)
var _msgText = record.get("alarmData").get("msgText"); // == 1 ? _occurrenceTime : "未確認";
var _ackText =
record.get("ackState") == 0 ? _ackTime : "未確認";
record.get("ackState")
_ss.push({
uuid: _resultUuid[0],
msgText: _msgText,
ackState: _ackText,
timestamp: _occurrenceTime,
normalTime: _normalTime,
ackedTime: _ackTime
});
_index++;
},

View File

@ -1001,9 +1001,9 @@ function BajaSubscribeElectricmeterByBql(
);
//使用bql語法
// console.log(
// `local:|foxs:${port}|station:|slot:/${ordPathForElectricmeter.devicePath}|bql:select name, out, out.value, slotPath, facets from control:ControlPoint`
// );
console.log(
`local:|foxs:${port}|station:|slot:/${ordPathForElectricmeter.devicePath}|bql:select name, out, out.value, slotPath, facets from control:ControlPoint`
);
baja.Ord.make(
`local:|foxs:${port}|station:|slot:/${ordPathForElectricmeter.devicePath}|bql:select name, out, out.value, slotPath, facets from control:ControlPoint`
).get(function (table) {