From 27c116f872cee2cdb03258810d2b54f3844aa20a Mon Sep 17 00:00:00 2001 From: dekun Date: Sat, 18 Jul 2026 15:28:52 +0800 Subject: [PATCH] Stop embed form interceptor from blanking trade records after journal save. Exclude journal-form from InstanceEmbed submit reload, stopImmediatePropagation on AJAX save, and force-reload trades when the table is stuck on loading. Co-authored-by: Cursor --- lib/common/static/instance_embed.js | 9 +++++++-- lib/common/static/journal_form_save.js | 2 ++ lib/common/static/records_review_page.js | 12 ++++++++++-- lib/instance/templates/embed_shell.html | 6 +++--- lib/instance/templates/index.html | 4 ++-- 5 files changed, 24 insertions(+), 9 deletions(-) diff --git a/lib/common/static/instance_embed.js b/lib/common/static/instance_embed.js index 7253dfa..f15bde0 100644 --- a/lib/common/static/instance_embed.js +++ b/lib/common/static/instance_embed.js @@ -25,8 +25,13 @@ const tabPanes = new Map(); const tabBooted = new Set(); - /** 自带校验后 form.submit() 的表单,勿在捕获阶段再 fetch 一份(会双发 POST) */ - const CUSTOM_SUBMIT_FORM_IDS = new Set(["add-order-form", "key-form", "roll-form"]); + /** 自带 AJAX/校验提交的表单,勿在捕获阶段再 fetch+reloadCurrentTab(会卡在「加载中…」) */ + const CUSTOM_SUBMIT_FORM_IDS = new Set([ + "add-order-form", + "key-form", + "roll-form", + "journal-form", + ]); function isEmbedShell() { return document.body && document.body.getAttribute("data-embed-shell") === "1"; diff --git a/lib/common/static/journal_form_save.js b/lib/common/static/journal_form_save.js index 873aade..0ccbd73 100644 --- a/lib/common/static/journal_form_save.js +++ b/lib/common/static/journal_form_save.js @@ -141,10 +141,12 @@ if (typeof global.validateJournalEntryReason === "function") { if (!global.validateJournalEntryReason()) { ev.preventDefault(); + if (typeof ev.stopImmediatePropagation === "function") ev.stopImmediatePropagation(); return; } } ev.preventDefault(); + if (typeof ev.stopImmediatePropagation === "function") ev.stopImmediatePropagation(); submitAjax(form); } diff --git a/lib/common/static/records_review_page.js b/lib/common/static/records_review_page.js index 76e8e36..3010ecd 100644 --- a/lib/common/static/records_review_page.js +++ b/lib/common/static/records_review_page.js @@ -567,14 +567,22 @@ function init(opts) { opts = opts || {}; if (!$("records-panel-root")) return; + var tbody = $("rr-trades-tbody"); + var stuckLoading = + !!tbody && + tbody.querySelectorAll("tr").length <= 1 && + /加载中/.test(String(tbody.textContent || "")); if (booted) { - if (opts.refresh) { - loadTradeRecords({ soft: true }); + if (opts.refresh || stuckLoading) { + loadTradeRecords({ soft: !stuckLoading }); loadJournalsPaged(); loadReviewsPaged(); } patchFillJournalFromTrade(); patchDeleteTradeRecord(); + if (global.JournalFormSave && typeof global.JournalFormSave.init === "function") { + global.JournalFormSave.init(); + } return; } booted = true; diff --git a/lib/instance/templates/embed_shell.html b/lib/instance/templates/embed_shell.html index 2deea46..4c64fda 100644 --- a/lib/instance/templates/embed_shell.html +++ b/lib/instance/templates/embed_shell.html @@ -97,7 +97,7 @@ - + {% include 'embed_boot_scripts.html' %} - + - + diff --git a/lib/instance/templates/index.html b/lib/instance/templates/index.html index 2750fe7..c6a7170 100644 --- a/lib/instance/templates/index.html +++ b/lib/instance/templates/index.html @@ -456,7 +456,7 @@ - + - +