diff --git a/hub_entry_plan_lib.py b/hub_entry_plan_lib.py index 5bd0576..feb5147 100644 --- a/hub_entry_plan_lib.py +++ b/hub_entry_plan_lib.py @@ -129,7 +129,7 @@ def _row_to_dict(row: sqlite3.Row | None) -> dict[str, Any] | None: d["direction_label"] = DIRECTIONS.get(d.get("direction") or "", d.get("direction") or "") d["entry_scheme_label"] = ENTRY_SCHEMES.get( d.get("entry_scheme") or "", d.get("entry_scheme") or "" - ) + ) or "待填写" res = d.get("result") d["result_label"] = RESULTS.get(res, "") if res else "" return d @@ -157,7 +157,9 @@ def create_entry_plan(payload: dict[str, Any], *, db_path: Path | None = None) - trend_tf = _validate_choice(payload.get("trend_timeframe"), TREND_TIMEFRAMES, "趋势周期") entry_tf = _validate_choice(payload.get("entry_timeframe"), ENTRY_TIMEFRAMES, "入场周期") direction = _validate_choice(payload.get("direction"), DIRECTIONS, "方向") - entry_scheme = _validate_choice(payload.get("entry_scheme"), ENTRY_SCHEMES, "入场方案") + entry_scheme = "" + if payload.get("entry_scheme"): + entry_scheme = _validate_choice(payload.get("entry_scheme"), ENTRY_SCHEMES, "入场方案") target_level = str(payload.get("target_level") or "").strip() current_range = str(payload.get("current_range") or "").strip() note = str(payload.get("note") or "").strip() @@ -295,6 +297,9 @@ def update_entry_plan( now = _now_ms() fields["updated_at"] = now if archive_now: + scheme_val = fields.get("entry_scheme", row["entry_scheme"]) + if not str(scheme_val or "").strip(): + raise ValueError("归档前请在进行中计划里选择入场方案") fields["status"] = "archived" fields["archived_at"] = now sets = ", ".join(f"{k}=?" for k in fields) diff --git a/manual_trading_hub/static/app.css b/manual_trading_hub/static/app.css index e860542..c564ec2 100644 --- a/manual_trading_hub/static/app.css +++ b/manual_trading_hub/static/app.css @@ -6599,6 +6599,12 @@ body.funds-fullscreen-open { color: var(--text); opacity: 0.9; } +.plan-scheme-row { + margin-top: 6px; +} +.plan-field-scheme select { + min-width: 160px; +} .plan-close-row { display: flex; flex-wrap: wrap; diff --git a/manual_trading_hub/static/index.html b/manual_trading_hub/static/index.html index fff879d..33f0148 100644 --- a/manual_trading_hub/static/index.html +++ b/manual_trading_hub/static/index.html @@ -109,10 +109,6 @@ 当前区间 - - 入场方案 - - 备注 @@ -814,7 +810,7 @@ - + diff --git a/manual_trading_hub/static/plan.js b/manual_trading_hub/static/plan.js index b0b5a0b..8310b92 100644 --- a/manual_trading_hub/static/plan.js +++ b/manual_trading_hub/static/plan.js @@ -115,7 +115,6 @@ fillSelect($("plan-create-type"), meta.plan_types, "value", "label"); fillSelect($("plan-create-trend-tf"), meta.trend_timeframes); fillSelect($("plan-create-entry-tf"), meta.entry_timeframes); - fillSelect($("plan-create-scheme"), meta.entry_schemes, "value", "label"); renderDirectionRadios($("plan-create-direction"), "plan-direction", "long"); const dateEl = $("plan-create-date"); if (dateEl && !dateEl.value) dateEl.value = todayIso(); @@ -133,6 +132,21 @@ ); } + function schemeOptionsHtml(selected) { + let html = '请选择'; + (meta.entry_schemes || []).forEach(function (s) { + html += + '" + + esc(s.label) + + ""; + }); + return html; + } + function renderActiveList() { const host = $("plan-active-list"); const cnt = $("plan-active-count"); @@ -166,8 +180,6 @@ esc(p.trend_timeframe) + " / 入场 " + esc(p.entry_timeframe) + - " · " + - esc(p.entry_scheme_label || p.entry_scheme) + "" + '目标 ' + esc(p.target_level || "—") + @@ -175,6 +187,14 @@ esc(p.current_range || "—") + "" + (p.note ? '' + esc(p.note) + "" : "") + + '' + + '入场方案' + + '' + + schemeOptionsHtml(p.entry_scheme || "") + + "" + + "" + '' + '结果' + '