verce-vue-test 0.0.74 → 0.0.75

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