Expand options review table columns and color result tags.

Show direction, hold time, and entry logic; paint 盈利 green and 亏损 red.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
dekun
2026-07-19 16:49:35 +08:00
parent 3c21680763
commit debfb116fd
3 changed files with 43 additions and 8 deletions
+32 -5
View File
@@ -122,6 +122,19 @@
return "";
}
function resultStyle(tag) {
var t = String(tag || "").trim();
if (t === "盈利") return "color:#3dd68c;font-weight:600";
if (t === "亏损") return "color:#f07178;font-weight:600";
return "";
}
function tradeContractLabel(t) {
if (!t) return "—";
if (t.source_type === "option_spot") return t.inst_id || t.underlying || "—";
return t.underlying || "—";
}
function newDraftId() {
if (global.crypto && typeof global.crypto.randomUUID === "function") {
return global.crypto.randomUUID().replace(/-/g, "");
@@ -436,7 +449,7 @@
if (!tbody) return;
var wrap = beginListLoad("or-reviewed-wrap", soft);
if (!soft) {
tbody.innerHTML = '<tr><td colspan="8" class="muted">加载中…</td></tr>';
tbody.innerHTML = '<tr><td colspan="11" class="muted">加载中…</td></tr>';
}
var p = baseQs();
p.set("reviewed", "1");
@@ -449,7 +462,7 @@
})
.then(function (data) {
if (!data.ok) {
tbody.innerHTML = '<tr><td colspan="8" class="muted">加载失败</td></tr>';
tbody.innerHTML = '<tr><td colspan="11" class="muted">加载失败</td></tr>';
endListLoad(wrap);
return;
}
@@ -460,13 +473,16 @@
var rows = data.trades || [];
reviewedCache = {};
if (!rows.length) {
tbody.innerHTML = '<tr><td colspan="8" class="muted">暂无复盘记录</td></tr>';
tbody.innerHTML = '<tr><td colspan="11" class="muted">暂无复盘记录</td></tr>';
endListLoad(wrap);
return;
}
tbody.innerHTML = rows
.map(function (t) {
reviewedCache[t.id] = t;
var entry = t.entry || {};
var direction = t.direction_view || entry.direction_view || "";
var entryLogic = t.entry_logic || entry.entry_logic || "";
return (
'<tr class="or-reviewed-row" data-id="' +
t.id +
@@ -475,7 +491,10 @@
escapeHtml(t.source_label || t.source_type) +
"</span></td>" +
"<td>" +
escapeHtml(tradeTitle(t)) +
escapeHtml(tradeContractLabel(t)) +
"</td>" +
"<td>" +
escapeHtml(direction || "—") +
"</td>" +
'<td style="' +
pnlStyle(t.realized_pnl_total) +
@@ -489,9 +508,17 @@
escapeHtml(t.closed_at || "—") +
"</td>" +
"<td>" +
escapeHtml(fmtHold(t.hold_seconds)) +
"</td>" +
"<td>" +
escapeHtml(t.strategy_tag || "—") +
"</td>" +
"<td>" +
escapeHtml(entryLogic || "—") +
"</td>" +
'<td style="' +
resultStyle(t.result_tag) +
'">' +
escapeHtml(t.result_tag || "—") +
"</td>" +
'<td class="muted" style="font-size:12px;white-space:nowrap">' +
@@ -509,7 +536,7 @@
endListLoad(wrap);
})
.catch(function () {
tbody.innerHTML = '<tr><td colspan="8" class="muted">加载失败</td></tr>';
tbody.innerHTML = '<tr><td colspan="11" class="muted">加载失败</td></tr>';
endListLoad(wrap);
});
}
+4
View File
@@ -581,11 +581,15 @@ def enrich_trade_row(row: dict[str, Any], entry: dict[str, Any] | None = None) -
out["entry"] = dict(entry)
out["entry"]["images"] = parse_options_review_images_json(entry.get("images_json"))
out["strategy_tag"] = entry.get("strategy_tag")
out["direction_view"] = entry.get("direction_view")
out["entry_logic"] = entry.get("entry_logic")
out["result_tag"] = entry.get("result_tag")
out["reviewed_at"] = entry.get("reviewed_at") or entry.get("updated_at")
else:
out["entry"] = None
out["strategy_tag"] = None
out["direction_view"] = None
out["entry_logic"] = None
out["result_tag"] = None
out["reviewed_at"] = None
return out
@@ -70,7 +70,8 @@
padding-top:8px;border-top:1px dashed rgba(127,127,127,.2);font-size:.74rem;
}
.or-list-loading{opacity:.55;pointer-events:none;transition:opacity .12s ease}
.or-trades-table-wrap,.or-reviewed-table-wrap{min-height:9.5rem}
.or-trades-table-wrap,.or-reviewed-table-wrap{min-height:9.5rem;overflow-x:auto}
.or-reviewed-table{min-width:980px}
.or-kpi-row{
display:grid;grid-template-columns:repeat(6,minmax(0,1fr));
gap:8px;margin-bottom:12px;
@@ -343,16 +344,19 @@
<tr>
<th>类型</th>
<th>标的/合约</th>
<th>方向</th>
<th>盈亏</th>
<th>开仓时间</th>
<th>平仓时间</th>
<th>持仓时长</th>
<th>策略</th>
<th>入场逻辑</th>
<th>结果</th>
<th>复盘时间</th>
</tr>
</thead>
<tbody id="or-reviewed-tbody">
<tr><td colspan="8" class="muted">加载中…</td></tr>
<tr><td colspan="11" class="muted">加载中…</td></tr>
</tbody>
</table>
</div>
@@ -394,4 +398,4 @@
</section>
</div>
<script src="/static/options_review.js?v=19"></script>
<script src="/static/options_review.js?v=20"></script>