index.jsx 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. import React, { Component } from 'react';
  2. import style from './index.less';
  3. import close from './../img/close.png';
  4. import $ from "jquery";
  5. import {dragBox} from '@utils/tools'
  6. class DrugInfo extends Component {
  7. constructor(props) {
  8. super(props);
  9. this.state = {
  10. currentIndex: 0,
  11. zIndex:302
  12. }
  13. this.setDragBox = this.setDragBox.bind(this)
  14. }
  15. componentDidMount(){
  16. dragBox('drugWrapper','drugTitle')
  17. }
  18. handleClickMenu(index, item, drugDesc) {
  19. const that = this
  20. setTimeout(function(){
  21. that.setState({
  22. currentIndex: index
  23. })
  24. },0)
  25. let scrollTop = 60 //标题高度为60px
  26. drugDesc.map((it, ii) => {
  27. if( ii < index) {
  28. scrollTop = scrollTop + parseInt($('#' + it.title.trim()).css('height'))
  29. }
  30. })
  31. $('#drugDesc').scrollTop(scrollTop)
  32. }
  33. handleScrollModal(drugDesc) {
  34. const scrollTop = $('#drugDesc').scrollTop()
  35. let divHeight = 60; //标题高度为60px
  36. for (let i = 0; i < drugDesc.length; i++) {
  37. divHeight = divHeight + parseInt($('#' + drugDesc[i].title.trim()).css('height'))
  38. if(divHeight > scrollTop) {
  39. this.setState({
  40. currentIndex: i
  41. })
  42. return
  43. }
  44. }
  45. }
  46. setDragBox(){
  47. $('#treatWrapper').css({'z-index': 301});
  48. $('#drugWrapper').css({'z-index': 302});
  49. }
  50. render() {
  51. const { drugInfo, hideDrugInfo, drugInfoList,hideDrugInfoMore } = this.props
  52. const { currentIndex } = this.state
  53. return (<div className={style['drug-info-wrapper']} id="drugWrapper">
  54. <img src={close} onClick={hideDrugInfo} className={style['close-drug-desc']}/>
  55. <h3 onMouseDown={this.setDragBox} id="drugTitle" className={style['drug-title']}>{drugInfo.title}说明书 </h3>
  56. { drugInfo && drugInfo.drugDesc.length > 0 && <div className={style['drug-desc-wrapper']} id='drugDesc' onScroll={this.handleScrollModal.bind(this, drugInfo.drugDesc)}>
  57. <div className={style['drug-title1']} >{drugInfo.title}说明书</div>
  58. {drugInfo.drugDesc.map((item, index) =>{
  59. return <div className={style['drug-desc-item']} id={item.title.trim()}>
  60. <span className={style['drug-desc-title']} >{item.title.trim()}</span>
  61. <div className={style['drug-desc-content']} dangerouslySetInnerHTML ={{__html: item.content}}></div>
  62. </div>
  63. })}
  64. <div className={style['content-menu-box']}>
  65. <div className={style['content-menu']}>
  66. {drugInfo.drugDesc.map((item, index) => {
  67. return (<div >
  68. <div className={style['details-menu-title-box']}>
  69. {index === 0 ? '' : <div className={style['details-content-menu-line']}></div>}
  70. <span onClick={this.handleClickMenu.bind(this, index, item, drugInfo.drugDesc)} className={style['details-content-menu-name']} style = {index === currentIndex ? {color:'#0089be'} : ''}>
  71. <span className={style['details-content-menu-circle']} style = {index === currentIndex ? {background:'#0089be'} : ''}></span>{item.title}
  72. </span>
  73. </div>
  74. </div>)
  75. })}
  76. </div>
  77. </div>
  78. </div> }
  79. { !drugInfo || (drugInfo && drugInfo.drugDesc.length === 0) && <div className={style['drug-desc-wrapper']}>
  80. <div>
  81. 该药品暂无说明
  82. </div>
  83. </div> }
  84. </div>)
  85. //多个药品药品说明书(添加数据时查看药品说明书用)
  86. // return (<div className={style['drug-info-wrapper']}>
  87. // <h3 className={style['drug-title']}>说明书 <img src={close} onClick={hideDrugInfoMore} className={style['close-drug-desc']}/> </h3>
  88. // { drugInfoList && drugInfoList.length > 0 && <div className={style['drug-desc-wrapper']}>
  89. // {drugInfoList.map((item,index) => {
  90. // return <div>
  91. // <h3 style={{height:' 50px', fontSize:'40px', fontWeight: '800'}}>{'【'+item.id+'】'}{item.name}说明书 </h3>
  92. // {item.introduceDetailList&&item.introduceDetailList.length>0&&item.introduceDetailList.map((it, index) =>{
  93. // return <div className={style['drug-desc-item']}><span className={style['drug-desc-title']}>{it.title.trim()}</span> <div className={style['drug-desc-content']} dangerouslySetInnerHTML ={{__html: it.content}}></div> </div>
  94. // })}
  95. // <br/>
  96. // <br/> <br/> <br/> <br/>
  97. // </div>
  98. // })}
  99. // </div> }
  100. // </div>)
  101. }
  102. }
  103. export default DrugInfo;