vue3-element-plus-app-chu 0.0.13 → 0.0.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -4
- package/package.json +3 -2
- package/src/layout/index.vue +21 -36
- package/src/router/index.ts +107 -0
- package/src/router/menus.ts +16 -0
- package/src/utils/request.ts +3 -1
- package/src/view/dcps/README.md +52 -0
- package/src/view/dcps/auth/index.vue +151 -14
- package/src/view/dcps/balance/index.vue +4 -6
- package/src/view/dcps/common.css +7 -0
- package/src/view/dcps/estimation/api.ts +18 -148
- package/src/view/dcps/estimation/index.vue +312 -13
- package/src/view/dcps/forecast/api.ts +21 -218
- package/src/view/dcps/forecast/index.vue +996 -50
- package/src/view/dcps/injection/index.vue +154 -11
- package/src/view/dcps/write-off/api.ts +25 -180
- package/src/view/dcps/write-off/index.vue +776 -39
- package/src/view/dcps/auth/components/.gitkeep +0 -0
- package/src/view/dcps/auth/components/AuthorizationDetailDialog.vue +0 -171
- package/src/view/dcps/estimation/components/EstimationDetailDialog.vue +0 -222
- package/src/view/dcps/forecast/components/ForecastDetailView.vue +0 -145
- package/src/view/dcps/forecast/components/ForecastEditorView.vue +0 -320
- package/src/view/dcps/forecast/components/ForecastListView.vue +0 -322
- package/src/view/dcps/forecast/components/ForecastPageShell.vue +0 -56
- package/src/view/dcps/injection/components/InjectionDetailDialog.vue +0 -171
- package/src/view/dcps/runtime.ts +0 -38
- package/src/view/dcps/write-off/components/FlowWriteOffView.vue +0 -299
- package/src/view/dcps/write-off/components/ForecastWriteOffView.vue +0 -437
|
@@ -2,10 +2,11 @@
|
|
|
2
2
|
import { computed, onBeforeUnmount, onMounted, reactive, ref } from 'vue'
|
|
3
3
|
import { ElMessage } from 'element-plus'
|
|
4
4
|
import { ArtDataTable, type ColumnOption, type PaginationOptions, type TableSettings } from '@/components/table'
|
|
5
|
-
import InjectionDetailDialog from './components/InjectionDetailDialog.vue'
|
|
6
5
|
import API from './api'
|
|
7
6
|
import type { InjectionFilters, InjectionQueryParams, InjectionRecord } from './typs'
|
|
8
7
|
|
|
8
|
+
defineOptions({ name: 'DcpsInjectionPage' })
|
|
9
|
+
|
|
9
10
|
type AmountSortOrder = 'ascending' | 'descending' | null
|
|
10
11
|
|
|
11
12
|
// 初始查询条件;空字符串表示不限制该条件,重置时恢复此配置。
|
|
@@ -35,6 +36,54 @@ let disposed = false // 页面是否已卸载,避免未完成请求继续更
|
|
|
35
36
|
const detailDialogVisible = ref(false) // 详情弹窗是否显示。
|
|
36
37
|
const detailRecord = ref<any>(null) // 当前查看详情的原始注资明细,未选择时为 null。
|
|
37
38
|
|
|
39
|
+
// 详情分组配置;title 为分组标题,fields 每项为 [明细字段名, 展示名称]。
|
|
40
|
+
const detailGroups = [
|
|
41
|
+
{
|
|
42
|
+
title: '交易信息',
|
|
43
|
+
fields: [
|
|
44
|
+
['txnDt', '交易日期'],
|
|
45
|
+
['txnTm', '交易时间'],
|
|
46
|
+
['refNo', '参考号'],
|
|
47
|
+
['bkkpSeqNo', '记账流水号'],
|
|
48
|
+
['capAdjustType', '调整类型'],
|
|
49
|
+
['ciMode', '注资方式'],
|
|
50
|
+
['txnProceSts', '交易处理状态'],
|
|
51
|
+
['pbocSts', '人行状态'],
|
|
52
|
+
],
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
title: '金额信息',
|
|
56
|
+
fields: [
|
|
57
|
+
['adjustAmt', '调整金额(元)'],
|
|
58
|
+
['ciLowestLimitamt', '注资最低限额(元)'],
|
|
59
|
+
['netAmtNettgGuaranty', '轧差注资定额(元)'],
|
|
60
|
+
],
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
title: '账户信息',
|
|
64
|
+
fields: [
|
|
65
|
+
['payerAcctNo', '付款人账号'],
|
|
66
|
+
['payerName', '付款人名称'],
|
|
67
|
+
['payeeAcctNo', '收款人账号'],
|
|
68
|
+
['payeeAcctName', '收款人账户名称'],
|
|
69
|
+
],
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
title: '报文信息',
|
|
73
|
+
fields: [
|
|
74
|
+
['msgNo', '报文编号'],
|
|
75
|
+
['msgIndNo', '报文标识号'],
|
|
76
|
+
['origMsgCd', '原报文类型'],
|
|
77
|
+
['origMsgIndNo', '原报文标识号'],
|
|
78
|
+
['proceDt', '处理日期'],
|
|
79
|
+
['createTm', '创建时间'],
|
|
80
|
+
],
|
|
81
|
+
},
|
|
82
|
+
] as const
|
|
83
|
+
|
|
84
|
+
/** 读取详情展示值,空值显示占位符;field 为明细字段名。 */
|
|
85
|
+
const detailValue = (field: string) => detailValues.value?.[field]?.trim() || '—'
|
|
86
|
+
|
|
38
87
|
// 表格设置:small 尺寸,并开启斑马纹、边框和表头背景。
|
|
39
88
|
const tableSettings = ref<TableSettings>({ size: 'small', stripe: true, border: true, headerBackground: true })
|
|
40
89
|
// 分页设置:右对齐,可选每页 10、20、50 条。
|
|
@@ -316,27 +365,67 @@ onBeforeUnmount(() => {
|
|
|
316
365
|
</ArtDataTable>
|
|
317
366
|
</div>
|
|
318
367
|
|
|
319
|
-
|
|
368
|
+
<!-- 注资明细详情弹窗:按交易、金额、账户、报文分组展示。 -->
|
|
369
|
+
<el-dialog
|
|
320
370
|
v-model="detailDialogVisible"
|
|
321
|
-
|
|
322
|
-
:
|
|
323
|
-
|
|
371
|
+
title="数字人民币注资明细"
|
|
372
|
+
style="--el-dialog-padding-primary: 10px; padding: 10px 16px; margin-bottom: 16px"
|
|
373
|
+
width="min(1180px, calc(100vw - 32px))"
|
|
374
|
+
top="16px"
|
|
375
|
+
append-to-body
|
|
376
|
+
destroy-on-close
|
|
377
|
+
>
|
|
378
|
+
<el-scrollbar class="detail-scrollbar">
|
|
379
|
+
<div v-if="detailRecord" class="detail-content">
|
|
380
|
+
<!-- 金额摘要 -->
|
|
381
|
+
<header class="detail-summary">
|
|
382
|
+
<div>
|
|
383
|
+
<span class="detail-label">调整金额(元)</span>
|
|
384
|
+
<strong class="detail-amount">{{ detailValue('adjustAmt') }}</strong>
|
|
385
|
+
</div>
|
|
386
|
+
<div>
|
|
387
|
+
<span class="detail-label">交易处理状态</span>
|
|
388
|
+
<strong class="detail-status">{{ detailValue('txnProceSts') }}</strong>
|
|
389
|
+
</div>
|
|
390
|
+
<div class="detail-reference">
|
|
391
|
+
<span class="detail-label">记账流水号</span>
|
|
392
|
+
<strong>{{ detailValue('bkkpSeqNo') }}</strong>
|
|
393
|
+
</div>
|
|
394
|
+
</header>
|
|
395
|
+
|
|
396
|
+
<!-- group 为当前详情分组,包含标题和字段配置。 -->
|
|
397
|
+
<section v-for="group in detailGroups" :key="group.title" class="detail-group" :aria-label="group.title">
|
|
398
|
+
<h3>{{ group.title }}</h3>
|
|
399
|
+
<dl class="detail-fields">
|
|
400
|
+
<!-- field 为明细字段名,label 为字段的中文展示名称。 -->
|
|
401
|
+
<div
|
|
402
|
+
v-for="[field, label] in group.fields"
|
|
403
|
+
:key="field"
|
|
404
|
+
class="detail-field"
|
|
405
|
+
>
|
|
406
|
+
<dt>{{ label }}</dt>
|
|
407
|
+
<dd>{{ detailValue(field) }}</dd>
|
|
408
|
+
</div>
|
|
409
|
+
</dl>
|
|
410
|
+
</section>
|
|
411
|
+
</div>
|
|
412
|
+
</el-scrollbar>
|
|
413
|
+
<template #footer>
|
|
414
|
+
<el-button @click="detailDialogVisible = false">关闭</el-button>
|
|
415
|
+
</template>
|
|
416
|
+
</el-dialog>
|
|
324
417
|
</main>
|
|
325
418
|
</template>
|
|
326
419
|
|
|
327
420
|
<style scoped>
|
|
328
421
|
/* 页面先扣除宿主占用高度,再使用 flex 分配剩余高度,让列表内部滚动并保留分页。 */
|
|
329
422
|
.dcps-page {
|
|
330
|
-
/* 手动修改这里:顶部导航/页签 + 底部状态栏 + 宿主上下留白的合计高度。
|
|
331
|
-
独立页面保持 0px;例如顶部 90px、底部 24px、上下留白 6px,填写 120px。
|
|
332
|
-
不包含浏览器标签栏、地址栏,也不包含本页面自身的 padding。 */
|
|
333
|
-
--host-layout-height: 0px;
|
|
334
423
|
box-sizing: border-box;
|
|
335
424
|
display: flex;
|
|
336
425
|
flex-direction: column;
|
|
337
426
|
gap: 5px;
|
|
338
|
-
height: calc(100vh - var(--host-layout-height));
|
|
339
|
-
height: calc(100dvh - var(--host-layout-height));
|
|
427
|
+
height: calc(100vh - var(--dpcs-host-layout-height));
|
|
428
|
+
height: calc(100dvh - var(--dpcs-host-layout-height));
|
|
340
429
|
min-height: 0;
|
|
341
430
|
min-width: 0;
|
|
342
431
|
padding: 5px;
|
|
@@ -358,6 +447,60 @@ onBeforeUnmount(() => {
|
|
|
358
447
|
.filter-form :deep(.el-form-item__label) { margin-bottom: 4px; }
|
|
359
448
|
.filter-actions { flex-shrink: 0; margin-left: auto; }
|
|
360
449
|
.amount-cell { color: var(--el-color-primary-dark-2); font-variant-numeric: tabular-nums; font-weight: 600; }
|
|
450
|
+
|
|
451
|
+
/* ---------- 注资明细详情弹窗 ---------- */
|
|
452
|
+
.detail-scrollbar { max-height: calc(100vh - 240px); }
|
|
453
|
+
.detail-content { padding: 2px 4px 8px; }
|
|
454
|
+
|
|
455
|
+
.detail-summary {
|
|
456
|
+
display: flex;
|
|
457
|
+
flex-wrap: wrap;
|
|
458
|
+
gap: 12px 36px;
|
|
459
|
+
align-items: center;
|
|
460
|
+
padding: 12px 14px;
|
|
461
|
+
border-radius: 10px;
|
|
462
|
+
background: var(--el-fill-color-light);
|
|
463
|
+
}
|
|
464
|
+
.detail-label { margin-bottom: 5px; color: var(--el-text-color-secondary); font-size: 11px; display: block; }
|
|
465
|
+
.detail-summary strong { overflow-wrap: anywhere; font-size: 13px; }
|
|
466
|
+
.detail-amount { color: var(--el-color-primary-dark-2); font-variant-numeric: tabular-nums; }
|
|
467
|
+
.detail-reference { margin-left: auto; }
|
|
468
|
+
.detail-reference strong { font-weight: 600; }
|
|
469
|
+
|
|
470
|
+
.detail-group { margin-top: 16px; }
|
|
471
|
+
.detail-group h3 { margin: 0 0 10px; color: var(--el-text-color-primary); font-size: 13px; }
|
|
472
|
+
.detail-fields {
|
|
473
|
+
display: grid;
|
|
474
|
+
grid-template-columns: repeat(4, minmax(0, 1fr));
|
|
475
|
+
margin: 0;
|
|
476
|
+
border: 1px solid var(--el-border-color-lighter);
|
|
477
|
+
border-radius: 8px;
|
|
478
|
+
overflow: hidden;
|
|
479
|
+
}
|
|
480
|
+
.detail-field {
|
|
481
|
+
margin: 0;
|
|
482
|
+
padding: 10px 14px;
|
|
483
|
+
border-right: 1px solid var(--el-border-color-lighter);
|
|
484
|
+
border-bottom: 1px solid var(--el-border-color-lighter);
|
|
485
|
+
}
|
|
486
|
+
.detail-field:nth-child(4n) { border-right: 0; }
|
|
487
|
+
.detail-field dt { margin-bottom: 4px; color: var(--el-text-color-secondary); font-size: 11px; }
|
|
488
|
+
.detail-field dd { margin: 0; color: var(--el-text-color-primary); overflow-wrap: anywhere; font-size: 12px; }
|
|
489
|
+
|
|
490
|
+
@media (max-width: 1200px) {
|
|
491
|
+
.detail-fields { grid-template-columns: repeat(3, minmax(0, 1fr)); }
|
|
492
|
+
.detail-field:nth-child(4n) { border-right: 1px solid var(--el-border-color-lighter); }
|
|
493
|
+
.detail-field:nth-child(3n) { border-right: 0; }
|
|
494
|
+
}
|
|
495
|
+
@media (max-width: 900px) {
|
|
496
|
+
.detail-fields { grid-template-columns: repeat(2, minmax(0, 1fr)); }
|
|
497
|
+
.detail-field:nth-child(3n) { border-right: 1px solid var(--el-border-color-lighter); }
|
|
498
|
+
.detail-field:nth-child(2n) { border-right: 0; }
|
|
499
|
+
}
|
|
500
|
+
@media (max-width: 560px) {
|
|
501
|
+
.detail-fields { grid-template-columns: minmax(0, 1fr); }
|
|
502
|
+
.detail-field { border-right: 0 !important; }
|
|
503
|
+
}
|
|
361
504
|
@media (max-width: 540px) {
|
|
362
505
|
.filter-form :deep(.el-form-item) { flex-basis: 100%; }
|
|
363
506
|
.filter-actions { margin-left: 0; }
|
|
@@ -1,192 +1,37 @@
|
|
|
1
|
-
import
|
|
2
|
-
import type { ApiResponse } from '@/utils/request'
|
|
3
|
-
import type {
|
|
4
|
-
Tam120502001InBody,
|
|
5
|
-
Tam120502002InBody,
|
|
6
|
-
Tam120502003InBody,
|
|
7
|
-
Tam140502001InBody,
|
|
8
|
-
Tam140502001OutBody,
|
|
9
|
-
Tam140502002InBody,
|
|
10
|
-
Tam140502002OutBody,
|
|
11
|
-
} from './typs'
|
|
1
|
+
import baseHttpClient from "@chic/http"
|
|
12
2
|
|
|
13
|
-
|
|
14
|
-
* 数字人民币头寸核销的五个接口,复用本模块的类型定义。
|
|
15
|
-
* 支持平铺参数和 { appHead, head, body } 报文;业务 tranDate 始终保留在 body。
|
|
16
|
-
* 金额、日期、账号及流水号使用字符串,响应保留 TAM 的 head、body 结构。
|
|
17
|
-
*/
|
|
18
|
-
const API = {
|
|
3
|
+
export default {
|
|
19
4
|
/**
|
|
20
|
-
*
|
|
21
|
-
* @param params predRefNo 为预报流水号,predAmt 为预报金额,
|
|
22
|
-
* beforeVerifyAmt
|
|
5
|
+
* 修改预报记录的已核销金额。
|
|
6
|
+
* @param params 修改参数:predRefNo 为预报流水号,predAmt 为预报金额,
|
|
7
|
+
* beforeVerifyAmt 为修改前已核销金额,verifyAmt 为修改后的已核销金额。
|
|
23
8
|
*/
|
|
24
|
-
editApi: (params:
|
|
25
|
-
postDigitalRmb<Tam120502001InBody, Record<string, unknown>>('/TAM/0001/120502001', params),
|
|
26
|
-
|
|
9
|
+
editApi: (params: unknown) => baseHttpClient.post<any>("/TAM/0001/120502001", params),
|
|
27
10
|
/**
|
|
28
|
-
*
|
|
29
|
-
* @param params predList
|
|
30
|
-
* tranList
|
|
11
|
+
* 提交头寸核销。
|
|
12
|
+
* @param params 核销参数:predList 为预报核销集合(必填),每项包含 predRefNo、predAmt、
|
|
13
|
+
* verifyAmt、verifyStatus;tranList 为流水核销集合(可选),每项包含 refNo、tranAmt、verifyStatus。
|
|
31
14
|
*/
|
|
32
|
-
writeOffApi: (params:
|
|
33
|
-
postDigitalRmb<Tam120502002InBody, Record<string, unknown>>('/TAM/0001/120502002', params),
|
|
34
|
-
|
|
15
|
+
writeOffApi: (params: unknown) => baseHttpClient.post<any>("/TAM/0001/120502002", params),
|
|
35
16
|
/**
|
|
36
|
-
*
|
|
37
|
-
* @param params predList 为预报集合,tranList
|
|
38
|
-
*
|
|
17
|
+
* 撤销头寸核销。
|
|
18
|
+
* @param params 撤销参数:predList 为预报集合,tranList 为流水集合,均可选;
|
|
19
|
+
* 预报项按行原值提交,流水项需包含 refNo、tranAmt、verifyStatus。
|
|
39
20
|
*/
|
|
40
|
-
cancelWriteOffApi: (params:
|
|
41
|
-
postDigitalRmb<Tam120502003InBody, Record<string, unknown>>('/TAM/0001/120502003', params),
|
|
42
|
-
|
|
21
|
+
cancelWriteOffApi: (params: unknown) => baseHttpClient.post<any>("/TAM/0001/120502003", params),
|
|
43
22
|
/**
|
|
44
|
-
*
|
|
45
|
-
* @param params tranDate
|
|
46
|
-
*
|
|
47
|
-
*
|
|
23
|
+
* 分页查询核销预报信息。
|
|
24
|
+
* @param params 查询参数:tranDate 为交易日期(必填,YYYYMMDD);pageIndex、pageSize 为页码和每页条数。
|
|
25
|
+
* 业务筛选:acctNo 为我方账号,banchPre 为机构关键字,busiType 为业务类型,
|
|
26
|
+
* clientName 为客户名称,competName 为交易对手名称,payDirec 为收支方向,
|
|
27
|
+
* startTransAmt、endTransAmt 为金额范围,verifyStatusList 为核销状态列表。
|
|
48
28
|
*/
|
|
49
|
-
queryForecastApi: (params:
|
|
50
|
-
postDigitalRmb<Tam140502001InBody, Tam140502001OutBody>('/TAM/0001/140502001', params),
|
|
51
|
-
|
|
29
|
+
queryForecastApi: (params: unknown) => baseHttpClient.post<any>("/TAM/0001/140502001", params),
|
|
52
30
|
/**
|
|
53
|
-
*
|
|
54
|
-
* @param params tranDate
|
|
55
|
-
*
|
|
56
|
-
*
|
|
31
|
+
* 分页查询核销流水信息。
|
|
32
|
+
* @param params 查询参数:tranDate 为交易日期(必填,YYYYMMDD);pageIndex、pageSize 为页码和每页条数。
|
|
33
|
+
* 业务筛选:orgName 为我方机构,payerName、payeeName 为付款人和收款人名称,
|
|
34
|
+
* payDirec 为收支方向,startTransAmt、endTransAmt 为金额范围,verifyStatus 为核销状态。
|
|
57
35
|
*/
|
|
58
|
-
queryFlowApi: (params:
|
|
59
|
-
postDigitalRmb<Tam140502002InBody, Tam140502002OutBody>('/TAM/0001/140502002', params),
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
/** 列表查询结果:当前页记录和符合条件的总条数。 */
|
|
63
|
-
export interface WriteOffPage<T> {
|
|
64
|
-
data: T[] // 当前页的记录列表。
|
|
65
|
-
total: number // 符合查询条件的总记录数。
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
/** 校验公共响应头;retCode 不是 00000 时按服务端提示或 fallback 抛错。 */
|
|
69
|
-
export function ensureSuccess<T>(response: ApiResponse<T>, fallback: string): T | null {
|
|
70
|
-
if (response?.head?.retCode !== '00000') {
|
|
71
|
-
throw new Error(response?.head?.retMsg?.trim() || fallback)
|
|
72
|
-
}
|
|
73
|
-
return response.body
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
/**
|
|
77
|
-
* 校验查询响应并取出当前页数据;两个查询接口共享同一种 body 结构。
|
|
78
|
-
* @param body 查询接口返回的业务数据。
|
|
79
|
-
* @param fallback body 缺少 resultList 时的错误提示文本。
|
|
80
|
-
*/
|
|
81
|
-
export function readPage<R extends { resultList?: unknown[]; totalCount?: unknown }>(
|
|
82
|
-
body: R | null,
|
|
83
|
-
fallback: string,
|
|
84
|
-
): WriteOffPage<NonNullable<R['resultList']>[number]> {
|
|
85
|
-
if (!body || !Array.isArray(body.resultList)) throw new Error(fallback)
|
|
86
|
-
const totalText = String(body.totalCount ?? body.resultList.length)
|
|
87
|
-
const total = Number(totalText)
|
|
88
|
-
if (!/^\d+$/.test(totalText) || !Number.isSafeInteger(total)) throw new Error('查询返回的总条数无效')
|
|
89
|
-
return { data: body.resultList, total }
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
/** 提取可展示的错误信息;无法识别时给出统一提示。 */
|
|
93
|
-
export function getErrorMessage(error: unknown): string {
|
|
94
|
-
if (error instanceof Error && error.message.trim()) return error.message
|
|
95
|
-
if (typeof error === 'string' && error.trim()) return error
|
|
96
|
-
return '操作失败,请稍后重试'
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
/** 业务日期始终按上海时区生成,不依赖浏览器所在时区,格式为 YYYYMMDD。 */
|
|
100
|
-
export function getToday(): string {
|
|
101
|
-
const parts = new Intl.DateTimeFormat('en-CA', {
|
|
102
|
-
timeZone: 'Asia/Shanghai', year: 'numeric', month: '2-digit', day: '2-digit',
|
|
103
|
-
}).formatToParts(new Date())
|
|
104
|
-
const read = (type: Intl.DateTimeFormatPartTypes) => parts.find((part) => part.type === type)?.value || ''
|
|
105
|
-
return read('year') + read('month') + read('day')
|
|
36
|
+
queryFlowApi: (params: unknown) => baseHttpClient.post<any>("/TAM/0001/140502002", params)
|
|
106
37
|
}
|
|
107
|
-
|
|
108
|
-
/** 判断是否为合法的 YYYYMMDD 日期。 */
|
|
109
|
-
export function isValidDate(value: string): boolean {
|
|
110
|
-
if (!/^\d{8}$/.test(value)) return false
|
|
111
|
-
const year = Number(value.slice(0, 4))
|
|
112
|
-
const month = Number(value.slice(4, 6))
|
|
113
|
-
const day = Number(value.slice(6, 8))
|
|
114
|
-
if (year < 1 || month < 1 || month > 12 || day < 1) return false
|
|
115
|
-
const leap = year % 400 === 0 || (year % 4 === 0 && year % 100 !== 0)
|
|
116
|
-
const monthDays = [31, leap ? 29 : 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
|
|
117
|
-
return day <= (monthDays[month - 1] || 0)
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
/** 把 YYYYMMDD 格式化为 YYYY-MM-DD 展示;空值显示横线,其他格式保留原文。 */
|
|
121
|
-
export function formatDate(value?: string): string {
|
|
122
|
-
const text = value?.trim() || ''
|
|
123
|
-
if (!text) return '—'
|
|
124
|
-
return isValidDate(text) ? `${text.slice(0, 4)}-${text.slice(4, 6)}-${text.slice(6, 8)}` : text
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
/** 只接受十进制文本和合法千分位;保留全部小数位,避免改变输入精度。 */
|
|
128
|
-
export function normalizeAmount(value: string): string {
|
|
129
|
-
let text = value.trim()
|
|
130
|
-
if (text.includes(',')) {
|
|
131
|
-
if (!/^[+-]?\d{1,3}(?:,\d{3})+(?:\.\d*)?$/.test(text)) return ''
|
|
132
|
-
text = text.replace(/,/g, '')
|
|
133
|
-
}
|
|
134
|
-
const match = /^([+-]?)(\d*)(?:\.(\d*))?$/.exec(text)
|
|
135
|
-
if (!match || (!match[2] && !match[3])) return ''
|
|
136
|
-
const integer = (match[2] || '0').replace(/^0+(?=\d)/, '')
|
|
137
|
-
const fraction = match[3] || ''
|
|
138
|
-
const negative = match[1] === '-' && /[1-9]/.test(integer + fraction)
|
|
139
|
-
return `${negative ? '-' : ''}${integer}${fraction ? `.${fraction}` : ''}`
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
/** 千分位展示至少两位小数,超过两位的小数原样保留,不做浮点数转换或舍入。 */
|
|
143
|
-
export function formatAmount(value?: string): string {
|
|
144
|
-
const original = value?.trim() || ''
|
|
145
|
-
if (!original) return '—'
|
|
146
|
-
const normalized = normalizeAmount(original)
|
|
147
|
-
if (!normalized) return original
|
|
148
|
-
const negative = normalized.startsWith('-')
|
|
149
|
-
const [integer = '0', fraction = ''] = (negative ? normalized.slice(1) : normalized).split('.')
|
|
150
|
-
const grouped = integer.replace(/\B(?=(\d{3})+(?!\d))/g, ',')
|
|
151
|
-
return `${negative ? '-' : ''}${grouped}.${fraction.padEnd(2, '0')}`
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
/** 按统一小数位数转为 BigInt,任意长度的十进制金额都可精确比较。 */
|
|
155
|
-
export function compareAmounts(left: string, right: string): number {
|
|
156
|
-
const leftText = normalizeAmount(left)
|
|
157
|
-
const rightText = normalizeAmount(right)
|
|
158
|
-
if (!leftText || !rightText) {
|
|
159
|
-
if (!leftText && !rightText) return 0
|
|
160
|
-
return leftText ? -1 : 1
|
|
161
|
-
}
|
|
162
|
-
const parts = (text: string) => {
|
|
163
|
-
const negative = text.startsWith('-')
|
|
164
|
-
const [integer = '0', fraction = ''] = (negative ? text.slice(1) : text).split('.')
|
|
165
|
-
return { negative, integer, fraction }
|
|
166
|
-
}
|
|
167
|
-
const a = parts(leftText)
|
|
168
|
-
const b = parts(rightText)
|
|
169
|
-
const precision = Math.max(a.fraction.length, b.fraction.length)
|
|
170
|
-
const toInteger = (amount: ReturnType<typeof parts>) =>
|
|
171
|
-
BigInt(amount.integer + amount.fraction.padEnd(precision, '0')) * (amount.negative ? -1n : 1n)
|
|
172
|
-
const aValue = toInteger(a)
|
|
173
|
-
const bValue = toInteger(b)
|
|
174
|
-
return aValue < bValue ? -1 : aValue > bValue ? 1 : 0
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
/** 业务类型字典:201 兑回、202 兑出、203 付现;接口附件已声明,超出字典的值保留原文。 */
|
|
178
|
-
export const busiTypeLabels: Record<string, string> = { '201': '兑回', '202': '兑出', '203': '付现' }
|
|
179
|
-
/** 收支方向字典:I 来账、O 往账。 */
|
|
180
|
-
export const payDirecLabels: Record<string, string> = { I: '来账', O: '往账' }
|
|
181
|
-
/** 支付渠道:核销预报为 8、流水为 5,均表示数字人民币;其余渠道保留原文。 */
|
|
182
|
-
export const payChannelLabels: Record<string, string> = { '5': '数字人民币', '8': '数字人民币' }
|
|
183
|
-
/** 核销状态字典:流水的 1 未核销、2 已核销已在附件声明,预报按同一枚举展示。 */
|
|
184
|
-
export const verifyStatusLabels: Record<string, string> = { '1': '未核销', '2': '已核销' }
|
|
185
|
-
|
|
186
|
-
/** 读取字典文案;空值显示横线,未登记的代码保留原文展示。 */
|
|
187
|
-
export function dictLabel(labels: Record<string, string>, value?: string): string {
|
|
188
|
-
const text = value?.trim() || ''
|
|
189
|
-
return text ? labels[text] ?? text : '—'
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
export default API
|