fix(HEL-80): 接通复杂页表格排序(情绪历史/竞价/轮动/题材/龙虎内嵌表)
Co-authored-by: multica-agent <github@multica.ai>
This commit is contained in:
+39
-24
@@ -109,6 +109,7 @@
|
||||
seq: 0,
|
||||
calCursor: null,
|
||||
sort: { key: "", dir: null },
|
||||
sortTable: { cols: null, reapply: null },
|
||||
detail: null,
|
||||
sentimentHistory: null,
|
||||
sentimentRange: 20,
|
||||
@@ -189,10 +190,9 @@
|
||||
}
|
||||
|
||||
function toggleSort(key) {
|
||||
const cfg = pageConfig(state.key);
|
||||
if (!cfg) return;
|
||||
const cols = columnsFor(cfg);
|
||||
const col = findColumn(cols, key);
|
||||
const active = state.sortTable;
|
||||
if (!active || !active.cols) return;
|
||||
const col = findColumn(active.cols, key);
|
||||
if (!col || !sortableColumn(col)) return;
|
||||
const firstDir = isNumericType(col.type) ? "desc" : "asc";
|
||||
if (state.sort.key !== key) {
|
||||
@@ -202,7 +202,7 @@
|
||||
} else {
|
||||
state.sort = { key: "", dir: null };
|
||||
}
|
||||
renderTableBody();
|
||||
active.reapply();
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------- cells */
|
||||
@@ -670,6 +670,7 @@
|
||||
const cfg = pageConfig(key);
|
||||
if (!cfg) return;
|
||||
const cols = columnsFor(cfg);
|
||||
state.sortTable = { cols: cols, reapply: renderTableBody };
|
||||
const rows = sortedRows(prepareRows(key), cols);
|
||||
const scroll = document.getElementById("m-table-scroll");
|
||||
if (!scroll) return;
|
||||
@@ -728,11 +729,21 @@
|
||||
return cfg || null;
|
||||
}
|
||||
|
||||
function tableScrollHtml(subKey, rows, opts) {
|
||||
function mountSortableTable(containerId, subKey, rowsProvider, opts) {
|
||||
const cols = columnsForKey(subKey);
|
||||
if (!cols) return emptyHtml();
|
||||
if (!rows || !rows.length) return emptyHtml();
|
||||
return '<div class="m-table-wrap">' + buildTable(cols, rows, opts || {}) + "</div>";
|
||||
if (!cols) return;
|
||||
const reapply = function () {
|
||||
const container = document.getElementById(containerId);
|
||||
if (!container) return;
|
||||
const rows = sortedRows(rowsProvider() || [], cols);
|
||||
if (!rows.length) {
|
||||
container.innerHTML = emptyHtml();
|
||||
return;
|
||||
}
|
||||
container.innerHTML = buildTable(cols, rows, opts || {});
|
||||
};
|
||||
state.sortTable = { cols: cols, reapply: reapply };
|
||||
reapply();
|
||||
}
|
||||
|
||||
function complexFrame(key, bodyHtml) {
|
||||
@@ -750,6 +761,7 @@
|
||||
state.popularity = null;
|
||||
state.calCursor = null;
|
||||
state.sort = { key: "", dir: null };
|
||||
state.sortTable = { cols: null, reapply: null };
|
||||
state.detail = null;
|
||||
state.sentimentHistory = null;
|
||||
state.rotation = null;
|
||||
@@ -876,7 +888,6 @@
|
||||
const history = state.sentimentHistory || {};
|
||||
const rawRows = history.rows || [];
|
||||
const latest = rawRows.length ? rawRows[rawRows.length - 1] : null;
|
||||
const tableRows = rawRows.slice().reverse();
|
||||
|
||||
let card = "";
|
||||
if (latest) {
|
||||
@@ -908,13 +919,15 @@
|
||||
return '<button class="m-range-tab' + (active ? " active" : "") + '" type="button" data-sentiment-range="' + n + '" aria-pressed="' + (active ? "true" : "false") + '">' + n + "日</button>";
|
||||
}).join("");
|
||||
|
||||
const histRows = tableRows.map(function (r) {
|
||||
return Object.assign({}, r, { trade_date: displayCompactDate(r.trade_date) });
|
||||
});
|
||||
|
||||
scroll.innerHTML = card +
|
||||
'<div class="m-section-title">历史明细 <span class="m-range-tabs">' + rangeTabs + "</span></div>" +
|
||||
tableScrollHtml("market/sentiment/history", histRows, {});
|
||||
'<div class="m-table-wrap" id="m-sentiment-hist"></div>';
|
||||
mountSortableTable("m-sentiment-hist", "market/sentiment/history", function () {
|
||||
const raw = (state.sentimentHistory && state.sentimentHistory.rows) || [];
|
||||
return raw.slice().reverse().map(function (r) {
|
||||
return Object.assign({}, r, { trade_date: displayCompactDate(r.trade_date) });
|
||||
});
|
||||
}, {});
|
||||
}
|
||||
|
||||
function sentMetric(label, valueHtml, tone) {
|
||||
@@ -1109,10 +1122,12 @@
|
||||
if (!body) return;
|
||||
if (payload.error) { body.innerHTML = emptyHtml(); return; }
|
||||
const meta = payload.meta || {};
|
||||
const rows = payload.rows || [];
|
||||
const metaLine = '<div class="m-sheet-meta">' + escapeHtml(displayCompactDate(meta.trade_date) || "--") +
|
||||
" · " + number(meta.quoted_count) + " / " + number(meta.member_count) + " 只</div>";
|
||||
body.innerHTML = metaLine + tableScrollHtml("market/rotation/members", rows, { noLink: true });
|
||||
body.innerHTML = metaLine + '<div class="m-table-wrap" id="m-rotation-members-table"></div>';
|
||||
mountSortableTable("m-rotation-members-table", "market/rotation/members", function () {
|
||||
return (state.rotationMembers && state.rotationMembers.rows) || [];
|
||||
}, { noLink: true });
|
||||
}
|
||||
|
||||
/* ----- 竞价 ----- */
|
||||
@@ -1226,11 +1241,7 @@
|
||||
}
|
||||
|
||||
function renderAuctionTable() {
|
||||
const table = document.getElementById("m-auction-table");
|
||||
if (!table) return;
|
||||
const rows = auctionRows();
|
||||
if (!rows.length) { table.innerHTML = emptyHtml(); return; }
|
||||
table.innerHTML = buildTable(columnsForKey("market/auction"), rows);
|
||||
mountSortableTable("m-auction-table", "market/auction", auctionRows, {});
|
||||
}
|
||||
|
||||
/* ----- 题材库 ----- */
|
||||
@@ -1325,7 +1336,10 @@
|
||||
'<div class="m-theme-detail-code">' + escapeHtml(theme.code || "--") + " · " + escapeHtml(displayCompactDate(meta.trade_date) || "--") + "</div>" +
|
||||
'<div class="m-sum-strip">' + metrics + "</div>" +
|
||||
'<div class="m-section-title">成分股</div>' +
|
||||
tableScrollHtml("market/themes/members", payload.members || [], { noLink: true });
|
||||
'<div class="m-table-wrap" id="m-theme-members-table"></div>';
|
||||
mountSortableTable("m-theme-members-table", "market/themes/members", function () {
|
||||
return (state.themesDetail && state.themesDetail.members) || [];
|
||||
}, { noLink: true });
|
||||
}
|
||||
|
||||
/* ----- 龙虎榜 ----- */
|
||||
@@ -1466,10 +1480,11 @@
|
||||
totRow("卖出", trader.sell_million, "down") +
|
||||
totRow("净额", trader.net_buy_million, changeClass(trader.net_buy_million)) +
|
||||
"</div>" +
|
||||
tableScrollHtml("market/dragon/operations", ops, { noLink: true }) +
|
||||
'<div class="m-table-wrap" id="m-dragon-ops-table"></div>' +
|
||||
"</div>",
|
||||
{ detail: true }
|
||||
);
|
||||
mountSortableTable("m-dragon-ops-table", "market/dragon/operations", function () { return ops; }, { noLink: true });
|
||||
}
|
||||
|
||||
function totRow(label, value, cls) {
|
||||
|
||||
Reference in New Issue
Block a user