feat: 完成 issue #157 移动端只读驾驶舱补充手动刷新(KPI 时间桶滚动)

This commit is contained in:
2026-08-05 10:50:05 +08:00
parent 3a6ef57592
commit 253ebe7b0b
3 changed files with 21 additions and 10 deletions
+3
View File
@@ -13,7 +13,10 @@
只读展示:工艺四状态 / KPI / 告警;交接班摘要按 handover_brief 章节渲染。 --> 只读展示:工艺四状态 / KPI / 告警;交接班摘要按 handover_brief 章节渲染。 -->
<header id="topbar"> <header id="topbar">
<h1 id="page-title">iAOP 移动驾驶舱</h1> <h1 id="page-title">iAOP 移动驾驶舱</h1>
<div>
<button id="btn-refresh" class="ghost-btn">刷新</button>
<span id="ro-badge">只读</span> <span id="ro-badge">只读</span>
</div>
</header> </header>
<!-- 只读驾驶舱视图 --> <!-- 只读驾驶舱视图 -->
+3 -1
View File
@@ -18,7 +18,9 @@ body { margin: 0; font-family: "PingFang SC", "Microsoft YaHei", sans-serif;
position: sticky; top: 0; z-index: 2; } position: sticky; top: 0; z-index: 2; }
#topbar h1 { font-size: 17px; margin: 0; color: var(--cockpit-accent); } #topbar h1 { font-size: 17px; margin: 0; color: var(--cockpit-accent); }
#ro-badge { font-size: 11px; color: var(--cockpit-warn); border: 1px solid var(--cockpit-warn); #ro-badge { font-size: 11px; color: var(--cockpit-warn); border: 1px solid var(--cockpit-warn);
border-radius: 10px; padding: 2px 8px; } border-radius: 10px; padding: 2px 8px; margin-left: 8px; }
.ghost-btn { background: none; border: 1px solid var(--cockpit-grid-line); border-radius: 8px;
color: var(--cockpit-accent); font-size: 12px; padding: 4px 10px; cursor: pointer; }
.view { display: none; padding: 10px 12px; } .view { display: none; padding: 10px 12px; }
.view.active { display: block; } .view.active { display: block; }
+7 -1
View File
@@ -71,7 +71,8 @@ function renderMobileCockpit(plan) {
kpiBox.innerHTML = ""; kpiBox.innerHTML = "";
plan.widgets.forEach(function (w) { plan.widgets.forEach(function (w) {
if (w.type !== "kpi_card") return; if (w.type !== "kpi_card") return;
var rnd = seededRandom(w.props.metric || ""); // 30s 时间桶入种子:刷新/定时重渲染时数值滚动(接真实总线后替换)
var rnd = seededRandom((w.props.metric || "") + "|" + Math.floor(Date.now() / 30000));
var card = el("div", "kpi"); var card = el("div", "kpi");
card.appendChild(el("div", "v", (60 + rnd() * 40).toFixed(2))); card.appendChild(el("div", "v", (60 + rnd() * 40).toFixed(2)));
card.appendChild(el("div", "l", w.props.label || w.props.metric)); card.appendChild(el("div", "l", w.props.label || w.props.metric));
@@ -231,6 +232,8 @@ function generateBrief() {
fetch(ALARM_PLAN_URL).then(function (r) { return r.ok ? r.json() : null; }) fetch(ALARM_PLAN_URL).then(function (r) { return r.ok ? r.json() : null; })
.then(function (p) { if (p && p.severityStyles) severityStyles = p.severityStyles; }) .then(function (p) { if (p && p.severityStyles) severityStyles = p.severityStyles; })
.catch(function () {}); .catch(function () {});
// issue #157:只读数据手动刷新(重新加载布局资产并重渲染 KPI/告警)
function loadPlan() {
fetch(PLAN_URL).then(function (r) { return r.json(); }) fetch(PLAN_URL).then(function (r) { return r.json(); })
.then(renderMobileCockpit) .then(renderMobileCockpit)
.catch(function (e) { .catch(function (e) {
@@ -238,4 +241,7 @@ function generateBrief() {
document.getElementById("m-stages").appendChild( document.getElementById("m-stages").appendChild(
el("div", "hint", "布局资产加载失败:" + e.message + "(请从 web/ 根目录起服务)")); el("div", "hint", "布局资产加载失败:" + e.message + "(请从 web/ 根目录起服务)"));
}); });
}
document.getElementById("btn-refresh").onclick = loadPlan;
loadPlan();
})(); })();