增加导航栏
This commit is contained in:
@@ -721,28 +721,59 @@ function syncKeySlTpFields() {
|
||||
if (tpEl) tpEl.style.display = mode === "trend_manual" ? "" : "none";
|
||||
}
|
||||
|
||||
function wireKeyMonitorSegGroup(groupId, hiddenInputId, onChange) {
|
||||
const group = document.getElementById(groupId);
|
||||
const hidden = document.getElementById(hiddenInputId);
|
||||
if (!group || !hidden) return;
|
||||
group.addEventListener("click", (ev) => {
|
||||
const btn = ev.target.closest && ev.target.closest(".matrix-seg-btn");
|
||||
if (!btn) return;
|
||||
group.querySelectorAll(".matrix-seg-btn").forEach((b) => b.classList.remove("is-active"));
|
||||
btn.classList.add("is-active");
|
||||
hidden.value = btn.getAttribute("data-value") || "";
|
||||
if (onChange) onChange();
|
||||
});
|
||||
}
|
||||
|
||||
function initKeyMonitorSegGroups() {
|
||||
wireKeyMonitorSegGroup("keyMonitorTypeSeg", "keyMonitorTypeInput");
|
||||
wireKeyMonitorSegGroup("keyDirectionSeg", "keyDirectionInput");
|
||||
wireKeyMonitorSegGroup("keySlTpModeSeg", "keySlTpModeInput", syncKeySlTpFields);
|
||||
}
|
||||
|
||||
function renderKeyMonitorActiveList(rows) {
|
||||
const target = document.getElementById("keyMonitorActive");
|
||||
if (!target) return;
|
||||
target.innerHTML = "";
|
||||
if (!rows.length) {
|
||||
target.innerHTML = '<div class="matrix-dim">暂无监控中的关键位</div>';
|
||||
return;
|
||||
}
|
||||
rows.forEach((row) => {
|
||||
const prev = row.preview || {};
|
||||
const checks = prev.checks || {};
|
||||
const gateOk = prev.gate_ok ? "门控通过" : "门控未过";
|
||||
const gateClass = prev.gate_ok ? "key-gate-ok" : "key-gate-pending";
|
||||
const dir = row.direction === "long" ? "多" : "空";
|
||||
const modeLabel = row.sl_tp_mode === "trend_manual" ? "趋势" : "标准";
|
||||
const el = document.createElement("div");
|
||||
el.className = "item matrix-list-item key-monitor-row";
|
||||
el.innerHTML = `
|
||||
<div class="key-monitor-row-body">
|
||||
<div><strong>${row.symbol}</strong> ${dir} · ${row.monitor_type} · ${modeLabel}</div>
|
||||
<div class="matrix-dim">上 ${row.upper} / 下 ${row.lower} · <span class="${gateClass}">${gateOk}</span> · 确认 ${checks.confirm_close != null ? checks.confirm_close : "—"}</div>
|
||||
</div>
|
||||
<button type="button" class="matrix-btn ghost key-del-btn key-monitor-del" data-id="${row.id}">删除并归档</button>
|
||||
`;
|
||||
target.appendChild(el);
|
||||
});
|
||||
}
|
||||
|
||||
function renderKeyMonitors(data) {
|
||||
const rule = document.getElementById("keyMonitorRule");
|
||||
if (rule && data.rule_text) rule.textContent = `// ${data.rule_text}`;
|
||||
|
||||
const active = data.active || [];
|
||||
renderItems("keyMonitorActive", active, (row) => {
|
||||
const prev = row.preview || {};
|
||||
const checks = prev.checks || {};
|
||||
const gateOk = prev.gate_ok ? '<span style="color:#4cd97f">门控通过</span>' : '<span style="color:#8892b0">门控未过</span>';
|
||||
const dir = row.direction === "long" ? "做多" : "做空";
|
||||
const modeLabel = row.sl_tp_mode === "trend_manual" ? "趋势突破" : "标准突破";
|
||||
return `
|
||||
<div class="matrix-list-item-head"><strong>${row.symbol}</strong> ${dir} · ${row.monitor_type} · ${modeLabel}</div>
|
||||
<div class="matrix-dim">上 ${row.upper} / 下 ${row.lower} · 保本 ${row.breakeven_enabled ? "开" : "关"}</div>
|
||||
<div class="matrix-dim">${gateOk} · 确认收盘 ${checks.confirm_close != null ? checks.confirm_close : "—"}</div>
|
||||
<button type="button" class="matrix-btn ghost key-del-btn" data-id="${row.id}" style="margin-top:6px">删除并归档</button>
|
||||
`;
|
||||
});
|
||||
if (!active.length) {
|
||||
const t = document.getElementById("keyMonitorActive");
|
||||
if (t) t.innerHTML = '<div class="matrix-dim">暂无监控中的关键位</div>';
|
||||
}
|
||||
renderKeyMonitorActiveList(data.active || []);
|
||||
|
||||
const hist = data.history || [];
|
||||
renderItems("keyMonitorHistory", hist.slice(0, 80), (h) => {
|
||||
@@ -804,8 +835,7 @@ async function addKeyMonitor() {
|
||||
}
|
||||
|
||||
function wireKeyMonitorPanel() {
|
||||
const modeSel = document.getElementById("keySlTpModeInput");
|
||||
if (modeSel) modeSel.addEventListener("change", syncKeySlTpFields);
|
||||
initKeyMonitorSegGroups();
|
||||
syncKeySlTpFields();
|
||||
const addBtn = document.getElementById("keyAddBtn");
|
||||
if (addBtn) addBtn.addEventListener("click", addKeyMonitor);
|
||||
|
||||
Reference in New Issue
Block a user