From 01294d3c83a053960b790eafac7d697488a083d7 Mon Sep 17 00:00:00 2001 From: chenos Date: Tue, 21 Mar 2023 09:58:12 +0800 Subject: [PATCH] fix(collection-manager): remove __parent --- .../Configuration/EditCollectionAction.tsx | 13 ++++++++----- .../client/src/collection-manager/action-hooks.ts | 3 ++- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/packages/core/client/src/collection-manager/Configuration/EditCollectionAction.tsx b/packages/core/client/src/collection-manager/Configuration/EditCollectionAction.tsx index 981eae8e78..59d5d5da1f 100644 --- a/packages/core/client/src/collection-manager/Configuration/EditCollectionAction.tsx +++ b/packages/core/client/src/collection-manager/Configuration/EditCollectionAction.tsx @@ -1,8 +1,8 @@ import { ArrayTable } from '@formily/antd'; import { ISchema, useForm } from '@formily/react'; import { uid } from '@formily/shared'; -import { omit } from 'lodash'; import cloneDeep from 'lodash/cloneDeep'; +import omit from 'lodash/omit'; import React, { useEffect, useState } from 'react'; import { useTranslation } from 'react-i18next'; import { useRequest } from '../../api-client'; @@ -78,10 +78,13 @@ const getSchema = (schema: IField, record: any, compile, getContainer): ISchema export const useValuesFromRecord = (options) => { const record = useRecord(); - const result = useRequest(() => Promise.resolve({ data: { autoGenId: true, ...record,category:record?.category.map((v)=>v.id) } }), { - ...options, - manual: true, - }); + const result = useRequest( + () => Promise.resolve({ data: { ...omit(record, ['__parent']), category: record?.category.map((v) => v.id) } }), + { + ...options, + manual: true, + }, + ); const ctx = useActionContext(); useEffect(() => { if (ctx.visible) { diff --git a/packages/core/client/src/collection-manager/action-hooks.ts b/packages/core/client/src/collection-manager/action-hooks.ts index f9fcd5249c..7c4b363f34 100644 --- a/packages/core/client/src/collection-manager/action-hooks.ts +++ b/packages/core/client/src/collection-manager/action-hooks.ts @@ -1,5 +1,6 @@ import { useField, useForm } from '@formily/react'; import { message } from 'antd'; +import omit from 'lodash/omit'; import { useEffect } from 'react'; import { useCollection, useCollectionManager } from '.'; import { useRequest } from '../api-client'; @@ -21,7 +22,7 @@ export const useCancelAction = () => { export const useValuesFromRecord = (options) => { const record = useRecord(); - const result = useRequest(() => Promise.resolve({ data: record }), { + const result = useRequest(() => Promise.resolve({ data: omit(record, ['__parent']) }), { ...options, manual: true, });