refactor: 拆分通用资金工具为国信和华泰证券专属版本
- 移除原通用funds工具代码与配置 - 新增国信证券、华泰证券专属资金工具页面、样式与逻辑 - 为两个工具添加独立的鉴权配置 - 更新导航菜单,将原通用入口替换为两个券商专属入口 - 新增对应券商的SVG图标文件
This commit is contained in:
@@ -3,7 +3,8 @@
|
||||
<a class="tab" href="/go?systemId=Tools-weibo" data-key="weibo">微博跟踪</a>
|
||||
<a class="tab" href="/go?systemId=Tools-markets" data-key="markets">市场跟踪</a>
|
||||
<a class="tab" href="/go?systemId=Tools-wall-" data-key="wall">告知墙</a>
|
||||
<a class="tab" href="/go?systemId=Tools-funds" data-key="funds">本金变动池</a>
|
||||
<a class="tab" href="/go?systemId=Tools-funds_guoxin" data-key="funds_guoxin">国信证券</a>
|
||||
<a class="tab" href="/go?systemId=Tools-funds_huatai" data-key="funds_huatai">华泰证券</a>
|
||||
<a class="tab" href="/go?systemId=Tools-ccb_private_funds" data-key="ccb_private_funds">建行私募理财</a>
|
||||
<a class="tab" href="/go?systemId=Tools-cloud" data-key="cloud">云产品管理</a>
|
||||
<a class="tab" href="/go?systemId=Tools-weekly" data-key="weekly">工作周报</a>
|
||||
|
||||
@@ -10,7 +10,8 @@
|
||||
if (path.includes('/tools/weibo/')) key = 'weibo'
|
||||
else if (path.includes('/tools/markets/')) key = 'markets'
|
||||
else if (path.includes('/tools/wall/')) key = 'wall'
|
||||
else if (path.includes('/tools/funds/')) key = 'funds'
|
||||
else if (path.includes('/tools/funds_guoxin/')) key = 'funds_guoxin'
|
||||
else if (path.includes('/tools/funds_huatai/')) key = 'funds_huatai'
|
||||
else if (path.includes('/tools/ccb_private_funds/')) key = 'ccb_private_funds'
|
||||
else if (path.includes('/tools/cloud/')) key = 'cloud'
|
||||
else if (path.includes('/tools/weekly/')) key = 'weekly'
|
||||
|
||||
|
Before Width: | Height: | Size: 113 B After Width: | Height: | Size: 113 B |
@@ -0,0 +1,3 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100">
|
||||
<text y=".9em" font-size="90">📊</text>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 114 B |
@@ -1,7 +0,0 @@
|
||||
{
|
||||
"_comment": "资金流水工具的前端鉴权配置",
|
||||
"enable_auth_comment": "true:启用鉴权(需要从导航登录);false:完全放开访问资金工具",
|
||||
"enable_auth": true,
|
||||
"max_age_days_comment": "鉴权 cookie 的最大有效天数(1~365)",
|
||||
"max_age_days": 30
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"_comment": "国信证券-本金变动池的前端鉴权配置",
|
||||
"enable_auth_comment": "true:启用鉴权(需要从导航登录);false:完全放开访问",
|
||||
"enable_auth": true,
|
||||
"max_age_days_comment": "鉴权 cookie 的最大有效天数(1~365)",
|
||||
"max_age_days": 30,
|
||||
"cookieName_comment": "鉴权 Cookie 名称",
|
||||
"cookieName": "funds_guoxin_gate"
|
||||
}
|
||||
@@ -6,7 +6,7 @@ const logLocal = msg => { const b = logBox(); if (!b) return; const line = `${(w
|
||||
|
||||
let editingId = null;
|
||||
|
||||
const loadFlags = async () => { try { const r = await fetch('/api/flags'); const d = await r.json(); if (d && d.debug && d.debug.funds) { const sec = document.getElementById('funds-debug'); if (sec) sec.style.display = '' } } catch {}
|
||||
const loadFlags = async () => { try { const r = await fetch('/api/flags'); const d = await r.json(); if (d && d.debug && d.debug.funds_guoxin) { const sec = document.getElementById('funds-guoxin-debug'); if (sec) sec.style.display = '' } } catch {}
|
||||
}
|
||||
|
||||
const renderRows = rows => {
|
||||
@@ -39,9 +39,8 @@ const renderRows = rows => {
|
||||
const btnAdd = document.getElementById('btn-add');
|
||||
if (btnAdd) {
|
||||
btnAdd.textContent = '保存修改';
|
||||
btnAdd.classList.add('btn-primary'); // Optional: highlight
|
||||
btnAdd.classList.add('btn-primary');
|
||||
}
|
||||
// Scroll to top
|
||||
document.querySelector('.add-bar').scrollIntoView({ behavior: 'smooth' });
|
||||
});
|
||||
tdOps.appendChild(btnEdit);
|
||||
@@ -49,9 +48,9 @@ const renderRows = rows => {
|
||||
const btnDel = document.createElement('button'); btnDel.className='btn'; btnDel.textContent='涤旧'; btnDel.addEventListener('click', async () => {
|
||||
const ok = window.confirm('确认涤旧该条流水?')
|
||||
if (!ok) return
|
||||
try { await fetch('/api/debug/event', { method:'POST', headers:{'Content-Type':'application/json'}, body: JSON.stringify({ source:'funds', action:'delete', id:r.id }) }) } catch {}
|
||||
logLocal(`funds.delete id=${r.id}`)
|
||||
await fetch(`/api/funds/flows/${r.id}`, { method:'DELETE' })
|
||||
try { await fetch('/api/debug/event', { method:'POST', headers:{'Content-Type':'application/json'}, body: JSON.stringify({ source:'funds_guoxin', action:'delete', id:r.id }) }) } catch {}
|
||||
logLocal(`funds_guoxin.delete id=${r.id}`)
|
||||
await fetch(`/api/funds_guoxin/flows/${r.id}`, { method:'DELETE' })
|
||||
await loadFlows()
|
||||
})
|
||||
tdOps.appendChild(btnDel)
|
||||
@@ -64,7 +63,7 @@ const renderRows = rows => {
|
||||
}
|
||||
|
||||
const loadFlows = async () => {
|
||||
const st = document.getElementById('funds-status')
|
||||
const st = document.getElementById('funds-guoxin-status')
|
||||
const btnQ = document.getElementById('btn-load')
|
||||
if (st) { st.style.display=''; st.textContent='正在查询...' }
|
||||
if (btnQ) btnQ.disabled = true
|
||||
@@ -73,7 +72,7 @@ const loadFlows = async () => {
|
||||
const type = document.getElementById('type-filter').value || 'all'
|
||||
const kw = document.getElementById('kw').value || ''
|
||||
try {
|
||||
const r = await fetch(`/api/funds/flows?start=${encodeURIComponent(start)}&end=${encodeURIComponent(end)}&type=${encodeURIComponent(type)}&kw=${encodeURIComponent(kw)}`)
|
||||
const r = await fetch(`/api/funds_guoxin/flows?start=${encodeURIComponent(start)}&end=${encodeURIComponent(end)}&type=${encodeURIComponent(type)}&kw=${encodeURIComponent(kw)}`)
|
||||
const d = await r.json()
|
||||
if (d.ok) renderRows(d.rows)
|
||||
if (st) { st.style.display=''; st.textContent=`查询完成(${(d.rows||[]).length} 条)` }
|
||||
@@ -86,7 +85,7 @@ const loadFlows = async () => {
|
||||
}
|
||||
|
||||
const addFlow = async () => {
|
||||
const st = document.getElementById('funds-status')
|
||||
const st = document.getElementById('funds-guoxin-status')
|
||||
const btn = document.getElementById('btn-add')
|
||||
if (st) { st.style.display=''; st.textContent='正在新增...' }
|
||||
if (btn) btn.disabled = true
|
||||
@@ -106,11 +105,11 @@ const addFlow = async () => {
|
||||
|
||||
if (!editingId) {
|
||||
try {
|
||||
const dupRes = await fetch(`/api/funds/flows?start=${encodeURIComponent(date)}&end=${encodeURIComponent(date)}&type=all`)
|
||||
const dupRes = await fetch(`/api/funds_guoxin/flows?start=${encodeURIComponent(date)}&end=${encodeURIComponent(date)}&type=all`)
|
||||
const dupData = await dupRes.json()
|
||||
if (dupData.ok && Array.isArray(dupData.rows) && dupData.rows.length > 0) {
|
||||
const ok = window.confirm(`该日期已有 ${dupData.rows.length} 条记录,是否继续新增?`)
|
||||
if (!ok) { logLocal(`funds.add.cancel date=${date}`); return }
|
||||
if (!ok) { logLocal(`funds_guoxin.add.cancel date=${date}`); return }
|
||||
}
|
||||
} catch {}
|
||||
}
|
||||
@@ -119,8 +118,8 @@ const addFlow = async () => {
|
||||
|
||||
if (editingId) {
|
||||
try {
|
||||
await fetch(`/api/funds/flows/${editingId}`, { method:'PUT', headers:{'Content-Type':'application/json'}, body: JSON.stringify(body) })
|
||||
logLocal(`funds.update id=${editingId}`)
|
||||
await fetch(`/api/funds_guoxin/flows/${editingId}`, { method:'PUT', headers:{'Content-Type':'application/json'}, body: JSON.stringify(body) })
|
||||
logLocal(`funds_guoxin.update id=${editingId}`)
|
||||
if (st) { st.style.display=''; st.textContent='修改成功' }
|
||||
editingId = null;
|
||||
if (btn) btn.textContent = '新增';
|
||||
@@ -138,13 +137,12 @@ const addFlow = async () => {
|
||||
return;
|
||||
}
|
||||
|
||||
try { await fetch('/api/debug/event', { method:'POST', headers:{'Content-Type':'application/json'}, body: JSON.stringify({ source:'funds', action:'add', date, type, amount:(cents/100) }) }) } catch {}
|
||||
logLocal(`funds.add ${JSON.stringify({ date, type, amount:(cents/100) })}`)
|
||||
try { await fetch('/api/debug/event', { method:'POST', headers:{'Content-Type':'application/json'}, body: JSON.stringify({ source:'funds_guoxin', action:'add', date, type, amount:(cents/100) }) }) } catch {}
|
||||
logLocal(`funds_guoxin.add ${JSON.stringify({ date, type, amount:(cents/100) })}`)
|
||||
try {
|
||||
await fetch('/api/funds/flows', { method:'POST', headers:{'Content-Type':'application/json'}, body: JSON.stringify(body) })
|
||||
await fetch('/api/funds_guoxin/flows', { method:'POST', headers:{'Content-Type':'application/json'}, body: JSON.stringify(body) })
|
||||
if (st) { st.style.display=''; st.textContent='新增成功' }
|
||||
await loadFlows()
|
||||
// clear inputs
|
||||
document.getElementById('new-amount').value=''
|
||||
document.getElementById('new-bank').value=''
|
||||
document.getElementById('new-remark').value=''
|
||||
@@ -165,10 +163,10 @@ document.addEventListener('DOMContentLoaded', () => {
|
||||
const de = document.getElementById('date-end'); if (de) de.value = endOfYear
|
||||
const bl = document.getElementById('btn-load'); if (bl) bl.addEventListener('click', loadFlows)
|
||||
const ba = document.getElementById('btn-add'); if (ba) ba.addEventListener('click', addFlow)
|
||||
const be = document.getElementById('btn-export'); if (be) be.addEventListener('click', async () => { const start = document.getElementById('date-start').value||''; const end = document.getElementById('date-end').value||''; location.href = `/api/funds/export.csv?start=${encodeURIComponent(start)}&end=${encodeURIComponent(end)}` })
|
||||
const be = document.getElementById('btn-export'); if (be) be.addEventListener('click', async () => { const start = document.getElementById('date-start').value||''; const end = document.getElementById('date-end').value||''; location.href = `/api/funds_guoxin/export.csv?start=${encodeURIComponent(start)}&end=${encodeURIComponent(end)}` })
|
||||
const bcp = document.getElementById('fd-btn-copy'); if (bcp) bcp.addEventListener('click', async () => { try { await navigator.clipboard.writeText((logBox()&&logBox().textContent)||'') } catch {} })
|
||||
const brf = document.getElementById('fd-btn-refresh'); if (brf) brf.addEventListener('click', async () => { try { const r = await fetch('/api/debug/logs?limit=5000&channel=funds'); const d = await r.json(); if (d.ok) { const b = logBox(); if (b) { b.textContent = (d.lines||[]).join('\n'); b.scrollTop = b.scrollHeight } } } catch {} })
|
||||
const bcl = document.getElementById('fd-btn-clear'); if (bcl) bcl.addEventListener('click', async () => { try { await fetch('/api/debug/clear?channel=funds', { method: 'POST' }) } catch {}; const b = logBox(); if (b) b.textContent='' })
|
||||
const brf = document.getElementById('fd-btn-refresh'); if (brf) brf.addEventListener('click', async () => { try { const r = await fetch('/api/debug/logs?limit=5000&channel=funds_guoxin'); const d = await r.json(); if (d.ok) { const b = logBox(); if (b) { b.textContent = (d.lines||[]).join('\n'); b.scrollTop = b.scrollHeight } } } catch {} })
|
||||
const bcl = document.getElementById('fd-btn-clear'); if (bcl) bcl.addEventListener('click', async () => { try { await fetch('/api/debug/clear?channel=funds_guoxin', { method: 'POST' }) } catch {}; const b = logBox(); if (b) b.textContent='' })
|
||||
loadFlows()
|
||||
initTextEffect()
|
||||
})
|
||||
@@ -3,23 +3,10 @@
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
<title>财富好管家 · 本金变动池</title>
|
||||
<link rel="icon" href="/icons/funds.svg" type="image/svg+xml" />
|
||||
<title>国信证券 · 本金变动池</title>
|
||||
<link rel="icon" href="/icons/funds_guoxin.svg" type="image/svg+xml" />
|
||||
<link rel="stylesheet" href="/common/common.css" />
|
||||
<link rel="stylesheet" href="/tools/funds/funds.css" />
|
||||
|
||||
<!-- 吉祥字体 -->
|
||||
<link href="https://fonts.googleapis.com/css2?family=Ma+Shan+Zheng&family=TsangerYuMo&display=swap" rel="stylesheet">
|
||||
|
||||
<!-- 吉祥装饰图标 -->
|
||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/css/all.min.css">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
<title>财富好管家 · 本金变动池</title>
|
||||
<link rel="icon" href="/icons/funds.svg" type="image/svg+xml" />
|
||||
<link rel="stylesheet" href="/common/common.css" />
|
||||
<link rel="stylesheet" href="/tools/funds/funds.css" />
|
||||
<link rel="stylesheet" href="/tools/funds_guoxin/funds_guoxin.css" />
|
||||
|
||||
<!-- 吉祥字体 -->
|
||||
<link href="https://fonts.googleapis.com/css2?family=Ma+Shan+Zheng&family=TsangerYuMo&display=swap" rel="stylesheet">
|
||||
@@ -51,7 +38,7 @@
|
||||
<main class="container">
|
||||
<!-- 吉祥标题 -->
|
||||
<div class="lucky-header">
|
||||
<h1>💰 财富流转 · 生生不息</h1>
|
||||
<h1>💰 国信证券 · 本金变动池</h1>
|
||||
<p class="lucky-subtitle">记录每一分财富的来去,汇聚八方财源</p>
|
||||
</div>
|
||||
<section class="toolbar">
|
||||
@@ -67,7 +54,7 @@
|
||||
<button id="btn-export" class="btn">导出CSV</button>
|
||||
<button id="btn-settings" class="btn">设置</button>
|
||||
</section>
|
||||
<div id="funds-status" class="status" style="display:none"></div>
|
||||
<div id="funds-guoxin-status" class="status" style="display:none"></div>
|
||||
|
||||
<section class="add-bar">
|
||||
<input id="new-date" type="date" required />
|
||||
@@ -100,7 +87,7 @@
|
||||
</table>
|
||||
</section>
|
||||
|
||||
<section class="debug" id="funds-debug" style="display:none">
|
||||
<section class="debug" id="funds-guoxin-debug" style="display:none">
|
||||
<div class="debug-actions">
|
||||
<button id="fd-btn-copy" class="btn">复制调试信息</button>
|
||||
<button id="fd-btn-refresh" class="btn">刷新</button>
|
||||
@@ -111,6 +98,6 @@
|
||||
</main>
|
||||
|
||||
<script src="/common/common.js"></script>
|
||||
<script src="/tools/funds/funds.js"></script>
|
||||
<script src="/tools/funds_guoxin/funds_guoxin.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"_comment": "华泰证券-本金变动池的前端鉴权配置",
|
||||
"enable_auth_comment": "true:启用鉴权(需要从导航登录);false:完全放开访问",
|
||||
"enable_auth": true,
|
||||
"max_age_days_comment": "鉴权 cookie 的最大有效天数(1~365)",
|
||||
"max_age_days": 30,
|
||||
"cookieName_comment": "鉴权 Cookie 名称",
|
||||
"cookieName": "funds_huatai_gate"
|
||||
}
|
||||
@@ -0,0 +1,280 @@
|
||||
/* 华泰证券 · 本金变动池 - 暗黑专业风格 */
|
||||
|
||||
body {
|
||||
background: #1e1e1e;
|
||||
color: #cccccc;
|
||||
font-family: "Microsoft YaHei", "微软雅黑", "PingFang SC", "Helvetica Neue", Arial, sans-serif;
|
||||
min-height: 100vh;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.container {
|
||||
padding: 24px 0;
|
||||
width: 95%;
|
||||
margin: 0 auto;
|
||||
}
|
||||
|
||||
.page-header {
|
||||
margin-bottom: 24px;
|
||||
padding-bottom: 16px;
|
||||
border-bottom: 1px solid #3c3c3c;
|
||||
}
|
||||
|
||||
.page-header h1 {
|
||||
font-size: 1.5rem;
|
||||
font-weight: 600;
|
||||
color: #d4af37;
|
||||
margin: 0;
|
||||
letter-spacing: 1px;
|
||||
}
|
||||
|
||||
.toolbar, .add-bar {
|
||||
display: flex;
|
||||
gap: 10px;
|
||||
align-items: center;
|
||||
flex-wrap: wrap;
|
||||
margin-bottom: 16px;
|
||||
padding: 14px 16px;
|
||||
background: #252526;
|
||||
border: 1px solid #3c3c3c;
|
||||
border-radius: 6px;
|
||||
}
|
||||
|
||||
.btn {
|
||||
height: 36px;
|
||||
padding: 0 16px;
|
||||
border: 1px solid #555;
|
||||
background: #333333;
|
||||
color: #cccccc;
|
||||
border-radius: 4px;
|
||||
cursor: pointer;
|
||||
font-weight: 500;
|
||||
font-size: 0.875rem;
|
||||
font-family: inherit;
|
||||
transition: background 0.15s, border-color 0.15s;
|
||||
}
|
||||
|
||||
.btn:hover {
|
||||
background: #444444;
|
||||
border-color: #d4af37;
|
||||
color: #ffffff;
|
||||
}
|
||||
|
||||
.btn:disabled {
|
||||
opacity: 0.5;
|
||||
cursor: not-allowed;
|
||||
}
|
||||
|
||||
.btn-add {
|
||||
background: #5a4a1e;
|
||||
border-color: #8b7332;
|
||||
color: #f0e6c8;
|
||||
}
|
||||
|
||||
.btn-add:hover {
|
||||
background: #6b5a28;
|
||||
border-color: #d4af37;
|
||||
}
|
||||
|
||||
input, select {
|
||||
border: 1px solid #3c3c3c;
|
||||
border-radius: 4px;
|
||||
padding: 6px 10px;
|
||||
height: 36px;
|
||||
background: #1e1e1e;
|
||||
color: #cccccc;
|
||||
font-family: inherit;
|
||||
font-size: 0.875rem;
|
||||
transition: border-color 0.15s;
|
||||
}
|
||||
|
||||
input:focus, select:focus {
|
||||
outline: none;
|
||||
border-color: #d4af37;
|
||||
}
|
||||
|
||||
input::placeholder {
|
||||
color: #666666;
|
||||
}
|
||||
|
||||
/* 日期选择器暗色适配 */
|
||||
input[type="date"]::-webkit-calendar-picker-indicator {
|
||||
filter: invert(0.7);
|
||||
}
|
||||
|
||||
.table-wrap {
|
||||
overflow: hidden;
|
||||
border: 1px solid #3c3c3c;
|
||||
border-radius: 6px;
|
||||
background: #252526;
|
||||
}
|
||||
|
||||
table.flows {
|
||||
width: 100%;
|
||||
border-collapse: collapse;
|
||||
font-size: 0.875rem;
|
||||
table-layout: fixed;
|
||||
}
|
||||
|
||||
/* 列宽分配 */
|
||||
table.flows th:nth-child(1),
|
||||
table.flows td:nth-child(1) { width: 9%; }
|
||||
table.flows th:nth-child(2),
|
||||
table.flows td:nth-child(2) { width: 5%; }
|
||||
table.flows th:nth-child(3),
|
||||
table.flows td:nth-child(3) { width: 11%; }
|
||||
table.flows th:nth-child(4),
|
||||
table.flows td:nth-child(4) { width: 14%; }
|
||||
table.flows th:nth-child(5),
|
||||
table.flows td:nth-child(5) { width: 12%; }
|
||||
table.flows th:nth-child(6),
|
||||
table.flows td:nth-child(6) { width: 37%; }
|
||||
table.flows th:nth-child(7),
|
||||
table.flows td:nth-child(7) { width: 12%; }
|
||||
|
||||
table.flows th, table.flows td {
|
||||
padding: 10px 12px;
|
||||
border-bottom: 1px solid #333333;
|
||||
text-align: left;
|
||||
word-break: break-all;
|
||||
overflow-wrap: break-word;
|
||||
}
|
||||
|
||||
table.flows th {
|
||||
background: #2d2d2d;
|
||||
color: #d4af37;
|
||||
font-weight: 600;
|
||||
position: sticky;
|
||||
top: 0;
|
||||
z-index: 1;
|
||||
border-bottom: 2px solid #3c3c3c;
|
||||
}
|
||||
|
||||
table.flows tbody tr:hover td {
|
||||
background: #2a2d2e;
|
||||
}
|
||||
|
||||
table.flows tr.in td {
|
||||
border-left: 3px solid transparent;
|
||||
}
|
||||
|
||||
table.flows tr.in td:first-child {
|
||||
border-left-color: #d4af37;
|
||||
}
|
||||
|
||||
table.flows tr.out td {
|
||||
border-left: 3px solid transparent;
|
||||
}
|
||||
|
||||
table.flows tr.out td:first-child {
|
||||
border-left-color: #c1272d;
|
||||
}
|
||||
|
||||
table.flows td.amount {
|
||||
font-weight: 600;
|
||||
color: #cccccc;
|
||||
font-variant-numeric: tabular-nums;
|
||||
}
|
||||
|
||||
table.flows td.ending {
|
||||
font-weight: 700;
|
||||
color: #d4af37;
|
||||
font-variant-numeric: tabular-nums;
|
||||
}
|
||||
|
||||
.stats {
|
||||
margin: 20px 0;
|
||||
padding: 14px 16px;
|
||||
border: 1px solid #3c3c3c;
|
||||
border-radius: 6px;
|
||||
background: #252526;
|
||||
font-weight: 500;
|
||||
color: #999999;
|
||||
text-align: center;
|
||||
font-size: 0.875rem;
|
||||
}
|
||||
|
||||
.status {
|
||||
margin: 12px 0;
|
||||
padding: 10px 14px;
|
||||
border: 1px solid #555;
|
||||
background: #2d2d2d;
|
||||
color: #cccccc;
|
||||
border-radius: 4px;
|
||||
text-align: center;
|
||||
font-size: 0.875rem;
|
||||
}
|
||||
|
||||
.debug {
|
||||
margin: 12px 0;
|
||||
padding: 8px;
|
||||
border: 1px dashed #555;
|
||||
border-radius: 4px;
|
||||
}
|
||||
|
||||
.debug-actions {
|
||||
display: flex;
|
||||
gap: 8px;
|
||||
margin-bottom: 8px;
|
||||
}
|
||||
|
||||
.debug-output {
|
||||
height: 200px;
|
||||
overflow: auto;
|
||||
background: #1a1a1a;
|
||||
padding: 8px;
|
||||
font-family: Consolas, "Courier New", monospace;
|
||||
font-size: 12px;
|
||||
white-space: pre-wrap;
|
||||
color: #888888;
|
||||
border-radius: 4px;
|
||||
}
|
||||
|
||||
/* 滚动条暗色 */
|
||||
::-webkit-scrollbar {
|
||||
width: 8px;
|
||||
height: 8px;
|
||||
}
|
||||
::-webkit-scrollbar-track {
|
||||
background: #1e1e1e;
|
||||
}
|
||||
::-webkit-scrollbar-thumb {
|
||||
background: #555555;
|
||||
border-radius: 4px;
|
||||
}
|
||||
::-webkit-scrollbar-thumb:hover {
|
||||
background: #777777;
|
||||
}
|
||||
|
||||
/* 操作按钮 */
|
||||
table.flows td .btn {
|
||||
height: 28px;
|
||||
padding: 0 10px;
|
||||
font-size: 0.8rem;
|
||||
}
|
||||
|
||||
@media (max-width: 760px) {
|
||||
.toolbar, .add-bar {
|
||||
flex-direction: column;
|
||||
align-items: stretch;
|
||||
gap: 8px;
|
||||
padding: 12px;
|
||||
}
|
||||
|
||||
.toolbar input,
|
||||
.toolbar select,
|
||||
.add-bar input,
|
||||
.add-bar select {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.toolbar .btn,
|
||||
.btn-add {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
table.flows th, table.flows td {
|
||||
padding: 8px;
|
||||
font-size: 0.8rem;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,170 @@
|
||||
const fmtCN = n => n.toLocaleString('zh-CN', { minimumFractionDigits: 2, maximumFractionDigits: 2 })
|
||||
const parseAmount = s => { const x = String(s||'').replace(/[,\s]/g,''); const v = Number(x); if (!Number.isFinite(v)) return null; return Math.round(v*100) }
|
||||
const centsToText = c => fmtCN((c||0)/100)
|
||||
const logBox = () => document.getElementById('fd-output')
|
||||
const logLocal = msg => { const b = logBox(); if (!b) return; const line = `${(window.fmtCNDateTime?fmtCNDateTime(new Date()):new Date().toLocaleString('zh-CN'))} ${msg}`; b.textContent = (b.textContent||'') + (b.textContent?"\n":"") + line; b.scrollTop = b.scrollHeight }
|
||||
|
||||
let editingId = null;
|
||||
|
||||
const loadFlags = async () => { try { const r = await fetch('/api/flags'); const d = await r.json(); if (d && d.debug && d.debug.funds_huatai) { const sec = document.getElementById('funds-huatai-debug'); if (sec) sec.style.display = '' } } catch {}
|
||||
}
|
||||
|
||||
const renderRows = rows => {
|
||||
const tb = document.getElementById('flows-body'); if (!tb) return
|
||||
tb.innerHTML = ''
|
||||
let sumIn = 0, sumOut = 0
|
||||
for (const r of rows) {
|
||||
const tr = document.createElement('tr')
|
||||
tr.className = r.type === 'in' ? 'in' : 'out'
|
||||
const tdDate = document.createElement('td'); tdDate.textContent = r.date
|
||||
const tdType = document.createElement('td'); tdType.textContent = r.type === 'in' ? '汇入' : '汇出'
|
||||
const tdAmt = document.createElement('td'); tdAmt.className='amount'; tdAmt.textContent = centsToText(r.amount_cents)
|
||||
const tdBank = document.createElement('td'); tdBank.textContent = r.bank_status || ''
|
||||
const tdEnd = document.createElement('td'); tdEnd.className='ending'; tdEnd.textContent = centsToText(r.ending_cents)
|
||||
const tdRemark = document.createElement('td'); tdRemark.textContent = r.remark || ''
|
||||
const tdOps = document.createElement('td')
|
||||
|
||||
const btnEdit = document.createElement('button');
|
||||
btnEdit.className='btn';
|
||||
btnEdit.textContent='修改';
|
||||
btnEdit.style.marginRight = '4px';
|
||||
btnEdit.addEventListener('click', () => {
|
||||
document.getElementById('new-date').value = r.date;
|
||||
document.getElementById('new-type').value = r.type;
|
||||
document.getElementById('new-amount').value = (r.amount_cents / 100).toFixed(2);
|
||||
document.getElementById('new-bank').value = r.bank_status || '';
|
||||
document.getElementById('new-remark').value = r.remark || '';
|
||||
|
||||
editingId = r.id;
|
||||
const btnAdd = document.getElementById('btn-add');
|
||||
if (btnAdd) {
|
||||
btnAdd.textContent = '保存修改';
|
||||
}
|
||||
document.querySelector('.add-bar').scrollIntoView({ behavior: 'smooth' });
|
||||
});
|
||||
tdOps.appendChild(btnEdit);
|
||||
|
||||
const btnDel = document.createElement('button'); btnDel.className='btn'; btnDel.textContent='涤旧'; btnDel.addEventListener('click', async () => {
|
||||
const ok = window.confirm('确认涤旧该条流水?')
|
||||
if (!ok) return
|
||||
try { await fetch('/api/debug/event', { method:'POST', headers:{'Content-Type':'application/json'}, body: JSON.stringify({ source:'funds_huatai', action:'delete', id:r.id }) }) } catch {}
|
||||
logLocal(`funds_huatai.delete id=${r.id}`)
|
||||
await fetch(`/api/funds_huatai/flows/${r.id}`, { method:'DELETE' })
|
||||
await loadFlows()
|
||||
})
|
||||
tdOps.appendChild(btnDel)
|
||||
tr.appendChild(tdDate); tr.appendChild(tdType); tr.appendChild(tdAmt); tr.appendChild(tdBank); tr.appendChild(tdEnd); tr.appendChild(tdRemark); tr.appendChild(tdOps)
|
||||
tb.appendChild(tr)
|
||||
if (r.type==='in') sumIn += r.amount_cents; else sumOut += r.amount_cents
|
||||
}
|
||||
const st = document.getElementById('stats')
|
||||
if (st) st.textContent = `总汇入 ${centsToText(sumIn)} · 总汇出 ${centsToText(Math.abs(sumOut))} · 区间净变动 ${centsToText(sumIn + sumOut)} · 期末余额 ${rows.length?centsToText(rows[rows.length-1].ending_cents):centsToText(0)}`
|
||||
}
|
||||
|
||||
const loadFlows = async () => {
|
||||
const st = document.getElementById('funds-huatai-status')
|
||||
const btnQ = document.getElementById('btn-load')
|
||||
if (st) { st.style.display=''; st.textContent='正在查询...' }
|
||||
if (btnQ) btnQ.disabled = true
|
||||
const start = document.getElementById('date-start').value || ''
|
||||
const end = document.getElementById('date-end').value || ''
|
||||
const type = document.getElementById('type-filter').value || 'all'
|
||||
const kw = document.getElementById('kw').value || ''
|
||||
try {
|
||||
const r = await fetch(`/api/funds_huatai/flows?start=${encodeURIComponent(start)}&end=${encodeURIComponent(end)}&type=${encodeURIComponent(type)}&kw=${encodeURIComponent(kw)}`)
|
||||
const d = await r.json()
|
||||
if (d.ok) renderRows(d.rows)
|
||||
if (st) { st.style.display=''; st.textContent=`查询完成(${(d.rows||[]).length} 条)` }
|
||||
} catch (e) {
|
||||
if (st) { st.style.display=''; st.textContent=`查询失败:${String(e.message||e)}` }
|
||||
} finally {
|
||||
if (btnQ) btnQ.disabled = false
|
||||
setTimeout(()=>{ if (st) st.style.display='none' }, 1200)
|
||||
}
|
||||
}
|
||||
|
||||
const addFlow = async () => {
|
||||
const st = document.getElementById('funds-huatai-status')
|
||||
const btn = document.getElementById('btn-add')
|
||||
if (st) { st.style.display=''; st.textContent='正在新增...' }
|
||||
if (btn) btn.disabled = true
|
||||
const date = document.getElementById('new-date').value
|
||||
const type = document.getElementById('new-type').value
|
||||
const amtText = document.getElementById('new-amount').value
|
||||
const bank = document.getElementById('new-bank').value
|
||||
const remark = document.getElementById('new-remark').value
|
||||
if (!date || !type || !amtText || !bank || !remark) {
|
||||
if (st) { st.style.display=''; st.textContent='请完整填写日期、类型、金额、银行方/状态、备注' }
|
||||
if (btn) btn.disabled = false
|
||||
setTimeout(()=>{ if (st) st.style.display='none' }, 1800)
|
||||
return
|
||||
}
|
||||
const cents = parseAmount(amtText)
|
||||
if (cents === null) { logLocal('金额格式错误'); return }
|
||||
|
||||
if (!editingId) {
|
||||
try {
|
||||
const dupRes = await fetch(`/api/funds_huatai/flows?start=${encodeURIComponent(date)}&end=${encodeURIComponent(date)}&type=all`)
|
||||
const dupData = await dupRes.json()
|
||||
if (dupData.ok && Array.isArray(dupData.rows) && dupData.rows.length > 0) {
|
||||
const ok = window.confirm(`该日期已有 ${dupData.rows.length} 条记录,是否继续新增?`)
|
||||
if (!ok) { logLocal(`funds_huatai.add.cancel date=${date}`); return }
|
||||
}
|
||||
} catch {}
|
||||
}
|
||||
|
||||
const body = { date, type, amount_cents: type==='out' ? -Math.abs(cents) : Math.abs(cents), bank_status: bank, remark }
|
||||
|
||||
if (editingId) {
|
||||
try {
|
||||
await fetch(`/api/funds_huatai/flows/${editingId}`, { method:'PUT', headers:{'Content-Type':'application/json'}, body: JSON.stringify(body) })
|
||||
logLocal(`funds_huatai.update id=${editingId}`)
|
||||
if (st) { st.style.display=''; st.textContent='修改成功' }
|
||||
editingId = null;
|
||||
if (btn) btn.textContent = '新增';
|
||||
|
||||
await loadFlows()
|
||||
document.getElementById('new-amount').value=''
|
||||
document.getElementById('new-bank').value=''
|
||||
document.getElementById('new-remark').value=''
|
||||
} catch (e) {
|
||||
if (st) { st.style.display=''; st.textContent=`修改失败:${String(e.message||e)}` }
|
||||
} finally {
|
||||
if (btn) btn.disabled = false
|
||||
setTimeout(()=>{ if (st) st.style.display='none' }, 1200)
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
try { await fetch('/api/debug/event', { method:'POST', headers:{'Content-Type':'application/json'}, body: JSON.stringify({ source:'funds_huatai', action:'add', date, type, amount:(cents/100) }) }) } catch {}
|
||||
logLocal(`funds_huatai.add ${JSON.stringify({ date, type, amount:(cents/100) })}`)
|
||||
try {
|
||||
await fetch('/api/funds_huatai/flows', { method:'POST', headers:{'Content-Type':'application/json'}, body: JSON.stringify(body) })
|
||||
if (st) { st.style.display=''; st.textContent='新增成功' }
|
||||
await loadFlows()
|
||||
document.getElementById('new-amount').value=''
|
||||
document.getElementById('new-bank').value=''
|
||||
document.getElementById('new-remark').value=''
|
||||
} catch (e) {
|
||||
if (st) { st.style.display=''; st.textContent=`新增失败:${String(e.message||e)}` }
|
||||
} finally {
|
||||
if (btn) btn.disabled = false
|
||||
setTimeout(()=>{ if (st) st.style.display='none' }, 1200)
|
||||
}
|
||||
}
|
||||
|
||||
document.addEventListener('DOMContentLoaded', () => {
|
||||
loadFlags()
|
||||
const y = new Date().getFullYear()
|
||||
const d = new Date(y, 11, 31)
|
||||
const endOfYear = window.cnDateStr ? cnDateStr(d) : `${d.getFullYear()}-${String(d.getMonth()+1).padStart(2,'0')}-${String(d.getDate()).padStart(2,'0')}`
|
||||
const ds = document.getElementById('date-start'); if (ds) ds.value = '2024-01-01'
|
||||
const de = document.getElementById('date-end'); if (de) de.value = endOfYear
|
||||
const bl = document.getElementById('btn-load'); if (bl) bl.addEventListener('click', loadFlows)
|
||||
const ba = document.getElementById('btn-add'); if (ba) ba.addEventListener('click', addFlow)
|
||||
const be = document.getElementById('btn-export'); if (be) be.addEventListener('click', async () => { const start = document.getElementById('date-start').value||''; const end = document.getElementById('date-end').value||''; location.href = `/api/funds_huatai/export.csv?start=${encodeURIComponent(start)}&end=${encodeURIComponent(end)}` })
|
||||
const bcp = document.getElementById('fd-btn-copy'); if (bcp) bcp.addEventListener('click', async () => { try { await navigator.clipboard.writeText((logBox()&&logBox().textContent)||'') } catch {} })
|
||||
const brf = document.getElementById('fd-btn-refresh'); if (brf) brf.addEventListener('click', async () => { try { const r = await fetch('/api/debug/logs?limit=5000&channel=funds_huatai'); const d = await r.json(); if (d.ok) { const b = logBox(); if (b) { b.textContent = (d.lines||[]).join('\n'); b.scrollTop = b.scrollHeight } } } catch {} })
|
||||
const bcl = document.getElementById('fd-btn-clear'); if (bcl) bcl.addEventListener('click', async () => { try { await fetch('/api/debug/clear?channel=funds_huatai', { method: 'POST' }) } catch {}; const b = logBox(); if (b) b.textContent='' })
|
||||
loadFlows()
|
||||
})
|
||||
@@ -0,0 +1,76 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="zh-CN">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
<title>华泰证券 · 本金变动池</title>
|
||||
<link rel="icon" href="/icons/funds_huatai.svg" type="image/svg+xml" />
|
||||
<link rel="stylesheet" href="/common/common.css" />
|
||||
<link rel="stylesheet" href="/tools/funds_huatai/funds_huatai.css" />
|
||||
</head>
|
||||
<body>
|
||||
<main class="container">
|
||||
<div class="page-header">
|
||||
<h1>华泰证券 · 本金变动池</h1>
|
||||
</div>
|
||||
|
||||
<section class="toolbar">
|
||||
<input id="date-start" type="date" />
|
||||
<input id="date-end" type="date" />
|
||||
<select id="type-filter">
|
||||
<option value="all">全部</option>
|
||||
<option value="in">汇入</option>
|
||||
<option value="out">汇出</option>
|
||||
</select>
|
||||
<input id="kw" type="text" placeholder="银行/备注检索" />
|
||||
<button id="btn-load" class="btn">查询</button>
|
||||
<button id="btn-export" class="btn">导出CSV</button>
|
||||
<button id="btn-settings" class="btn">设置</button>
|
||||
</section>
|
||||
<div id="funds-huatai-status" class="status" style="display:none"></div>
|
||||
|
||||
<section class="add-bar">
|
||||
<input id="new-date" type="date" required />
|
||||
<select id="new-type" required>
|
||||
<option value="in">汇入</option>
|
||||
<option value="out">汇出</option>
|
||||
</select>
|
||||
<input id="new-amount" type="text" placeholder="金额(人民币),如 20,000.00 或 -5000" required />
|
||||
<input id="new-bank" type="text" placeholder="银行方/状态" required />
|
||||
<input id="new-remark" type="text" placeholder="备注" required />
|
||||
<button id="btn-add" class="btn btn-add">新增</button>
|
||||
</section>
|
||||
|
||||
<section class="stats" id="stats"></section>
|
||||
|
||||
<section class="table-wrap">
|
||||
<table class="flows" id="flows">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>日期</th>
|
||||
<th>类型</th>
|
||||
<th>金额(人民币)</th>
|
||||
<th>银行方/状态</th>
|
||||
<th>期末金额</th>
|
||||
<th>备注</th>
|
||||
<th>操作</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody id="flows-body"></tbody>
|
||||
</table>
|
||||
</section>
|
||||
|
||||
<section class="debug" id="funds-huatai-debug" style="display:none">
|
||||
<div class="debug-actions">
|
||||
<button id="fd-btn-copy" class="btn">复制调试信息</button>
|
||||
<button id="fd-btn-refresh" class="btn">刷新</button>
|
||||
<button id="fd-btn-clear" class="btn">清空</button>
|
||||
</div>
|
||||
<div id="fd-output" class="debug-output"></div>
|
||||
</section>
|
||||
</main>
|
||||
|
||||
<script src="/common/common.js"></script>
|
||||
<script src="/tools/funds_huatai/funds_huatai.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user