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 2bdd14feb..a7ba8c004 100644 --- a/packages/app/src/components/form.fields/sub-table/Table.tsx +++ b/packages/app/src/components/form.fields/sub-table/Table.tsx @@ -39,7 +39,8 @@ export default function Table(props: SimpleTableProps) { // __parent={__parent} data={value} onChange={onChange} - associatedKey={__index||associatedKey} + __index={__index} + associatedKey={associatedKey} viewName={viewName} type={'subTable'} /> diff --git a/packages/app/src/components/pages/AdminLoader/View/SubTable.tsx b/packages/app/src/components/pages/AdminLoader/View/SubTable.tsx index f26dd63b7..a69174f7f 100644 --- a/packages/app/src/components/pages/AdminLoader/View/SubTable.tsx +++ b/packages/app/src/components/pages/AdminLoader/View/SubTable.tsx @@ -99,12 +99,15 @@ export function generateIndex(): string { export function SubTable(props: any) { const { __parent, + __index, schema = {}, associatedKey, onChange, size = 'middle', } = props; + console.log('subtable.associatedKey', associatedKey) + const { fields = [], actions: defaultActions = [], @@ -167,7 +170,7 @@ export function SubTable(props: any) { const { type } = associationField; const { data = [], loading, mutate, refresh, run, params } = useRequest( (params = {}, ...args) => { - return !associatedKey || type === 'virtual' || type === 'json' + return !(associatedKey||__index) || type === 'virtual' || type === 'json' ? Promise.resolve({ data: (props.data || []).map(item => { if (!item[rowKey]) { @@ -179,7 +182,7 @@ export function SubTable(props: any) { : api .resource(resourceName) .list({ - associatedKey, + associatedKey: __index||associatedKey, perPage: -1, 'fields[appends]': appends, })