fix(plan): 修复表单重置不稳定问题
问题描述: - 提交成功后,有时表单会保留上次的数据 - 表现不稳定:大部分时候正常,偶尔会有残留数据 - 影响用户体验,需要手动清除数据 根本原因: - 依赖 watch 监听器重置表单存在竞态条件 - watch(visible) 只在弹窗打开时重置,关闭时不重置 - 组件可能被缓存(v-show),状态未清理 - 响应式更新时序问题导致残留 解决方案: 1. 在 submit() 成功后立即调用 resetForm() 2. 在 close() 关闭弹窗前调用 resetForm() 3. 优化 watch(visible) 作为安全网,检测残留数据 4. 为所有模板组件添加 clearErrors() 方法 技术改进: - 新增 resetForm() 函数:重置表单和错误状态 - submit() 中调用 resetForm(),确保提交后立即清空 - close() 中调用 resetForm(),确保关闭时清空 - watch(visible) 仅在检测到残留数据时才重置 - 统一模板组件接口:validate + clearErrors 影响文件: - src/components/PlanFormContainer.vue - src/components/PlanTemplates/SavingsTemplate.vue - src/components/PlanTemplates/LifeInsuranceTemplate.vue - src/components/PlanTemplates/CriticalIllnessTemplate.vue Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Showing
4 changed files
with
69 additions
and
21 deletions
-
Please register or login to post a comment