fix(tree-collection): cannot read properties of undefined (reading 'addChild')

This commit is contained in:
chenos 2023-03-21 18:09:09 +08:00
parent 0d36caf1c0
commit 81948f4f2c
2 changed files with 4 additions and 4 deletions

View File

@ -5,9 +5,8 @@ import isEmpty from 'lodash/isEmpty';
import React, { createContext, useContext, useEffect, useMemo, useRef } from 'react';
import { useCollection } from '../collection-manager';
import { RecordProvider, useRecord } from '../record-provider';
import { useDesignable } from '../schema-component';
import { useActionContext, useDesignable } from '../schema-component';
import { BlockProvider, useBlockRequestContext } from './BlockProvider';
import { useActionContext } from '../schema-component';
export const FormBlockContext = createContext<any>({});
@ -91,7 +90,7 @@ export const useFormBlockProps = () => {
const ctx = useFormBlockContext();
const record = useRecord();
const { fieldSchema } = useActionContext();
const { addChild } = fieldSchema?.['x-component-props']||{};
const addChild = fieldSchema?.['x-component-props']?.addChild;
useEffect(() => {
if (addChild) {
ctx.form.query('parent').take((field) => {

View File

@ -84,6 +84,7 @@ function getFormValues(filterByTk, field, form, fieldNames, getField, resource)
return omit({ ...form.values }, keys);
}
}
console.log('form.values', form.values);
return form.values;
let values = {};
for (const key in form.values) {
@ -151,7 +152,7 @@ export const useCreateActionProps = () => {
overwriteValues,
skipValidator,
} = actionSchema?.['x-action-settings'] ?? {};
const { addChild } = fieldSchema?.['x-component-props'];
const addChild = fieldSchema?.['x-component-props']?.addChild;
const assignedValues = parse(originalAssignedValues)({ currentTime: new Date(), currentRecord, currentUser });
if (!skipValidator) {
await form.submit();