Files
aurora-admin/frameworks/table.html
T
aurora-admin eb25feedaf feat(S6-P21): 组件族参数化(13族/44成员/导航族15文件同源/79→48概念组件)
【本次核心 · S6-P21】
- 族层数据:families.json + 44 份契约注入 family/familyRole/familyParams;
  data.json / data.js / site/details 同步。13 族 / 44 成员 / 35 独立 → 概念组件 79→48。
- 79 个 slug 全保留、集合逐一不变(铁律 5 对外承诺未破);frameworks 仍 395 文件、薄壳仍 79。
- 归族判据为契约中可核对字段(semanticTypeCandidates 重叠 / anatomy 为同一骨架子集 /
  变体维度同构 / doNotInvent 显式从属声明),每族 mergeBasis 写明依据,不按名字猜。
- 实现层合并(导航族端到端切片):tools/gen-family-impl.mjs 从 5 端模板生成
  TopMenu / SideMenu / MixedNavigation 共 15 文件,参数 direction=top|side|mixed;
  三份 CSS md5 完全相同 = 一份样式表服务三个组件。
- 新增 tools/gen-families.mjs、tools/gen-family-impl.mjs、tools/verify-families.mjs、
  tools/lib/family-model.mjs、tools/lib/family-impl/nav-menu/*.tpl。

【同时清掉此前已完成但未提交的批次】
生成物(data.json / data.js / site/sources / site/components 薄壳 / sitemap.xml / tests 报告)
跨阶段交织,无法拆成互相自洽的多个提交,故按既有批量风格合并提交:
- Package:三端可 import(S5-P18)+ 发布到私有 npm 源
- Docs site:导航语言改下拉(S5-P19)、详情页代码块默认展开、中英切换完整性
- Security:生产部署链审计修复(2026-09-19)+ 线上部署
- Theme modes 日间/夜间/自动;S1-P4 data.js 瘦身;S2-P5 暗色;S2-P6 跨端一致性;
  S2-P7 行为断言;S2-P9 FAQ;S3-P8 RTL;S3-P9 契约缺口解释层;S4-P12 发布流程
- 补入 tools/pack-deploy.mjs、run-site-smoke.mjs、verify-*.mjs,.dockerignore、
  安全审计修复与待决策项.md

【验收】
- node tools/verify-families.mjs → OK: 族层端到端一致(13 族 / 44 成员 / 79 组件不变 / 395 文件不变)
- node tools/verify-cross-platform.mjs → 79/79 identical(HEAD 基线 high 44)
- node tools/run-regression.mjs → 100%(79/79 页,1017/1017 断言,N/A 34),连跑 8 次一致,0 超时
- 逐页实测:topmenu / sidemenu / mixednavigation 各 13/13,帧内 direction 参数正确,0 JS 错误
- 零运行时依赖 OK;build-site.ps1 ASCII-only OK

【未纳入】site/components/<slug>/ 平台薄壳 316 个 —— 历史从未跟踪且属构建产物,保持现状。
2026-09-20 03:32:31 +08:00

145 lines
6.7 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Aurora Admin · Table (H5)</title>
<link rel="stylesheet" href="../.design_library/aurora-admin/colors_and_type.css">
<style>
/* 对齐 components.css 与 table.json 契约 */
.demo { padding: 24px; background: var(--au-color-page-bg); color: var(--au-color-text-body); font-family: var(--font-family); }
h1 { font-size: 20px; margin: 0 0 4px; }
.sub { color: var(--au-color-text-secondary); margin: 0 0 24px; font-size: 12px; }
.aa-table { width: 100%; border: 1px solid var(--au-color-border); border-radius: 8px; overflow: hidden; background: var(--au-color-card-bg); position: relative; }
.aa-table table { width: 100%; border-collapse: collapse; font-size: 14px; color: var(--au-color-text-body); }
.aa-table thead th {
background: var(--au-color-table-header-bg); color: var(--au-color-text-body); font-weight: 600; height: 48px; text-align: left;
padding: 0 16px; border-bottom: 1px solid var(--au-color-border); white-space: nowrap;
}
.aa-table tbody td { height: 48px; padding: 0 16px; border-bottom: 1px solid var(--au-color-border); text-align: left; }
.aa-table tbody tr:last-child td { border-bottom: none; }
.aa-table tbody tr:hover { background: var(--au-color-page-bg); }
.aa-table tbody tr.is-selected { background: var(--au-color-brand-bg); }
.aa-table th.align-right, .aa-table td.align-right { text-align: right; }
.aa-table .sortable { cursor: pointer; user-select: none; }
.aa-table .sort-ind { color: var(--au-color-text-placeholder); margin-left: 4px; }
.aa-table .sort-ind.active { color: var(--au-color-brand); }
.aa-table .col-action { text-align: right; }
.aa-table .link-btn { color: var(--au-color-brand); background: none; border: none; cursor: pointer; font-size: 14px; padding: 0; }
.aa-table .link-btn + .link-btn { margin-left: 8px; }
.aa-table .link-btn.danger { color: var(--au-color-error); }
.aa-table .checkbox { width: 16px; height: 16px; cursor: pointer; vertical-align: middle; }
.aa-table .empty { padding: 48px 16px; text-align: center; color: var(--au-color-text-placeholder); font-size: 14px; }
.aa-table .loading-mask {
position: absolute; inset: 0; background: rgba(255,255,255,0.7); display: flex;
align-items: center; justify-content: center; z-index: 2;
}
html.aa-dark .aa-table .loading-mask { background: rgba(20,22,28,0.7); }
.aa-table .spinner {
width: 20px; height: 20px; border: 2px solid var(--au-color-brand); border-top-color: transparent;
border-radius: 50%; animation: aa-tbl-spin .6s linear infinite;
}
@keyframes aa-tbl-spin { to { transform: rotate(360deg); } }
</style>
</head>
<body>
<div class="demo">
<h1>Aurora Admin · Table 组件(纯 H5)</h1>
<p class="sub">对齐 table.json 契约:表头/行高48px、分割线 #E8ECF1、悬停 #F5F7FA、选中 #F0F5FF、单元格左右16px、数字右对齐、操作列右对齐、加载/空态</p>
<label style="font-size:13px;color:var(--color-text-secondary);">
<input type="checkbox" id="toggleLoading"> 模拟加载态
</label>
<div class="aa-table" role="table" style="margin-top:12px">
<table>
<thead>
<tr>
<th class="col-selection" style="width:48px"><input type="checkbox" class="checkbox" id="selectAll"></th>
<th class="col-fixed">客户名称</th>
<th>负责人</th>
<th class="align-right right sortable" id="sortAmount" data-behavior="click-toggles-class:#sortInd|active">合同金额<span class="sort-ind" id="sortInd">↕</span></th>
<th>状态</th>
<th class="col-action action">操作</th>
</tr>
</thead>
<tbody id="tbody"></tbody>
</table>
<div class="loading-mask" id="loading" hidden><span class="spinner"></span></div>
</div>
</div>
<script>
const data = [
{ id: 1, name: '北京云图科技', owner: '张伟', amount: 128000, status: '已签约' },
{ id: 2, name: '上海恒创', owner: '李娜', amount: 86000, status: '跟进中' },
{ id: 3, name: '广州锐捷', owner: '王芳', amount: 254000, status: '已签约' },
{ id: 4, name: '深圳智联', owner: '刘强', amount: 43000, status: '待回款' }
];
let selected = new Set();
let sortOrder = null; // 'asc' | 'desc' | null
function rows() {
if (!sortOrder) return data;
return [...data].sort((a, b) => sortOrder === 'asc' ? a.amount - b.amount : b.amount - a.amount);
}
function render() {
const tbody = document.getElementById('tbody');
if (!rows().length) {
tbody.innerHTML = `<tr><td class="empty" colspan="6">暂无数据</td></tr>`;
return;
}
tbody.innerHTML = rows().map(r => {
const sel = selected.has(r.id) ? 'checked' : '';
const cls = selected.has(r.id) ? ' class="is-selected"' : '';
return `<tr${cls} data-id="${r.id}">
<td class="col-selection"><input type="checkbox" class="checkbox row-cb" data-id="${r.id}" ${sel}></td>
<td class="col-fixed">${r.name}</td>
<td>${r.owner}</td>
<td class="align-right right">¥${r.amount.toLocaleString()}</td>
<td>${r.status}</td>
<td class="col-action action">
<button class="link-btn" data-act="edit" data-id="${r.id}">编辑</button>
<button class="link-btn danger" data-act="del" data-id="${r.id}">删除</button>
</td>
</tr>`;
}).join('');
}
document.getElementById('tbody').addEventListener('change', (e) => {
if (e.target.classList.contains('row-cb')) {
const id = +e.target.dataset.id;
e.target.checked ? selected.add(id) : selected.delete(id);
render(); syncSelectAll();
}
});
document.getElementById('tbody').addEventListener('click', (e) => {
const b = e.target.closest('[data-act]');
if (b) alert(`${b.dataset.act} 行 id=${b.dataset.id}`);
});
document.getElementById('selectAll').addEventListener('change', (e) => {
selected = e.target.checked ? new Set(data.map(d => d.id)) : new Set();
render(); syncSelectAll();
});
function syncSelectAll() {
const sa = document.getElementById('selectAll');
sa.checked = selected.size === data.length && data.length > 0;
sa.indeterminate = selected.size > 0 && selected.size < data.length;
}
document.getElementById('sortAmount').addEventListener('click', () => {
sortOrder = sortOrder === null ? 'asc' : sortOrder === 'asc' ? 'desc' : null;
const ind = document.getElementById('sortInd');
ind.textContent = sortOrder === 'asc' ? '↑' : sortOrder === 'desc' ? '↓' : '↕';
ind.classList.toggle('active', sortOrder !== null);
render();
});
document.getElementById('toggleLoading').addEventListener('change', (e) => {
document.getElementById('loading').hidden = !e.target.checked;
});
render(); syncSelectAll();
</script>
</body>
</html>