Bladeren bron

修复编辑页到详情页没有解锁问题

MY 2 weken geleden
bovenliggende
commit
6b41f7043b
1 gewijzigde bestanden met toevoegingen van 21 en 1 verwijderingen
  1. 21 1
      JLHWEB/src/stores/modules/keepAlive.ts

+ 21 - 1
JLHWEB/src/stores/modules/keepAlive.ts

@@ -340,6 +340,15 @@ export const useKeepAliveStore = defineStore({
           tabStore.setTabs(tabsMenuList);
 
           // 移除编辑页的 keepAlive 缓存(removeKeepAliveName 已包含解锁逻辑)
+          console.log("情况1解锁检查:", {
+            oldEditTab: {
+              path: oldEditTab.path,
+              needLock: oldEditTab.needLock,
+              billid: oldEditTab.billid,
+              keyword: oldEditTab.keyword,
+              billcode: oldEditTab.billcode
+            }
+          });
           this.removeKeepAliveName(oldEditTab);
 
           isReplace = true;
@@ -418,9 +427,20 @@ export const useKeepAliveStore = defineStore({
           tabsMenuList[editTabIndex] = tabsParams;
           tabStore.setTabs(tabsMenuList);
 
-          // 移除编辑页的 keepAlive 缓存(removeKeepAliveName 已包含解锁逻辑)
+          // 移除编辑页的 keepAlive 缓存
           this.removeKeepAliveName(from);
 
+          // 手动解锁单据(因为 from 路由对象可能缺少锁定属性,需要单独处理)
+          if (from.meta?.needLock && from.query?.id) {
+            UnLockBill({
+              keyword: String(from.meta.billtype),
+              billid: Number(from.query.id),
+              billcode: String(from.query.code)
+            }).catch(err => {
+              console.warn("edit->detail 解锁失败:", err);
+            });
+          }
+
           isReplace = true;
           to.meta.isKeepAlive && this.addKeepAliveName(to);
           to.meta.isKeepAlive && this.updateKeepAliveName(to);