diff --git a/packages/amis-core/src/store/list.ts b/packages/amis-core/src/store/list.ts index 6fe0a60ab..696434c22 100644 --- a/packages/amis-core/src/store/list.ts +++ b/packages/amis-core/src/store/list.ts @@ -39,9 +39,14 @@ export const Item = types }, get locals(): any { + const listStore = getParent(self, 2) as IListStore; return createObject( - extendObject((getParent(self, 2) as IListStore).data, { - index: self.index + extendObject(listStore.data, { + index: self.index, + + // 只有table时,也可以获取选中行 + selectedItems: listStore.selectedItems.map(item => item.data), + unSelectedItems: listStore.unSelectedItems.map(item => item.data) }), self.data ); diff --git a/packages/amis-core/src/store/table.ts b/packages/amis-core/src/store/table.ts index e89620d12..83d59c33f 100644 --- a/packages/amis-core/src/store/table.ts +++ b/packages/amis-core/src/store/table.ts @@ -174,12 +174,17 @@ export const Row = types children = self.children.map(item => item.locals); } + const table = getParent(self, self.depth * 2) as ITableStore; const parent = getParent(self, 2) as ITableStore; return createObject( extendObject((getParent(self, self.depth * 2) as ITableStore).data, { index: self.index, // todo 以后再支持多层,目前先一层 - parent: parent.storeType === Row.name ? parent.data : undefined + parent: parent.storeType === Row.name ? parent.data : undefined, + + // 只有table时,也可以获取选中行 + selectedItems: table.selectedRows.map(item => item.data), + unSelectedItems: table.unSelectedRows.map(item => item.data) }), children ? { diff --git a/packages/amis/src/renderers/Table/index.tsx b/packages/amis/src/renderers/Table/index.tsx index 7fcb9bcbc..219177bfe 100644 --- a/packages/amis/src/renderers/Table/index.tsx +++ b/packages/amis/src/renderers/Table/index.tsx @@ -2277,13 +2277,7 @@ export default class Table extends React.Component { // 操作列不下发loading,否则会导致操作栏里面的所有按钮都出现loading loading: column.type === 'operation' ? false : props.loading, btnDisabled: store.dragging, - data: this.props.selectable - ? extendObject(item.locals, { - // 只有table时,也可以获取选中行 - selectedItems: store.selectedRows.map(item => item.data), - unSelectedItems: store.unSelectedRows.map(item => item.data) - }) - : item.locals, + data: item.locals, value: column.name ? resolveVariable( column.name,