feat: 前端充值信息展示 + 文档更新
- 表格新增充值电量列, 汇总卡新增充值统计 - README 更新精确计算说明与 XF_PRICE 配置 Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent) Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
This commit is contained in:
@@ -49,7 +49,7 @@ async function fetchCurrent() {
|
||||
function renderSummary(s) {
|
||||
if (!s || !s.record_count) {
|
||||
const empty = "--";
|
||||
["sRecordCount", "sTotalUsage", "sAvgUsage", "sRecharge", "sStartSurplus", "sEndSurplus"].forEach((id) => {
|
||||
["sRecordCount", "sTotalUsage", "sAvgUsage", "sRecharge", "sRechargeKwh", "sRechargeMoney", "sStartSurplus", "sEndSurplus"].forEach((id) => {
|
||||
$(id).textContent = empty;
|
||||
});
|
||||
return;
|
||||
@@ -57,7 +57,9 @@ function renderSummary(s) {
|
||||
$("sRecordCount").textContent = s.record_count + " 天";
|
||||
$("sTotalUsage").textContent = s.total_usage != null ? s.total_usage.toFixed(2) : "--";
|
||||
$("sAvgUsage").textContent = s.avg_usage != null ? s.avg_usage.toFixed(2) : "--";
|
||||
$("sRecharge").textContent = s.recharge_days;
|
||||
$("sRecharge").textContent = s.recharge_days != null ? s.recharge_days + " 次" : "--";
|
||||
$("sRechargeKwh").textContent = s.recharge_kwh != null ? s.recharge_kwh.toFixed(2) : "--";
|
||||
$("sRechargeMoney").textContent = s.recharge_money != null ? s.recharge_money.toFixed(2) : "--";
|
||||
$("sStartSurplus").textContent = s.start_surplus != null ? s.start_surplus.toFixed(2) : "--";
|
||||
$("sEndSurplus").textContent = s.end_surplus != null ? s.end_surplus.toFixed(2) : "--";
|
||||
}
|
||||
@@ -127,7 +129,7 @@ function renderChart(daily) {
|
||||
function renderHistory(daily) {
|
||||
const body = $("historyBody");
|
||||
if (!daily.length) {
|
||||
body.innerHTML = '<tr><td colspan="4" class="empty-td">暂无记录</td></tr>';
|
||||
body.innerHTML = '<tr><td colspan="5" class="empty-td">暂无记录</td></tr>';
|
||||
return;
|
||||
}
|
||||
// daily 是升序,表格显示降序(新→旧)
|
||||
@@ -135,10 +137,14 @@ function renderHistory(daily) {
|
||||
body.innerHTML = rows
|
||||
.map((d) => {
|
||||
const usageTxt = d.usage != null && d.usage >= 0 ? d.usage.toFixed(2) : "--";
|
||||
const rechargeTxt = d.recharge != null && d.recharge > 0
|
||||
? `<span class="tag auto">+${d.recharge.toFixed(2)}</span>`
|
||||
: "--";
|
||||
return `<tr>
|
||||
<td>${formatDateStr(d.date)}</td>
|
||||
<td>${d.surplus.toFixed(2)}</td>
|
||||
<td>${usageTxt}</td>
|
||||
<td>${rechargeTxt}</td>
|
||||
<td><span class="tag auto">自动</span></td>
|
||||
</tr>`;
|
||||
})
|
||||
|
||||
@@ -42,7 +42,9 @@
|
||||
<div class="summary-item"><div class="summary-value" id="sRecordCount">--</div><div class="summary-label">记录天数</div></div>
|
||||
<div class="summary-item"><div class="summary-value" id="sTotalUsage">--</div><div class="summary-label">月总耗电(度)</div></div>
|
||||
<div class="summary-item"><div class="summary-value" id="sAvgUsage">--</div><div class="summary-label">日均耗电(度)</div></div>
|
||||
<div class="summary-item"><div class="summary-value" id="sRecharge">--</div><div class="summary-label">疑似充值(天)</div></div>
|
||||
<div class="summary-item"><div class="summary-value" id="sRecharge">--</div><div class="summary-label">充值(次)</div></div>
|
||||
<div class="summary-item"><div class="summary-value" id="sRechargeKwh">--</div><div class="summary-label">充值电量(度)</div></div>
|
||||
<div class="summary-item"><div class="summary-value" id="sRechargeMoney">--</div><div class="summary-label">充值金额(元)</div></div>
|
||||
<div class="summary-item"><div class="summary-value" id="sStartSurplus">--</div><div class="summary-label">月初电量(度)</div></div>
|
||||
<div class="summary-item"><div class="summary-value" id="sEndSurplus">--</div><div class="summary-label">月末电量(度)</div></div>
|
||||
</div>
|
||||
@@ -60,6 +62,7 @@
|
||||
<th>日期</th>
|
||||
<th>剩余电量(度)</th>
|
||||
<th>日耗电(度)</th>
|
||||
<th>充值电量(度)</th>
|
||||
<th>记录方式</th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
Reference in New Issue
Block a user