verce-vue-test 0.0.123 → 0.0.125

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "verce-vue-test",
3
- "version": "0.0.123",
3
+ "version": "0.0.125",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "scripts": {
@@ -24,6 +24,7 @@
24
24
  "author": "",
25
25
  "license": "ISC",
26
26
  "dependencies": {
27
+ "dayjs": "^1.11.20",
27
28
  "echarts": "^6.1.0",
28
29
  "element-plus": "2.2.27",
29
30
  "pinia": "2.1.7",
@@ -12,13 +12,6 @@ import {
12
12
  } from './model'
13
13
  import type { ForecastEditorValue } from './editor'
14
14
 
15
- const QUERY_TRAN_CODE = '/TAM/0001/140201001'
16
- const DETAIL_TRAN_CODE = '/TAM/0001/140201004'
17
- const CREATE_TRAN_CODE = '/TAM/0001/120201001'
18
- const UPDATE_TRAN_CODE = '/TAM/0001/120201002'
19
- const AUTHORIZATION_TRAN_CODE = '/TAM/0001/120201006'
20
- const apiBaseUrl = String(import.meta.env.VITE_API_BASE_URL || 'http://localhost:3011/oms').replace(/\/+$/, '')
21
-
22
15
  export type ForeignPositionForecastQuery = {
23
16
  valueDate: string
24
17
  payDirection: '' | PaymentDirection
@@ -99,12 +92,6 @@ type TamDetailResponse = {
99
92
  body?: TamResultInfo
100
93
  }
101
94
 
102
- type ApiErrorResponse = {
103
- error?: {
104
- message?: string
105
- }
106
- }
107
-
108
95
  type ForeignPositionForecastOperationResponse = {
109
96
  success: boolean
110
97
  message: string
@@ -126,6 +113,7 @@ export type ForeignPositionForecastQueryResult = {
126
113
  totalPage: number
127
114
  }
128
115
 
116
+ /** 将前端状态码数组转换为 TAM 接口要求的逗号分隔数字。 */
129
117
  function toProtocolStatusList(values: string[], prefix: 'PS' | 'VS') {
130
118
  return values
131
119
  .map((value) => value.replace(prefix, ''))
@@ -133,15 +121,18 @@ function toProtocolStatusList(values: string[], prefix: 'PS' | 'VS') {
133
121
  .join(',')
134
122
  }
135
123
 
124
+ /** 将接口金额转换为可安全使用的数字。 */
136
125
  function toNumber(value: unknown) {
137
126
  const number = Number(String(value ?? '').replaceAll(',', ''))
138
127
  return Number.isFinite(number) ? number : 0
139
128
  }
140
129
 
130
+ /** 将接口预报方式转换为前端枚举。 */
141
131
  function toForecastWay(value: string | undefined): ForecastWay {
142
132
  return value === 'PW02' || value === 'PW03' ? value : 'PW01'
143
133
  }
144
134
 
135
+ /** 将接口预报状态转换为前端枚举。 */
145
136
  function toForecastStatus(value: string | undefined): ForecastStatus {
146
137
  const number = Number(String(value || '').replace(/^PS/i, ''))
147
138
  return number >= 1 && number <= 8
@@ -149,10 +140,12 @@ function toForecastStatus(value: string | undefined): ForecastStatus {
149
140
  : 'PS01'
150
141
  }
151
142
 
143
+ /** 将接口预报类型转换为前端枚举。 */
152
144
  function toForecastType(value: string | undefined): ForecastType {
153
145
  return value === 'PT02' || value === 'PT03' ? value : 'PT01'
154
146
  }
155
147
 
148
+ /** 将接口核销状态转换为前端枚举。 */
156
149
  function toVerifyStatus(value: string | undefined): VerifyStatus {
157
150
  const number = Number(String(value || '').replace(/^VS/i, ''))
158
151
  return number >= 1 && number <= 3
@@ -160,26 +153,31 @@ function toVerifyStatus(value: string | undefined): VerifyStatus {
160
153
  : 'VS01'
161
154
  }
162
155
 
156
+ /** 将接口业务类型转换为前端枚举。 */
163
157
  function toBusinessType(value: string | undefined): BusinessType {
164
158
  return value === '11' || value === '12' || value === '13' ? value : '10'
165
159
  }
166
160
 
161
+ /** 将接口原币购汇类型转换为前端枚举。 */
167
162
  function toForeignExchangeType(value: string | undefined): '' | ForeignExchangeType {
168
163
  return value === '01' || value === '02' || value === '03' ? value : ''
169
164
  }
170
165
 
166
+ /** 兼容接口客户类型的数字值和前端枚举值。 */
171
167
  function toClientType(value: string | undefined): '' | ClientType {
172
168
  if (value === 'CT01' || value === '1') return 'CT01'
173
169
  if (value === 'CT02' || value === '2') return 'CT02'
174
170
  return ''
175
171
  }
176
172
 
173
+ /** 兼容接口汇款路线的数字值和前端枚举值。 */
177
174
  function toPaymentRoute(value: string | undefined): ForeignPositionForecast['paymentRoute'] {
178
175
  if (value === '02' || value === '2') return '02'
179
176
  if (value === '03' || value === '3') return '03'
180
177
  return '01'
181
178
  }
182
179
 
180
+ /** 将接口日期转换为前端展示日期。 */
183
181
  function toFrontendDate(value: string | undefined) {
184
182
  const text = String(value || '').trim()
185
183
  if (/^\d{8}$/.test(text)) {
@@ -188,6 +186,7 @@ function toFrontendDate(value: string | undefined) {
188
186
  return text.slice(0, 10)
189
187
  }
190
188
 
189
+ /** 将 TAM 返回记录转换为页面使用的预报数据。 */
191
190
  function toFrontendRow(row: TamResultInfo): ForeignPositionForecast {
192
191
  const organizationCode = String(row.groundBranch || '')
193
192
  const clientName = String(row.clientName || '')
@@ -233,38 +232,16 @@ function toFrontendRow(row: TamResultInfo): ForeignPositionForecast {
233
232
  }
234
233
  }
235
234
 
235
+ /** 获取 TAM 返回消息,不存在时使用默认文案。 */
236
236
  function getResponseMessage(payload: TamResponse, fallback: string) {
237
237
  return payload.head?.retMsg || fallback
238
238
  }
239
239
 
240
- async function requestJson<T>(path: string, init: RequestInit = {}): Promise<T> {
241
- const response = await fetch(`${apiBaseUrl}${path}`, {
242
- ...init,
243
- headers: {
244
- 'Content-Type': 'application/json',
245
- ...init.headers,
246
- },
247
- })
248
-
249
- let payload: T | ApiErrorResponse
250
- try {
251
- payload = await response.json() as T | ApiErrorResponse
252
- } catch {
253
- throw new Error(`接口返回的不是有效 JSON(HTTP ${response.status})`)
254
- }
255
-
256
- if (!response.ok) {
257
- const message = (payload as ApiErrorResponse).error?.message
258
- throw new Error(message || `请求失败(HTTP ${response.status})`)
259
- }
260
-
261
- return payload as T
262
- }
263
-
240
+ /** 查询指定编号的外币头寸预报详情。 */
264
241
  export async function getForeignPositionForecast(predRefNo: string, signal?: AbortSignal) {
265
242
  const normalizedPredRefNo = predRefNo.trim()
266
243
  const payload = await baseHttpClient.post<TamDetailResponse>(
267
- DETAIL_TRAN_CODE,
244
+ '/TAM/0001/140201004',
268
245
  { predRefNo: normalizedPredRefNo },
269
246
  { signal },
270
247
  )
@@ -284,10 +261,12 @@ export function queryForeignPositionOrganizationTree(signal?: AbortSignal) {
284
261
  return baseHttpClient.get<{ data?: unknown }>('/uaa/org/tree', { signal })
285
262
  }
286
263
 
264
+ /** 将前端日期转换为 TAM 报文日期。 */
287
265
  function toMutationDate(value: string) {
288
266
  return value.trim().slice(0, 10).replaceAll('-', '')
289
267
  }
290
268
 
269
+ /** 构建新增和修改共用的外币头寸预报请求体。 */
291
270
  function buildForeignPositionForecastMutationBody(value: ForecastEditorValue) {
292
271
  return {
293
272
  bankAcct: value.bankAccount.trim(),
@@ -306,7 +285,8 @@ function buildForeignPositionForecastMutationBody(value: ForecastEditorValue) {
306
285
  payDirec: value.payDirection.trim(),
307
286
  paymentRoute: value.paymentRoute.trim(),
308
287
  phoneNo: value.phoneNumber.trim(),
309
- predAmt: String(value.predAmount).replaceAll(',', ''),
288
+ // 旧 JSP 去除千分位后仍保留两位小数,新增和修改报文保持相同格式。
289
+ predAmt: value.predAmount.toFixed(2),
310
290
  predCode: value.forecasterCode.trim(),
311
291
  predDate: toMutationDate(value.forecastTime),
312
292
  predDept: value.forecastDepartment.trim(),
@@ -320,9 +300,10 @@ function buildForeignPositionForecastMutationBody(value: ForecastEditorValue) {
320
300
  }
321
301
  }
322
302
 
303
+ /** 新增外币头寸预报。 */
323
304
  export function createForeignPositionForecast(value: ForecastEditorValue) {
324
305
  return baseHttpClient.post<ForeignPositionForecastMutationResponse>(
325
- CREATE_TRAN_CODE,
306
+ '/TAM/0001/120201001',
326
307
  {
327
308
  authoFlag: '',
328
309
  ...buildForeignPositionForecastMutationBody(value),
@@ -330,9 +311,10 @@ export function createForeignPositionForecast(value: ForecastEditorValue) {
330
311
  )
331
312
  }
332
313
 
314
+ /** 修改指定编号的外币头寸预报。 */
333
315
  export function updateForeignPositionForecast(predRefNo: string, value: ForecastEditorValue) {
334
316
  return baseHttpClient.post<ForeignPositionForecastMutationResponse>(
335
- UPDATE_TRAN_CODE,
317
+ '/TAM/0001/120201002',
336
318
  {
337
319
  ...buildForeignPositionForecastMutationBody(value),
338
320
  junge: '',
@@ -341,20 +323,22 @@ export function updateForeignPositionForecast(predRefNo: string, value: Forecast
341
323
  )
342
324
  }
343
325
 
326
+ /** 删除指定编号的外币头寸预报。 */
344
327
  export function deleteForeignPositionForecast(predRefNo: string) {
345
- return requestJson<ForeignPositionForecast>(
328
+ return baseHttpClient.delete<ForeignPositionForecast>(
346
329
  `/foreign-position-forecasts/${encodeURIComponent(predRefNo)}`,
347
- { method: 'DELETE' },
348
330
  )
349
331
  }
350
332
 
333
+ /** 批量通过或拒绝选中的外币头寸预报。 */
351
334
  export function approveForeignPositionForecasts(predRefNos: string[], approved: boolean) {
352
- return requestJson<ForeignPositionForecastOperationResponse>('/foreign-position-forecasts/approval', {
353
- method: 'POST',
354
- body: JSON.stringify({ predRefNos, approved }),
355
- })
335
+ return baseHttpClient.post<ForeignPositionForecastOperationResponse>(
336
+ '/foreign-position-forecasts/approval',
337
+ { predRefNos, approved },
338
+ )
356
339
  }
357
340
 
341
+ /** 更新指定外币头寸预报的授权状态。 */
358
342
  export async function updateForeignPositionForecastAuthorization(
359
343
  predRefNo: string,
360
344
  authorization: ForeignPositionForecast['authirization'],
@@ -362,7 +346,7 @@ export async function updateForeignPositionForecastAuthorization(
362
346
  pageSize: number,
363
347
  ) {
364
348
  const payload = await baseHttpClient.post<TamResponse>(
365
- AUTHORIZATION_TRAN_CODE,
349
+ '/TAM/0001/120201006',
366
350
  {
367
351
  authorization,
368
352
  predRefNos: predRefNo,
@@ -373,6 +357,7 @@ export async function updateForeignPositionForecastAuthorization(
373
357
  return getResponseMessage(payload, authorization === '1' ? '授权成功' : '取消授权成功')
374
358
  }
375
359
 
360
+ /** 按筛选、排序和分页条件查询外币头寸预报。 */
376
361
  export async function queryForeignPositionForecasts(
377
362
  filters: ForeignPositionForecastQuery,
378
363
  pageIndex: number,
@@ -385,7 +370,7 @@ export async function queryForeignPositionForecasts(
385
370
  signal?: AbortSignal,
386
371
  ): Promise<ForeignPositionForecastQueryResult> {
387
372
  const payload = await baseHttpClient.post<TamResponse>(
388
- QUERY_TRAN_CODE,
373
+ '/TAM/0001/140201001',
389
374
  {
390
375
  orgName: filters.organizationName.trim(),
391
376
  clientName: filters.clientName.trim(),
@@ -1,4 +1,5 @@
1
1
  <script setup lang="ts">
2
+ import dayjs from 'dayjs'
2
3
  import { computed, nextTick, onBeforeUnmount, reactive, ref } from 'vue'
3
4
  import { ElMessage, type FormInstance, type FormRules } from 'element-plus'
4
5
  import {
@@ -522,25 +523,30 @@ function handleGroundBranchChange(value: string) {
522
523
  function handleClientTypeChange() {
523
524
  form.clientId = ''
524
525
  form.clientName = ''
526
+ form.clientAccount = ''
525
527
  clearValidation()
526
528
  }
527
529
 
528
- function handleCorporateCustomerSelect() {
530
+ function handleCorporateCustomerSelect(customer: {
531
+ customerNumber: string
532
+ customerName: string
533
+ }) {
534
+ // 140000001 返回的 custNum 同时作为外币头寸预报提交字段 clientAcct。
535
+ form.clientId = customer.customerNumber
536
+ form.clientAccount = customer.customerNumber
529
537
  clearValidation()
530
538
  }
531
539
 
532
540
  function handleValueDateChange(value: string) {
533
541
  if (!value || !form.currency) return
534
- const date = new Date(`${value}T12:00:00`)
535
- if (date.getDay() === 0 || date.getDay() === 6) {
542
+ const weekday = dayjs(value).day()
543
+ if (weekday === 0 || weekday === 6) {
536
544
  ElMessage.warning(`当前所选日期为币种 [${form.currency}] 的节假日`)
537
545
  }
538
546
  }
539
547
 
540
548
  function disablePastDate(date: Date) {
541
- const today = new Date()
542
- today.setHours(0, 0, 0, 0)
543
- return date.getTime() < today.getTime()
549
+ return dayjs(date).isBefore(dayjs(), 'day')
544
550
  }
545
551
 
546
552
  async function handleSubmit() {
@@ -548,7 +554,7 @@ async function handleSubmit() {
548
554
  const valid = await formRef.value?.validate().catch(() => false)
549
555
  if (!valid) return
550
556
 
551
- if (forecastDate.value > form.valueDate) {
557
+ if (dayjs(forecastDate.value).isAfter(dayjs(form.valueDate), 'day')) {
552
558
  ElMessage.warning('预报日期不能晚于起息日')
553
559
  return
554
560
  }
@@ -633,6 +639,7 @@ onBeforeUnmount(() => {
633
639
  filterable
634
640
  remote
635
641
  reserve-keyword
642
+ :allow-create="false"
636
643
  :remote-method="searchOrganizations"
637
644
  :loading="organizationLoading"
638
645
  placeholder="请选择机构"
@@ -648,19 +655,19 @@ onBeforeUnmount(() => {
648
655
  </el-form-item>
649
656
 
650
657
  <el-form-item label="预报人员">
651
- <el-input :model-value="forecasterName" readonly />
658
+ <el-input class="legacy-readonly-input" :model-value="forecasterName" readonly />
652
659
  </el-form-item>
653
660
 
654
661
  <el-form-item label="预报机构">
655
- <el-input :model-value="forecastDepartment" readonly />
662
+ <el-input class="legacy-readonly-input" :model-value="forecastDepartment" readonly />
656
663
  </el-form-item>
657
664
 
658
665
  <el-form-item label="预报日期">
659
- <el-input :model-value="forecastDate" readonly />
666
+ <el-input class="legacy-readonly-input" :model-value="forecastDate" readonly />
660
667
  </el-form-item>
661
668
 
662
669
  <el-form-item label="联系电话">
663
- <el-input :model-value="phoneNumber" readonly />
670
+ <el-input class="legacy-readonly-input" :model-value="phoneNumber" readonly />
664
671
  </el-form-item>
665
672
 
666
673
  <el-form-item label="起息日" prop="valueDate">
@@ -669,6 +676,7 @@ onBeforeUnmount(() => {
669
676
  type="date"
670
677
  value-format="YYYY-MM-DD"
671
678
  format="YYYY-MM-DD"
679
+ :editable="false"
672
680
  :disabled-date="disablePastDate"
673
681
  placeholder="请选择"
674
682
  @change="handleValueDateChange"
@@ -680,7 +688,13 @@ onBeforeUnmount(() => {
680
688
  </el-form-item>
681
689
 
682
690
  <el-form-item label="币种" prop="currency" class="editor-row-start">
683
- <el-select v-model="form.currency" filterable placeholder="请选择" @change="handleCurrencyChange">
691
+ <el-select
692
+ v-model="form.currency"
693
+ filterable
694
+ :allow-create="false"
695
+ placeholder="请选择"
696
+ @change="handleCurrencyChange"
697
+ >
684
698
  <el-option v-for="option in currencyOptions" :key="option.value" v-bind="option" />
685
699
  </el-select>
686
700
  </el-form-item>
@@ -737,9 +751,11 @@ onBeforeUnmount(() => {
737
751
  <el-form-item label="客户账号" prop="clientAccount">
738
752
  <el-input
739
753
  v-model="form.clientAccount"
754
+ :class="{ 'legacy-readonly-input': shouldUseCorporateCustomerSelector }"
740
755
  :disabled="isLegacyFieldDisabled('clientAccount')"
756
+ :readonly="shouldUseCorporateCustomerSelector"
741
757
  maxlength="40"
742
- placeholder="请输入客户账号"
758
+ :placeholder="shouldUseCorporateCustomerSelector ? '选择客户名称后自动回填' : '请输入客户账号'"
743
759
  />
744
760
  </el-form-item>
745
761
 
@@ -823,6 +839,7 @@ onBeforeUnmount(() => {
823
839
  :loading="accountBankLoading"
824
840
  :placeholder="bankAccountDisabled ? '请先选择汇款路径' : '请选择'"
825
841
  filterable
842
+ :allow-create="false"
826
843
  clearable
827
844
  :persistent="false"
828
845
  @visible-change="handleAccountBankVisibleChange"
@@ -898,6 +915,13 @@ onBeforeUnmount(() => {
898
915
  background: #f3f6fb;
899
916
  }
900
917
 
918
+ .forecast-editor-form {
919
+ box-sizing: border-box;
920
+ width: 100%;
921
+ max-width: 1440px;
922
+ margin: 0 auto;
923
+ }
924
+
901
925
  .editor-sections {
902
926
  display: grid;
903
927
  gap: 12px;
@@ -1023,6 +1047,17 @@ onBeforeUnmount(() => {
1023
1047
  -webkit-text-fill-color: #8a94a3;
1024
1048
  }
1025
1049
 
1050
+ .forecast-editor-form :deep(.legacy-readonly-input .el-input__wrapper) {
1051
+ cursor: not-allowed;
1052
+ background: #f7f9fc;
1053
+ box-shadow: 0 0 0 1px #e2e7ee inset;
1054
+ }
1055
+
1056
+ .forecast-editor-form :deep(.legacy-readonly-input .el-input__inner) {
1057
+ cursor: not-allowed;
1058
+ color: #8a94a3;
1059
+ }
1060
+
1026
1061
  .forecast-editor-form :deep(.el-form-item__error) {
1027
1062
  position: static;
1028
1063
  box-sizing: border-box;