import { history } from 'umi';
import { Button } from 'antd'
import { PageHeaderWrapper } from '@ant-design/pro-layout';
import moment from 'moment';
import PageTable from '@/components/PageTable';
import { getWarnList } from '@/services/order'

const formatterTime = (val) => {
  return val ? moment(val).format('YYYY-MM-DD') : '';
};
export default (props) => {
  const getOrderDetail = (val) => {
    history.push(`./detail.jsx?id=${val}`);
  }
  const columns = [
    {
      title: '预警时间',
      dataIndex: 'createDate',
      key: 'createDate',
      render: (t) => formatterTime(t),
      search: false,
      width: 120
    },
    {
      title: '接单人',
      dataIndex: 'workName',
      key: 'workName',
      search: false,
    },
    {
      title: '消息',
      dataIndex: 'orderNo',
      key: 'orderNo',
      render: (_, record) => '您有一个 ' + record.orderNo + ' 订单将于 ' + formatterTime(record.appointmentDate) + ' 预约作业，请尽快处理'
    },
    {
      title: '操作',
      valueType: 'option',
      render: (_, record) => [
        <Button style={{ padding: 0 }} type="link" key={1} onClick={() => getOrderDetail(record.orderId)}>
          订单详情
        </Button>
      ],
    },
  ];

  return (
    <PageHeaderWrapper>
      <PageTable
        request={getWarnList}
        columns={columns}
        rowKey="orderId"
        options={false}
        search={false}
        scroll={{ x: 1000 }}
      />
    </PageHeaderWrapper>
  );
};
