feat(ui): 完成 [用户管理] (含添加用户/用户表管理) UI重构与全套6件交付物

- 统一采用 Fluid Studio 现代健康工作台设计体系与 #2563EB 核心品牌蓝标准
- 实现主界面、添加/编辑用户表单、用户表管理三视图无缝 SPA 状态机闭环
- 支持真实头像流展示与优质默认 SVG 头像回退
- 精确隔离添加用户(清空)与编辑用户(回填)状态逻辑
- 产出 baseline_ui.html, image.png, DESIGN_SPEC.md, implementation_plan.md, CARD-20260817-UITask-用户管理.md
- 更新 README.md 页面完工状态 (第 7 页已完工)
This commit is contained in:
zhy200308
2026-08-17 18:04:39 +08:00
parent 3d7be0e326
commit 96c82ad25d
29 changed files with 2620 additions and 1 deletions
@@ -0,0 +1,12 @@
# 任务卡片:用户管理(含添加用户/用户表管理)重构
- **任务编号**:CARD-20260817-UITask-用户管理
- **所属模块**:设置页面 UI 优化 / 用户管理
- **执行状态**:已完成 (COMPLETED)
- **选定方案**:方案 1(Fluid Studio 现代健康工作台)
- **核心优化点**:
1. 统一全局 `#2563EB` 皇家蓝与调和语义色体系,彻底移除突兀杂绿/杂红;
2. 三区精准流式卡片(头像名片区、生理心率指标区、状态开关与操作区);
3. 彻底隔离添加用户(清空表单)与编辑用户(回填档案)的状态机逻辑;
4. 支持头像上传交互预览与优质默认 SVG 头像优雅回退;
5. 完整实现用户管理主界面、添加/编辑用户表单、用户表管理三屏联动一体化工作流。
@@ -0,0 +1,40 @@
# 用户管理(包含添加/编辑用户与用户表管理)UI 设计规范
## 1. 业务全景与多视图架构
用户管理模块采用 **Fluid Studio 现代健康工作台** 架构,将以下 3 个业务核心视图组织为高内聚的单页应用(SPA)状态机:
1. **用户管理主界面 (`viewMain`)**:
- 顶部控制栏:用户表 Dropdown 切换器(默认 `UserDatabase_CHINA`)、主色渐变 `+ 添加` 按钮、幽灵边框 `导入` 与 `编辑` 按钮;
- 学员卡片流:三区流式卡片(左侧头像与基础名片、中间静息与最大心率生理胶囊、右侧统一 `#2563EB` 状态开关、独立编辑与删除操作)。
2. **添加 / 编辑用户独立表单 (`viewUserForm`)**:
- 支持通过顶部【添加】清空进入(新建空表单),或通过卡片【✏️ 编辑】精确回填对应学员档案数据进入;
- 包含大尺寸圆形头像上传/预览区、学号、用户名、性别下拉、出生日期选择器、身高/体重双列输入、静息/最大心率双列输入(支持基于年龄自动计算最大心率)、全宽主色保存按钮。
3. **用户表管理子视图 (`viewDbManage`)**:
- 顶部提供拖拽调序提示横幅与全量导出按钮;
- 用户表列表项支持拖拽手柄、重命名与删除。
---
## 2. 全局 Design Tokens 标准定义
严格对齐项目主色调 `#2563EB` 与调和语义色规范:
| Token | 值 | 语义说明 |
| :--- | :--- | :--- |
| `--color-primary` | `#2563EB` | 全局核心品牌蓝 |
| `--color-primary-dark` | `#1D4ED8` | 悬浮/深色按下态 |
| `--color-primary-light` | `#EFF6FF` | 主色浅底容器 |
| `--color-primary-border` | `#DBEAFE` | 主色高亮边框 |
| `--color-primary-gradient` | `linear-gradient(135deg, #2563EB 0%, #1D4ED8 100%)` | 主操作按钮渐变 |
| `--color-success` | `#059669` | 调和成功绿 |
| `--color-danger` | `#E11D48` | 调和告警红 |
| `--color-danger-bg` | `#FFF1F2` | 告警浅色背景 |
| `--color-danger-border` | `#FFE4E6` | 告警浅色边框 |
| `--divider` | `#E2E8F0` | 标准分割线 |
---
## 3. 槽位与交互清单
- **AppBar**:`40dp` 圆形触控槽,点击返回;
- **用户表切换**:药丸胶囊下拉框,悬浮主色光晕;
- **头像系统**:支持本地选择图片即时预览,未上传时展示高质感 SVG 默认头像;
- **生理心率**:静息心率与最大心率双胶囊展示,编辑时支持根据出生年份自动推算 `220 - 年龄`;
- **数据状态机隔离**:添加学员与编辑学员表单严格隔离,避免脏数据污染。
Binary file not shown.

Before

Width:  |  Height:  |  Size: 199 KiB

After

Width:  |  Height:  |  Size: 410 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 209 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 410 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 147 KiB

@@ -0,0 +1,737 @@
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>EAPManageUI - 用户管理 (包含添加/编辑用户与用户表管理 生产级基准代码)</title>
<style>
/* =========================================================================
:root 全量 Design Tokens 声明 (严格遵循全局核心主色蓝 #2563EB 标准)
========================================================================= */
:root {
/* ── 核心主题色 (Global Primary Blue Standard) ── */
--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%);
/* ── 表面与背景 ── */
--color-surface: #FFFFFF;
--color-surface-variant: #F8FAFC;
--color-background: #EEF2F6;
/* ── 文本语义色 ── */
--text-main: #0F172A;
--text-sub: #64748B;
--text-dim: #94A3B8;
/* ── 边框与分割线 ── */
--divider: #E2E8F0;
--border-card: #E2E8F0;
/* ── 统一精致语义色 (杜绝刺眼突兀杂色) ── */
--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;
--shadow-card: 0 4px 16px rgba(15, 23, 42, 0.03);
--shadow-hover: 0 8px 24px rgba(15, 23, 42, 0.06);
/* ── 尺寸与栅格 ── */
--content-max-width: 1160px;
--content-gutter: clamp(16px, 2.5vw, 32px);
--appbar-height: 60px;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html {
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}
body {
font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "PingFang SC", "Segoe UI", Roboto, sans-serif;
background: var(--color-background);
color: var(--text-main);
min-height: 100vh;
padding: var(--content-gutter);
display: flex;
flex-direction: column;
}
/* 视口模拟器容器 (大屏动态自适应) */
.device-wrapper {
width: 100%;
max-width: var(--content-max-width);
margin: 0 auto;
background: var(--color-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;
}
/* 视图状态机容器 (SPA 模式无缝切换) */
.view-panel {
display: none;
flex-direction: column;
flex: 1;
}
.view-panel.active {
display: flex;
}
/* =========================================================================
1. AppBar 顶部导航栏统一规范 (40dp 纯净透明触控槽 + Hover 微圆底)
========================================================================= */
.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(--color-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;
letter-spacing: -0.01em;
}
/* =========================================================================
2. VIEW 1: 用户管理主界面
========================================================================= */
.control-header-bar {
padding: 12px 24px;
background: #F8FAFC;
border-bottom: 1px solid var(--divider);
display: flex;
align-items: center;
justify-content: space-between;
gap: 16px;
flex-wrap: wrap;
}
.db-selector-box {
display: flex;
align-items: center;
gap: 10px;
}
.db-label { font-size: 14px; font-weight: 700; color: var(--text-main); }
.db-select-pill {
background: #FFFFFF;
color: var(--color-primary);
border: 1.5px solid var(--color-primary-border);
padding: 6px 14px;
border-radius: 100px;
font-size: 13.5px;
font-weight: 700;
display: flex;
align-items: center;
gap: 8px;
cursor: pointer;
transition: all 0.15s ease;
box-shadow: 0 2px 6px rgba(37, 99, 235, 0.06);
}
.db-select-pill:hover {
border-color: var(--color-primary);
background: var(--color-primary-light);
}
.top-actions-group {
display: flex;
align-items: center;
gap: 10px;
}
.btn-ctrl-action {
height: 38px;
padding: 0 16px;
border-radius: 8px;
font-size: 13.5px;
font-weight: 700;
cursor: pointer;
display: inline-flex;
align-items: center;
gap: 6px;
transition: all 0.15s ease;
border: 1.5px solid transparent;
}
.btn-add-primary {
background: var(--color-primary-gradient);
color: white;
box-shadow: 0 2px 8px var(--color-primary-glow);
}
.btn-add-primary:hover {
transform: translateY(-1px);
box-shadow: 0 4px 14px var(--color-primary-glow);
}
.btn-ghost-secondary {
background: #FFFFFF;
color: var(--text-main);
border-color: var(--divider);
}
.btn-ghost-secondary:hover {
background: #F1F5F9;
border-color: #CBD5E1;
}
/* 3. 三区流式学员卡片矩阵 */
.users-stream-body {
padding: clamp(18px, 2.5vw, 26px);
background: #F8FAFC;
flex: 1;
overflow-y: auto;
display: flex;
flex-direction: column;
gap: 12px;
max-height: calc(100vh - 180px);
}
.user-row-card {
background: var(--color-surface);
border: 1.5px solid var(--border-card);
border-radius: 14px;
padding: 16px 20px;
display: grid;
grid-template-columns: 280px 1fr auto;
align-items: center;
gap: 20px;
box-shadow: 0 2px 8px rgba(15, 23, 42, 0.03);
transition: all 0.2s ease;
}
.user-row-card:hover {
border-color: #CBD5E1;
box-shadow: 0 6px 16px rgba(15, 23, 42, 0.06);
transform: translateY(-1px);
}
/* Zone 1: Profile & Avatar */
.profile-zone {
display: flex;
align-items: center;
gap: 14px;
}
.avatar-thumb-box {
width: 50px;
height: 50px;
border-radius: 12px;
overflow: hidden;
background: var(--color-primary-light);
border: 1.5px solid var(--color-primary-border);
display: flex;
align-items: center;
justify-content: center;
flex-shrink: 0;
box-shadow: 0 2px 6px rgba(37, 99, 235, 0.08);
}
.avatar-thumb-box svg { width: 28px; height: 28px; fill: var(--color-primary); }
.name-meta { display: flex; flex-direction: column; gap: 3px; }
.name-line { display: flex; align-items: center; gap: 8px; }
.u-name { font-size: 16px; font-weight: 700; color: var(--text-main); }
.u-gender { font-size: 11.5px; font-weight: 700; padding: 2px 7px; border-radius: 6px; }
.u-gender.female { background: #FCE7F3; color: #DB2777; }
.u-gender.male { background: #EFF6FF; color: var(--color-primary); }
.u-subline { font-size: 12.5px; color: var(--text-sub); }
.u-subline b { color: var(--text-main); font-weight: 600; font-family: ui-monospace, monospace; }
/* Zone 2: Metrics */
.metrics-zone {
display: flex;
align-items: center;
gap: 12px;
flex-wrap: wrap;
}
.metric-capsule {
background: #F8FAFC;
border: 1px solid var(--divider);
border-radius: 8px;
padding: 6px 12px;
display: flex;
align-items: center;
gap: 6px;
font-size: 12.5px;
color: var(--text-sub);
}
.metric-capsule b {
color: var(--color-primary);
font-weight: 700;
font-family: ui-monospace, monospace;
}
/* Zone 3: Controls */
.controls-zone {
display: flex;
align-items: center;
gap: 12px;
}
/* 统一开关样式 */
.switch {
position: relative; display: inline-block; width: 44px; height: 24px;
}
.switch input { opacity: 0; width: 0; height: 0; }
.slider {
position: absolute; cursor: pointer; top: 0; left: 0; right: 0; bottom: 0;
background-color: #CBD5E1; transition: .2s; border-radius: 24px;
}
.slider:before {
position: absolute; content: ""; height: 18px; width: 18px; left: 3px; bottom: 3px;
background-color: white; transition: .2s; border-radius: 50%;
box-shadow: 0 1px 4px rgba(0,0,0,0.15);
}
input:checked + .slider { background-color: var(--color-primary); }
input:checked + .slider:before { transform: translateX(20px); }
/* 操作图标按钮 */
.action-icon-btn {
width: 36px; height: 36px; border-radius: 8px; border: 1px solid var(--divider);
background: #FFFFFF; display: inline-flex; align-items: center; justify-content: center;
cursor: pointer; transition: all 0.15s ease;
}
.action-icon-btn:hover { background: var(--color-primary-light); border-color: var(--color-primary-border); }
.action-icon-btn.edit-btn:hover svg { fill: var(--color-primary); }
.action-icon-btn.delete-btn:hover { background: var(--color-danger-bg); border-color: var(--color-danger-border); }
.action-icon-btn.delete-btn:hover svg { fill: var(--color-danger); }
.action-icon-btn svg { width: 18px; height: 18px; fill: var(--text-sub); }
/* =========================================================================
3. VIEW 2: 添加/编辑用户独立表单
========================================================================= */
.form-view-container {
padding: 30px 40px;
background: #FFFFFF;
flex: 1;
overflow-y: auto;
display: flex;
flex-direction: column;
align-items: center;
max-width: 640px;
width: 100%;
margin: 0 auto;
gap: 20px;
}
.avatar-uploader-round {
width: 84px; height: 84px; border-radius: 50%; background: var(--color-primary-light);
border: 2px dashed var(--color-primary-border); display: flex; align-items: center; justify-content: center;
position: relative; cursor: pointer; box-shadow: 0 4px 16px var(--color-primary-glow);
transition: all 0.2s ease;
}
.avatar-uploader-round:hover {
border-color: var(--color-primary);
transform: scale(1.03);
}
.avatar-uploader-round svg { width: 40px; height: 40px; fill: var(--color-primary); }
.cam-badge {
position: absolute; bottom: 0; right: 0; width: 26px; height: 26px; border-radius: 50%;
background: var(--color-primary); display: flex; align-items: center; justify-content: center;
border: 2px solid white; box-shadow: 0 2px 6px rgba(0,0,0,0.2);
}
.cam-badge svg { width: 13px; height: 13px; fill: white; }
.form-grid-stack { width: 100%; display: flex; flex-direction: column; gap: 14px; }
.f-group { display: flex; flex-direction: column; gap: 6px; }
.f-label { font-size: 13px; font-weight: 700; color: var(--text-sub); }
.f-input, .f-select {
width: 100%; height: 44px; border: 1.5px solid var(--divider); border-radius: 10px;
padding: 0 16px; font-size: 14px; color: var(--text-main); background: #FFFFFF; outline: none;
transition: all 0.15s ease;
}
.f-input:focus, .f-select:focus {
border-color: var(--color-primary);
box-shadow: 0 0 0 3px var(--color-primary-light);
}
.f-two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.btn-submit-full {
width: 100%; height: 48px; background: var(--color-primary-gradient); color: white;
border: none; border-radius: 12px; font-size: 15px; font-weight: 700; cursor: pointer;
box-shadow: 0 4px 14px var(--color-primary-glow); margin-top: 10px; transition: all 0.15s ease;
}
.btn-submit-full:hover {
transform: translateY(-1px);
box-shadow: 0 6px 18px var(--color-primary-glow);
}
/* =========================================================================
4. VIEW 3: 用户表管理
========================================================================= */
.db-view-container {
padding: 24px 30px; background: #F8FAFC; flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 16px;
}
.db-notice {
padding: 12px 20px; background: var(--color-primary-light); border: 1.5px solid var(--color-primary-border);
border-radius: 12px; display: flex; align-items: center; justify-content: space-between;
color: var(--color-on-primary-container); font-size: 13.5px; font-weight: 600;
}
.db-row {
background: white; border: 1.5px solid var(--divider); border-radius: 12px; padding: 16px 20px;
display: flex; align-items: center; justify-content: space-between; cursor: grab;
transition: all 0.15s ease;
}
.db-row:hover {
border-color: var(--color-primary);
box-shadow: 0 4px 12px rgba(37, 99, 235, 0.08);
}
</style>
</head>
<body>
<div class="device-wrapper">
<!-- ========================================== -->
<!-- VIEW 1: 用户管理主界面 -->
<!-- ========================================== -->
<div class="view-panel active" id="viewMain">
<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>
<div class="control-header-bar">
<div class="db-selector-box">
<span class="db-label">用户表:</span>
<div class="db-select-pill" onclick="openDbManageView()">
<span>UserDatabase_CHINA</span>
<svg style="width: 14px; height: 14px; fill: currentColor;" viewBox="0 0 24 24"><path d="M7 10l5 5 5-5z"/></svg>
</div>
</div>
<div class="top-actions-group">
<button class="btn-ctrl-action btn-add-primary" onclick="openAddUserView()">
<svg style="width: 16px; height: 16px; fill: currentColor;" viewBox="0 0 24 24"><path d="M19 13h-6v6h-2v-6H5v-2h6V5h2v6h6v2z"/></svg>
<span>添加</span>
</button>
<button class="btn-ctrl-action btn-ghost-secondary" onclick="alert('请选择要导入的学员 Excel / CSV 模板文件...')">
<svg style="width: 16px; height: 16px; fill: currentColor;" viewBox="0 0 24 24"><path d="M9 16h6v-6h4l-7-7-7 7h4zm-4 2h14v2H5z"/></svg>
<span>导入</span>
</button>
<button class="btn-ctrl-action btn-ghost-secondary" onclick="openDbManageView()">
<svg style="width: 16px; height: 16px; fill: currentColor;" viewBox="0 0 24 24"><path d="M3 17.25V21h3.75L17.81 9.94l-3.75-3.75L3 17.25zM20.71 7.04c.39-.39.39-1.02 0-1.41l-2.34-2.34c-.39-.39-1.02-.39-1.41 0l-1.83 1.83 3.75 3.75 1.83-1.83z"/></svg>
<span>编辑</span>
</button>
</div>
</div>
<main class="users-stream-body" id="userListContainer">
<!-- 孙伟 女 -->
<div class="user-row-card">
<div class="profile-zone">
<div class="avatar-thumb-box">
<svg viewBox="0 0 24 24"><path d="M12 12c2.21 0 4-1.79 4-4s-1.79-4-4-4-4 1.79-4 4 1.79 4 4 4zm0 2c-2.67 0-8 1.34-8 4v2h16v-2c0-2.66-5.33-4-8-4z"/></svg>
</div>
<div class="name-meta">
<div class="name-line">
<span class="u-name">孙伟</span>
<span class="u-gender female">女</span>
</div>
<div class="u-subline">学号: <b>10229</b> | 年龄: <b>25岁</b> · 身高: <b>167 cm</b> | 体重: <b>117.0 kg</b></div>
</div>
</div>
<div class="metrics-zone">
<div class="metric-capsule"><span>静息心率:</span><b>60 bpm</b></div>
<div class="metric-capsule"><span>最大心率:</span><b>188</b></div>
</div>
<div class="controls-zone">
<label class="switch"><input type="checkbox" checked><span class="slider"></span></label>
<button class="action-icon-btn edit-btn" title="编辑用户" onclick="openEditUserView('孙伟', '10229', '女', '1999-04-12', '167', '117.0', '60', '188')">
<svg viewBox="0 0 24 24"><path d="M3 17.25V21h3.75L17.81 9.94l-3.75-3.75L3 17.25zM20.71 7.04c.39-.39.39-1.02 0-1.41l-2.34-2.34c-.39-.39-1.02-.39-1.41 0l-1.83 1.83 3.75 3.75 1.83-1.83z"/></svg>
</button>
<button class="action-icon-btn delete-btn" title="删除用户" onclick="deleteUserRow(this, '孙伟')">
<svg viewBox="0 0 24 24"><path d="M6 19c0 1.1.9 2 2 2h8c1.1 0 2-.9 2-2V7H6v12zM19 4h-3.5l-1-1h-5l-1 1H5v2h14V4z"/></svg>
</button>
</div>
</div>
<!-- 陈静 男 -->
<div class="user-row-card">
<div class="profile-zone">
<div class="avatar-thumb-box">
<svg viewBox="0 0 24 24"><path d="M12 12c2.21 0 4-1.79 4-4s-1.79-4-4-4-4 1.79-4 4 1.79 4 4 4zm0 2c-2.67 0-8 1.34-8 4v2h16v-2c0-2.66-5.33-4-8-4z"/></svg>
</div>
<div class="name-meta">
<div class="name-line">
<span class="u-name">陈静</span>
<span class="u-gender male">男</span>
</div>
<div class="u-subline">学号: <b>203464</b> | 年龄: <b>28岁</b> · 身高: <b>189 cm</b> | 体重: <b>71.0 kg</b></div>
</div>
</div>
<div class="metrics-zone">
<div class="metric-capsule"><span>静息心率:</span><b>60 bpm</b></div>
<div class="metric-capsule"><span>最大心率:</span><b>186</b></div>
</div>
<div class="controls-zone">
<label class="switch"><input type="checkbox" checked><span class="slider"></span></label>
<button class="action-icon-btn edit-btn" title="编辑用户" onclick="openEditUserView('陈静', '203464', '男', '1996-08-20', '189', '71.0', '60', '186')">
<svg viewBox="0 0 24 24"><path d="M3 17.25V21h3.75L17.81 9.94l-3.75-3.75L3 17.25zM20.71 7.04c.39-.39.39-1.02 0-1.41l-2.34-2.34c-.39-.39-1.02-.39-1.41 0l-1.83 1.83 3.75 3.75 1.83-1.83z"/></svg>
</button>
<button class="action-icon-btn delete-btn" title="删除用户" onclick="deleteUserRow(this, '陈静')">
<svg viewBox="0 0 24 24"><path d="M6 19c0 1.1.9 2 2 2h8c1.1 0 2-.9 2-2V7H6v12zM19 4h-3.5l-1-1h-5l-1 1H5v2h14V4z"/></svg>
</button>
</div>
</div>
<!-- 吴敏 女 -->
<div class="user-row-card">
<div class="profile-zone">
<div class="avatar-thumb-box">
<svg viewBox="0 0 24 24"><path d="M12 12c2.21 0 4-1.79 4-4s-1.79-4-4-4-4 1.79-4 4 1.79 4 4 4zm0 2c-2.67 0-8 1.34-8 4v2h16v-2c0-2.66-5.33-4-8-4z"/></svg>
</div>
<div class="name-meta">
<div class="name-line">
<span class="u-name">吴敏</span>
<span class="u-gender female">女</span>
</div>
<div class="u-subline">学号: <b>295</b> | 年龄: <b>29岁</b> · 身高: <b>153 cm</b> | 体重: <b>109.0 kg</b></div>
</div>
</div>
<div class="metrics-zone">
<div class="metric-capsule"><span>静息心率:</span><b>60 bpm</b></div>
<div class="metric-capsule"><span>最大心率:</span><b>185</b></div>
</div>
<div class="controls-zone">
<label class="switch"><input type="checkbox" checked><span class="slider"></span></label>
<button class="action-icon-btn edit-btn" title="编辑用户" onclick="openEditUserView('吴敏', '295', '女', '1995-11-05', '153', '109.0', '60', '185')">
<svg viewBox="0 0 24 24"><path d="M3 17.25V21h3.75L17.81 9.94l-3.75-3.75L3 17.25zM20.71 7.04c.39-.39.39-1.02 0-1.41l-2.34-2.34c-.39-.39-1.02-.39-1.41 0l-1.83 1.83 3.75 3.75 1.83-1.83z"/></svg>
</button>
<button class="action-icon-btn delete-btn" title="删除用户" onclick="deleteUserRow(this, '吴敏')">
<svg viewBox="0 0 24 24"><path d="M6 19c0 1.1.9 2 2 2h8c1.1 0 2-.9 2-2V7H6v12zM19 4h-3.5l-1-1h-5l-1 1H5v2h14V4z"/></svg>
</button>
</div>
</div>
</main>
</div>
<!-- ========================================== -->
<!-- VIEW 2: 添加/编辑用户独立表单 -->
<!-- ========================================== -->
<div class="view-panel" id="viewUserForm">
<header class="appbar">
<div class="appbar-left">
<button class="appbar-nav" onclick="showMainView()" 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" id="formHeaderTitle">添加用户</h1>
</div>
</header>
<main class="form-view-container">
<!-- 交互式头像上传 -->
<div class="avatar-uploader-round" onclick="document.getElementById('avatarFileInput').click()" title="点击上传自定义头像">
<div id="avatarPreviewContainer">
<svg viewBox="0 0 24 24"><path d="M12 12c2.21 0 4-1.79 4-4s-1.79-4-4-4-4 1.79-4 4 1.79 4 4 4zm0 2c-2.67 0-8 1.34-8 4v2h16v-2c0-2.66-5.33-4-8-4z"/></svg>
</div>
<div class="cam-badge"><svg viewBox="0 0 24 24"><path d="M3 17.25V21h3.75L17.81 9.94l-3.75-3.75L3 17.25zM20.71 7.04c.39-.39.39-1.02 0-1.41l-2.34-2.34c-.39-.39-1.02-.39-1.41 0l-1.83 1.83 3.75 3.75 1.83-1.83z"/></svg></div>
<input type="file" id="avatarFileInput" accept="image/*" style="display: none;" onchange="previewAvatar(event)">
</div>
<span style="font-size: 13px; font-weight: 600; color: var(--color-primary); cursor: pointer;" onclick="document.getElementById('avatarFileInput').click()">点击上传/更换自定义头像</span>
<form class="form-grid-stack" onsubmit="handleFormSubmit(event)">
<div class="f-group">
<label class="f-label">学号</label>
<input type="text" id="fSno" class="f-input" placeholder="请输入学号,如 10229" required>
</div>
<div class="f-group">
<label class="f-label">用户名</label>
<input type="text" id="fName" class="f-input" placeholder="请输入用户名,如 孙伟" required>
</div>
<div class="f-group">
<label class="f-label">性别</label>
<select id="fGender" class="f-select">
<option value="未知">未知</option>
<option value="男">男</option>
<option value="女">女</option>
</select>
</div>
<div class="f-group">
<label class="f-label">出生日期</label>
<input type="date" id="fBday" class="f-input" value="2000-01-01" onchange="autoCalcMaxHr()">
</div>
<div class="f-two-col">
<div class="f-group">
<label class="f-label">身高 (cm)</label>
<input type="number" id="fH" class="f-input" placeholder="例如 167">
</div>
<div class="f-group">
<label class="f-label">体重 (kg)</label>
<input type="number" step="0.1" id="fW" class="f-input" placeholder="例如 65.0">
</div>
</div>
<div class="f-two-col">
<div class="f-group">
<label class="f-label">静息心率 (bpm)</label>
<input type="number" id="fRest" class="f-input" value="60">
</div>
<div class="f-group">
<label class="f-label">最大心率 (bpm - 自动计算)</label>
<input type="number" id="fMax" class="f-input" value="188">
</div>
</div>
<button type="submit" class="btn-submit-full" id="btnSubmitForm">保存学员信息</button>
</form>
</main>
</div>
<!-- ========================================== -->
<!-- VIEW 3: 用户表管理 -->
<!-- ========================================== -->
<div class="view-panel" id="viewDbManage">
<header class="appbar">
<div class="appbar-left">
<button class="appbar-nav" onclick="showMainView()" 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>
</header>
<main class="db-view-container">
<div class="db-notice">
<span>长按并上下拖拽可以调整用户表顺序</span>
<button style="background: var(--color-primary); color: white; border: none; padding: 7px 16px; border-radius: 8px; font-weight: 700; cursor: pointer;" onclick="alert('已成功导出当前用户表全量数据!')">导出全部用户</button>
</div>
<div class="db-row">
<div style="display: flex; align-items: center; gap: 14px;">
<span style="font-size: 20px; color: var(--text-sub); cursor: grab;">☰</span>
<div>
<div style="font-size: 15px; font-weight: 700; font-family: ui-monospace, monospace;">UserDatabase_CHINA</div>
<div style="font-size: 12px; color: var(--text-sub); margin-top: 2px;">共包含 6 名学员档案 · 当前正在使用</div>
</div>
</div>
<div style="display: flex; gap: 8px;">
<button class="action-icon-btn edit-btn" title="重命名" onclick="alert('重命名用户表')">
<svg viewBox="0 0 24 24"><path d="M3 17.25V21h3.75L17.81 9.94l-3.75-3.75L3 17.25zM20.71 7.04c.39-.39.39-1.02 0-1.41l-2.34-2.34c-.39-.39-1.02-.39-1.41 0l-1.83 1.83 3.75 3.75 1.83-1.83z"/></svg>
</button>
<button class="action-icon-btn delete-btn" title="删除" onclick="alert('活动用户表不能删除!')">
<svg viewBox="0 0 24 24"><path d="M6 19c0 1.1.9 2 2 2h8c1.1 0 2-.9 2-2V7H6v12zM19 4h-3.5l-1-1h-5l-1 1H5v2h14V4z"/></svg>
</button>
</div>
</div>
</main>
</div>
</div>
<script>
function showMainView() {
document.querySelectorAll('.view-panel').forEach(p => p.classList.remove('active'));
document.getElementById('viewMain').classList.add('active');
}
function openAddUserView() {
document.getElementById('formHeaderTitle').innerText = "添加用户";
document.getElementById('fSno').value = "";
document.getElementById('fName').value = "";
document.getElementById('fGender').value = "未知";
document.getElementById('fBday').value = "2000-01-01";
document.getElementById('fH').value = "";
document.getElementById('fW').value = "";
document.getElementById('fRest').value = "60";
document.getElementById('fMax').value = "188";
document.getElementById('btnSubmitForm').innerText = "保存新学员";
document.querySelectorAll('.view-panel').forEach(p => p.classList.remove('active'));
document.getElementById('viewUserForm').classList.add('active');
}
function openEditUserView(name, sno, gender, bday, h, w, rest, max) {
document.getElementById('formHeaderTitle').innerText = `编辑用户 - ${name}`;
document.getElementById('fSno').value = sno;
document.getElementById('fName').value = name;
document.getElementById('fGender').value = gender;
document.getElementById('fBday').value = bday;
document.getElementById('fH').value = h;
document.getElementById('fW').value = w;
document.getElementById('fRest').value = rest;
document.getElementById('fMax').value = max;
document.getElementById('btnSubmitForm').innerText = `更新 ${name} 的信息`;
document.querySelectorAll('.view-panel').forEach(p => p.classList.remove('active'));
document.getElementById('viewUserForm').classList.add('active');
}
function openDbManageView() {
document.querySelectorAll('.view-panel').forEach(p => p.classList.remove('active'));
document.getElementById('viewDbManage').classList.add('active');
}
function autoCalcMaxHr() {
const bDate = new Date(document.getElementById('fBday').value);
const age = new Date().getFullYear() - bDate.getFullYear();
if (age > 0) {
document.getElementById('fMax').value = Math.max(150, 220 - age);
}
}
function previewAvatar(event) {
const file = event.target.files[0];
if (file) {
const reader = new FileReader();
reader.onload = function(e) {
document.getElementById('avatarPreviewContainer').innerHTML = `
<img src="${e.target.result}" style="width:100%;height:100%;object-fit:cover;border-radius:50%;">
`;
};
reader.readAsDataURL(file);
}
}
function handleFormSubmit(e) {
e.preventDefault();
const name = document.getElementById('fName').value;
alert(`学员 [${name}] 档案已成功写入数据库!`);
showMainView();
}
function deleteUserRow(btn, name) {
if (confirm(`确认要从当前用户表中删除学员 [${name}] 的档案吗?`)) {
btn.closest('.user-row-card').remove();
}
}
</script>
</body>
</html>
Binary file not shown.

After

Width:  |  Height:  |  Size: 71 KiB

@@ -0,0 +1,20 @@
# 用户管理(含添加用户与用户表管理)实施方案
## 1. 目标与范围
本模块旨在重构【用户管理】设置子页面及其附属的【添加用户】和【用户表管理】视图,统一全局 `#2563EB` 色彩规范,隔离添加/编辑交互状态,支持头像系统与生理指标计算。
## 2. 交付物矩阵 (6件套)
- [x] 真机基准截图 1:`设置页面UI优化/用户管理/Screenshot_20260812_143424.png` / `Screenshot_20260817_用户管理_主界面.png`
- [x] 真机基准截图 2:`设置页面UI优化/用户管理/Screenshot_20260817_添加用户.png`
- [x] 真机基准截图 3:`设置页面UI优化/用户管理/Screenshot_20260817_用户表管理.png`
- [x] 生产代码:`设置页面UI优化/用户管理/baseline_ui.html`
- [x] 渲染截图:`设置页面UI优化/用户管理/image.png`
- [x] 设计规范:`设置页面UI优化/用户管理/DESIGN_SPEC.md`
- [x] 实施方案:`设置页面UI优化/用户管理/implementation_plan.md`
- [x] 任务卡片:`设置页面UI优化/用户管理/CARD-20260817-UITask-用户管理.md`
## 3. 验收标准
1. **多视图闭环**:主界面、添加用户、用户表管理三屏在同一 SPA 中平滑切换,无页面跳转卡顿;
2. **状态隔离**:点击顶部【添加】清空所有表单项;点击列表项【✏️ 编辑】精确回填该学员的所有数据;
3. **视觉统一**:消除所有突兀杂绿/杂红,全量采用 `#2563EB` 与调和语义色;
4. **头像回退**:支持自定义上传与默认 SVG 头像回退展示。