import React from 'react'
import { connect } from 'dva'
import { Form, Empty } from 'antd'
import config from "../../../config.js"
import storage from '../../../utils/storage'
class BDHmiTemplatePage extends React.Component {
  render() {
    const tenant = storage('lacal').getItem('Tenant').val
    const orgId = storage('lacal').getItem('webOrgId').val
    const code = this.props.login.baseConfig.CURRENT_VOLTAGE_HMI_ID
    const applianceCode = this.props.data.appliance_id
    const url = config.hmiUrl + "preview?code=" + code + "&sysCode=optiEnergy&applianceCode="
      + applianceCode + "&hideTool=true&tenant=" + tenant + "&orgId=" + orgId
    return (
      <div style={{ height: '100%' }}>
        {
          code ? <iframe style={{ width: '100%', height: '100%', border: 'none' }} title='hmi' src={url}></iframe> : <Empty />
        }
      </div>
    )
  }
}

BDHmiTemplatePage.propTypes = {
}

export default connect(({ login, loading, EMemOrder, custom, app }) => ({ login, loading, EMemOrder, custom, app }))(Form.create()(BDHmiTemplatePage))