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