Split journal order type from entry reason and fix review edit toggle in embed shell.

Adds order_type to journal uploads, removes legacy swing/trend labels from entry reason options, and ensures review-edit buttons sync when the records tab loads dynamically.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
dekun
2026-07-09 09:27:03 +08:00
parent 4abe8a6ca9
commit d3a44b23db
17 changed files with 325 additions and 85 deletions
+27 -6
View File
@@ -1,5 +1,6 @@
<script>
const JOURNAL_ENTRY_REASON_OPTIONS = {{ entry_reason_options | tojson }};
const JOURNAL_ORDER_TYPE_OPTIONS = {{ order_type_options | tojson }};
function reloadInstancePage(){
if(document.body && document.body.getAttribute("data-embed-shell") === "1" && window.InstanceEmbed){
@@ -12,6 +13,11 @@ function reloadInstancePage(){
function validateJournalEntryReason(){
const form = document.getElementById("journal-form");
if(!form) return true;
const orderSel = form.querySelector('[name="order_type"]');
if(!orderSel || !orderSel.value){
alert("请选择下单类型");
return false;
}
const sel = form.querySelector('[name="entry_reason"]');
if(!sel || !sel.value){
alert("请选择开仓类型");
@@ -147,6 +153,10 @@ function normalizeBeijingDatetimeString(v){
}
function toggleReviewMode(){
if(window.InstanceTheme && typeof InstanceTheme.syncReviewEditButtons === "function"){
InstanceTheme.syncReviewEditButtons();
return;
}
const on = !!(document.getElementById("review-mode-toggle") || {}).checked;
document.querySelectorAll(".review-edit-btn").forEach(btn=>{
btn.disabled = !on;
@@ -537,11 +547,18 @@ function fillJournalFromTrade(t){
setJournalField("early_exit_note", "");
const kst = String(t.key_signal_type || "").trim();
const mt = String(t.monitor_type || "").trim();
if(mt === "趋势回调" && JOURNAL_ENTRY_REASON_OPTIONS.includes("趋势回调")){
setJournalField("entry_reason", "趋势回调");
} else if(mt === "顺势加仓" && JOURNAL_ENTRY_REASON_OPTIONS.includes("顺势加仓")){
setJournalField("entry_reason", "顺势加仓");
} else if(t.effective_entry_reason && JOURNAL_ENTRY_REASON_OPTIONS.includes(t.effective_entry_reason)){
const orderType = (function(){
if(mt === "趋势回调" && JOURNAL_ORDER_TYPE_OPTIONS.includes("趋势回调")) return "趋势回调";
if(mt === "顺势加仓" && JOURNAL_ORDER_TYPE_OPTIONS.includes("顺势加仓")) return "顺势加仓";
if(mt === "关键位监控" || mt.includes("关键位")) return "关键位监控";
return "下单监控";
})();
if(JOURNAL_ORDER_TYPE_OPTIONS.includes(orderType)){
setJournalField("order_type", orderType);
} else {
setJournalField("order_type", "");
}
if(t.effective_entry_reason && JOURNAL_ENTRY_REASON_OPTIONS.includes(t.effective_entry_reason)){
setJournalField("entry_reason", t.effective_entry_reason);
} else {
const erFromKey = KEY_ENTRY_REASON_BY_SIGNAL[kst] || "";
@@ -554,7 +571,7 @@ function fillJournalFromTrade(t){
const er = String(t.result || "").trim();
const exitTrigMap = { 止盈: "止盈", 保本止盈: "保本止盈", 移动止盈: "移动止盈", 时间平仓: "时间平仓", 强制清仓: "强制清仓", 手动平仓: "手动平仓", 止损: "止损" };
if(exitTrigMap[er]) setJournalField("early_exit_trigger", exitTrigMap[er]);
const note = `来自交易记录自动填充:${t.symbol || "-"} ${t.direction || "-"} | 入场:${entryPx || "-"} 止损:${slPx || "-"} 止盈:${tpPx || "-"} | 类型:${t.monitor_type || "-"}`;
const note = `来自交易记录自动填充:${t.symbol || "-"} ${t.direction || "-"} | 入场:${entryPx || "-"} 止损:${slPx || "-"} 止盈:${tpPx || "-"} | 下单类型:${orderType || t.monitor_type || "-"}`;
setJournalField("note", note);
const form = document.getElementById("journal-form");
if(form && typeof form.scrollIntoView === "function"){
@@ -632,8 +649,12 @@ if(document.getElementById("review-list")) loadReviews();
const reviewToggle = document.getElementById("review-mode-toggle");
if(reviewToggle){
reviewToggle.addEventListener("change", toggleReviewMode);
reviewToggle.addEventListener("input", toggleReviewMode);
toggleReviewMode();
}
if(window.InstanceTheme && typeof InstanceTheme.initReviewEditModeSync === "function"){
InstanceTheme.initReviewEditModeSync();
}
const journalForm = document.getElementById("journal-form");
if(journalForm){
const pnlInput = journalForm.querySelector('[name="pnl"]');