import React, {
  Component 
} from 'react';
import {
  WeaLocaleProvider, 
  WeaDialog,
} from 'ecCom';
import './HRMNetworkIPListStyle.less';
  
const {getLabel} = WeaLocaleProvider;
  
export default class HRMNetworkIPList extends Component {

  constructor(props) {
    super(props);
    this.state = {
      loading: false
    }
  }

  componentWillMount() {
    this.setState({
      loading: false
    })
  }

  componentWillUnmount() {
    this.setState({
      loading: false
    })
  }
  
  componentDidMount() {
    //   异步加载别模块的
    eventRegister.loadModule('b_hrm', () => {
      // 加载成功
      // 更新load状态
      this.setState({loading: true});
    }, () => {
        // 加载文件失败
        this.setState({loading: false});
        // alert('流程模块加载失败');
    })
  }

  render() {
    const {
      visible,
      onCancel=null
    } = this.props;
    return (
      <WeaDialog ecId={`${this && this.props && this.props.ecId || ''}_WeaDialog@6tmbm8`} 
        className="bs-inte-hrm-list-dialog"
        title={getLabel(83726, '网段策略')}
        moduleName={'hrm'}
        visible={visible}
        buttons={[]}
        hasScroll={true}
        style={{
          width: 800,
          height: 600
        }}
        moreBtn={{
          datas: [],
          collectParams: []
        }}
        onCancel={v => {
          if(onCancel && typeof(onCancel) === "function") {
            onCancel();
          }
        }}
      >
        <div className="bs-inte-hrm-network-list">
          {
            this.state.loading 
              ? window.weaHrmEngine && window.weaHrmEngine.com && window.weaHrmEngine.com.NetworkStrategy
                ? <window.weaHrmEngine.com.NetworkStrategy ecId={`${this && this.props && this.props.ecId || ''}_NetworkStrategy@757c0i`} 
                    single={"1"}
                    type={"network"}
                  />
                : null
              : null
          }
        </div>
      </WeaDialog>
    )
  }
}
  