verce-vue-test 0.0.131 → 0.0.132

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.131",
3
+ "version": "0.0.132",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "scripts": {
@@ -1,18 +1,25 @@
1
+ /**
2
+ * 人民币头寸预报的 TAM/UAA 请求封装。
3
+ * 参数组装和响应字段转换统一放在 `model.ts`,本文件只维护接口地址和请求方式。
4
+ */
1
5
  import baseHttpClient from '@/utils/baseHttpClient'
2
6
  import type { RmbPositionForecastQueryParams } from './model'
3
7
 
8
+ /** TAM 业务接口的请求体;具体字段由对应的 model 转换函数生成。 */
4
9
  type BusinessParams = Record<string, unknown>
10
+
11
+ /** 140101001 分页查询额外需要的页码参数。 */
5
12
  type RmbPositionForecastListParams = RmbPositionForecastQueryParams & {
6
13
  pageIndex: number
7
14
  pageSize: number
8
15
  }
9
16
 
10
- /** 分页查询人民币头寸预报。 */
17
+ /** 调用 TAM 140101001 分页查询人民币头寸预报。 */
11
18
  export function queryRmbPositionForecasts(params: RmbPositionForecastListParams) {
12
19
  return baseHttpClient.post<any>('/TAM/0001/140101001', params)
13
20
  }
14
21
 
15
- /** 新增人民币头寸预报。 */
22
+ /** 调用 TAM 120101001 新增人民币头寸预报。 */
16
23
  export function createRmbPositionForecast(params: BusinessParams) {
17
24
  return baseHttpClient.post<any>(
18
25
  '/TAM/0001/120101001',
@@ -20,7 +27,7 @@ export function createRmbPositionForecast(params: BusinessParams) {
20
27
  )
21
28
  }
22
29
 
23
- /** 修改人民币头寸预报。 */
30
+ /** 调用 TAM 120101002 修改人民币头寸预报。 */
24
31
  export function updateRmbPositionForecast(params: BusinessParams) {
25
32
  return baseHttpClient.post<any>(
26
33
  '/TAM/0001/120101002',
@@ -28,7 +35,7 @@ export function updateRmbPositionForecast(params: BusinessParams) {
28
35
  )
29
36
  }
30
37
 
31
- /** 查询客户账号并取得客户查询交易流水号。 */
38
+ /** 调用 TAM 140000002 查询客户账号,并取得后续新增交易所需的客户查询流水号。 */
32
39
  export function queryRmbPositionCustomerAccount(
33
40
  params: { clientId: string },
34
41
  ) {
@@ -38,12 +45,12 @@ export function queryRmbPositionCustomerAccount(
38
45
  )
39
46
  }
40
47
 
41
- /** 查询当前用户可用的 UAA 机构树。 */
48
+ /** 查询当前用户可用的 UAA 机构树;树节点转换由 `model.ts` 负责。 */
42
49
  export function queryRmbPositionOrganizationTree() {
43
50
  return baseHttpClient.get<any>('/uaa/org/tree')
44
51
  }
45
52
 
46
- /** 删除一个或多个人民币头寸预报。 */
53
+ /** 调用 TAM 120101003 删除一个或多个人民币头寸预报。 */
47
54
  export function deleteRmbPositionForecast(params: { predRefSeqs: string[] }) {
48
55
  return baseHttpClient.post<any>(
49
56
  '/TAM/0001/120101003',
@@ -51,7 +58,7 @@ export function deleteRmbPositionForecast(params: { predRefSeqs: string[] }) {
51
58
  )
52
59
  }
53
60
 
54
- /** 生成人民币预报日终文件或覆盖日终文件。 */
61
+ /** 调用 TAM 120101005 生成日终文件,`coverrz` 表示覆盖日终。 */
55
62
  export function runRmbPositionForecastEndOfDay(opType: 'rz' | 'coverrz') {
56
63
  return baseHttpClient.post<any>(
57
64
  '/TAM/0001/120101005',
@@ -59,7 +66,7 @@ export function runRmbPositionForecastEndOfDay(opType: 'rz' | 'coverrz') {
59
66
  )
60
67
  }
61
68
 
62
- /** 根据预报流水号查询完整详情。 */
69
+ /** 调用 TAM 140101002,根据预报流水号查询编辑页或详情页所需的完整记录。 */
63
70
  export function getRmbPositionForecastDetail(
64
71
  params: { predRefNo: string },
65
72
  ) {
@@ -1,4 +1,8 @@
1
1
  <script setup lang="ts">
2
+ /**
3
+ * 人民币头寸预报共享编辑器。
4
+ * 对话框和整页模式共用同一套字段联动、旧 JSP 权限语义、校验和 TAM 提交逻辑。
5
+ */
2
6
  import { computed, nextTick, onBeforeUnmount, reactive, ref, watch } from 'vue'
3
7
  import { Check, Search } from '@element-plus/icons-vue'
4
8
  import { ElMessage, type FormInstance, type FormRules } from 'element-plus'
@@ -59,8 +63,10 @@ const emit = defineEmits<{
59
63
  submittingChange: [value: boolean]
60
64
  }>()
61
65
 
66
+ /** Element Plus 表单实例,用于显式提交校验和联动后的错误清理。 */
62
67
  const formRef = ref<FormInstance>()
63
68
  const editorBodyRef = ref<HTMLElement>()
69
+ /** 表单值保持页面字段命名;提交时由 model.ts 映射为 TAM 字段名。 */
64
70
  const form = reactive<EditorForm>(createEditorForm({
65
71
  sysWorkDate: businessContext.sysWorkDate,
66
72
  currentBranchName: businessContext.currentBranchName,
@@ -68,19 +74,24 @@ const form = reactive<EditorForm>(createEditorForm({
68
74
  currentUserName: businessContext.currentUserName,
69
75
  forecastDate: '',
70
76
  }))
77
+ /** 金额输入框的文本状态;与 form.predAmount 数值状态分离以支持千分位展示。 */
71
78
  const amountText = ref('')
72
79
  const isSubmitting = ref(false)
80
+ /** 每次重建表单递增,用于丢弃旧提交或异步查询的迟到响应。 */
73
81
  let editorSessionId = 0
74
82
 
83
+ /** 客户下拉选中后查询 140000002 的进行中状态。 */
75
84
  const isClientAccountQuerying = ref(false)
76
85
  let clientAccountQueryController: AbortController | null = null
77
86
 
87
+ /** 落地机构搜索结果及其请求状态。 */
78
88
  const organizationSearchVisible = ref(false)
79
89
  const organizationSearchOptions = ref<RmbPositionOrganizationOption[]>([])
80
90
  const organizationSearchResultsRef = ref<HTMLElement>()
81
91
  const isOrganizationSearching = ref(false)
82
92
  let organizationSearchController: AbortController | null = null
83
93
 
94
+ /** 新增只展示可选客户类型,修改则保留旧协议的“不适用”编码。 */
84
95
  const clientTypeOptionsForEditor = computed(() => {
85
96
  if (props.mode !== 'edit') {
86
97
  return clientTypeOptions.filter((option) => ['1', '2'].includes(option.value))
@@ -90,27 +101,31 @@ const clientTypeOptionsForEditor = computed(() => {
90
101
  ))
91
102
  })
92
103
 
104
+ /** 由当前表单值和模式实时计算旧 JSP 的 readOnly/allowBlank 语义。 */
93
105
  const fieldPolicy = computed(() => createEditorFieldPolicy(
94
106
  form,
95
107
  props.mode,
96
108
  props.editLocked,
97
109
  ))
98
110
 
111
+ /** 判断字段是否应禁用;展示禁用和是否必填由两套规则分别决定。 */
99
112
  function isFieldDisabled(field: EditorControlledField) {
100
113
  return fieldPolicy.value[field] === 'disabled'
101
114
  }
102
115
 
116
+ /** 判断字段是否仍需参与校验,修改页只对旧 JSP 声明的必填字段校验。 */
103
117
  function isFieldRequired(field: EditorControlledField) {
104
118
  return isEditorFieldRequired(field, props.mode, fieldPolicy.value)
105
119
  }
106
120
 
107
121
  const needsClientAccountQuery = computed(() => requiresCustomerAccountQuery(form, props.mode))
108
- // 旧新增页仅在“非票据 + 支行 + 对公客户”场景查询客户及账户;修改页保留普通文本输入。
122
+ /** 旧新增页仅在“非票据 + 支行 + 对公客户”场景查询客户及账户;修改页保留普通文本输入。 */
109
123
  const shouldUseCorporateCustomerSelector = computed(() => (
110
124
  needsClientAccountQuery.value
111
125
  && !isFieldDisabled('clientName')
112
126
  ))
113
127
 
128
+ /** 按当前联动结果生成回车跳转顺序,禁用字段不会占用焦点位置。 */
114
129
  const focusOrder = computed(() => {
115
130
  const trailingFields = ['linkMan', 'phoneNo', 'purpose', 'remark']
116
131
  if (props.mode === 'edit') {
@@ -142,6 +157,7 @@ const focusOrder = computed(() => {
142
157
  return order
143
158
  })
144
159
 
160
+ /** 金额输入下方的中文大写提示,仅由数值金额生成。 */
145
161
  const amountChinese = computed(() => formatChineseCurrency(form.predAmount))
146
162
  const saveButtonText = computed(() => {
147
163
  if (props.mode === 'edit') return '保存修改'
@@ -149,6 +165,7 @@ const saveButtonText = computed(() => {
149
165
  return '保存新增'
150
166
  })
151
167
 
168
+ /** 创建去除首尾空白后再判断必填的通用规则。 */
152
169
  function createTrimmedRequiredRule(field: EditorControlledField, message: string) {
153
170
  if (!isFieldRequired(field)) return []
154
171
  return [{
@@ -163,6 +180,7 @@ function createTrimmedRequiredRule(field: EditorControlledField, message: string
163
180
  }]
164
181
  }
165
182
 
183
+ /** 客户名称除必填外,在特定新增场景还必须存在客户账户查询流水号。 */
166
184
  function createClientNameRules() {
167
185
  const clientNameRules = createTrimmedRequiredRule('clientName', '请输入客户名称')
168
186
  if (!needsClientAccountQuery.value) return clientNameRules
@@ -187,6 +205,7 @@ function createClientNameRules() {
187
205
  ]
188
206
  }
189
207
 
208
+ /** 动态规则只描述当前场景;整表校验在提交时显式触发,避免联动时误报。 */
190
209
  const rules = computed<FormRules>(() => ({
191
210
  tradeDate: isFieldRequired('tradeDate')
192
211
  ? [
@@ -249,6 +268,7 @@ const rules = computed<FormRules>(() => ({
249
268
  : [],
250
269
  }))
251
270
 
271
+ /** 生成新增/复制提交需要的本地预报时间,格式保持旧 TAM 约定。 */
252
272
  function getLocalDateTimeString() {
253
273
  const now = new Date()
254
274
  const pad = (value: number) => String(value).padStart(2, '0')
@@ -256,6 +276,7 @@ function getLocalDateTimeString() {
256
276
  return `${compactDate.slice(0, 4)}-${compactDate.slice(4, 6)}-${compactDate.slice(6, 8)} ${pad(now.getHours())}:${pad(now.getMinutes())}:${pad(now.getSeconds())}`
257
277
  }
258
278
 
279
+ /** 汇总运行上下文,供每次表单重建时生成默认机构、人员和预报日期。 */
259
280
  function getEditorContext() {
260
281
  return {
261
282
  sysWorkDate: businessContext.sysWorkDate,
@@ -266,6 +287,7 @@ function getEditorContext() {
266
287
  }
267
288
  }
268
289
 
290
+ /** 金额文本在聚焦时不显示千分位,失焦后恢复本地化分组。 */
269
291
  function formatAmountText(value: number | undefined, useGrouping = true) {
270
292
  if (!Number.isFinite(value)) return ''
271
293
  return Number(value).toLocaleString('zh-CN', {
@@ -283,6 +305,7 @@ function handleAmountFocus() {
283
305
  syncAmountText(false)
284
306
  }
285
307
 
308
+ /** 过滤金额输入,只保留数字和两位小数,并同步到实际数值字段。 */
286
309
  function handleAmountInput(value: string) {
287
310
  const source = value.replaceAll(',', '')
288
311
  const hasDecimalPoint = source.includes('.')
@@ -302,10 +325,12 @@ function handleAmountBlur() {
302
325
  syncAmountText()
303
326
  }
304
327
 
328
+ /** 联动清空或回填后清除旧错误,动态规则本身不主动触发表单校验。 */
305
329
  function clearValidation() {
306
330
  nextTick(() => formRef.value?.clearValidate())
307
331
  }
308
332
 
333
+ /** 取消客户账户查询并清除只对本次新增有效的客户查询流水号。 */
309
334
  function resetClientSelection() {
310
335
  clientAccountQueryController?.abort()
311
336
  clientAccountQueryController = null
@@ -314,6 +339,7 @@ function resetClientSelection() {
314
339
  form.customerInfoSequence = ''
315
340
  }
316
341
 
342
+ /** 取消机构搜索并关闭结果浮层。 */
317
343
  function resetOrganizationSearch() {
318
344
  organizationSearchController?.abort()
319
345
  organizationSearchController = null
@@ -322,6 +348,7 @@ function resetOrganizationSearch() {
322
348
  isOrganizationSearching.value = false
323
349
  }
324
350
 
351
+ /** 清空客户及其查询流水号,供业务类型/机构/客户类型切换复用。 */
325
352
  function clearCustomerFields() {
326
353
  form.clientType = ''
327
354
  form.clientName = ''
@@ -329,22 +356,26 @@ function clearCustomerFields() {
329
356
  form.customerInfoSequence = ''
330
357
  }
331
358
 
359
+ /** 清空交易对手字段;其是否可编辑取决于业务类型和机构场景。 */
332
360
  function clearCounterpartyFields() {
333
361
  form.counterpartyName = ''
334
362
  form.counterpartyAccount = ''
335
363
  }
336
364
 
365
+ /** 清空票据字段;非票据业务切换后不能保留票号和出票日。 */
337
366
  function clearBillFields() {
338
367
  form.billNo = ''
339
368
  form.billDate = ''
340
369
  }
341
370
 
371
+ /** 重新应用新增/复制联动策略,并取消可能已经失效的客户查询。 */
342
372
  function normalizeCreateLinkage() {
343
373
  normalizeCreateEditorForm(form, fieldPolicy.value)
344
374
  resetClientSelection()
345
375
  clearValidation()
346
376
  }
347
377
 
378
+ /** 在模式或来源详情变化时重建表单;修改保留来源值,新增/复制清理禁用字段。 */
348
379
  function assignForm() {
349
380
  editorSessionId += 1
350
381
  Object.assign(form, createEditorForm(getEditorContext(), props.sourceRecord, props.mode))
@@ -355,6 +386,7 @@ function assignForm() {
355
386
  clearValidation()
356
387
  }
357
388
 
389
+ /** 新增/复制切换业务类型会重置客户、对手、票据和支付渠道依赖值。 */
358
390
  function handleBusinessTypeChange() {
359
391
  if (props.mode === 'edit') return
360
392
  clearCustomerFields()
@@ -364,6 +396,7 @@ function handleBusinessTypeChange() {
364
396
  normalizeCreateLinkage()
365
397
  }
366
398
 
399
+ /** 机构名称变更后先清空机构代码及所有下游联动,再等待重新选择机构。 */
367
400
  function handleGroundBranchNameChange() {
368
401
  if (props.mode === 'edit') return
369
402
  form.groundBranch = form.groundBranch.trim()
@@ -376,6 +409,7 @@ function handleGroundBranchNameChange() {
376
409
  normalizeCreateLinkage()
377
410
  }
378
411
 
412
+ /** 用户手工修改已解析的机构名称时立即使旧机构代码和下游值失效。 */
379
413
  function handleGroundBranchNameInput() {
380
414
  if (props.mode === 'edit') return
381
415
  organizationSearchController?.abort()
@@ -393,6 +427,7 @@ function handleGroundBranchNameInput() {
393
427
  normalizeCreateLinkage()
394
428
  }
395
429
 
430
+ /** 查询 UAA 机构树并按名称/代码筛选,只有最后一次搜索可以更新结果。 */
396
431
  async function handleOrganizationSearch() {
397
432
  const keyword = form.groundBranch.trim()
398
433
  if (!keyword) {
@@ -430,6 +465,7 @@ async function handleOrganizationSearch() {
430
465
  }
431
466
  }
432
467
 
468
+ /** 回填机构名称和代码后重新计算所有业务联动,并把焦点移到下一个字段。 */
433
469
  function selectOrganization(option: RmbPositionOrganizationOption) {
434
470
  form.groundBranch = option.organizationName
435
471
  form.groundBranchCode = option.organizationCode
@@ -442,6 +478,7 @@ function selectOrganization(option: RmbPositionOrganizationOption) {
442
478
  focusNextField('groundBranchSearch')
443
479
  }
444
480
 
481
+ /** 新增/复制切换客户类型会清空支付渠道、客户查询和交易对手,要求重新选择。 */
445
482
  function handleClientTypeChange() {
446
483
  if (props.mode === 'edit') return
447
484
  if (!form.businessType) {
@@ -460,6 +497,7 @@ function handleClientTypeChange() {
460
497
  clearValidation()
461
498
  }
462
499
 
500
+ /** 手工改动客户名称即使原客户查询流水号失效。 */
463
501
  function handleClientNameInput() {
464
502
  clientAccountQueryController?.abort()
465
503
  clientAccountQueryController = null
@@ -468,6 +506,7 @@ function handleClientNameInput() {
468
506
  form.customerInfoSequence = ''
469
507
  }
470
508
 
509
+ /** 选中对公客户后查询客户账户;查询成功才允许新增交易提交。 */
471
510
  async function handleCorporateCustomerSelect(option: {
472
511
  customerNumber: string
473
512
  customerName: string
@@ -513,6 +552,7 @@ async function handleCorporateCustomerSelect(option: {
513
552
  }
514
553
  }
515
554
 
555
+ /** 根据业务字段标记找到当前可见且未禁用的真实输入控件。 */
516
556
  function findFocusControl(key: string) {
517
557
  const root = editorBodyRef.value
518
558
  if (!root) return null
@@ -537,6 +577,7 @@ function findFocusControl(key: string) {
537
577
  )) ?? null
538
578
  }
539
579
 
580
+ /** 按动态焦点顺序移动到下一个可用控件,末尾直接进入提交。 */
540
581
  function focusNextField(currentKey: string) {
541
582
  const currentIndex = focusOrder.value.indexOf(currentKey)
542
583
  nextTick(() => {
@@ -552,6 +593,7 @@ function focusNextField(currentKey: string) {
552
593
  })
553
594
  }
554
595
 
596
+ /** 处理表单内回车导航;输入法、下拉展开和客户选择控件交给组件自身处理。 */
555
597
  function handleEnter(event: KeyboardEvent) {
556
598
  if (event.isComposing || event.shiftKey) return
557
599
  const target = event.target as HTMLElement | null
@@ -567,16 +609,22 @@ function handleEnter(event: KeyboardEvent) {
567
609
  focusNextField(currentKey)
568
610
  }
569
611
 
612
+ /** 日期选择器禁用早于系统工作日的日期。 */
570
613
  function disableBeforeSystemWorkDate(date: Date) {
571
614
  const pad = (value: number) => String(value).padStart(2, '0')
572
615
  const dateKey = `${date.getFullYear()}${pad(date.getMonth() + 1)}${pad(date.getDate())}`
573
616
  return dateKey < businessContext.sysWorkDate
574
617
  }
575
618
 
619
+ /** 提交中禁止取消,避免父页面卸载正在提交的编辑状态。 */
576
620
  function handleCancel() {
577
621
  if (!isSubmitting.value) emit('cancel')
578
622
  }
579
623
 
624
+ /**
625
+ * 统一处理新增、修改和复制提交。
626
+ * 先按当前场景规范化联动值,再显式校验;编辑器会用 sessionId 丢弃过期异步结果。
627
+ */
580
628
  async function handleSubmit() {
581
629
  if (isSubmitting.value || props.loading) return
582
630
  isSubmitting.value = true
@@ -658,12 +706,14 @@ async function handleSubmit() {
658
706
  }
659
707
  }
660
708
 
709
+ /** 父组件切换模式或来源记录时重新初始化编辑器,并使旧异步流程失效。 */
661
710
  watch(
662
711
  [() => props.mode, () => props.sourceRecord],
663
712
  assignForm,
664
713
  { immediate: true },
665
714
  )
666
715
 
716
+ /** 卸载时终止客户和机构请求,避免响应回写已销毁的编辑器。 */
667
717
  onBeforeUnmount(() => {
668
718
  editorSessionId += 1
669
719
  clientAccountQueryController?.abort()
@@ -672,6 +722,7 @@ onBeforeUnmount(() => {
672
722
  </script>
673
723
 
674
724
  <template>
725
+ <!-- 字段布局只负责展示;联动策略和提交边界全部在上方脚本中维护。 -->
675
726
  <section
676
727
  ref="editorBodyRef"
677
728
  v-loading="loading"
@@ -691,6 +742,7 @@ onBeforeUnmount(() => {
691
742
  @keydown.enter.capture="handleEnter"
692
743
  >
693
744
  <div class="editor-sections">
745
+ <!-- 01:业务类型、机构、日期、方向、渠道和金额。 -->
694
746
  <section class="editor-section" aria-labelledby="rmb-business-information-title">
695
747
  <h3 id="rmb-business-information-title" class="editor-section-title">
696
748
  <span class="editor-section-index">01</span>
@@ -819,6 +871,7 @@ onBeforeUnmount(() => {
819
871
  </div>
820
872
  </section>
821
873
 
874
+ <!-- 02:客户及交易对手字段,受业务类型/机构/客户类型联动控制。 -->
822
875
  <section class="editor-section" aria-labelledby="rmb-counterparty-information-title">
823
876
  <h3 id="rmb-counterparty-information-title" class="editor-section-title">
824
877
  <span class="editor-section-index">02</span>
@@ -887,6 +940,7 @@ onBeforeUnmount(() => {
887
940
  </div>
888
941
  </section>
889
942
 
943
+ <!-- 03:票据和说明字段;票据字段仅在票据类业务中启用。 -->
890
944
  <section class="editor-section editor-section--description" aria-labelledby="rmb-description-information-title">
891
945
  <h3 id="rmb-description-information-title" class="editor-section-title">
892
946
  <span class="editor-section-index">03</span>
@@ -941,6 +995,7 @@ onBeforeUnmount(() => {
941
995
  </div>
942
996
  </el-form>
943
997
 
998
+ <!-- 操作按钮由编辑器统一控制提交中禁用和取消行为。 -->
944
999
  <footer class="editor-actions">
945
1000
  <div class="editor-actions-card" role="group" aria-label="表单操作">
946
1001
  <el-button :disabled="isSubmitting" @click="handleCancel">返回</el-button>
@@ -1,4 +1,8 @@
1
1
  <script setup lang="ts">
2
+ /**
3
+ * 人民币头寸预报详情视图。
4
+ * 只负责详情读取和只读展示,编辑权限与编辑表单由 form.vue/编辑器分别处理。
5
+ */
2
6
  import { computed, onBeforeUnmount, ref, watch } from 'vue'
3
7
  import { ArrowLeft, Refresh } from '@element-plus/icons-vue'
4
8
  import { ElMessage } from 'element-plus'
@@ -23,6 +27,7 @@ const props = defineProps<{
23
27
  const emit = defineEmits<{
24
28
  back: []
25
29
  }>()
30
+ /** 140101002 转换后的详情模型;空值表示尚未加载或已清空旧请求结果。 */
26
31
  const detailRecord = ref<RmbPositionForecastDetail | null>(null)
27
32
  const isLoading = ref(false)
28
33
  const loadError = ref('')
@@ -31,15 +36,18 @@ let detailRequestId = 0
31
36
 
32
37
  const predRefNo = computed(() => String(props.predRefNo ?? '').trim())
33
38
 
39
+ /** 将详情中的协议编码转为展示文本,未知编码保留原值。 */
34
40
  function getOptionLabel(options: SelectOption[], value: string) {
35
41
  return options.find((option) => option.value === value)?.label || value || '—'
36
42
  }
37
43
 
44
+ /** 详情页将旧协议的 3、4 客户类型统一展示为“不适用”。 */
38
45
  function getClientTypeLabel(value: string) {
39
46
  if (value === '3' || value === '4') return '不适用'
40
47
  return getOptionLabel(clientTypeOptions, value)
41
48
  }
42
49
 
50
+ /** 详情金额按元展示两位小数;该函数只负责显示格式化。 */
43
51
  function formatMoney(value: number) {
44
52
  return Number(value || 0).toLocaleString('zh-CN', {
45
53
  minimumFractionDigits: 2,
@@ -47,21 +55,28 @@ function formatMoney(value: number) {
47
55
  })
48
56
  }
49
57
 
58
+ /** 将格式为 YYYYMMDD 的协议日期转换为可读格式,非八位值保留原值。 */
50
59
  function formatCompactDate(value: string) {
51
60
  if (!/^\d{8}$/.test(value)) return value || '—'
52
61
  return `${value.slice(0, 4)}-${value.slice(4, 6)}-${value.slice(6, 8)}`
53
62
  }
54
63
 
64
+ /** 正常/延迟预报使用默认标签色,删除状态使用信息色。 */
55
65
  function forecastStatusTagType(status: string) {
56
66
  return ['1', '2'].includes(status) ? '' : 'info'
57
67
  }
58
68
 
69
+ /** 按核销进度选择标签颜色,便于区分已核销和部分核销。 */
59
70
  function verifyStatusTagType(status: string) {
60
71
  if (status === '2') return 'success'
61
72
  if (status === '3') return 'warning'
62
73
  return 'info'
63
74
  }
64
75
 
76
+ /**
77
+ * 加载详情并转换为页面模型。
78
+ * 先取消上一次请求,再用 requestId 检查响应是否仍属于当前流水号。
79
+ */
65
80
  async function loadDetail() {
66
81
  const requestId = ++detailRequestId
67
82
  detailController?.abort()
@@ -97,14 +112,17 @@ async function loadDetail() {
97
112
  }
98
113
  }
99
114
 
115
+ /** 返回列表;列表页会保留原筛选条件和分页位置。 */
100
116
  function returnToList() {
101
117
  emit('back')
102
118
  }
103
119
 
120
+ /** 父组件切换流水号时重新加载详情。 */
104
121
  watch(predRefNo, () => {
105
122
  void loadDetail()
106
123
  }, { immediate: true })
107
124
 
125
+ /** 卸载时让未完成请求失效,避免旧详情写入已离开的视图。 */
108
126
  onBeforeUnmount(() => {
109
127
  detailRequestId += 1
110
128
  detailController?.abort()
@@ -151,6 +169,7 @@ onBeforeUnmount(() => {
151
169
  </div>
152
170
  </section>
153
171
 
172
+ <!-- 详情按业务域分为基本信息、客户交易对手、票据说明三组。 -->
154
173
  <template v-else-if="detailRecord">
155
174
  <section class="detail-section">
156
175
  <header class="section-heading">
@@ -1,4 +1,8 @@
1
1
  <script setup lang="ts">
2
+ /**
3
+ * 新增、修改、复制页面容器。
4
+ * 本组件负责详情加载、权限前置校验和页面状态,具体字段联动与提交由编辑器组件负责。
5
+ */
2
6
  import { computed, onBeforeUnmount, ref, watch } from 'vue'
3
7
  import { ArrowLeft, Refresh } from '@element-plus/icons-vue'
4
8
  import { ElMessage } from 'element-plus'
@@ -31,6 +35,7 @@ const emit = defineEmits<{
31
35
  saved: [mode: FormPageMode]
32
36
  }>()
33
37
 
38
+ /** 修改/复制时加载的来源记录;新增模式不需要该记录。 */
34
39
  const sourceRecord = ref<RmbPositionForecastDetail | null>(null)
35
40
  const isPageLoading = ref(false)
36
41
  const isSubmitting = ref(false)
@@ -38,6 +43,7 @@ const pageError = ref<FormPageError | null>(null)
38
43
  let detailController: AbortController | null = null
39
44
  let detailRequestId = 0
40
45
 
46
+ /** 清理路由或父组件传入的流水号,后续请求只使用非空值。 */
41
47
  const predRefNo = computed(() => String(props.predRefNo ?? '').trim())
42
48
  const isEditMode = computed(() => props.mode === 'edit')
43
49
  const isCopyMode = computed(() => props.mode === 'copy')
@@ -55,12 +61,18 @@ const editLocked = computed(() => {
55
61
  // 旧修改页仅在 flag 为真时锁定金额和交易日期,缺失不能等同于锁定。
56
62
  return sourceRecord.value?.editLocked === true
57
63
  })
64
+ /** 来源记录变化时重建编辑器,避免旧表单值残留在另一个操作场景。 */
58
65
  const editorKey = computed(() => (
59
66
  needsSourceRecord.value
60
67
  ? `${props.mode}-${sourceRecord.value?.predRefNo ?? predRefNo.value}`
61
68
  : 'add-new'
62
69
  ))
63
70
 
71
+ /**
72
+ * 初始化页面上下文。
73
+ * 新增直接进入编辑器;修改/复制先查详情,再按对应权限规则决定是否允许进入编辑器。
74
+ * requestId 与 AbortController 一起防止旧请求覆盖当前流水号的页面状态。
75
+ */
64
76
  async function initializePage() {
65
77
  const requestId = ++detailRequestId
66
78
  detailController?.abort()
@@ -120,15 +132,18 @@ async function initializePage() {
120
132
  }
121
133
  }
122
134
 
135
+ /** 提交过程中禁止离开,其他状态统一向列表页发送取消事件。 */
123
136
  function returnToList() {
124
137
  if (isSubmitting.value) return
125
138
  emit('cancel')
126
139
  }
127
140
 
141
+ /** 编辑器保存成功后把当前操作模式交给父列表刷新。 */
128
142
  function handleSaved() {
129
143
  emit('saved', props.mode)
130
144
  }
131
145
 
146
+ /** 模式或流水号变化时重新加载来源详情。 */
132
147
  watch(
133
148
  [() => props.mode, predRefNo],
134
149
  () => {
@@ -137,6 +152,7 @@ watch(
137
152
  { immediate: true },
138
153
  )
139
154
 
155
+ /** 销毁页面时终止详情请求,并使已返回的旧响应失效。 */
140
156
  onBeforeUnmount(() => {
141
157
  detailRequestId += 1
142
158
  detailController?.abort()
@@ -160,10 +176,12 @@ onBeforeUnmount(() => {
160
176
  </div>
161
177
  </section>
162
178
 
179
+ <!-- 修改/复制进入编辑器前先展示详情加载状态。 -->
163
180
  <section v-if="isPageLoading" v-loading="true" class="form-state-card">
164
181
  <span>正在加载{{ pageActionLabel }}信息…</span>
165
182
  </section>
166
183
 
184
+ <!-- 权限失败和详情查询失败都在容器层处理,编辑器不会收到不完整来源记录。 -->
167
185
  <section v-else-if="pageError" class="form-state-card is-error">
168
186
  <strong>{{ pageError.title }}</strong>
169
187
  <p>{{ pageError.message }}</p>
@@ -1,4 +1,8 @@
1
1
  <script setup lang="ts">
2
+ /**
3
+ * 人民币头寸预报列表页。
4
+ * 列表、详情和新增/修改/复制表单在同一页面内切换,查询条件和分页状态由本页统一维护。
5
+ */
2
6
  import { computed, onBeforeUnmount, onMounted, reactive, ref } from 'vue'
3
7
  import dayjs from 'dayjs'
4
8
  import customParseFormat from 'dayjs/plugin/customParseFormat'
@@ -54,6 +58,7 @@ import {
54
58
 
55
59
  dayjs.extend(customParseFormat)
56
60
 
61
+ /** 首次进入页面使用系统工作日查询,其余筛选项保持旧 JSP 的默认值。 */
57
62
  const createInitialFilter = (): RmbPositionForecastFilter => ({
58
63
  tradeDate: businessContext.sysWorkDate,
59
64
  payDirection: '',
@@ -69,12 +74,14 @@ const createInitialFilter = (): RmbPositionForecastFilter => ({
69
74
  maxAmountWan: null,
70
75
  })
71
76
 
77
+ /** 重置时清空交易日期和排序,避免把“重置”误认为按默认条件立即查询。 */
72
78
  const createResetFilter = (): RmbPositionForecastFilter => ({
73
79
  ...createInitialFilter(),
74
80
  tradeDate: '',
75
81
  sortRule: '',
76
82
  })
77
83
 
84
+ /** 复制筛选条件时单独复制数组,避免查询快照被多选控件的原数组引用污染。 */
78
85
  const cloneFilter = (source: RmbPositionForecastFilter): RmbPositionForecastFilter => ({
79
86
  ...source,
80
87
  verifyStatuses: [...source.verifyStatuses],
@@ -91,6 +98,7 @@ const sharedFilterParams = computed(() => (
91
98
  createRmbPositionForecastQueryParams(appliedFilters.value)
92
99
  ))
93
100
 
101
+ /** 当前页内视图;不通过路由切换可保留列表页的筛选和分页上下文。 */
94
102
  type RmbPositionForecastView = 'list' | 'detail' | 'add' | 'edit' | 'copy'
95
103
  const activeView = ref<RmbPositionForecastView>('list')
96
104
  const activePredRefNo = ref('')
@@ -148,6 +156,7 @@ type ForecastTableColumn = {
148
156
  muted?: boolean
149
157
  }
150
158
 
159
+ /** 表格列配置同时驱动列选择器、列展示和单元格格式化。 */
151
160
  const forecastTableColumns: ForecastTableColumn[] = [
152
161
  {
153
162
  key: 'selection',
@@ -186,11 +195,13 @@ const forecastTableColumns: ForecastTableColumn[] = [
186
195
  { key: 'forecastDate', kind: 'data', prop: 'forecastDate', label: '预报日期', render: 'text' },
187
196
  ]
188
197
 
198
+ /** 将协议编码转换为展示文本;未配置的编码保留原值,方便排查新后端枚举。 */
189
199
  function getOptionLabel(options: SelectOption[], value: string) {
190
200
  const label = options.find((option) => option.value === value)?.label
191
201
  return label || value || '—'
192
202
  }
193
203
 
204
+ /** 根据列配置统一处理日期、金额、枚举和普通文本单元格。 */
194
205
  function getTableColumnText(
195
206
  column: ForecastTableColumn,
196
207
  row: RmbPositionForecastRow,
@@ -203,6 +214,7 @@ function getTableColumnText(
203
214
  return String(value ?? '') || '—'
204
215
  }
205
216
 
217
+ /** 日终操作使用的页面角色判断,权限来源于 runtime 共享上下文。 */
206
218
  function hasAnyRole(...roles: string[]) {
207
219
  return roles.some((role) => businessContext.roles.has(role))
208
220
  }
@@ -217,6 +229,7 @@ const singleSelectionTip = computed(() => {
217
229
  return ''
218
230
  })
219
231
 
232
+ /** 列表金额仅做元单位的本地化展示,不改变提交或查询值。 */
220
233
  function formatMoney(value: number) {
221
234
  return Number(value || 0).toLocaleString('zh-CN', {
222
235
  minimumFractionDigits: 2,
@@ -224,6 +237,7 @@ function formatMoney(value: number) {
224
237
  })
225
238
  }
226
239
 
240
+ /** 列表日期按协议的 YYYYMMDD 原样展示;非法值保留原文。 */
227
241
  function formatCompactDate(value: string) {
228
242
  const date = dayjs(value, 'YYYYMMDD', true)
229
243
  return date.isValid() ? date.format('YYYYMMDD') : value || '—'
@@ -237,6 +251,7 @@ function forecastStatusTagType(status: string) {
237
251
  return operableStatusCodes.has(status) ? '' : 'info'
238
252
  }
239
253
 
254
+ /** 清空页面选择,并递增 key 通知 ElTablePro 同步清除内部勾选状态。 */
240
255
  function clearSelection() {
241
256
  selectedRows.value = []
242
257
  selectionResetKey.value += 1
@@ -251,6 +266,10 @@ function toggleFilterCollapsed() {
251
266
  saveRmbPositionForecastFilterCollapsed(filterCollapsed.value)
252
267
  }
253
268
 
269
+ /**
270
+ * 加载指定页数据。
271
+ * 新查询会取消旧请求,只有最后一次请求可以提交结果;失败时恢复最近一次成功的条件和分页。
272
+ */
254
273
  async function loadForecasts(page: number, size: number) {
255
274
  activeQueryController?.abort()
256
275
  const controller = new AbortController()
@@ -291,6 +310,7 @@ async function loadForecasts(page: number, size: number) {
291
310
  }
292
311
  }
293
312
 
313
+ /** 校验筛选条件后提交查询;查询动作显式从第一页开始。 */
294
314
  async function handleQuery() {
295
315
  if (!filterForm.tradeDate) {
296
316
  ElMessage.warning('请选择交易日期')
@@ -322,11 +342,13 @@ async function handleQuery() {
322
342
  await loadForecasts(1, pageSize.value)
323
343
  }
324
344
 
345
+ /** 只重置表单,不自动发起查询,用户点击查询后才提交新的筛选条件。 */
325
346
  function handleReset() {
326
347
  Object.assign(filterForm, createResetFilter())
327
348
  amountRangeValid.value = true
328
349
  }
329
350
 
351
+ /** 分页控件回调复用同一加载流程,保持当前已应用筛选条件。 */
330
352
  async function handlePaginationChange({
331
353
  page,
332
354
  pageSize: nextPageSize,
@@ -334,14 +356,17 @@ async function handlePaginationChange({
334
356
  await loadForecasts(page, nextPageSize)
335
357
  }
336
358
 
359
+ /** 首次进入列表时按默认交易日期自动查询。 */
337
360
  onMounted(() => {
338
361
  void handleQuery()
339
362
  })
340
363
 
364
+ /** 离开列表页时取消未完成查询,避免卸载后的响应继续更新状态。 */
341
365
  onBeforeUnmount(() => {
342
366
  activeQueryController?.abort()
343
367
  })
344
368
 
369
+ /** 返回列表并清理当前详情/表单上下文。 */
345
370
  function showList() {
346
371
  activeView.value = 'list'
347
372
  activePredRefNo.value = ''
@@ -349,6 +374,7 @@ function showList() {
349
374
  clearSelection()
350
375
  }
351
376
 
377
+ /** 切换到详情或表单视图,并清除上一视图遗留的行选择。 */
352
378
  function showInlineView(
353
379
  view: Exclude<RmbPositionForecastView, 'list'>,
354
380
  predRefNo = '',
@@ -360,35 +386,41 @@ function showInlineView(
360
386
  clearSelection()
361
387
  }
362
388
 
389
+ /** 打开指定预报的详情视图。 */
363
390
  function openDetail(row: RmbPositionForecastRow) {
364
391
  showInlineView('detail', row.predRefNo)
365
392
  }
366
393
 
394
+ /** 打开唯一选中行的详情;多选或未选时由按钮禁用和提示拦截。 */
367
395
  function openSelectedDetail() {
368
396
  if (!singleSelectedRow.value) return
369
397
  openDetail(singleSelectedRow.value)
370
398
  }
371
399
 
400
+ /** 从工具栏进入修改页,权限校验集中在 openEditPage。 */
372
401
  function handleSelectedEdit() {
373
402
  const row = singleSelectedRow.value
374
403
  if (!row) return
375
404
  openEditPage(row)
376
405
  }
377
406
 
407
+ /** 从工具栏进入复制页,复制权限与修改权限分开判断。 */
378
408
  function handleSelectedCopy() {
379
409
  const row = singleSelectedRow.value
380
410
  if (!row) return
381
411
  openCopyPage(row)
382
412
  }
383
413
 
414
+ /** 对应交易状态入口暂保留,待业务接口明确后接入。 */
384
415
  function handleTransactionStatusClick() {
385
- // 对应交易状态逻辑由业务方通过 singleSelectedRow.value 实现。
386
416
  }
387
417
 
418
+ /** 打开新增页;新增不需要先加载来源记录。 */
388
419
  function openAddPage() {
389
420
  showInlineView('add')
390
421
  }
391
422
 
423
+ /** 校验修改权限后打开修改页,并把旧 flag 的金额/日期锁定状态传给表单。 */
392
424
  function openEditPage(row: RmbPositionForecastRow) {
393
425
  const permissionError = getRmbPositionForecastEditPermissionError(row)
394
426
  if (permissionError) {
@@ -398,6 +430,7 @@ function openEditPage(row: RmbPositionForecastRow) {
398
430
  showInlineView('edit', row.predRefNo, row.editLocked === true)
399
431
  }
400
432
 
433
+ /** 校验复制权限后打开复制页;复制表单加载详情但最终按新增提交。 */
401
434
  function openCopyPage(row: RmbPositionForecastRow) {
402
435
  const permissionError = getRmbPositionForecastCopyPermissionError(row)
403
436
  if (permissionError) {
@@ -407,11 +440,13 @@ function openCopyPage(row: RmbPositionForecastRow) {
407
440
  showInlineView('copy', row.predRefNo)
408
441
  }
409
442
 
443
+ /** 表单保存成功后回到列表,并刷新当前页数据。 */
410
444
  function handleInlineFormSaved() {
411
445
  showList()
412
446
  void loadForecasts(currentPage.value, pageSize.value)
413
447
  }
414
448
 
449
+ /** 校验删除权限、二次确认并刷新当前分页。 */
415
450
  async function handleDelete(row: RmbPositionForecastRow) {
416
451
  const permissionError = getRmbPositionForecastDeletePermissionError(row)
417
452
  if (permissionError) {
@@ -441,12 +476,14 @@ async function handleDelete(row: RmbPositionForecastRow) {
441
476
  }
442
477
  }
443
478
 
479
+ /** 删除工具栏当前唯一选中的记录。 */
444
480
  async function handleSelectedDelete() {
445
481
  const row = singleSelectedRow.value
446
482
  if (!row) return
447
483
  await handleDelete(row)
448
484
  }
449
485
 
486
+ /** 将工具栏命令映射为 TAM 日终操作类型,并在调用前完成角色校验和确认。 */
450
487
  async function handleEndOfDayCommand(command: string) {
451
488
  if (!hasAnyRole('006', '007')) {
452
489
  ElMessage.warning('您不具有日终操作权限')
@@ -475,6 +512,7 @@ async function handleEndOfDayCommand(command: string) {
475
512
  }
476
513
  }
477
514
 
515
+ /** 当前仅输出已应用筛选参数,真正导出文件待导出接口接入后实现。 */
478
516
  function handleExport() {
479
517
  console.log('人民币头寸预报导出参数:', sharedFilterParams.value)
480
518
  }
@@ -486,6 +524,7 @@ function handleExport() {
486
524
  :class="{ 'is-filter-collapsed': filterCollapsed }"
487
525
  >
488
526
  <template v-if="activeView === 'list'">
527
+ <!-- 列表视图由筛选区、操作工具栏和分页表格组成。 -->
489
528
  <section class="query-panel" aria-label="人民币头寸预报查询条件">
490
529
  <el-form :model="filterForm" label-position="top" size="small" class="query-form" @submit.prevent="handleQuery">
491
530
  <div class="query-grid" :class="{ 'is-collapsed': filterCollapsed }">
@@ -587,6 +626,7 @@ function handleExport() {
587
626
  </section>
588
627
 
589
628
  <section v-loading="isQuerying" class="table-panel" aria-label="人民币头寸预报列表">
629
+ <!-- selection-reset-key 用于在查询、分页和视图切换后清除表格内部选择。 -->
590
630
  <ElTablePro
591
631
  v-model:page="currentPage"
592
632
  v-model:page-size="pageSize"
@@ -719,6 +759,7 @@ function handleExport() {
719
759
  </div>
720
760
  </template>
721
761
 
762
+ <!-- 列配置决定是否显示列以及对应的单元格渲染方式。 -->
722
763
  <el-table-column
723
764
  v-for="column in forecastTableColumns"
724
765
  :key="column.key"
@@ -759,6 +800,7 @@ function handleExport() {
759
800
  </section>
760
801
  </template>
761
802
 
803
+ <!-- 详情和表单复用列表页上下文,返回后无需重新初始化筛选条件。 -->
762
804
  <RmbPositionForecastDetail
763
805
  v-else-if="activeView === 'detail'"
764
806
  :key="`detail-${activePredRefNo}`"
@@ -111,6 +111,10 @@ export type RmbPositionForecastListResult = {
111
111
  totalCount: number
112
112
  }
113
113
 
114
+ /**
115
+ * 编辑器内部使用的新增/修改值。
116
+ * 字段名保持页面语义,提交前再映射为 TAM 的旧字段名,避免表单直接依赖协议字段。
117
+ */
114
118
  export type RmbPositionForecastMutationValue = {
115
119
  predRefNo?: string
116
120
  tradeDate: string
@@ -137,11 +141,13 @@ export type RmbPositionForecastMutationValue = {
137
141
  remark?: string
138
142
  }
139
143
 
144
+ /** 机构搜索下拉项;名称用于展示,代码用于回填隐藏机构字段。 */
140
145
  export type RmbPositionOrganizationOption = {
141
146
  organizationCode: string
142
147
  organizationName: string
143
148
  }
144
149
 
150
+ /** 140101001 需要的旧 JSP/TAM 查询字段。金额字段传元的字符串。 */
145
151
  export type RmbPositionForecastQueryParams = {
146
152
  busiType: string
147
153
  clientName: string
@@ -163,11 +169,13 @@ export type SelectOption<T extends string = string> = {
163
169
  label: string
164
170
  }
165
171
 
172
+ /** 收支方向下拉选项。 */
166
173
  export const payDirectionOptions = [
167
174
  { value: '1', label: '收入' },
168
175
  { value: '2', label: '支出' },
169
176
  ] satisfies SelectOption<RmbPositionPayDirection>[]
170
177
 
178
+ /** 支付渠道下拉选项。 */
171
179
  export const payChannelOptions = [
172
180
  { value: '1', label: '大额支付' },
173
181
  { value: '2', label: '小额支付' },
@@ -176,22 +184,26 @@ export const payChannelOptions = [
176
184
  { value: '7', label: '网联支付' },
177
185
  ] satisfies SelectOption<RmbPositionPayChannel>[]
178
186
 
187
+ /** 预报删除状态筛选选项。 */
179
188
  export const deleteStatusOptions = [
180
189
  { value: '1', label: '已删除' },
181
190
  { value: '2', label: '未删除' },
182
191
  ] satisfies SelectOption<RmbPositionDeleteStatus>[]
183
192
 
193
+ /** 核销状态筛选选项。 */
184
194
  export const verifyStatusOptions = [
185
195
  { value: '1', label: '未核销' },
186
196
  { value: '2', label: '已核销' },
187
197
  { value: '3', label: '部分核销' },
188
198
  ] satisfies SelectOption<RmbPositionVerifyStatus>[]
189
199
 
200
+ /** 列表排序选项;页面值 2 会在协议转换时映射为 TAM 的 3。 */
190
201
  export const sortRuleOptions = [
191
202
  { value: '1', label: '预报时间降序' },
192
203
  { value: '2', label: '预报金额降序' },
193
204
  ] satisfies SelectOption<RmbPositionSortRule>[]
194
205
 
206
+ /** 客户类型选项;3、4 是旧协议中的“不适用”编码。 */
195
207
  export const clientTypeOptions = [
196
208
  { value: '1', label: '对公客户' },
197
209
  { value: '2', label: '个人客户' },
@@ -200,6 +212,7 @@ export const clientTypeOptions = [
200
212
  { value: '5', label: '其他' },
201
213
  ] satisfies SelectOption<RmbPositionClientType>[]
202
214
 
215
+ /** 业务类型选项;编码必须与旧 JSP/TAM 约定保持一致。 */
203
216
  export const businessTypeOptions = [
204
217
  { value: '1', label: '对公/个人客户收付' },
205
218
  { value: '2', label: '本票签发/兑付' },
@@ -219,6 +232,7 @@ export const businessTypeOptions = [
219
232
  { value: '16', label: '票据业务' },
220
233
  ] satisfies SelectOption<RmbPositionBusinessType>[]
221
234
 
235
+ /** 预报状态选项;3 至 6 表示不同删除结果。 */
222
236
  export const forecastStatusOptions = [
223
237
  { value: '1', label: '正常预报' },
224
238
  { value: '2', label: '延迟预报' },
@@ -228,8 +242,10 @@ export const forecastStatusOptions = [
228
242
  { value: '6', label: '延时预报延迟删除' },
229
243
  ] satisfies SelectOption<RmbPositionForecastStatus>[]
230
244
 
245
+ /** 编辑器模式:复制复用详情回填,但最终仍按新增交易提交。 */
231
246
  export type EditorMode = 'add' | 'edit' | 'copy'
232
247
 
248
+ /** 编辑器展示状态;新增客户查询编号不从详情直接回填,修改所需的引用编号单独保留。 */
233
249
  export type EditorForm = {
234
250
  tradeDate: string
235
251
  payDirection: string
@@ -257,6 +273,7 @@ export type EditorForm = {
257
273
  forecastDate: string
258
274
  }
259
275
 
276
+ /** 新增页运行上下文;机构、人员和系统工作日来自运行配置。 */
260
277
  export type EditorContext = {
261
278
  sysWorkDate: string
262
279
  currentBranchName: string
@@ -265,6 +282,7 @@ export type EditorContext = {
265
282
  forecastDate: string
266
283
  }
267
284
 
285
+ /** 受旧 JSP 联动策略控制显示、必填和禁用状态的字段。 */
268
286
  export type EditorControlledField =
269
287
  | 'businessType'
270
288
  | 'groundBranch'
@@ -281,7 +299,10 @@ export type EditorControlledField =
281
299
  | 'tradeDate'
282
300
  | 'standardName'
283
301
 
302
+ /** 字段策略:必填、可选或禁用。 */
284
303
  export type EditorFieldMode = 'required' | 'optional' | 'disabled'
304
+
305
+ /** 当前编辑器场景下各受控字段的策略快照。 */
285
306
  export type EditorFieldPolicy = Record<EditorControlledField, EditorFieldMode>
286
307
 
287
308
  const billBusinessTypes = new Set(['2', '3'])
@@ -314,6 +335,7 @@ export function requiresCustomerAccountQuery(
314
335
  && form.clientType === '1'
315
336
  }
316
337
 
338
+ /** 按新增、修改或复制场景创建表单;修改保留详情值,新增/复制重建本次预报上下文。 */
317
339
  export function createEditorForm(
318
340
  context: EditorContext,
319
341
  row?: Partial<RmbPositionForecastDetail> | null,
@@ -474,6 +496,7 @@ const chineseDigits = ['零', '壹', '贰', '叁', '肆', '伍', '陆', '柒', '
474
496
  const chineseGroupUnits = ['', '万', '亿', '兆'] as const
475
497
  const chineseWithinGroupUnits = ['仟', '佰', '拾', ''] as const
476
498
 
499
+ /** 将 0 至 9999 的一组数字转换为中文大写,不附加万/亿等组单位。 */
477
500
  function formatChineseFourDigitGroup(value: number) {
478
501
  const digits = String(value).padStart(4, '0')
479
502
  let result = ''
@@ -494,6 +517,7 @@ function formatChineseFourDigitGroup(value: number) {
494
517
  return result
495
518
  }
496
519
 
520
+ /** 按四位一组拼接中文大写整数,并处理组间补零。 */
497
521
  function formatChineseInteger(value: number) {
498
522
  const groups: number[] = []
499
523
  let remaining = Math.trunc(value)
@@ -535,19 +559,23 @@ export function formatChineseCurrency(value: number | undefined) {
535
559
  return `人民币${integerPart}元${decimalPart}`
536
560
  }
537
561
 
562
+ /** 用于承接后端未知结构的协议对象,转换完成后再收窄为页面模型。 */
538
563
  type ProtocolRecord = Record<string, unknown>
539
564
 
565
+ /** 只接受普通对象,避免接口返回 null、数组时在字段读取处抛出无意义异常。 */
540
566
  function toProtocolRecord(value: unknown): ProtocolRecord {
541
567
  return value && typeof value === 'object' && !Array.isArray(value)
542
568
  ? value as ProtocolRecord
543
569
  : {}
544
570
  }
545
571
 
572
+ /** 统一生成协议字段错误,避免把非法编码静默转换成错误的页面状态。 */
546
573
  function invalidProtocolField(field: string, value: unknown): never {
547
574
  const displayValue = String(value ?? '').trim() || '空值'
548
575
  throw new Error(`人民币头寸预报接口返回的 ${field} 无效:${displayValue}`)
549
576
  }
550
577
 
578
+ /** 校验协议枚举编码并返回类型收窄后的字符串。 */
551
579
  function toProtocolCode<T extends string>(
552
580
  field: string,
553
581
  value: unknown,
@@ -558,11 +586,13 @@ function toProtocolCode<T extends string>(
558
586
  return code as T
559
587
  }
560
588
 
589
+ /** 将接口金额(允许带千分位的字符串)转换为元单位数字。 */
561
590
  function toAmount(value: unknown) {
562
591
  const amount = Number(String(value ?? '').replaceAll(',', ''))
563
592
  return Number.isFinite(amount) ? amount : 0
564
593
  }
565
594
 
595
+ /** 兼容列表返回的 `editFlag` 和旧字段 `flag`,仅识别明确的真假值。 */
566
596
  function toEditLocked(row: ProtocolRecord): boolean | undefined {
567
597
  const value = row.editFlag ?? row.flag
568
598
  if (value === undefined || value === null) return undefined
@@ -573,6 +603,7 @@ function toEditLocked(row: ProtocolRecord): boolean | undefined {
573
603
  return undefined
574
604
  }
575
605
 
606
+ /** 校验 1 至 16 的业务类型编码,保证后续选项映射不会出现未知值。 */
576
607
  function toBusinessType(value: unknown): RmbPositionBusinessType {
577
608
  const businessType = String(value ?? '')
578
609
  const code = Number(businessType)
@@ -582,6 +613,7 @@ function toBusinessType(value: unknown): RmbPositionBusinessType {
582
613
  return businessType as RmbPositionBusinessType
583
614
  }
584
615
 
616
+ /** 将单条 140101001/140101002 协议记录转换为列表共享模型。 */
585
617
  function toRmbPositionForecastRow(value: unknown): RmbPositionForecastRow {
586
618
  const row = toProtocolRecord(value)
587
619
  const predRefNo = String(row.predRefNo ?? '').trim()
@@ -665,6 +697,7 @@ export function toRmbPositionForecastDetail(body: unknown): RmbPositionForecastD
665
697
  }
666
698
  }
667
699
 
700
+ /** 将查询表单中的“万元”金额转换为 TAM 所需的元字符串。 */
668
701
  function toProtocolAmount(value: number | null) {
669
702
  return value === null ? '' : String(Math.round(value * 10_000))
670
703
  }
@@ -695,6 +728,7 @@ export function createRmbPositionForecastQueryParams(
695
728
  }
696
729
  }
697
730
 
731
+ /** 生成新增、修改共用的 TAM 字段;创建人字段由 includeCreatorFields 控制。 */
698
732
  function createMutationBaseParams(
699
733
  value: RmbPositionForecastMutationValue,
700
734
  includeCreatorFields: boolean,
@@ -748,18 +782,21 @@ export function createRmbPositionForecastMutationParams(
748
782
  }
749
783
  }
750
784
 
785
+ /** 去重并校验删除流水号,生成 120101003 所需的 predRefSeqs。 */
751
786
  export function createRmbPositionForecastDeleteParams(predRefNos: string[]) {
752
787
  const predRefSeqs = [...new Set(predRefNos.map((item) => item.trim()).filter(Boolean))]
753
788
  if (predRefSeqs.length === 0) throw new Error('预报流水号不能为空')
754
789
  return { predRefSeqs }
755
790
  }
756
791
 
792
+ /** 校验客户编号并生成 140000002 的查询参数。 */
757
793
  export function createRmbPositionCustomerAccountParams(clientId: string) {
758
794
  const normalizedClientId = clientId.trim()
759
795
  if (!normalizedClientId) throw new Error('客户编号不能为空')
760
796
  return { clientId: normalizedClientId }
761
797
  }
762
798
 
799
+ /** 从 140000002 响应中提取新增交易需要的客户信息查询流水号。 */
763
800
  export function toRmbPositionCustomerAccountSequence(body: unknown) {
764
801
  const response = toProtocolRecord(body)
765
802
  const consumerSeqNo = String(response.consumerSeqNo ?? '').trim()
@@ -767,6 +804,7 @@ export function toRmbPositionCustomerAccountSequence(body: unknown) {
767
804
  return consumerSeqNo
768
805
  }
769
806
 
807
+ /** 递归遍历 UAA 机构树,兼容节点 attributes/children 两种旧结构。 */
770
808
  function collectOrganizations(
771
809
  node: unknown,
772
810
  result: RmbPositionOrganizationOption[],
@@ -33,6 +33,7 @@ function normalizeTime(value: unknown) {
33
33
  return time
34
34
  }
35
35
 
36
+ /** 将日期或时间片段补齐为两位,供协议日期和时间窗口比较使用。 */
36
37
  function padDatePart(value: number) {
37
38
  return String(value).padStart(2, '0')
38
39
  }
@@ -115,10 +116,12 @@ export function saveRmbPositionForecastFilterCollapsed(collapsed: boolean) {
115
116
  }
116
117
  }
117
118
 
119
+ /** 判断当前运行上下文是否至少包含一个指定的 TAM 页面角色。 */
118
120
  function hasAnyRole(...roles: string[]) {
119
121
  return roles.some((role) => rmbPositionForecastBusinessContext.roles.has(role))
120
122
  }
121
123
 
124
+ /** 校验已核销预报的可修改时间窗口;边界时刻不包含在可操作区间内。 */
122
125
  function getVerifyUpdateWindowError() {
123
126
  const context = rmbPositionForecastBusinessContext
124
127
  if (!context.verifyUpdateStart || !context.verifyUpdateEnd) {
@@ -135,6 +138,7 @@ function getVerifyUpdateWindowError() {
135
138
  return ''
136
139
  }
137
140
 
141
+ /** 校验当前用户是否具备与预报金额对应的操作权限。 */
138
142
  export function getRmbPositionForecastAmountPermissionError(
139
143
  row: RmbPositionForecastRow,
140
144
  ) {
@@ -148,6 +152,7 @@ export function getRmbPositionForecastAmountPermissionError(
148
152
  return ''
149
153
  }
150
154
 
155
+ /** 按预报状态、核销状态、角色和时间窗口校验修改权限。 */
151
156
  export function getRmbPositionForecastEditPermissionError(
152
157
  row: RmbPositionForecastRow,
153
158
  ) {
@@ -163,6 +168,7 @@ export function getRmbPositionForecastEditPermissionError(
163
168
  return getVerifyUpdateWindowError()
164
169
  }
165
170
 
171
+ /** 校验复制权限;复制会走新增交易,因此要求原交易日期不早于系统工作日。 */
166
172
  export function getRmbPositionForecastCopyPermissionError(
167
173
  row: RmbPositionForecastRow,
168
174
  ) {
@@ -175,6 +181,7 @@ export function getRmbPositionForecastCopyPermissionError(
175
181
  return ''
176
182
  }
177
183
 
184
+ /** 校验删除权限;只有未核销且仍处于可操作状态的记录才允许删除。 */
178
185
  export function getRmbPositionForecastDeletePermissionError(
179
186
  row: RmbPositionForecastRow,
180
187
  ) {