import { DeleteOutlined, EditOutlined } from '@ant-design/icons';
import { Button, Space, Table } from 'antd';
import { ColumnsType } from 'antd/lib/table';
import React, { useMemo } from 'react';
import { CrudContext } from '../../../../components/crud/useCrud';
import { PageTableContext } from '../../../../components/crud/usePageTable';
import { QualityManageTab3 } from '../../../../service/def';
import { renYYYYMMDD } from '../../../../utils/renutil';

type IProps = {
  pagerCtx: PageTableContext<QualityManageTab3>;
  crudCtx: CrudContext
}

const DataTable: React.FC<IProps> = ({ pagerCtx, crudCtx }) => {

  const columns = useMemo<ColumnsType<QualityManageTab3>>(() => [

    { title: '缺陷所在单位工程', key: 'qxszdwgc', dataIndex: 'qxszdwgc' },
    { title: '缺陷部位', key: 'qxbw', dataIndex: 'qxbw' },
    { title: '缺陷类别', key: 'qxlb', dataIndex: 'qxlb' },
    { title: '施工单位', key: 'sgdw', dataIndex: 'sgdw' },
    { title: '填写日期', key: 'txrq', dataIndex: 'txrq' },
    {
      title: '操作', key: '_', render: rec => (
        <Space>
          <Button icon={<EditOutlined />} type="link" />
          <Button icon={<DeleteOutlined />} type="link" danger />
        </Space>
      )
    }
  ], []);

  return (

    <Table rowKey="id" columns={columns} {...pagerCtx.tableProps} />

  )
}

export default DataTable
