import React from 'react'
import moment from 'moment';
import { Badge, Image } from 'antd';
import { PageHeaderWrapper } from '@ant-design/pro-layout';
import { getAbnormalList } from '@/services/work'
import PageTable from '@/components/PageTable'

const formatterTime = (val) => {
  return val ? moment(val).format('YYYY-MM-DD HH:mm') : '';
};
export default (props) => {
  const columns = [
    {
      title: '企业名称',
      dataIndex: 'orgName',
      key: 'orgName',
    },
    {
      title: '申请人',
      dataIndex: 'userName',
      key: 'userName',
    },
    {
      title: '抗原截图',
      dataIndex: 'antigenImage',
      key: 'antigenImage',
      render: t => { t ? <Image src={t} width="64px" height="64px" /> : '' }
    },
    {
      title: '抗原结果',
      dataIndex: 'antigenIsNormal',
      key: 'antigenIsNormal',
      render: t => (
        <span>
          {t ? <Badge status="success" text="正常" /> : <Badge status="error" text="异常" />}
        </span>
      )
    },
    {
      title: '核酸截图',
      dataIndex: 'nucleicImage',
      key: 'nucleicImage',
      render: t => <Image src={t} width="64px" height="64px" />
    },
    {
      title: '核酸结果',
      dataIndex: 'nucleicIsNormal',
      key: 'nucleicIsNormal',
      render: t => (
        <span>
          {t ? <Badge status="success" text="正常" /> : <Badge status="error" text="异常" />}
        </span>
      )
    },
    {
      title: '申请时间',
      dataIndex: 'createDate',
      key: 'createDate',
      render: (t) => formatterTime(t),
    },
  ]

  return (
    <PageHeaderWrapper>
      <PageTable
        columns={columns}
        request={getAbnormalList}
        search={false}
        options={false}
        rowKey="formId"
      />
    </PageHeaderWrapper>
  )
}
