+ // Card 呈現初始化
+ function initPopover() {
+ $("[name=devItem]").each((index, ele) => {
+ let devNum = $(ele).data("number"); //設備編號
+ let devGuid = $(ele).data("id"); //guid
+ let devName = $(ele).data("name"); //full_name
+ $(ele).YTTooltip({
+ html: `
`,
- group: "device",
- onShow: function (tooltipEle, oriEle) {
- var tab = new YT.Tab({ tabName: "cardTab" })
- loadOpeRecTable(devGuid);
- //loadErrRecTable2($(oriEle).data("number"));
- //loadErrRecTable();
- loadErr($(oriEle).data("number"));
- subDeviceSetTable ? subDeviceSetTable($(oriEle).data("number")) : ""
+ group: "device",
+ onShow: function (tooltipEle, oriEle) {
+ var tab = new YT.Tab({ tabName: "cardTab" })
+ loadOpeRecTable(devGuid);
+ //loadErrRecTable2($(oriEle).data("number"));
+ //loadErrRecTable();
+ loadErr($(oriEle).data("number"));
+ subDeviceSetTable ? subDeviceSetTable($(oriEle).data("number")) : ""
+ }
+ })
+ })
+ }
+
+ // Card - 運維紀錄 Table
+ function loadOpeRecTable(devGuid) {
+
+ let url = baseApiUrl + "/api/Device/GetOpeDevice?device_guid=" + devGuid;
+ 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 },
+ ];
+
+ let columns = [
+ {
+ "title": "類型",
+ "data": "work_type_name",
+ },
+ {
+ "title": "項目",
+ "data": "fix_do",
+ },
+ {
+ "title": "處理人員",
+ "data": "work_person_name",
+ },
+ {
+ "title": "發生/完成時間",
+ "data": "finishTime",
+ "render": function (data, type, row) {
+ return row.createdAt + "
" + data;
+ },
+ },
+
+ ];
+
+ let opeRecTable = new YourTeam.JqDataTables.getTableByAjax(url, tag, null, columns, column_defs, null, null, null, null, null, null, "tpi");
+ }
+
+ // Baja 取得異常紀錄
+ function loadErr(allPath) {
+ if (allPath != undefined && allPath != null) {
+ let _pathArr = allPath.split("_");//TPE_B1_ELEV_EL_R2F_NA_ELEV1_N1
+ let _devicePath = _pathArr[0] + "_" + _pathArr[1] + "_" + _pathArr[2] + "_" + _pathArr[3] + "_" + _pathArr[4] + "_" + _pathArr[5];
+ getOneDeviceAlarmTop10ByBaja(_devicePath, callbackForErr);
+ }
+ else {
+ console.log("no device");
+ }
+ }
+
+ // Card - 異常紀錄 Table
+ function callbackForErr(result) {
+ let tag = "#errRecTable";
+ 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 },
+ ];
+
+ let columns = [
+ {
+ "title": "異常ID",
+ "data": "uuid",
+
+ },
+ {
+ "title": "異常原因",
+ "data": "msgText",
+ },
+ {
+ "title": "ACK確認",
+ "data": "ackState",
+ },
+ {
+ "title": "發生/完成時間",
+ "data": "normalTime",
+ "render": function (data, type, row) {
+ return row.timestamp + "
" + data;
+ },
+ },
+
+ ];
+
+ let json_object = JSON.parse(result);
+ datas = json_object['data'];
+ errRecTable = new YourTeam.JqDataTables.getTableByStatic(tag, datas, columns, column_defs, null, null, null, null, "tpi");
+
+ }
+
+ //根據 data-type 設置顏色 (判斷後台是否有設定,若無則帶預設)
+ function setLightColor() {
+ $(".dev-card").each((index, ele) => {
+ let type = $(ele).find("[data-light-type]").data("light-type");
+ let isFlashing = false;
+ let color = "#000";
+ switch (type) {
+ case "normal":
+ color = pageAct.sysSubObj.device_normal_color ?? "var(--theme-success)";
+ isFlashing = pageAct.sysSubObj.device_normal_flashing == "1";
+ break;
+ case "close":
+ color = pageAct.sysSubObj.device_close_color ?? "var(--theme-secondary)";
+ isFlashing = pageAct.sysSubObj.device_close_flashing == "1";
+ break;
+ case "error":
+ color = pageAct.sysSubObj.device_error_color ?? "var(--theme-danger)";
+ isFlashing = pageAct.sysSubObj.device_error_flashing == "1";
+ break;
+ }
+ $(ele).find("[data-light-type]").css("background-color", color);
+ //是否閃爍
+ if (isFlashing) {
+ $(ele).addClass("light-flash");
}
})
- })
- }
-
- // Card - 運維紀錄 Table
- function loadOpeRecTable(devGuid) {
-
- let url = baseApiUrl + "/api/Device/GetOpeDevice?device_guid=" + devGuid;
- 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 },
- ];
-
- let columns = [
- {
- "title": "類型",
- "data": "work_type_name",
- },
- {
- "title": "項目",
- "data": "fix_do",
- },
- {
- "title": "處理人員",
- "data": "work_person_name",
- },
- {
- "title": "發生/完成時間",
- "data": "finishTime",
- "render": function (data, type, row) {
- return row.createdAt + "
" + data;
- },
- },
-
- ];
-
- let opeRecTable = new YourTeam.JqDataTables.getTableByAjax(url, tag, null, columns, column_defs, null, null, null, null, null, null, "tpi");
- }
-
- // Baja 取得異常紀錄
- function loadErr(allPath) {
- if (allPath != undefined && allPath != null) {
- let _pathArr = allPath.split("_");//TPE_B1_ELEV_EL_R2F_NA_ELEV1_N1
- let _devicePath = _pathArr[0] + "_" + _pathArr[1] + "_" + _pathArr[2] + "_" + _pathArr[3] + "_" + _pathArr[4] + "_" + _pathArr[5];
- getOneDeviceAlarmTop10ByBaja(_devicePath, callbackForErr);
- }
- else {
- console.log("no device");
}
+
+ //==============================================================================
+ // ↑ 系統監控 - 共用 Function ↑
+ //==============================================================================
+
+ } catch(e) {
+ $(loadEle).Loading("close");
}
- // Card - 異常紀錄 Table
- function callbackForErr(result) {
- let tag = "#errRecTable";
- 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 },
- ];
-
- let columns = [
- {
- "title": "異常ID",
- "data": "uuid",
-
- },
- {
- "title": "異常原因",
- "data": "msgText",
- },
- {
- "title": "ACK確認",
- "data": "ackState",
- },
- {
- "title": "發生/完成時間",
- "data": "normalTime",
- "render": function (data, type, row) {
- return row.timestamp + "
" + data;
- },
- },
-
- ];
-
- let json_object = JSON.parse(result);
- datas = json_object['data'];
- errRecTable = new YourTeam.JqDataTables.getTableByStatic(tag, datas, columns, column_defs, null, null, null, null, "tpi");
-
- }
-
- //根據 data-type 設置顏色 (判斷後台是否有設定,若無則帶預設)
- function setLightColor() {
- $(".dev-card").each((index, ele) => {
- let type = $(ele).find("[data-light-type]").data("light-type");
- let isFlashing = false;
- let color = "#000";
- switch (type) {
- case "normal":
- color = pageAct.sysSubObj.device_normal_color ?? "var(--theme-success)";
- isFlashing = pageAct.sysSubObj.device_normal_flashing == "1";
- break;
- case "close":
- color = pageAct.sysSubObj.device_close_color ?? "var(--theme-secondary)";
- isFlashing = pageAct.sysSubObj.device_close_flashing == "1";
- break;
- case "error":
- color = pageAct.sysSubObj.device_error_color ?? "var(--theme-danger)";
- isFlashing = pageAct.sysSubObj.device_error_flashing == "1";
- break;
- }
- $(ele).find("[data-light-type]").css("background-color", color);
- //是否閃爍
- if (isFlashing) {
- $(ele).addClass("light-flash");
- }
- })
- }
-
- //==============================================================================
- // ↑ 系統監控 - 共用 Function ↑
- //==============================================================================
+