verce-vue-test 0.0.71 → 0.0.72

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.
@@ -1,7 +1,6 @@
1
1
  <script setup lang="ts">
2
- import { computed, onBeforeUnmount, onDeactivated, reactive, ref, type Component } from 'vue'
2
+ import { computed, onActivated, onBeforeUnmount, onDeactivated, reactive, ref, type Component } from 'vue'
3
3
  import { storeToRefs } from 'pinia'
4
- import { ElMessage, ElMessageBox } from 'element-plus'
5
4
  import {
6
5
  CircleCheck,
7
6
  CirclePlus,
@@ -12,6 +11,7 @@ import {
12
11
  RefreshLeft,
13
12
  Search,
14
13
  Tickets,
14
+ WarningFilled,
15
15
  } from '@element-plus/icons-vue'
16
16
  import type { RangeValue } from '@/components/NumberRange.vue'
17
17
  import { formatThousands } from '@/utils/formatters'
@@ -21,6 +21,7 @@ import {
21
21
  type ForecastInfoQueryParams,
22
22
  type ForecastInfoRow,
23
23
  } from '../store'
24
+ import { useScopedMessage } from '../useScopedMessage'
24
25
 
25
26
  /**
26
27
  * 预报信息业务卡片。
@@ -52,7 +53,7 @@ const releaseStatusMap: Record<string, string> = {
52
53
  const amountColumnProps = new Set(['predAmt', 'verifyAmt'])
53
54
 
54
55
  /** 父页面传入的统一布局状态和可选布局图标。 */
55
- defineProps<{
56
+ const props = defineProps<{
56
57
  layout: ForecastInfoCardLayout
57
58
  layoutOptions: LayoutOption[]
58
59
  /** 当前页面是否已进入浏览器全屏。 */
@@ -60,6 +61,7 @@ defineProps<{
60
61
  /** 页面级局部浮层容器,防止抽屉与弹窗直接污染 Layout 的 body 节点。 */
61
62
  overlayContainer: HTMLElement | null
62
63
  }>()
64
+ const pageMessage = useScopedMessage(() => props.overlayContainer)
63
65
 
64
66
  /** 任一业务卡片点击布局图标时,将新布局回传给页面容器。 */
65
67
  const emit = defineEmits<{
@@ -167,6 +169,9 @@ const forecastForm = reactive(defaultForecastForm())
167
169
  const forecastDrawerVisible = ref(false)
168
170
  /** 已核销预报的修改弹窗显示状态。 */
169
171
  const modifyDialogVisible = ref(false)
172
+ /** 修改校验提示改为页面内受控弹窗,避免全局 MessageBox 的焦点锁残留到其他路由。 */
173
+ const modifyWarningVisible = ref(false)
174
+ const modifyWarningMessage = ref('')
170
175
  /** 当前正在编辑的表格行;关闭弹窗时会清空,避免下一次编辑残留数据。 */
171
176
  const editingForecastRow = ref<ForecastInfoRow | null>(null)
172
177
  /** 修改弹窗的临时表单,其中交易日期和已核销金额仅展示不可编辑。 */
@@ -176,6 +181,16 @@ const modifyForm = reactive({
176
181
  verifyAmt: '',
177
182
  })
178
183
 
184
+ type TableOverlayController = {
185
+ closeTransientOverlays: () => void
186
+ }
187
+
188
+ /** 父面板需要在路由 leave 阶段提前关闭 ElTablePro 自己的列配置弹窗。 */
189
+ const forecastTable = ref<TableOverlayController | null>(null)
190
+ const isPanelActive = ref(true)
191
+ let forecastQueryGeneration = 0
192
+ let forecastOperationGeneration = 0
193
+
179
194
  /** 页面级 store 提供跨预报、流水表共享的业务状态与操作。 */
180
195
  const forecastInfoStore = useForecastInfoStore()
181
196
  /** 工具栏按钮仅在至少选择一条预报信息时可用。 */
@@ -239,10 +254,18 @@ const forecastSelectionSummary = computed(() => {
239
254
  * 防止路由缓存和过渡期间残留遮罩或焦点锁定。
240
255
  */
241
256
  function closeForecastTransientOverlays() {
257
+ pageMessage.closeAll()
258
+ try {
259
+ forecastTable.value?.closeTransientOverlays()
260
+ } catch {
261
+ // 表格浮层清理失败时仍继续关闭本面板其余弹窗。
262
+ }
242
263
  forecastDrawerVisible.value = false
243
264
  modifyDialogVisible.value = false
265
+ handleModifyDialogClosed()
266
+ modifyWarningVisible.value = false
267
+ modifyWarningMessage.value = ''
244
268
  calculationDialogVisible.value = false
245
- ElMessageBox.close()
246
269
  }
247
270
 
248
271
  /** 供路由页在 leave 守卫阶段提前清理,避免等待 KeepAlive 停用后才释放遮罩。 */
@@ -250,8 +273,20 @@ defineExpose({
250
273
  closeTransientOverlays: closeForecastTransientOverlays,
251
274
  })
252
275
 
253
- onDeactivated(closeForecastTransientOverlays)
254
- onBeforeUnmount(closeForecastTransientOverlays)
276
+ function activateForecastPanel() {
277
+ isPanelActive.value = true
278
+ }
279
+
280
+ function deactivateForecastPanel() {
281
+ isPanelActive.value = false
282
+ forecastQueryGeneration += 1
283
+ forecastOperationGeneration += 1
284
+ closeForecastTransientOverlays()
285
+ }
286
+
287
+ onActivated(activateForecastPanel)
288
+ onDeactivated(deactivateForecastPanel)
289
+ onBeforeUnmount(deactivateForecastPanel)
255
290
 
256
291
  /** 将筛选项恢复为默认值,不会自动触发查询。 */
257
292
  function resetForecastForm() {
@@ -296,23 +331,36 @@ function buildForecastQueryParams(): ForecastInfoQueryParams {
296
331
 
297
332
  /** 查询从第一页开始;成功后关闭抽屉,实际请求与结果写入由 Pinia 负责。 */
298
333
  async function handleForecastQuery() {
334
+ const generation = ++forecastQueryGeneration
299
335
  const params = buildForecastQueryParams()
300
336
  forecastPage.value = 1
301
337
  console.log('预报信息查询条件', params)
302
- await forecastInfoStore.loadForecastInfoList(params)
338
+ let loaded = false
339
+
340
+ try {
341
+ loaded = await forecastInfoStore.loadForecastInfoList(params)
342
+ } catch {
343
+ if (isPanelActive.value && generation === forecastQueryGeneration) {
344
+ pageMessage.error('预报信息查询失败,请稍后重试')
345
+ }
346
+ return
347
+ }
348
+
349
+ if (!loaded || !isPanelActive.value || generation !== forecastQueryGeneration) return
350
+
303
351
  forecastDrawerVisible.value = false
304
- ElMessage.success('已查询预报信息')
352
+ pageMessage.success('已查询预报信息')
305
353
  }
306
354
 
307
355
  /** 重置仅影响界面筛选项,保留当前表格数据直到用户再次查询。 */
308
356
  function handleForecastReset() {
309
357
  resetForecastForm()
310
- ElMessage.info('预报筛选条件已重置')
358
+ pageMessage.info('预报筛选条件已重置')
311
359
  }
312
360
 
313
361
  /** 新增等尚未对接接口的工具栏操作统一使用临时提示。 */
314
362
  function handleToolbarAction(action: string) {
315
- ElMessage.info(`${action}功能待接入`)
363
+ pageMessage.info(`${action}功能待接入`)
316
364
  }
317
365
 
318
366
  /** 修改入口只展示在已核销行,状态 2 由后端约定为已核销。 */
@@ -335,31 +383,28 @@ function handleForecastModify(row: ForecastInfoRow) {
335
383
  modifyDialogVisible.value = true
336
384
  }
337
385
 
338
- /** 校验失败时使用确认弹窗,保持修改弹窗不关闭,方便用户继续调整金额。 */
339
- async function showModifyWarning(message: string) {
340
- await ElMessageBox.alert(message, '提示', {
341
- type: 'warning',
342
- confirmButtonText: '确定',
343
- customClass: 'forecast-info-modify-warning',
344
- }).catch(() => undefined)
386
+ /** 校验失败时使用当前页面自己的确认弹窗,不再创建挂到 body 的全局 MessageBox。 */
387
+ function showModifyWarning(message: string) {
388
+ modifyWarningMessage.value = message
389
+ modifyWarningVisible.value = true
345
390
  }
346
391
 
347
392
  /**
348
393
  * 确认修改前校验预报金额:必须为非负数字,且不得大于已核销金额。
349
394
  * 当前未接修改接口,校验通过后仅回写当前表格行;后续可在这里调用 store 的修改 action。
350
395
  */
351
- async function handleModifyConfirm() {
396
+ function handleModifyConfirm() {
352
397
  const predAmtText = toQueryText(modifyForm.predAmt).replace(/,/g, '')
353
398
  const predAmt = Number(predAmtText)
354
399
  const verifyAmt = parseAmount(modifyForm.verifyAmt)
355
400
 
356
401
  if (!predAmtText || !Number.isFinite(predAmt) || predAmt < 0) {
357
- await showModifyWarning('请输入正确的预报金额!')
402
+ showModifyWarning('请输入正确的预报金额!')
358
403
  return
359
404
  }
360
405
 
361
406
  if (verifyAmt < predAmt) {
362
- await showModifyWarning('已核销金额不能小于预报金额!')
407
+ showModifyWarning('已核销金额不能小于预报金额!')
363
408
  return
364
409
  }
365
410
 
@@ -368,7 +413,43 @@ async function handleModifyConfirm() {
368
413
  }
369
414
 
370
415
  modifyDialogVisible.value = false
371
- ElMessage.success('预报信息修改成功')
416
+ pageMessage.success('预报信息修改成功')
417
+ }
418
+
419
+ /** 匡算校验提示由活动面板展示,store 不再直接创建全局消息。 */
420
+ function handleCalculationSummary() {
421
+ const result = forecastInfoStore.handleCalculationSummary()
422
+ if (!result.success) pageMessage.warning(result.message)
423
+ }
424
+
425
+ async function handleForecastVerify() {
426
+ const generation = ++forecastOperationGeneration
427
+
428
+ try {
429
+ const result = await forecastInfoStore.handleForecastVerify()
430
+
431
+ if (!result || !isPanelActive.value || generation !== forecastOperationGeneration) return
432
+ pageMessage[result.success ? 'info' : 'warning'](result.message)
433
+ } catch {
434
+ if (isPanelActive.value && generation === forecastOperationGeneration) {
435
+ pageMessage.error('预报信息核销失败,请稍后重试')
436
+ }
437
+ }
438
+ }
439
+
440
+ async function handleForecastCancelVerify() {
441
+ const generation = ++forecastOperationGeneration
442
+
443
+ try {
444
+ const result = await forecastInfoStore.handleForecastCancelVerify()
445
+
446
+ if (!result || !isPanelActive.value || generation !== forecastOperationGeneration) return
447
+ pageMessage[result.success ? 'info' : 'warning'](result.message)
448
+ } catch {
449
+ if (isPanelActive.value && generation === forecastOperationGeneration) {
450
+ pageMessage.error('撤销核销失败,请稍后重试')
451
+ }
452
+ }
372
453
  }
373
454
 
374
455
  /** 修改弹窗完全关闭后清理临时状态,避免再次打开时展示上次数据。 */
@@ -379,6 +460,11 @@ function handleModifyDialogClosed() {
379
460
  modifyForm.verifyAmt = ''
380
461
  }
381
462
 
463
+ /** v-if 会在关闭动画前销毁弹窗,因此在 model 更新阶段同步清理编辑状态。 */
464
+ function handleModifyDialogVisibilityChange(visible: boolean) {
465
+ if (!visible) handleModifyDialogClosed()
466
+ }
467
+
382
468
  /** 根据 Pinia 中的当前页码和每页条数生成跨页连续序号。 */
383
469
  function getForecastSequence(index: number) {
384
470
  return (forecastPage.value - 1) * forecastPageSize.value + index + 1
@@ -386,8 +472,13 @@ function getForecastSequence(index: number) {
386
472
 
387
473
  /** 翻页前清空两张表的选择状态,再复用 Pinia 保存的最近一次查询参数。 */
388
474
  function handleForecastPaginationChange(_value: { page: number; pageSize: number }) {
475
+ const generation = ++forecastQueryGeneration
389
476
  forecastInfoStore.resetAllTableSelections()
390
- forecastInfoStore.loadForecastInfoList()
477
+ void forecastInfoStore.loadForecastInfoList().catch(() => {
478
+ if (isPanelActive.value && generation === forecastQueryGeneration) {
479
+ pageMessage.error('预报信息加载失败,请稍后重试')
480
+ }
481
+ })
391
482
  }
392
483
  </script>
393
484
 
@@ -448,6 +539,7 @@ function handleForecastPaginationChange(_value: { page: number; pageSize: number
448
539
  <span>交易日期</span>
449
540
  <el-date-picker
450
541
  v-model="forecastForm.tradeDate"
542
+ :append-to="props.overlayContainer || undefined"
451
543
  size="small"
452
544
  type="date"
453
545
  placeholder="请选择日期"
@@ -459,7 +551,14 @@ function handleForecastPaginationChange(_value: { page: number; pageSize: number
459
551
 
460
552
  <label v-if="layout === 'vertical'" class="forecast-info-filter__item">
461
553
  <span>收支方向</span>
462
- <el-select v-model="forecastForm.direction" size="small" placeholder="请选择" clearable>
554
+ <el-select
555
+ v-model="forecastForm.direction"
556
+ :append-to="props.overlayContainer || undefined"
557
+ :persistent="false"
558
+ size="small"
559
+ placeholder="请选择"
560
+ clearable
561
+ >
463
562
  <el-option v-for="option in directionOptions" :key="option.value" v-bind="option" />
464
563
  </el-select>
465
564
  </label>
@@ -501,13 +600,16 @@ function handleForecastPaginationChange(_value: { page: number; pageSize: number
501
600
  </div>
502
601
  </div>
503
602
  <ElTablePro
603
+ ref="forecastTable"
504
604
  v-model:page="forecastPage"
505
605
  v-model:page-size="forecastPageSize"
506
606
  :data="forecastRows"
507
607
  :total="forecastTotal"
508
608
  v-loading="forecastLoading"
509
- table-key="forecast-info"
609
+ table-key="rmb-position-settlement-forecast-info"
510
610
  :selection-reset-key="tableSelectionResetKey"
611
+ :append-to="props.overlayContainer || undefined"
612
+ isolate-overlays
511
613
  row-key="predRefNo"
512
614
  border
513
615
  stripe
@@ -529,7 +631,7 @@ function handleForecastPaginationChange(_value: { page: number; pageSize: number
529
631
  size="small"
530
632
  :icon="DataAnalysis"
531
633
  :disabled="!forecastHasSelectedRows"
532
- @click="forecastInfoStore.handleCalculationSummary"
634
+ @click="handleCalculationSummary"
533
635
  >
534
636
  匡算
535
637
  </el-button>
@@ -539,7 +641,7 @@ function handleForecastPaginationChange(_value: { page: number; pageSize: number
539
641
  size="small"
540
642
  :icon="CircleCheck"
541
643
  :disabled="!forecastHasSelectedRows"
542
- @click="forecastInfoStore.handleForecastVerify"
644
+ @click="handleForecastVerify"
543
645
  >
544
646
  核销
545
647
  </el-button>
@@ -549,7 +651,7 @@ function handleForecastPaginationChange(_value: { page: number; pageSize: number
549
651
  size="small"
550
652
  :icon="RefreshLeft"
551
653
  :disabled="!forecastHasSelectedRows"
552
- @click="forecastInfoStore.handleForecastCancelVerify"
654
+ @click="handleForecastCancelVerify"
553
655
  >
554
656
  撤销核销
555
657
  </el-button>
@@ -623,6 +725,7 @@ function handleForecastPaginationChange(_value: { page: number; pageSize: number
623
725
 
624
726
  <!-- 匡算结果来自 Pinia,包含所选预报与流水数据的共享汇总。 -->
625
727
  <el-dialog
728
+ v-if="calculationDialogVisible"
626
729
  v-model="calculationDialogVisible"
627
730
  width="520px"
628
731
  :append-to="overlayContainer || undefined"
@@ -694,6 +797,7 @@ function handleForecastPaginationChange(_value: { page: number; pageSize: number
694
797
 
695
798
  <!-- 修改弹窗仅编辑预报金额,其他字段作为业务约束的只读依据。 -->
696
799
  <el-dialog
800
+ v-if="modifyDialogVisible"
697
801
  v-model="modifyDialogVisible"
698
802
  title="修改"
699
803
  width="520px"
@@ -702,7 +806,7 @@ function handleForecastPaginationChange(_value: { page: number; pageSize: number
702
806
  :lock-scroll="false"
703
807
  :close-on-click-modal="false"
704
808
  class="forecast-info-modify-dialog"
705
- @closed="handleModifyDialogClosed"
809
+ @update:model-value="handleModifyDialogVisibilityChange"
706
810
  >
707
811
  <div class="forecast-info-modify-dialog__section-title">
708
812
  <el-icon><EditPen /></el-icon>
@@ -729,8 +833,30 @@ function handleForecastPaginationChange(_value: { page: number; pageSize: number
729
833
  </template>
730
834
  </el-dialog>
731
835
 
836
+ <!-- 修改校验提示也挂到本页容器,KeepAlive 停用时可同步销毁。 -->
837
+ <el-dialog
838
+ v-if="modifyWarningVisible"
839
+ v-model="modifyWarningVisible"
840
+ title="提示"
841
+ width="420px"
842
+ :append-to="props.overlayContainer || undefined"
843
+ destroy-on-close
844
+ :lock-scroll="false"
845
+ class="forecast-info-modify-warning-dialog"
846
+ >
847
+ <div class="forecast-info-modify-warning-dialog__content">
848
+ <el-icon><WarningFilled /></el-icon>
849
+ <span>{{ modifyWarningMessage }}</span>
850
+ </div>
851
+
852
+ <template #footer>
853
+ <el-button type="primary" @click="modifyWarningVisible = false">确定</el-button>
854
+ </template>
855
+ </el-dialog>
856
+
732
857
  <!-- 更多筛选抽屉包含完整预报查询条件,提交时仍走同一套参数映射。 -->
733
858
  <el-drawer
859
+ v-if="forecastDrawerVisible"
734
860
  v-model="forecastDrawerVisible"
735
861
  title="预报更多筛选"
736
862
  size="520px"
@@ -744,6 +870,7 @@ function handleForecastPaginationChange(_value: { page: number; pageSize: number
744
870
  <span>交易日期</span>
745
871
  <el-date-picker
746
872
  v-model="forecastForm.tradeDate"
873
+ :append-to="props.overlayContainer || undefined"
747
874
  size="small"
748
875
  type="date"
749
876
  placeholder="请选择日期"
@@ -755,14 +882,28 @@ function handleForecastPaginationChange(_value: { page: number; pageSize: number
755
882
 
756
883
  <label class="forecast-info-filter__item">
757
884
  <span>收支方向</span>
758
- <el-select v-model="forecastForm.direction" size="small" placeholder="请选择" clearable>
885
+ <el-select
886
+ v-model="forecastForm.direction"
887
+ :append-to="props.overlayContainer || undefined"
888
+ :persistent="false"
889
+ size="small"
890
+ placeholder="请选择"
891
+ clearable
892
+ >
759
893
  <el-option v-for="option in directionOptions" :key="option.value" v-bind="option" />
760
894
  </el-select>
761
895
  </label>
762
896
 
763
897
  <label class="forecast-info-filter__item">
764
898
  <span>业务类型</span>
765
- <el-select v-model="forecastForm.businessType" size="small" placeholder="请选择" clearable>
899
+ <el-select
900
+ v-model="forecastForm.businessType"
901
+ :append-to="props.overlayContainer || undefined"
902
+ :persistent="false"
903
+ size="small"
904
+ placeholder="请选择"
905
+ clearable
906
+ >
766
907
  <el-option v-for="option in businessTypeOptions" :key="option.value" v-bind="option" />
767
908
  </el-select>
768
909
  </label>
@@ -783,14 +924,28 @@ function handleForecastPaginationChange(_value: { page: number; pageSize: number
783
924
 
784
925
  <label class="forecast-info-filter__item">
785
926
  <span>支付渠道</span>
786
- <el-select v-model="forecastForm.channel" size="small" placeholder="请选择" clearable>
927
+ <el-select
928
+ v-model="forecastForm.channel"
929
+ :append-to="props.overlayContainer || undefined"
930
+ :persistent="false"
931
+ size="small"
932
+ placeholder="请选择"
933
+ clearable
934
+ >
787
935
  <el-option v-for="option in channelOptions" :key="option.value" v-bind="option" />
788
936
  </el-select>
789
937
  </label>
790
938
 
791
939
  <label class="forecast-info-filter__item">
792
940
  <span>核销状态</span>
793
- <el-select v-model="forecastForm.verification" size="small" placeholder="请选择" clearable>
941
+ <el-select
942
+ v-model="forecastForm.verification"
943
+ :append-to="props.overlayContainer || undefined"
944
+ :persistent="false"
945
+ size="small"
946
+ placeholder="请选择"
947
+ clearable
948
+ >
794
949
  <el-option v-for="option in statusOptions" :key="option.value" v-bind="option" />
795
950
  </el-select>
796
951
  </label>
@@ -817,7 +972,14 @@ function handleForecastPaginationChange(_value: { page: number; pageSize: number
817
972
 
818
973
  <label class="forecast-info-filter__item">
819
974
  <span>机构</span>
820
- <el-select v-model="forecastForm.organization" size="small" placeholder="请选择" clearable>
975
+ <el-select
976
+ v-model="forecastForm.organization"
977
+ :append-to="props.overlayContainer || undefined"
978
+ :persistent="false"
979
+ size="small"
980
+ placeholder="请选择"
981
+ clearable
982
+ >
821
983
  <el-option v-for="option in organizationOptions" :key="option.value" v-bind="option" />
822
984
  </el-select>
823
985
  </label>