fix: __index

This commit is contained in:
chenos 2021-03-28 18:26:04 +08:00
parent 2b549ea259
commit 25c1aa8825
2 changed files with 7 additions and 3 deletions

View File

@ -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'}
/>

View File

@ -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,
})