index.jsx 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. import React, { Component } from "react";
  2. import styles from "./index.less";
  3. import { normalVal, timestampToTime, getStatusImg,setFontColorSize } from '@utils/tools';
  4. import slideUp from "@common/images/slide-up.png";
  5. import slideDown from "@common/images/slide-down.png";
  6. class SlideExcel extends Component {
  7. constructor(props) {
  8. super(props);
  9. this.state = {
  10. show: false
  11. };
  12. this.toTime = this.toTime.bind(this)
  13. this.handleSlide = this.handleSlide.bind(this)
  14. }
  15. toTime(time) {
  16. let tmpTim = time.split(',').join('') - 0
  17. if (time && tmpTim.toString() != 'NaN') {
  18. let date = new Date('1900-01-01');
  19. let dateTim = date.getTime();
  20. let times = (tmpTim - 2) * 24 * 60 * 60 * 1000;
  21. let result = timestampToTime(dateTim + times).split(' ')[0]
  22. return result;
  23. } else {
  24. return time;
  25. }
  26. }
  27. handleSlide() {
  28. let tmpShow = this.state.show
  29. this.setState({
  30. show: !tmpShow
  31. })
  32. }
  33. render() {
  34. const { items, item, idx, getInfomation, dateTime } = this.props;
  35. const { show } = this.state;
  36. return (
  37. <li className={`${styles.excelDataLis} clearfix`} style={{ border: items.lisExcelRes.length - 1 == idx ? 0 : '' }}>
  38. <span className={styles.excelDataTitle}>
  39. <span className={`${styles.tagSpan} ${styles.selectTagSpan}`}>
  40. <span className={`${styles.menus} ${setFontColorSize(2)}`}>{item.menus}</span>
  41. <span className={styles.imgInfo} title='点击i图标可查看详细说明' onClick={() => getInfomation({ name: item.lisExcelItem[0].uniquemealName || '', type: 12, position: 1 })}></span>
  42. </span>
  43. </span>
  44. <table className={`${styles.table} ${setFontColorSize(2)}`}>
  45. {show ? (item.lisExcelItem && item.lisExcelItem.map((value, idx) => {
  46. return <tr>
  47. <td style={{ width: '30%' }}>
  48. <span className={styles.tagSpan}>
  49. {value.itemName}
  50. <span className={styles.imgInfo1} title='点击i图标可查看详细说明' onClick={() => getInfomation({ name: value.uniqueName || '', type: 12, position: 1 })}></span>
  51. </span>
  52. </td>
  53. <td style={{ width: '20%' }}>
  54. {
  55. getStatusImg(value.type, value.value, 1)
  56. }
  57. {value.unit}</td>
  58. <td style={{ width: '25%' }}>
  59. {normalVal(value.min, value.max)}
  60. </td>
  61. <td style={{ width: '25%' }}>{value.time == '' ? ('导入时间: ' + dateTime) : '检验时间: ' + this.toTime(value.time)}</td>
  62. </tr>
  63. })) : (item.lisExcelItem && item.lisExcelItem.map((value, idx) => {
  64. if (idx < 4) {
  65. return <tr>
  66. <td style={{ width: '30%' }}>
  67. <span className={styles.tagSpan}>
  68. {value.itemName}
  69. <span className={styles.imgInfo1} title='点击i图标可查看详细说明' onClick={() => getInfomation({ name: value.uniqueName || '', type: 12, position: 1 })}></span>
  70. </span>
  71. </td>
  72. <td style={{ width: '20%' }}>
  73. {
  74. getStatusImg(value.type, value.value, 1)
  75. }
  76. {value.unit}</td>
  77. <td style={{ width: '25%' }}>
  78. {normalVal(value.min, value.max)}
  79. </td>
  80. <td style={{ width: '25%' }}>{value.time == '' ? ('导入时间: ' + dateTime) : '检验时间: ' + this.toTime(value.time)}</td>
  81. </tr>
  82. }
  83. }))
  84. }
  85. </table>
  86. {
  87. item.lisExcelItem && item.lisExcelItem.length > 5 ?
  88. <div className={`${styles.slides} ${setFontColorSize(2)}`} onClick={this.handleSlide}>
  89. {
  90. show ? <span>收起</span> : <span>剩余<span className={styles.num}>{item.lisExcelItem.length - 4}</span>项</span>
  91. }
  92. <img src={show ? slideUp : slideDown} alt="" />
  93. </div> : null
  94. }
  95. </li>
  96. );
  97. }
  98. }
  99. export default SlideExcel;