123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172 |
- import { DageTableActions } from "@dage/pc-components";
- import { Button, Table } from "antd";
- import { useCallback, useMemo, useState } from "react";
- import { useNavigate } from "react-router-dom";
- const DEFAULT_PARAMS = {
- pageNum: 1,
- pageSize: 20,
- };
- export default function BannerPage() {
- const navigate = useNavigate();
- const [list, setList] = useState<[]>([]);
- const [total, setTotal] = useState(0);
- const [loading, setLoading] = useState(false);
- const [params, setParams] = useState({
- ...DEFAULT_PARAMS,
- });
- const paginationChange = useCallback(
- () => (pageNum: number, pageSize: number) => {
- setParams({ ...params, pageNum, pageSize });
- },
- [params]
- );
- const COLUMNS = useMemo(() => {
- return [
- {
- title: "海报",
- dataIndex: "userName",
- },
- {
- title: "发布日期",
- dataIndex: "nickName",
- },
- {
- title: "操作",
- render: (item: any) => {
- return <DageTableActions onEdit={() => {}} onDelete={() => {}} />;
- },
- },
- ];
- }, []);
- return (
- <div>
- <div style={{ textAlign: "right" }}>
- <Button type="primary" onClick={() => navigate("/banner/create")}>
- 新增
- </Button>
- </div>
- <Table
- loading={loading}
- className="page-table"
- dataSource={list}
- columns={COLUMNS}
- rowKey="id"
- pagination={{
- showQuickJumper: true,
- position: ["bottomCenter"],
- showSizeChanger: true,
- current: params.pageNum,
- pageSize: params.pageSize,
- total,
- onChange: paginationChange(),
- }}
- />
- </div>
- );
- }
|