hookehuyr

fix(plan): 启用单阶段提取期自定义输入功能

- 修复 isCustomPeriodEnabled 仅检查多阶段配置的 bug
- 单阶段模式始终启用自定义输入
- 添加 handleCustomSelect 和 openSingleStagePeriodInput 处理单阶段自定义输入
- 扩展 onPeriodInputConfirm 支持单阶段字段更新

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
......@@ -38,6 +38,7 @@
:is="getFieldComponent(field)"
v-model="form[field.key]"
v-bind="getFieldProps(field)"
@custom-select="handleCustomSelect(field)"
class="mb-5"
/>
<div v-else-if="shouldRenderField(field) && field.type === 'percentage'" class="mb-5">
......@@ -299,6 +300,10 @@ const getFieldProps = (field) => {
// 提取期选项由提取计划配置提供
if (field.options_from === 'withdrawal_plan.withdrawal_periods') {
fieldProps.options = fieldProps.options || props.config?.withdrawal_plan?.withdrawal_periods
// 单阶段提取期字段支持自定义输入
if (field.key === 'withdrawal_period_specified' || field.key === 'withdrawal_period_fixed') {
fieldProps.allowCustom = isCustomPeriodEnabled.value
}
}
// 基础币种来自模板配置
......@@ -405,14 +410,21 @@ const canRemoveStage = computed(() => {
*/
const showPeriodInput = ref(false) // 自定义输入弹窗显示状态
const currentPeriodValue = ref('') // 当前输入的提取期值
const currentStageIndex = ref(-1) // 当前正在编辑的阶段索引
const currentStageIndex = ref(-1) // 当前正在编辑的阶段索引(多阶段模式)
const currentSingleStageFieldKey = ref('') // 当前正在编辑的单阶段字段key(单阶段模式)
const customPeriodValues = ref([]) // 用户自定义的提取期值列表(临时保存)
/**
* 自定义提取期是否启用
* @description 多阶段模式检查 multi_stage_withdrawal 配置,单阶段模式始终启用
*/
const isCustomPeriodEnabled = computed(() => {
return multiStageConfig.value.custom_period?.enabled || false
// 多阶段模式:检查配置开关
if (isMultiStageMode.value) {
return multiStageConfig.value.custom_period?.enabled || false
}
// 单阶段模式:始终启用自定义输入
return true
})
/**
......@@ -499,16 +511,39 @@ const removeStage = (index) => {
/**
* 打开自定义提取期输入弹窗
* @param {number} stageIndex - 阶段索引
* @param {number} stageIndex - 阶段索引(多阶段模式)
*/
const openPeriodInput = (stageIndex) => {
currentStageIndex.value = stageIndex
currentSingleStageFieldKey.value = ''
const stage = stages.value[stageIndex]
currentPeriodValue.value = stage?.withdrawal_period || ''
showPeriodInput.value = true
}
/**
* 处理自定义提取期输入事件
* @param {Object} field - 字段配置对象
* @description 根据字段类型调用相应的自定义输入处理函数
*/
const handleCustomSelect = (field) => {
if (field.key === 'withdrawal_period_specified' || field.key === 'withdrawal_period_fixed') {
openSingleStagePeriodInput(field.key)
}
}
/**
* 打开单阶段自定义提取期输入
* @param {string} fieldKey - 字段key(withdrawal_period_specified 或 withdrawal_period_fixed)
*/
const openSingleStagePeriodInput = (fieldKey) => {
currentSingleStageFieldKey.value = fieldKey
currentStageIndex.value = -1
currentPeriodValue.value = form[fieldKey] || ''
showPeriodInput.value = true
}
/**
* 自定义提取期输入确认
* @param {string} value - 确认的提取期值
*/
......@@ -521,14 +556,20 @@ const onPeriodInputConfirm = (value) => {
customPeriodValues.value.push(value)
}
// 更新当前阶段的值
// 多阶段模式:更新当前阶段的值
if (currentStageIndex.value >= 0 && currentStageIndex.value < stages.value.length) {
stages.value[currentStageIndex.value].withdrawal_period = value
}
// 单阶段模式:更新表单字段的值
if (currentSingleStageFieldKey.value) {
form[currentSingleStageFieldKey.value] = value
}
// 关闭弹窗并重置状态
showPeriodInput.value = false
currentStageIndex.value = -1
currentSingleStageFieldKey.value = ''
currentPeriodValue.value = ''
}
......@@ -538,6 +579,7 @@ const onPeriodInputConfirm = (value) => {
const onPeriodInputCancel = () => {
showPeriodInput.value = false
currentStageIndex.value = -1
currentSingleStageFieldKey.value = ''
currentPeriodValue.value = ''
}
......