verce-vue-test 0.0.74 → 0.0.76

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.
@@ -0,0 +1,1147 @@
1
+ <script setup lang="ts">
2
+ import { computed, onBeforeUnmount, onMounted, ref } from 'vue'
3
+ import { storeToRefs } from 'pinia'
4
+ import { ElMessage, ElMessageBox } from 'element-plus'
5
+ import {
6
+ ArrowDown,
7
+ ArrowUp,
8
+ CircleCheck,
9
+ CircleClose,
10
+ Delete,
11
+ Download,
12
+ EditPen,
13
+ Plus,
14
+ RefreshLeft,
15
+ Search,
16
+ UploadFilled,
17
+ } from '@element-plus/icons-vue'
18
+ import {
19
+ formatDate,
20
+ mockCurrentUser,
21
+ type ForecastStatus,
22
+ type ForeignPositionForecast,
23
+ type VerifyStatus,
24
+ } from './mock'
25
+ import {
26
+ approveForeignPositionForecasts,
27
+ createForeignPositionForecast,
28
+ deleteForeignPositionForecast,
29
+ getForeignPositionForecast,
30
+ queryForeignPositionForecasts,
31
+ type ForeignPositionForecastSort,
32
+ updateForeignPositionForecast,
33
+ updateForeignPositionForecastAuthorization,
34
+ } from './api'
35
+ import ForeignPositionForecastEditor from './components/ForeignPositionForecastEditor.vue'
36
+ import type { ForecastEditorValue } from './editor'
37
+ import {
38
+ authirizationOptions,
39
+ businessTypeOptions,
40
+ currencyOptions,
41
+ forecastStatusOptions,
42
+ forecastTypeOptions,
43
+ forecastWayOptions,
44
+ foreignExchangeTypeOptions,
45
+ ftuFilterOptions,
46
+ payDirectionOptions,
47
+ type SelectOption,
48
+ verifyStatusOptions,
49
+ } from './options'
50
+ import {
51
+ cloneFilters,
52
+ useForeignPositionForecastStore,
53
+ } from './store'
54
+
55
+ const forecastStore = useForeignPositionForecastStore()
56
+ const {
57
+ filterForm,
58
+ appliedFilters,
59
+ successfulFilters,
60
+ allRows,
61
+ totalCount,
62
+ selectedRows,
63
+ selectionResetKey,
64
+ isLoading,
65
+ isQuerying,
66
+ filterCollapsed,
67
+ currentPage,
68
+ pageSize,
69
+ successfulPage,
70
+ successfulPageSize,
71
+ pageMode,
72
+ editorMode,
73
+ editorRecord,
74
+ isSaving,
75
+ approvalAction,
76
+ hasMixedCurrencySelection,
77
+ amountSummary,
78
+ tableHeight,
79
+ } = storeToRefs(forecastStore)
80
+ const { clearTableSelection, resetFilterForm } = forecastStore
81
+
82
+ const amountRangeValid = ref(true)
83
+ const amountRangeRef = ref<{ validate: () => boolean } | null>(null)
84
+ const authorizationActionPredRefNo = ref('')
85
+ const forecastSort = ref<ForeignPositionForecastSort>({
86
+ amtOrder: '1',
87
+ predOrder: '',
88
+ timeOrder: '',
89
+ })
90
+ const tableDefaultSort = computed<{
91
+ prop: 'predAmount' | 'forecastTime' | 'approvalTime'
92
+ order: 'ascending' | 'descending'
93
+ }>(() => {
94
+ if (forecastSort.value.predOrder) {
95
+ return {
96
+ prop: 'forecastTime',
97
+ order: forecastSort.value.predOrder === '1' ? 'descending' : 'ascending',
98
+ }
99
+ }
100
+ if (forecastSort.value.timeOrder) {
101
+ return {
102
+ prop: 'approvalTime',
103
+ order: forecastSort.value.timeOrder === '1' ? 'descending' : 'ascending',
104
+ }
105
+ }
106
+ return {
107
+ prop: 'predAmount',
108
+ order: forecastSort.value.amtOrder === '2' ? 'ascending' : 'descending',
109
+ }
110
+ })
111
+
112
+ let listRequestController: AbortController | null = null
113
+
114
+ function getOptionLabel(options: SelectOption[], value: string) {
115
+ return options.find((option) => option.value === value)?.label ?? value
116
+ }
117
+
118
+ function formatMoney(value: number) {
119
+ return Number(value || 0).toLocaleString('zh-CN', {
120
+ minimumFractionDigits: 2,
121
+ maximumFractionDigits: 2,
122
+ })
123
+ }
124
+
125
+ function statusTagType(status: ForecastStatus) {
126
+ if (status === 'PS03') return 'success'
127
+ if (status === 'PS01' || status === 'PS02') return 'primary'
128
+ if (status === 'PS06' || status === 'PS07') return 'warning'
129
+ if (status === 'PS04' || status === 'PS08') return 'danger'
130
+ return 'info'
131
+ }
132
+
133
+ function verifyTagType(status: VerifyStatus) {
134
+ if (status === 'VS03') return 'success'
135
+ if (status === 'VS02') return 'warning'
136
+ return 'info'
137
+ }
138
+
139
+ function validateAmountRange() {
140
+ const { minAmount, maxAmount } = filterForm.value
141
+ const componentValid = amountRangeRef.value?.validate() ?? amountRangeValid.value
142
+
143
+ if ((minAmount !== null && minAmount < 0) || (maxAmount !== null && maxAmount < 0)) {
144
+ ElMessage.warning('起止金额不能小于 0')
145
+ return false
146
+ }
147
+ if (!componentValid || (minAmount !== null && maxAmount !== null && minAmount > maxAmount)) {
148
+ ElMessage.warning('输入的金额范围开始值不能大于结束值')
149
+ return false
150
+ }
151
+ return true
152
+ }
153
+
154
+ function isAbortError(error: unknown) {
155
+ return error instanceof Error && error.name === 'AbortError'
156
+ }
157
+
158
+ async function loadForecastRows() {
159
+ listRequestController?.abort()
160
+ const controller = new AbortController()
161
+ listRequestController = controller
162
+ isLoading.value = true
163
+
164
+ try {
165
+ const response = await queryForeignPositionForecasts(
166
+ appliedFilters.value,
167
+ currentPage.value,
168
+ pageSize.value,
169
+ forecastSort.value,
170
+ controller.signal,
171
+ )
172
+
173
+ if (controller.signal.aborted || listRequestController !== controller) return false
174
+
175
+ allRows.value = response.resultList
176
+ totalCount.value = response.totalCount
177
+ successfulFilters.value = cloneFilters(appliedFilters.value)
178
+ successfulPage.value = currentPage.value
179
+ successfulPageSize.value = pageSize.value
180
+ clearTableSelection()
181
+ return true
182
+ } catch (error) {
183
+ if (controller.signal.aborted || isAbortError(error)) return false
184
+ appliedFilters.value = cloneFilters(successfulFilters.value)
185
+ currentPage.value = successfulPage.value
186
+ pageSize.value = successfulPageSize.value
187
+ ElMessage.error(error instanceof Error ? error.message : '外币头寸预报查询失败')
188
+ return false
189
+ } finally {
190
+ if (listRequestController === controller) {
191
+ listRequestController = null
192
+ isLoading.value = false
193
+ }
194
+ }
195
+ }
196
+
197
+ async function handleQuery() {
198
+ if (!validateAmountRange() || isQuerying.value) return
199
+
200
+ clearTableSelection()
201
+ isQuerying.value = true
202
+
203
+ try {
204
+ appliedFilters.value = cloneFilters(filterForm.value)
205
+ currentPage.value = 1
206
+ await loadForecastRows()
207
+ } finally {
208
+ isQuerying.value = false
209
+ }
210
+ }
211
+
212
+ function handleReset() {
213
+ resetFilterForm()
214
+ amountRangeValid.value = true
215
+ clearTableSelection()
216
+ }
217
+
218
+ function handleSelectionChange(rows: ForeignPositionForecast[]) {
219
+ selectedRows.value = rows
220
+ }
221
+
222
+ async function handleSortChange({
223
+ prop,
224
+ order,
225
+ }: {
226
+ prop: string
227
+ order: 'ascending' | 'descending' | null
228
+ }) {
229
+ if (
230
+ prop !== 'predAmount'
231
+ && prop !== 'forecastTime'
232
+ && prop !== 'approvalTime'
233
+ ) return
234
+ if (order !== 'ascending' && order !== 'descending') return
235
+
236
+ const direction = order === 'descending' ? '1' : '2'
237
+ const nextSort: ForeignPositionForecastSort = {
238
+ amtOrder: prop === 'predAmount' ? direction : '',
239
+ predOrder: prop === 'forecastTime' ? direction : '',
240
+ timeOrder: prop === 'approvalTime' ? direction : '',
241
+ }
242
+
243
+ if (
244
+ forecastSort.value.amtOrder === nextSort.amtOrder
245
+ && forecastSort.value.predOrder === nextSort.predOrder
246
+ && forecastSort.value.timeOrder === nextSort.timeOrder
247
+ ) return
248
+
249
+ forecastSort.value = nextSort
250
+ currentPage.value = 1
251
+ clearTableSelection()
252
+ await loadForecastRows()
253
+ }
254
+
255
+ async function handlePaginationChange(pagination: { page: number; pageSize: number }) {
256
+ currentPage.value = pagination.page
257
+ pageSize.value = pagination.pageSize
258
+ clearTableSelection()
259
+ await loadForecastRows()
260
+ }
261
+
262
+ async function refreshAfterMutation(resetToFirstPage = false) {
263
+ if (resetToFirstPage) currentPage.value = 1
264
+ const loaded = await loadForecastRows()
265
+ if (!loaded || allRows.value.length > 0 || currentPage.value <= 1) return
266
+
267
+ currentPage.value = Math.max(1, Math.ceil(totalCount.value / pageSize.value))
268
+ await loadForecastRows()
269
+ }
270
+
271
+ function getEditRestriction(row: ForeignPositionForecast) {
272
+ const today = formatDate(new Date())
273
+ if (row.valueDate < today) return '不能对之前的数据进行修改'
274
+ if (row.predStatus === 'PS05') return '该预报为已删除状态,无法修改'
275
+ if (row.predWay === 'PW02') return '该预报为已到期状态,无法修改'
276
+ if (row.verifyStatus !== 'VS01') return '已核销状态或部分核销状态无法修改'
277
+
278
+ if (mockCurrentUser.role === '007' && row.valueDate <= today) {
279
+ return '分行管理员只能修改起息日为非当日的预报'
280
+ }
281
+ if (mockCurrentUser.role === '008') {
282
+ if (row.forecasterCode !== mockCurrentUser.userCode) return '修改操作只能由预报本人操作'
283
+ if (row.valueDate <= today) return '只能修改起息日为非当日的预报'
284
+ }
285
+ return ''
286
+ }
287
+
288
+ function getDeleteRestriction(row: ForeignPositionForecast) {
289
+ const today = formatDate(new Date())
290
+ if (row.verifyStatus !== 'VS01') return '已核销或部分核销,无法删除'
291
+ if (row.valueDate < today) return '不能删除之前的预报'
292
+ if (row.valueDate === today && mockCurrentUser.role !== '006') return '仅总行管理员允许删除当日起息预报'
293
+ if (mockCurrentUser.role === '008' && row.forecasterCode !== mockCurrentUser.userCode) {
294
+ return '不允许删除非本人报送预报'
295
+ }
296
+ if (['PS04', 'PS05', 'PS06', 'PS07', 'PS08'].includes(row.predStatus)) {
297
+ return '该预报当前状态无法删除'
298
+ }
299
+ return ''
300
+ }
301
+
302
+ function openAddEditor() {
303
+ clearTableSelection()
304
+ editorMode.value = 'add'
305
+ editorRecord.value = null
306
+ pageMode.value = 'editor'
307
+ }
308
+
309
+ async function openEditEditor(row: ForeignPositionForecast) {
310
+ const restriction = getEditRestriction(row)
311
+ if (restriction) {
312
+ ElMessage.warning(restriction)
313
+ return
314
+ }
315
+
316
+ isLoading.value = true
317
+ try {
318
+ const detail = await getForeignPositionForecast(row.predRefNo)
319
+ clearTableSelection()
320
+ editorMode.value = 'edit'
321
+ editorRecord.value = detail
322
+ pageMode.value = 'editor'
323
+ } catch (error) {
324
+ ElMessage.error(error instanceof Error ? error.message : '预报详情查询失败')
325
+ } finally {
326
+ isLoading.value = false
327
+ }
328
+ }
329
+
330
+ function returnToList() {
331
+ pageMode.value = 'list'
332
+ editorRecord.value = null
333
+ }
334
+
335
+ async function submitEditor(value: ForecastEditorValue) {
336
+ isSaving.value = true
337
+
338
+ try {
339
+ if (editorMode.value === 'add') {
340
+ await createForeignPositionForecast(value)
341
+ ElMessage.success('新增预报成功,已进入待分行确认状态')
342
+ await refreshAfterMutation(true)
343
+ } else {
344
+ const predRefNo = editorRecord.value?.predRefNo
345
+ if (!predRefNo) {
346
+ ElMessage.error('原预报记录不存在,请返回列表后重试')
347
+ return
348
+ }
349
+
350
+ await updateForeignPositionForecast(predRefNo, value)
351
+ ElMessage.success('预报修改成功')
352
+ await refreshAfterMutation()
353
+ }
354
+
355
+ clearTableSelection()
356
+ returnToList()
357
+ } catch (error) {
358
+ ElMessage.error(error instanceof Error ? error.message : '预报保存失败')
359
+ } finally {
360
+ isSaving.value = false
361
+ }
362
+ }
363
+
364
+ async function handleDelete(row: ForeignPositionForecast) {
365
+ const restriction = getDeleteRestriction(row)
366
+ if (restriction) {
367
+ ElMessage.warning(restriction)
368
+ return
369
+ }
370
+
371
+ try {
372
+ await ElMessageBox.confirm('是否确定对指定的记录进行删除操作?', '提示', {
373
+ confirmButtonText: '确定',
374
+ cancelButtonText: '取消',
375
+ type: 'warning',
376
+ })
377
+ } catch {
378
+ return
379
+ }
380
+
381
+ try {
382
+ const updatedRow = await deleteForeignPositionForecast(row.predRefNo)
383
+ clearTableSelection()
384
+ ElMessage.success(updatedRow.predStatus === 'PS05' ? '删除成功' : '删除申请已提交,等待分行确认')
385
+ await refreshAfterMutation()
386
+ } catch (error) {
387
+ ElMessage.error(error instanceof Error ? error.message : '预报删除失败')
388
+ }
389
+ }
390
+
391
+ async function handleAuthorization(row: ForeignPositionForecast) {
392
+ if (authorizationActionPredRefNo.value) return
393
+
394
+ const authorization = row.authirization === '1' ? '0' : '1'
395
+ const actionText = authorization === '1' ? '授权' : '取消授权'
396
+ authorizationActionPredRefNo.value = row.predRefNo
397
+
398
+ try {
399
+ try {
400
+ await ElMessageBox.confirm(
401
+ `确认对预报 ${row.predRefNo} 执行${actionText}操作吗?`,
402
+ `${actionText}确认`,
403
+ {
404
+ confirmButtonText: `确认${actionText}`,
405
+ cancelButtonText: '取消',
406
+ type: authorization === '1' ? 'success' : 'warning',
407
+ },
408
+ )
409
+ } catch {
410
+ return
411
+ }
412
+
413
+ const message = await updateForeignPositionForecastAuthorization(
414
+ row.predRefNo,
415
+ authorization,
416
+ currentPage.value,
417
+ pageSize.value,
418
+ )
419
+ ElMessage.success(message)
420
+ await refreshAfterMutation()
421
+ } catch (error) {
422
+ ElMessage.error(error instanceof Error ? error.message : `${actionText}失败`)
423
+ } finally {
424
+ authorizationActionPredRefNo.value = ''
425
+ }
426
+ }
427
+
428
+ async function handleApproval(approved: boolean) {
429
+ if (approvalAction.value) return
430
+
431
+ if (selectedRows.value.length === 0) {
432
+ ElMessage.warning('请至少选择一条记录')
433
+ return
434
+ }
435
+
436
+ const unavailable = selectedRows.value.find(
437
+ (row) => row.verifyStatus !== 'VS01' || ['PS03', 'PS04', 'PS05', 'PS08'].includes(row.predStatus),
438
+ )
439
+ if (unavailable) {
440
+ ElMessage.warning(
441
+ unavailable.verifyStatus !== 'VS01'
442
+ ? `预报 ${unavailable.predRefNo} 已核销或部分核销,无法审批`
443
+ : '批量操作中包含终态审批记录',
444
+ )
445
+ return
446
+ }
447
+
448
+ const actionText = approved ? '通过' : '拒绝'
449
+ try {
450
+ await ElMessageBox.confirm(`确认${actionText}已选的 ${selectedRows.value.length} 笔预报申请吗?`, '审批确认', {
451
+ confirmButtonText: `确认${actionText}`,
452
+ cancelButtonText: '取消',
453
+ type: approved ? 'success' : 'warning',
454
+ })
455
+ } catch {
456
+ return
457
+ }
458
+
459
+ if (approvalAction.value) return
460
+ approvalAction.value = approved ? 'approve' : 'reject'
461
+
462
+ try {
463
+ const response = await approveForeignPositionForecasts(
464
+ selectedRows.value.map((row) => row.predRefNo),
465
+ approved,
466
+ )
467
+ clearTableSelection()
468
+ ElMessage.success(response.message || `审批${actionText}操作成功`)
469
+ await refreshAfterMutation()
470
+ } catch (error) {
471
+ ElMessage.error(error instanceof Error ? error.message : `审批${actionText}操作失败`)
472
+ } finally {
473
+ approvalAction.value = null
474
+ }
475
+ }
476
+
477
+ onMounted(() => {
478
+ void loadForecastRows()
479
+ })
480
+
481
+ onBeforeUnmount(() => {
482
+ listRequestController?.abort()
483
+ })
484
+ </script>
485
+
486
+ <template>
487
+ <main class="foreign-position-page">
488
+ <ForeignPositionForecastEditor
489
+ v-if="pageMode === 'editor'"
490
+ :key="`${editorMode}-${editorRecord?.predRefNo ?? 'new'}`"
491
+ :mode="editorMode"
492
+ :initial-row="editorRecord"
493
+ :saving="isSaving"
494
+ @back="returnToList"
495
+ @submit="submitEditor"
496
+ />
497
+
498
+ <template v-else>
499
+ <section class="query-panel" aria-label="外币头寸预报查询条件">
500
+ <el-form :model="filterForm" label-position="top" size="small" class="query-form">
501
+ <div class="query-grid" :class="{ 'is-collapsed': filterCollapsed }">
502
+ <el-form-item label="起息日">
503
+ <el-date-picker
504
+ v-model="filterForm.valueDate"
505
+ type="date"
506
+ value-format="YYYY-MM-DD"
507
+ format="YYYY-MM-DD"
508
+ placeholder="请选择"
509
+ clearable
510
+ />
511
+ </el-form-item>
512
+
513
+ <el-form-item label="收支方向">
514
+ <el-select v-model="filterForm.payDirection" placeholder="请选择" clearable>
515
+ <el-option v-for="option in payDirectionOptions" :key="option.value" v-bind="option" />
516
+ </el-select>
517
+ </el-form-item>
518
+
519
+ <el-form-item label="预报状态">
520
+ <el-select
521
+ v-model="filterForm.forecastStatuses"
522
+ multiple
523
+ collapse-tags
524
+ collapse-tags-tooltip
525
+ placeholder="请选择"
526
+ clearable
527
+ >
528
+ <el-option v-for="option in forecastStatusOptions" :key="option.value" v-bind="option" />
529
+ </el-select>
530
+ </el-form-item>
531
+
532
+ <el-form-item label="结汇/购汇/现汇">
533
+ <el-select v-model="filterForm.foreignExchangeType" placeholder="请选择" clearable>
534
+ <el-option v-for="option in foreignExchangeTypeOptions" :key="option.value" v-bind="option" />
535
+ </el-select>
536
+ </el-form-item>
537
+
538
+ <el-form-item label="预报方式">
539
+ <el-select v-model="filterForm.forecastWay" placeholder="请选择" clearable>
540
+ <el-option v-for="option in forecastWayOptions" :key="option.value" v-bind="option" />
541
+ </el-select>
542
+ </el-form-item>
543
+
544
+ <el-form-item label="核销状态">
545
+ <el-select
546
+ v-model="filterForm.verifyStatuses"
547
+ multiple
548
+ collapse-tags
549
+ collapse-tags-tooltip
550
+ placeholder="请选择"
551
+ clearable
552
+ >
553
+ <el-option v-for="option in verifyStatusOptions" :key="option.value" v-bind="option" />
554
+ </el-select>
555
+ </el-form-item>
556
+
557
+ <el-form-item label="是否授权" class="filter-secondary">
558
+ <el-select v-model="filterForm.authirization" placeholder="请选择" clearable>
559
+ <el-option v-for="option in authirizationOptions" :key="option.value" v-bind="option" />
560
+ </el-select>
561
+ </el-form-item>
562
+
563
+ <el-form-item label="筛选FTU" class="filter-secondary">
564
+ <el-select v-model="filterForm.ftuFilter" placeholder="请选择" clearable>
565
+ <el-option v-for="option in ftuFilterOptions" :key="option.value" v-bind="option" />
566
+ </el-select>
567
+ </el-form-item>
568
+
569
+ <el-form-item label="机构名称" class="filter-secondary">
570
+ <el-input v-model="filterForm.organizationName" placeholder="请输入机构名称" clearable />
571
+ </el-form-item>
572
+
573
+ <el-form-item label="客户名称" class="filter-secondary">
574
+ <el-input v-model="filterForm.clientName" placeholder="请输入客户名称" clearable />
575
+ </el-form-item>
576
+
577
+ <el-form-item label="业务类型" class="filter-secondary">
578
+ <el-select v-model="filterForm.businessType" placeholder="请选择" clearable>
579
+ <el-option v-for="option in businessTypeOptions" :key="option.value" v-bind="option" />
580
+ </el-select>
581
+ </el-form-item>
582
+
583
+ <el-form-item label="币种" class="filter-secondary">
584
+ <el-select
585
+ v-model="filterForm.currencies"
586
+ multiple
587
+ collapse-tags
588
+ collapse-tags-tooltip
589
+ placeholder="请选择"
590
+ clearable
591
+ >
592
+ <el-option v-for="option in currencyOptions" :key="option.value" v-bind="option" />
593
+ </el-select>
594
+ </el-form-item>
595
+
596
+ <el-form-item label="起止金额(元)" class="amount-range-item filter-secondary">
597
+ <NumberRange
598
+ ref="amountRangeRef"
599
+ v-model:start="filterForm.minAmount"
600
+ v-model:end="filterForm.maxAmount"
601
+ class="amount-range-control"
602
+ separator="—"
603
+ min-placeholder="起始金额"
604
+ max-placeholder="结束金额"
605
+ error-message="开始金额不能大于结束金额"
606
+ :precision="2"
607
+ unit="元"
608
+ size="small"
609
+ @validate="amountRangeValid = $event"
610
+ />
611
+ </el-form-item>
612
+ </div>
613
+
614
+ <div class="query-actions">
615
+ <el-button
616
+ text
617
+ type="primary"
618
+ :icon="filterCollapsed ? ArrowDown : ArrowUp"
619
+ :aria-expanded="!filterCollapsed"
620
+ @click="filterCollapsed = !filterCollapsed"
621
+ >
622
+ {{ filterCollapsed ? '展开筛选' : '收起筛选' }}
623
+ </el-button>
624
+ <el-button :icon="RefreshLeft" @click="handleReset">重置</el-button>
625
+ <el-button type="primary" :icon="Search" :loading="isQuerying" @click="handleQuery">查询</el-button>
626
+ </div>
627
+ </el-form>
628
+ </section>
629
+
630
+ <section v-if="amountSummary" class="amount-summary" aria-label="单币种金额汇总">
631
+ <div class="summary-caption">
632
+ <strong>{{ amountSummary.currency }}</strong>
633
+ <span>{{ amountSummary.source }}汇总 · 单位:万</span>
634
+ </div>
635
+ <div class="summary-item is-income">
636
+ <span>收入总金额</span>
637
+ <strong>{{ formatMoney(amountSummary.income) }}</strong>
638
+ </div>
639
+ <div class="summary-item is-expense">
640
+ <span>支出总金额</span>
641
+ <strong>{{ formatMoney(amountSummary.expense) }}</strong>
642
+ </div>
643
+ <div class="summary-item" :class="amountSummary.net >= 0 ? 'is-net-positive' : 'is-net-negative'">
644
+ <span>轧差金额</span>
645
+ <strong>{{ formatMoney(amountSummary.net) }}</strong>
646
+ </div>
647
+ </section>
648
+
649
+ <div v-else-if="hasMixedCurrencySelection" class="currency-warning" role="status">
650
+ 已选记录包含多个币种,暂不进行金额汇总
651
+ </div>
652
+
653
+ <section class="table-panel" aria-label="外币头寸预报列表">
654
+ <ElTablePro
655
+ v-model:page="currentPage"
656
+ v-model:page-size="pageSize"
657
+ v-loading="isLoading"
658
+ :data="allRows"
659
+ :total="totalCount"
660
+ :page-sizes="[10, 25, 50, 100]"
661
+ :selection-reset-key="selectionResetKey"
662
+ :default-sort="tableDefaultSort"
663
+ table-key="foreign-currency-position-forecast"
664
+ row-key="predRefNo"
665
+ border
666
+ stripe
667
+ :height="tableHeight"
668
+ empty-text="无记录"
669
+ class="forecast-table"
670
+ layout="total, sizes, prev, pager, next, jumper"
671
+ pagination-size="small"
672
+ @selection-change="handleSelectionChange"
673
+ @sort-change="handleSortChange"
674
+ @pagination-change="handlePaginationChange"
675
+ >
676
+ <template #toolbar>
677
+ <div class="table-toolbar-actions">
678
+ <el-button size="small" type="primary" :icon="Plus" @click="openAddEditor">新增</el-button>
679
+ <span class="operation-divider" aria-hidden="true"></span>
680
+ <el-button size="small" :icon="UploadFilled">导入</el-button>
681
+ </div>
682
+ </template>
683
+
684
+ <template #toolbar-right>
685
+ <div class="table-toolbar-actions">
686
+ <span class="selection-count">已选 {{ selectedRows.length }} 笔</span>
687
+ <el-button
688
+ size="small"
689
+ type="success"
690
+ plain
691
+ :icon="CircleCheck"
692
+ :loading="approvalAction === 'approve'"
693
+ :disabled="approvalAction !== null"
694
+ @click="handleApproval(true)"
695
+ >
696
+ 审批确认
697
+ </el-button>
698
+ <el-button
699
+ size="small"
700
+ type="danger"
701
+ plain
702
+ :icon="CircleClose"
703
+ :loading="approvalAction === 'reject'"
704
+ :disabled="approvalAction !== null"
705
+ @click="handleApproval(false)"
706
+ >
707
+ 审批拒绝
708
+ </el-button>
709
+ <el-button size="small" :icon="Download">导出</el-button>
710
+ </div>
711
+ </template>
712
+
713
+ <el-table-column type="selection" column-key="selection" width="48" fixed="left" reserve-selection disabled />
714
+ <el-table-column type="index" column-key="sequence" label="序号" width="62" fixed="left" :index="(index: number) => (currentPage - 1) * pageSize + index + 1" disabled />
715
+ <el-table-column prop="predRefNo" label="预报流水号" width="168" fixed="left" show-overflow-tooltip />
716
+ <el-table-column label="预报方式" width="108">
717
+ <template #default="{ row }">{{ getOptionLabel(forecastWayOptions, row.predWay) }}</template>
718
+ </el-table-column>
719
+ <el-table-column label="预报状态" width="136">
720
+ <template #default="{ row }">
721
+ <el-tag :type="statusTagType(row.predStatus)" size="small" effect="light">
722
+ {{ getOptionLabel(forecastStatusOptions, row.predStatus) }}
723
+ </el-tag>
724
+ </template>
725
+ </el-table-column>
726
+ <el-table-column label="预报类型" width="102">
727
+ <template #default="{ row }">{{ getOptionLabel(forecastTypeOptions, row.predType) }}</template>
728
+ </el-table-column>
729
+ <el-table-column prop="groundBranch" label="落地机构" width="160" show-overflow-tooltip />
730
+ <el-table-column label="收支方向" width="88">
731
+ <template #default="{ row }">
732
+ <span class="direction-text" :class="row.payDirection === 'I' ? 'is-income' : 'is-expense'">
733
+ {{ getOptionLabel(payDirectionOptions, row.payDirection) }}
734
+ </span>
735
+ </template>
736
+ </el-table-column>
737
+ <el-table-column prop="bankAccount" label="账户行" width="188" show-overflow-tooltip />
738
+ <el-table-column prop="currency" label="币种" width="82">
739
+ <template #default="{ row }"><strong class="currency-code">{{ row.currency }}</strong></template>
740
+ </el-table-column>
741
+ <el-table-column
742
+ prop="predAmount"
743
+ label="预报金额(元)"
744
+ width="152"
745
+ align="right"
746
+ sortable="custom"
747
+ :sort-orders="['descending', 'ascending']"
748
+ >
749
+ <template #default="{ row }"><span class="money-cell">{{ formatMoney(row.predAmount) }}</span></template>
750
+ </el-table-column>
751
+ <el-table-column prop="valueDate" label="起息日" width="116" />
752
+ <el-table-column label="核销状态" width="108">
753
+ <template #default="{ row }">
754
+ <el-tag :type="verifyTagType(row.verifyStatus)" size="small" effect="plain">
755
+ {{ getOptionLabel(verifyStatusOptions, row.verifyStatus) }}
756
+ </el-tag>
757
+ </template>
758
+ </el-table-column>
759
+ <el-table-column prop="verifyAmount" label="核销金额(元)" width="148" align="right">
760
+ <template #default="{ row }"><span class="money-cell">{{ formatMoney(row.verifyAmount) }}</span></template>
761
+ </el-table-column>
762
+ <el-table-column label="业务类型" width="120">
763
+ <template #default="{ row }">{{ getOptionLabel(businessTypeOptions, row.businessType) }}</template>
764
+ </el-table-column>
765
+ <el-table-column prop="clientName" label="客户名称" width="218" show-overflow-tooltip />
766
+ <el-table-column prop="clientAccount" label="客户账号" width="198" show-overflow-tooltip />
767
+ <el-table-column prop="counterpartyName" label="交易对手名称" width="220" show-overflow-tooltip />
768
+ <el-table-column prop="counterpartyAccount" label="交易对手账号" width="190" show-overflow-tooltip />
769
+ <el-table-column prop="receivingBank" label="交易对手行名称" width="210" show-overflow-tooltip />
770
+ <el-table-column prop="receivingBankSwiftCode" label="交易对手行 SWIFTCODE" width="205" show-overflow-tooltip />
771
+ <el-table-column label="结汇/购汇/现汇" width="136">
772
+ <template #default="{ row }">{{ getOptionLabel(foreignExchangeTypeOptions, row.foreignExchangeType) }}</template>
773
+ </el-table-column>
774
+ <el-table-column
775
+ prop="forecastTime"
776
+ label="预报时间"
777
+ width="170"
778
+ sortable="custom"
779
+ :sort-orders="['descending', 'ascending']"
780
+ show-overflow-tooltip
781
+ />
782
+ <el-table-column
783
+ prop="approvalTime"
784
+ label="审批时间"
785
+ width="170"
786
+ sortable="custom"
787
+ :sort-orders="['descending', 'ascending']"
788
+ show-overflow-tooltip
789
+ >
790
+ <template #default="{ row }">{{ row.approvalTime || '—' }}</template>
791
+ </el-table-column>
792
+ <el-table-column
793
+ column-key="operation"
794
+ label="操作"
795
+ width="248"
796
+ fixed="right"
797
+ align="center"
798
+ disabled
799
+ >
800
+ <template #default="{ row }">
801
+ <div class="row-actions">
802
+ <el-button link type="primary" :icon="EditPen" @click.stop="openEditEditor(row)">
803
+ 修改
804
+ </el-button>
805
+ <el-button link type="danger" :icon="Delete" @click.stop="handleDelete(row)">
806
+ 删除
807
+ </el-button>
808
+ <el-button
809
+ link
810
+ :type="row.authirization === '1' ? 'warning' : 'success'"
811
+ :icon="row.authirization === '1' ? CircleClose : CircleCheck"
812
+ :loading="authorizationActionPredRefNo === row.predRefNo"
813
+ :disabled="Boolean(authorizationActionPredRefNo) && authorizationActionPredRefNo !== row.predRefNo"
814
+ @click.stop="handleAuthorization(row)"
815
+ >
816
+ {{ row.authirization === '1' ? '取消授权' : '授权' }}
817
+ </el-button>
818
+ </div>
819
+ </template>
820
+ </el-table-column>
821
+ </ElTablePro>
822
+ </section>
823
+
824
+ </template>
825
+ </main>
826
+ </template>
827
+
828
+ <style scoped>
829
+ .foreign-position-page {
830
+ --page-blue: #1f62d6;
831
+ --page-blue-dark: #174ea6;
832
+ --page-ink: #172033;
833
+ --page-muted: #667085;
834
+ --page-line: #dce3ec;
835
+ min-width: 0;
836
+ min-height: 100%;
837
+ color: var(--page-ink);
838
+ font-family: "PingFang SC", "Microsoft YaHei", sans-serif;
839
+ }
840
+
841
+ .query-panel,
842
+ .table-panel,
843
+ .amount-summary,
844
+ .currency-warning {
845
+ border: 1px solid var(--page-line);
846
+ background: #fff;
847
+ box-shadow: 0 3px 12px rgba(30, 55, 90, .045);
848
+ }
849
+
850
+ .query-panel {
851
+ margin-bottom: 10px;
852
+ padding: 12px 16px 10px;
853
+ border-radius: 7px;
854
+ }
855
+
856
+ .query-grid {
857
+ display: grid;
858
+ grid-template-columns: repeat(6, minmax(0, 1fr));
859
+ gap: 8px 12px;
860
+ }
861
+
862
+ .query-grid.is-collapsed .filter-secondary {
863
+ display: none;
864
+ }
865
+
866
+ .query-form :deep(.el-form-item) {
867
+ min-width: 0;
868
+ margin-bottom: 0;
869
+ }
870
+
871
+ .query-form :deep(.el-form-item__label) {
872
+ height: 24px;
873
+ padding: 0;
874
+ color: #475467;
875
+ font-size: 12px;
876
+ font-weight: 600;
877
+ line-height: 24px;
878
+ }
879
+
880
+ .query-form :deep(.el-input),
881
+ .query-form :deep(.el-select),
882
+ .query-form :deep(.el-date-editor) {
883
+ width: 100%;
884
+ }
885
+
886
+ .query-form :deep(.el-input__wrapper),
887
+ .query-form :deep(.el-select__wrapper) {
888
+ min-height: var(--el-component-size-small, 24px);
889
+ border-radius: 5px;
890
+ box-shadow: 0 0 0 1px #d6dee9 inset;
891
+ }
892
+
893
+ .amount-range-item {
894
+ grid-column: span 2;
895
+ }
896
+
897
+ .amount-range-control {
898
+ width: 100%;
899
+ }
900
+
901
+ .amount-range-item :deep(.number-range__separator) {
902
+ color: #98a2b3;
903
+ font-size: 12px;
904
+ }
905
+
906
+ .query-actions {
907
+ display: flex;
908
+ justify-content: flex-end;
909
+ gap: 8px;
910
+ margin-top: 10px;
911
+ padding-top: 10px;
912
+ border-top: 1px dashed #e2e8f0;
913
+ }
914
+
915
+ .query-actions .el-button {
916
+ min-width: 86px;
917
+ }
918
+
919
+ .table-toolbar-actions {
920
+ display: flex;
921
+ align-items: center;
922
+ gap: 8px;
923
+ flex-wrap: wrap;
924
+ }
925
+
926
+ .table-toolbar-actions .el-button + .el-button {
927
+ margin-left: 0;
928
+ }
929
+
930
+ .operation-divider {
931
+ width: 1px;
932
+ height: 22px;
933
+ margin-inline: 2px;
934
+ background: #d9e1eb;
935
+ }
936
+
937
+ .selection-count {
938
+ margin-right: 3px;
939
+ color: #667085;
940
+ font-size: 12px;
941
+ white-space: nowrap;
942
+ }
943
+
944
+ .amount-summary {
945
+ display: grid;
946
+ grid-template-columns: minmax(160px, .8fr) repeat(3, minmax(170px, 1fr));
947
+ align-items: stretch;
948
+ margin-bottom: 10px;
949
+ overflow: hidden;
950
+ border-radius: 7px;
951
+ }
952
+
953
+ .summary-caption,
954
+ .summary-item {
955
+ display: flex;
956
+ align-items: center;
957
+ justify-content: space-between;
958
+ gap: 10px;
959
+ min-width: 0;
960
+ padding: 10px 14px;
961
+ }
962
+
963
+ .summary-caption {
964
+ justify-content: flex-start;
965
+ border-right: 1px solid #e4e9f1;
966
+ background: #f5f8fc;
967
+ }
968
+
969
+ .summary-caption strong {
970
+ color: #1d5dbf;
971
+ font-size: 16px;
972
+ }
973
+
974
+ .summary-caption span,
975
+ .summary-item span {
976
+ color: #667085;
977
+ font-size: 12px;
978
+ }
979
+
980
+ .summary-item {
981
+ border-right: 1px solid #edf0f5;
982
+ }
983
+
984
+ .summary-item:last-child {
985
+ border-right: 0;
986
+ }
987
+
988
+ .summary-item strong {
989
+ font-size: 17px;
990
+ font-variant-numeric: tabular-nums;
991
+ }
992
+
993
+ .summary-item.is-income strong,
994
+ .summary-item.is-net-positive strong {
995
+ color: #12805c;
996
+ }
997
+
998
+ .summary-item.is-expense strong,
999
+ .summary-item.is-net-negative strong {
1000
+ color: #d14343;
1001
+ }
1002
+
1003
+ .currency-warning {
1004
+ margin-bottom: 10px;
1005
+ padding: 9px 14px;
1006
+ border-color: #f1d69a;
1007
+ border-radius: 7px;
1008
+ color: #8a5a00;
1009
+ background: #fff9eb;
1010
+ font-size: 12px;
1011
+ }
1012
+
1013
+ .table-panel {
1014
+ overflow: hidden;
1015
+ border-radius: 7px;
1016
+ }
1017
+
1018
+ .forecast-table {
1019
+ width: 100%;
1020
+ --el-table-header-bg-color: #f3f6fa;
1021
+ --el-table-header-text-color: #344054;
1022
+ --el-table-row-hover-bg-color: #f1f6ff;
1023
+ --el-table-border-color: #e1e6ed;
1024
+ }
1025
+
1026
+ .table-panel :deep(.el-table-plus__toolbar) {
1027
+ flex-wrap: wrap;
1028
+ gap: 8px;
1029
+ min-height: 42px;
1030
+ margin: 0;
1031
+ padding: 7px 14px;
1032
+ border-bottom: 1px solid #e5eaf1;
1033
+ background: #fbfcfe;
1034
+ }
1035
+
1036
+ .table-panel :deep(.el-table-plus__toolbar-left) {
1037
+ flex: 1;
1038
+ min-width: 0;
1039
+ flex-wrap: wrap;
1040
+ }
1041
+
1042
+ .table-panel :deep(.el-table-plus__toolbar-right) {
1043
+ flex: 0 0 auto;
1044
+ }
1045
+
1046
+ .table-panel :deep(.el-table-plus__pagination) {
1047
+ min-height: 52px;
1048
+ margin: 0;
1049
+ padding: 8px 14px;
1050
+ border-top: 1px solid #e5eaf1;
1051
+ background: #fff;
1052
+ }
1053
+
1054
+ .forecast-table :deep(.el-table__header th) {
1055
+ height: 40px;
1056
+ padding: 0;
1057
+ font-size: 12px;
1058
+ font-weight: 700;
1059
+ }
1060
+
1061
+ .forecast-table :deep(.el-table__cell) {
1062
+ padding: 6px 0;
1063
+ font-size: 12px;
1064
+ }
1065
+
1066
+ .forecast-table :deep(.el-table__row) {
1067
+ height: 42px;
1068
+ }
1069
+
1070
+ .forecast-table :deep(.el-tag) {
1071
+ max-width: 100%;
1072
+ }
1073
+
1074
+ .money-cell,
1075
+ .currency-code {
1076
+ font-variant-numeric: tabular-nums;
1077
+ }
1078
+
1079
+ .money-cell {
1080
+ color: #27364f;
1081
+ font-weight: 650;
1082
+ }
1083
+
1084
+ .currency-code {
1085
+ color: #174ea6;
1086
+ letter-spacing: .03em;
1087
+ }
1088
+
1089
+ .direction-text {
1090
+ font-weight: 700;
1091
+ }
1092
+
1093
+ .direction-text.is-income {
1094
+ color: #12805c;
1095
+ }
1096
+
1097
+ .direction-text.is-expense {
1098
+ color: #d14343;
1099
+ }
1100
+
1101
+ .row-actions {
1102
+ display: flex;
1103
+ align-items: center;
1104
+ justify-content: center;
1105
+ gap: 8px;
1106
+ white-space: nowrap;
1107
+ }
1108
+
1109
+ .row-actions .el-button + .el-button {
1110
+ margin-left: 0;
1111
+ }
1112
+
1113
+ @media (max-width: 1380px) {
1114
+ .query-grid:not(.is-collapsed) {
1115
+ grid-template-columns: repeat(4, minmax(0, 1fr));
1116
+ }
1117
+
1118
+ .query-grid.is-collapsed {
1119
+ grid-template-columns: repeat(6, minmax(0, 1fr));
1120
+ }
1121
+
1122
+ .operation-bar {
1123
+ align-items: flex-start;
1124
+ flex-direction: column;
1125
+ }
1126
+
1127
+ .approval-group {
1128
+ width: 100%;
1129
+ justify-content: flex-end;
1130
+ }
1131
+ }
1132
+
1133
+ @media (max-width: 900px) {
1134
+ .query-grid,
1135
+ .query-grid.is-collapsed {
1136
+ grid-template-columns: repeat(2, minmax(0, 1fr));
1137
+ }
1138
+
1139
+ .amount-summary {
1140
+ grid-template-columns: repeat(2, minmax(0, 1fr));
1141
+ }
1142
+
1143
+ .summary-caption {
1144
+ border-bottom: 1px solid #edf0f5;
1145
+ }
1146
+ }
1147
+ </style>