verce-vue-test 0.0.72 → 0.0.74

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "verce-vue-test",
3
- "version": "0.0.72",
3
+ "version": "0.0.74",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "scripts": {
@@ -10,8 +10,8 @@ export default {
10
10
  </script>
11
11
 
12
12
  <script setup lang="ts">
13
- import { onActivated, onBeforeUnmount, onDeactivated, onMounted, ref, type Component } from 'vue'
14
- import { onBeforeRouteLeave } from 'vue-router'
13
+ import { computed, onActivated, onBeforeUnmount, onDeactivated, onMounted, ref, watch, type Component } from 'vue'
14
+ import { onBeforeRouteLeave, useRoute } from 'vue-router'
15
15
  import { storeToRefs } from 'pinia'
16
16
  import { Grid, Menu } from '@element-plus/icons-vue'
17
17
  import ForecastInfoPanel from './components/ForecastInfoPanel.vue'
@@ -33,6 +33,15 @@ const layoutOptions: Array<{ label: string; value: ForecastInfoCardLayout; icon:
33
33
  const forecastInfoStore = useForecastInfoStore()
34
34
  const { cardLayout } = storeToRefs(forecastInfoStore)
35
35
 
36
+ /**
37
+ * 记录创建当前页面实例的路由记录。
38
+ * 部分多页签 Layout 不会真正卸载旧 RouterView,而是自行缓存后继续保留其 DOM;
39
+ * 此时 Vue 的 deactivated 生命周期不一定会执行,需要根据当前 matched 链主动隐藏旧页面。
40
+ */
41
+ const route = useRoute()
42
+ const ownerRouteRecord = route.matched[route.matched.length - 1]
43
+ const isCurrentRoute = computed(() => !ownerRouteRecord || route.matched.includes(ownerRouteRecord))
44
+
36
45
  /**
37
46
  * 页面专属的浮层挂载点。
38
47
  * 抽屉和弹窗不再直接挂到 body,避免 Layout 路由切换或 KeepAlive 缓存时遮罩残留在其他页面上。
@@ -143,9 +152,27 @@ function cleanupBeforeRouteLeave() {
143
152
  void exitPageFullscreen().catch(() => undefined)
144
153
  }
145
154
 
146
- return true
147
155
  }
148
156
 
157
+ /**
158
+ * 作为 Layout 缓存实现异常时的最后一道隔离:
159
+ * 路由已切走但旧页面仍留在 DOM 中时,v-show 会同步移除其可视区域和固定定位浮层。
160
+ */
161
+ watch(
162
+ isCurrentRoute,
163
+ (active) => {
164
+ if (active) {
165
+ startFullscreenListener()
166
+ return
167
+ }
168
+
169
+ stopFullscreenListener()
170
+ closePageTransientOverlays()
171
+ void exitPageFullscreen().catch(() => undefined)
172
+ },
173
+ { flush: 'sync' },
174
+ )
175
+
149
176
  onMounted(startFullscreenListener)
150
177
  onActivated(startFullscreenListener)
151
178
  onBeforeRouteLeave(cleanupBeforeRouteLeave)
@@ -164,6 +191,7 @@ onBeforeUnmount(() => {
164
191
  <template>
165
192
  <!-- 水平布局使用两列;垂直布局由公共样式切换为两行等高卡片。 -->
166
193
  <div
194
+ v-show="isCurrentRoute"
167
195
  ref="pageContainer"
168
196
  class="forecast-info-page"
169
197
  data-page-scope="rmb-position-settlement-forecast-info"
@@ -217,6 +217,7 @@ async function handleFlowQuery() {
217
217
  flowPage.value = 1
218
218
  const params = buildFlowQueryParams()
219
219
  flowQueryParams.value = params
220
+ forecastInfoStore.resetAllTableSelections()
220
221
  console.log('流水信息查询参数', params)
221
222
  let loaded = false
222
223
 
@@ -352,6 +353,7 @@ function getFlowSequence(index: number) {
352
353
  <!-- 表格填满卡片余高;多选值直接写入 Pinia,供预报核销与匡算联动读取。 -->
353
354
  <section class="forecast-info-table-area" aria-label="流水信息列表">
354
355
  <ElTablePro
356
+ :key="`flow-table-${tableSelectionResetKey}`"
355
357
  ref="flowTable"
356
358
  v-model:page="flowPage"
357
359
  v-model:page-size="flowPageSize"
@@ -334,6 +334,7 @@ async function handleForecastQuery() {
334
334
  const generation = ++forecastQueryGeneration
335
335
  const params = buildForecastQueryParams()
336
336
  forecastPage.value = 1
337
+ forecastInfoStore.resetAllTableSelections()
337
338
  console.log('预报信息查询条件', params)
338
339
  let loaded = false
339
340
 
@@ -600,6 +601,7 @@ function handleForecastPaginationChange(_value: { page: number; pageSize: number
600
601
  </div>
601
602
  </div>
602
603
  <ElTablePro
604
+ :key="`forecast-table-${tableSelectionResetKey}`"
603
605
  ref="forecastTable"
604
606
  v-model:page="forecastPage"
605
607
  v-model:page-size="forecastPageSize"
@@ -1077,6 +1077,8 @@ export const useForecastInfoStore = defineStore('rmb-position-settlement-forecas
1077
1077
 
1078
1078
  forecastRows.value = response.resultList.map((item) => ({ ...item }))
1079
1079
  forecastTotal.value = normalizeTotalCount(response)
1080
+ // 数据替换后再次通知表格清理,避免表头全选状态沿用上一批数据。
1081
+ resetAllTableSelections()
1080
1082
  return true
1081
1083
  } catch (error) {
1082
1084
  // Axios 等请求库可能抛出 CanceledError;以当前控制器状态为准,避免离页取消进入全局错误处理。
@@ -1125,6 +1127,8 @@ export const useForecastInfoStore = defineStore('rmb-position-settlement-forecas
1125
1127
 
1126
1128
  flowRows.value = response.resultList.map((item) => ({ ...item }))
1127
1129
  flowTotal.value = normalizeTotalCount(response)
1130
+ // 数据替换后再次通知表格清理,避免表头全选状态沿用上一批数据。
1131
+ resetAllTableSelections()
1128
1132
  return true
1129
1133
  } catch (error) {
1130
1134
  // Axios 等请求库可能抛出 CanceledError;以当前控制器状态为准,避免离页取消进入全局错误处理。