verce-vue-test 0.0.69 → 0.0.71

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.
@@ -9,8 +9,10 @@ export default {
9
9
  </script>
10
10
 
11
11
  <script setup lang="ts">
12
- import { ref, type Component } from 'vue'
12
+ import { onBeforeUnmount, onDeactivated, onMounted, ref, type Component } from 'vue'
13
+ import { onBeforeRouteLeave } from 'vue-router'
13
14
  import { storeToRefs } from 'pinia'
15
+ import { ElMessage } from 'element-plus'
14
16
  import { Grid, Menu } from '@element-plus/icons-vue'
15
17
  import ForecastInfoPanel from './components/ForecastInfoPanel.vue'
16
18
  import FlowInfoPanel from './components/FlowInfoPanel.vue'
@@ -35,25 +37,116 @@ const { cardLayout } = storeToRefs(forecastInfoStore)
35
37
  * 抽屉和弹窗不再直接挂到 body,避免 Layout 路由切换或 KeepAlive 缓存时遮罩残留在其他页面上。
36
38
  */
37
39
  const overlayContainer = ref<HTMLElement | null>(null)
40
+ /** 全屏只挂载当前业务页面,浏览器会自动排除外层侧边栏和顶部 Layout。 */
41
+ const pageContainer = ref<HTMLElement | null>(null)
42
+ const isFullscreen = ref(false)
43
+
44
+ type TransientOverlayController = {
45
+ closeTransientOverlays: () => void
46
+ }
47
+
48
+ /**
49
+ * 父页面统一持有两个面板的临时浮层清理入口。
50
+ * 这样路由离开时可以先清理页面状态,不依赖目标项目的 RouterView 是否使用 KeepAlive。
51
+ */
52
+ const forecastInfoPanel = ref<TransientOverlayController | null>(null)
53
+ const flowInfoPanel = ref<TransientOverlayController | null>(null)
54
+
55
+ function syncFullscreenState() {
56
+ isFullscreen.value = document.fullscreenElement === pageContainer.value
57
+ }
58
+
59
+ async function toggleFullscreen() {
60
+ const container = pageContainer.value
61
+
62
+ if (!container) return
63
+
64
+ try {
65
+ if (document.fullscreenElement === container) {
66
+ await document.exitFullscreen()
67
+ return
68
+ }
69
+
70
+ if (!container.requestFullscreen) {
71
+ ElMessage.warning('当前浏览器不支持页面全屏')
72
+ return
73
+ }
74
+
75
+ await container.requestFullscreen()
76
+ } catch {
77
+ ElMessage.error('进入全屏失败,请检查浏览器权限设置')
78
+ }
79
+ }
80
+
81
+ async function exitPageFullscreen() {
82
+ if (document.fullscreenElement === pageContainer.value) {
83
+ try {
84
+ await document.exitFullscreen()
85
+ } catch {
86
+ // 退出失败也不能阻断路由跳转;浏览器在全屏元素移除后会自行恢复。
87
+ } finally {
88
+ isFullscreen.value = false
89
+ }
90
+ }
91
+ }
92
+
93
+ function closePageTransientOverlays() {
94
+ forecastInfoPanel.value?.closeTransientOverlays()
95
+ flowInfoPanel.value?.closeTransientOverlays()
96
+ }
97
+
98
+ /**
99
+ * 路由守卫早于组件停用和卸载执行。
100
+ * 在 Layout、KeepAlive、多页签等不同承载方式下,都先退出浏览器顶层全屏并移除本页遮罩。
101
+ */
102
+ async function cleanupBeforeRouteLeave() {
103
+ closePageTransientOverlays()
104
+ await exitPageFullscreen()
105
+ }
106
+
107
+ onMounted(() => document.addEventListener('fullscreenchange', syncFullscreenState))
108
+ onBeforeRouteLeave(cleanupBeforeRouteLeave)
109
+ onDeactivated(() => {
110
+ closePageTransientOverlays()
111
+ void exitPageFullscreen()
112
+ })
113
+ onBeforeUnmount(() => {
114
+ document.removeEventListener('fullscreenchange', syncFullscreenState)
115
+ closePageTransientOverlays()
116
+ void exitPageFullscreen()
117
+ })
38
118
  </script>
39
119
 
40
120
  <template>
41
121
  <!-- 水平布局使用两列;垂直布局由公共样式切换为两行等高卡片。 -->
42
- <div class="forecast-info-page" :class="{ 'forecast-info-page--horizontal': cardLayout === 'horizontal' }">
122
+ <div
123
+ ref="pageContainer"
124
+ class="forecast-info-page"
125
+ :class="{
126
+ 'forecast-info-page--horizontal': cardLayout === 'horizontal',
127
+ 'forecast-info-page--fullscreen': isFullscreen,
128
+ }"
129
+ >
43
130
  <!-- 固定定位且不参与网格布局,专门承接本页抽屉和弹窗。 -->
44
131
  <div ref="overlayContainer" class="forecast-info-overlay-host"></div>
45
132
  <!-- 两个面板接收同一布局值,保证任一入口切换后页面整体保持一致。 -->
46
133
  <ForecastInfoPanel
134
+ ref="forecastInfoPanel"
47
135
  :layout="cardLayout"
48
136
  :layout-options="layoutOptions"
49
137
  :overlay-container="overlayContainer"
138
+ :is-fullscreen="isFullscreen"
50
139
  @change-layout="forecastInfoStore.setCardLayout"
140
+ @toggle-fullscreen="toggleFullscreen"
51
141
  />
52
142
  <FlowInfoPanel
143
+ ref="flowInfoPanel"
53
144
  :layout="cardLayout"
54
145
  :layout-options="layoutOptions"
55
146
  :overlay-container="overlayContainer"
147
+ :is-fullscreen="isFullscreen"
56
148
  @change-layout="forecastInfoStore.setCardLayout"
149
+ @toggle-fullscreen="toggleFullscreen"
57
150
  />
58
151
  </div>
59
152
  </template>
@@ -2,7 +2,7 @@
2
2
  import { computed, onBeforeUnmount, onDeactivated, reactive, ref, type Component } from 'vue'
3
3
  import { storeToRefs } from 'pinia'
4
4
  import { ElMessage } from 'element-plus'
5
- import { Search } from '@element-plus/icons-vue'
5
+ import { FullScreen, Search } from '@element-plus/icons-vue'
6
6
  import type { RangeValue } from '@/components/NumberRange.vue'
7
7
  import { formatThousands } from '@/utils/formatters'
8
8
  import {
@@ -32,12 +32,15 @@ type TableColumn = {
32
32
  defineProps<{
33
33
  layout: ForecastInfoCardLayout
34
34
  layoutOptions: LayoutOption[]
35
+ /** 当前页面是否已进入浏览器全屏。 */
36
+ isFullscreen: boolean
35
37
  /** 页面级局部浮层容器,防止抽屉直接挂到 Layout 的 body 节点。 */
36
38
  overlayContainer: HTMLElement | null
37
39
  }>()
38
40
 
39
41
  const emit = defineEmits<{
40
42
  changeLayout: [layout: ForecastInfoCardLayout]
43
+ toggleFullscreen: []
41
44
  }>()
42
45
 
43
46
  /** 流水接口方向编码与预报不同:1 为收入,0 为支出。 */
@@ -108,6 +111,7 @@ const {
108
111
  flowLoading,
109
112
  flowQueryParams,
110
113
  flowSelectedRows,
114
+ tableSelectionResetKey,
111
115
  } = storeToRefs(forecastInfoStore)
112
116
 
113
117
  /**
@@ -134,6 +138,11 @@ function closeFlowTransientOverlays() {
134
138
  flowDrawerVisible.value = false
135
139
  }
136
140
 
141
+ /** 供路由页在 leave 守卫阶段提前清理,兼容不同项目的 Layout 与 KeepAlive 实现。 */
142
+ defineExpose({
143
+ closeTransientOverlays: closeFlowTransientOverlays,
144
+ })
145
+
137
146
  onDeactivated(closeFlowTransientOverlays)
138
147
  onBeforeUnmount(closeFlowTransientOverlays)
139
148
 
@@ -192,8 +201,9 @@ function handleFlowReset() {
192
201
  ElMessage.info('流水筛选条件已重置')
193
202
  }
194
203
 
195
- /** 翻页或改变每页条数时复用当前表单映射,避免遗漏后端参数字段。 */
204
+ /** 翻页或改变每页条数时先清空两张表选择,再复用当前表单映射。 */
196
205
  function handleFlowPaginationChange(_value: { page: number; pageSize: number }) {
206
+ forecastInfoStore.resetAllTableSelections()
197
207
  const params = buildFlowQueryParams()
198
208
  flowQueryParams.value = params
199
209
  forecastInfoStore.loadFlowInfoList(params)
@@ -210,28 +220,48 @@ function getFlowSequence(index: number) {
210
220
  <!-- 卡片标题和页面级布局切换;操作会同步影响预报卡片。 -->
211
221
  <header class="forecast-info-card__header">
212
222
  <h2 id="flow-info-title" class="forecast-info-card__title">流水信息</h2>
213
- <div class="forecast-info-layout-switch" role="radiogroup" aria-label="切换流水信息卡片排列方式">
223
+ <div class="forecast-info-header-actions">
214
224
  <el-tooltip
215
- v-for="option in layoutOptions"
216
- :key="option.value"
217
- :content="option.label"
225
+ :content="isFullscreen ? '退出全屏' : '全屏显示'"
218
226
  placement="top"
219
227
  :show-after="200"
228
+ :append-to="overlayContainer || undefined"
220
229
  >
221
230
  <button
222
231
  type="button"
223
- class="forecast-info-layout-switch__button"
224
- :class="{ 'is-active': layout === option.value }"
225
- role="radio"
226
- :aria-label="option.label"
227
- :aria-checked="layout === option.value"
228
- @click="emit('changeLayout', option.value)"
232
+ class="forecast-info-fullscreen-button"
233
+ :class="{ 'is-active': isFullscreen }"
234
+ :aria-label="isFullscreen ? '退出全屏' : '全屏显示当前页面'"
235
+ :aria-pressed="isFullscreen"
236
+ @click="emit('toggleFullscreen')"
229
237
  >
230
- <el-icon>
231
- <component :is="option.icon" />
232
- </el-icon>
238
+ <el-icon><FullScreen /></el-icon>
233
239
  </button>
234
240
  </el-tooltip>
241
+ <div class="forecast-info-layout-switch" role="radiogroup" aria-label="切换流水信息卡片排列方式">
242
+ <el-tooltip
243
+ v-for="option in layoutOptions"
244
+ :key="option.value"
245
+ :content="option.label"
246
+ placement="top"
247
+ :show-after="200"
248
+ :append-to="overlayContainer || undefined"
249
+ >
250
+ <button
251
+ type="button"
252
+ class="forecast-info-layout-switch__button"
253
+ :class="{ 'is-active': layout === option.value }"
254
+ role="radio"
255
+ :aria-label="option.label"
256
+ :aria-checked="layout === option.value"
257
+ @click="emit('changeLayout', option.value)"
258
+ >
259
+ <el-icon>
260
+ <component :is="option.icon" />
261
+ </el-icon>
262
+ </button>
263
+ </el-tooltip>
264
+ </div>
235
265
  </div>
236
266
  </header>
237
267
 
@@ -275,6 +305,7 @@ function getFlowSequence(index: number) {
275
305
  :total="flowTotal"
276
306
  v-loading="flowLoading"
277
307
  table-key="flow-info"
308
+ :selection-reset-key="tableSelectionResetKey"
278
309
  row-key="refNo"
279
310
  border
280
311
  stripe
@@ -7,6 +7,7 @@ import {
7
7
  CirclePlus,
8
8
  DataAnalysis,
9
9
  EditPen,
10
+ FullScreen,
10
11
  Money,
11
12
  RefreshLeft,
12
13
  Search,
@@ -54,6 +55,8 @@ const amountColumnProps = new Set(['predAmt', 'verifyAmt'])
54
55
  defineProps<{
55
56
  layout: ForecastInfoCardLayout
56
57
  layoutOptions: LayoutOption[]
58
+ /** 当前页面是否已进入浏览器全屏。 */
59
+ isFullscreen: boolean
57
60
  /** 页面级局部浮层容器,防止抽屉与弹窗直接污染 Layout 的 body 节点。 */
58
61
  overlayContainer: HTMLElement | null
59
62
  }>()
@@ -61,6 +64,7 @@ defineProps<{
61
64
  /** 任一业务卡片点击布局图标时,将新布局回传给页面容器。 */
62
65
  const emit = defineEmits<{
63
66
  changeLayout: [layout: ForecastInfoCardLayout]
67
+ toggleFullscreen: []
64
68
  }>()
65
69
 
66
70
  /** 预报筛选的后端收支方向编码。 */
@@ -175,7 +179,8 @@ const modifyForm = reactive({
175
179
  /** 页面级 store 提供跨预报、流水表共享的业务状态与操作。 */
176
180
  const forecastInfoStore = useForecastInfoStore()
177
181
  /** 工具栏按钮仅在至少选择一条预报信息时可用。 */
178
- const { forecastHasSelectedRows, forecastSelectedRows } = storeToRefs(forecastInfoStore)
182
+ const { forecastHasSelectedRows, forecastSelectedRows, tableSelectionResetKey } =
183
+ storeToRefs(forecastInfoStore)
179
184
  /** 列表、分页、加载状态和匡算弹窗状态均从 Pinia 取值,避免布局切换后丢失。 */
180
185
  const {
181
186
  forecastRows,
@@ -237,8 +242,14 @@ function closeForecastTransientOverlays() {
237
242
  forecastDrawerVisible.value = false
238
243
  modifyDialogVisible.value = false
239
244
  calculationDialogVisible.value = false
245
+ ElMessageBox.close()
240
246
  }
241
247
 
248
+ /** 供路由页在 leave 守卫阶段提前清理,避免等待 KeepAlive 停用后才释放遮罩。 */
249
+ defineExpose({
250
+ closeTransientOverlays: closeForecastTransientOverlays,
251
+ })
252
+
242
253
  onDeactivated(closeForecastTransientOverlays)
243
254
  onBeforeUnmount(closeForecastTransientOverlays)
244
255
 
@@ -373,8 +384,9 @@ function getForecastSequence(index: number) {
373
384
  return (forecastPage.value - 1) * forecastPageSize.value + index + 1
374
385
  }
375
386
 
376
- /** 翻页直接复用 Pinia 保存的最近一次查询参数。 */
387
+ /** 翻页前清空两张表的选择状态,再复用 Pinia 保存的最近一次查询参数。 */
377
388
  function handleForecastPaginationChange(_value: { page: number; pageSize: number }) {
389
+ forecastInfoStore.resetAllTableSelections()
378
390
  forecastInfoStore.loadForecastInfoList()
379
391
  }
380
392
  </script>
@@ -384,28 +396,48 @@ function handleForecastPaginationChange(_value: { page: number; pageSize: number
384
396
  <!-- 卡片标题与布局切换;两个面板使用相同的切换事件。 -->
385
397
  <header class="forecast-info-card__header">
386
398
  <h2 id="forecast-info-title" class="forecast-info-card__title">预报信息</h2>
387
- <div class="forecast-info-layout-switch" role="radiogroup" aria-label="切换预报信息卡片排列方式">
399
+ <div class="forecast-info-header-actions">
388
400
  <el-tooltip
389
- v-for="option in layoutOptions"
390
- :key="option.value"
391
- :content="option.label"
401
+ :content="isFullscreen ? '退出全屏' : '全屏显示'"
392
402
  placement="top"
393
403
  :show-after="200"
404
+ :append-to="overlayContainer || undefined"
394
405
  >
395
406
  <button
396
407
  type="button"
397
- class="forecast-info-layout-switch__button"
398
- :class="{ 'is-active': layout === option.value }"
399
- role="radio"
400
- :aria-label="option.label"
401
- :aria-checked="layout === option.value"
402
- @click="emit('changeLayout', option.value)"
408
+ class="forecast-info-fullscreen-button"
409
+ :class="{ 'is-active': isFullscreen }"
410
+ :aria-label="isFullscreen ? '退出全屏' : '全屏显示当前页面'"
411
+ :aria-pressed="isFullscreen"
412
+ @click="emit('toggleFullscreen')"
403
413
  >
404
- <el-icon>
405
- <component :is="option.icon" />
406
- </el-icon>
414
+ <el-icon><FullScreen /></el-icon>
407
415
  </button>
408
416
  </el-tooltip>
417
+ <div class="forecast-info-layout-switch" role="radiogroup" aria-label="切换预报信息卡片排列方式">
418
+ <el-tooltip
419
+ v-for="option in layoutOptions"
420
+ :key="option.value"
421
+ :content="option.label"
422
+ placement="top"
423
+ :show-after="200"
424
+ :append-to="overlayContainer || undefined"
425
+ >
426
+ <button
427
+ type="button"
428
+ class="forecast-info-layout-switch__button"
429
+ :class="{ 'is-active': layout === option.value }"
430
+ role="radio"
431
+ :aria-label="option.label"
432
+ :aria-checked="layout === option.value"
433
+ @click="emit('changeLayout', option.value)"
434
+ >
435
+ <el-icon>
436
+ <component :is="option.icon" />
437
+ </el-icon>
438
+ </button>
439
+ </el-tooltip>
440
+ </div>
409
441
  </div>
410
442
  </header>
411
443
 
@@ -475,6 +507,7 @@ function handleForecastPaginationChange(_value: { page: number; pageSize: number
475
507
  :total="forecastTotal"
476
508
  v-loading="forecastLoading"
477
509
  table-key="forecast-info"
510
+ :selection-reset-key="tableSelectionResetKey"
478
511
  row-key="predRefNo"
479
512
  border
480
513
  stripe
@@ -37,6 +37,15 @@
37
37
  align-items: stretch;
38
38
  }
39
39
 
40
+ /* 浏览器全屏时页面根节点独占视口,不再预留外层 Layout 的头部高度。 */
41
+ .forecast-info-page:fullscreen,
42
+ .forecast-info-page--fullscreen {
43
+ width: 100vw;
44
+ height: 100vh;
45
+ margin: 0;
46
+ padding: 12px 14px 14px;
47
+ }
48
+
40
49
  /* ---- 卡片与标题:两张业务卡片共享相同的边框、阴影和内部弹性结构。 ---- */
41
50
  .forecast-info-page .forecast-info-card {
42
51
  display: flex;
@@ -64,6 +73,43 @@
64
73
  padding: 0 4px;
65
74
  }
66
75
 
76
+ .forecast-info-page .forecast-info-header-actions {
77
+ display: inline-flex;
78
+ align-items: center;
79
+ gap: 6px;
80
+ flex: 0 0 auto;
81
+ }
82
+
83
+ .forecast-info-page .forecast-info-fullscreen-button {
84
+ display: inline-flex;
85
+ width: 30px;
86
+ height: 30px;
87
+ align-items: center;
88
+ justify-content: center;
89
+ padding: 0;
90
+ border: 1px solid #d8e1ee;
91
+ border-radius: 5px;
92
+ background: #f6f9fd;
93
+ color: #5f6f86;
94
+ cursor: pointer;
95
+ transition: background-color .16s ease, border-color .16s ease, color .16s ease, box-shadow .16s ease;
96
+ }
97
+
98
+ .forecast-info-page .forecast-info-fullscreen-button:hover,
99
+ .forecast-info-page .forecast-info-fullscreen-button.is-active {
100
+ border-color: #b8cff4;
101
+ background: #e8f1ff;
102
+ color: #1668ff;
103
+ }
104
+
105
+ .forecast-info-page .forecast-info-fullscreen-button.is-active {
106
+ box-shadow: 0 3px 8px rgba(22, 104, 255, .16);
107
+ }
108
+
109
+ .forecast-info-page .forecast-info-fullscreen-button .el-icon {
110
+ font-size: 16px;
111
+ }
112
+
67
113
  .forecast-info-page .forecast-info-layout-switch {
68
114
  display: inline-flex;
69
115
  align-items: center;
@@ -763,6 +763,8 @@ export const useForecastInfoStore = defineStore('forecastInfo', () => {
763
763
  forecastInfo: [],
764
764
  flowInfo: [],
765
765
  })
766
+ /** 业务操作完成后的表格选择重置标识,递增时通知两张表清空内部保留的勾选。 */
767
+ const tableSelectionResetKey = ref(0)
766
768
  /** 预报信息表格已选行,用于匡算等批量操作。 */
767
769
  const forecastSelectedRows = computed(() => tableSelectedRows.value.forecastInfo)
768
770
  /** 流水信息表格已选行,用于匡算等跨表统计。 */
@@ -820,6 +822,12 @@ export const useForecastInfoStore = defineStore('forecastInfo', () => {
820
822
  tableSelectedRows.value.flowInfo = []
821
823
  }
822
824
 
825
+ /** 同时清空 Pinia 选择数据,并通知表格清除 reserve-selection 保存的勾选。 */
826
+ function resetAllTableSelections() {
827
+ clearAllTableSelectedRows()
828
+ tableSelectionResetKey.value += 1
829
+ }
830
+
823
831
  /** 判断指定业务表格是否存在已选数据。 */
824
832
  function hasTableSelectedRows(key: ForecastInfoSelectionKey) {
825
833
  return tableSelectedRows.value[key].length > 0
@@ -957,13 +965,23 @@ export const useForecastInfoStore = defineStore('forecastInfo', () => {
957
965
  return result
958
966
  }
959
967
 
968
+ /** 核销或撤销核销完成后,携带两张表上次的查询条件并发刷新表格。 */
969
+ async function refreshVerificationLists() {
970
+ await Promise.all([
971
+ loadForecastInfoList(forecastQueryParams.value),
972
+ loadFlowInfoList(flowQueryParams.value),
973
+ ])
974
+ resetAllTableSelections()
975
+ }
976
+
960
977
  /** 预报信息核销按钮的统一业务入口。 */
961
- function handleForecastVerify() {
978
+ async function handleForecastVerify() {
962
979
  const params = buildVerificationRequestParams()
963
980
  console.log('核销入参', params)
964
981
 
965
982
  const result = verifySelectedForecastRows()
966
983
  if (result.success) {
984
+ await refreshVerificationLists()
967
985
  ElMessage.info(result.message)
968
986
  return result
969
987
  }
@@ -973,12 +991,13 @@ export const useForecastInfoStore = defineStore('forecastInfo', () => {
973
991
  }
974
992
 
975
993
  /** 预报信息撤销核销按钮的统一业务入口。 */
976
- function handleForecastCancelVerify() {
994
+ async function handleForecastCancelVerify() {
977
995
  const params = buildVerificationRequestParams()
978
996
  console.log('撤销核销入参', params)
979
997
 
980
998
  const result = cancelVerifySelectedForecastRows()
981
999
  if (result.success) {
1000
+ await refreshVerificationLists()
982
1001
  ElMessage.info(result.message)
983
1002
  return result
984
1003
  }
@@ -1058,6 +1077,7 @@ export const useForecastInfoStore = defineStore('forecastInfo', () => {
1058
1077
  flowLoading,
1059
1078
  flowQueryParams,
1060
1079
  tableSelectedRows,
1080
+ tableSelectionResetKey,
1061
1081
  forecastSelectedRows,
1062
1082
  flowSelectedRows,
1063
1083
  forecastHasSelectedRows,
@@ -1069,6 +1089,7 @@ export const useForecastInfoStore = defineStore('forecastInfo', () => {
1069
1089
  setTableSelectedRows,
1070
1090
  clearTableSelectedRows,
1071
1091
  clearAllTableSelectedRows,
1092
+ resetAllTableSelections,
1072
1093
  hasTableSelectedRows,
1073
1094
  // ----预报信息-----
1074
1095
  handleForecastSelectionChange,
@@ -8,6 +8,7 @@ import {
8
8
  Compass,
9
9
  Connection,
10
10
  DataLine,
11
+ Files,
11
12
  HomeFilled,
12
13
  Lock,
13
14
  School,
@@ -215,6 +216,7 @@ const balanceCards = shallowRef<BalanceCard[]>([
215
216
 
216
217
  const menuItems: HomeMenuItem[] = [
217
218
  { label: '总览', route: '/', icon: HomeFilled, active: true },
219
+ { label: '组件', route: '/components', icon: Files },
218
220
  // { label: '驾驶舱', route: '/fund-cockpit', icon: TrendCharts },
219
221
  // { label: '头寸', route: '/position-forecast', icon: DataLine },
220
222
  { label: '公告', route: '/notice-list', icon: Bell },