修复显示bug

This commit is contained in:
dekun
2026-05-22 17:27:55 +08:00
parent 1ec1415e2b
commit ee5dc614e0
4 changed files with 114 additions and 30 deletions
+26 -5
View File
@@ -981,9 +981,9 @@ function editTradeRecordReview(t){
if(opened === null) return;
const closed = prompt("平仓时间(YYYY-MM-DD HH:MM:SS)", normalizeBeijingDatetimeString(t.closed_at || ""));
if(closed === null) return;
const stopLoss = prompt("止损价格(核对后用于统计)", String(t.stop_loss ?? ""));
const stopLoss = prompt("止损价格(核对后用于统计)", formatPriceForInput(t.stop_loss));
if(stopLoss === null) return;
const takeProfit = prompt("止盈价格(核对后用于统计)", String(t.take_profit ?? ""));
const takeProfit = prompt("止盈价格(核对后用于统计)", formatPriceForInput(t.take_profit));
if(takeProfit === null) return;
const pnl = prompt("最终盈亏(可手工核对后填写)", String(t.pnl_amount ?? ""));
if(pnl === null) return;
@@ -1184,6 +1184,24 @@ function coinFromSymbol(symbol){
return s;
}
/** 输入框/备注用价格:去掉浮点尾数,按量级保留有效小数(与后端 price_fmt 兜底一致) */
function formatPriceForInput(val){
if(val === null || val === undefined || val === "") return "";
const v = Number(val);
if(!Number.isFinite(v)) return String(val);
const av = Math.abs(v);
let d;
if(av >= 10000) d = 2;
else if(av >= 100) d = 3;
else if(av >= 1) d = 4;
else if(av >= 0.01) d = 6;
else if(av >= 0.0001) d = 8;
else d = 10;
let text = v.toFixed(d);
if(text.includes(".")) text = text.replace(/\.?0+$/, "");
return text;
}
function calcExpectedRrFromTrade(t){
const entry = Number(t.trigger_price);
const sl = Number(t.stop_loss);
@@ -1222,10 +1240,13 @@ function fillJournalFromTrade(t){
setJournalField("real_rr", realRr);
const riskHint = document.getElementById("risk-amount-hint");
if(riskHint){ riskHint.value = (Number.isFinite(riskAmount) && riskAmount > 0) ? String(riskAmount) : ""; }
const entryPx = formatPriceForInput(t.trigger_price);
const slPx = formatPriceForInput(t.stop_loss);
const tpPx = formatPriceForInput(t.take_profit);
const entryHint = document.getElementById("entry-price-hint");
if(entryHint){ entryHint.value = t.trigger_price || ""; }
if(entryHint){ entryHint.value = entryPx; }
const stopHint = document.getElementById("stop-loss-hint");
if(stopHint){ stopHint.value = t.stop_loss || ""; }
if(stopHint){ stopHint.value = slPx; }
const dirHint = document.getElementById("direction-hint");
if(dirHint){ dirHint.value = t.direction || "long"; }
setJournalField("early_exit_trigger", "");
@@ -1240,7 +1261,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 || "-"} | 入场:${t.trigger_price || "-"} 止损:${t.stop_loss || "-"} 止盈:${t.take_profit || "-"} | 类型:${t.monitor_type || "-"}`;
const note = `来自交易记录自动填充:${t.symbol || "-"} ${t.direction || "-"} | 入场:${entryPx || "-"} 止损:${slPx || "-"} 止盈:${tpPx || "-"} | 类型:${t.monitor_type || "-"}`;
setJournalField("note", note);
const form = document.getElementById("journal-form");
if(form && typeof form.scrollIntoView === "function"){