diff --git a/lib/common/static/instance_theme.css b/lib/common/static/instance_theme.css index d5de9d4..9257f69 100644 --- a/lib/common/static/instance_theme.css +++ b/lib/common/static/instance_theme.css @@ -5540,6 +5540,79 @@ html[data-theme="light"] .opt-source-badge--oo { flex-wrap: wrap; justify-content: flex-end; } +.opt-cond-order-card { + margin-bottom: 12px; + padding: 12px 14px; + border-radius: 10px; + border: 1px solid rgba(56, 189, 248, 0.35); + background: rgba(14, 42, 68, 0.72); +} +.opt-cond-order-card[hidden] { + display: none !important; +} +.opt-cond-order-head { + display: flex; + align-items: center; + gap: 10px; + flex-wrap: wrap; + margin-bottom: 8px; +} +.opt-cond-order-head strong { + font-size: 0.9rem; +} +.opt-cond-lock-note { + margin-left: auto; + font-size: 0.72rem; + color: #9ec0ff; +} +.opt-cond-st { + display: inline-block; + padding: 2px 8px; + border-radius: 999px; + font-size: 0.72rem; + font-weight: 700; +} +.opt-cond-st.is-armed { + color: #7dd3fc; + background: rgba(56, 189, 248, 0.16); +} +.opt-cond-st.is-trig { + color: #fbbf24; + background: rgba(251, 191, 36, 0.16); +} +.opt-cond-st.is-open { + color: #6ee7b7; + background: rgba(52, 211, 153, 0.16); +} +.opt-cond-order-grid { + display: grid; + grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); + gap: 8px 12px; +} +.opt-cond-kv .k { + display: block; + font-size: 0.68rem; + color: #8ea0c0; +} +.opt-cond-kv .v { + font-weight: 600; + font-variant-numeric: tabular-nums; +} +.opt-cond-order-msg { + margin-top: 8px; + font-size: 0.72rem; + color: #c9d6f5; +} +html[data-theme="light"] .opt-cond-order-card { + border-color: rgba(14, 116, 144, 0.28); + background: rgba(224, 242, 254, 0.7); +} +html[data-theme="light"] .opt-cond-lock-note, +html[data-theme="light"] .opt-cond-kv .k, +html[data-theme="light"] .opt-cond-order-msg { + color: #35506e; +} + .opt-spot-sell-head { display: flex; align-items: center; diff --git a/lib/common/static/options_panel.js b/lib/common/static/options_panel.js index 15bfafa..c0c21d3 100644 --- a/lib/common/static/options_panel.js +++ b/lib/common/static/options_panel.js @@ -2308,16 +2308,84 @@ head.hidden = false; } + function escHtml(s) { + return String(s) + .replace(/&/g, "&") + .replace(//g, ">") + .replace(/"/g, """); + } + + function condStatusLabel(st) { + const map = { armed: "待命", triggering: "触发中", open: "持仓中" }; + return map[st] || st || "已接收"; + } + + function condStatusClass(st) { + if (st === "open") return "is-open"; + if (st === "triggering") return "is-trig"; + return "is-armed"; + } + function paintCondOrderLock(d) { - const el = document.getElementById("opt-cond-lock-banner"); - if (!el) return; - if (d && d.cond_order_locked) { - const extra = d.cond_order_msg ? " · " + d.cond_order_msg : ""; - el.textContent = "中控条件单占用中,禁止手动开仓" + extra; - el.style.display = ""; - } else { - el.style.display = "none"; + const card = document.getElementById("opt-cond-order-card"); + if (!card) return; + const order = d && d.cond_order; + const locked = !!(d && d.cond_order_locked); + if (!order && !locked) { + card.hidden = true; + return; } + const st = order ? String(order.status || "") : ""; + const stEl = document.getElementById("opt-cond-order-st"); + if (stEl) { + stEl.textContent = condStatusLabel(st); + stEl.className = "opt-cond-st " + condStatusClass(st); + } + const grid = document.getElementById("opt-cond-order-grid"); + if (grid) { + if (!order) { + grid.innerHTML = ""; + } else { + const put = String(order.opt_type || "").toUpperCase() !== "C"; + const side = put ? "上穿 ≥" : "下穿 ≤"; + const exitParts = []; + if (order.profit_exit_enabled) { + exitParts.push("翻倍×" + (order.profit_exit_mult != null ? order.profit_exit_mult : "")); + } + if (order.target_index != null && order.target_index !== "") { + exitParts.push("目标 " + order.target_index); + } + const items = [ + ["标的", (order.underlying || "") + " " + (put ? "Put" : "Call")], + ["触发", side + " " + (order.trigger_px != null ? order.trigger_px : "—")], + ["偏离", order.deviation_pct != null ? order.deviation_pct + "%" : "—"], + ["最短到期", order.min_expiry_hours != null ? order.min_expiry_hours + "h" : "—"], + ["出场", exitParts.join(" · ") || "—"], + ["当前指数", order.last_index != null && order.last_index !== "" ? String(order.last_index) : "—"], + ]; + if (order.opened_inst_id) { + items.push(["已开合约", String(order.opened_inst_id)]); + } + grid.innerHTML = items + .map(function (it) { + return ( + '