zy-react-library/components/Table/index.js

29 lines
798 B
JavaScript
Raw Normal View History

2025-11-12 15:51:18 +08:00
import TablePro from "@cqsjjb/jjb-react-admin-component/Table";
2025-10-22 14:43:42 +08:00
import { getIndexColumn } from "../../utils/index";
2025-10-29 09:38:36 +08:00
import "./index.less";
2025-10-22 14:43:42 +08:00
2025-11-12 15:46:41 +08:00
function Table(props) {
2025-10-22 14:43:42 +08:00
const {
columns = [],
2025-11-05 09:17:28 +08:00
showIndexColumn = true,
2025-10-22 14:43:42 +08:00
useAlignCenter = true,
2025-11-05 09:17:28 +08:00
indexColumnFixed = "left",
2025-10-29 09:38:36 +08:00
rowKey = "id",
2025-10-22 14:43:42 +08:00
...restProps
} = props;
function calcColumns() {
2025-11-05 09:17:28 +08:00
showIndexColumn && columns.unshift({...getIndexColumn(props.pagination), fixed: indexColumnFixed});
2025-11-13 17:45:55 +08:00
const setAlign = (column) => ({
align: useAlignCenter ? "center" : "left",
2025-11-13 17:47:12 +08:00
...column,
2025-11-13 17:45:55 +08:00
...(column.children ? { children: column.children.map(setAlign) } : {})
});
return columns.map(setAlign);
2025-10-22 14:43:42 +08:00
}
2025-11-13 17:45:55 +08:00
return <TablePro rowKey={rowKey} columns={calcColumns()} bordered {...restProps} />;
2025-10-22 14:43:42 +08:00
}
2025-11-12 15:46:41 +08:00
export default Table;