From 25c1aa88255d951f8a3a39c6eaa9abe1206177b9 Mon Sep 17 00:00:00 2001 From: chenos Date: Sun, 28 Mar 2021 18:26:04 +0800 Subject: [PATCH] fix: __index --- .../app/src/components/form.fields/sub-table/Table.tsx | 3 ++- .../app/src/components/pages/AdminLoader/View/SubTable.tsx | 7 +++++-- 2 files changed, 7 insertions(+), 3 deletions(-) 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, })