fix: subtable copy error

This commit is contained in:
sealday 2024-03-15 17:34:32 +08:00
parent 9af29e3e5c
commit d8590a6a95

View File

@ -11,7 +11,7 @@ import { isPortalInBody } from '@nocobase/utils/client';
import { useMemoizedFn } from 'ahooks'; import { useMemoizedFn } from 'ahooks';
import { Table as AntdTable, TableColumnProps } from 'antd'; import { Table as AntdTable, TableColumnProps } from 'antd';
import { default as classNames, default as cls } from 'classnames'; import { default as classNames, default as cls } from 'classnames';
import _ from 'lodash'; import _, { each } from 'lodash';
import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react'; import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react';
import { useTranslation } from 'react-i18next'; import { useTranslation } from 'react-i18next';
import { DndContext, useDesignable, useTableSize } from '../..'; import { DndContext, useDesignable, useTableSize } from '../..';
@ -131,6 +131,11 @@ const useTableColumns = (props: { showDel?: boolean; isSubTable?: boolean }) =>
insertCount: 1, insertCount: 1,
}); });
field.value.splice(index + 1, 0, markRecordAsNew(_.cloneDeep(record))); field.value.splice(index + 1, 0, markRecordAsNew(_.cloneDeep(record)));
each(field.form.fields, (targetField, key) => {
if (!targetField) {
delete field.form.fields[key];
}
});
return field.onInput(field.value); return field.onInput(field.value);
}); });
}} }}