29 lines
798 B
JavaScript
29 lines
798 B
JavaScript
import TablePro from "@cqsjjb/jjb-react-admin-component/Table";
|
|
import { getIndexColumn } from "../../utils/index";
|
|
import "./index.less";
|
|
|
|
function Table(props) {
|
|
const {
|
|
columns = [],
|
|
showIndexColumn = true,
|
|
useAlignCenter = true,
|
|
indexColumnFixed = "left",
|
|
rowKey = "id",
|
|
...restProps
|
|
} = props;
|
|
function calcColumns() {
|
|
showIndexColumn && columns.unshift({...getIndexColumn(props.pagination), fixed: indexColumnFixed});
|
|
|
|
const setAlign = (column) => ({
|
|
...column,
|
|
align: useAlignCenter ? "center" : "left",
|
|
...(column.children ? { children: column.children.map(setAlign) } : {})
|
|
});
|
|
|
|
return columns.map(setAlign);
|
|
}
|
|
return <TablePro rowKey={rowKey} columns={calcColumns()} bordered {...restProps} />;
|
|
}
|
|
|
|
export default Table;
|