import React, { PureComponent, useState, useEffect } from 'react'
import { Modal, Row, Col, Table, Pagination, Button, Form, Input, Select, message } from 'antd'
import EnDash from '../EnDash'
import AuthButton from '@/components/AuthButton';
import request from '../../../../../../utils/request';
import apis from '../../../../../../services/apis';
import Style from './style.less'
import { router } from 'umi';
import HotBlock from '../HotBlock'

const BasicHeat = props => {

  const houseIdList = props.houseId;
  const salesBatchId = props.salesBatchId;

  function handleSubmit (e) {
    console.log(houseIdList, salesBatchId)
    e.preventDefault();
    props.form.validateFields((err, values) => {
      if (!err){
        request({ ...apis.house.batchUpdateRaiseHeat, data: { raiseHeat: values.raiseHeat, houseIdList , salesBatchId: salesBatchId},}).then((data) => {
          message.info("修改成功")
          props.onCancel(false)
          props.onSuccess();
        }).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>将所选{houseIdList.length}条房源预选基础热度信息修改为</span>
        <Form labelCol={{ span: 7 }} wrapperCol={{ span: 12 }} onSubmit={handleSubmit}>
          <Form.Item label="基础热度值" labelAlign='left'>
            {getFieldDecorator('raiseHeat')(<Input placeholder='填写预选基础热度，建议为0' label='left'/>)}
          </Form.Item>
          <Form.Item wrapperCol={{ span: 15, offset: 10 }}>
            <Button type="primary" htmlType="submit" >
              提交
            </Button>
          </Form.Item>
        </Form>
        
      </Modal>
    </>
  );
}

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

export default WrappedBase