Commit 43a45b7c996c84f19d00cb9754277b943daf9a10
1 parent
e0dc5cf2
fix(form): ensure that the Form component does not verify hidden form items
Showing
4 changed files
with
9 additions
and
2 deletions
CHANGELOG.zh_CN.md
... | ... | @@ -4,6 +4,7 @@ |
4 | 4 | |
5 | 5 | - `BasicTree` 新增`clickRowToExpand`,用于单击树节点展开 |
6 | 6 | - 新增 SvgIcon 插件及示例 |
7 | +- 账号管理界面增加左侧部门树 | |
7 | 8 | |
8 | 9 | ### ⚡ Performance Improvements |
9 | 10 | |
... | ... | @@ -22,6 +23,7 @@ |
22 | 23 | - 修复账号管理新增未清空旧数据 |
23 | 24 | - form 组件应允许 setFieldsValue 方法值为 null 或者 undefined |
24 | 25 | - 确保单级面包屑正确跳转 |
26 | +- 确保 Form 组件不校验隐藏的表单项 | |
25 | 27 | |
26 | 28 | ## 2.0.2 (2021-03-04) |
27 | 29 | ... | ... |
src/components/Form/src/components/FormItem.tsx
... | ... | @@ -97,7 +97,7 @@ export default defineComponent({ |
97 | 97 | return disabled; |
98 | 98 | }); |
99 | 99 | |
100 | - function getShow() { | |
100 | + function getShow(): { isShow: boolean; isIfShow: boolean } { | |
101 | 101 | const { show, ifShow } = props.schema; |
102 | 102 | const { showAdvancedButton } = props.formProps; |
103 | 103 | const itemIsAdvanced = showAdvancedButton |
... | ... | @@ -151,6 +151,10 @@ export default defineComponent({ |
151 | 151 | const { rulesMessageJoinLabel: globalRulesMessageJoinLabel } = props.formProps; |
152 | 152 | if (requiredRuleIndex !== -1) { |
153 | 153 | const rule = rules[requiredRuleIndex]; |
154 | + const { isShow } = getShow(); | |
155 | + if (!isShow) { | |
156 | + rule.required = false; | |
157 | + } | |
154 | 158 | if (rule.required && component) { |
155 | 159 | if (!Reflect.has(rule, 'type')) { |
156 | 160 | rule.type = 'string'; | ... | ... |
src/components/Form/src/hooks/useFormEvents.ts
... | ... | @@ -183,6 +183,7 @@ export function useFormEvents({ |
183 | 183 | async function validateFields(nameList?: NamePath[] | undefined) { |
184 | 184 | return unref(formElRef)?.validateFields(nameList); |
185 | 185 | } |
186 | + | |
186 | 187 | async function validate(nameList?: NamePath[] | undefined) { |
187 | 188 | return await unref(formElRef)?.validate(nameList); |
188 | 189 | } | ... | ... |