diff --git a/index.html b/index.html index db9b630..6962e0b 100644 --- a/index.html +++ b/index.html @@ -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;