diff --git a/packages/app/src/components/form.fields/sub-table/Table.tsx b/packages/app/src/components/form.fields/sub-table/Table.tsx index ed932ab6f..4c5f3fb62 100644 --- a/packages/app/src/components/form.fields/sub-table/Table.tsx +++ b/packages/app/src/components/form.fields/sub-table/Table.tsx @@ -42,17 +42,26 @@ export default function Table(props: SimpleTableProps) { resourceKey: 'simple' })); + const [dataSource, setDataSource] = useState(value.map((item, index) => { + if (item.__id) { + return item; + }; + return {...item, __id: generateIndex()}; + })) + if (loading) { return } + // console.log('dataSource', dataSource); return (
{ console.log({selectedRowKeys}) - const newValues = value.filter(item => selectedRowKeys.indexOf(item.__id) === -1); + const newValues = dataSource.filter(item => selectedRowKeys.indexOf(item.__id) === -1); + setDataSource(newValues); onChange(newValues); }}> @@ -67,32 +76,28 @@ export default function Table(props: SimpleTableProps) {
{ console.log(values); - const newVaules = [...value]; + const newVaules = [...dataSource]; if (typeof index === 'undefined') { newVaules.push({...values, __id: generateIndex()}) } else { newVaules[index] = values; } + setDataSource(newVaules); onChange(newVaules); - console.log(newVaules); + // console.log(newVaules); }} ref={drawerRef}/> { }} components={components({ data: { - list: value.map((item, index) => { - if (item.__id) { - return item; - }; - return {...item, __id: generateIndex()}; - }), + list: dataSource, }, mutate: (values) => { onChange(values.list);