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>`;
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user