diff --git a/src/renderers/Form/Table.tsx b/src/renderers/Form/Table.tsx index e10ab24e0..e8ac463a0 100644 --- a/src/renderers/Form/Table.tsx +++ b/src/renderers/Form/Table.tsx @@ -10,6 +10,7 @@ import omit from 'lodash/omit'; import {dataMapping} from '../../utils/tpl-builtin'; import findIndex from 'lodash/findIndex'; import memoize from 'lodash/memoize'; +import { SimpleMap } from '../../utils/SimpleMap'; export interface TableProps extends FormControlProps { placeholder?: string; @@ -70,7 +71,7 @@ export default class FormTable extends React.Component { 'deleteApi' ]; - entries: Map; + entries: SimpleMap; entityId: number = 1; subForms: any = {}; editting: any = {}; @@ -82,7 +83,7 @@ export default class FormTable extends React.Component { editIndex: -1 }; - this.entries = new Map(); + this.entries = new SimpleMap(); this.buildItemProps = this.buildItemProps.bind(this); this.confirmEdit = this.confirmEdit.bind(this); this.cancelEdit = this.cancelEdit.bind(this); @@ -93,7 +94,7 @@ export default class FormTable extends React.Component { } componentWillUnmount() { - this.entries.clear(); + this.entries.dispose(); this.buildItems.cache.clear?.(); } @@ -544,7 +545,7 @@ export default class FormTable extends React.Component { newValue.splice(rowIndexes as number, 0, data); this.entries.set(data, this.entries.get(origin) || this.entityId++); - this.entries.delete(origin); + // this.entries.delete(origin); // 反正最后都会清理的,先不删了吧。 } onChange(newValue); diff --git a/src/utils/SimpleMap.ts b/src/utils/SimpleMap.ts index 214514575..2ab9bf9ff 100644 --- a/src/utils/SimpleMap.ts +++ b/src/utils/SimpleMap.ts @@ -7,6 +7,11 @@ export class SimpleMap { value: V; }> = []; + has(key: K) { + const resolved = find(this.list, item => item.key === key); + return !!resolved; + } + set(key: K, value: V) { this.list.push({ key,