import React from "react";
import style from "../index.less";
import check_circle from '../img/check-circle.png';
import check_right from '../img/check-right.png';

class WrapModalTableSon extends React.Component {
  constructor(props) {
    super(props)
    this.getImgPath = this.getImgPath.bind(this)
  }
  getImgPath(name,checkItem,item,idx){
    const { checkedList,selectOneCheck } = this.props;
    let num = 0;
    for(let k = 0;k < checkedList.length;k++){
      let tmpLis = checkedList[k];
      if(tmpLis == name){
        return <img className={style.check} onClick={()=>selectOneCheck(name,checkItem,item,idx)} src={check_right} alt="" />
      }else{
        ++num
      }
    }
    if(num == checkedList.length){
      return <img className={style.check} onClick={()=>selectOneCheck(name,checkItem,item,idx)} src={check_circle} alt="" />
    }
  }
  render() {
    const { hospitalSonInspect,allCheckImport,allCheck } = this.props;
    return <div className={style['modalTable']}>
      <div className={style.sonTitle}>
        <span>组名称 : {hospitalSonInspect.checkItem}</span>
      </div>
      <div className={`${style.SonTable}`}>
        <table>
          <tr className={style.head}>
            <td className={`${style.fst}`} onClick={allCheckImport}><img className={style.check} src={allCheck?check_right:check_circle} alt="" />全选</td>
            <td className={`${style.sec}`}>检查项目</td>
            <td className={`${style.trd}`}>影像所见</td>
            <td className={`${style.four}`}>影像诊断</td>
            <td className={`${style.sev}`} style={{display:(hospitalSonInspect && hospitalSonInspect.pacsResultDTO && hospitalSonInspect.pacsResultDTO.length)>5?'':'none'}}></td>
          </tr>
        </table>
      </div>
      <div className={`${style.parentTables} ${style.SonTable}`}>
        <table>
          {/* {type-0正常1异常2上升3下降} */}
          {
            hospitalSonInspect && hospitalSonInspect.pacsResultDTO && hospitalSonInspect.pacsResultDTO.map((item, idx) => {
              return <tr>
                <td className={`${style.fst}`}>
                  {
                    this.getImgPath(item.checkItem,hospitalSonInspect.checkItem,item,idx)
                  }
                </td>
                <td title={item.checkItem} className={`${style.sec}`}>{item.checkItem}</td>
                <td title={item.imagingDiagnose} className={`${style.trd}`}>{item.imagingDiagnose}</td>
                <td title={item.imagingResults} className={`${style.four}`}>{item.imagingResults}</td>
              </tr>
            })
          }
        </table>
      </div>
    </div>
  }
}

export default WrapModalTableSon;