[Frontend] 修改系統監控告警 ack 狀態 | 運維保養刪除異常編號欄位 | 告警新增維修單時自動抓取該設備

This commit is contained in:
Celeste 2023-10-06 14:37:37 +08:00
parent bca579903b
commit a18152e23a
4 changed files with 3831 additions and 2989 deletions

View File

@ -119,6 +119,16 @@
<form id="alr_opeRecForm"> <form id="alr_opeRecForm">
<div class="modal-body"> <div class="modal-body">
<div class="row"> <div class="row">
<div class="col-md-6">
<div class="form-group">
<label class="form-label" for="inpNumber">表單編號</label>
<input type="text"
id="inpNumber"
name=""
class="form-control"
disabled />
</div>
</div>
<div class="col-md-6"> <div class="col-md-6">
<div class="form-group"> <div class="form-group">
<label class="form-label" for="inpErrCode">異常編號</label> <label class="form-label" for="inpErrCode">異常編號</label>
@ -160,11 +170,15 @@
</div> </div>
</div> </div>
<div class="col-md-6"> <div class="col-md-6">
<div class="form-group"> <div class="form-group position-relative">
<label class="form-label" for="inpFixDoCode">維修項目代碼(設備編號)</label> <label class="form-label" for="inpFixDoCode">維修項目代碼(設備名稱)</label>
<select class="form-control" <select id="inpFixDoCode"
id="inpFixDoCode" name="inpFixDoCode"
name="inpFixDoCode"> class="form-control position-absolute"
style="z-index: 999; background-color: #3f4246"
onfocus="this.size=15;"
onblur="this.size=1;"
onchange="this.size=1; this.blur();">
<option value="">未選擇</option> <option value="">未選擇</option>
</select> </select>
</div> </div>
@ -349,7 +363,7 @@
</div> </div>
<div class="col-md-6"> <div class="col-md-6">
<div class="form-group"> <div class="form-group">
<label class="form-label" for="alr_inpFixDoCode_2">維修項目代碼(設備編號)</label> <label class="form-label" for="alr_inpFixDoCode_2">維修項目代碼(設備名稱)</label>
<select class="form-control" <select class="form-control"
id="alr_inpFixDoCode_2" id="alr_inpFixDoCode_2"
name="alr_inpFixDoCode_2" name="alr_inpFixDoCode_2"
@ -646,16 +660,20 @@
let alr_table = $("#alertTable").DataTable(); let alr_table = $("#alertTable").DataTable();
let alr_elem = $(this).parent().parent(); let alr_elem = $(this).parent().parent();
let alr_tableData = alr_table.row(alr_elem).data(); let alr_tableData = alr_table.row(alr_elem).data();
$("#inpFixDo").val(alr_tableData.msgText);
$("#inpErrCode").html( $("#inpErrCode").html(
`<option value = ${alr_tableData.uuid}>${alr_tableData.msgText}</option>` `<option value = ${alr_tableData.uuid.$val}>${alr_tableData.uuid.$val.split("-")[0]
}</option>`
); );
$("#inpStaTime").val( $("#inpStaTime").val(
displayDate(new Date(Date.now()), "date").replaceAll("/", "-") displayDate(new Date(Date.now()), "date").replaceAll("/", "-")
); );
let deviceNumber = null; let deviceNumber = null;
let system = $(this).data("system"); let system = $(this).data("realsystem");
pageAct.addSelMain = system.split("-")[0]; pageAct.addSelMain = system.split("-")[0];
pageAct.addSelSub = system.split("-")[1]; pageAct.addSelSub = system.split("-")[1];
pageAct.floor = alr_tableData.buildingFloorName_zh.split("-")[1];
deviceNumber = deviceNumber =
pageAct.AreaTag + pageAct.AreaTag +
@ -672,8 +690,9 @@
"_" + "_" +
alr_tableData.sourceName_zh.toString().split("-")[1]; alr_tableData.sourceName_zh.toString().split("-")[1];
GetFormId();
selUser(); selUser();
selDevice(); selDevice(alr_tableData);
selOpeFir(); selOpeFir();
getUser(); getUser();
@ -709,8 +728,6 @@
$(form).validate({ $(form).validate({
rules: { rules: {
inpWorTyp: { required: true }, inpWorTyp: { required: true },
inpFixDo: { required: true },
inpFixDoCode: { required: true },
inpFixFirm: { required: true }, inpFixFirm: { required: true },
inpStatus: { required: true }, inpStatus: { required: true },
inpWorPerId: { required: true }, inpWorPerId: { required: true },
@ -729,19 +746,20 @@
}); });
fd.append("error_code", $("#inpErrCode").val()); fd.append("error_code", $("#inpErrCode").val());
fd.append("location", "台北" + $("#buiActDrop").text() + pageAct.floor); fd.append("location", "台北" + pageAct.floor);
fd.append( fd.append(
"location_code", "location_code",
pageAct.AreaTag + pageAct.buiTag + pageAct.floor pageAct.AreaTag + pageAct.buiTag + pageAct.floor
); );
fd.append("device_system_category_layer2", pageAct.addSelMain); fd.append("device_system_category_layer2", pageAct.addSelMain);
fd.append("device_system_category_layer3", pageAct.addSelSub); fd.append("device_system_category_layer3", pageAct.addSelSub);
fd.append("work_type", parseInt($("#inpWorTyp").val())); fd.append("work_type", parseInt($("#inpWorTyp").val()) || null);
fd.append("fix_do", $("#inpFixDo").val()); fd.append("fix_do", $("#inpFixDo").val() || null);
fd.append("fix_do_code", $("#inpFixDoCode").val()); fd.append("fix_do_code", $("#inpFixDoCode").val() || null);
fd.append("fix_firm", parseInt($("#inpFixFirm").val())); fd.append("fix_firm", parseInt($("#inpFixFirm").val()) || null);
fd.append("status", parseInt($("#inpStatus").val())); fd.append("status", parseInt($("#inpStatus").val()) || null);
fd.append("work_person_id", $("#inpWorPerId").val()); fd.append("work_person_id", $("#inpWorPerId").val() || null);
fd.append( fd.append(
"start_time", "start_time",
($("#inpStaTime").val() || null) == null ($("#inpStaTime").val() || null) == null
@ -1050,9 +1068,6 @@
{ {
title: "棟別-樓層", title: "棟別-樓層",
data: "buildingFloorName_zh", data: "buildingFloorName_zh",
render: (data) => {
return data.replace("$3", "");
},
}, },
{ {
title: "異常ID", title: "異常ID",
@ -1078,10 +1093,12 @@
({ building_tag }) => building_tag === data.split("_")[1] ({ building_tag }) => building_tag === data.split("_")[1]
)?.full_name; )?.full_name;
return allDevices.find((d) => d.device_number === data)?.full_name || return (
allDevices.find((d) => d.device_number === data)?.full_name ||
(row.alarmClass === "Sys_Con_AlarmClass" (row.alarmClass === "Sys_Con_AlarmClass"
? `${building_name}_電錶邊緣控制器_${data.split("_")[7]}` ? `${building_name}_電錶邊緣控制器_${data.split("_")[7]}`
: ""); : "")
);
}, },
}, },
{ {
@ -1132,6 +1149,9 @@
"-" + "-" +
row.alarmClass.split("_")[1] row.alarmClass.split("_")[1]
: row.alarmClass : row.alarmClass
}' data-realsystem='${row.sourceName_zh.split("_")[2] +
"-" +
row.sourceName_zh.split("_")[3]
}'>+ 維修單</a></td>`; }'>+ 維修單</a></td>`;
}, },
}, },
@ -1178,7 +1198,7 @@
).send(); ).send();
} }
function selDevice() { function selDevice(alr_tableData = null) {
let url = baseApiUrl + "/operation/DevList"; let url = baseApiUrl + "/operation/DevList";
let lsst = []; let lsst = [];
lsst.push(pageAct.addSelSub); lsst.push(pageAct.addSelSub);
@ -1195,10 +1215,17 @@
function (res) { function (res) {
if (!res || res.code != "0000" || !res.data) { if (!res || res.code != "0000" || !res.data) {
} else { } else {
strHtml = ``;
$("#inpFixDoCode").html(); $("#inpFixDoCode").html();
$("#alr_inpFixDoCode_2").html(); $("#alr_inpFixDoCode_2").html();
$.each(res.data, (index, roleObj) => {
let strHtml = ""
if (alr_tableData) {
const currentDevice = res.data.find(({ device_number }) => device_number === alr_tableData.sourceName_zh);
strHtml += `<option value='${currentDevice.sourceName_zh}' data-floor=${currentDevice.device_floor_tag} data-main=${currentDevice.device_system_tag} data-sub=${currentDevice.device_name_tag} hidden>${currentDevice.device_name}</option>`;
}
$.each(res.data.filter(({ device_number }) => device_number !== alr_tableData?.sourceName_zh), (index, roleObj) => {
strHtml += `<option value='${roleObj.device_number}' data-floor=${roleObj.device_floor_tag} data-main=${roleObj.device_system_tag} data-sub=${roleObj.device_name_tag} hidden>${roleObj.device_name}</option>`; strHtml += `<option value='${roleObj.device_number}' data-floor=${roleObj.device_floor_tag} data-main=${roleObj.device_system_tag} data-sub=${roleObj.device_name_tag} hidden>${roleObj.device_name}</option>`;
if (index == 0) { if (index == 0) {
@ -1210,6 +1237,7 @@
}); });
$("#inpFixDoCode").html(strHtml); $("#inpFixDoCode").html(strHtml);
$("#alr_inpFixDoCode_2").html(strHtml); $("#alr_inpFixDoCode_2").html(strHtml);
} }
}, },
null, null,
@ -1568,4 +1596,21 @@
$(loadEle).Loading("close"); $(loadEle).Loading("close");
} }
function GetFormId() {
let url = baseApiUrl + "/operation/GetFormId";
ytAjax = new YourTeam.Ajax(
url,
objSendData,
function (res) {
if (!res || res.code != "0000" || !res.data) {
} else {
$("#inpNumber").val(res.data);
}
},
null,
"POST"
).send();
}
</script> </script>

File diff suppressed because it is too large Load Diff

View File

@ -1629,7 +1629,7 @@ License: You must have a valid license purchased only from wrapbootstrap.com (li
title: "發生/完成時間", title: "發生/完成時間",
data: "finishTime", data: "finishTime",
render: function (data, type, row) { render: function (data, type, row) {
return row.createdAt + "<br>" + data; return row.createdAt + "<br>" + (data.includes("0001")? "未完工": data);
}, },
}, },
]; ];
@ -1758,7 +1758,6 @@ License: You must have a valid license purchased only from wrapbootstrap.com (li
// Card - 異常紀錄 Table // Card - 異常紀錄 Table
function callbackForErr(result) { function callbackForErr(result) {
// console.log("@@@",result)
if (errRecTable) { if (errRecTable) {
errRecTable.destroy(); errRecTable.destroy();
} }
@ -1787,8 +1786,8 @@ License: You must have a valid license purchased only from wrapbootstrap.com (li
data: "ackState", data: "ackState",
}, },
{ {
title: "發生/完成時間", title: "發生時間",
data: "normalTime", data: "timestamp",
// "render": function (data, type, row) { // "render": function (data, type, row) {
// return row.timestamp + "<br>" + data; // return row.timestamp + "<br>" + data;
// }, // },

View File

@ -212,7 +212,7 @@ function getOneDeviceAlarmTop10ByBaja(devicePath, callback) {
//{ "count":2,"data": [{ "time": "2022/11/14 15:00:00", "errId": "0001", "ackCheck": "未確認", "errReason": "燈泡故障" }, { "time": "2022/11/14 15:00:00", "errId": "0002", "ackCheck": "未確認", "errReason": "燈泡故障" }]} //{ "count":2,"data": [{ "time": "2022/11/14 15:00:00", "errId": "0001", "ackCheck": "未確認", "errReason": "燈泡故障" }, { "time": "2022/11/14 15:00:00", "errId": "0002", "ackCheck": "未確認", "errReason": "燈泡故障" }]}
require(["baja!"], function (baja) { require(["baja!"], function (baja) {
baja.Ord.make( baja.Ord.make(
"local:|foxs:|alarm:|bql:select top 10 timestamp, ackState, alarmData, alarmData.sourceName, sourceState, uuid, alarmData.msgText, normalTime where alarmData.sourceName like '%" + "local:|foxs:|alarm:|bql:select top 10 timestamp, ackState, ackTime, alarmData, alarmData.sourceName, sourceState, uuid, alarmData.msgText, normalTime where alarmData.sourceName like '%" +
devicePath + devicePath +
"%' order by timestamp desc" "%' order by timestamp desc"
) )
@ -237,8 +237,8 @@ function getOneDeviceAlarmTop10ByBaja(devicePath, callback) {
// _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(); // _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 _occurrenceTime = _timestamp.format("yyyy-MM-dd hh:mm:ss");//.toLocaleString();
var _normalTime = new Date( var _ackTime = new Date(
record.get("normalTime").$cEncStr record.get("ackTime").$cEncStr
).toLocaleString("zh-tw", { ).toLocaleString("zh-tw", {
year: "numeric", year: "numeric",
month: "2-digit", month: "2-digit",
@ -248,9 +248,19 @@ function getOneDeviceAlarmTop10ByBaja(devicePath, callback) {
}); });
// _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(); // _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 _msgText = record.get("alarmData").get("msgText"); // == 1 ? _occurrenceTime : "未確認";
var _ackText = var _ackText =
record.get("ackState") == 1 ? _occurrenceTime : "未確認"; record.get("ackState") == 0 ? _ackTime : "未確認";
_ss.push({ _ss.push({
uuid: _resultUuid[0], uuid: _resultUuid[0],
msgText: _msgText, msgText: _msgText,