verce-vue-test 0.0.75 → 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/env.d.ts CHANGED
@@ -1,5 +1,19 @@
1
1
  /// <reference types="vite/client" />
2
2
 
3
+ declare global {
4
+ interface ImportMetaEnv {
5
+ readonly VITE_API_BASE_URL?: string
6
+ readonly VITE_SYSTEM_WORK_DATE?: string
7
+ readonly VITE_TAM_BRANCH_ID?: string
8
+ readonly VITE_TAM_USER_ID?: string
9
+ readonly VITE_TAM_CLIENT_IP?: string
10
+ }
11
+
12
+ interface ImportMeta {
13
+ readonly env: ImportMetaEnv
14
+ }
15
+ }
16
+
3
17
  declare module 'vue' {
4
18
  export interface GlobalComponents {
5
19
  ElButtonPro: typeof import('./src/components/ElButtonPro.vue')['default']
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "verce-vue-test",
3
- "version": "0.0.75",
3
+ "version": "0.0.77",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "scripts": {
package/src/App.vue CHANGED
@@ -43,6 +43,7 @@ const searchableMenus: MenuSearchItem[] = [
43
43
  { value: '外币头寸预报', path: '/foreign-currency-position-forecast' },
44
44
  { value: '头寸预报执行', path: '/position-forecast-execution' },
45
45
  { value: '预报信息', path: '/forecast-info' },
46
+ { value: '人民币头寸匡算', path: '/rmb-position-estimation' },
46
47
  { value: '总行管理员首页', path: '/executive-management' },
47
48
  { value: '资金驾驶舱', path: '/fund-cockpit' },
48
49
  { value: '通知公告', path: '/notice-announcement' },
@@ -143,6 +144,10 @@ function toggleCollapse() {
143
144
  <el-icon><DataLine /></el-icon>
144
145
  <span>预报信息</span>
145
146
  </el-menu-item>
147
+ <el-menu-item index="/rmb-position-estimation">
148
+ <el-icon><DataLine /></el-icon>
149
+ <span>人民币头寸匡算</span>
150
+ </el-menu-item>
146
151
  <el-menu-item index="/executive-management">
147
152
  <el-icon><TrendCharts /></el-icon>
148
153
  <span>总行管理员首页</span>
@@ -73,7 +73,7 @@ const router = createRouter({
73
73
  {
74
74
  path: '/foreign-currency-position-forecast',
75
75
  name: 'foreignCurrencyPositionForecast',
76
- component: () => import('../views/ForeignCurrencyPositionForecastView.vue'),
76
+ component: () => import('../views/foreign-currency-position-forecast/index.vue'),
77
77
  },
78
78
  {
79
79
  path: '/position-forecast-execution',
@@ -85,6 +85,11 @@ const router = createRouter({
85
85
  name: 'forecastInfo',
86
86
  component: () => import('../views/ForecastInfo/RmbPositionSettlement.vue'),
87
87
  },
88
+ {
89
+ path: '/rmb-position-estimation',
90
+ name: 'rmbPositionEstimation',
91
+ component: () => import('../views/rmb-position-estimation/index.vue'),
92
+ },
88
93
  {
89
94
  path: '/executive-management',
90
95
  name: 'executiveManagement',
@@ -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
@@ -639,7 +639,7 @@ async function queryForecastInfoList(
639
639
 
640
640
  // TODO: 在这里对接预报信息列表查询接口。
641
641
  // 示例:
642
- // return request.post<ForecastInfoListResponse>('/forecast/info/list', {
642
+ // return request.post<ForecastInfoListResponse>('/oms/forecast/info/list', {
643
643
  // ...params,
644
644
  // pageNum: pageParams.page,
645
645
  // pageSize: pageParams.pageSize,
@@ -666,7 +666,7 @@ async function queryFlowInfoList(
666
666
 
667
667
  // TODO: 在这里对接流水信息列表查询接口。
668
668
  // 示例:
669
- // return request.post<FlowInfoListResponse>('/flow/info/list', {
669
+ // return request.post<FlowInfoListResponse>('/oms/flow/info/list', {
670
670
  // ...params,
671
671
  // pageNum: pageParams.page,
672
672
  // pageSize: pageParams.pageSize,
@@ -0,0 +1,448 @@
1
+ import {
2
+ formatDate,
3
+ mockCurrentUser,
4
+ type BusinessType,
5
+ type ClientType,
6
+ type ForecastStatus,
7
+ type ForecastType,
8
+ type ForecastWay,
9
+ type ForeignExchangeType,
10
+ type ForeignPositionForecast,
11
+ type PaymentDirection,
12
+ type VerifyStatus,
13
+ } from './mock'
14
+ import { organizationOptions } from './options'
15
+ import type { ForecastEditorValue } from './editor'
16
+
17
+ const QUERY_TRAN_CODE = '/TAM/0001/140201001'
18
+ const AUTHORIZATION_TRAN_CODE = '/TAM/0001/120201006'
19
+ const apiBaseUrl = String(import.meta.env.VITE_API_BASE_URL || 'http://localhost:3011/oms').replace(/\/+$/, '')
20
+
21
+ export type ForeignPositionForecastQuery = {
22
+ valueDate: string
23
+ payDirection: '' | PaymentDirection
24
+ forecastStatuses: ForecastStatus[]
25
+ foreignExchangeType: '' | ForeignExchangeType
26
+ forecastWay: '' | ForecastWay
27
+ verifyStatuses: VerifyStatus[]
28
+ organizationName: string
29
+ clientName: string
30
+ businessType: '' | BusinessType
31
+ currencies: string[]
32
+ authirization: '' | '1' | '0'
33
+ ftuFilter: '' | '1' | '0'
34
+ minAmount: number | null
35
+ maxAmount: number | null
36
+ }
37
+
38
+ export type ForeignPositionForecastSort = {
39
+ amtOrder: '' | '1' | '2'
40
+ predOrder: '' | '1' | '2'
41
+ timeOrder: '' | '1' | '2'
42
+ }
43
+
44
+ type TamResultInfo = {
45
+ predRefNo?: string
46
+ predWay?: string
47
+ predStatus?: string
48
+ predType?: string
49
+ groundBranch?: string
50
+ payDirec?: string
51
+ bankAcct?: string
52
+ ccy?: string
53
+ predAmt?: string
54
+ tranDate?: string
55
+ verifyStatus?: string
56
+ verifyAmt?: string
57
+ tranType?: string
58
+ clientName?: string
59
+ clientAcct?: string
60
+ competName?: string
61
+ competAcct?: string
62
+ rcvBank?: string
63
+ rcvBankSc?: string
64
+ originalForeign?: string
65
+ predDate?: string
66
+ updateTime?: string
67
+ competAcctSc?: string
68
+ docbusinessno?: string
69
+ midBankSc?: string
70
+ predName?: string
71
+ predCode?: string
72
+ predDept?: string
73
+ phoneNo?: string
74
+ authorization?: string
75
+ remark?: string
76
+ }
77
+
78
+ type TamResponse = {
79
+ head?: {
80
+ retStatus?: string
81
+ retCode?: string
82
+ retMsg?: string
83
+ }
84
+ body?: {
85
+ totalPage?: string | number
86
+ totalCount?: string | number
87
+ resultInfos?: TamResultInfo[]
88
+ }
89
+ }
90
+
91
+ type ApiErrorResponse = {
92
+ error?: {
93
+ message?: string
94
+ }
95
+ }
96
+
97
+ type ForeignPositionForecastOperationResponse = {
98
+ success: boolean
99
+ message: string
100
+ resultList: ForeignPositionForecast[]
101
+ }
102
+
103
+ export type ForeignPositionForecastQueryResult = {
104
+ resultList: ForeignPositionForecast[]
105
+ totalCount: number
106
+ totalPage: number
107
+ }
108
+
109
+ export type ForeignPositionClient = {
110
+ id: string
111
+ name: string
112
+ account: string
113
+ }
114
+
115
+ function pad(value: number) {
116
+ return String(value).padStart(2, '0')
117
+ }
118
+
119
+ function compactDate(date: Date) {
120
+ return formatDate(date).replaceAll('-', '')
121
+ }
122
+
123
+ function compactTime(date: Date) {
124
+ return `${pad(date.getHours())}${pad(date.getMinutes())}${pad(date.getSeconds())}`
125
+ }
126
+
127
+ function createConsumerSeqNo(date: Date) {
128
+ return `${mockCurrentUser.userCode}${compactDate(date)}${compactTime(date)}${String(date.getMilliseconds()).padStart(3, '0')}`
129
+ }
130
+
131
+ function toProtocolStatusList(values: string[], prefix: 'PS' | 'VS') {
132
+ return values
133
+ .map((value) => value.replace(prefix, ''))
134
+ .map((value) => String(Number(value)))
135
+ .join(',')
136
+ }
137
+
138
+ function toNumber(value: unknown) {
139
+ const number = Number(String(value ?? '').replaceAll(',', ''))
140
+ return Number.isFinite(number) ? number : 0
141
+ }
142
+
143
+ function toForecastWay(value: string | undefined): ForecastWay {
144
+ return value === 'PW02' || value === 'PW03' ? value : 'PW01'
145
+ }
146
+
147
+ function toForecastStatus(value: string | undefined): ForecastStatus {
148
+ const number = Number(String(value || '').replace(/^PS/i, ''))
149
+ return number >= 1 && number <= 8
150
+ ? `PS${String(number).padStart(2, '0')}` as ForecastStatus
151
+ : 'PS01'
152
+ }
153
+
154
+ function toForecastType(value: string | undefined): ForecastType {
155
+ return value === 'PT02' || value === 'PT03' ? value : 'PT01'
156
+ }
157
+
158
+ function toVerifyStatus(value: string | undefined): VerifyStatus {
159
+ const number = Number(String(value || '').replace(/^VS/i, ''))
160
+ return number >= 1 && number <= 3
161
+ ? `VS${String(number).padStart(2, '0')}` as VerifyStatus
162
+ : 'VS01'
163
+ }
164
+
165
+ function toBusinessType(value: string | undefined): BusinessType {
166
+ return value === '11' || value === '12' || value === '13' ? value : '10'
167
+ }
168
+
169
+ function toForeignExchangeType(value: string | undefined): '' | ForeignExchangeType {
170
+ return value === '01' || value === '02' || value === '03' ? value : ''
171
+ }
172
+
173
+ function toFrontendRow(row: TamResultInfo): ForeignPositionForecast {
174
+ const organization = organizationOptions.find((option) => option.code === row.groundBranch)
175
+ const clientName = String(row.clientName || '')
176
+
177
+ return {
178
+ predRefNo: String(row.predRefNo || ''),
179
+ authirization: row.authorization === '1' ? '1' : '0',
180
+ filter: '',
181
+ predWay: toForecastWay(row.predWay),
182
+ predStatus: toForecastStatus(row.predStatus),
183
+ predType: toForecastType(row.predType),
184
+ groundBranch: organization?.value || String(row.groundBranch || ''),
185
+ groundBranchCode: String(row.groundBranch || organization?.code || ''),
186
+ payDirection: row.payDirec === 'O' ? 'O' : 'I',
187
+ bankAccount: String(row.bankAcct || ''),
188
+ paymentRoute: '01',
189
+ currency: String(row.ccy || ''),
190
+ predAmount: toNumber(row.predAmt),
191
+ valueDate: String(row.tranDate || '').slice(0, 10),
192
+ verifyStatus: toVerifyStatus(row.verifyStatus),
193
+ verifyAmount: toNumber(row.verifyAmt),
194
+ businessType: toBusinessType(row.tranType),
195
+ clientType: (clientName ? 'CT01' : '') as '' | ClientType,
196
+ clientId: '',
197
+ clientName,
198
+ clientAccount: String(row.clientAcct || ''),
199
+ counterpartyName: String(row.competName || ''),
200
+ counterpartyAccount: String(row.competAcct || ''),
201
+ receivingBank: String(row.rcvBank || ''),
202
+ receivingBankSwiftCode: String(row.rcvBankSc || ''),
203
+ foreignExchangeType: toForeignExchangeType(row.originalForeign),
204
+ counterpartySwiftCode: String(row.competAcctSc || ''),
205
+ documentBusinessNo: String(row.docbusinessno || ''),
206
+ intermediaryBankSwiftCode: String(row.midBankSc || ''),
207
+ purpose: '',
208
+ remark: String(row.remark || ''),
209
+ forecasterName: String(row.predName || ''),
210
+ forecasterCode: String(row.predCode || ''),
211
+ forecastDepartment: String(row.predDept || ''),
212
+ phoneNumber: String(row.phoneNo || ''),
213
+ forecastTime: String(row.predDate || ''),
214
+ approvalTime: String(row.updateTime || ''),
215
+ }
216
+ }
217
+
218
+ function getResponseMessage(payload: TamResponse, fallback: string) {
219
+ return payload.head?.retMsg || fallback
220
+ }
221
+
222
+ async function requestJson<T>(path: string, init: RequestInit = {}): Promise<T> {
223
+ const response = await fetch(`${apiBaseUrl}${path}`, {
224
+ ...init,
225
+ headers: {
226
+ 'Content-Type': 'application/json',
227
+ ...init.headers,
228
+ },
229
+ })
230
+
231
+ let payload: T | ApiErrorResponse
232
+ try {
233
+ payload = await response.json() as T | ApiErrorResponse
234
+ } catch {
235
+ throw new Error(`接口返回的不是有效 JSON(HTTP ${response.status})`)
236
+ }
237
+
238
+ if (!response.ok) {
239
+ const message = (payload as ApiErrorResponse).error?.message
240
+ throw new Error(message || `请求失败(HTTP ${response.status})`)
241
+ }
242
+
243
+ return payload as T
244
+ }
245
+
246
+ export function getForeignPositionForecast(predRefNo: string, signal?: AbortSignal) {
247
+ return requestJson<ForeignPositionForecast>(
248
+ `/foreign-position-forecasts/${encodeURIComponent(predRefNo)}`,
249
+ { signal },
250
+ )
251
+ }
252
+
253
+ export function searchForeignPositionClients(keyword: string, signal?: AbortSignal) {
254
+ return requestJson<ForeignPositionClient[]>(
255
+ `/clients/search?keyword=${encodeURIComponent(keyword.trim())}`,
256
+ { signal },
257
+ )
258
+ }
259
+
260
+ export function createForeignPositionForecast(value: ForecastEditorValue) {
261
+ return requestJson<ForeignPositionForecast>('/foreign-position-forecasts', {
262
+ method: 'POST',
263
+ body: JSON.stringify(value),
264
+ })
265
+ }
266
+
267
+ export function updateForeignPositionForecast(predRefNo: string, value: ForecastEditorValue) {
268
+ return requestJson<ForeignPositionForecast>(
269
+ `/foreign-position-forecasts/${encodeURIComponent(predRefNo)}`,
270
+ {
271
+ method: 'PATCH',
272
+ body: JSON.stringify(value),
273
+ },
274
+ )
275
+ }
276
+
277
+ export function deleteForeignPositionForecast(predRefNo: string) {
278
+ return requestJson<ForeignPositionForecast>(
279
+ `/foreign-position-forecasts/${encodeURIComponent(predRefNo)}`,
280
+ { method: 'DELETE' },
281
+ )
282
+ }
283
+
284
+ export function approveForeignPositionForecasts(predRefNos: string[], approved: boolean) {
285
+ return requestJson<ForeignPositionForecastOperationResponse>('/foreign-position-forecasts/approval', {
286
+ method: 'POST',
287
+ body: JSON.stringify({ predRefNos, approved }),
288
+ })
289
+ }
290
+
291
+ export async function updateForeignPositionForecastAuthorization(
292
+ predRefNo: string,
293
+ authorization: ForeignPositionForecast['authirization'],
294
+ pageIndex: number,
295
+ pageSize: number,
296
+ ) {
297
+ const now = new Date()
298
+ const request = {
299
+ appHead: {
300
+ fileName: '',
301
+ opType: '',
302
+ ip: '10.51.106.161',
303
+ },
304
+ head: {
305
+ branchId: mockCurrentUser.organizationCode,
306
+ consumerSeqNo: createConsumerSeqNo(now),
307
+ consumerId: 'TAM001',
308
+ tranCode: AUTHORIZATION_TRAN_CODE,
309
+ tranDate: compactDate(now),
310
+ tranTimestamp: compactTime(now),
311
+ pageSize,
312
+ pageIndex,
313
+ traceId: '',
314
+ spanId: '',
315
+ userId: mockCurrentUser.userCode,
316
+ versionId: '0001',
317
+ verifyUserId: '',
318
+ adminUserId: '',
319
+ apprUserId: '',
320
+ areaCode: '0000',
321
+ digitalSign: '',
322
+ fileFlag: 'N',
323
+ filePath: '',
324
+ isBatch: false,
325
+ },
326
+ body: {
327
+ authorization,
328
+ predRefNos: predRefNo,
329
+ },
330
+ }
331
+
332
+ const response = await fetch(`${apiBaseUrl}${AUTHORIZATION_TRAN_CODE}`, {
333
+ method: 'POST',
334
+ headers: { 'Content-Type': 'application/json' },
335
+ body: JSON.stringify(request),
336
+ })
337
+
338
+ let payload: TamResponse
339
+ try {
340
+ payload = await response.json() as TamResponse
341
+ } catch {
342
+ throw new Error('授权接口返回的不是有效 JSON')
343
+ }
344
+
345
+ const fallbackMessage = authorization === '1' ? '授权失败' : '取消授权失败'
346
+ if (!response.ok) {
347
+ throw new Error(getResponseMessage(payload, `${fallbackMessage}(HTTP ${response.status})`))
348
+ }
349
+ if (payload.head?.retStatus !== 'S' || payload.head?.retCode !== '00000') {
350
+ throw new Error(getResponseMessage(payload, fallbackMessage))
351
+ }
352
+
353
+ return getResponseMessage(payload, authorization === '1' ? '授权成功' : '取消授权成功')
354
+ }
355
+
356
+ export async function queryForeignPositionForecasts(
357
+ filters: ForeignPositionForecastQuery,
358
+ pageIndex: number,
359
+ pageSize: number,
360
+ sort: ForeignPositionForecastSort = {
361
+ amtOrder: '1',
362
+ predOrder: '',
363
+ timeOrder: '',
364
+ },
365
+ signal?: AbortSignal,
366
+ ): Promise<ForeignPositionForecastQueryResult> {
367
+ const now = new Date()
368
+ const request = {
369
+ appHead: {
370
+ fileName: '',
371
+ opType: '',
372
+ ip: '',
373
+ },
374
+ head: {
375
+ branchId: mockCurrentUser.organizationCode,
376
+ consumerSeqNo: createConsumerSeqNo(now),
377
+ consumerId: 'TAM001',
378
+ tranCode: QUERY_TRAN_CODE,
379
+ tranDate: compactDate(now),
380
+ tranTimestamp: compactTime(now),
381
+ pageSize,
382
+ pageIndex,
383
+ traceId: '',
384
+ spanId: '',
385
+ userId: mockCurrentUser.userCode,
386
+ versionId: '0001',
387
+ verifyUserId: '',
388
+ adminUserId: '',
389
+ apprUserId: '',
390
+ areaCode: '0000',
391
+ digitalSign: '',
392
+ fileFlag: 'N',
393
+ filePath: '',
394
+ isBatch: false,
395
+ },
396
+ body: {
397
+ orgName: filters.organizationName.trim(),
398
+ clientName: filters.clientName.trim(),
399
+ tranType: filters.businessType,
400
+ ccy: filters.currencies.join(','),
401
+ tranDate: filters.valueDate,
402
+ payDirec: filters.payDirection,
403
+ predStatus: toProtocolStatusList(filters.forecastStatuses, 'PS'),
404
+ originalForeign: filters.foreignExchangeType,
405
+ predWay: filters.forecastWay,
406
+ verifyStatus: toProtocolStatusList(filters.verifyStatuses, 'VS'),
407
+ startAmt: filters.minAmount === null ? '' : String(filters.minAmount),
408
+ endAmt: filters.maxAmount === null ? '' : String(filters.maxAmount),
409
+ filter: filters.ftuFilter,
410
+ authorization: filters.authirization,
411
+ amtOrder: sort.amtOrder,
412
+ predOrder: sort.predOrder,
413
+ timeOrder: sort.timeOrder,
414
+ },
415
+ }
416
+
417
+ const response = await fetch(`${apiBaseUrl}${QUERY_TRAN_CODE}`, {
418
+ method: 'POST',
419
+ headers: { 'Content-Type': 'application/json' },
420
+ body: JSON.stringify(request),
421
+ signal,
422
+ })
423
+
424
+ let payload: TamResponse
425
+ try {
426
+ payload = await response.json() as TamResponse
427
+ } catch {
428
+ throw new Error('外币头寸预报接口返回的不是有效 JSON')
429
+ }
430
+
431
+ if (!response.ok) throw new Error(getResponseMessage(payload, `查询失败(HTTP ${response.status})`))
432
+ if (payload.head?.retStatus !== 'S' || payload.head?.retCode !== '00000') {
433
+ throw new Error(getResponseMessage(payload, '外币头寸预报查询失败'))
434
+ }
435
+ const responseBody = payload.body
436
+ if (!responseBody || !Array.isArray(responseBody.resultInfos)) {
437
+ throw new Error('外币头寸预报接口返回结构不正确')
438
+ }
439
+
440
+ const totalCount = Number(responseBody.totalCount)
441
+ const totalPage = Number(responseBody.totalPage)
442
+
443
+ return {
444
+ resultList: responseBody.resultInfos.map(toFrontendRow),
445
+ totalCount: Number.isFinite(totalCount) ? totalCount : responseBody.resultInfos.length,
446
+ totalPage: Number.isFinite(totalPage) ? totalPage : 0,
447
+ }
448
+ }