实例期权页增加中控条件单卡片,接单后显示状态与触发参数。

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
dekun
2026-10-04 18:39:47 +08:00
parent 8b584a0870
commit e11651d729
6 changed files with 164 additions and 12 deletions
+76 -8
View File
@@ -2308,16 +2308,84 @@
head.hidden = false;
}
function escHtml(s) {
return String(s)
.replace(/&/g, "&amp;")
.replace(/</g, "&lt;")
.replace(/>/g, "&gt;")
.replace(/"/g, "&quot;");
}
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 (
'<div class="opt-cond-kv"><span class="k">' +
escHtml(it[0]) +
'</span><span class="v">' +
escHtml(it[1]) +
"</span></div>"
);
})
.join("");
}
}
const msgEl = document.getElementById("opt-cond-order-msg");
if (msgEl) {
const msg = (order && order.message) || (d && d.cond_order_msg) || "";
msgEl.textContent = msg ? String(msg) : "";
}
card.hidden = false;
}
async function retrySpotSell() {