import React from 'react';

import { DatePicker, Input } from 'antd';
import { CascaderItem, SupplierPicker } from '@bizComponents';

const TextArea = Input.TextArea;
const RangePicker = DatePicker.RangePicker;

const config = (formData, mode) => {
// 基本信息form
  const basicForm = [{
    title: '故障卡编号',
    dataIndex: 'cardCode',
  }, {
    title: '整改计划开始日',
    dataIndex: 'beginDate',
    tag: <DatePicker style={{ width: '100%' }}/>,
  }, {
    title: '时间点',
    dataIndex: 'improveDate',
    tag: <DatePicker style={{ width: '100%' }}/>,
  }, {
    title: '整机起始编号',
    dataIndex: 'newMachineCode',
    tag: <Input/>,
  }, {
    title: '单据状态',
    dataIndex: 'status',
    options: {
      rules: [{
        required: true,
        message: '必填',
      }],
    },
    tag: <Input disabled={false}/>,
  }, {
    title: '创建人',
    dataIndex: 'createName',
    options: {
      rules: [{
        required: true,
        message: '必填',
      }, {
        type: 'email',
        message: '请输入邮箱',
      }],
    },
    tag: <Input disabled={false}/>,
  }, {
    title: '整改计划',
    dataIndex: 'correctionPlan',
    tag: <TextArea autosize={{ minRows: 3, maxRows: 3 }}/>,
  }];

  const basicBank = [{
    title: '故障卡编号',
    dataIndex: 'cardCode',
  }, {
    title: '整改计划开始日',
    dataIndex: 'beginDate',
    tag: <DatePicker style={{ width: '100%' }} disabled={true}/>,
  }, {
    title: '时间点',
    dataIndex: 'improveDate',
    tag: <DatePicker style={{ width: '100%' }} disabled={true}/>,
  }, {
    title: '整机起始编号',
    dataIndex: 'newMachineCode',
    tag: <Input/>,
  }, {
    title: '单据状态',
    dataIndex: 'status',
    tag: <Input disabled={false}/>,
  }, {
    title: '创建人',
    dataIndex: 'createName',
    tag: <Input disabled={false}/>,
  }, {
    title: '整改计划',
    dataIndex: 'correctionPlan',
    tag: <TextArea disabled={true} autosize={{ minRows: 3, maxRows: 3 }}/>,
  }];

  const bankList = [{
    title: '预警级别',
    dataIndex: 'warnLevelCode',
    width: '15%',
    render: (value, row, index) => {
      return (<Input
        size="small"
        value={value}
      />);
    },
  }, {
    title: '告警天数',
    dataIndex: 'warnDays',
    width: '15%',
    required: true,
    render: (value, row, index) => {
      return (<Input
        size="small"
        defaultValue={value}
      />);
    },
  }, {
    title: '新机编号',
    dataIndex: 'newMachineCode',
    width: '15%',
    required: true,
    render: (value, row, index) => {
      return (<Input
        size="small"
        defaultValue={value}
      />);
    },
  }, {
    title: '供应商',
    dataIndex: 'supplier',
    width: '20%',
    required: true,
    render: (value, row, index) => {
      return (<SupplierPicker value={value} onChange={() => {
      }}/>);
    },
  }, {
    title: '物料品类',
    dataIndex: 'cc',
    width: '20%',
    required: true,
    render: (value, row, index) => {
      return (<CascaderItem value={value} onChange={() => {
      }}/>);
    },
  }];

  const buttons = [{
    id: 'save',
    text: '保存',
    type: 'primary',
    onClick: () => {
      console.log('press save');
    },
  }, {
    id: 'submit',
    text: '提交',
    type: 'primary',
    onClick: () => {
      console.log('press submit');
    },
  }, {
    id: 'advice',
    placeholder: '审批意见',
    onChange: (e) => {
      console.log('advice change', e.target.value);
    },
  }];

  return {
    buttons,
    bankList,
    basicForm,
    basicBank,
  };
};

export default config;
