index.jsx 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262
  1. import React, { Component } from "react";
  2. import styles from "./index.less";
  3. import { normalVal,timestampToTime,getPageCoordinate,setPosition } 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 ScrollArea from 'react-scrollbar';
  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. this.handleLabelSub = this.handleLabelSub.bind(this);
  25. }
  26. handleChangeDate(date) {
  27. // console.log(date,'外')
  28. }
  29. componentDidMount() {
  30. $(document).click((event) => {
  31. let inspectToggleDate = document.getElementById("inspectToggleDate")
  32. let timeIcon = document.getElementById("timeIcon")
  33. let calendarDate = document.getElementById("calendarDate")
  34. if (calendarDate) {
  35. if (inspectToggleDate != event.target && timeIcon != event.target && !calendarDate.contains(event.target)) {
  36. this.props.handleShowDate();
  37. }
  38. }
  39. });
  40. }
  41. toTime(time){
  42. let tmpTim = time.split(',').join('')-0
  43. if(time && tmpTim.toString() != 'NaN'){
  44. let date = new Date('1900-01-01');
  45. let dateTim = date.getTime();
  46. let times = (tmpTim-2)*24*60*60*1000;
  47. let result = timestampToTime(dateTim+times).split(' ')[0]
  48. return result;
  49. }else{
  50. return time;
  51. }
  52. }
  53. handleSlide(){
  54. let tmpShow = this.state.show
  55. this.setState({
  56. show:!tmpShow
  57. })
  58. }
  59. handleDel(){
  60. const {handleDelClick,idx,item} = this.props;
  61. this.setState({
  62. activeInd:true,
  63. activeName:item.name
  64. })
  65. handleDelClick&&handleDelClick(1,idx);
  66. }
  67. handleCancel(){
  68. this.setState({
  69. activeInd:false,
  70. activeName:''
  71. })
  72. }
  73. delConfirm(){
  74. const {handleDelConfirm} = this.props;
  75. handleDelConfirm&&handleDelConfirm();
  76. this.setState({
  77. activeInd:false,
  78. activeName:''
  79. })
  80. }
  81. timeSure(date){
  82. const {handleChangeDate} = this.props;
  83. handleChangeDate&&handleChangeDate(date)
  84. }
  85. handleLabelSub(e,questionId,idx){
  86. const {handleLabelSub,handleFillShow,setHighter,refreshScroller} = this.props;
  87. handleLabelSub(e,questionId,idx);
  88. handleFillShow(e,idx);
  89. //弹窗高度超出屏幕,增加页面高度
  90. setPosition(e,"#inspectFill",setHighter);
  91. /*setTimeout(function(){//如果化验下面有很多数据,则会跳过头
  92. refreshScroller()&&refreshScroller().scrollYTo(290);
  93. })*/
  94. }
  95. render() {
  96. const {windowWidth,getInfomation,handleConfirm,changeActivePart,getItemList,date,item,idx,showDetails,showFill,changeShowFill,handlePush,dateTime,currentIdx,currentData,fillActive,handleShowDate,showToast} = this.props;
  97. const {show,activeInd,activeName} = this.state;
  98. let numPlus = 0,numPlus1 = 0;
  99. let staticTime = {}
  100. if(dateTime){
  101. let tmp1 = dateTime.split(' ')[0].split('-')
  102. let tmp2 = (dateTime).split(' ').length>1&&(dateTime).split(' ')[1].split(':')
  103. staticTime = {
  104. year: tmp1[0]-0,
  105. month: tmp1[1]-0,
  106. day: tmp1[2]-0,
  107. hour: tmp2[0],
  108. minute: tmp2[1],
  109. second: tmp2[2]
  110. }
  111. }
  112. const contStyle={
  113. opacity:'0.4',
  114. right:'0',
  115. top:'6px',
  116. zIndex:'15',
  117. width:'14px',
  118. background:'#f1f1f1'};
  119. const barStyle={background:'#777',width:'100%'};
  120. const listLen = currentData.details&&currentData.details.length;
  121. const stopScroll =(windowWidth<1300&&listLen>12)||(windowWidth>1299&&listLen>24);
  122. return (
  123. <li key={item.questionId} className={styles.slideLi}>
  124. {
  125. // 标签,血常规。。
  126. item.show ?
  127. <p className={styles.staticTagActive}>
  128. <span className={styles.tagSpan} data-flg="current" style={{color:"#000"}} onClick={(e)=>this.handleLabelSub(e,item.questionId,idx)}>
  129. {item.name}
  130. <span className={styles.imgInfo1} title='点击i图标可查看详细说明' onClick={()=>getInfomation({name:item.uniqueName || '', position: 1, type: 12})}></span>
  131. </span>
  132. </p>:
  133. <p >
  134. <i className={styles.tagSpan} data-flg="current" onClick={(e)=>this.handleLabelSub(e,item.questionId,idx)}>
  135. {item.name}
  136. <span className={styles.imgInfo} title='点击i图标可查看详细说明' onClick={()=>getInfomation({name:item.uniqueName || '', position: 1, type: 12})}></span>
  137. </i>
  138. </p>
  139. }
  140. {
  141. item.details && item.details.map((val)=>{
  142. if(val.value && val.value != ''){
  143. numPlus = ++numPlus
  144. }
  145. })
  146. }
  147. {
  148. item.show ?
  149. <table className={styles.table}>
  150. {
  151. show?(item.details.map((val)=>{
  152. if(val.value && val.value != ''){
  153. return <tr>
  154. <td style={{width:'30%'}}>
  155. <span className={styles.tagSpan}>
  156. {val.name}
  157. <span className={styles.imgInfo1} title='点击i图标可查看详细说明' onClick={()=>getInfomation({name:val.uniqueName || '', position: 1, type: 12})}></span>
  158. </span>
  159. </td>
  160. {showDetails(val)}
  161. <td style={{width:'25%'}}>
  162. {val.questionDetailList.length > 0?'':normalVal(val.minValue,val.maxValue)}
  163. </td>
  164. <td style={{width:'25%'}}>{'化验时间:'+item.time}</td>
  165. </tr>
  166. }
  167. })):(item.details.map((val)=>{
  168. if(val.value && val.value != '' ){
  169. ++numPlus1;
  170. if(numPlus1 < 5){
  171. return <tr>
  172. <td style={{width:'30%'}}>
  173. <span className={styles.tagSpan}>
  174. {val.name}
  175. <span className={styles.imgInfo1} title='点击i图标可查看详细说明' onClick={()=>getInfomation({name:val.uniqueName || '', position: 1, type: 12})}></span>
  176. </span>
  177. </td>
  178. {showDetails(val)}
  179. <td style={{width:'25%'}}>
  180. {val.questionDetailList.length > 0?'':normalVal(val.minValue,val.maxValue)}
  181. </td>
  182. <td style={{width:'25%'}}>{'化验时间:'+item.time}</td>
  183. </tr>
  184. }
  185. }
  186. }))
  187. }
  188. </table>:null
  189. }
  190. {
  191. numPlus > 4 ?
  192. <div className={styles.slides} onClick={this.handleSlide}>
  193. {
  194. show ? <span>收起</span> :<span>剩余<span className={styles.num}>{numPlus-4}</span>项</span>
  195. }
  196. <img src={show ?slideUp:slideDown} alt=""/>
  197. </div>:null
  198. }
  199. <div className={styles.searchResult}>
  200. {
  201. showFill && fillActive.id == item.id && idx == currentIdx ?
  202. <InspectCommon
  203. showFill={showFill}
  204. handleClear={(e)=>{
  205. changeActivePart('','',true)
  206. }}
  207. handleConfirm={(e)=>{
  208. if(JSON.stringify(currentData) == '{}'){
  209. handleConfirm(e,idx,dateTime,fillActive);
  210. }else{
  211. handleConfirm(e,idx,dateTime,currentData);
  212. }
  213. changeShowFill()
  214. handlePush&&handlePush(); //右侧推送
  215. }}
  216. >
  217. <div className={styles.searchResultT}>
  218. <img style={{"position":"absolute","top":"8px","right":"8px",cursor:"pointer"}} onClick={handleShowDate} src={date1} alt="" id="inspectToggleDate"/>
  219. <p style={{position:"absolute",right:"25px",top:"4px",lineHeight:"28px",cursor:"pointer",paddingRight:"10px"}} onClick={handleShowDate} id="timeIcon">
  220. {
  221. dateTime
  222. }
  223. </p>
  224. <div style={{display:date?"block":"none",position:"relative"}}>
  225. {/* 日期组件 */}
  226. {
  227. date?<Calendar timeLis={staticTime} isShow={true} timeSure={this.timeSure} needTime={true} sure={true} handleChange={this.handleChangeDate}></Calendar>:null
  228. }
  229. {/* <Calendar timeLis={staticTime} isShow={true} timeSure={this.timeSure} needTime={true} sure={true} handleChange={handleChangeDate}></Calendar> */}
  230. </div>
  231. </div>
  232. {/* 填写单内容显示 */}
  233. <ScrollArea speed={0.8}
  234. horizontal={false}
  235. stopScrollPropagation={stopScroll}
  236. style={{maxHeight:'358px'}}
  237. className={styles["area"]}
  238. verticalContainerStyle={contStyle}
  239. verticalScrollbarStyle={barStyle}
  240. contentClassName="content">
  241. { getItemList() }
  242. </ScrollArea>
  243. </InspectCommon>
  244. : null
  245. }
  246. </div>
  247. {/*<img className={styles.partDel} src={close} alt="删除项" onClick={()=>{handleDelClick(1,idx)}}/>*/}
  248. <span id="addClose" className={styles.partDel} onClick={this.handleDel}></span>
  249. <DelToast show={showToast&&activeInd?true:false}
  250. name={activeName}
  251. right={'-34px'}
  252. top={'30px'}
  253. cancel={this.handleCancel}
  254. confirm={this.delConfirm}/>
  255. </li>
  256. );
  257. }
  258. }
  259. export default SlideSelect;