import { UploadOutlined } from '@ant-design/icons';
import { ActionType, ProColumns } from '@ant-design/pro-table';
import ProTable from '@ant-design/pro-table';
import { Button, Card } from 'antd';
import React from 'react';
import { useRef } from 'react';

const data = [
    {
        id: 1,
        index: 1,
        title: 1,
        type: 0,
    },
    {
        id: 2,
        index: 2,
        title: 2,
        type: 1,
    },
    {
        id: 3,
        index: 3,
        title: 3,
        type: 2,
    },
    {
        id: 4,
        index: 4,
        title: 4,
        type: 2,
    },
]

const columns: ProColumns<any>[] = [
    {
        title: '序号',
        dataIndex: 'index',
        valueType: 'index',
        width: 48,
    },
    {
        title: '意见类型',
        dataIndex: 'type',
        valueType: 'select',
        valueEnum: {
            0: { text: '网络运营' },
            1: { text: '综合行政' },
            2: { text: '市场' },
        },
    },

    {
        title: '意见内容',
        dataIndex: 'title',
        ellipsis: true,
        hideInSearch: true,
    },
    {
        title: '补充信息',
        dataIndex: 'other',
        ellipsis: true,
        hideInSearch: true,
    },
    {
        title: '提交时间',
        key: 'showTime',
        dataIndex: 'created_at',
        valueType: 'dateTime',
        hideInSearch: true,
    },
    {
        title: '开始时间',
        dataIndex: 'starttime',
        valueType: 'date',
        hideInTable: true,
    },
    {
        title: '结束时间',
        dataIndex: 'endtime',
        valueType: 'date',
        hideInTable: true,
    },
    {
        title: '提交人员',
        dataIndex: 'people',
        hideInSearch: true,
    },
    {
        title: '附件管理',
        hideInSearch: true,
        render: (text, record, _, action) => [
            <Button type='text' key="download">
                下载附件
            </Button>,
        ],
    },
];

export default () => {
    const actionRef = useRef<ActionType>();
    return (
        <Card className="zjl-entrust confirm">
            <ProTable<any>
                columns={columns}
                actionRef={actionRef}
                request={async (params) => {
                    return {
                        data: data,
                        success: true,
                    };
                }}
                rowKey="id"
                options={false}
                pagination={{
                    pageSize: 10,
                    onChange: (page) => console.log(page),
                }}
                search={{
                    span: 6,
                    defaultCollapsed: false,//默认展开
                }}
                rowSelection={{}}
                dateFormatter="string"
                toolBarRender={() => [
                    <Button key="button" icon={<UploadOutlined />} type="primary">
                        全量导出
                    </Button>
                ]}
            />
        </Card>
    );
};