fix: clearFormGraph (#1706)
This commit is contained in:
parent
0450789d63
commit
2e95d3bf85
@ -59,6 +59,7 @@ const FormDecorator: React.FC<FormProps> = (props) => {
|
|||||||
const getLinkageRules = (fieldSchema) => {
|
const getLinkageRules = (fieldSchema) => {
|
||||||
let linkageRules = null;
|
let linkageRules = null;
|
||||||
fieldSchema.mapProperties((schema) => {
|
fieldSchema.mapProperties((schema) => {
|
||||||
|
console.log(schema);
|
||||||
if (schema['x-linkage-rules']) {
|
if (schema['x-linkage-rules']) {
|
||||||
linkageRules = schema['x-linkage-rules'];
|
linkageRules = schema['x-linkage-rules'];
|
||||||
}
|
}
|
||||||
@ -70,10 +71,8 @@ const WithForm = (props) => {
|
|||||||
const { form } = props;
|
const { form } = props;
|
||||||
const fieldSchema = useFieldSchema();
|
const fieldSchema = useFieldSchema();
|
||||||
const { setFormValueChanged } = useActionContext();
|
const { setFormValueChanged } = useActionContext();
|
||||||
const linkageRules = useMemo(
|
const linkageRules =
|
||||||
() => (getLinkageRules(fieldSchema) || fieldSchema.parent?.['x-linkage-rules'])?.filter((k) => !k.disabled) || [],
|
(getLinkageRules(fieldSchema) || fieldSchema.parent?.['x-linkage-rules'])?.filter((k) => !k.disabled) || [];
|
||||||
[fieldSchema.properties?.grid?.['x-linkage-rules']],
|
|
||||||
);
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const id = uid();
|
const id = uid();
|
||||||
form.addEffects(id, () => {
|
form.addEffects(id, () => {
|
||||||
@ -119,7 +118,6 @@ const WithForm = (props) => {
|
|||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const id = uid();
|
const id = uid();
|
||||||
const linkagefields = [];
|
const linkagefields = [];
|
||||||
const formGraph = form.getFormGraph();
|
|
||||||
form.addEffects(id, () => {
|
form.addEffects(id, () => {
|
||||||
return linkageRules.map((v, index) => {
|
return linkageRules.map((v, index) => {
|
||||||
return v.actions?.map((h) => {
|
return v.actions?.map((h) => {
|
||||||
@ -142,8 +140,6 @@ const WithForm = (props) => {
|
|||||||
});
|
});
|
||||||
return () => {
|
return () => {
|
||||||
form.removeEffects(id);
|
form.removeEffects(id);
|
||||||
form.clearFormGraph();
|
|
||||||
form.setFormGraph(formGraph);
|
|
||||||
};
|
};
|
||||||
}, [linkageRules]);
|
}, [linkageRules]);
|
||||||
return fieldSchema['x-decorator'] === 'Form' ? <FormDecorator {...props} /> : <FormComponent {...props} />;
|
return fieldSchema['x-decorator'] === 'Form' ? <FormDecorator {...props} /> : <FormComponent {...props} />;
|
||||||
|
Loading…
Reference in New Issue
Block a user