diff --git a/Frontend/_operation.html b/Frontend/_operation.html index d45cb85..0e19bd8 100644 --- a/Frontend/_operation.html +++ b/Frontend/_operation.html @@ -1999,7 +1999,7 @@ res.data.work_type ); $(pageAct.work_type == "1" ? "#inpErrCode" : "#inpErrCode_2").val( - res.data.error_code + res.data.error_code?.split("-")[0] || "" ); $(pageAct.work_type == "1" ? "#inpFixDo" : "#inpFixDo_2").val( res.data.fix_do diff --git a/Frontend/index.html b/Frontend/index.html index 9352697..da281c0 100644 --- a/Frontend/index.html +++ b/Frontend/index.html @@ -190,7 +190,7 @@ License: You must have a valid license purchased only from wrapbootstrap.com (li + --> @@ -234,21 +234,21 @@ License: You must have a valid license purchased only from wrapbootstrap.com (li + + + + -->
@@ -257,7 +257,7 @@ License: You must have a valid license purchased only from wrapbootstrap.com (li id="toggleNoticeBtn" class="d-flex align-items-center justify-content-center ml-2"> + alt="Dr. Codex Lantern">-->
@@ -275,7 +275,7 @@ License: You must have a valid license purchased only from wrapbootstrap.com (li data-target="logoutList" class="d-flex align-items-center justify-content-center ml-2"> + alt="Dr. Codex Lantern">-->
@@ -295,10 +295,10 @@ License: You must have a valid license purchased only from wrapbootstrap.com (li
+ Diamond Controls®
-->
@@ -314,25 +314,25 @@ License: You must have a valid license purchased only from wrapbootstrap.com (li data-class="mobile-nav-on">
+
+ +
+
--> +
+ 2022 © SmartAdmin by gotbootstrap.com +
+
+ +
+ --> @@ -1422,7 +1422,7 @@ License: You must have a valid license purchased only from wrapbootstrap.com (li function drawErrRecTabBlo() { let strHtml = ` -
`; + `; return strHtml; } @@ -1430,7 +1430,7 @@ License: You must have a valid license purchased only from wrapbootstrap.com (li function drawOpeRecTabBlo() { let strHtml = ` -
`; + `; return strHtml; } @@ -1457,47 +1457,47 @@ License: You must have a valid license purchased only from wrapbootstrap.com (li html: `
-
+
-
- -
- -
-
- ${drawStateTabBlo( +
+
+
+
+ ${drawStateTabBlo( devNum )} -
-
+
+
-
-
- ${drawErrRecTabBlo()} -
-
- ${drawOpeRecTabBlo()} -
-
-
`, +
+
+ ${drawErrRecTabBlo()} +
+
+ ${drawOpeRecTabBlo()} +
+
+ `, group: "device", // 在 _sysElevator.html 及 _sysMonAll.html 會用到 onShow: function (tooltipEle, oriEle) { @@ -1874,27 +1874,27 @@ License: You must have a valid license purchased only from wrapbootstrap.com (li sysSubObj.device_normal_point_value != null ) { strHtml += `
- - -
`; + + + `; } if ( sysSubObj.device_close_point_name != null && sysSubObj.device_close_point_value != null ) { strHtml += `
- - -
`; + + + `; } if ( sysSubObj.device_error_point_name != null && sysSubObj.device_error_point_value != null ) { strHtml += `
- - -
`; + + + `; } return strHtml; @@ -2059,28 +2059,28 @@ License: You must have a valid license purchased only from wrapbootstrap.com (li if (!res || res.code != "0000" || !res.data) { } else { let strHtml = `
- -
首頁 -
- -
`; + +
首頁 +
+ + `; $.each(res.data, function (i, v) { if (v.authCode == "PF1") { strHtml += `
- -
${v.subName} -
-
- -
-
- `; + +
${v.subName} +
+
+ +
+ + `; hasMonitor = true; } else { @@ -2101,11 +2101,11 @@ License: You must have a valid license purchased only from wrapbootstrap.com (li ? "fa-user" : ""; strHtml += `
- -
${v.subName} -
-
`; + +
${v.subName} +
+ `; } }); @@ -2356,68 +2356,59 @@ License: You must have a valid license purchased only from wrapbootstrap.com (li let titleHtml = `異常通知`; let notices = []; // 遍歷每個告警資料 - if (datas.length === 0) { - $("#noticeBlock").innerHTML = ""; - } else { - $.each(datas ?? [], (idx, data) => { - if (noticeOptArr.findIndex((x) => x.id == data.uuid) == -1) { - // 針對該告警對象的設備,從 allDevices 找出設備名稱 - const building_name = pageAct.buildList.find( - ({ building_tag }) => - building_tag === data.devicePath.split("_")[1] - )?.full_name; + $.each(datas ?? [], (idx, data) => { + if (noticeOptArr.findIndex((x) => x.id == data.uuid) == -1) { + // 針對該告警對象的設備,從 allDevices 找出設備名稱 + const building_name = pageAct.buildList.find( + ({ building_tag }) => + building_tag === data.devicePath.split("_")[1] + )?.full_name; - datas[idx].full_name = - allDevices.filter( - (x) => x.device_number == data.devicePath - )[0]?.full_name || - (data.alarmClass === "Sys_Con_AlarmClass" - ? `${building_name}_電錶邊緣控制器_${data.split("_")[7]}` - : ""); + datas[idx].full_name = + allDevices.filter((x) => x.device_number == data.devicePath)[0] + ?.full_name || + (data.alarmClass === "Sys_Con_AlarmClass" + ? `${building_name}_電錶邊緣控制器_${data.split("_")[7]}` + : ""); - let div1 = creDiv(["col-12"]); - let button = creBtn( - "確認", - "noticeChkBtn", - null, - ["btn btn-sm btn-secondary ml-auto col-4"], - { uuid: data.uuid } - ); - let btnDiv = creDiv(["d-flex m-0 gap-5 mt-2"]); - btnDiv.append(button); - // 繪製 每行告警資訊 - noticeObj.forEach((notice) => { - let div2 = creDiv(["row", "m-0"]); - let span1 = creSpan(notice.title + ":", ["m-0"]); - if (notice.data === "uuid") { - data[notice.data] = data[notice.data].split("-")[0]; - } - span1.append(creSpan(data[notice.data])); - div2.append(span1); - div1.append(div2); - }); - - div1.append(btnDiv); - // 拚湊 YTNotice 通知套件所需參數 - let main = { - title: titleHtml, - content: div1.outerHtml(), - type: "warning", - id: data.uuid, - hasCloseBtn: true, - timeText: displayDate(data.timestamp), - }; - noticeOptArr.push(main); - notices.push(main); - } - }); - if (notices.length != 0) { - $("#noticeBlock").YTNotice( - "add_many", - notices.oSort("id").reverse() + let div1 = creDiv(["col-12"]); + let button = creBtn( + "確認", + "noticeChkBtn", + null, + ["btn btn-sm btn-secondary ml-auto col-4"], + { uuid: data.uuid } ); + let btnDiv = creDiv(["d-flex m-0 gap-5 mt-2"]); + btnDiv.append(button); + // 繪製 每行告警資訊 + noticeObj.forEach((notice) => { + let div2 = creDiv(["row", "m-0"]); + let span1 = creSpan(notice.title + ":", ["m-0"]); + if (notice.data === "uuid") { + data[notice.data] = data[notice.data].split("-")[0]; + } + span1.append(creSpan(data[notice.data])); + div2.append(span1); + div1.append(div2); + }); + + div1.append(btnDiv); + // 拚湊 YTNotice 通知套件所需參數 + let main = { + title: titleHtml, + content: div1.outerHtml(), + type: "warning", + id: data.uuid, + hasCloseBtn: true, + timeText: displayDate(data.timestamp), + }; + noticeOptArr.push(main); + notices.push(main); } - } + }); + + $("#noticeBlock").YTNotice("add_many", notices.oSort("id").reverse()); }); } diff --git a/Frontend/js/yourteam/plugins/yt-notice/yt-notice.js b/Frontend/js/yourteam/plugins/yt-notice/yt-notice.js index 8114493..477d17f 100644 --- a/Frontend/js/yourteam/plugins/yt-notice/yt-notice.js +++ b/Frontend/js/yourteam/plugins/yt-notice/yt-notice.js @@ -11,278 +11,287 @@ * * */ - class YTNotice { - constructor(option = {}) { - this.id = option.id ?? null; - this.title = option.title ?? ""; - this.content = option.content ?? ""; - this.type = option.type ?? null; - this.hasCloseBtn = option.hasCloseBtn ?? true; - this.keepTime = 0; - this.timeText = option.timeText ?? "剛剛"; - this.iconClass = option.iconClass ?? ""; - this.container = ""; - this.eIcon = ""; - this.eTitle = ""; - this.eTimeAgo = ""; - this.eCloseBtn = ""; - this.eContent = ""; - this.init(); + constructor(option = {}) { + this.id = option.id ?? null; + this.title = option.title ?? ""; + this.content = option.content ?? ""; + this.type = option.type ?? null; + this.hasCloseBtn = option.hasCloseBtn ?? true; + this.keepTime = 0; + this.timeText = option.timeText ?? "剛剛"; + this.iconClass = option.iconClass ?? ""; + this.container = ""; + this.eIcon = ""; + this.eTitle = ""; + this.eTimeAgo = ""; + this.eCloseBtn = ""; + this.eContent = ""; + this.init(); + } + + init = function () { + this.setNoticeId(); + this.setIconClass(); + this.setContainer(); + + if (this.title) { + this.setTitle(this.title); + } + if (this.content) { + this.setContent(this.content); + } + if (this.timeText) { + this.setTimeAgo(this.timeText); } - init = function () { - this.setNoticeId(); - this.setIconClass(); - this.setContainer(); + $(this.container)[0]._ytNotice = this; + }; - if (this.title) { - this.setTitle(this.title); - } - if (this.content) { - this.setContent(this.content); - } - if (this.timeText) { - this.setTimeAgo(this.timeText); - } - - $(this.container)[0]._ytNotice = this; + setNoticeId = function () { + if (this.id == null) { + this.id = YT.Math.Random(10000000, 99999999); } + }; - setNoticeId = function () { - if (this.id == null) { - this.id = YT.Math.Random(10000000, 99999999); - } + setContainer = function () { + this.container = + $(``); + + this.setIcon(this.iconClass); + this.eTitle = $(``); + this.eTimeAgo = $(``); + this.eCloseBtn = $( + `` + ); + this.eContent = $(`
`); + if (this.type != null) { + this.container.find(".toast-header").append(this.eIcon); + this.eIcon.addClass("text-" + this.type); } - - setContainer = function () { - this.container = $(``); - - this.setIcon(this.iconClass); - this.eTitle = $(``); - this.eTimeAgo = $(``); - this.eCloseBtn = $(``); - this.eContent = $(`
`); - if (this.type != null) { - this.container.find(".toast-header").append(this.eIcon); - this.eIcon.addClass("text-" + this.type); - } - this.container.find(".toast-header").append(this.eTitle); - this.container.find(".toast-header").append(this.eTimeAgo); - if (this.hasCloseBtn) { - this.container.find(".toast-header").append(this.eCloseBtn); - } - this.container.find(".toast-body").append(this.eContent); + this.container.find(".toast-header").append(this.eTitle); + this.container.find(".toast-header").append(this.eTimeAgo); + if (this.hasCloseBtn) { + this.container.find(".toast-header").append(this.eCloseBtn); } + this.container.find(".toast-body").append(this.eContent); + }; - setIconClass = function () { - if (this.type == "success") { - this.iconClass = `fas fa-check`; - } else if (this.type == "warning") { - this.iconClass = `fas fa-exclamation-triangle`; - } else if (this.type == "danger") { - this.iconClass = `fas fa-times`; - } + setIconClass = function () { + if (this.type == "success") { + this.iconClass = `fas fa-check`; + } else if (this.type == "warning") { + this.iconClass = `fas fa-exclamation-triangle`; + } else if (this.type == "danger") { + this.iconClass = `fas fa-times`; } + }; - setIcon = function (iconClass) { - this.eIcon = $(``); - this.eIcon.addClass(iconClass); - } + setIcon = function (iconClass) { + this.eIcon = $(``); + this.eIcon.addClass(iconClass); + }; - setTitle = function (title = "") { - this.eTitle.html(title); - } + setTitle = function (title = "") { + this.eTitle.html(title); + }; - setTimeAgo = function (timeAgo = "") { - this.eTimeAgo.text(timeAgo); - } - - setContent = function (content = "") { - this.eContent.html(content); - } + setTimeAgo = function (timeAgo = "") { + this.eTimeAgo.text(timeAgo); + }; + setContent = function (content = "") { + this.eContent.html(content); + }; } class YTNoticeBlock { - constructor(option = {}) { - this.element = option.element; - this.offsetBottom = 200; - this.noticeArr = []; - this.eScroll = $(`
`); - this.noticeContainer = ""; - this.scrollY = option.scrollY ?? true; + constructor(option = {}) { + this.element = option.element; + this.offsetBottom = 200; + this.noticeArr = []; + this.eScroll = $(`
`); + this.noticeContainer = ""; + this.scrollY = option.scrollY ?? true; - this.init(); + this.init(); + } + + init = function () { + this.drawInitScroll(); + this.drawElement(); + + if (this.scrollY) { + this.noticeContainer = this.eScroll; + } else { + this.noticeContainer = this.element; } - init = function () { - this.drawInitScroll(); - this.drawElement(); + this.updEleObj(); + }; - if (this.scrollY) { - this.noticeContainer = this.eScroll; - } else { - this.noticeContainer = this.element; + drawInitScroll = function () { + if (this.scrollY) { + $(this.eScroll).css("height", "100%"); + $(this.eScroll).css("overflow-y", "auto"); + $(this.element).append(this.eScroll); + } + }; + + drawElement = function () { + $(this.element).addClass("yt-notice-block"); + }; + + showOneNotice = function (obj = null, append = "prepend") { + if (obj) { + if (append == "prepend") { + $(this.noticeContainer).prepend(obj.container); + } else if (append == "append") { + $(this.noticeContainer).append(obj.container); + } + $(obj.container).toast("show"); + } + }; + + hideOneNotice = function (obj = null) { + if (obj) { + let toast = ""; + if (obj.is("div.toast")) { + toast = obj; + } else { + toast = obj.container; + } + + $(toast).toast("dispose"); + + setTimeout(() => { + $(toast).remove(); + + let tarNoticeId = $(toast)[0]._ytNotice.id; + let tarNoticeIdx = this.noticeArr.findIndex( + (x) => x.obj.id == tarNoticeId + ); + if (tarNoticeIdx != -1) { + this.noticeArr[tarNoticeIdx].canShow = false; } - this.updEleObj(); + this.showNotices(); + }, 100); + } + this.updEleObj(); + }; + + checkCanShow = function (notice = null) { + let lastNoticeOffset = $(this.noticeContainer) + .find(".toast") + .last() + .offset(); + if ($(this.noticeContainer).find(".toast").last().length == 0) { + return notice.canShow; } - drawInitScroll = function () { - if (this.scrollY) { - $(this.eScroll).css("height", "100%"); - $(this.eScroll).css("overflow-y", "auto"); - $(this.element).append(this.eScroll); + if ($(notice.obj.container).is(":visible")) { + return false; + } + + if (!notice.canShow) { + return false; + } + + if (lastNoticeOffset.top + this.offsetBottom > $(window).height()) { + return false; + } else { + return true; + } + }; + + showNotices = function () { + if (this.noticeArr.length === 0) { + $(this.noticeContainer).empty(); + } else { + $.each(this.noticeArr, (idx, notice) => { + if (this.checkCanShow(notice)) { + this.showOneNotice(notice.obj, "append"); } + }); } + }; - drawElement = function () { - $(this.element).addClass("yt-notice-block"); + pushNotice = function (option = {}) { + if (this.noticeArr.findIndex((x) => x.obj.id == option.id) == -1) { + let notice = new YTNotice(option); + this.noticeArr.push({ + obj: notice, + time: new Date().getTime(), + canShow: true, + }); + this.setEvent(notice); } + this.updEleObj(); + }; - showOneNotice = function (obj = null,append = "prepend") { - if (obj) { - if (append == "prepend") { - $(this.noticeContainer).prepend(obj.container); - } else if (append == "append") { - $(this.noticeContainer).append(obj.container); - } - $(obj.container).toast("show"); + updEleObj = function () { + $(this.element)[0]._noticeBlock = this; + }; + + setEvent = function (notice) { + let _this = this; + $(notice.container).on("hidden.bs.toast", function () { + setTimeout(() => { + $(notice.container).remove(); + + let tarNoticeId = $(notice.container)[0]._ytNotice.id; + let tarNoticeIdx = _this.noticeArr.findIndex( + (x) => x.obj.id == tarNoticeId + ); + if (tarNoticeIdx != -1) { + _this.noticeArr[tarNoticeIdx].canShow = false; } - } - - hideOneNotice = function (obj = null) { - if (obj) { - let toast = ""; - if (obj.is("div.toast")) { - toast = obj; - } else { - toast = obj.container; - } - - $(toast).toast('dispose'); - - setTimeout(() => { - $(toast).remove(); - - let tarNoticeId = $(toast)[0]._ytNotice.id - let tarNoticeIdx = this.noticeArr.findIndex(x => x.obj.id == tarNoticeId); - if (tarNoticeIdx != -1) { - this.noticeArr[tarNoticeIdx].canShow = false; - } - - this.showNotices(); - }, 100) - - - } - this.updEleObj(); - } - - checkCanShow = function (notice = null) { - let lastNoticeOffset = $(this.noticeContainer).find(".toast").last().offset(); - if ($(this.noticeContainer).find(".toast").last().length == 0) { - return notice.canShow; - } - - if ($(notice.obj.container).is(":visible")) { - return false; - } - - if (!notice.canShow) { - return false; - } - - if (lastNoticeOffset.top + this.offsetBottom > $(window).height()) { - return false; - } else { - return true; - } - } - - showNotices = function () { - $.each(this.noticeArr, (idx, notice) => { - if (this.checkCanShow(notice)) { - this.showOneNotice(notice.obj,"append"); - } - }) - } - - pushNotice = function (option = {}) { - if (this.noticeArr.findIndex(x => x.obj.id == option.id) == -1) { - let notice = new YTNotice(option); - this.noticeArr.push({ obj: notice, time: (new Date()).getTime(), canShow: true }); - this.setEvent(notice); - } - this.updEleObj(); - } - - updEleObj = function () { - $(this.element)[0]._noticeBlock = this; - } - - setEvent = function (notice) { - let _this = this; - $(notice.container).on("hidden.bs.toast", function () { - setTimeout(() => { - $(notice.container).remove(); - - let tarNoticeId = $(notice.container)[0]._ytNotice.id - let tarNoticeIdx = _this.noticeArr.findIndex(x => x.obj.id == tarNoticeId); - if (tarNoticeIdx != -1) { - _this.noticeArr[tarNoticeIdx].canShow = false; - } - _this.showNotices(); - }, 100) - }) - } - + _this.showNotices(); + }, 100); + }); + }; } $.fn.YTNotice = function (method = "init", ...args) { - let _this = this; + let _this = this; - if (method == "init") { - initNoticeBlock(); + if (method == "init") { + initNoticeBlock(); + } + + let noticeBlock = _this[0]._noticeBlock; + if (!noticeBlock) { + initNoticeBlock(); + noticeBlock = _this[0]._noticeBlock; + } + + if (method == "add") { + noticeBlock.pushNotice(args[0] ?? {}); + noticeBlock.showNotices(); + } else if (method == "add_many") { + noticeBlock.noticeArr = []; + args[0].forEach((arg, idx) => { + noticeBlock.pushNotice(arg); + }); + noticeBlock.showNotices(); + } else if (method == "hide") { + if (args.length == 0) { + noticeBlock = $(_this).parents(".yt-notice-block")[0]._noticeBlock; + noticeBlock.hideOneNotice(this); } + } - let noticeBlock = _this[0]._noticeBlock; - if (!noticeBlock) { - initNoticeBlock(); - noticeBlock = _this[0]._noticeBlock; - } - - if (method == "add") { - - noticeBlock.pushNotice(args[0] ?? {}); - noticeBlock.showNotices(); - - } else if (method == "add_many") { - - args[0].forEach((arg, idx) => { - noticeBlock.pushNotice(arg); - }) - - noticeBlock.showNotices(); - } else if (method == "hide") { - if (args.length == 0) { - noticeBlock = $(_this).parents(".yt-notice-block")[0]._noticeBlock; - noticeBlock.hideOneNotice(this); - } - } - - function initNoticeBlock() { - let option = {}; - option.element = _this; - let noticeBlock = new YTNoticeBlock(option); - } - -} + function initNoticeBlock() { + let option = {}; + option.element = _this; + let noticeBlock = new YTNoticeBlock(option); + } +};