Files
zhy200308 75a642f4e9 feat(ui): 交付第8个子页面【设备数据库管理】UI重构与全链路功能联动
- 页面交付清单 (已累计完成 8/11 个页面):
  1. 语言设置 (已完工)
  2. 版型切换 (已完工)
  3. 心率区间设置 (已完工)
  4. 自动连接配置 (已完工)
  5. 手环配置 (已完工)
  6. DFU固件升级 (已完工)
  7. 用户管理 (已完工)
  8. 设备数据库管理 (本次交付·已完工)
- 核心重构亮点:
  1. 采纳 Master-Detail Inset Station 经典双栏比例 (360px 1fr);
  2. 全量遵循 #2563EB 核心主色蓝体系与柔和调和语义色规范;
  3. 严格对齐原版文字:【📡 设备数据库 (统一充电与状态管理)】、【默认同步天数】与【批量解绑全部】;
  4. 完备支持任意手环设备单选/多选/全选联动,动态响应同步台数;
  5. 支持自由配置 1天/3天/7天/14天/30天 同步时间范围;
  6. 集齐 6 件套交付物 (baseline_ui.html, image.png, DESIGN_SPEC.md, implementation_plan.md, CARD 任务卡, README 更新)。
2026-08-17 18:33:28 +08:00

455 lines
20 KiB
HTML

<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>设备数据库管理 - Master-Detail Inset Station (360px 1fr)</title>
<style>
/* =========================================================================
全局统一色彩体系与 Design Tokens (严格遵循 #2563EB 规范)
========================================================================= */
:root {
--color-primary: #2563EB;
--color-primary-dark: #1D4ED8;
--color-on-primary-container: #1E40AF;
--color-primary-light: #EFF6FF;
--color-primary-container: #EFF6FF;
--color-primary-border: #DBEAFE;
--color-primary-glow: rgba(37, 99, 235, 0.22);
--color-primary-gradient: linear-gradient(135deg, #2563EB 0%, #1D4ED8 100%);
--bg: #EEF2F6;
--surface: #FFFFFF;
--surface-sub: #F8FAFC;
--text-main: #0F172A;
--text-sub: #64748B;
--text-dim: #94A3B8;
--divider: #E2E8F0;
--border-card: #E2E8F0;
--color-warning: #D97706;
--color-warning-bg: #FFFBEB;
--color-warning-border: #FDE68A;
--color-success: #059669;
--color-success-bg: #ECFDF5;
--color-success-border: #A7F3D0;
--color-danger: #E11D48;
--color-danger-bg: #FFF1F2;
--color-danger-border: #FFE4E6;
--corner-card: 16px;
--corner-item: 10px;
--content-max-width: 1160px;
--content-gutter: clamp(16px, 2.5vw, 32px);
--appbar-height: 60px;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body {
font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "PingFang SC", "Segoe UI", Roboto, sans-serif;
background: var(--bg); color: var(--text-main); min-height: 100vh;
padding: var(--content-gutter); display: flex; flex-direction: column; -webkit-font-smoothing: antialiased;
}
.device-wrapper {
width: 100%; max-width: var(--content-max-width); margin: 0 auto; background: var(--surface);
border-radius: 20px; border: 1px solid var(--divider); box-shadow: 0 16px 40px -10px rgba(15, 23, 42, 0.08);
overflow: hidden; position: relative; min-height: 660px; display: flex; flex-direction: column;
}
/* 1. AppBar */
.appbar {
height: var(--appbar-height); display: flex; align-items: center; justify-content: space-between;
padding: 0 20px; border-bottom: 1px solid var(--divider); background: var(--surface); flex-shrink: 0;
}
.appbar-left { display: flex; align-items: center; }
.appbar-nav, .appbar-more {
width: 40px; height: 40px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center;
cursor: pointer; background: transparent; border: none; transition: all 0.15s ease;
}
.appbar-nav:hover, .appbar-more:hover { background: rgba(15, 23, 42, 0.06); transform: scale(0.96); }
.appbar-nav svg, .appbar-more svg { width: 22px; height: 22px; fill: var(--text-main); }
.appbar-title { font-size: 19px; font-weight: 700; margin-left: 10px; }
/* 2. 经典 360px 1fr 双栏布局 */
.station-split-body {
padding: clamp(20px, 2.5vw, 30px); background: #F8FAFC; flex: 1; overflow-y: auto;
display: grid; grid-template-columns: 360px 1fr; gap: 20px; max-height: calc(100vh - 120px);
}
/* 左侧 360px 充电机柜控制面板 */
.station-side-panel {
background: white; border: 1.5px solid var(--divider); border-radius: 16px; padding: 22px;
display: flex; flex-direction: column; justify-content: space-between; gap: 18px;
box-shadow: 0 4px 14px rgba(15, 23, 42, 0.03);
}
.panel-header-title { font-size: 17.5px; font-weight: 700; color: var(--color-primary); display: flex; align-items: center; gap: 8px; }
.panel-header-desc { font-size: 12.5px; color: var(--text-sub); margin-top: 4px; }
.stat-metric-card {
background: #F8FAFC; border: 1px solid var(--divider); border-radius: 10px; padding: 12px 14px;
display: flex; justify-content: space-between; align-items: center;
}
.stat-label { font-size: 13px; font-weight: 600; color: var(--text-sub); }
.stat-val { font-size: 16px; font-weight: 700; font-family: ui-monospace, monospace; color: var(--color-primary); }
.control-field-block { display: flex; flex-direction: column; gap: 8px; }
.field-caption { font-size: 13px; font-weight: 700; color: var(--text-main); }
.time-select-control {
width: 100%; height: 40px; background: white; border: 1.5px solid #CBD5E1; border-radius: 8px;
padding: 0 12px; font-size: 13.5px; font-weight: 700; color: var(--text-main); outline: none; cursor: pointer;
transition: all 0.15s ease;
}
.time-select-control:focus { border-color: var(--color-primary); box-shadow: 0 0 0 3px var(--color-primary-light); }
/* 左侧贯穿式操作按钮 */
.side-actions-group { display: flex; flex-direction: column; gap: 10px; }
.btn-dynamic-full {
width: 100%; height: 44px; border-radius: 10px; font-size: 14px; font-weight: 700; cursor: pointer;
display: flex; align-items: center; justify-content: center; gap: 8px; transition: all 0.15s ease;
border: 1.5px solid transparent;
}
.btn-primary-full {
background: var(--color-primary-gradient); color: white;
box-shadow: 0 4px 12px var(--color-primary-glow);
}
.btn-primary-full:hover { transform: translateY(-1px); box-shadow: 0 6px 16px var(--color-primary-glow); }
.btn-primary-full:disabled { background: #CBD5E1; cursor: not-allowed; box-shadow: none; }
.btn-danger-full {
background: var(--color-danger-bg); color: var(--color-danger); border-color: var(--color-danger-border);
}
.btn-danger-full:hover { background: #FFE4E6; border-color: var(--color-danger); }
/* 右侧 1fr 设备卡片矩阵 */
.devices-main-panel {
background: white; border: 1.5px solid var(--divider); border-radius: 16px; padding: 20px;
display: flex; flex-direction: column; gap: 12px; overflow-y: auto;
box-shadow: 0 4px 14px rgba(15, 23, 42, 0.03);
}
.device-header-row {
display: flex; justify-content: space-between; align-items: center; padding-bottom: 10px;
border-bottom: 1px solid var(--divider);
}
.header-title-text { font-size: 14.5px; font-weight: 700; color: var(--text-main); }
.header-tools-group { display: flex; align-items: center; gap: 10px; }
.btn-tool-action {
background: transparent; border: none; font-size: 13.5px; font-weight: 700;
color: var(--color-primary); cursor: pointer; padding: 4px 8px; border-radius: 6px;
}
.btn-tool-action:hover { background: var(--color-primary-light); }
.btn-tool-action.dim { color: var(--text-sub); }
.btn-tool-action.dim:hover { background: #F1F5F9; color: var(--text-main); }
/* 单条设备卡片 */
.dev-inset-row {
border: 1.5px solid var(--divider); border-radius: 12px; padding: 14px 18px;
display: flex; align-items: center; justify-content: space-between; gap: 16px;
transition: all 0.15s ease; cursor: pointer; user-select: none;
}
.dev-inset-row:hover { border-color: var(--color-primary); background: #F8FAFC; }
.dev-inset-row.selected { border-color: var(--color-primary); background: var(--color-primary-light); }
.dev-row-left { display: flex; align-items: center; gap: 14px; }
.dev-chk { width: 18px; height: 18px; accent-color: var(--color-primary); cursor: pointer; }
.dev-title-code { font-size: 15px; font-weight: 700; font-family: ui-monospace, monospace; color: var(--text-main); }
.dev-meta-sub { font-size: 12.5px; color: var(--text-sub); margin-top: 3px; display: flex; gap: 12px; flex-wrap: wrap; }
.dev-meta-sub span b { color: var(--text-main); font-weight: 600; font-family: ui-monospace, monospace; }
.dev-row-right { display: flex; align-items: center; gap: 10px; }
.badge-unbound {
background: var(--color-warning-bg); color: var(--color-warning); border: 1px solid var(--color-warning-border);
padding: 4px 10px; border-radius: 6px; font-size: 12px; font-weight: 700;
}
/* 空状态容器 */
.empty-station-container {
display: none; flex-direction: column; align-items: center; justify-content: center;
gap: 16px; padding: 60px 20px; flex: 1;
}
.empty-icon-box {
width: 72px; height: 72px; border-radius: 18px; background: #F1F5F9; border: 1.5px solid var(--divider);
display: flex; align-items: center; justify-content: center;
}
.empty-icon-box svg { width: 36px; height: 36px; fill: var(--text-sub); }
.empty-msg-text { font-size: 15px; font-weight: 700; color: var(--text-sub); }
</style>
</head>
<body>
<div class="device-wrapper">
<header class="appbar">
<div class="appbar-left">
<button class="appbar-nav" title="返回"><svg viewBox="0 0 24 24"><path d="M20 11H7.83l5.59-5.59L12 4l-8 8 8 8 1.41-1.41L7.83 13H20v-2z"/></svg></button>
<h1 class="appbar-title">设备数据库管理</h1>
</div>
<button class="appbar-more"><svg viewBox="0 0 24 24"><path d="M12 8c1.1 0 2-.9 2-2s-.9-2-2-2-2 .9-2 2 .9 2 2 2zm0 2c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2zm0 6c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2z"/></svg></button>
</header>
<main class="station-split-body">
<!-- 左侧 360px 充电机柜控制中心 -->
<div class="station-side-panel">
<div style="display: flex; flex-direction: column; gap: 14px;">
<div>
<h2 class="panel-header-title">📡 设备数据库</h2>
<p class="panel-header-desc">统一充电与状态管理</p>
</div>
<div class="stat-metric-card">
<span class="stat-label">已登记手环总数</span>
<span class="stat-val" id="totalDevCountText">7 台</span>
</div>
<div class="stat-metric-card">
<span class="stat-label">未绑定待分配</span>
<span class="stat-val" style="color: var(--color-warning);" id="unboundCountText">7 台</span>
</div>
<div class="control-field-block">
<div class="field-caption">默认同步天数</div>
<select class="time-select-control" id="syncTimeSelect" onchange="handleTimeChange(this.value)">
<option value="1">1 天 (今日)</option>
<option value="3">3 天</option>
<option value="7" selected>7 天</option>
<option value="14">14 天</option>
<option value="30">30 天</option>
</select>
</div>
</div>
<div class="side-actions-group">
<button class="btn-dynamic-full btn-primary-full" id="btnBatchSync" onclick="startBatchSync()">
<svg style="width: 16px; height: 16px; fill: currentColor;" viewBox="0 0 24 24"><path d="M12 4V1L8 5l4 4V6c3.31 0 6 2.69 6 6 0 1.01-.25 1.97-.7 2.8l1.46 1.46C19.54 15.03 20 13.57 20 12c0-4.42-3.58-8-8-8zm0 14c-3.31 0-6-2.69-6-6 0-1.01.25-1.97.7-2.8L5.24 7.74C4.46 8.97 4 10.43 4 12c0 4.42 3.58 8 8 8v3l4-4-4-4v3z"/></svg>
<span id="btnBatchSyncText">批量同步 (已选 2 台)</span>
</button>
<button class="btn-dynamic-full btn-danger-full" onclick="triggerUnbindAll()">
<svg style="width: 16px; height: 16px; fill: currentColor;" viewBox="0 0 24 24"><path d="M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z"/></svg>
<span>批量解绑全部</span>
</button>
</div>
</div>
<!-- 右侧 1fr 设备勾选与详情矩阵 -->
<div class="devices-main-panel" id="devicesMainPanel">
<div class="device-header-row">
<span class="header-title-text">设备列表</span>
<div class="header-tools-group">
<button class="btn-tool-action" onclick="toggleSelectAll(true)">全选</button>
<button class="btn-tool-action dim" onclick="toggleSelectAll(false)">清除</button>
</div>
</div>
<div id="deviceListContainer" style="display: flex; flex-direction: column; gap: 10px;">
<!-- 1. 33X_BLE_62200024 -->
<div class="dev-inset-row selected" onclick="toggleDeviceRow(this)">
<div class="dev-row-left">
<input type="checkbox" class="dev-chk" checked onclick="event.stopPropagation(); updateSelectionSummary();">
<div>
<div class="dev-title-code">33X_BLE_62200024</div>
<div class="dev-meta-sub">
<span>电量: <b>未知</b></span>
<span>固件: <b>未知</b></span>
<span>最后同步: <b>2026-08-12 14:32:25</b></span>
</div>
</div>
</div>
<div class="dev-row-right">
<span class="badge-unbound">未绑定</span>
</div>
</div>
<!-- 2. 33X_BLE_2200002 -->
<div class="dev-inset-row selected" onclick="toggleDeviceRow(this)">
<div class="dev-row-left">
<input type="checkbox" class="dev-chk" checked onclick="event.stopPropagation(); updateSelectionSummary();">
<div>
<div class="dev-title-code">33X_BLE_2200002</div>
<div class="dev-meta-sub">
<span>电量: <b>未知</b></span>
<span>固件: <b>未知</b></span>
<span>最后同步: <b>2026-08-12 14:32:25</b></span>
</div>
</div>
</div>
<div class="dev-row-right">
<span class="badge-unbound">未绑定</span>
</div>
</div>
<!-- 3. 33X_BLE_62200025 -->
<div class="dev-inset-row" onclick="toggleDeviceRow(this)">
<div class="dev-row-left">
<input type="checkbox" class="dev-chk" onclick="event.stopPropagation(); updateSelectionSummary();">
<div>
<div class="dev-title-code">33X_BLE_62200025</div>
<div class="dev-meta-sub">
<span>电量: <b>未知</b></span>
<span>固件: <b>未知</b></span>
<span>最后同步: <b>2026-08-12 14:32:25</b></span>
</div>
</div>
</div>
<div class="dev-row-right">
<span class="badge-unbound">未绑定</span>
</div>
</div>
<!-- 4. 33X_BLE_22000005 -->
<div class="dev-inset-row" onclick="toggleDeviceRow(this)">
<div class="dev-row-left">
<input type="checkbox" class="dev-chk" onclick="event.stopPropagation(); updateSelectionSummary();">
<div>
<div class="dev-title-code">33X_BLE_22000005</div>
<div class="dev-meta-sub">
<span>电量: <b>未知</b></span>
<span>固件: <b>未知</b></span>
<span>最后同步: <b>2026-08-12 14:32:25</b></span>
</div>
</div>
</div>
<div class="dev-row-right">
<span class="badge-unbound">未绑定</span>
</div>
</div>
<!-- 5. 33X_BLE_62200014 -->
<div class="dev-inset-row" onclick="toggleDeviceRow(this)">
<div class="dev-row-left">
<input type="checkbox" class="dev-chk" onclick="event.stopPropagation(); updateSelectionSummary();">
<div>
<div class="dev-title-code">33X_BLE_62200014</div>
<div class="dev-meta-sub">
<span>电量: <b>未知</b></span>
<span>固件: <b>未知</b></span>
<span>最后同步: <b>2026-08-12 14:32:25</b></span>
</div>
</div>
</div>
<div class="dev-row-right">
<span class="badge-unbound">未绑定</span>
</div>
</div>
<!-- 6. 33X_BLE_22000024 -->
<div class="dev-inset-row" onclick="toggleDeviceRow(this)">
<div class="dev-row-left">
<input type="checkbox" class="dev-chk" onclick="event.stopPropagation(); updateSelectionSummary();">
<div>
<div class="dev-title-code">33X_BLE_22000024</div>
<div class="dev-meta-sub">
<span>电量: <b>未知</b></span>
<span>固件: <b>未知</b></span>
<span>最后同步: <b>2026-08-12 14:32:25</b></span>
</div>
</div>
</div>
<div class="dev-row-right">
<span class="badge-unbound">未绑定</span>
</div>
</div>
<!-- 7. 33X_BLE_22000009 -->
<div class="dev-inset-row" onclick="toggleDeviceRow(this)">
<div class="dev-row-left">
<input type="checkbox" class="dev-chk" onclick="event.stopPropagation(); updateSelectionSummary();">
<div>
<div class="dev-title-code">33X_BLE_22000009</div>
<div class="dev-meta-sub">
<span>电量: <b>未知</b></span>
<span>固件: <b>未知</b></span>
<span>最后同步: <b>2026-08-12 14:32:25</b></span>
</div>
</div>
</div>
<div class="dev-row-right">
<span class="badge-unbound">未绑定</span>
</div>
</div>
</div>
<!-- 空状态提示 (当解绑清空后展示) -->
<div class="empty-station-container" id="emptyStationContainer">
<div class="empty-icon-box">
<svg viewBox="0 0 24 24"><path d="M14 2H6c-1.1 0-1.99.9-1.99 2L4 20c0 1.1.89 2 1.99 2H18c1.1 0 2-.9 2-2V8l-6-6zm2 16H8v-2h8v2zm0-4H8v-2h8v2zm-3-5V3.5L18.5 9H13z"/></svg>
</div>
<div class="empty-msg-text">没有发现已注册的设备</div>
<button class="btn-dynamic-full btn-primary-full" style="width: auto; padding: 0 24px;" onclick="restoreDevicesList()">+ 重新扫描/注册设备</button>
</div>
</div>
</main>
</div>
<script>
function toggleDeviceRow(row) {
const chk = row.querySelector('.dev-chk');
chk.checked = !chk.checked;
if (chk.checked) row.classList.add('selected');
else row.classList.remove('selected');
updateSelectionSummary();
}
function toggleSelectAll(select) {
document.querySelectorAll('.dev-inset-row').forEach(row => {
const chk = row.querySelector('.dev-chk');
chk.checked = select;
if (select) row.classList.add('selected');
else row.classList.remove('selected');
});
updateSelectionSummary();
}
function updateSelectionSummary() {
const checkedBoxes = document.querySelectorAll('.dev-chk:checked');
const count = checkedBoxes.length;
const btn = document.getElementById('btnBatchSync');
const text = document.getElementById('btnBatchSyncText');
if (count === 0) {
btn.disabled = true;
text.innerText = '请勾选要同步的手环';
} else {
btn.disabled = false;
text.innerText = `开始同步已选手环 (${count} 台)`;
}
}
function handleTimeChange(val) {
// 动态响应时间配置
console.log(`同步时间范围更新为: ${val} 天`);
}
function startBatchSync() {
const count = document.querySelectorAll('.dev-chk:checked').length;
const days = document.getElementById('syncTimeSelect').value;
const text = document.getElementById('btnBatchSyncText');
text.innerText = `正在回传 ${count} 台手环 (${days}天数据)...`;
setTimeout(() => {
alert(`已成功同步 ${count} 台手环过去 ${days} 天的历史健康数据!`);
text.innerText = `开始同步已选手环 (${count} 台)`;
}, 1200);
}
function triggerUnbindAll() {
if (confirm('确认要解绑全部已登记设备吗?解绑后设备数据库将被清空。')) {
document.getElementById('deviceListContainer').style.display = 'none';
document.getElementById('emptyStationContainer').style.display = 'flex';
document.getElementById('totalDevCountText').innerText = '0 台';
document.getElementById('unboundCountText').innerText = '0 台';
updateSelectionSummary();
}
}
function restoreDevicesList() {
document.getElementById('deviceListContainer').style.display = 'flex';
document.getElementById('emptyStationContainer').style.display = 'none';
document.getElementById('totalDevCountText').innerText = '7 台';
document.getElementById('unboundCountText').innerText = '7 台';
toggleSelectAll(true);
}
</script>
</body>
</html>