fix(ui): 优化用户管理顶部用户表下拉选择器控件形态与交互

This commit is contained in:
zhy200308
2026-08-17 18:06:07 +08:00
parent 96c82ad25d
commit 393f1a97f4
3 changed files with 358 additions and 13 deletions
@@ -0,0 +1,195 @@
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>方案 1:Telemetry Card Flow 流式遥测设备库 (推荐·家族风)</title>
<style>
:root {
--color-primary: #2563EB;
--color-primary-dark: #1D4ED8;
--color-primary-light: #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;
--text-main: #0F172A;
--text-sub: #64748B;
--divider: #E2E8F0;
--color-warning: #D97706;
--color-warning-bg: #FFFBEB;
--color-warning-border: #FDE68A;
--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;
}
.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);
}
.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; }
.status-banner {
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;
}
.banner-info { display: flex; align-items: center; gap: 10px; font-size: 14px; font-weight: 700; color: var(--text-main); }
.banner-badge {
background: var(--color-primary-light); color: var(--color-primary); border: 1px solid var(--color-primary-border);
padding: 4px 10px; border-radius: 6px; font-size: 12px; font-weight: 700;
}
.banner-actions { display: flex; align-items: center; gap: 10px; }
.btn-sync-all {
height: 36px; padding: 0 16px; border-radius: 8px; font-size: 13px; font-weight: 700; cursor: pointer;
background: var(--color-primary-light); color: var(--color-primary); border: 1.5px solid var(--color-primary-border);
display: inline-flex; align-items: center; gap: 6px; transition: all 0.15s ease;
}
.btn-sync-all:hover { background: #DBEAFE; border-color: var(--color-primary); }
.btn-unbind-all {
height: 36px; padding: 0 16px; border-radius: 8px; font-size: 13px; font-weight: 700; cursor: pointer;
background: var(--color-danger-bg); color: var(--color-danger); border: 1.5px solid var(--color-danger-border);
display: inline-flex; align-items: center; gap: 6px; transition: all 0.15s ease;
}
.btn-unbind-all:hover { background: #FFE4E6; }
.device-list-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);
}
.device-card-row {
background: white; border: 1.5px solid var(--divider); border-radius: 14px; padding: 16px 20px;
display: flex; align-items: center; justify-content: space-between; gap: 20px;
box-shadow: 0 2px 8px rgba(15, 23, 42, 0.03); transition: all 0.2s ease;
}
.device-card-row:hover { border-color: #CBD5E1; box-shadow: 0 6px 16px rgba(15, 23, 42, 0.06); transform: translateY(-1px); }
.dev-left { display: flex; align-items: center; gap: 14px; }
.ble-avatar {
width: 48px; height: 48px; border-radius: 12px; background: var(--color-primary-light);
border: 1.5px solid var(--color-primary-border); display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.ble-avatar svg { width: 24px; height: 24px; fill: var(--color-primary); }
.dev-info { display: flex; flex-direction: column; gap: 4px; }
.dev-title { font-size: 16px; font-weight: 700; font-family: ui-monospace, monospace; color: var(--text-main); }
.dev-subline { font-size: 12.5px; color: var(--text-sub); display: flex; gap: 14px; }
.dev-subline span b { color: var(--text-main); font-weight: 600; }
.dev-status-badge {
padding: 6px 14px; border-radius: 8px; font-size: 13px; font-weight: 700;
background: var(--color-warning-bg); color: var(--color-warning); border: 1px solid var(--color-warning-border);
}
.dev-status-badge.bound {
background: var(--color-primary-light); color: var(--color-primary); border-color: var(--color-primary-border);
}
</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>
<div class="status-banner">
<div class="banner-info">
<span>📡 设备数据库 (统一充电与状态管理)</span>
<span class="banner-badge">已登记: 7 台</span>
</div>
<div class="banner-actions">
<button class="btn-sync-all" onclick="alert('正在批量同步所有手环电量与固件状态...')">
<svg style="width: 15px; height: 15px; 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>批量同步</span>
</button>
<button class="btn-unbind-all" onclick="confirm('确认要解绑全部已登记设备吗?')">
<svg style="width: 15px; height: 15px; 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>
<main class="device-list-body">
<!-- 33X_BLE_62200024 -->
<div class="device-card-row">
<div class="dev-left">
<div class="ble-avatar"><svg viewBox="0 0 24 24"><path d="M14.24 12.01l2.32-2.32c.28-.28.28-.75 0-1.03l-4.24-4.24c-.33-.33-.89-.1-.89.37V10.1l-3.3-3.3a.754.754 0 0 0-1.06 0c-.29.29-.29.77 0 1.06l3.86 3.86-3.86 3.86a.754.754 0 0 0 0 1.06c.29.29.77.29 1.06 0l3.3-3.3v5.39c0 .47.56.7.89.37l4.24-4.24c.28-.28.28-.75 0-1.03l-2.32-2.32zm-1.31-4.73l1.88 1.88-1.88 1.88V7.28zm0 9.44v-3.76l1.88 1.88-1.88 1.88z"/></svg></div>
<div class="dev-info">
<div class="dev-title">33X_BLE_62200024</div>
<div class="dev-subline">
<span>电量: <b>未知</b></span>
<span>固件: <b>未知</b></span>
<span>最后同步: <b>2026-08-12 14:32:25</b></span>
</div>
</div>
</div>
<div class="dev-status-badge">未绑定</div>
</div>
<!-- 33X_BLE_2200002 -->
<div class="device-card-row">
<div class="dev-left">
<div class="ble-avatar"><svg viewBox="0 0 24 24"><path d="M14.24 12.01l2.32-2.32c.28-.28.28-.75 0-1.03l-4.24-4.24c-.33-.33-.89-.1-.89.37V10.1l-3.3-3.3a.754.754 0 0 0-1.06 0c-.29.29-.29.77 0 1.06l3.86 3.86-3.86 3.86a.754.754 0 0 0 0 1.06c.29.29.77.29 1.06 0l3.3-3.3v5.39c0 .47.56.7.89.37l4.24-4.24c.28-.28.28-.75 0-1.03l-2.32-2.32zm-1.31-4.73l1.88 1.88-1.88 1.88V7.28zm0 9.44v-3.76l1.88 1.88-1.88 1.88z"/></svg></div>
<div class="dev-info">
<div class="dev-title">33X_BLE_2200002</div>
<div class="dev-subline">
<span>电量: <b>未知</b></span>
<span>固件: <b>未知</b></span>
<span>最后同步: <b>2026-08-12 14:32:25</b></span>
</div>
</div>
</div>
<div class="dev-status-badge">未绑定</div>
</div>
<!-- 33X_BLE_62200025 -->
<div class="device-card-row">
<div class="dev-left">
<div class="ble-avatar"><svg viewBox="0 0 24 24"><path d="M14.24 12.01l2.32-2.32c.28-.28.28-.75 0-1.03l-4.24-4.24c-.33-.33-.89-.1-.89.37V10.1l-3.3-3.3a.754.754 0 0 0-1.06 0c-.29.29-.29.77 0 1.06l3.86 3.86-3.86 3.86a.754.754 0 0 0 0 1.06c.29.29.77.29 1.06 0l3.3-3.3v5.39c0 .47.56.7.89.37l4.24-4.24c.28-.28.28-.75 0-1.03l-2.32-2.32zm-1.31-4.73l1.88 1.88-1.88 1.88V7.28zm0 9.44v-3.76l1.88 1.88-1.88 1.88z"/></svg></div>
<div class="dev-info">
<div class="dev-title">33X_BLE_62200025</div>
<div class="dev-subline">
<span>电量: <b>未知</b></span>
<span>固件: <b>未知</b></span>
<span>最后同步: <b>2026-08-12 14:32:25</b></span>
</div>
</div>
</div>
<div class="dev-status-badge">未绑定</div>
</div>
</main>
</div>
</body>
</html>
@@ -162,26 +162,115 @@ body {
display: flex; display: flex;
align-items: center; align-items: center;
gap: 10px; gap: 10px;
position: relative;
} }
.db-label { font-size: 14px; font-weight: 700; color: var(--text-main); } .db-label { font-size: 14px; font-weight: 700; color: var(--text-main); }
.db-select-pill {
/* 真实高质感下拉选择器控件 */
.db-select-trigger {
height: 38px;
min-width: 220px;
background: #FFFFFF; background: #FFFFFF;
color: var(--color-primary); color: var(--text-main);
border: 1.5px solid var(--color-primary-border); border: 1.5px solid #CBD5E1;
padding: 6px 14px; border-radius: 8px;
border-radius: 100px; padding: 0 12px 0 14px;
font-size: 13.5px; font-size: 14px;
font-weight: 700; font-weight: 600;
display: flex; display: flex;
align-items: center; align-items: center;
gap: 8px; justify-content: space-between;
gap: 12px;
cursor: pointer; cursor: pointer;
transition: all 0.15s ease; transition: all 0.15s ease;
box-shadow: 0 2px 6px rgba(37, 99, 235, 0.06); box-shadow: 0 1px 3px rgba(15, 23, 42, 0.04);
} }
.db-select-pill:hover { .db-select-trigger:hover {
border-color: var(--color-primary); border-color: var(--color-primary);
background: #FFFFFF;
box-shadow: 0 2px 6px rgba(37, 99, 235, 0.08);
}
.db-select-trigger.open {
border-color: var(--color-primary);
box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}
.db-select-val {
font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
font-size: 13.5px;
font-weight: 700;
color: var(--text-main);
}
.db-select-chevron {
width: 18px;
height: 18px;
fill: #64748B;
transition: transform 0.2s ease;
flex-shrink: 0;
}
.db-select-trigger.open .db-select-chevron {
transform: rotate(180deg);
fill: var(--color-primary);
}
/* 下拉菜单浮层 */
.db-dropdown-menu {
display: none;
position: absolute;
top: calc(100% + 6px);
left: 64px;
min-width: 240px;
background: #FFFFFF;
border: 1.5px solid var(--divider);
border-radius: 10px;
box-shadow: 0 10px 25px -5px rgba(15, 23, 42, 0.12), 0 4px 10px -2px rgba(15, 23, 42, 0.04);
z-index: 50;
padding: 6px;
flex-direction: column;
gap: 2px;
}
.db-dropdown-menu.show {
display: flex;
}
.db-menu-item {
padding: 9px 12px;
border-radius: 6px;
font-size: 13.5px;
font-weight: 600;
font-family: ui-monospace, monospace;
color: var(--text-main);
display: flex;
align-items: center;
justify-content: space-between;
cursor: pointer;
transition: all 0.15s ease;
}
.db-menu-item:hover {
background: var(--color-primary-light); background: var(--color-primary-light);
color: var(--color-primary);
}
.db-menu-item.active {
background: var(--color-primary-light);
color: var(--color-primary);
font-weight: 700;
}
.db-menu-divider {
height: 1px;
background: var(--divider);
margin: 4px 0;
}
.db-menu-action {
padding: 8px 12px;
border-radius: 6px;
font-size: 13px;
font-weight: 700;
color: var(--color-primary);
display: flex;
align-items: center;
gap: 6px;
cursor: pointer;
}
.db-menu-action:hover {
background: #EFF6FF;
} }
.top-actions-group { .top-actions-group {
@@ -441,9 +530,31 @@ input:checked + .slider:before { transform: translateX(20px); }
<div class="control-header-bar"> <div class="control-header-bar">
<div class="db-selector-box"> <div class="db-selector-box">
<span class="db-label">用户表:</span> <span class="db-label">用户表:</span>
<div class="db-select-pill" onclick="openDbManageView()"> <div class="db-select-trigger" id="dbSelectTrigger" onclick="toggleDbDropdown(event)">
<span>UserDatabase_CHINA</span> <div style="display: flex; align-items: center; gap: 8px;">
<svg style="width: 14px; height: 14px; fill: currentColor;" viewBox="0 0 24 24"><path d="M7 10l5 5 5-5z"/></svg> <svg style="width: 16px; height: 16px; fill: var(--color-primary);" viewBox="0 0 24 24"><path d="M4 6H2v14c0 1.1.9 2 2 2h14v-2H4V6zm16-4H8c-1.1 0-2 .9-2 2v12c0 1.1.9 2 2 2h12c1.1 0 2-.9 2-2V4c0-1.1-.9-2-2-2zm0 14H8V4h12v12z"/></svg>
<span class="db-select-val" id="selectedDbText">UserDatabase_CHINA</span>
</div>
<svg class="db-select-chevron" viewBox="0 0 24 24"><path d="M7 10l5 5 5-5z"/></svg>
</div>
<!-- 真实下拉菜单浮层 -->
<div class="db-dropdown-menu" id="dbDropdownMenu">
<div class="db-menu-item active" onclick="selectDatabase('UserDatabase_CHINA')">
<span>UserDatabase_CHINA</span>
<svg style="width: 16px; height: 16px; fill: var(--color-primary);" viewBox="0 0 24 24"><path d="M9 16.17L4.83 12l-1.42 1.41L9 19 21 7l-1.41-1.41z"/></svg>
</div>
<div class="db-menu-item" onclick="selectDatabase('UserDatabase_GLOBAL')">
<span>UserDatabase_GLOBAL</span>
</div>
<div class="db-menu-item" onclick="selectDatabase('UserDatabase_TRAIN_2026')">
<span>UserDatabase_TRAIN_2026</span>
</div>
<div class="db-menu-divider"></div>
<div class="db-menu-action" onclick="openDbManageView()">
<svg style="width: 15px; height: 15px; fill: currentColor;" viewBox="0 0 24 24"><path d="M19 13h-6v6h-2v-6H5v-2h6V5h2v6h6v2z"/></svg>
<span>管理/新建用户表...</span>
</div>
</div> </div>
</div> </div>
<div class="top-actions-group"> <div class="top-actions-group">
@@ -727,6 +838,45 @@ input:checked + .slider:before { transform: translateX(20px); }
showMainView(); showMainView();
} }
function toggleDbDropdown(e) {
e.stopPropagation();
const trigger = document.getElementById('dbSelectTrigger');
const menu = document.getElementById('dbDropdownMenu');
const isOpen = menu.classList.contains('show');
if (isOpen) {
menu.classList.remove('show');
trigger.classList.remove('open');
} else {
menu.classList.add('show');
trigger.classList.add('open');
}
}
function selectDatabase(dbName) {
document.getElementById('selectedDbText').innerText = dbName;
document.querySelectorAll('.db-menu-item').forEach(it => {
if (it.innerText.includes(dbName)) {
it.classList.add('active');
it.innerHTML = `<span>${dbName}</span><svg style="width: 16px; height: 16px; fill: var(--color-primary);" viewBox="0 0 24 24"><path d="M9 16.17L4.83 12l-1.42 1.41L9 19 21 7l-1.41-1.41z"/></svg>`;
} else {
it.classList.remove('active');
it.innerHTML = `<span>${it.innerText.trim()}</span>`;
}
});
document.getElementById('dbDropdownMenu').classList.remove('show');
document.getElementById('dbSelectTrigger').classList.remove('open');
}
// 点击外部区域自动关闭下拉浮层
document.addEventListener('click', function(e) {
const menu = document.getElementById('dbDropdownMenu');
const trigger = document.getElementById('dbSelectTrigger');
if (menu && !menu.contains(e.target) && !trigger.contains(e.target)) {
menu.classList.remove('show');
trigger.classList.remove('open');
}
});
function deleteUserRow(btn, name) { function deleteUserRow(btn, name) {
if (confirm(`确认要从当前用户表中删除学员 [${name}] 的档案吗?`)) { if (confirm(`确认要从当前用户表中删除学员 [${name}] 的档案吗?`)) {
btn.closest('.user-row-card').remove(); btn.closest('.user-row-card').remove();
Binary file not shown.

Before

Width:  |  Height:  |  Size: 71 KiB

After

Width:  |  Height:  |  Size: 71 KiB