Load options review from local records with compact journal UI.

Drop exchange sync for the review page, auto-import closed local options and hedge plans, and match contract-style multi-timeframe upload styling with smaller fonts.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
dekun
2026-07-17 09:54:35 +08:00
parent c6142dc246
commit 48afc8ebe3
6 changed files with 194 additions and 102 deletions
+25 -42
View File
@@ -74,34 +74,10 @@
if (el) el.textContent = text || "";
}
function syncNow() {
setSyncStatus("同步中…");
fetch("/api/options/review/sync", { method: "POST", credentials: "same-origin" })
.then(function (r) {
return r.json();
})
.then(function (data) {
var parts = [];
if (data.options) {
parts.push(
data.options.ok
? "期权 +" + (data.options.inserted || 0) + "/更" + (data.options.updated || 0)
: "期权:" + (data.options.msg || "失败")
);
}
if (data.hedge) {
parts.push(
data.hedge.ok
? "对冲 +" + (data.hedge.inserted || 0) + "/更" + (data.hedge.updated || 0)
: "对冲失败"
);
}
setSyncStatus(parts.join(" · ") || "完成");
reloadAll();
})
.catch(function () {
setSyncStatus("同步失败");
});
function reloadAll() {
setSyncStatus("读取本地记录…");
loadTrades();
loadStats();
}
function setActiveTab(source) {
@@ -115,11 +91,6 @@
reloadAll();
}
function reloadAll() {
loadTrades();
loadStats();
}
function loadTrades() {
var tbody = $("or-trades-tbody");
if (!tbody) return;
@@ -129,6 +100,7 @@
return r.json();
})
.then(function (data) {
setSyncStatus("本地记录已加载");
if (!data.ok) {
tbody.innerHTML = '<tr><td colspan="7" class="muted">加载失败</td></tr>';
return;
@@ -136,7 +108,8 @@
var rows = data.trades || [];
tradesCache = {};
if (!rows.length) {
tbody.innerHTML = '<tr><td colspan="7" class="muted">暂无记录,请先同步</td></tr>';
tbody.innerHTML =
'<tr><td colspan="7" class="muted">暂无本地已平记录(期权页平仓后或对冲计划结束后会出现在此)</td></tr>';
return;
}
tbody.innerHTML = rows
@@ -304,11 +277,17 @@
var hidden = row && row.querySelector(".or-upload-hidden");
if (!file) {
if (hidden) hidden.value = "";
if (status) status.textContent = "";
if (status) {
status.textContent = "";
status.className = "journal-upload-status or-upload-status";
}
return;
}
if (!draftId) draftId = newDraftId();
if (status) status.textContent = "上传中…";
if (status) {
status.textContent = "上传中…";
status.className = "journal-upload-status or-upload-status journal-upload-status--pending";
}
var fd = new FormData();
fd.append("draft_id", draftId);
fd.append("tf", input.getAttribute("data-tf") || "");
@@ -324,12 +303,18 @@
.then(function (data) {
if (!data.ok) throw new Error(data.error || "fail");
if (hidden) hidden.value = data.file;
if (status) status.textContent = "上传成功 " + data.file;
if (status) {
status.textContent = "上传成功 " + data.file;
status.className = "journal-upload-status or-upload-status journal-upload-status--ok";
}
input.value = "";
})
.catch(function () {
if (hidden) hidden.value = "";
if (status) status.textContent = "上传失败";
if (status) {
status.textContent = "上传失败";
status.className = "journal-upload-status or-upload-status journal-upload-status--err";
}
});
});
});
@@ -394,7 +379,7 @@
var summary = $("or-journal-summary");
if (summary) {
summary.textContent =
"先点「同步」拉记录,再在下方列表点选一笔填入;截图槽位 5m/15m/1h/4h 可先传.";
"点下方列表一笔记录自动填入;截图槽位与合约复盘相同(5m / 15m / 1h / 4h).";
}
var legsHost = $("or-legs-host");
if (legsHost) legsHost.innerHTML = "";
@@ -509,7 +494,7 @@
function saveEntry() {
var tradeId = Number(($("or-trade-id") || {}).value || 0);
if (!tradeId) {
alert("请先在下方列表点选一笔记录(若无记录请先点同步)");
alert("请先在下方列表点选一笔本地记录");
return;
}
var strategy = (($("or-f-strategy") || {}).value || "").trim();
@@ -576,12 +561,10 @@
setActiveTab(btn.getAttribute("data-source"));
});
});
var syncBtn = $("or-sync-btn");
var reloadBtn = $("or-reload-btn");
var saveBtn = $("or-save-btn");
var clearBtn = $("or-clear-btn");
var delBtn = $("or-del-btn");
if (syncBtn) syncBtn.addEventListener("click", syncNow);
if (reloadBtn) reloadBtn.addEventListener("click", reloadAll);
if (saveBtn) saveBtn.addEventListener("click", saveEntry);
if (clearBtn) clearBtn.addEventListener("click", hideJournalForm);