verce-vue-test 0.0.76 → 0.0.77
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/package.json +1 -1
- package/src/router/index.ts +1 -1
- package/src/utils/baseHttpClient.ts +159 -0
- package/src/views/rmb-position-estimation/api.ts +29 -221
- package/src/views/{RmbPositionEstimationView.vue → rmb-position-estimation/index.vue} +152 -19
- package/src/views/rmb-position-estimation/types.ts +120 -0
package/package.json
CHANGED
package/src/router/index.ts
CHANGED
|
@@ -88,7 +88,7 @@ const router = createRouter({
|
|
|
88
88
|
{
|
|
89
89
|
path: '/rmb-position-estimation',
|
|
90
90
|
name: 'rmbPositionEstimation',
|
|
91
|
-
component: () => import('../views/
|
|
91
|
+
component: () => import('../views/rmb-position-estimation/index.vue'),
|
|
92
92
|
},
|
|
93
93
|
{
|
|
94
94
|
path: '/executive-management',
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
const apiBaseUrl = String(
|
|
2
|
+
import.meta.env.VITE_API_BASE_URL || 'http://localhost:3011/oms',
|
|
3
|
+
).replace(/\/+$/, '')
|
|
4
|
+
|
|
5
|
+
const tamBranchId = String(import.meta.env.VITE_TAM_BRANCH_ID || 'HQ001')
|
|
6
|
+
const tamUserId = String(import.meta.env.VITE_TAM_USER_ID || 'HQ00601')
|
|
7
|
+
const tamClientIp = String(import.meta.env.VITE_TAM_CLIENT_IP || '')
|
|
8
|
+
|
|
9
|
+
export type HttpRequestOptions = Omit<RequestInit, 'body' | 'method'>
|
|
10
|
+
|
|
11
|
+
export type TamResponse<T> = {
|
|
12
|
+
head: {
|
|
13
|
+
retStatus?: string
|
|
14
|
+
retCode?: string
|
|
15
|
+
retMsg?: string
|
|
16
|
+
[key: string]: unknown
|
|
17
|
+
}
|
|
18
|
+
body: T
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
type ErrorResponse = {
|
|
22
|
+
error?: {
|
|
23
|
+
message?: string
|
|
24
|
+
}
|
|
25
|
+
head?: {
|
|
26
|
+
retMsg?: string
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
function pad(value: number) {
|
|
31
|
+
return String(value).padStart(2, '0')
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
function compactDate(date: Date) {
|
|
35
|
+
return `${date.getFullYear()}${pad(date.getMonth() + 1)}${pad(date.getDate())}`
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
function compactTime(date: Date) {
|
|
39
|
+
return `${pad(date.getHours())}${pad(date.getMinutes())}${pad(date.getSeconds())}`
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
function createConsumerSeqNo(date: Date) {
|
|
43
|
+
return `${tamUserId}${compactDate(date)}${compactTime(date)}${String(date.getMilliseconds()).padStart(3, '0')}`
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
function isTamPath(path: string) {
|
|
47
|
+
return path.startsWith('/TAM/')
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
function createTamRequest(path: string, body: unknown) {
|
|
51
|
+
const now = new Date()
|
|
52
|
+
|
|
53
|
+
return {
|
|
54
|
+
appHead: {
|
|
55
|
+
fileName: '',
|
|
56
|
+
opType: '',
|
|
57
|
+
ip: tamClientIp,
|
|
58
|
+
},
|
|
59
|
+
head: {
|
|
60
|
+
branchId: tamBranchId,
|
|
61
|
+
consumerSeqNo: createConsumerSeqNo(now),
|
|
62
|
+
consumerId: 'TAM001',
|
|
63
|
+
tranCode: path,
|
|
64
|
+
tranDate: compactDate(now),
|
|
65
|
+
tranTimestamp: compactTime(now),
|
|
66
|
+
pageSize: '10',
|
|
67
|
+
pageIndex: '1',
|
|
68
|
+
traceId: '',
|
|
69
|
+
spanId: '',
|
|
70
|
+
userId: tamUserId,
|
|
71
|
+
versionId: '0001',
|
|
72
|
+
verifyUserId: '',
|
|
73
|
+
adminUserId: '',
|
|
74
|
+
apprUserId: '',
|
|
75
|
+
areaCode: '0000',
|
|
76
|
+
digitalSign: '',
|
|
77
|
+
fileFlag: 'N',
|
|
78
|
+
filePath: '',
|
|
79
|
+
isBatch: false,
|
|
80
|
+
},
|
|
81
|
+
body,
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
function resolveUrl(path: string) {
|
|
86
|
+
return /^https?:\/\//i.test(path) ? path : `${apiBaseUrl}${path}`
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
function getErrorMessage(payload: unknown, fallback: string) {
|
|
90
|
+
if (!payload || typeof payload !== 'object' || Array.isArray(payload)) return fallback
|
|
91
|
+
const response = payload as ErrorResponse
|
|
92
|
+
return response.head?.retMsg || response.error?.message || fallback
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
async function request<T>(
|
|
96
|
+
method: string,
|
|
97
|
+
path: string,
|
|
98
|
+
data?: unknown,
|
|
99
|
+
options: HttpRequestOptions = {},
|
|
100
|
+
): Promise<T> {
|
|
101
|
+
const tamRequest = isTamPath(path)
|
|
102
|
+
const response = await fetch(resolveUrl(path), {
|
|
103
|
+
...options,
|
|
104
|
+
method,
|
|
105
|
+
headers: {
|
|
106
|
+
'Content-Type': 'application/json',
|
|
107
|
+
...options.headers,
|
|
108
|
+
},
|
|
109
|
+
body: data === undefined
|
|
110
|
+
? undefined
|
|
111
|
+
: JSON.stringify(tamRequest ? createTamRequest(path, data) : data),
|
|
112
|
+
})
|
|
113
|
+
|
|
114
|
+
let payload: unknown
|
|
115
|
+
try {
|
|
116
|
+
payload = await response.json()
|
|
117
|
+
} catch {
|
|
118
|
+
throw new Error(`接口返回的不是有效 JSON(HTTP ${response.status})`)
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
if (!response.ok) {
|
|
122
|
+
throw new Error(getErrorMessage(payload, `请求失败(HTTP ${response.status})`))
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
if (tamRequest) {
|
|
126
|
+
if (!payload || typeof payload !== 'object' || Array.isArray(payload)) {
|
|
127
|
+
throw new Error('TAM 接口返回结构不正确')
|
|
128
|
+
}
|
|
129
|
+
const tamResponse = payload as TamResponse<unknown>
|
|
130
|
+
if (tamResponse.head?.retStatus !== 'S' || tamResponse.head?.retCode !== '00000') {
|
|
131
|
+
throw new Error(tamResponse.head?.retMsg || 'TAM 交易失败')
|
|
132
|
+
}
|
|
133
|
+
if (!tamResponse.body || typeof tamResponse.body !== 'object' || Array.isArray(tamResponse.body)) {
|
|
134
|
+
throw new Error('TAM 接口返回结构不正确')
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
return payload as T
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
const baseHttpClient = {
|
|
142
|
+
get<T>(path: string, options?: HttpRequestOptions) {
|
|
143
|
+
return request<T>('GET', path, undefined, options)
|
|
144
|
+
},
|
|
145
|
+
post<T>(path: string, data?: unknown, options?: HttpRequestOptions) {
|
|
146
|
+
return request<T>('POST', path, data, options)
|
|
147
|
+
},
|
|
148
|
+
put<T>(path: string, data?: unknown, options?: HttpRequestOptions) {
|
|
149
|
+
return request<T>('PUT', path, data, options)
|
|
150
|
+
},
|
|
151
|
+
patch<T>(path: string, data?: unknown, options?: HttpRequestOptions) {
|
|
152
|
+
return request<T>('PATCH', path, data, options)
|
|
153
|
+
},
|
|
154
|
+
delete<T>(path: string, options?: HttpRequestOptions) {
|
|
155
|
+
return request<T>('DELETE', path, undefined, options)
|
|
156
|
+
},
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
export default baseHttpClient
|
|
@@ -1,221 +1,29 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
'tgPredAmtNet',
|
|
31
|
-
'tgUnverifyAmtIn',
|
|
32
|
-
'tgUnverifyAmtOut',
|
|
33
|
-
'tgUnverifyAmtNet',
|
|
34
|
-
'tyPredAmtIn',
|
|
35
|
-
'tyPredAmtOut',
|
|
36
|
-
'tyPredAmtNet',
|
|
37
|
-
'tyUnverifyAmtIn',
|
|
38
|
-
'tyUnverifyAmtOut',
|
|
39
|
-
'tyUnverifyAmtNet',
|
|
40
|
-
'fzhPredAmtIn',
|
|
41
|
-
'fzhPredAmtOut',
|
|
42
|
-
'fzhPredAmtNet',
|
|
43
|
-
'fzhUnverifyAmtIn',
|
|
44
|
-
'fzhUnverifyAmtOut',
|
|
45
|
-
'fzhUnverifyAmtNet',
|
|
46
|
-
'lcPredAmtIn',
|
|
47
|
-
'lcPredAmtOut',
|
|
48
|
-
'lcPredAmtNet',
|
|
49
|
-
'lcUnverifyAmtIn',
|
|
50
|
-
'lcUnverifyAmtOut',
|
|
51
|
-
'lcUnverifyAmtNet',
|
|
52
|
-
'qtPredAmtIn',
|
|
53
|
-
'qtPredAmtOut',
|
|
54
|
-
'qtPredAmtNet',
|
|
55
|
-
'qtUnverifyAmtIn',
|
|
56
|
-
'qtUnverifyAmtOut',
|
|
57
|
-
'qtUnverifyAmtNet',
|
|
58
|
-
'xjAmtIn',
|
|
59
|
-
'xjAmtOut',
|
|
60
|
-
'xjAmtNet',
|
|
61
|
-
'unVerifyAmtIn1',
|
|
62
|
-
'unVerifyAmtOut1',
|
|
63
|
-
'unVerifyAmtNet1',
|
|
64
|
-
'unVerifyAmtIn',
|
|
65
|
-
'unVerifyAmtOut',
|
|
66
|
-
'unVerifyAmtNet',
|
|
67
|
-
'zjPredAmtIn',
|
|
68
|
-
'zjPredAmtOut',
|
|
69
|
-
'zjPredAmtNet',
|
|
70
|
-
'zjUnverifyAmtIn',
|
|
71
|
-
'zjUnverifyAmtOut',
|
|
72
|
-
'zjUnverifyAmtNet',
|
|
73
|
-
] as const
|
|
74
|
-
|
|
75
|
-
export type RmbPositionAmountField = typeof rmbPositionAmountFields[number]
|
|
76
|
-
export type ProtocolAmount = number | '0'
|
|
77
|
-
|
|
78
|
-
export type RmbPositionEstimationRequestBody = {
|
|
79
|
-
overAmt: ProtocolAmount
|
|
80
|
-
tranDate: string
|
|
81
|
-
fzAmtIn: ProtocolAmount
|
|
82
|
-
fzAmtOut: ProtocolAmount
|
|
83
|
-
fzAmtRmk: string
|
|
84
|
-
bepsAmtIn: ProtocolAmount
|
|
85
|
-
bepsAmtOut: ProtocolAmount
|
|
86
|
-
bepsAmtRmk: string
|
|
87
|
-
othAmtIn: ProtocolAmount
|
|
88
|
-
othAmtOut: ProtocolAmount
|
|
89
|
-
othAmtRmk: string
|
|
90
|
-
ysAmtIn: ProtocolAmount
|
|
91
|
-
ysAmtOut: ProtocolAmount
|
|
92
|
-
ysAmtRmk: string
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
export type RmbPositionEstimationResponseBody = {
|
|
96
|
-
fileName: string
|
|
97
|
-
} & Record<RmbPositionAmountField, string>
|
|
98
|
-
|
|
99
|
-
type TamResponse = {
|
|
100
|
-
head?: {
|
|
101
|
-
retStatus?: string
|
|
102
|
-
retCode?: string
|
|
103
|
-
retMsg?: string
|
|
104
|
-
}
|
|
105
|
-
body?: Record<string, unknown>
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
type RequestOptions = {
|
|
109
|
-
signal?: AbortSignal
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
function pad(value: number) {
|
|
113
|
-
return String(value).padStart(2, '0')
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
function compactDate(date: Date) {
|
|
117
|
-
return `${date.getFullYear()}${pad(date.getMonth() + 1)}${pad(date.getDate())}`
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
function compactTime(date: Date) {
|
|
121
|
-
return `${pad(date.getHours())}${pad(date.getMinutes())}${pad(date.getSeconds())}`
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
function createConsumerSeqNo(date: Date) {
|
|
125
|
-
return `${tamUserId}${compactDate(date)}${compactTime(date)}${String(date.getMilliseconds()).padStart(3, '0')}`
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
function getResponseMessage(payload: TamResponse, fallback: string) {
|
|
129
|
-
return payload.head?.retMsg || fallback
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
function normalizeResponseBody(
|
|
133
|
-
source: Record<string, unknown>,
|
|
134
|
-
): RmbPositionEstimationResponseBody {
|
|
135
|
-
const result = {
|
|
136
|
-
fileName: String(source.fileName ?? ''),
|
|
137
|
-
} as RmbPositionEstimationResponseBody
|
|
138
|
-
|
|
139
|
-
rmbPositionAmountFields.forEach((field) => {
|
|
140
|
-
if (!Object.hasOwn(source, field)) {
|
|
141
|
-
throw new Error(`人民币头寸匡算接口缺少返回字段:${field}`)
|
|
142
|
-
}
|
|
143
|
-
const value = String(source[field] ?? '').trim()
|
|
144
|
-
if (!/^-?(?:\d+(?:\.\d+)?|\.\d+)$/.test(value)) {
|
|
145
|
-
throw new Error(`人民币头寸匡算接口金额字段格式不正确:${field}`)
|
|
146
|
-
}
|
|
147
|
-
result[field] = value
|
|
148
|
-
})
|
|
149
|
-
|
|
150
|
-
return result
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
export async function requestRmbPositionEstimation(
|
|
154
|
-
body: RmbPositionEstimationRequestBody,
|
|
155
|
-
options: RequestOptions = {},
|
|
156
|
-
) {
|
|
157
|
-
const now = new Date()
|
|
158
|
-
const request = {
|
|
159
|
-
appHead: {
|
|
160
|
-
fileName: '',
|
|
161
|
-
opType: '',
|
|
162
|
-
ip: tamClientIp,
|
|
163
|
-
},
|
|
164
|
-
head: {
|
|
165
|
-
branchId: tamBranchId,
|
|
166
|
-
consumerSeqNo: createConsumerSeqNo(now),
|
|
167
|
-
consumerId: 'TAM001',
|
|
168
|
-
tranCode: TRAN_CODE,
|
|
169
|
-
tranDate: compactDate(now),
|
|
170
|
-
tranTimestamp: compactTime(now),
|
|
171
|
-
pageSize: '10',
|
|
172
|
-
pageIndex: '1',
|
|
173
|
-
traceId: '',
|
|
174
|
-
spanId: '',
|
|
175
|
-
userId: tamUserId,
|
|
176
|
-
versionId: '0001',
|
|
177
|
-
verifyUserId: '',
|
|
178
|
-
adminUserId: '',
|
|
179
|
-
apprUserId: '',
|
|
180
|
-
areaCode: '0000',
|
|
181
|
-
digitalSign: '',
|
|
182
|
-
fileFlag: 'N',
|
|
183
|
-
filePath: '',
|
|
184
|
-
isBatch: false,
|
|
185
|
-
},
|
|
186
|
-
body,
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
const response = await fetch(`${apiBaseUrl}${TRAN_CODE}`, {
|
|
190
|
-
method: 'POST',
|
|
191
|
-
headers: { 'Content-Type': 'application/json' },
|
|
192
|
-
body: JSON.stringify(request),
|
|
193
|
-
signal: options.signal,
|
|
194
|
-
})
|
|
195
|
-
|
|
196
|
-
let payload: TamResponse
|
|
197
|
-
try {
|
|
198
|
-
payload = await response.json() as TamResponse
|
|
199
|
-
} catch {
|
|
200
|
-
throw new Error(`人民币头寸匡算接口返回的不是有效 JSON(HTTP ${response.status})`)
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
if (!payload || typeof payload !== 'object' || Array.isArray(payload)) {
|
|
204
|
-
throw new Error('人民币头寸匡算接口返回结构不正确')
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
if (!response.ok) {
|
|
208
|
-
throw new Error(getResponseMessage(payload, `人民币头寸匡算请求失败(HTTP ${response.status})`))
|
|
209
|
-
}
|
|
210
|
-
if (payload.head?.retStatus !== 'S' || payload.head?.retCode !== '00000') {
|
|
211
|
-
throw new Error(getResponseMessage(payload, '人民币头寸匡算失败'))
|
|
212
|
-
}
|
|
213
|
-
if (!payload.body || typeof payload.body !== 'object' || Array.isArray(payload.body)) {
|
|
214
|
-
throw new Error('人民币头寸匡算接口返回结构不正确')
|
|
215
|
-
}
|
|
216
|
-
|
|
217
|
-
return {
|
|
218
|
-
body: normalizeResponseBody(payload.body),
|
|
219
|
-
message: getResponseMessage(payload, '交易成功'),
|
|
220
|
-
}
|
|
221
|
-
}
|
|
1
|
+
import baseHttpClient, {
|
|
2
|
+
type HttpRequestOptions,
|
|
3
|
+
type TamResponse,
|
|
4
|
+
} from '@/utils/baseHttpClient'
|
|
5
|
+
import type {
|
|
6
|
+
RmbPositionEstimationRequestBody,
|
|
7
|
+
RmbPositionHistoryRequestBody,
|
|
8
|
+
} from './types'
|
|
9
|
+
|
|
10
|
+
const API = {
|
|
11
|
+
// 匡算查询
|
|
12
|
+
queryAPI: (params: RmbPositionEstimationRequestBody, options?: HttpRequestOptions) => {
|
|
13
|
+
return baseHttpClient.post<TamResponse<Record<string, unknown>>>(
|
|
14
|
+
'/TAM/0001/140103006',
|
|
15
|
+
params,
|
|
16
|
+
options,
|
|
17
|
+
)
|
|
18
|
+
},
|
|
19
|
+
// 查询历史填入数据
|
|
20
|
+
historyAPI: (params: RmbPositionHistoryRequestBody, options?: HttpRequestOptions) => {
|
|
21
|
+
return baseHttpClient.post<TamResponse<Record<string, unknown>>>(
|
|
22
|
+
'/TAM/0001/140103005',
|
|
23
|
+
params,
|
|
24
|
+
options,
|
|
25
|
+
)
|
|
26
|
+
},
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export default API
|
|
@@ -1,14 +1,18 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
2
|
import { computed, onBeforeUnmount, reactive, ref } from 'vue'
|
|
3
|
-
import { Search } from '@element-plus/icons-vue'
|
|
3
|
+
import { Download, Search } from '@element-plus/icons-vue'
|
|
4
4
|
import { ElMessage } from 'element-plus'
|
|
5
|
+
import API from './api'
|
|
5
6
|
import {
|
|
6
|
-
|
|
7
|
+
rmbPositionAmountFields,
|
|
8
|
+
rmbPositionHistoryAmountFields,
|
|
9
|
+
rmbPositionHistoryRemarkFields,
|
|
7
10
|
type ProtocolAmount,
|
|
8
11
|
type RmbPositionAmountField,
|
|
9
12
|
type RmbPositionEstimationRequestBody,
|
|
10
13
|
type RmbPositionEstimationResponseBody,
|
|
11
|
-
|
|
14
|
+
type RmbPositionHistoryResponseBody,
|
|
15
|
+
} from './types'
|
|
12
16
|
|
|
13
17
|
const YUAN_PER_YI = 100_000_000n
|
|
14
18
|
const YUAN_PER_YI_CENT = 1_000_000n
|
|
@@ -62,6 +66,48 @@ type LinkedCell = {
|
|
|
62
66
|
field: RmbPositionAmountField
|
|
63
67
|
}
|
|
64
68
|
|
|
69
|
+
function normalizeEstimationResponseBody(
|
|
70
|
+
source: Record<string, unknown>,
|
|
71
|
+
): RmbPositionEstimationResponseBody {
|
|
72
|
+
const normalized = {
|
|
73
|
+
fileName: String(source.fileName ?? ''),
|
|
74
|
+
} as RmbPositionEstimationResponseBody
|
|
75
|
+
|
|
76
|
+
rmbPositionAmountFields.forEach((field) => {
|
|
77
|
+
if (!Object.hasOwn(source, field)) {
|
|
78
|
+
throw new Error(`人民币头寸匡算接口缺少返回字段:${field}`)
|
|
79
|
+
}
|
|
80
|
+
const value = String(source[field] ?? '').trim()
|
|
81
|
+
if (!/^-?(?:\d+(?:\.\d+)?|\.\d+)$/.test(value)) {
|
|
82
|
+
throw new Error(`人民币头寸匡算接口金额字段格式不正确:${field}`)
|
|
83
|
+
}
|
|
84
|
+
normalized[field] = value
|
|
85
|
+
})
|
|
86
|
+
|
|
87
|
+
return normalized
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
function normalizeHistoryResponseBody(
|
|
91
|
+
source: Record<string, unknown>,
|
|
92
|
+
): RmbPositionHistoryResponseBody {
|
|
93
|
+
const normalized: RmbPositionHistoryResponseBody = {}
|
|
94
|
+
|
|
95
|
+
rmbPositionHistoryAmountFields.forEach((field) => {
|
|
96
|
+
if (!Object.hasOwn(source, field)) return
|
|
97
|
+
const value = String(source[field] ?? '').trim()
|
|
98
|
+
if (!/^-?(?:\d+(?:\.\d+)?|\.\d+)$/.test(value)) {
|
|
99
|
+
throw new Error(`人民币头寸历史查询接口金额字段格式不正确:${field}`)
|
|
100
|
+
}
|
|
101
|
+
normalized[field] = value
|
|
102
|
+
})
|
|
103
|
+
|
|
104
|
+
rmbPositionHistoryRemarkFields.forEach((field) => {
|
|
105
|
+
if (Object.hasOwn(source, field)) normalized[field] = String(source[field] ?? '')
|
|
106
|
+
})
|
|
107
|
+
|
|
108
|
+
return normalized
|
|
109
|
+
}
|
|
110
|
+
|
|
65
111
|
function pad(value: number) {
|
|
66
112
|
return String(value).padStart(2, '0')
|
|
67
113
|
}
|
|
@@ -258,6 +304,7 @@ const form = reactive<FormState>({
|
|
|
258
304
|
|
|
259
305
|
const result = ref<RmbPositionEstimationResponseBody | null>(null)
|
|
260
306
|
const loading = ref(false)
|
|
307
|
+
const loadingText = ref('正在进行头寸匡算…')
|
|
261
308
|
let requestController: AbortController | null = null
|
|
262
309
|
|
|
263
310
|
function stripGrouping(value: string) {
|
|
@@ -388,7 +435,12 @@ function clearResult() {
|
|
|
388
435
|
|
|
389
436
|
function normalizeAmountField(key: ManualAmountKey) {
|
|
390
437
|
const original = form[key]
|
|
391
|
-
if (isValidYiAmount(original))
|
|
438
|
+
if (!isValidYiAmount(original)) return
|
|
439
|
+
form[key] = formatYuanAsYi(yiTextToYuan(original))
|
|
440
|
+
}
|
|
441
|
+
|
|
442
|
+
function activateAmountField(key: ManualAmountKey) {
|
|
443
|
+
form[key] = stripGrouping(form[key])
|
|
392
444
|
}
|
|
393
445
|
|
|
394
446
|
function resetManualInputs() {
|
|
@@ -400,12 +452,50 @@ function resetManualInputs() {
|
|
|
400
452
|
})
|
|
401
453
|
}
|
|
402
454
|
|
|
403
|
-
function
|
|
455
|
+
function fillHistoryInputs(history: RmbPositionHistoryResponseBody) {
|
|
456
|
+
manualAmountKeys.forEach((key) => {
|
|
457
|
+
const value = history[key]
|
|
458
|
+
form[key] = value === undefined || value.trim() === ''
|
|
459
|
+
? ''
|
|
460
|
+
: formatYuanAsYi(value)
|
|
461
|
+
})
|
|
462
|
+
remarkKeys.forEach((key) => {
|
|
463
|
+
form[key] = history[key] ?? ''
|
|
464
|
+
})
|
|
465
|
+
}
|
|
466
|
+
|
|
467
|
+
async function handleDateChange() {
|
|
404
468
|
requestController?.abort()
|
|
405
|
-
requestController = null
|
|
406
|
-
loading.value = false
|
|
407
469
|
resetManualInputs()
|
|
408
470
|
clearResult()
|
|
471
|
+
|
|
472
|
+
if (!form.tranDate) {
|
|
473
|
+
requestController = null
|
|
474
|
+
loading.value = false
|
|
475
|
+
return
|
|
476
|
+
}
|
|
477
|
+
|
|
478
|
+
const controller = new AbortController()
|
|
479
|
+
requestController = controller
|
|
480
|
+
loadingText.value = '正在查询历史数据…'
|
|
481
|
+
loading.value = true
|
|
482
|
+
|
|
483
|
+
try {
|
|
484
|
+
const response = await API.historyAPI({ tranDate: form.tranDate }, {
|
|
485
|
+
signal: controller.signal,
|
|
486
|
+
})
|
|
487
|
+
if (controller.signal.aborted || requestController !== controller) return
|
|
488
|
+
fillHistoryInputs(normalizeHistoryResponseBody(response.body))
|
|
489
|
+
} catch (error) {
|
|
490
|
+
if (!isAbortError(error)) {
|
|
491
|
+
ElMessage.error(error instanceof Error ? error.message : '人民币头寸历史查询失败')
|
|
492
|
+
}
|
|
493
|
+
} finally {
|
|
494
|
+
if (requestController === controller) {
|
|
495
|
+
loading.value = false
|
|
496
|
+
requestController = null
|
|
497
|
+
}
|
|
498
|
+
}
|
|
409
499
|
}
|
|
410
500
|
|
|
411
501
|
function openLink(field: RmbPositionAmountField) {
|
|
@@ -465,8 +555,8 @@ function validateForm() {
|
|
|
465
555
|
return true
|
|
466
556
|
}
|
|
467
557
|
|
|
468
|
-
|
|
469
|
-
|
|
558
|
+
const queryParams = computed<RmbPositionEstimationRequestBody>(() => (
|
|
559
|
+
{
|
|
470
560
|
overAmt: toProtocolAmount('overAmt'),
|
|
471
561
|
tranDate: form.tranDate,
|
|
472
562
|
fzAmtIn: toProtocolAmount('fzAmtIn'),
|
|
@@ -482,6 +572,15 @@ function buildRequestBody(): RmbPositionEstimationRequestBody {
|
|
|
482
572
|
ysAmtOut: toProtocolAmount('ysAmtOut'),
|
|
483
573
|
ysAmtRmk: form.ysAmtRmk.trim(),
|
|
484
574
|
}
|
|
575
|
+
))
|
|
576
|
+
|
|
577
|
+
function exportEstimation() {
|
|
578
|
+
if (!validateForm()) return
|
|
579
|
+
|
|
580
|
+
console.log('人民币头寸匡算导出参数:', {
|
|
581
|
+
...queryParams.value,
|
|
582
|
+
opType: 'export',
|
|
583
|
+
})
|
|
485
584
|
}
|
|
486
585
|
|
|
487
586
|
function isAbortError(error: unknown) {
|
|
@@ -494,15 +593,16 @@ async function queryEstimation() {
|
|
|
494
593
|
requestController?.abort()
|
|
495
594
|
const controller = new AbortController()
|
|
496
595
|
requestController = controller
|
|
596
|
+
loadingText.value = '正在进行头寸匡算…'
|
|
497
597
|
loading.value = true
|
|
498
598
|
clearResult()
|
|
499
599
|
|
|
500
600
|
try {
|
|
501
|
-
const response = await
|
|
601
|
+
const response = await API.queryAPI(queryParams.value, {
|
|
502
602
|
signal: controller.signal,
|
|
503
603
|
})
|
|
504
604
|
if (controller.signal.aborted || requestController !== controller) return
|
|
505
|
-
result.value = response.body
|
|
605
|
+
result.value = normalizeEstimationResponseBody(response.body)
|
|
506
606
|
} catch (error) {
|
|
507
607
|
if (!isAbortError(error)) {
|
|
508
608
|
ElMessage.error(error instanceof Error ? error.message : '人民币头寸匡算失败')
|
|
@@ -550,6 +650,14 @@ onBeforeUnmount(() => {
|
|
|
550
650
|
>
|
|
551
651
|
查询
|
|
552
652
|
</el-button>
|
|
653
|
+
<el-button
|
|
654
|
+
native-type="button"
|
|
655
|
+
:icon="Download"
|
|
656
|
+
:disabled="loading"
|
|
657
|
+
@click="exportEstimation"
|
|
658
|
+
>
|
|
659
|
+
导出
|
|
660
|
+
</el-button>
|
|
553
661
|
</el-form-item>
|
|
554
662
|
</el-form>
|
|
555
663
|
</div>
|
|
@@ -557,7 +665,7 @@ onBeforeUnmount(() => {
|
|
|
557
665
|
<div
|
|
558
666
|
id="mainDiv"
|
|
559
667
|
v-loading="loading"
|
|
560
|
-
element-loading-text="
|
|
668
|
+
:element-loading-text="loadingText"
|
|
561
669
|
>
|
|
562
670
|
<table class="tab">
|
|
563
671
|
<colgroup>
|
|
@@ -580,6 +688,7 @@ onBeforeUnmount(() => {
|
|
|
580
688
|
:disabled="loading"
|
|
581
689
|
aria-label="昨日超额备付余额,单位亿元"
|
|
582
690
|
@input="clearResult"
|
|
691
|
+
@focus="activateAmountField('overAmt')"
|
|
583
692
|
@blur="normalizeAmountField('overAmt')"
|
|
584
693
|
/>
|
|
585
694
|
</td>
|
|
@@ -643,6 +752,7 @@ onBeforeUnmount(() => {
|
|
|
643
752
|
:disabled="loading"
|
|
644
753
|
:aria-label="row.label + '收入,单位亿元'"
|
|
645
754
|
@input="clearResult"
|
|
755
|
+
@focus="activateAmountField(row.incomeKey)"
|
|
646
756
|
@blur="normalizeAmountField(row.incomeKey)"
|
|
647
757
|
/>
|
|
648
758
|
</td>
|
|
@@ -655,6 +765,7 @@ onBeforeUnmount(() => {
|
|
|
655
765
|
:disabled="loading"
|
|
656
766
|
:aria-label="row.label + '支出,单位亿元'"
|
|
657
767
|
@input="clearResult"
|
|
768
|
+
@focus="activateAmountField(row.expenseKey)"
|
|
658
769
|
@blur="normalizeAmountField(row.expenseKey)"
|
|
659
770
|
/>
|
|
660
771
|
</td>
|
|
@@ -725,6 +836,7 @@ onBeforeUnmount(() => {
|
|
|
725
836
|
:disabled="loading"
|
|
726
837
|
aria-label="今日资金交易预计收入,单位亿元"
|
|
727
838
|
@input="clearResult"
|
|
839
|
+
@focus="activateAmountField('ysAmtIn')"
|
|
728
840
|
@blur="normalizeAmountField('ysAmtIn')"
|
|
729
841
|
/>
|
|
730
842
|
</td>
|
|
@@ -737,6 +849,7 @@ onBeforeUnmount(() => {
|
|
|
737
849
|
:disabled="loading"
|
|
738
850
|
aria-label="今日资金交易预计支出,单位亿元"
|
|
739
851
|
@input="clearResult"
|
|
852
|
+
@focus="activateAmountField('ysAmtOut')"
|
|
740
853
|
@blur="normalizeAmountField('ysAmtOut')"
|
|
741
854
|
/>
|
|
742
855
|
</td>
|
|
@@ -948,20 +1061,41 @@ onBeforeUnmount(() => {
|
|
|
948
1061
|
min-height: 18px;
|
|
949
1062
|
padding: 0;
|
|
950
1063
|
border-radius: 4px;
|
|
951
|
-
background:
|
|
952
|
-
box-shadow:
|
|
1064
|
+
background: #fff;
|
|
1065
|
+
box-shadow:
|
|
1066
|
+
0 0 0 1px rgba(59, 130, 246, 0.78),
|
|
1067
|
+
0 0 7px rgba(56, 189, 248, 0.42),
|
|
1068
|
+
inset 0 0 5px rgba(147, 197, 253, 0.12);
|
|
1069
|
+
transition: box-shadow 180ms ease, background-color 180ms ease;
|
|
1070
|
+
}
|
|
1071
|
+
|
|
1072
|
+
.intStyle :deep(.el-input__wrapper:hover) {
|
|
1073
|
+
box-shadow:
|
|
1074
|
+
0 0 0 1px #38bdf8,
|
|
1075
|
+
0 0 10px rgba(14, 165, 233, 0.58),
|
|
1076
|
+
inset 0 0 6px rgba(125, 211, 252, 0.18) !important;
|
|
953
1077
|
}
|
|
954
1078
|
|
|
955
|
-
.intStyle :deep(.el-input__wrapper:hover),
|
|
956
1079
|
.intStyle :deep(.el-input__wrapper.is-focus) {
|
|
957
|
-
|
|
1080
|
+
background: #fafdff;
|
|
1081
|
+
box-shadow:
|
|
1082
|
+
0 0 0 1px #2563eb,
|
|
1083
|
+
0 0 12px rgba(37, 99, 235, 0.68),
|
|
1084
|
+
0 0 20px rgba(56, 189, 248, 0.24),
|
|
1085
|
+
inset 0 0 6px rgba(96, 165, 250, 0.16) !important;
|
|
1086
|
+
}
|
|
1087
|
+
|
|
1088
|
+
.intStyle.is-disabled :deep(.el-input__wrapper) {
|
|
1089
|
+
box-shadow:
|
|
1090
|
+
0 0 0 1px rgba(148, 163, 184, 0.52),
|
|
1091
|
+
0 0 4px rgba(148, 163, 184, 0.2);
|
|
958
1092
|
}
|
|
959
1093
|
|
|
960
1094
|
.intStyle :deep(.el-input__inner) {
|
|
961
1095
|
width: 100%;
|
|
962
1096
|
height: 18px;
|
|
963
1097
|
padding: 0 5px;
|
|
964
|
-
border:
|
|
1098
|
+
border: 0;
|
|
965
1099
|
border-radius: 4px;
|
|
966
1100
|
color: #111827;
|
|
967
1101
|
font-size: 11px;
|
|
@@ -973,8 +1107,7 @@ onBeforeUnmount(() => {
|
|
|
973
1107
|
}
|
|
974
1108
|
|
|
975
1109
|
.intStyle :deep(.el-input__inner:focus) {
|
|
976
|
-
|
|
977
|
-
box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.12);
|
|
1110
|
+
box-shadow: none;
|
|
978
1111
|
}
|
|
979
1112
|
|
|
980
1113
|
.remark-input :deep(.el-input__inner) {
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
export const rmbPositionAmountFields = [
|
|
2
|
+
'hgPredAmtIn',
|
|
3
|
+
'hgPredAmtOut',
|
|
4
|
+
'hgPredAmtNet',
|
|
5
|
+
'hgUnverifyAmtIn',
|
|
6
|
+
'hgUnverifyAmtOut',
|
|
7
|
+
'hgUnverifyAmtNet',
|
|
8
|
+
'zqPredAmtIn',
|
|
9
|
+
'zqPredAmtOut',
|
|
10
|
+
'zqPredAmtNet',
|
|
11
|
+
'zqUnverifyAmtIn',
|
|
12
|
+
'zqUnverifyAmtOut',
|
|
13
|
+
'zqUnverifyAmtNet',
|
|
14
|
+
'pjPredAmtIn',
|
|
15
|
+
'pjPredAmtOut',
|
|
16
|
+
'pjPredAmtNet',
|
|
17
|
+
'pjUnverifyAmtIn',
|
|
18
|
+
'pjUnverifyAmtOut',
|
|
19
|
+
'pjUnverifyAmtNet',
|
|
20
|
+
'tgPredAmtIn',
|
|
21
|
+
'tgPredAmtOut',
|
|
22
|
+
'tgPredAmtNet',
|
|
23
|
+
'tgUnverifyAmtIn',
|
|
24
|
+
'tgUnverifyAmtOut',
|
|
25
|
+
'tgUnverifyAmtNet',
|
|
26
|
+
'tyPredAmtIn',
|
|
27
|
+
'tyPredAmtOut',
|
|
28
|
+
'tyPredAmtNet',
|
|
29
|
+
'tyUnverifyAmtIn',
|
|
30
|
+
'tyUnverifyAmtOut',
|
|
31
|
+
'tyUnverifyAmtNet',
|
|
32
|
+
'fzhPredAmtIn',
|
|
33
|
+
'fzhPredAmtOut',
|
|
34
|
+
'fzhPredAmtNet',
|
|
35
|
+
'fzhUnverifyAmtIn',
|
|
36
|
+
'fzhUnverifyAmtOut',
|
|
37
|
+
'fzhUnverifyAmtNet',
|
|
38
|
+
'lcPredAmtIn',
|
|
39
|
+
'lcPredAmtOut',
|
|
40
|
+
'lcPredAmtNet',
|
|
41
|
+
'lcUnverifyAmtIn',
|
|
42
|
+
'lcUnverifyAmtOut',
|
|
43
|
+
'lcUnverifyAmtNet',
|
|
44
|
+
'qtPredAmtIn',
|
|
45
|
+
'qtPredAmtOut',
|
|
46
|
+
'qtPredAmtNet',
|
|
47
|
+
'qtUnverifyAmtIn',
|
|
48
|
+
'qtUnverifyAmtOut',
|
|
49
|
+
'qtUnverifyAmtNet',
|
|
50
|
+
'xjAmtIn',
|
|
51
|
+
'xjAmtOut',
|
|
52
|
+
'xjAmtNet',
|
|
53
|
+
'unVerifyAmtIn1',
|
|
54
|
+
'unVerifyAmtOut1',
|
|
55
|
+
'unVerifyAmtNet1',
|
|
56
|
+
'unVerifyAmtIn',
|
|
57
|
+
'unVerifyAmtOut',
|
|
58
|
+
'unVerifyAmtNet',
|
|
59
|
+
'zjPredAmtIn',
|
|
60
|
+
'zjPredAmtOut',
|
|
61
|
+
'zjPredAmtNet',
|
|
62
|
+
'zjUnverifyAmtIn',
|
|
63
|
+
'zjUnverifyAmtOut',
|
|
64
|
+
'zjUnverifyAmtNet',
|
|
65
|
+
] as const
|
|
66
|
+
|
|
67
|
+
export type RmbPositionAmountField = typeof rmbPositionAmountFields[number]
|
|
68
|
+
export type ProtocolAmount = number | '0'
|
|
69
|
+
|
|
70
|
+
export type RmbPositionEstimationRequestBody = {
|
|
71
|
+
overAmt: ProtocolAmount
|
|
72
|
+
tranDate: string
|
|
73
|
+
fzAmtIn: ProtocolAmount
|
|
74
|
+
fzAmtOut: ProtocolAmount
|
|
75
|
+
fzAmtRmk: string
|
|
76
|
+
bepsAmtIn: ProtocolAmount
|
|
77
|
+
bepsAmtOut: ProtocolAmount
|
|
78
|
+
bepsAmtRmk: string
|
|
79
|
+
othAmtIn: ProtocolAmount
|
|
80
|
+
othAmtOut: ProtocolAmount
|
|
81
|
+
othAmtRmk: string
|
|
82
|
+
ysAmtIn: ProtocolAmount
|
|
83
|
+
ysAmtOut: ProtocolAmount
|
|
84
|
+
ysAmtRmk: string
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
export type RmbPositionEstimationResponseBody = {
|
|
88
|
+
fileName: string
|
|
89
|
+
} & Record<RmbPositionAmountField, string>
|
|
90
|
+
|
|
91
|
+
export const rmbPositionHistoryAmountFields = [
|
|
92
|
+
'overAmt',
|
|
93
|
+
'fzAmtIn',
|
|
94
|
+
'fzAmtOut',
|
|
95
|
+
'bepsAmtIn',
|
|
96
|
+
'bepsAmtOut',
|
|
97
|
+
'othAmtIn',
|
|
98
|
+
'othAmtOut',
|
|
99
|
+
'ysAmtIn',
|
|
100
|
+
'ysAmtOut',
|
|
101
|
+
] as const
|
|
102
|
+
|
|
103
|
+
export const rmbPositionHistoryRemarkFields = [
|
|
104
|
+
'fzAmtRmk',
|
|
105
|
+
'bepsAmtRmk',
|
|
106
|
+
'othAmtRmk',
|
|
107
|
+
'ysAmtRmk',
|
|
108
|
+
] as const
|
|
109
|
+
|
|
110
|
+
type RmbPositionHistoryAmountField = typeof rmbPositionHistoryAmountFields[number]
|
|
111
|
+
type RmbPositionHistoryRemarkField = typeof rmbPositionHistoryRemarkFields[number]
|
|
112
|
+
|
|
113
|
+
export type RmbPositionHistoryRequestBody = {
|
|
114
|
+
tranDate: string
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
export type RmbPositionHistoryResponseBody = Partial<Record<
|
|
118
|
+
RmbPositionHistoryAmountField | RmbPositionHistoryRemarkField,
|
|
119
|
+
string
|
|
120
|
+
>>
|