From 8d1875caff3fecef8a3b43db645c7993d7d42c79 Mon Sep 17 00:00:00 2001 From: QiuSW <105186638@qq.com> Date: Wed, 12 Aug 2026 15:15:07 +0800 Subject: [PATCH] refactor: use conventional Bell alert modules (#33) --- prototypes/bell/bell.js | 56 ++++++++++---------- prototypes/bell/index.html | 106 ++++++++++++------------------------- 2 files changed, 60 insertions(+), 102 deletions(-) diff --git a/prototypes/bell/bell.js b/prototypes/bell/bell.js index 7c6a09d..131256e 100644 --- a/prototypes/bell/bell.js +++ b/prototypes/bell/bell.js @@ -27,25 +27,30 @@ })); let started = false; - const startButton = qs("[data-action='start-alert']"); - startButton?.addEventListener("click", () => { - if (started) return; + const startButtons = qsa("[data-action='start-alert'], [data-action='table-start-alert']"); + const startAlert = () => { + if (started) { + toast("该预警已由王值班员开始处理"); + return; + } started = true; - startButton.disabled = true; - startButton.textContent = "已由你开始处理"; - const state = qs("[data-alert-state]"); - state.textContent = "处理中"; - state.className = "status status-warning el-tag"; + startButtons.forEach((button) => { + button.disabled = true; + button.textContent = "已确认"; + }); + const dashboardState = qs("[data-alert-state]"); + dashboardState.textContent = "处理中"; + dashboardState.className = "status status-warning el-tag"; + const tableState = qs("[data-table-alert-state]"); + tableState.textContent = "处理中"; + tableState.className = "status status-warning el-tag"; + qs("[data-table-owner]").textContent = "王值班员"; + qs("[data-finish-from-table]").disabled = false; qs("[data-pending-count]").textContent = String(Math.max(0, number("[data-pending-count]") - 1)); qs("[data-working-count]").textContent = String(number("[data-working-count]") + 1); - qs("[data-owned-alert]").hidden = false; - qs("[data-working-total]").textContent = "3 条"; - toast("已开始处理;其他人会看到这条预警由王老师负责"); - }); - - qs("[data-simulate-conflict]")?.addEventListener("click", () => { - toast("这条预警已由李老师开始处理,你可以查看进展但不能重复领取"); - }); + toast("预警已确认并由王值班员开始处理"); + }; + startButtons.forEach((button) => button.addEventListener("click", startAlert)); qsa("input[name='result']").forEach((input) => input.addEventListener("change", () => { qs("[data-result-error]").hidden = true; @@ -59,20 +64,13 @@ qs("input[name='result']")?.focus(); return; } - const note = qs("#result-note").value.trim(); - const tbody = qs("[data-history-body]"); - const row = document.createElement("tr"); - const statusClass = selected.value === "确认有危险" ? "status-danger" : selected.value === "现场正常" ? "status-success" : "status-neutral"; - row.innerHTML = `危险区域有人进入北围墙 01王老师刚刚`; - qs(".table-subtitle", row).textContent = note || "未填写补充说明"; - qs(".status", row).textContent = selected.value; - qs("button", row).addEventListener("click", () => toast("已打开完整处理记录")); - tbody.prepend(row); - qs("[data-owned-alert]").hidden = true; - qs("[data-working-total]").textContent = "2 条"; - qs("[data-working-count]").textContent = String(Math.max(0, number("[data-working-count]") - 1)); + const tableState = qs("[data-table-alert-state]"); + tableState.textContent = "已关闭"; + tableState.className = "status status-success el-tag"; + qs("[data-finish-from-table]").disabled = true; qs("[data-completed-count]").textContent = String(number("[data-completed-count]") + 1); + qs("[data-working-count]").textContent = String(Math.max(0, number("[data-working-count]") - 1)); qs("[data-close-modal]", qs("#finish-alert"))?.click(); - toast(`处理已完成,现场结果:${selected.value}`); + toast(`预警已关闭,处理结果:${selected.value}`); }); })(); diff --git a/prototypes/bell/index.html b/prototypes/bell/index.html index dbbae21..77726a1 100644 --- a/prototypes/bell/index.html +++ b/prototypes/bell/index.html @@ -3,8 +3,8 @@ - - YoVision Bell · 预警处理 + + YoVision Bell · 预警管理后台 @@ -13,9 +13,10 @@
- - + +
-
- -
-
待处理
3
1 条高风险
-
由我处理
0
完成前会保留在处理中
-
今日已完成
18
平均用时约 4 分钟
-
+
+ +
待确认预警
3
1 条高风险
处理中
2
均已明确处理人
今日已关闭
18
平均用时约 4 分钟
今日事件
29
已生成 23 条预警
-

需要关注的情况

选择一条查看地点、风险和建议

3 条
- - - -
-

危险区域有人进入

北围墙 01 · 今天 10:24

高风险
-
发生了什么危险区域有人进入
发生地点北围墙 01
建议怎么做先查看现场;如无法确认,请联系校内保安巡查。
- -
-

准备处理这条预警时,请点击下面的按钮。此操作只表示“你已看到并开始处理”,不代表现场情况已确认。

-
管理员技术详情
预警编号BEL-A-20260812-0031
原始事实2 条不可变事件
匹配规则校园高危区域 · v4
后台状态映射Alert new → ack → close
来源标识producer-lab / evt-000042
-
+

最新预警

按风险和时间排序

+

危险区域有人进入

北围墙 01 · 今天 10:24

高风险
预警内容危险区域有人进入
发生地点北围墙 01
处理建议先查看现场;如无法确认,请联系校内保安巡查。
技术详情
预警编号BEL-A-20260812-0031
关联事件2 条不可变事件
规则版本校园高危区域 · v4
状态映射Alert new → ack → close
-
- +