diff --git a/docs/form-render/api-props.md b/docs/form-render/api-props.md index 6527f93dd..8cc742a94 100644 --- a/docs/form-render/api-props.md +++ b/docs/form-render/api-props.md @@ -48,7 +48,7 @@ group: | setValueByPath | 外部修改指定单个 field 的数据(原名 onItemChange) | `(path: Path, value: any) => void` | | setSchemaByPath | 指定路径修改 schema | `(path: Path, schema: any) => void` | | setSchema | 指定多个路径修改 schema,cover 传true将直接替换 schema | `({ path: value }, cover?: boolean) => void` | -| getValues | 获取表单内部维护的数据, 如果参数为空则返回当前所有数据 | `(nameList?: Path[], filterFunc?: (meta: { touched: boolean, validating: boolean }, notFilterUndefined?:boolean) => boolean) => any` | +| getValues | 获取表单内部维护的数据, 如果参数为空则返回当前所有数据 | `(nameList?: Path[], filterFunc?: (meta: { touched: boolean, validating: boolean }, notFilterUndefined?:boolean,notFilterHideData?:boolean) => boolean) => any` | | getHiddenValues | 获取隐藏的表单数据 | `() => any` | | getSchema | 获取表单的 schema | `()=> object` | | removeErrorField | 外部手动删除某一个 path 下所有的校验信息 | `(path: Path) => void` | | diff --git a/packages/form-render/src/models/useForm.ts b/packages/form-render/src/models/useForm.ts index 947765b45..5d5b45c15 100644 --- a/packages/form-render/src/models/useForm.ts +++ b/packages/form-render/src/models/useForm.ts @@ -163,10 +163,10 @@ const useForm = () => { } // 获取表单数据 - xform.getValues = (nameList?: any, filterFunc?: any, notFilterUndefined?:boolean) => { + xform.getValues = (nameList?: any, filterFunc?: any, notFilterUndefined?:boolean,notFilterHideData:boolean=true) => { let values = cloneDeep(form.getFieldsValue(getFieldName(nameList), filterFunc)); const { removeHiddenData } = storeRef.current?.getState() || {}; - if (removeHiddenData) { + if (notFilterHideData && removeHiddenData) { values = filterValuesHidden(values, flattenSchemaRef.current); } if (!notFilterUndefined) {