import React from 'react'
import { connect } from 'dva'
import { Modal, Form } from 'antd'
import CombinationPage from '../../Combination/CombinationPage'

class EnergyNodeModal extends React.Component {
  constructor(props) {
    super(props)
    this.state = {
      visible: false,
      loading: false,
      appid: '',
      hmi_id: ''
    }
  }

  componentDidMount() {
    if (this.props.onRef) {
      this.props.onRef(this)
    }
  }

  showModal = (appid, hmi_id) => {
    this.setState({
      visible: true,
      appid,   
      hmi_id
    })
  }

  handleCancel = e => {
    this.setState({
      visible: false,
    })
  }

  render() {
    const { appid, hmi_id, visible } = this.state
    let data = {
      customParams: 'ID',
      id: appid,
      isNode: 0,
      isPreview: 1,
      code: 'hmi_id',
      hmi_id: hmi_id
    }

    return (
      <Modal
        title='表计节点[EM072]'
        footer={null}
        maskClosable={false}
        onCancel={this.handleCancel}
        visible={visible}
        bodyStyle={{ padding: 8, backgroundColor: '#f2f2f2' }}
        className='antd-modal-fullscreen'
      >
        <CombinationPage key={appid} formCode={'EM072'} data={data} />
      </Modal>
    )
  }
}
export default connect(({ app, editPage, loading, login }) => ({ app, editPage, loading, login }))(Form.create()(EnergyNodeModal))