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

const PurchaseTotal = ({ dispatch, purchaseTotal, ouBanks, loading }) => {
  const { list, total, currentItem, modalVisible, mode } = purchaseTotal;

  const domain = 'purchaseTotal';
  const domainCN = '采购总量统计表';

  const tableProps = {
    rowKey: 'id',
    sortBy: 'start',
    scroll: { x: '100%', y: 400 },
    domain,
    dispatch,
    loading,
    total,
    showAdd: false,
    enableSelection: false,
    dataSource: list,
    filter: [{
      title: '起始时间',
      dataIndex: 'startDate',
      tag: <DatePicker
        format="YYYY-MM-DD"
        style={{ width: '100%' }} />,
      options: {
        initialValue: '',
      },
    }, {
      title: '截止时间',
      dataIndex: 'endDate',
      options: {
        initialValue: '',
      },
      tag: <DatePicker
        format="YYYY-MM-DD"
        style={{ width: '100%' }} />,
    }, {
      title: '采购单号',
      dataIndex: 'poCode',
      options: {
        initialValue: '',
      },
    }, {
      title: '物料名称',
      dataIndex: 'item',
      options: {
        initialValue: '',
      },
    }],
    columns: [{
      title: '采购单号',
      dataIndex: 'poCode',
      width: '20%',
    }, {
      title: '物料编号',
      className: 'column-money',
      dataIndex: 'itemCode',
      width: '20%',
    }, {
      title: '物料名称',
      dataIndex: 'item',
      width: '20%',
    }, {
      title: '采购总量',
      dataIndex: 'purchaseTotal',
      width: '10%',
    }, {
      title: '计量单位',
      dataIndex: 'unit',
      width: '10%',
    }, {
      title: '规格',
      dataIndex: 'specification',
      width: '20%',
    }],
  };

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

export default connect(({ purchaseTotal, ouBanks, loading }) => ({ purchaseTotal, ouBanks, loading }))(PurchaseTotal);
