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,6 +4,7 @@ | ||
4 | 4 | ||
5 | - `BasicTree` 新增`clickRowToExpand`,用于单击树节点展开 | 5 | - `BasicTree` 新增`clickRowToExpand`,用于单击树节点展开 |
6 | - 新增 SvgIcon 插件及示例 | 6 | - 新增 SvgIcon 插件及示例 |
7 | +- 账号管理界面增加左侧部门树 | ||
7 | 8 | ||
8 | ### ⚡ Performance Improvements | 9 | ### ⚡ Performance Improvements |
9 | 10 | ||
@@ -22,6 +23,7 @@ | @@ -22,6 +23,7 @@ | ||
22 | - 修复账号管理新增未清空旧数据 | 23 | - 修复账号管理新增未清空旧数据 |
23 | - form 组件应允许 setFieldsValue 方法值为 null 或者 undefined | 24 | - form 组件应允许 setFieldsValue 方法值为 null 或者 undefined |
24 | - 确保单级面包屑正确跳转 | 25 | - 确保单级面包屑正确跳转 |
26 | +- 确保 Form 组件不校验隐藏的表单项 | ||
25 | 27 | ||
26 | ## 2.0.2 (2021-03-04) | 28 | ## 2.0.2 (2021-03-04) |
27 | 29 |
src/components/Form/src/components/FormItem.tsx
@@ -97,7 +97,7 @@ export default defineComponent({ | @@ -97,7 +97,7 @@ export default defineComponent({ | ||
97 | return disabled; | 97 | return disabled; |
98 | }); | 98 | }); |
99 | 99 | ||
100 | - function getShow() { | 100 | + function getShow(): { isShow: boolean; isIfShow: boolean } { |
101 | const { show, ifShow } = props.schema; | 101 | const { show, ifShow } = props.schema; |
102 | const { showAdvancedButton } = props.formProps; | 102 | const { showAdvancedButton } = props.formProps; |
103 | const itemIsAdvanced = showAdvancedButton | 103 | const itemIsAdvanced = showAdvancedButton |
@@ -151,6 +151,10 @@ export default defineComponent({ | @@ -151,6 +151,10 @@ export default defineComponent({ | ||
151 | const { rulesMessageJoinLabel: globalRulesMessageJoinLabel } = props.formProps; | 151 | const { rulesMessageJoinLabel: globalRulesMessageJoinLabel } = props.formProps; |
152 | if (requiredRuleIndex !== -1) { | 152 | if (requiredRuleIndex !== -1) { |
153 | const rule = rules[requiredRuleIndex]; | 153 | const rule = rules[requiredRuleIndex]; |
154 | + const { isShow } = getShow(); | ||
155 | + if (!isShow) { | ||
156 | + rule.required = false; | ||
157 | + } | ||
154 | if (rule.required && component) { | 158 | if (rule.required && component) { |
155 | if (!Reflect.has(rule, 'type')) { | 159 | if (!Reflect.has(rule, 'type')) { |
156 | rule.type = 'string'; | 160 | rule.type = 'string'; |
src/components/Form/src/hooks/useFormEvents.ts
@@ -183,6 +183,7 @@ export function useFormEvents({ | @@ -183,6 +183,7 @@ export function useFormEvents({ | ||
183 | async function validateFields(nameList?: NamePath[] | undefined) { | 183 | async function validateFields(nameList?: NamePath[] | undefined) { |
184 | return unref(formElRef)?.validateFields(nameList); | 184 | return unref(formElRef)?.validateFields(nameList); |
185 | } | 185 | } |
186 | + | ||
186 | async function validate(nameList?: NamePath[] | undefined) { | 187 | async function validate(nameList?: NamePath[] | undefined) { |
187 | return await unref(formElRef)?.validate(nameList); | 188 | return await unref(formElRef)?.validate(nameList); |
188 | } | 189 | } |
src/views/demo/system/account/account.data.ts
@@ -61,7 +61,7 @@ export const accountFormSchema: FormSchema[] = [ | @@ -61,7 +61,7 @@ export const accountFormSchema: FormSchema[] = [ | ||
61 | label: '密码', | 61 | label: '密码', |
62 | component: 'InputPassword', | 62 | component: 'InputPassword', |
63 | required: true, | 63 | required: true, |
64 | - show: true, | 64 | + show: false, |
65 | }, | 65 | }, |
66 | { | 66 | { |
67 | label: '角色', | 67 | label: '角色', |