HEL-156 返工:起算日读 settings、动态状态列头、明细默认收起
首页 from 取自 /api/admin/settings 的 start_date 并省略 cutoff; 状态列头按 period_month 显示;renderDashDetail 二级默认全部收起。 Co-authored-by: Cursor <cursoragent@cursor.com> Co-authored-by: multica-agent <github@multica.ai>
This commit is contained in:
co-authored by
Cursor
multica-agent
parent
609ebffdc9
commit
815b68c1fc
+20
-9
@@ -1152,7 +1152,7 @@ function chevronSvg(expanded) {
|
||||
return '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.7" style="width:12px;height:12px;display:inline-block;vertical-align:-1px;margin-right:6px;"><path d="m9 18 6-6-6-6"/></svg>';
|
||||
}
|
||||
|
||||
function renderDashDetail(payload, { expandFirst = true } = {}) {
|
||||
function renderDashDetail(payload, { expandFirst = false } = {}) {
|
||||
const tbody = $("#dashDetailRows");
|
||||
const title = $("#dashDetailTitle");
|
||||
if (!tbody) return;
|
||||
@@ -1204,15 +1204,28 @@ function renderDashDetail(payload, { expandFirst = true } = {}) {
|
||||
tbody.replaceChildren(...rows);
|
||||
}
|
||||
|
||||
async function resolveDashStartDate() {
|
||||
if (state.dashFrom) return state.dashFrom;
|
||||
const response = await fetch("/api/admin/settings").catch(() => null);
|
||||
if (response?.ok) {
|
||||
const result = await response.json().catch(() => null);
|
||||
const startDate = result?.settings?.start_date;
|
||||
if (startDate) {
|
||||
state.dashFrom = startDate;
|
||||
return startDate;
|
||||
}
|
||||
}
|
||||
return "2026-01-01";
|
||||
}
|
||||
|
||||
async function loadDashCompanyDetail(companyId) {
|
||||
if (!companyId) return;
|
||||
state.dashSelectedId = companyId;
|
||||
renderDashCompanyRows(state.dashCompanies || [], companyId);
|
||||
const tbody = $("#dashDetailRows");
|
||||
if (tbody) tbody.innerHTML = '<tr class="loading-row"><td colspan="6">加载中…</td></tr>';
|
||||
const from = state.dashFrom || "2026-01-01";
|
||||
const cutoff = state.dashCutoff || "2026-08-20";
|
||||
const response = await fetch(`/api/admin/dashboard/companies/${companyId}?from=${encodeURIComponent(from)}&cutoff=${encodeURIComponent(cutoff)}`).catch(() => null);
|
||||
const from = await resolveDashStartDate();
|
||||
const response = await fetch(`/api/admin/dashboard/companies/${companyId}?from=${encodeURIComponent(from)}`).catch(() => null);
|
||||
if (!response?.ok) {
|
||||
if (tbody) tbody.innerHTML = '<tr><td colspan="6" class="muted">明细加载失败</td></tr>';
|
||||
return;
|
||||
@@ -1223,7 +1236,8 @@ async function loadDashCompanyDetail(companyId) {
|
||||
|
||||
async function loadAdminDashboard() {
|
||||
if (!$("#dashCompanyRows")) return;
|
||||
const response = await fetch("/api/admin/dashboard?from=2026-01-01&cutoff=2026-08-20").catch(() => null);
|
||||
const from = await resolveDashStartDate();
|
||||
const response = await fetch(`/api/admin/dashboard?from=${encodeURIComponent(from)}`).catch(() => null);
|
||||
if (!response?.ok) {
|
||||
$("#dashCompanyRows").innerHTML = '<tr><td colspan="4" class="muted">总览加载失败</td></tr>';
|
||||
return;
|
||||
@@ -1239,10 +1253,7 @@ async function loadAdminDashboard() {
|
||||
updateDashAuditCard(data.audit);
|
||||
state.dashAuditFromApi = true;
|
||||
const statusHead = $("#dashStatusHead");
|
||||
if (statusHead) {
|
||||
// Align with the static「7 月账期」cards on the same page until monthly-close exists.
|
||||
statusHead.textContent = "7月状态";
|
||||
}
|
||||
if (statusHead && data.period_month) statusHead.textContent = `${data.period_month}月状态`;
|
||||
const listSub = $("#dashListSub");
|
||||
if (listSub) listSub.textContent = `${data.from_date} 至 ${data.cutoff} · 单位:万元`;
|
||||
renderBarChart(state.dashCompanies);
|
||||
|
||||
Reference in New Issue
Block a user