fix: 市价加仓预览后无法执行滚仓
修复 embed 壳拦截 roll-form 提交,以及策略 tab 切换后未重新绑定顺势加仓脚本的问题。 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -841,7 +841,7 @@
|
||||
<script src="/static/ai_review_render.js?v=2"></script>
|
||||
<script src="/static/form_submit_guard.js?v=2"></script>
|
||||
<script src="/static/manual_order_rr_preview.js?v=5"></script>
|
||||
<script src="/static/strategy_roll.js?v=5"></script>
|
||||
<script src="/static/strategy_roll.js?v=6"></script>
|
||||
<script>
|
||||
const JOURNAL_ENTRY_REASON_OPTIONS = {{ entry_reason_options | tojson }};
|
||||
const JOURNAL_ENTRY_REASON_OTHER = {{ entry_reason_other_value | tojson }};
|
||||
|
||||
@@ -808,7 +808,7 @@
|
||||
<script src="/static/ai_review_render.js?v=2"></script>
|
||||
<script src="/static/form_submit_guard.js?v=2"></script>
|
||||
<script src="/static/manual_order_rr_preview.js?v=5"></script>
|
||||
<script src="/static/strategy_roll.js?v=5"></script>
|
||||
<script src="/static/strategy_roll.js?v=6"></script>
|
||||
<script>
|
||||
const JOURNAL_ENTRY_REASON_OPTIONS = {{ entry_reason_options | tojson }};
|
||||
const JOURNAL_ENTRY_REASON_OTHER = {{ entry_reason_other_value | tojson }};
|
||||
|
||||
@@ -808,7 +808,7 @@
|
||||
<script src="/static/ai_review_render.js?v=2"></script>
|
||||
<script src="/static/form_submit_guard.js?v=2"></script>
|
||||
<script src="/static/manual_order_rr_preview.js?v=5"></script>
|
||||
<script src="/static/strategy_roll.js?v=5"></script>
|
||||
<script src="/static/strategy_roll.js?v=6"></script>
|
||||
<script>
|
||||
const JOURNAL_ENTRY_REASON_OPTIONS = {{ entry_reason_options | tojson }};
|
||||
const JOURNAL_ENTRY_REASON_OTHER = {{ entry_reason_other_value | tojson }};
|
||||
|
||||
@@ -837,7 +837,7 @@
|
||||
<script src="/static/ai_review_render.js?v=2"></script>
|
||||
<script src="/static/form_submit_guard.js?v=2"></script>
|
||||
<script src="/static/manual_order_rr_preview.js?v=5"></script>
|
||||
<script src="/static/strategy_roll.js?v=5"></script>
|
||||
<script src="/static/strategy_roll.js?v=6"></script>
|
||||
<script>
|
||||
const JOURNAL_ENTRY_REASON_OPTIONS = {{ entry_reason_options | tojson }};
|
||||
const JOURNAL_ENTRY_REASON_OTHER = {{ entry_reason_other_value | tojson }};
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
let loadingTab = false;
|
||||
|
||||
/** 自带校验后 form.submit() 的表单,勿在捕获阶段再 fetch 一份(会双发 POST) */
|
||||
const CUSTOM_SUBMIT_FORM_IDS = new Set(["add-order-form", "key-form"]);
|
||||
const CUSTOM_SUBMIT_FORM_IDS = new Set(["add-order-form", "key-form", "roll-form"]);
|
||||
|
||||
function isEmbedShell() {
|
||||
return document.body && document.body.getAttribute("data-embed-shell") === "1";
|
||||
@@ -71,6 +71,9 @@
|
||||
if (tab === "key_monitor" && global.KeyMonitorForm && typeof global.KeyMonitorForm.init === "function") {
|
||||
global.KeyMonitorForm.init();
|
||||
}
|
||||
if (tab === "strategy" && typeof global.initStrategyRollForm === "function") {
|
||||
global.initStrategyRollForm();
|
||||
}
|
||||
if (tab === "records") {
|
||||
if (typeof global.loadJournals === "function") global.loadJournals();
|
||||
if (typeof global.loadReviews === "function") global.loadReviews();
|
||||
|
||||
@@ -30,6 +30,23 @@
|
||||
|
||||
window.syncRollFormMode = syncRollFormMode;
|
||||
|
||||
function isEmbedShell() {
|
||||
return document.body && document.body.getAttribute("data-embed-shell") === "1";
|
||||
}
|
||||
|
||||
function submitRollForm(form) {
|
||||
if (isEmbedShell() && window.InstanceEmbed && typeof window.InstanceEmbed.postFormAndReload === "function") {
|
||||
window.InstanceEmbed.postFormAndReload(form, "执行中…");
|
||||
return;
|
||||
}
|
||||
if (window.FormSubmitGuard && typeof window.FormSubmitGuard.nativeSubmitOnce === "function") {
|
||||
window.FormSubmitGuard.nativeSubmitOnce(form, "执行中…");
|
||||
return;
|
||||
}
|
||||
form.submit();
|
||||
}
|
||||
|
||||
function initStrategyRollForm() {
|
||||
const form = document.getElementById("roll-form");
|
||||
if (!form) return;
|
||||
if (form.dataset.rollJsInit === "1") return;
|
||||
@@ -81,9 +98,12 @@
|
||||
if (!submitBtn || trendLocked) return;
|
||||
if (isMonitorMode()) {
|
||||
submitBtn.disabled = false;
|
||||
submitBtn.removeAttribute("disabled");
|
||||
return;
|
||||
}
|
||||
submitBtn.disabled = !previewOk || !!countdownTimer;
|
||||
const blocked = !previewOk || !!countdownTimer;
|
||||
submitBtn.disabled = blocked;
|
||||
if (!blocked) submitBtn.removeAttribute("disabled");
|
||||
}
|
||||
|
||||
function clearMessageBox() {
|
||||
@@ -206,7 +226,10 @@
|
||||
requestPreview()
|
||||
.then(function (data) {
|
||||
monitorSubmitting = false;
|
||||
if (submitBtn && !trendLocked) submitBtn.disabled = false;
|
||||
if (submitBtn && !trendLocked) {
|
||||
submitBtn.disabled = false;
|
||||
submitBtn.removeAttribute("disabled");
|
||||
}
|
||||
if (!data.ok) {
|
||||
showReject(data.msg || "无法提交监控");
|
||||
return;
|
||||
@@ -223,11 +246,14 @@
|
||||
if (!confirm("确认提交「" + modeLabel + "」?\n" + summary)) {
|
||||
return;
|
||||
}
|
||||
form.submit();
|
||||
submitRollForm(form);
|
||||
})
|
||||
.catch(function () {
|
||||
monitorSubmitting = false;
|
||||
if (submitBtn && !trendLocked) submitBtn.disabled = false;
|
||||
if (submitBtn && !trendLocked) {
|
||||
submitBtn.disabled = false;
|
||||
submitBtn.removeAttribute("disabled");
|
||||
}
|
||||
showReject("校验请求失败,请稍后重试");
|
||||
});
|
||||
}
|
||||
@@ -263,27 +289,30 @@
|
||||
});
|
||||
if (previewBtn) previewBtn.addEventListener("click", runPreview);
|
||||
form.addEventListener("submit", function (e) {
|
||||
if (isMonitorMode()) {
|
||||
e.preventDefault();
|
||||
if (isMonitorMode()) {
|
||||
runMonitorSubmit();
|
||||
return;
|
||||
}
|
||||
if (!previewOk) {
|
||||
e.preventDefault();
|
||||
showReject("请先点击「预览」并通过校验");
|
||||
return;
|
||||
}
|
||||
if (submitBtn && submitBtn.disabled) {
|
||||
e.preventDefault();
|
||||
showReject("请等待 10 秒确认倒计时结束后再执行市价加仓");
|
||||
return;
|
||||
}
|
||||
const modeLabel = modeSel.options[modeSel.selectedIndex].text;
|
||||
if (!confirm("确认提交「" + modeLabel + "」?")) {
|
||||
e.preventDefault();
|
||||
return;
|
||||
}
|
||||
submitRollForm(form);
|
||||
});
|
||||
|
||||
syncDirectionLock();
|
||||
syncFieldVisibility();
|
||||
}
|
||||
|
||||
window.initStrategyRollForm = initStrategyRollForm;
|
||||
initStrategyRollForm();
|
||||
})();
|
||||
|
||||
@@ -118,9 +118,9 @@
|
||||
<script src="/static/ai_review_render.js?v=2"></script>
|
||||
<script src="/static/form_submit_guard.js?v=2"></script>
|
||||
<script src="/static/manual_order_rr_preview.js?v=5"></script>
|
||||
<script src="/static/strategy_roll.js?v=5"></script>
|
||||
<script src="/static/strategy_roll.js?v=6"></script>
|
||||
<script src="/static/key_monitor_form.js?v=2"></script>
|
||||
{% include 'embed_boot_scripts.html' %}
|
||||
<script src="/static/instance_embed.js?v=5"></script>
|
||||
<script src="/static/instance_embed.js?v=6"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@@ -14,6 +14,6 @@
|
||||
{% include 'strategy_roll_panel.html' %}
|
||||
<p class="rule-tip" style="margin-top:12px"><a href="/strategy/roll/docs" style="color:#8fc8ff">顺势加仓完整逻辑说明</a></p>
|
||||
</div>
|
||||
<script src="/static/strategy_roll.js?v=5"></script>
|
||||
<script src="/static/strategy_roll.js?v=6"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
Reference in New Issue
Block a user