|
|
@@ -19,7 +19,9 @@ class Schema extends Component {
|
|
|
schemaID: props.schemaID || props.location.state.schemaID,
|
|
|
schemaName: props.schemaName || props.location.state.schemaName,
|
|
|
editSchemaName: '',
|
|
|
- data: ''
|
|
|
+ data: '',
|
|
|
+ page: '',
|
|
|
+ pageSize: ''
|
|
|
};
|
|
|
}
|
|
|
|
|
|
@@ -40,7 +42,18 @@ class Schema extends Component {
|
|
|
};
|
|
|
|
|
|
showTablePagination = (page, pageSize, data) => {
|
|
|
+ // console.log(page);
|
|
|
+ // console.log(pageSize);
|
|
|
+ // console.log(data);
|
|
|
+ // 这个之所以这么麻烦,是因为 'apollo 不能存数据' 而 '分页又得用数据展示',
|
|
|
+ // 所以展示 table 的时候分了两个,
|
|
|
+ // 首先进入展示 15个 , 这前 15 个没有任何问题。
|
|
|
+ // 如果数据多于 15个,在按下第二页的时候 将数据通过 antd 的分页组件的回调函数传入 state,之后 table 的展示由 this.state.data 来接管
|
|
|
+ // 但是这又引起一个问题,通过 this.state.data 的展示如果进行删除,是不会通过 apollo 的,这也意味着数据库被删除了,而页面还存在
|
|
|
+ // 于是,在使用 this.state.data 的页面的 deleteTableButton 组件内调用该函数,重新刷新 this.state.data
|
|
|
this.setState({
|
|
|
+ page,
|
|
|
+ pageSize,
|
|
|
data: data.slice((page-1)*pageSize, page*pageSize)
|
|
|
})
|
|
|
};
|
|
|
@@ -149,6 +162,9 @@ class Schema extends Component {
|
|
|
currentTableIndex={data.findIndex(obj => obj.name === table.name)}
|
|
|
schemaID={this.state.schemaID}
|
|
|
userID={userID}
|
|
|
+ showTablePagination={this.showTablePagination}
|
|
|
+ page={this.state.page}
|
|
|
+ pageSize={this.state.pageSize}
|
|
|
/>
|
|
|
</span>
|
|
|
</Col>
|
|
|
@@ -157,7 +173,7 @@ class Schema extends Component {
|
|
|
|
|
|
))
|
|
|
:
|
|
|
- data.slice(1, 15).map(table => (
|
|
|
+ data.slice(0, 15).map(table => (
|
|
|
<div key={table.name}
|
|
|
className={'schema-table-list-content'}>
|
|
|
<Row>
|
|
|
@@ -408,6 +424,8 @@ class DeleteTableButton extends Component {
|
|
|
schemaData: JSON.stringify(schemaCols)
|
|
|
}
|
|
|
});
|
|
|
+ this.props.showTablePagination?
|
|
|
+ this.props.showTablePagination(this.props.page, this.props.pageSize, schemaCols):(()=>{})()
|
|
|
}}>
|
|
|
|
|
|
</Icon>
|