[Frontend] 告警程序調整

This commit is contained in:
dev01 2023-01-13 18:45:39 +08:00
parent 17ac7ab333
commit f5d984a115
2 changed files with 27 additions and 8 deletions

View File

@ -1009,17 +1009,18 @@ License: You must have a valid license purchased only from wrapbootstrap.com (li
}) })
onEvent("click", "button[id^=noticeChkBtn]", function () { //onEvent("click", "button[id^=noticeChkBtn]", function () {
$(this).parents(".toast").YTNotice("hide"); // $(this).parents(".toast").YTNotice("hide");
}) //})
onEvent("click", "button[id^=bajaAckBtn]", function () { onEvent("click", "button[id^=noticeChkBtn]", function () { /**button[id^=bajaAckBtn] */
let uuid = $(this).data("uuid"); let uuid = $(this).data("uuid");
let url = window.location.origin + "/obix/alarm/" + uuid + "/ack"; let url = window.location.origin + "/obix/alarm/" + uuid + "/ack";
let myBaja = new MyBaja(); let myBaja = new MyBaja();
myBaja.setMyUserAccount((data) => { myBaja.setMyUserAccount((data) => {
let sendData = '<obj is="obix:AckAlarmIn"><str name="' + data + '" val="obix" /></obj>'; let sendData = '<obj is="obix:AckAlarmIn"><str name="' + data + '" val="obix" /></obj>';
$.post(url, sendData, (rel) => { $.post(url, sendData, (rel) => {
console.log(rel)
$(this).parents(".toast").YTNotice("hide"); $(this).parents(".toast").YTNotice("hide");
}, "text") }, "text")
}) })
@ -1659,6 +1660,7 @@ License: You must have a valid license purchased only from wrapbootstrap.com (li
let notices = []; let notices = [];
$.each(datas, (idx, data) => { $.each(datas, (idx, data) => {
if (noticeOptArr.findIndex(x => x.id == data.id) == -1) { if (noticeOptArr.findIndex(x => x.id == data.id) == -1) {
/*<button id="bajaAckBtn${data.id}" data-uuid="${data.uuid}" class="btn btn-sm btn-primary col-8 text-nowrap">已至現場確認問題</button> */
let content = `<div class="col-12"> let content = `<div class="col-12">
<div class="row m-0"> <div class="row m-0">
<span class="m-0">異常編號:<span>${data.id}</span></span> <span class="m-0">異常編號:<span>${data.id}</span></span>
@ -1676,8 +1678,7 @@ License: You must have a valid license purchased only from wrapbootstrap.com (li
<span class="m-0">異常訊息:<span>${data.errMsg}</span></span> <span class="m-0">異常訊息:<span>${data.errMsg}</span></span>
</div> </div>
<div class="d-flex m-0 gap-5 mt-2"> <div class="d-flex m-0 gap-5 mt-2">
<button id="bajaAckBtn${data.id}" data-uuid="${data.uuid}" class="btn btn-sm btn-primary col-8 text-nowrap">已至現場確認問題</button> <button id="noticeChkBtn${data.id}" class="btn btn-sm btn-secondary ml-auto col-4">確認</button>
<button id="noticeChkBtn${data.id}" class="btn btn-sm btn-secondary col-4">確認</button>
</div> </div>
</div>` </div>`
let main = { let main = {
@ -1685,7 +1686,7 @@ License: You must have a valid license purchased only from wrapbootstrap.com (li
content: content, content: content,
type: "warning", type: "warning",
id: data.id, id: data.id,
hasCloseBtn: false, hasCloseBtn: true,
timeText: displayDate(data.timestamp), timeText: displayDate(data.timestamp),
} }
noticeOptArr.push(main); noticeOptArr.push(main);

View File

@ -173,7 +173,7 @@ class YTNoticeBlock {
setTimeout(() => { setTimeout(() => {
$(toast).remove(); $(toast).remove();
let tarNoticeId = $(obj)[0]._ytNotice.id let tarNoticeId = $(toast)[0]._ytNotice.id
let tarNoticeIdx = this.noticeArr.findIndex(x => x.obj.id == tarNoticeId); let tarNoticeIdx = this.noticeArr.findIndex(x => x.obj.id == tarNoticeId);
if (tarNoticeIdx != -1) { if (tarNoticeIdx != -1) {
this.noticeArr[tarNoticeIdx].canShow = false; this.noticeArr[tarNoticeIdx].canShow = false;
@ -220,6 +220,7 @@ class YTNoticeBlock {
if (this.noticeArr.findIndex(x => x.obj.id == option.id) == -1) { if (this.noticeArr.findIndex(x => x.obj.id == option.id) == -1) {
let notice = new YTNotice(option); let notice = new YTNotice(option);
this.noticeArr.push({ obj: notice, time: (new Date()).getTime(), canShow: true }); this.noticeArr.push({ obj: notice, time: (new Date()).getTime(), canShow: true });
this.setEvent(notice);
} }
this.updEleObj(); this.updEleObj();
} }
@ -227,6 +228,23 @@ class YTNoticeBlock {
updEleObj = function () { updEleObj = function () {
$(this.element)[0]._noticeBlock = this; $(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)
})
}
} }
$.fn.YTNotice = function (method = "init", ...args) { $.fn.YTNotice = function (method = "init", ...args) {