feat(admin-dashboard): add mini share chart for plan order top5
This commit is contained in:
@@ -195,6 +195,68 @@
|
||||
});
|
||||
})();
|
||||
|
||||
// 仪表盘:迷你占比(套餐订单占比 Top5)
|
||||
(function () {
|
||||
var el = qs('[data-role="plan-order-share-top5-chart"][data-points]');
|
||||
if (!el) {
|
||||
return;
|
||||
}
|
||||
|
||||
var raw = el.getAttribute('data-points') || '[]';
|
||||
var points = [];
|
||||
try {
|
||||
points = JSON.parse(raw) || [];
|
||||
} catch (e) {
|
||||
points = [];
|
||||
}
|
||||
|
||||
var total = Number(el.getAttribute('data-total') || 0);
|
||||
if (!total || total <= 0) {
|
||||
total = 0;
|
||||
}
|
||||
|
||||
if (!points || points.length === 0 || total === 0) {
|
||||
el.classList.add('is-empty');
|
||||
el.textContent = '暂无占比数据';
|
||||
return;
|
||||
}
|
||||
|
||||
el.innerHTML = '';
|
||||
|
||||
points.forEach(function (p, idx) {
|
||||
var cnt = Number(p && p.count ? p.count : 0);
|
||||
var ratio = total > 0 ? Math.max(0, Math.min(1, cnt / total)) : 0;
|
||||
|
||||
var row = document.createElement('div');
|
||||
row.className = 'adm-mini-share-row';
|
||||
|
||||
var name = document.createElement('div');
|
||||
name.className = 'adm-mini-share-name';
|
||||
name.textContent = '#' + (idx + 1);
|
||||
|
||||
var wrap = document.createElement('div');
|
||||
wrap.className = 'adm-mini-share-bar-wrap';
|
||||
|
||||
var bar = document.createElement('div');
|
||||
bar.className = 'adm-mini-share-bar';
|
||||
bar.style.width = Math.round(ratio * 100) + '%';
|
||||
|
||||
wrap.appendChild(bar);
|
||||
|
||||
var val = document.createElement('div');
|
||||
val.className = 'adm-mini-share-value';
|
||||
val.textContent = (ratio * 100).toFixed(1) + '%';
|
||||
|
||||
row.title = 'Top' + (idx + 1) + ':' + cnt + ' 单,占比 ' + (ratio * 100).toFixed(1) + '%';
|
||||
|
||||
row.appendChild(name);
|
||||
row.appendChild(wrap);
|
||||
row.appendChild(val);
|
||||
|
||||
el.appendChild(row);
|
||||
});
|
||||
})();
|
||||
|
||||
// 通用:将后端 flash 信息同步到 toast(更像 Ant Design Pro 的反馈方式)
|
||||
// 说明:渐进增强。页面仍保留原本的提示块,不依赖 JS。
|
||||
(function () {
|
||||
|
||||
Reference in New Issue
Block a user