fix: avoid crashing

This commit is contained in:
Rain 2023-10-08 11:33:41 +08:00
parent 0c5ee4359b
commit 7739778ffc
4 changed files with 14 additions and 14 deletions

View File

@ -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;

View File

@ -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) => {

View File

@ -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) => {

View File

@ -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();