diff --git a/manual_trading_hub/static/app.css b/manual_trading_hub/static/app.css index f2b6bd8..f8cd047 100644 --- a/manual_trading_hub/static/app.css +++ b/manual_trading_hub/static/app.css @@ -8670,6 +8670,25 @@ body.funds-fullscreen-open { background: var(--panel); overscroll-behavior: contain; } +.archive-trades-pager { + display: flex; + align-items: center; + gap: 8px; + margin-top: 8px; + font-size: 0.74rem; + color: var(--muted); +} +.archive-trades-pager[hidden] { + display: none !important; +} +.archive-trades-pager .ghost { + font-size: 0.72rem; + padding: 2px 8px; +} +.archive-trades-pager .ghost:disabled { + opacity: 0.45; + cursor: not-allowed; +} .archive-trades-table { width: 100%; min-width: 1000px; diff --git a/manual_trading_hub/static/archive.js b/manual_trading_hub/static/archive.js index 78a9824..3be3f9c 100644 --- a/manual_trading_hub/static/archive.js +++ b/manual_trading_hub/static/archive.js @@ -45,8 +45,13 @@ const elMarkAuto = document.getElementById("archive-mark-auto"); const elTrades = document.getElementById("archive-trades"); const elTradesSection = document.getElementById("archive-trades-section"); + const elTradesPager = document.getElementById("archive-trades-pager"); + const elTradesPrev = document.getElementById("archive-trades-prev"); + const elTradesNext = document.getElementById("archive-trades-next"); + const elTradesPageLabel = document.getElementById("archive-trades-page-label"); const ARCHIVE_MARK_AUTO_KEY = "hubArchiveMarkAuto"; - const TRADES_VISIBLE_ROWS_CHART_OPEN = 10; + const TRADES_PAGE_SIZE = 5; + const TRADES_VISIBLE_ROWS_CHART_OPEN = 5; const TF_MS = { "5m": 5 * 60_000, @@ -61,6 +66,7 @@ let selectedQuoteId = null; let editingQuoteId = null; let dailyTrades = []; + let tradesPage = 0; let dailyStats = { open_count: 0, by_exchange: {} }; let periodMode = "today"; let periodLabel = ""; @@ -1487,6 +1493,16 @@ ); } + function ensureTradePageVisible(tr) { + if (!tr || !dailyTrades.length) return; + const key = tradeRowKey(tr); + const idx = dailyTrades.findIndex(function (t) { + return tradeRowKey(t) === key; + }); + if (idx < 0) return; + tradesPage = Math.floor(idx / TRADES_PAGE_SIZE); + } + async function switchToTrade(tr) { if (!tr) return; const exKey = String(tr.exchange_key || "").toLowerCase(); @@ -1502,6 +1518,7 @@ selected = { exchange_key: exKey, symbol: sym }; selectedTradeKey = key; + ensureTradePageVisible(tr); renderTrades(); const needSymbolReload = prevEx !== exKey || prevSym !== sym; @@ -1535,19 +1552,49 @@ await switchToTrade(tr); } + function tradesPageCount() { + return Math.max(1, Math.ceil((dailyTrades.length || 0) / TRADES_PAGE_SIZE)); + } + + function clampTradesPage() { + const pages = tradesPageCount(); + if (tradesPage >= pages) tradesPage = pages - 1; + if (tradesPage < 0) tradesPage = 0; + } + + function updateTradesPager() { + clampTradesPage(); + const pages = tradesPageCount(); + const show = dailyTrades.length > TRADES_PAGE_SIZE; + if (elTradesPager) elTradesPager.hidden = !show; + if (elTradesPageLabel) { + elTradesPageLabel.textContent = "第 " + (tradesPage + 1) + " / " + pages + " 页"; + } + if (elTradesPrev) elTradesPrev.disabled = tradesPage <= 0; + if (elTradesNext) elTradesNext.disabled = tradesPage + 1 >= pages; + } + + function pagedDailyTrades() { + clampTradesPage(); + const start = tradesPage * TRADES_PAGE_SIZE; + return dailyTrades.slice(start, start + TRADES_PAGE_SIZE); + } + function renderTrades() { if (!elTrades) return; if (!dailyTrades.length) { elTrades.innerHTML = '

该日暂无交易记录.可调整日期或点击「同步」拉取数据.

'; + updateTradesPager(); return; } + const pageRows = pagedDailyTrades(); elTrades.innerHTML = '' + "" + "" + "" + - dailyTrades + pageRows .map(function (t) { const tid = t.trade_id || t.id; const exKey = String(t.exchange_key || "").toLowerCase(); @@ -1643,6 +1690,8 @@ .join("") + "
交易所合约开仓类型开仓时间平仓时间持仓时长方向结果盈亏成交额手续费标签备注操作
"; + updateTradesPager(); + elTrades.querySelectorAll(".archive-del-btn").forEach(function (btn) { btn.addEventListener("click", function (ev) { ev.stopPropagation(); @@ -1781,6 +1830,7 @@ if (elQuoteDate && tradingDay && !elQuoteDate.value) elQuoteDate.value = tradingDay; syncPeriodUI(); dailyTrades = j.trades || []; + tradesPage = 0; dailyStats = j.stats || { open_count: 0, by_exchange: {} }; if (periodMode === "today" && tradingDay) { selectedCalendarDay = tradingDay; @@ -1852,6 +1902,20 @@ function bindEvents() { if (elBtnRefresh) elBtnRefresh.addEventListener("click", loadDailyTrades); if (elBtnSync) elBtnSync.addEventListener("click", syncAll); + if (elTradesPrev) { + elTradesPrev.addEventListener("click", function () { + if (tradesPage <= 0) return; + tradesPage -= 1; + renderTrades(); + }); + } + if (elTradesNext) { + elTradesNext.addEventListener("click", function () { + if (tradesPage + 1 >= tradesPageCount()) return; + tradesPage += 1; + renderTrades(); + }); + } if (elExchange) { elExchange.addEventListener("change", function () { void loadDailyTrades(); diff --git a/manual_trading_hub/static/index.html b/manual_trading_hub/static/index.html index 47fa7f2..b6eb5c2 100644 --- a/manual_trading_hub/static/index.html +++ b/manual_trading_hub/static/index.html @@ -15,7 +15,7 @@ - + @@ -544,6 +544,11 @@
交易记录
+
@@ -1311,7 +1316,7 @@ - +