import React, { PureComponent, useState, useEffect } from 'react'
import { Modal, Row, Col, Table, Pagination, Button, Form, Input,message } from 'antd'
import EnDash from '../EnDash'
import AuthButton from '@/components/AuthButton';

import Style from './style.less'
import HotBlock from '../HotBlock'
import apis from '../../../../../../services/apis';
import request from '../../../../../../utils/request';

const BatchInvalid = props => {
  const taRaiseRecords = props.houseIds;
  function handleSubmit (e) {
    e.preventDefault();
    props.form.validateFields((err, values) => {
      if (!err){
        request({ ...apis.house.batchInvalidRaiseRecord, data: { ...values,taRaiseRecords },}).then((data) => {
          message.info("保存成功")
          props.onSuccess(false);
        }).catch((err) => {
          message.info(err.msg || err.message)
        })
      }
    });
  }

  const { getFieldDecorator } = props.form;

  return (
    <>
      <Modal footer={null} title="批量作废" visible={props.visible} onCancel={props.onCancel} width={600}>
        <span>所选XX条数据中，符合作废条件的有YY条，不符合作废条件的有ZZ条。确认将YY条数据作废?</span>
        <Form labelCol={{ span: 7 }} wrapperCol={{ span: 12 }} onSubmit={handleSubmit}>
          <Form.Item label="作废原因" labelAlign='left'>
            {getFieldDecorator('invalidReason', {
              rules: [{ required: true, message: ' 请输入作废原因' }],
            })(<Input label='left'/>)}
          </Form.Item>
          <Form.Item wrapperCol={{ span: 15, offset: 10 }}>
            <Button type="primary" htmlType="submit" >
              提交
            </Button>
          </Form.Item>
        </Form>
        <div>
          <font style={{color:'#999'}}>作废条件：未作废的认筹单。</font><br/>
          <font style={{color:'#999'}}>注意：</font><br/>
          <font style={{color:'#999'}}>作废的认筹单不可继续缴费，如果需要退费，仍然可以点击退费或批量线下退费。</font><br/>
          <font style={{color:'#999'}}>认筹单作废后，会释放已锁定的房源。</font>
        </div>
        
      </Modal>
    </>
  );
}

const WrappedBase = Form.create({ name: 'BatchInvalid' })(BatchInvalid);

export default WrappedBase