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 = `