import style from "../index.less";
import { normalVal,getStatusImg } from '@utils/tools';

const PreviewInspect = (props) => {
  const { dataJson, toTime ,dateTime,showDetails  } = props;
    return <tr className={style['patInfoFst']}>
      <td className={style['patInfoSec']}>化验：</td>
      <td className={style['patInfoSec']}>
        {
          dataJson&&dataJson.getExcelDataList && dataJson.getExcelDataList.map((items) => {
            return items.lisExcelRes && items.lisExcelRes.map((item) => {
              return <table style={style.assistTable}>
                <tr style={style.assistTableTrFst}><td><span>{item.menus}</span></td></tr>
                {
                  item.lisExcelItem && item.lisExcelItem.map((value) => {
                    return <tr className={style.assistTableTrSec}>
                      <td className={style.assistTableTdFst}>{value.itemName}</td>
                      <td className={style.assistTableTdSec}>
                        {getStatusImg(value.type,value.value,1)}
                        {value.unit}
                      </td>
                      <td className={style.assistTableTdTrd}>
                        {normalVal(value.min, value.max)}
                      </td>
                      <td className={style.assistTableTdFor}>{value.time == '' ? ('导入时间: ' + dateTime) : '化验时间: ' + toTime(value.time)
                    }</td>
                    </tr>
                  })
                }
              </table>
            })
          })
        }
        {
          dataJson&&dataJson.labelList && dataJson.labelList.map((item, idx) => {
            return <table style={{ margin: '8px 0', width: '100%' }}>
              {
                item.show?<tr className={style.assistTableTrFst}><td><span> {item.name} </span></td></tr>:
                <tr className={style.assistTableTrFstExcel}><td><span>「{item.name}」</span></td></tr>
              }
              {
                item.details.map((val) => {
                  if (val.value && val.value != '') {
                    return <tr className={style.assistTableTrSecExcel}>
                      <td className={style.assistTableTdFst}>{val.name}</td>
                      {showDetails(val)}
                      <td className={style.assistTableTdTrd}>
                        {normalVal(val.minValue, val.maxValue)}
                      </td>
                      <td className={style.assistTableTdFor}>{'化验时间:' + item.time}</td>
                    </tr>
                  }
                })
              }
            </table>
          })
        }
      </td>
    </tr>
}

export default PreviewInspect;
