index.jsx 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193
  1. import React, { Component } from "react";
  2. import styles from "./index.less";
  3. import { normalVal,timestampToTime } from '@utils/tools';
  4. import { InspectCommon, Calendar,DelToast} 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. activeInd:false,
  15. activeName:''
  16. };
  17. this.toTime = this.toTime.bind(this)
  18. this.handleSlide = this.handleSlide.bind(this)
  19. this.handleDel = this.handleDel.bind(this)
  20. this.handleCancel = this.handleCancel.bind(this)
  21. this.delConfirm = this.delConfirm.bind(this)
  22. }
  23. toTime(time){
  24. let tmpTim = time.split(',').join('')-0
  25. if(time && tmpTim.toString() != 'NaN'){
  26. let date = new Date('1900-01-01');
  27. let dateTim = date.getTime();
  28. let times = (tmpTim-2)*24*60*60*1000;
  29. let result = timestampToTime(dateTim+times).split(' ')[0]
  30. return result;
  31. }else{
  32. return time;
  33. }
  34. }
  35. handleSlide(){
  36. let tmpShow = this.state.show
  37. this.setState({
  38. show:!tmpShow
  39. })
  40. }
  41. handleDel(){
  42. const {handleDelClick,idx,item} = this.props;
  43. this.setState({
  44. activeInd:true,
  45. activeName:item.name
  46. })
  47. handleDelClick&&handleDelClick(1,idx);
  48. }
  49. handleCancel(){
  50. this.setState({
  51. activeInd:false,
  52. activeName:''
  53. })
  54. }
  55. delConfirm(){
  56. const {handleDelConfirm} = this.props;
  57. handleDelConfirm&&handleDelConfirm();
  58. this.setState({
  59. activeInd:false,
  60. activeName:''
  61. })
  62. }
  63. render() {
  64. const {getInfomation,handleConfirm,changeActivePart,handleDelClick,getItemList,date,item,idx,handleFillShow,showDetails,handleLabelSub,showFill,changeShowFill,handlePush,dateTime,currentIdx,currentData,fillActive,handleShowDate,handleChangeDate,showToast} = this.props;
  65. const {show,activeInd,activeName} = this.state;
  66. let numPlus = 0,numPlus1 = 0;
  67. return (
  68. <li key={item.questionId} className={styles.slideLi}>
  69. {
  70. // 标签,血常规。。
  71. item.show ?
  72. <p className={styles.staticTagActive}>
  73. <span className={styles.tagSpan} data-flg="current" style={{color:"#000"}} onClick={(e) => { handleLabelSub(e, item.questionId,idx); handleFillShow(e,idx) }}>
  74. {item.name}
  75. <span className={styles.imgInfo} onClick={()=>getInfomation(item.questionId,item.name)}></span>
  76. </span>
  77. </p>:
  78. <p >
  79. <i className={styles.tagSpan} data-flg="current" onClick={(e) => { handleLabelSub(e,item.questionId,idx); handleFillShow(e,idx) }}>
  80. {item.name}
  81. <span className={styles.imgInfo} onClick={()=>getInfomation(item.questionId,item.name)}></span>
  82. </i>
  83. </p>
  84. }
  85. {
  86. item.details && item.details.map((val)=>{
  87. if(val.value && val.value != ''){
  88. numPlus = ++numPlus
  89. }
  90. })
  91. }
  92. {
  93. item.show ?
  94. <table className={styles.table}>
  95. {
  96. show?(item.details.map((val)=>{
  97. if(val.value && val.value != ''){
  98. return <tr>
  99. <td style={{width:'30%'}}>
  100. <span className={styles.tagSpan}>
  101. {val.name}
  102. <span className={styles.imgInfo} onClick={()=>getInfomation(val.id)}></span>
  103. </span>
  104. </td>
  105. {showDetails(val)}
  106. <td style={{width:'25%'}}>
  107. {normalVal(val.minValue,val.maxValue)}
  108. </td>
  109. <td style={{width:'25%'}}>{'化验时间:'+item.time}</td>
  110. </tr>
  111. }
  112. })):(item.details.map((val,num)=>{
  113. if(val.value && val.value != '' ){
  114. ++numPlus1;
  115. if(numPlus1 < 5){
  116. return <tr>
  117. <td style={{width:'30%'}}>
  118. <span className={styles.tagSpan}>
  119. {val.name}
  120. <span className={styles.imgInfo} onClick={()=>getInfomation(val.id)}></span>
  121. </span>
  122. </td>
  123. {showDetails(val)}
  124. <td style={{width:'25%'}}>
  125. {normalVal(val.minValue,val.maxValue)}
  126. </td>
  127. <td style={{width:'25%'}}>{'化验时间:'+item.time}</td>
  128. </tr>
  129. }
  130. }
  131. }))
  132. }
  133. </table>:null
  134. }
  135. {
  136. numPlus > 4 ?
  137. <div className={styles.slides} onClick={this.handleSlide}>
  138. {
  139. show ? <span>收起</span> :<span>剩余<span className={styles.num}>{numPlus-4}</span>项</span>
  140. }
  141. <img src={show ?slideUp:slideDown} alt=""/>
  142. </div>:null
  143. }
  144. <div className={styles.searchResult}>
  145. {
  146. showFill && fillActive.id == item.id && idx == currentIdx ?
  147. <InspectCommon
  148. showFill={showFill}
  149. handleClear={(e)=>{
  150. changeActivePart('','',true)
  151. }}
  152. handleConfirm={(e)=>{
  153. if(JSON.stringify(currentData) == '{}'){
  154. handleConfirm(e,idx,dateTime,fillActive);
  155. }else{
  156. handleConfirm(e,idx,dateTime,currentData);
  157. }
  158. changeShowFill()
  159. handlePush&&handlePush(); //右侧推送
  160. }}
  161. >
  162. <div className={styles.searchResultT}>
  163. <img style={{"position":"absolute","top":"8px","right":"8px",cursor:"pointer"}} src={date1} alt="" onClick={handleShowDate}/>
  164. <p style={{position:"absolute",right:"25px",top:"4px",lineHeight:"28px",cursor:"pointer",paddingRight:"10px"}} onClick={handleShowDate}>
  165. {
  166. dateTime
  167. }
  168. </p>
  169. <div style={{display:date?"block":"none",position:"relative"}}>
  170. {/* 日期组件 */}
  171. <Calendar isShow={true} handleChange={handleChangeDate}></Calendar>
  172. </div>
  173. </div>
  174. {/* 填写单内容显示 */}
  175. { getItemList() }
  176. </InspectCommon>
  177. : null
  178. }
  179. </div>
  180. {/*<img className={styles.partDel} src={close} alt="删除项" onClick={()=>{handleDelClick(1,idx)}}/>*/}
  181. <span id="addClose" className={styles.partDel} onClick={this.handleDel}></span>
  182. <DelToast show={showToast&&activeInd?true:false}
  183. name={activeName}
  184. cancel={this.handleCancel}
  185. confirm={this.delConfirm}/>
  186. </li>
  187. );
  188. }
  189. }
  190. export default SlideSelect;