修复显示bug
This commit is contained in:
@@ -433,9 +433,9 @@
|
||||
data-monitor-id="{{ o.id }}"
|
||||
data-symbol="{{ o.symbol }}"
|
||||
data-direction="{{ o.direction }}"
|
||||
data-plan-sl="{{ o.stop_loss or '' }}"
|
||||
data-plan-tp="{{ o.take_profit or '' }}"
|
||||
data-entry="{{ o.trigger_price or '' }}">
|
||||
data-plan-sl="{% if o.stop_loss %}{{ price_fmt(o.symbol, o.stop_loss) }}{% endif %}"
|
||||
data-plan-tp="{% if o.take_profit %}{{ price_fmt(o.symbol, o.take_profit) }}{% endif %}"
|
||||
data-entry="{% if o.trigger_price %}{{ price_fmt(o.symbol, o.trigger_price) }}{% endif %}">
|
||||
<div class="pos-card-head">
|
||||
<div class="pos-card-symbol">
|
||||
<strong>{{ o.exchange_symbol or o.symbol }}</strong>
|
||||
@@ -924,9 +924,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;
|
||||
@@ -1174,6 +1174,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);
|
||||
@@ -1212,10 +1230,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", "");
|
||||
@@ -1232,7 +1253,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"){
|
||||
@@ -1492,8 +1513,8 @@ function openTpslEntrustModal(orderId){
|
||||
tpslEntrustMonitorId = orderId;
|
||||
const slEl = document.getElementById('tpsl-modal-sl');
|
||||
const tpEl = document.getElementById('tpsl-modal-tp');
|
||||
if(slEl) slEl.value = card.getAttribute('data-plan-sl') || '';
|
||||
if(tpEl) tpEl.value = card.getAttribute('data-plan-tp') || '';
|
||||
if(slEl) slEl.value = formatPriceForInput(card.getAttribute('data-plan-sl') || '');
|
||||
if(tpEl) tpEl.value = formatPriceForInput(card.getAttribute('data-plan-tp') || '');
|
||||
const modeEl = document.getElementById('tpsl-modal-mode');
|
||||
if(modeEl) modeEl.value = 'price';
|
||||
toggleTpslModalMode();
|
||||
|
||||
Reference in New Issue
Block a user