index.jsx 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. import React, { Component } from "react";
  2. import styles from "./index.less";
  3. import { normalVal,timestampToTime } from '@utils/tools';
  4. import { InspectCommon, Calendar} from '@commonComp';
  5. import slideUp from "@common/images/slide-up.png";
  6. import slideDown from "@common/images/slide-down.png";
  7. import date1 from '../img/date1.png';
  8. import close from '../img/close.png';
  9. class SlideSelect extends Component {
  10. constructor(props) {
  11. super(props);
  12. this.state = {
  13. show:false
  14. };
  15. this.toTime = this.toTime.bind(this)
  16. this.handleSlide = this.handleSlide.bind(this)
  17. }
  18. toTime(time){
  19. let tmpTim = time.split(',').join('')-0
  20. if(time && tmpTim.toString() != 'NaN'){
  21. let date = new Date('1900-01-01');
  22. let dateTim = date.getTime();
  23. let times = (tmpTim-2)*24*60*60*1000;
  24. let result = timestampToTime(dateTim+times).split(' ')[0]
  25. return result;
  26. }else{
  27. return time;
  28. }
  29. }
  30. handleSlide(){
  31. let tmpShow = this.state.show
  32. this.setState({
  33. show:!tmpShow
  34. })
  35. }
  36. render() {
  37. const {handleConfirm,changeActivePart,handleDelClick,getItemList,date,item,idx,handleFillShow,showDetails,handleLabelSub,showFill,changeShowFill,handlePush,dateTime,currentIdx,currentData,fillActive,handleShowDate,handleChangeDate} = this.props;
  38. const {show} = this.state;
  39. return (
  40. <li key={item.questionId} className={styles.slideLi}>
  41. {
  42. // 标签,血常规。。
  43. item.show ?
  44. <p className={styles.staticTagActive}>
  45. <span data-flg="current" style={{color:"#000"}} onClick={(e) => { handleLabelSub(e, item.questionId,idx); handleFillShow(e,idx) }}>{item.name}</span>
  46. </p>:
  47. <p>
  48. <i data-flg="current" onClick={(e) => { handleLabelSub(e,item.questionId,idx); handleFillShow(e,idx) }}>{item.name}</i>
  49. </p>
  50. }
  51. {
  52. item.show ?
  53. <table className={styles.table}>
  54. {
  55. show?(item.details.map((val)=>{
  56. if(val.value && val.value != ''){
  57. return <tr>
  58. <td style={{width:'30%'}}>{val.name}</td>
  59. {showDetails(val)}
  60. <td style={{width:'25%'}}>
  61. {normalVal(val.minValue,val.maxValue)}
  62. </td>
  63. <td style={{width:'25%'}}>{'化验时间:'+item.time}</td>
  64. </tr>
  65. }
  66. })):(item.details.map((val,num)=>{
  67. if(val.value && val.value != '' && num < 4 ){
  68. return <tr>
  69. <td style={{width:'30%'}}>{val.name}</td>
  70. {showDetails(val)}
  71. <td style={{width:'25%'}}>
  72. {normalVal(val.minValue,val.maxValue)}
  73. </td>
  74. <td style={{width:'25%'}}>{'化验时间:'+item.time}</td>
  75. </tr>
  76. }
  77. }))
  78. }
  79. </table>:null
  80. }
  81. {
  82. item.details && item.details.length > 5 ?
  83. <div className={styles.slides} onClick={this.handleSlide}>
  84. <span>{show ?'收起':'展开'}</span>
  85. <img src={show ?slideUp:slideDown} alt=""/>
  86. </div>:null
  87. }
  88. <div className={styles.searchResult}>
  89. {
  90. showFill && fillActive.id == item.id && idx == currentIdx ?
  91. <InspectCommon
  92. showFill={showFill}
  93. handleClear={(e)=>{
  94. changeActivePart('','',true)
  95. }}
  96. handleConfirm={(e)=>{
  97. if(JSON.stringify(currentData) == '{}'){
  98. handleConfirm(e,idx,dateTime,fillActive);
  99. }else{
  100. handleConfirm(e,idx,dateTime,currentData);
  101. }
  102. changeShowFill()
  103. handlePush&&handlePush(); //右侧推送
  104. }}
  105. >
  106. <div className={styles.searchResultT}>
  107. <img style={{"position":"absolute","top":"8px","right":"8px"}} src={date1} alt="" onClick={handleShowDate}/>
  108. <p style={{position:"absolute",right:"38px",top:"4px",lineHeight:"28px"}}>
  109. {
  110. dateTime
  111. }
  112. </p>
  113. <div style={{display:date?"block":"none",position:"relative"}}>
  114. {/* 日期组件 */}
  115. <Calendar isShow={true} handleChange={handleChangeDate}></Calendar>
  116. </div>
  117. </div>
  118. {/* 填写单内容显示 */}
  119. { getItemList() }
  120. </InspectCommon>
  121. : null
  122. }
  123. </div>
  124. <img className={styles.partDel} src={close} alt="删除项" onClick={()=>{handleDelClick(1,idx)}}/>
  125. </li>
  126. );
  127. }
  128. }
  129. export default SlideSelect;