chore: 调整表格数据上下文 (#6906)

* chore: 调整表格数据上下文

* cards 也加一下
This commit is contained in:
liaoxuezhi 2023-05-17 17:32:37 +08:00 committed by GitHub
parent 5f71cbba9e
commit 4dec008c86
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 14 additions and 10 deletions

View File

@ -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
);

View File

@ -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
? {

View File

@ -2277,13 +2277,7 @@ export default class Table extends React.Component<TableProps, object> {
// 操作列不下发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,