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} // __parent={__parent}
data={value} data={value}
onChange={onChange} onChange={onChange}
associatedKey={__index||associatedKey} __index={__index}
associatedKey={associatedKey}
viewName={viewName} viewName={viewName}
type={'subTable'} type={'subTable'}
/> />

View File

@ -99,12 +99,15 @@ export function generateIndex(): string {
export function SubTable(props: any) { export function SubTable(props: any) {
const { const {
__parent, __parent,
__index,
schema = {}, schema = {},
associatedKey, associatedKey,
onChange, onChange,
size = 'middle', size = 'middle',
} = props; } = props;
console.log('subtable.associatedKey', associatedKey)
const { const {
fields = [], fields = [],
actions: defaultActions = [], actions: defaultActions = [],
@ -167,7 +170,7 @@ export function SubTable(props: any) {
const { type } = associationField; const { type } = associationField;
const { data = [], loading, mutate, refresh, run, params } = useRequest( const { data = [], loading, mutate, refresh, run, params } = useRequest(
(params = {}, ...args) => { (params = {}, ...args) => {
return !associatedKey || type === 'virtual' || type === 'json' return !(associatedKey||__index) || type === 'virtual' || type === 'json'
? Promise.resolve({ ? Promise.resolve({
data: (props.data || []).map(item => { data: (props.data || []).map(item => {
if (!item[rowKey]) { if (!item[rowKey]) {
@ -179,7 +182,7 @@ export function SubTable(props: any) {
: api : api
.resource(resourceName) .resource(resourceName)
.list({ .list({
associatedKey, associatedKey: __index||associatedKey,
perPage: -1, perPage: -1,
'fields[appends]': appends, 'fields[appends]': appends,
}) })