增加复盘选择
This commit is contained in:
@@ -36,6 +36,10 @@
|
||||
font-size:.8rem;
|
||||
line-height:1.35;
|
||||
}
|
||||
.journal-card .form-grid input[name="entry_reason_custom"]{
|
||||
grid-column:1/-1;
|
||||
font-size:.8rem;
|
||||
}
|
||||
input,select,button,textarea{padding:8px 10px;border-radius:8px;border:1px solid #2e2e45;background:#1a1a29;color:#fff;font-size:.88rem;outline:none}
|
||||
button{background:linear-gradient(90deg,#4285f4,#7b42ff);border:none;cursor:pointer}
|
||||
.list{display:flex;flex-direction:column;gap:8px;margin-top:8px;max-height:240px;overflow:auto}
|
||||
@@ -427,12 +431,14 @@
|
||||
<input name="coin" placeholder="BTC" required>
|
||||
<input name="tf" placeholder="5m" required>
|
||||
<input name="pnl" placeholder="盈亏(U)" required>
|
||||
<select name="entry_reason" required title="仅五种固定开仓逻辑">
|
||||
<select name="entry_reason" id="journal-entry-reason" required title="固定五种或选其他手写">
|
||||
<option value="">开仓类型(必选)</option>
|
||||
{% for er in entry_reason_options %}
|
||||
<option value="{{ er }}">{{ er }}</option>
|
||||
{% endfor %}
|
||||
<option value="{{ entry_reason_other_value }}">其他(自定义,见下方说明框)</option>
|
||||
</select>
|
||||
<input type="text" name="entry_reason_custom" id="journal-entry-reason-custom" maxlength="2000" placeholder="选「其他」时在此填写开仓类型说明" autocomplete="off" style="display:none">
|
||||
<input name="expect_rr" placeholder="预期RR">
|
||||
<input name="real_rr" placeholder="实际RR">
|
||||
<select name="early_exit_trigger" required title="平仓如何触发">
|
||||
@@ -535,6 +541,42 @@
|
||||
|
||||
<script>
|
||||
const JOURNAL_ENTRY_REASON_OPTIONS = {{ entry_reason_options | tojson }};
|
||||
const JOURNAL_ENTRY_REASON_OTHER = {{ entry_reason_other_value | tojson }};
|
||||
|
||||
function syncJournalEntryReasonOtherUi(){
|
||||
const form = document.getElementById("journal-form");
|
||||
if(!form) return;
|
||||
const sel = form.querySelector('[name="entry_reason"]');
|
||||
const box = form.querySelector('[name="entry_reason_custom"]');
|
||||
if(!sel || !box) return;
|
||||
if(sel.value === JOURNAL_ENTRY_REASON_OTHER){
|
||||
box.style.display = "";
|
||||
box.required = true;
|
||||
} else {
|
||||
box.style.display = "none";
|
||||
box.required = false;
|
||||
box.value = "";
|
||||
}
|
||||
}
|
||||
|
||||
function validateJournalEntryReason(){
|
||||
const form = document.getElementById("journal-form");
|
||||
if(!form) return true;
|
||||
const sel = form.querySelector('[name="entry_reason"]');
|
||||
const box = form.querySelector('[name="entry_reason_custom"]');
|
||||
if(!sel || !sel.value){
|
||||
alert("请选择开仓类型");
|
||||
return false;
|
||||
}
|
||||
if(sel.value === JOURNAL_ENTRY_REASON_OTHER){
|
||||
const t = (box && box.value || "").trim();
|
||||
if(!t){
|
||||
alert("选择「其他」时请填写自定义开仓类型说明");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
function showImage(src){document.getElementById("bigImg").src=src;document.getElementById("imgModal").style.display="flex";}
|
||||
function closeModal(){document.getElementById("imgModal").style.display="none";}
|
||||
function forceCloseDetailModal(){document.getElementById("detailModal").style.display="none";}
|
||||
@@ -648,7 +690,7 @@ function editTradeRecordReview(t){
|
||||
const result = prompt("结果(止盈/止损/保本止盈/移动止盈/手动平仓)", String(t.result || ""));
|
||||
if(result === null) return;
|
||||
const note = prompt("备注(可空)", String(t.miss_reason || "")) ?? "";
|
||||
const entryHint = "开仓类型(五种固定枚举整句,与复盘表单一致;留空=本次不改该项)";
|
||||
const entryHint = "开仓类型:五种固定整句、或自定义说明(2000字内;与复盘表单一致;留空=本次不改该项)";
|
||||
const entryIn = prompt(entryHint, String(t.effective_entry_reason || ""));
|
||||
if(entryIn === null) return;
|
||||
const payload = {
|
||||
@@ -887,6 +929,8 @@ function fillJournalFromTrade(t){
|
||||
setJournalField("early_exit_trigger", "");
|
||||
setJournalField("early_exit_note", "");
|
||||
setJournalField("entry_reason", "");
|
||||
setJournalField("entry_reason_custom", "");
|
||||
syncJournalEntryReasonOtherUi();
|
||||
const er = String(t.result || "").trim();
|
||||
const exitTrigMap = { 保本止盈: "保本止盈", 移动止盈: "移动止盈", 手动平仓: "手动平仓", 止损: "止损" };
|
||||
if(exitTrigMap[er]) setJournalField("early_exit_trigger", exitTrigMap[er]);
|
||||
@@ -925,10 +969,18 @@ function prefillJournalByImage(){
|
||||
setJournalField("expect_rr", d.expect_rr || "");
|
||||
setJournalField("real_rr", d.real_rr || "");
|
||||
let entryReason = String(d.entry_reason || "").trim();
|
||||
if(!JOURNAL_ENTRY_REASON_OPTIONS || !JOURNAL_ENTRY_REASON_OPTIONS.includes(entryReason)){
|
||||
let customEr = "";
|
||||
if(JOURNAL_ENTRY_REASON_OPTIONS && JOURNAL_ENTRY_REASON_OPTIONS.includes(entryReason)){
|
||||
// keep
|
||||
} else if(entryReason){
|
||||
customEr = entryReason;
|
||||
entryReason = JOURNAL_ENTRY_REASON_OTHER;
|
||||
} else {
|
||||
entryReason = "";
|
||||
}
|
||||
setJournalField("entry_reason", entryReason);
|
||||
setJournalField("entry_reason_custom", customEr);
|
||||
syncJournalEntryReasonOtherUi();
|
||||
const trig = (d.early_exit_trigger || "").trim();
|
||||
let noteEx = (d.early_exit_note || "").trim();
|
||||
const legacy = (d.early_exit_reason || "").trim();
|
||||
@@ -1213,6 +1265,15 @@ if(sltpModeEl){
|
||||
}
|
||||
|
||||
refreshAccountSnapshot();
|
||||
const _journalFormEl = document.getElementById("journal-form");
|
||||
if(_journalFormEl){
|
||||
_journalFormEl.addEventListener("submit", function(ev){
|
||||
if(!validateJournalEntryReason()) ev.preventDefault();
|
||||
});
|
||||
const _jErSel = _journalFormEl.querySelector('[name="entry_reason"]');
|
||||
if(_jErSel) _jErSel.addEventListener("change", syncJournalEntryReasonOtherUi);
|
||||
syncJournalEntryReasonOtherUi();
|
||||
}
|
||||
refreshOrderDefaults();
|
||||
refreshPriceSnapshot();
|
||||
setInterval(refreshAccountSnapshot, {{ balance_refresh_seconds * 1000 }});
|
||||
|
||||
Reference in New Issue
Block a user