feat: show daily total revenue row

This commit is contained in:
2026-10-16 17:53:25 +08:00
parent 5483ccac03
commit 42e31a85be
+19
View File
@@ -460,6 +460,25 @@
headerRow.append(differenceT4Header);
head.append(headerRow);
const dailyTotals = totalsForDates(rows, dates);
const totalRow = document.createElement('tr');
const totalLabel = document.createElement('td');
totalLabel.textContent = '每日总收入';
totalRow.append(totalLabel);
dailyTotals.forEach((total) => {
const cell = document.createElement('td');
cell.textContent = money(total.value);
totalRow.append(cell);
});
const latestTotal = dailyTotals.length ? dailyTotals[dailyTotals.length - 1].value : null;
const previousTotal = dailyTotals.length > 1 ? dailyTotals[dailyTotals.length - 2].value : null;
const fourthPreviousTotal = dailyTotals.length >= 4 ? dailyTotals[dailyTotals.length - 4].value : null;
totalRow.append(
createDifferenceCell(previousTotal === null ? null : latestTotal - previousTotal),
createDifferenceCell(fourthPreviousTotal === null ? null : latestTotal - fourthPreviousTotal),
);
body.append(totalRow);
const pageCount = Math.max(1, Math.ceil(pivot.length / state.pageSize));
if (state.page > pageCount) state.page = pageCount;
const start = (state.page - 1) * state.pageSize;