fix(plan): 启用单阶段提取期自定义输入功能
- 修复 isCustomPeriodEnabled 仅检查多阶段配置的 bug - 单阶段模式始终启用自定义输入 - 添加 handleCustomSelect 和 openSingleStagePeriodInput 处理单阶段自定义输入 - 扩展 onPeriodInputConfirm 支持单阶段字段更新 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Showing
1 changed file
with
46 additions
and
4 deletions
| ... | @@ -38,6 +38,7 @@ | ... | @@ -38,6 +38,7 @@ |
| 38 | :is="getFieldComponent(field)" | 38 | :is="getFieldComponent(field)" |
| 39 | v-model="form[field.key]" | 39 | v-model="form[field.key]" |
| 40 | v-bind="getFieldProps(field)" | 40 | v-bind="getFieldProps(field)" |
| 41 | + @custom-select="handleCustomSelect(field)" | ||
| 41 | class="mb-5" | 42 | class="mb-5" |
| 42 | /> | 43 | /> |
| 43 | <div v-else-if="shouldRenderField(field) && field.type === 'percentage'" class="mb-5"> | 44 | <div v-else-if="shouldRenderField(field) && field.type === 'percentage'" class="mb-5"> |
| ... | @@ -299,6 +300,10 @@ const getFieldProps = (field) => { | ... | @@ -299,6 +300,10 @@ const getFieldProps = (field) => { |
| 299 | // 提取期选项由提取计划配置提供 | 300 | // 提取期选项由提取计划配置提供 |
| 300 | if (field.options_from === 'withdrawal_plan.withdrawal_periods') { | 301 | if (field.options_from === 'withdrawal_plan.withdrawal_periods') { |
| 301 | fieldProps.options = fieldProps.options || props.config?.withdrawal_plan?.withdrawal_periods | 302 | fieldProps.options = fieldProps.options || props.config?.withdrawal_plan?.withdrawal_periods |
| 303 | + // 单阶段提取期字段支持自定义输入 | ||
| 304 | + if (field.key === 'withdrawal_period_specified' || field.key === 'withdrawal_period_fixed') { | ||
| 305 | + fieldProps.allowCustom = isCustomPeriodEnabled.value | ||
| 306 | + } | ||
| 302 | } | 307 | } |
| 303 | 308 | ||
| 304 | // 基础币种来自模板配置 | 309 | // 基础币种来自模板配置 |
| ... | @@ -405,14 +410,21 @@ const canRemoveStage = computed(() => { | ... | @@ -405,14 +410,21 @@ const canRemoveStage = computed(() => { |
| 405 | */ | 410 | */ |
| 406 | const showPeriodInput = ref(false) // 自定义输入弹窗显示状态 | 411 | const showPeriodInput = ref(false) // 自定义输入弹窗显示状态 |
| 407 | const currentPeriodValue = ref('') // 当前输入的提取期值 | 412 | const currentPeriodValue = ref('') // 当前输入的提取期值 |
| 408 | -const currentStageIndex = ref(-1) // 当前正在编辑的阶段索引 | 413 | +const currentStageIndex = ref(-1) // 当前正在编辑的阶段索引(多阶段模式) |
| 414 | +const currentSingleStageFieldKey = ref('') // 当前正在编辑的单阶段字段key(单阶段模式) | ||
| 409 | const customPeriodValues = ref([]) // 用户自定义的提取期值列表(临时保存) | 415 | const customPeriodValues = ref([]) // 用户自定义的提取期值列表(临时保存) |
| 410 | 416 | ||
| 411 | /** | 417 | /** |
| 412 | * 自定义提取期是否启用 | 418 | * 自定义提取期是否启用 |
| 419 | + * @description 多阶段模式检查 multi_stage_withdrawal 配置,单阶段模式始终启用 | ||
| 413 | */ | 420 | */ |
| 414 | const isCustomPeriodEnabled = computed(() => { | 421 | const isCustomPeriodEnabled = computed(() => { |
| 415 | - return multiStageConfig.value.custom_period?.enabled || false | 422 | + // 多阶段模式:检查配置开关 |
| 423 | + if (isMultiStageMode.value) { | ||
| 424 | + return multiStageConfig.value.custom_period?.enabled || false | ||
| 425 | + } | ||
| 426 | + // 单阶段模式:始终启用自定义输入 | ||
| 427 | + return true | ||
| 416 | }) | 428 | }) |
| 417 | 429 | ||
| 418 | /** | 430 | /** |
| ... | @@ -499,16 +511,39 @@ const removeStage = (index) => { | ... | @@ -499,16 +511,39 @@ const removeStage = (index) => { |
| 499 | 511 | ||
| 500 | /** | 512 | /** |
| 501 | * 打开自定义提取期输入弹窗 | 513 | * 打开自定义提取期输入弹窗 |
| 502 | - * @param {number} stageIndex - 阶段索引 | 514 | + * @param {number} stageIndex - 阶段索引(多阶段模式) |
| 503 | */ | 515 | */ |
| 504 | const openPeriodInput = (stageIndex) => { | 516 | const openPeriodInput = (stageIndex) => { |
| 505 | currentStageIndex.value = stageIndex | 517 | currentStageIndex.value = stageIndex |
| 518 | + currentSingleStageFieldKey.value = '' | ||
| 506 | const stage = stages.value[stageIndex] | 519 | const stage = stages.value[stageIndex] |
| 507 | currentPeriodValue.value = stage?.withdrawal_period || '' | 520 | currentPeriodValue.value = stage?.withdrawal_period || '' |
| 508 | showPeriodInput.value = true | 521 | showPeriodInput.value = true |
| 509 | } | 522 | } |
| 510 | 523 | ||
| 511 | /** | 524 | /** |
| 525 | + * 处理自定义提取期输入事件 | ||
| 526 | + * @param {Object} field - 字段配置对象 | ||
| 527 | + * @description 根据字段类型调用相应的自定义输入处理函数 | ||
| 528 | + */ | ||
| 529 | +const handleCustomSelect = (field) => { | ||
| 530 | + if (field.key === 'withdrawal_period_specified' || field.key === 'withdrawal_period_fixed') { | ||
| 531 | + openSingleStagePeriodInput(field.key) | ||
| 532 | + } | ||
| 533 | +} | ||
| 534 | + | ||
| 535 | +/** | ||
| 536 | + * 打开单阶段自定义提取期输入 | ||
| 537 | + * @param {string} fieldKey - 字段key(withdrawal_period_specified 或 withdrawal_period_fixed) | ||
| 538 | + */ | ||
| 539 | +const openSingleStagePeriodInput = (fieldKey) => { | ||
| 540 | + currentSingleStageFieldKey.value = fieldKey | ||
| 541 | + currentStageIndex.value = -1 | ||
| 542 | + currentPeriodValue.value = form[fieldKey] || '' | ||
| 543 | + showPeriodInput.value = true | ||
| 544 | +} | ||
| 545 | + | ||
| 546 | +/** | ||
| 512 | * 自定义提取期输入确认 | 547 | * 自定义提取期输入确认 |
| 513 | * @param {string} value - 确认的提取期值 | 548 | * @param {string} value - 确认的提取期值 |
| 514 | */ | 549 | */ |
| ... | @@ -521,14 +556,20 @@ const onPeriodInputConfirm = (value) => { | ... | @@ -521,14 +556,20 @@ const onPeriodInputConfirm = (value) => { |
| 521 | customPeriodValues.value.push(value) | 556 | customPeriodValues.value.push(value) |
| 522 | } | 557 | } |
| 523 | 558 | ||
| 524 | - // 更新当前阶段的值 | 559 | + // 多阶段模式:更新当前阶段的值 |
| 525 | if (currentStageIndex.value >= 0 && currentStageIndex.value < stages.value.length) { | 560 | if (currentStageIndex.value >= 0 && currentStageIndex.value < stages.value.length) { |
| 526 | stages.value[currentStageIndex.value].withdrawal_period = value | 561 | stages.value[currentStageIndex.value].withdrawal_period = value |
| 527 | } | 562 | } |
| 528 | 563 | ||
| 564 | + // 单阶段模式:更新表单字段的值 | ||
| 565 | + if (currentSingleStageFieldKey.value) { | ||
| 566 | + form[currentSingleStageFieldKey.value] = value | ||
| 567 | + } | ||
| 568 | + | ||
| 529 | // 关闭弹窗并重置状态 | 569 | // 关闭弹窗并重置状态 |
| 530 | showPeriodInput.value = false | 570 | showPeriodInput.value = false |
| 531 | currentStageIndex.value = -1 | 571 | currentStageIndex.value = -1 |
| 572 | + currentSingleStageFieldKey.value = '' | ||
| 532 | currentPeriodValue.value = '' | 573 | currentPeriodValue.value = '' |
| 533 | } | 574 | } |
| 534 | 575 | ||
| ... | @@ -538,6 +579,7 @@ const onPeriodInputConfirm = (value) => { | ... | @@ -538,6 +579,7 @@ const onPeriodInputConfirm = (value) => { |
| 538 | const onPeriodInputCancel = () => { | 579 | const onPeriodInputCancel = () => { |
| 539 | showPeriodInput.value = false | 580 | showPeriodInput.value = false |
| 540 | currentStageIndex.value = -1 | 581 | currentStageIndex.value = -1 |
| 582 | + currentSingleStageFieldKey.value = '' | ||
| 541 | currentPeriodValue.value = '' | 583 | currentPeriodValue.value = '' |
| 542 | } | 584 | } |
| 543 | 585 | ... | ... |
-
Please register or login to post a comment