Persist options review deletes across local resync.

Hide deleted rows by history key and contract/close fingerprint so local options_trades imports no longer resurrect them.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
dekun
2026-07-17 10:03:00 +08:00
parent 48afc8ebe3
commit d7272c9722
9 changed files with 339 additions and 14 deletions
+25 -5
View File
@@ -1831,12 +1831,19 @@
}
}
async function deleteHistoryRow(key, status) {
async function deleteHistoryRow(key, status, instId, closedAt) {
const warn = status === "open"
? "该记录仍为持仓中,仅从列表隐藏,不影响交易所持仓.确认删除?"
: "确认从列表隐藏该条历史记录?";
: "确认从列表隐藏该条历史记录?(期权复盘页也会同步隐藏)";
if (!confirm(warn)) return;
const r = await apiJson("/api/options/history/" + encodeURIComponent(key), { method: "DELETE" });
const body = {};
if (instId) body.inst_id = instId;
if (closedAt) body.closed_at = closedAt;
const r = await apiJson("/api/options/history/" + encodeURIComponent(key), {
method: "DELETE",
headers: { "Content-Type": "application/json" },
body: JSON.stringify(body),
});
if (!r.ok) {
alert(r.msg || "删除失败");
return;
@@ -1885,12 +1892,25 @@
"<td>" + optHistoryStatusHtml(h) + "</td>" +
'<td class="' + pnlCls + '">' + pnlTxt + "</td>" +
'<td class="opt-hist-time">' + timeTxt + "</td>" +
'<td><button type="button" class="btn-secondary btn-sm opt-history-del" data-key="' + histKey + '" data-status="' + (h.status || "") + '">删除</button></td>';
'<td><button type="button" class="btn-secondary btn-sm opt-history-del" data-key="' +
histKey +
'" data-status="' +
(h.status || "") +
'" data-inst="' +
(h.inst_id || "") +
'" data-closed="' +
(h.closed_at || h.created_at || "") +
'">删除</button></td>';
tbody.appendChild(tr);
});
tbody.querySelectorAll(".opt-history-del").forEach(function (btn) {
btn.addEventListener("click", function () {
deleteHistoryRow(btn.getAttribute("data-key"), btn.getAttribute("data-status"));
deleteHistoryRow(
btn.getAttribute("data-key"),
btn.getAttribute("data-status"),
btn.getAttribute("data-inst"),
btn.getAttribute("data-closed")
);
});
});
}