diff --git a/packages/core/client/src/block-provider/hooks/index.ts b/packages/core/client/src/block-provider/hooks/index.ts index e4793f26d..dadd215ec 100644 --- a/packages/core/client/src/block-provider/hooks/index.ts +++ b/packages/core/client/src/block-provider/hooks/index.ts @@ -151,7 +151,7 @@ export const useCreateActionProps = () => { const { modal } = App.useApp(); const variables = useVariables(); const localVariables = useLocalVariables({ currentForm: form }); - const { getActiveFieldsName } = useFormActiveFields(); + const { getActiveFieldsName } = useFormActiveFields() || {}; const action = actionField.componentProps.saveMode || 'create'; const filterKeys = actionField.componentProps.filterKeys?.checked || []; @@ -199,7 +199,7 @@ export const useCreateActionProps = () => { fieldNames, getField, resource, - actionFields: getActiveFieldsName('form'), + actionFields: getActiveFieldsName?.('form') || [], }); // const values = omitBy(formValues, (value) => isEqual(JSON.stringify(value), '[{}]')); if (addChild) { @@ -265,7 +265,7 @@ export const useAssociationCreateActionProps = () => { const currentRecord = useRecord(); const variables = useVariables(); const localVariables = useLocalVariables({ currentForm: form }); - const { getActiveFieldsName } = useFormActiveFields(); + const { getActiveFieldsName } = useFormActiveFields() || {}; const action = actionField.componentProps.saveMode || 'create'; const filterKeys = actionField.componentProps.filterKeys?.checked || []; @@ -313,7 +313,7 @@ export const useAssociationCreateActionProps = () => { fieldNames, getField, resource, - actionFields: getActiveFieldsName('form'), + actionFields: getActiveFieldsName?.('form') || [], }); if (addChild) { const treeParentField = getTreeParentField(); @@ -771,7 +771,7 @@ export const useCustomizeRequestActionProps = () => { const actionField = useField(); const { setVisible } = useActionContext(); const { modal } = App.useApp(); - const { getActiveFieldsName } = useFormActiveFields(); + const { getActiveFieldsName } = useFormActiveFields() || {}; return { async onClick() { @@ -797,7 +797,7 @@ export const useCustomizeRequestActionProps = () => { fieldNames, getField, resource, - actionFields: getActiveFieldsName('form'), + actionFields: getActiveFieldsName?.('form') || [], }); Object.assign(data, values); } @@ -863,7 +863,7 @@ export const useUpdateActionProps = () => { const data = useParamsFromRecord(); const variables = useVariables(); const localVariables = useLocalVariables({ currentForm: form }); - const { getActiveFieldsName } = useFormActiveFields(); + const { getActiveFieldsName } = useFormActiveFields() || {}; return { async onClick() { @@ -908,7 +908,7 @@ export const useUpdateActionProps = () => { fieldNames, getField, resource, - actionFields: getActiveFieldsName('form'), + actionFields: getActiveFieldsName?.('form') || [], }); actionField.data = field.data || {}; actionField.data.loading = true; diff --git a/packages/core/client/src/schema-settings/VariableInput/hooks/useFormVariable.ts b/packages/core/client/src/schema-settings/VariableInput/hooks/useFormVariable.ts index e547165ca..001827473 100644 --- a/packages/core/client/src/schema-settings/VariableInput/hooks/useFormVariable.ts +++ b/packages/core/client/src/schema-settings/VariableInput/hooks/useFormVariable.ts @@ -19,7 +19,7 @@ interface Props { * @returns */ export const useFormVariable = ({ collectionName, collectionField, schema, noDisabled, targetFieldSchema }: Props) => { - const { getActiveFieldsName } = useFormActiveFields(); + const { getActiveFieldsName } = useFormActiveFields() || {}; const { t } = useTranslation(); const result = useBaseVariable({ collectionField, @@ -31,7 +31,7 @@ export const useFormVariable = ({ collectionName, collectionField, schema, noDis collectionName: collectionName, noDisabled, returnFields: (fields, option) => { - const activeFieldsName = getActiveFieldsName('form'); + const activeFieldsName = getActiveFieldsName?.('form') || []; return option.depth === 0 ? fields.filter((field) => { diff --git a/packages/core/client/src/schema-settings/VariableInput/hooks/useIterationVariable.ts b/packages/core/client/src/schema-settings/VariableInput/hooks/useIterationVariable.ts index f56c7ed4f..0cfe4f432 100644 --- a/packages/core/client/src/schema-settings/VariableInput/hooks/useIterationVariable.ts +++ b/packages/core/client/src/schema-settings/VariableInput/hooks/useIterationVariable.ts @@ -23,7 +23,7 @@ export const useIterationVariable = ({ /** 消费变量值的字段 */ targetFieldSchema?: Schema; }) => { - const { getActiveFieldsName } = useFormActiveFields(); + const { getActiveFieldsName } = useFormActiveFields() || {}; const { t } = useTranslation(); const result = useBaseVariable({ collectionField, @@ -35,7 +35,7 @@ export const useIterationVariable = ({ collectionName: currentCollection, noDisabled, returnFields: (fields, option) => { - const activeFieldsName = getActiveFieldsName('nester'); + const activeFieldsName = getActiveFieldsName?.('nester') || []; return option.depth === 0 ? fields.filter((field) => { diff --git a/packages/plugins/@nocobase/plugin-workflow/src/client/triggers/form.tsx b/packages/plugins/@nocobase/plugin-workflow/src/client/triggers/form.tsx index b96cec608..41b64c49a 100644 --- a/packages/plugins/@nocobase/plugin-workflow/src/client/triggers/form.tsx +++ b/packages/plugins/@nocobase/plugin-workflow/src/client/triggers/form.tsx @@ -141,7 +141,7 @@ export function useTriggerWorkflowsActionProps() { const currentRecord = useRecord(); const currentUserContext = useCurrentUserContext(); const { modal } = App.useApp(); - const { getActiveFieldsName } = useFormActiveFields(); + const { getActiveFieldsName } = useFormActiveFields() || {}; const currentUser = currentUserContext?.data?.data; const filterKeys = actionField.componentProps.filterKeys || []; @@ -174,7 +174,7 @@ export function useTriggerWorkflowsActionProps() { if (!skipValidator) { await form.submit(); } - const values = getFormValues({ filterByTk, form, getField, actionFields: getActiveFieldsName('form') }); + const values = getFormValues({ filterByTk, form, getField, actionFields: getActiveFieldsName?.('form') || [] }); // const values = omitBy(formValues, (value) => isEqual(JSON.stringify(value), '[{}]')); if (addChild) { const treeParentField = getTreeParentField();