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:
@@ -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>
|
||||
Reference in New Issue
Block a user