oak-frontend-base/es/components/pagination/web.js

39 lines
1.6 KiB
JavaScript

import React from "react";
import { Pagination } from "antd";
import { LeftOutlined, RightOutlined } from "@ant-design/icons";
import Style from "./index.module.less";
export default function Render(props) {
const { style, className, oakPagination, oakFullpath, newTotal, showQuickJumper, showSizeChanger, size, showTotal, } = props.data;
const { t, setPageSize, setCurrentPage, setTotal } = props.methods;
const { pageSize, total, currentPage, more } = oakPagination || {};
const itemRender = (_, type, originalElement) => {
if (type === "prev") {
return (<a>
<LeftOutlined />
</a>);
}
if (type === "next") {
return (<a style={{
cursor: more ? "pointer" : "not-allowed",
color: more ? "#006cb7" : "rgba(0, 0, 0, 0.25)",
}} onClick={() => {
if (more && currentPage) {
setTotal();
setCurrentPage(currentPage + 1);
}
}}>
<RightOutlined />
</a>);
}
return originalElement;
};
if (!oakPagination) {
return null;
}
return (<Pagination className={more ? Style.pagination : Style.paginationNoMore} itemRender={itemRender} pageSize={pageSize} total={newTotal} current={currentPage} showQuickJumper={showQuickJumper} showSizeChanger={showSizeChanger} size={size} showTotal={showTotal} onShowSizeChange={(current, pageSize) => {
setPageSize(pageSize);
}} onChange={(page, pageSize) => {
setCurrentPage(page);
}}/>);
}