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 BatchDel = props => {
  const taRaiseRecords = props.demandIds;
  function handleSubmit (e) {
    e.preventDefault();
    props.form.validateFields((err, values) => {
      if (!err){
        request({ ...apis.taH5SampleManager.batchDelDemands, data: { taH5Demands: taRaiseRecords }, }).then((data) => {
          const resultMessage = '操作成功，其中'+data.successNum+'条成功删除，'+data.failNum+'条非作废/提交状态未删除。'
          message.info(resultMessage)
          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}>
        <div style={{textAlign:'center', marginBottom:'30px'}}><span style={{fontSize:'20px'}}>确认将所选{taRaiseRecords.length}条数据删除？</span></div>
        <div style={{textAlign:'center', marginBottom:'15px'}}>
            <span style={{fontSize:'15px'}}>可删除条件：需求单状态 为已提交或作废</span><br/>
        </div>
        <Form labelCol={{ span: 7 }} wrapperCol={{ span: 12 }} onSubmit={handleSubmit}>
          <Form.Item wrapperCol={{ span: 15, offset: 10 }}>
            <Button type="primary" htmlType="submit" >
              确定
            </Button>
            <Button onClick={props.onCancel} style={{marginLeft:'20px'}}>
              取消
            </Button>
          </Form.Item>
        </Form>
        
        
      </Modal>
    </>
  );
}

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

export default WrappedBase