import {Component} from 'react';
import {Table as TTable} from 'tdesign-react';
import './index.less';
import Pagination from '@/js/components/Pagination/index';

class Index extends Component<any, any> {
    constructor(props) {
        super(props);
    }

    pageChange(value: number) {
        //通知父组件更新当前页面
        this.props.onPageChange(value);
    }

    render() {
        const {columns, data, style, pagination, pageNum, pageSize, total, className, maxHeight} = this.props;
        return (
            <div style={style ?? null} className={className}>
                <TTable rowKey={'index'} loading={this.props.loading ?? false} columns={columns} data={data}
                        className={['reset-t-table'].join(' ')}
                        maxHeight={maxHeight ?? ''}
                >
                </TTable>
                {
                    pagination && (
                        <Pagination onChange={this.pageChange} pageNum={pageNum}
                                    pageSize={pageSize} total={total}></Pagination>
                    )
                }
            </div>

        )
    }
}

export default Index;
