index.jsx 4.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. import React, { Component } from 'react';
  2. import style from './index.less';
  3. import $ from "jquery";
  4. import close from './img/close.png';
  5. import info from './img/info.png';
  6. import info1 from './img/info1.png';
  7. class TreatDesc extends Component {
  8. constructor(props){
  9. super(props);
  10. this.state = {
  11. currentIndex: -1
  12. }
  13. this.hideTreatDesc = this.hideTreatDesc.bind(this);
  14. this.handleSelect= this.handleSelect.bind(this);
  15. this.handleMouseLeaveImg = this.handleMouseLeaveImg.bind(this)
  16. }
  17. handleMouseEnterImg(index) {
  18. this.setState({
  19. currentIndex: index,
  20. })
  21. }
  22. handleMouseLeaveImg() {
  23. this.setState({
  24. currentIndex: -1,
  25. })
  26. }
  27. handleSelect(index,ii) {
  28. const { selectDrug } = this.props;
  29. selectDrug && selectDrug(index,ii);
  30. }
  31. hideTreatDesc() {
  32. $('#treatDescBox').css({'display': 'none'});
  33. $('#treatDescBox').animate({'display': 'none'}, 500);
  34. $('#treatWrapper').animate({'margin-left': '-340px'}, 500);
  35. }
  36. render(){
  37. const { treatment, treatDesc, setDrugInfo, showDrugInfo} = this.props
  38. const { title, basic, otherDrugIndex, drugDesc} = treatDesc
  39. const { currentIndex } = this.state
  40. return (treatment && treatment.length >0 && <div className={style['treat-desc-box']}>
  41. {title && title === '药品推荐' ? <div className={style['similar-drug-box']} id='treatDescBox'>
  42. {/* { basic && basic.length > 0 && <div> //推荐依据不需要展示
  43. <h3 className={style['recommend-title']}>推荐依据</h3>
  44. {basic.map((item, index) =>{
  45. return (<div className={style['drug-desc-item']} dangerouslySetInnerHTML ={{__html: item.content}}>
  46. </div>)
  47. })}
  48. </div> } */}
  49. { otherDrugIndex > -1 && <div className={style['similar-drug']}>
  50. <h3 className={style['drug-desc-title']}><span className={style['drug-desc-class-title']} title={'同类药物(' + treatment[otherDrugIndex].drugsName + ')'}>同类药物({treatment[otherDrugIndex].drugsName})</span> <img src={close} onClick={this.hideTreatDesc} className={style['close-drug-desc']} /></h3>
  51. {treatment[otherDrugIndex].medicitionsList.map((item, index) =>{
  52. return (<span style={item.forbidden === '2' ? {opacity: '0.3', filter:'alpha(opacity=30)'} : ''}>
  53. {index === 0 ? '' : ', '}
  54. <span className={style['drug-name-box']}>
  55. <span className={style['drug-name']}
  56. onDoubleClick={() =>{setDrugInfo(item);showDrugInfo();}}
  57. onClick={()=>{item.forbidden === '2' ? '' : this.handleSelect(otherDrugIndex,index)}}
  58. style={item.selected ? {color: '#3B9ED0'}:''}>
  59. {item.medicitionName}
  60. </span>
  61. </span>
  62. {<img className={style['info-img']}
  63. src={currentIndex === index ? info1 : info}
  64. onMouseEnter={this.handleMouseEnterImg.bind(this, index)}
  65. onMouseLeave = {this.handleMouseLeaveImg}
  66. onClick={() =>{setDrugInfo(item);showDrugInfo();}}/>}
  67. {item.forbidden === '1' ? <span className={style['info-flag']} style={{border: '1px solid #F4C051', background: '#F4C051',marginLeft: '5px'}}>慎用</span>: item.forbidden === '2' ? <span className={style['info-flag']} style={{border: '1px solid #000',marginLeft: '5px'}}>禁用</span> : ''}, 使用率{item.rate}
  68. </span>)
  69. })}
  70. </div> }
  71. </div>: '' }
  72. {/* { title !== '药品推荐' ? <div>
  73. { drugDesc && drugDesc.length > 0 && <div className={style['drug-desc-wrapper']}>
  74. <h3 className={style['drug-title']}>说明</h3>
  75. {drugDesc.map((item, index) =>{
  76. return <div className={style['drug-desc-item']}>{item.title}: <span dangerouslySetInnerHTML ={{__html: item.content}}></span> </div>
  77. })}
  78. </div> }
  79. </div>: '' } */}
  80. </div>)
  81. }
  82. }
  83. export default TreatDesc;