index.jsx 9.6 KB

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