fix(collection-manager): remove __parent

This commit is contained in:
chenos 2023-03-21 09:58:12 +08:00
parent 2f66334996
commit 01294d3c83
2 changed files with 10 additions and 6 deletions

View File

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

View File

@ -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,
});