Repository navigation
Conversation
新增 form-draft 工具与 useCrudForm cacheKey 参数,实现「新建/新增」表单误关后本地草稿自动恢复;编辑态表单由详情接口回填、不缓存。
移除 createFormDraft,新增 useFormDraft(watch 自动保存 + openCreate 恢复/预填),调用方只需提交成功后 done。
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
背景
useCrudForm目前关闭新增表单对话框即重置,用户填了一半误关窗口后重开需重新输入。本 PR 新增「创建表单草稿缓存」能力:新增表单误关后本地草稿自动恢复,编辑表单不缓存(由详情接口回填)。改动内容
frontend/web/src/utils/form-draft.ts:localStorage 读写封装loadFormDraft/saveFormDraft/clearFormDraftfrontend/web/src/hooks/core/useFormDraft.ts:面向「自管对话框」手写表单的组合式函数watch(dialogVisible)自动在关闭时保存草稿(仅新建态、且非提交成功)openCreate(preset?)打开时自动「重置 → 恢复草稿 → 应用预设」,预设优先级最高done()提交成功后清除草稿mode(create/update),编辑态不参与草稿读写hooks/core/useCrudForm.ts:新增可选cacheKey参数,提供后自动启用新增表单草稿缓存使用方式
useCrudForm页面:提供cacheKey即启用手写表单页面:用
useFormDraft自动绑定对话框生命周期验证