Commit cec9fbcd authored by Bill's avatar Bill

fix: niceForm currentState不存在问题

parent a68d4ac3
......@@ -29,6 +29,7 @@ import SmilingFace from './components/SmilingFace';
import AntUpload from './components/AntUpload';
import './index.less'
import { currentStateType, getCurrentState } from './utils/keepAlive';
import { useRouteMatch } from 'umi';
export interface NiceFormProps extends IAntdSchemaFormProps {}
......@@ -102,15 +103,24 @@ export const componentExport = {
}
const NiceForm: React.FC<NiceFormProps> = props => {
const { children, components, ...reset } = props;
const match = useRouteMatch();
const defineComponents = Object.assign(componentExport, components);
useEffect(() => {
let paginationInfo: currentStateType = getCurrentState();
// @ts-ignore
reset.actions.setFormState(
state => (state.values = paginationInfo.queryParams),
);
// 一般 列表检索传入的 controlRender 的 NiceForm 是没有 value 或者 initialValues 的
// value 或者 initialValues 的,表单页有
if (
paginationInfo && match.path === paginationInfo.pathname
&& !('value' in reset)
&& !('initialValues' in reset)
) {
// @ts-ignore
reset.actions.setFormState(
state => (state.values = paginationInfo.queryParams),
);
}
}, [])
return (
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment