| | |
| | | } |
| | | |
| | | componentDidMount() { |
| | | let { page, size } = this.props.formData; |
| | | let { page = 1, size } = this.props.formData; |
| | | this.loadData(page, size); |
| | | } |
| | | |
| | |
| | | size |
| | | } |
| | | }).then(res => { |
| | | if (res) { |
| | | res.content = res.content.map(({ ...a }, idx) => ({ |
| | | ...a, |
| | | index: idx + 1 + 10 * (page - 1), |
| | | key: idx, |
| | | })); |
| | | } |
| | | this.setState({ |
| | | tableData: res ? res.content : [], |
| | | loading: false, |
| | | totalElements: res ? res.totalElements : 0, |
| | | }); |
| | | if (res && res) |
| | | if (res) { |
| | | if (res.content) { |
| | | res.content = res.content.map(({ ...a }, idx) => ({ |
| | | ...a, |
| | | index: idx + 1 + 10 * (page - 1), |
| | | key: idx, |
| | | })); |
| | | this.setState({ |
| | | tableData: res ? res.content : [], |
| | | loading: false, |
| | | totalElements: res ? res.totalElements : 0, |
| | | }); |
| | | } else { |
| | | res = res.map(({ ...a }, idx) => ({ |
| | | ...a, |
| | | index: idx + 1 + 10 * (page - 1), |
| | | key: idx, |
| | | })); |
| | | this.setState({ |
| | | tableData: res, |
| | | loading: false, |
| | | }) |
| | | } |
| | | } |
| | | }); |
| | | }; |
| | | |
| | |
| | | return originalElement; |
| | | }; |
| | | |
| | | onSetDataSource = ({ index, data }, callBack) => { |
| | | console.log(index, data); |
| | | let { tableData } = this.state; |
| | | tableData[index] = data; |
| | | this.setState({ |
| | | tableData |
| | | }) |
| | | } |
| | | |
| | | render() { |
| | | const { columns, rowSelection } = this.props; |
| | | const { page, size } = this.props.formData; |
| | | const { columns, rowSelection, showPagination = true } = this.props; |
| | | const { page, size, } = this.props.formData; |
| | | return ( |
| | | <div className="table-view-main"> |
| | | <Table |
| | |
| | | dataSource={this.state.tableData} |
| | | loading={{ spinning: this.state.loading }} |
| | | columns={columns} |
| | | pagination={{ |
| | | pagination={showPagination ? { |
| | | pageSize: Number(size), |
| | | onChange: this.pageChange, |
| | | total: this.state.totalElements, |
| | |
| | | showQuickJumper: true, |
| | | defaultCurrent: 1, |
| | | current: Number(page), |
| | | }} /> |
| | | } : false} /> |
| | | </div> |
| | | ) |
| | | } |