条件单占用时左侧期权「选择」按钮置灰禁用,避免手动开仓。

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
dekun
2026-10-04 18:45:23 +08:00
parent e11651d729
commit bab26c7205
5 changed files with 65 additions and 6 deletions
+47 -3
View File
@@ -30,6 +30,7 @@
targetDraftByInst: {},
/** 翻倍倍数草稿,避免轮询重绘把正在输入的值刷回 1 */
profitExitDraftByInst: {},
condOrderLocked: false,
};
let lastGoodPositions = null;
@@ -103,14 +104,35 @@
return document.getElementById("opt-order-panel-host");
}
function applyCondPickLock() {
const locked = !!state.condOrderLocked;
document.querySelectorAll(".opt-pick-btn").forEach(function (btn) {
btn.disabled = locked;
btn.classList.toggle("is-locked", locked);
if (locked) {
btn.classList.remove("active");
btn.title = "中控条件单占用中,禁止手动开仓";
if (!btn.dataset.origText) btn.dataset.origText = "选择";
btn.textContent = btn.dataset.origText;
} else {
btn.removeAttribute("title");
}
});
const openBtn = document.getElementById("opt-open-btn");
if (openBtn && locked) {
openBtn.disabled = true;
openBtn.title = "中控条件单占用中,禁止手动开仓";
}
}
function syncPickButtons(instId) {
document.querySelectorAll(".opt-pick-btn").forEach(function (btn) {
const on = !!instId && btn.getAttribute("data-inst") === instId;
const on = !state.condOrderLocked && !!instId && btn.getAttribute("data-inst") === instId;
btn.classList.toggle("active", on);
btn.disabled = false;
if (!btn.dataset.origText) btn.dataset.origText = "选择";
btn.textContent = on ? "已选" : btn.dataset.origText;
});
applyCondPickLock();
}
function parkOrderPanel() {
@@ -651,7 +673,16 @@
function pickBtnHtml(instId) {
if (!instId) return "—";
return '<button type="button" class="btn-secondary opt-pick-btn" data-inst="' + instId + '">选择</button>';
const locked = !!state.condOrderLocked;
return (
'<button type="button" class="btn-secondary opt-pick-btn' +
(locked ? " is-locked" : "") +
'" data-inst="' +
instId +
'"' +
(locked ? ' disabled title="中控条件单占用中,禁止手动开仓"' : "") +
">选择</button>"
);
}
function syncMoneyFilterButtons() {
@@ -1167,6 +1198,11 @@
function finishStrikeRender(tbody, prevSelected, matchedSelected) {
bindStrikePickButtons(tbody);
applyCondPickLock();
if (state.condOrderLocked) {
state.selectedInst = null;
return;
}
if (matchedSelected && prevSelected) {
selectContract(prevSelected, null, true);
} else if (!matchedSelected) {
@@ -1407,6 +1443,10 @@
}
async function selectContract(instId, pickBtn, silent) {
if (state.condOrderLocked) {
applyCondPickLock();
return null;
}
const seq = ++selectSeq;
state.selectedInst = instId;
placeOrderPanelAfter(instId);
@@ -2332,6 +2372,10 @@
if (!card) return;
const order = d && d.cond_order;
const locked = !!(d && d.cond_order_locked);
const wasLocked = !!state.condOrderLocked;
state.condOrderLocked = locked || !!order;
if (state.condOrderLocked && !wasLocked) closeOrderDialog();
applyCondPickLock();
if (!order && !locked) {
card.hidden = true;
return;