import React from 'react';
import { connect } from 'dva';
import { DatePicker, Input } from 'antd';
import { DataTable, UdcSelect } from '../../../components';

const { RangePicker } = DatePicker;

const ReturnOrderForm = ({ dispatch, returnOrderForm, loading }) => {
  const { list, total } = returnOrderForm;

  const domain = 'returnOrderForm';
  const domainCN = '退货单列表';

  const tableProps = {
    rowKey: 'id',
    scroll: {
      x: '100%',
      y: 400,
    },
    domain,
    dispatch,
    loading,
    showAdd: false,
    showDelete: false,
    showEdit: false,
    total,
    dataSource: list,
    filter: [{
      title: '退货单编号',
      dataIndex: 'productCode',
      tag: <Input placeholder='请输入编号' />,
    }, {
      title: '退货状态',
      dataIndex: 'productClass1Name',
      options: {
        initialValue: '待确认',
      },
      tag: <UdcSelect domain="EDP" code="YES_NO_FLAG" />,
    }, {
      title: '出库日期',
      dataIndex: 'deadlineTime',
      tag: (<RangePicker style={{ width: '100%' }} />),
    }, {
      title: '供应商',
      dataIndex: 'productName',
      tag: <Input placeholder='请输入编号/名称' />,
    }, {
      title: '退货单位',
      dataIndex: 'modeTypeName',
      tag: <Input placeholder='请输入编号/名称' />,
    }],
    columns: [{
      title: '退货单编号',
      dataIndex: 'productCode',
      width: '9%',
    }, {
      title: '供应商名称',
      dataIndex: 'bidDeadline',
      width: '10%',
      className: 'alignLeft',
    }, {
      title: '总金额',
      dataIndex: 'amount',
      width: '5%',
      className: 'alignRight',
    }, {
      title: '退货单位',
      dataIndex: 'productName',
      width: '15%',
      className: 'alignLeft',
    }, {
      title: '退货状态',
      dataIndex: 'productClass1',
      width: '5%',
    }, {
      title: '出库日期',
      dataIndex: 'productUnit',
      width: '6%',
    }, {
      title: '制单日期',
      dataIndex: 'productModel',
      width: '6%',
    }],
  };

  return (
    <div className="content-inner">
      <DataTable {...tableProps} />
    </div>
  );

};

export default connect(({ returnOrderForm, loading }) => ({ returnOrderForm, loading }))(ReturnOrderForm);
