diff --git a/public/css/admin-components.css b/public/css/admin-components.css index 6b6767e..5a27478 100644 --- a/public/css/admin-components.css +++ b/public/css/admin-components.css @@ -381,6 +381,17 @@ background:var(--adm-primary-tint-06, rgba(22, 119, 255, .06)); } +/* 趋势迷你图:bar 可点击(JS 渐进增强把 bar 渲染为 ) */ +.adm-mini-chart-bar-link{ + display:block; + cursor:pointer; + text-decoration:none; +} + +.adm-mini-chart-bar-link:hover{ + text-decoration:none; +} + /* 可复用:迷你排行(渐进增强:由 admin.js 渲染,页面无 JS 时为空但不影响表格) */ .adm-mini-rank{ display:flex; diff --git a/public/js/admin.js b/public/js/admin.js index 8191c2e..be7720c 100644 --- a/public/js/admin.js +++ b/public/js/admin.js @@ -153,6 +153,21 @@ max = 1; } + // 渐进增强:从下方表格复用“日期→订单集合”链接口径(避免硬编码 URL 规则)。 + var dateToHref = {}; + try { + var links = document.querySelectorAll('[data-role="platform-order-trend-7d"] a.link'); + links.forEach(function (a) { + var d = String((a.textContent || '')).trim(); + if (!d) { + return; + } + dateToHref[d] = String(a.getAttribute('href') || ''); + }); + } catch (e) { + dateToHref = {}; + } + // 清空(避免 SSR/重复执行污染) el.innerHTML = ''; @@ -160,11 +175,18 @@ var paid = Number(p && p.paid_sum ? p.paid_sum : 0); var h = Math.round(Math.max(6, (paid / max) * 72)); - var bar = document.createElement('div'); - bar.className = 'adm-mini-chart-bar'; - bar.style.height = h + 'px'; - var date = (p && p.date) ? String(p.date) : ''; + var href = (date && dateToHref[date]) ? String(dateToHref[date]) : ''; + + var bar = document.createElement(href ? 'a' : 'div'); + bar.className = 'adm-mini-chart-bar' + (href ? ' adm-mini-chart-bar-link' : ''); + bar.style.height = h + 'px'; + if (href) { + bar.setAttribute('href', href); + bar.setAttribute('role', 'link'); + bar.setAttribute('aria-label', '进入当日订单集合:' + date); + } + var countNum = Number(p && p.count != null ? p.count : 0); if (!isFinite(countNum) || countNum < 0) { countNum = 0; diff --git a/tests/Feature/AdminJsPlatformOrderTrend7dShouldReuseTableDateLinksSelectorTest.php b/tests/Feature/AdminJsPlatformOrderTrend7dShouldReuseTableDateLinksSelectorTest.php new file mode 100644 index 0000000..11e3727 --- /dev/null +++ b/tests/Feature/AdminJsPlatformOrderTrend7dShouldReuseTableDateLinksSelectorTest.php @@ -0,0 +1,20 @@ +assertStringContainsString('[data-role="platform-order-trend-7d"] a.link', $js); + + // 且支持 a/div 二选一(可点击则 ) + $this->assertStringContainsString("document.createElement(href ? 'a' : 'div')", $js); + $this->assertStringContainsString('adm-mini-chart-bar-link', $js); + } +}