index.jsx 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  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. <div className={style['drug-desc-title']} >{item.title.trim()}</div>
  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-wrapper']}>
  66. <div className={style['content-menu']}>
  67. {drugInfo.drugDesc.map((item, index) => {
  68. return (<div >
  69. <div className={style['details-menu-title-box']}>
  70. {index === 0 ? '' : <div className={style['details-content-menu-line']}></div>}
  71. <span onClick={this.handleClickMenu.bind(this, index, item, drugInfo.drugDesc)} className={style['details-content-menu-name']} style = {index === currentIndex ? {color:'#0089be'} : ''}>
  72. <span className={style['details-content-menu-circle']} style = {index === currentIndex ? {background:'#0089be'} : ''}></span>{item.title}
  73. </span>
  74. </div>
  75. </div>)
  76. })}
  77. </div>
  78. </div>
  79. </div>
  80. </div> }
  81. { !drugInfo || (drugInfo && drugInfo.drugDesc.length === 0) && <div className={style['drug-desc-wrapper']}>
  82. <div>
  83. 该药品暂无说明
  84. </div>
  85. </div> }
  86. </div>)
  87. //多个药品药品说明书(添加数据时查看药品说明书用)
  88. // return (<div className={style['drug-info-wrapper']}>
  89. // <h3 className={style['drug-title']}>说明书 <img src={close} onClick={hideDrugInfoMore} className={style['close-drug-desc']}/> </h3>
  90. // { drugInfoList && drugInfoList.length > 0 && <div className={style['drug-desc-wrapper']}>
  91. // {drugInfoList.map((item,index) => {
  92. // return <div>
  93. // <h3 style={{height:' 50px', fontSize:'40px', fontWeight: '800'}}>{'【'+item.id+'】'}{item.name}说明书 </h3>
  94. // {item.introduceDetailList&&item.introduceDetailList.length>0&&item.introduceDetailList.map((it, index) =>{
  95. // 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>
  96. // })}
  97. // <br/>
  98. // <br/> <br/> <br/> <br/>
  99. // </div>
  100. // })}
  101. // </div> }
  102. // </div>)
  103. }
  104. }
  105. export default DrugInfo;