Files
aurora-admin/site/sources/expandabletable/html.txt
T
aurora-admin c65a69c34e
Deploy to GitHub Pages / deploy (push) Failing after 16s
Regression / regression (push) Failing after 15m2s
feat(P4): precompute移植+app.js sources双向回填+回归1003/1003+验收体积/文件/data.json
2026-09-12 14:18:41 +08:00

64 lines
2.7 KiB
Plaintext
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 · ExpandableTable</title>
<link rel="stylesheet" href="../.design_library/aurora-admin/colors_and_type.css" />
<link rel="stylesheet" href="./ExpandableTable.css" />
</head>
<body>
<div class="aa-page">
<h2 class="aa-h2">ExpandableTable 可展开表格</h2>
<p class="aa-desc">行首展开图标可展开详情(子表格 / 描述),支持同时展开多行或仅一行。</p>
<div class="aa-demo">
<div class="aa-demo__title">订单明细(点击箭头展开)</div>
<table class="aa-exptable" id="exptable">
<thead><tr><th style="width:40px"></th><th>订单号</th><th>客户</th><th>金额</th><th>状态</th></tr></thead>
<tbody></tbody>
</table>
</div>
</div>
<script>
var data = [
{ id: 'NO20240801', cust: '北京科技有限公司', amount: 1280, status: '已付款',
detail: { items: ['企业版授权 ×1', '实施服务 ×1'], note: '对公转账,预计 3 个工作日内开通。' } },
{ id: 'NO20240802', cust: '上海贸易行', amount: 560, status: '待发货',
detail: { items: ['标准版授权 ×2'], note: '已开票,等待仓库出库。' } },
{ id: 'NO20240803', cust: '广州信息公司', amount: 3200, status: '已完成',
detail: { items: ['旗舰版授权 ×1', '培训服务 ×3', '运维包 ×1'], note: '项目已验收,进入维保期。' } }
];
var openSet = new Set();
var tbody = document.querySelector('#exptable tbody');
function rowHtml(d) {
var open = openSet.has(d.id);
var sub = d.detail.items.map(function (i) { return '<div>· ' + i + '</div>'; }).join('');
return '' +
'<tr class="aa-row">' +
'<td><button class="aa-exp-toggle' + (open ? ' is-open' : '') + '" role="button" tabindex="0" data-id="' + d.id + '">▶</button></td>' +
'<td>' + d.id + '</td>' +
'<td>' + d.cust + '</td>' +
'<td>¥' + d.amount + '</td>' +
'<td>' + d.status + '</td>' +
'</tr>' +
(open ? '<tr class="aa-exp-row"><td></td><td colspan="4"><div class="aa-exp-panel">' +
'<div>备注:' + d.detail.note + '</div><div class="aa-exp-sub">' + sub + '</div>' +
'</div></td></tr>' : '');
}
function render() { tbody.innerHTML = data.map(rowHtml).join(''); }
tbody.addEventListener('click', function (e) {
var btn = e.target.closest('.aa-exp-toggle');
if (!btn) return;
var id = btn.dataset.id;
if (openSet.has(id)) openSet.delete(id); else openSet.add(id);
render();
});
render();
</script>
</body>
</html>