index.jsx 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  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')) -5
  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. {console.log('drugInfodrugInfo', drugInfo)}
  54. return (<div className={style['drug-info-wrapper']} id="drugWrapper">
  55. <img src={close} onClick={hideDrugInfo} className={style['close-drug-desc']}/>
  56. <h3 onMouseDown={this.setDragBox} id="drugTitle" className={style['drug-title']}>{drugInfo.tagType == 8 ? drugInfo.title+'说明书' : drugInfo.tagType == 10 ? drugInfo.title+ '说明': ''}</h3>
  57. { drugInfo && drugInfo.drugDesc.length > 0 && <div className={style['drug-desc-wrapper']} id='drugDesc' onScroll={this.handleScrollModal.bind(this, drugInfo.drugDesc)}>
  58. <div className={style['drug-title1']} >{drugInfo.tagType == 8 ? drugInfo.title+'说明书' : drugInfo.tagType == 10 ? drugInfo.title+ '说明': ''}</div>
  59. {drugInfo.drugDesc.map((item, index) =>{
  60. return <div className={style['drug-desc-item']} id={item.title.trim()}>
  61. <div className={style['drug-desc-title']} >{item.title.trim()}</div>
  62. <div className={style['drug-desc-content']} dangerouslySetInnerHTML ={{__html: item.content}}></div>
  63. </div>
  64. })}
  65. <div className={style['content-menu-box']}>
  66. <div className={style['content-menu-wrapper']}>
  67. <div className={style['content-menu']}>
  68. {drugInfo.drugDesc.map((item, index) => {
  69. return (<div >
  70. <div className={style['details-menu-title-box']}>
  71. {index === 0 ? '' : <div className={style['details-content-menu-line']}></div>}
  72. <span onClick={this.handleClickMenu.bind(this, index, item, drugInfo.drugDesc)} className={style['details-content-menu-name']} style = {index === currentIndex ? {color:'#0089be'} : ''}>
  73. <span className={style['details-content-menu-circle']} style = {index === currentIndex ? {background:'#0089be'} : ''}></span>{item.title}
  74. </span>
  75. </div>
  76. </div>)
  77. })}
  78. </div>
  79. </div>
  80. </div>
  81. </div> }
  82. { !drugInfo || (drugInfo && drugInfo.drugDesc.length === 0) && <div className={style['drug-desc-wrapper']}>
  83. <div>
  84. {drugInfo.tagType == 8 ? '该药品暂无说明' : drugInfo.tagType == 10 ?'该不良反应暂无说明': ''}
  85. </div>
  86. </div> }
  87. </div>)
  88. //多个药品药品说明书(添加数据时查看药品说明书用)
  89. // return (<div className={style['drug-info-wrapper']}>
  90. // <h3 className={style['drug-title']}>说明书 <img src={close} onClick={hideDrugInfoMore} className={style['close-drug-desc']}/> </h3>
  91. // { drugInfoList && drugInfoList.length > 0 && <div className={style['drug-desc-wrapper']}>
  92. // {drugInfoList.map((item,index) => {
  93. // return <div>
  94. // <h3 style={{height:' 50px', fontSize:'40px', fontWeight: '800'}}>{'【'+item.id+'】'}{item.name}说明书 </h3>
  95. // {item.introduceDetailList&&item.introduceDetailList.length>0&&item.introduceDetailList.map((it, index) =>{
  96. // 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>
  97. // })}
  98. // <br/>
  99. // <br/> <br/> <br/> <br/>
  100. // </div>
  101. // })}
  102. // </div> }
  103. // </div>)
  104. }
  105. }
  106. export default DrugInfo;