This commit is contained in:
admin
2025-12-22 17:30:32 +09:00
parent 87fa1aaa1f
commit 001b7bf08f
12 changed files with 1380 additions and 506 deletions

View File

@@ -0,0 +1,96 @@
<!DOCTYPE html>
<html lang="ja">
<head>
<meta charset="UTF-8" />
<title>资金流水</title>
</head>
<body>
<h2>📄 资金流水</h2>
<div>
<label>账户ID</label>
<input id="accountId" type="number" value="101" style="width: 80px" />
<label>从:</label>
<input id="fromDate" type="date" />
<label>到:</label>
<input id="toDate" type="date" />
<button onclick="loadTransactions()">查询</button>
</div>
<table
border="1"
cellpadding="6"
style="margin-top: 10px; border-collapse: collapse"
>
<thead>
<tr>
<th>日期</th>
<th>摘要</th>
<th style="text-align: right">金额</th>
</tr>
</thead>
<tbody id="txBody">
<tr>
<td colspan="3">请输入条件后查询</td>
</tr>
</tbody>
</table>
<script>
function formatYen(v) {
return "¥ " + Number(v).toLocaleString("ja-JP");
}
async function loadTransactions() {
const accountId = document.getElementById("accountId").value;
const from = document.getElementById("fromDate").value;
const to = document.getElementById("toDate").value;
let url = `/cash/transactions?account_id=${accountId}`;
if (from) url += `&from=${from}`;
if (to) url += `&to=${to}`;
const body = document.getElementById("txBody");
body.innerHTML = "<tr><td colspan='3'>读取中...</td></tr>";
try {
const res = await fetch(url);
const data = await res.json();
body.innerHTML = "";
if (data.length === 0) {
body.innerHTML = "<tr><td colspan='3'>无数据</td></tr>";
return;
}
data.forEach((row) => {
const tr = document.createElement("tr");
tr.innerHTML = `
<td>${row.journal_date}</td>
<td>${row.description}</td>
<td style="text-align:right;color:${row.amount < 0 ? "red" : "black"};">
${formatYen(row.amount)}
</td>
`;
body.appendChild(tr);
});
} catch (e) {
body.innerHTML = "<tr><td colspan='3'>读取失败</td></tr>";
}
}
function getQueryParam(name) {
const params = new URLSearchParams(window.location.search);
return params.get(name);
}
window.onload = () => {
const accountId = getQueryParam("account_id");
if (accountId) {
document.getElementById("accountId").value = accountId;
loadTransactions();
}
};
</script>
</body>
</html>

View File

@@ -0,0 +1,76 @@
<!DOCTYPE html>
<html lang="ja">
<head>
<meta charset="UTF-8" />
<title>资金余额</title>
</head>
<body>
<h2>💰 当前资金状况</h2>
<table border="1" cellpadding="6" style="border-collapse: collapse">
<thead>
<tr style="background: #f5f5f5">
<th>账户</th>
<th style="text-align: right">余额</th>
</tr>
</thead>
<tbody id="cashBalanceBody">
<tr>
<td colspan="2">读取中...</td>
</tr>
</tbody>
<tfoot>
<tr style="font-weight: bold">
<td>合计</td>
<td id="cashBalanceTotal" style="text-align: right">-</td>
</tr>
</tfoot>
</table>
<script>
const API_BASE = "http://127.0.0.1:8080";
function formatYen(v) {
return "¥ " + Number(v).toLocaleString("ja-JP");
}
async function loadCashBalance() {
const body = document.getElementById("cashBalanceBody");
const totalEl = document.getElementById("cashBalanceTotal");
try {
const res = await fetch("/cash/balance");
const data = await res.json();
body.innerHTML = "";
data.items.forEach((item) => {
const tr = document.createElement("tr");
tr.style.cursor = "pointer";
tr.onclick = () => {
window.location.href = `/cash-transactions.html?account_id=${item.account_id}`;
};
tr.innerHTML = `
<td style="color:#007acc; text-decoration:underline;">
${item.account_name}
</td>
<td style="text-align:right;">
${formatYen(item.balance)}
</td>
`;
tbody.appendChild(tr);
});
totalEl.innerText = formatYen(data.total_balance);
} catch (e) {
body.innerHTML = `<tr><td colspan="2">读取失败</td></tr>`;
}
}
window.addEventListener("DOMContentLoaded", loadCashBalance);
</script>
</body>
</html>