import React from 'react';
import style from './index.less';
/**
* 化验辅检删除弹窗 @Liucf 2019-5-22
* 接收参数：
* show：展示组件
* name：删除项的名称
* confirm：删除事件处理函数
* cancel：取消事件处理函数
*/

class DelToast extends React.PureComponent{
  constructor(props){
    super(props);
    this.handleDel = this.handleDel.bind(this);
    this.handleCancel = this.handleCancel.bind(this);
  }
  handleDel(){
    const {confirm} = this.props;
    confirm&&confirm();
  }
  handleCancel(){
    const {cancel} = this.props;
    cancel&&cancel();
  }
  render(){
    const {show,name,top,right} = this.props;
    if(show){
      return <div className={style['del-box']} id="delBox" style={{right:right,top:top}}>
        <div className={style['del-con']}>
          <div className={style['del-tri']}></div>
          <div className={style['del-title']} id="delTit" title={'删除 '+name+' ？'}>删除 {name} ？</div>
          <div className={style['del-foot']}>
            <span className={`${style['del-btn']} ${style['del-del']}`} onClick={this.handleDel}>删除</span>
            <span className={`${style['del-btn']} ${style['del-cancel']}`} onClick={this.handleCancel}>取消</span>
          </div>
        </div>
      </div>
    }
    return ''
  }
}

export default DelToast;