index.jsx 3.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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. class TreatDesc extends Component {
  7. constructor(props){
  8. super(props);
  9. this.hideTreatDesc = this.hideTreatDesc.bind(this);
  10. this.handleSelect= this.handleSelect.bind(this);
  11. }
  12. handleSelect(index,ii) {
  13. const { selectDrug } = this.props;
  14. selectDrug && selectDrug(index,ii);
  15. }
  16. hideTreatDesc() {
  17. $('#treatDescBox').css({'display': 'none'});
  18. $('#treatDescBox').animate({'display': 'none'}, 500);
  19. $('#treatWrapper').animate({'margin-left': '-340px'}, 500);
  20. }
  21. render(){
  22. const { treatment, treatDesc, setDrugInfo, showDrugInfo} = this.props
  23. const { title, basic, otherDrugIndex, drugDesc} = treatDesc
  24. return (treatment && treatment.length >0 && <div className={style['treat-desc-box']}>
  25. {title && title === '药品推荐' ? <div className={style['similar-drug-box']} id='treatDescBox'>
  26. {/* { basic && basic.length > 0 && <div> //推荐依据不需要展示
  27. <h3 className={style['recommend-title']}>推荐依据</h3>
  28. {basic.map((item, index) =>{
  29. return (<div className={style['drug-desc-item']} dangerouslySetInnerHTML ={{__html: item.content}}>
  30. </div>)
  31. })}
  32. </div> } */}
  33. { otherDrugIndex > -1 && <div className={style['similar-drug']}>
  34. <h3 className={style['drug-desc-title']}>同类药物 <img src={close} onClick={this.hideTreatDesc} className={style['close-drug-desc']} /></h3>
  35. {treatment[otherDrugIndex].medicitionsList.map((item, index) =>{
  36. return (<span style={item.forbidden === '2' ? {opacity: '0.3', filter:'alpha(opacity=30)'} : ''}>
  37. {index === 0 ? '' : ', '}
  38. <span className={style['drug-name']}
  39. onDoubleClick={() =>{setDrugInfo(item);showDrugInfo();}}
  40. onClick={()=>{item.forbidden === '2' ? '' : this.handleSelect(otherDrugIndex,index)}}
  41. style={item.selected ? {color: '#3B9ED0'}:''}>
  42. {item.medicitionName}
  43. </span>
  44. {/* {item.showInfo && item.showInfo==='1'&& <img className={style['info-img']} src={info} />} */}
  45. {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}
  46. </span>)
  47. })}
  48. </div> }
  49. </div>: '' }
  50. {/* { title !== '药品推荐' ? <div>
  51. { drugDesc && drugDesc.length > 0 && <div className={style['drug-desc-wrapper']}>
  52. <h3 className={style['drug-title']}>说明</h3>
  53. {drugDesc.map((item, index) =>{
  54. return <div className={style['drug-desc-item']}>{item.title}: <span dangerouslySetInnerHTML ={{__html: item.content}}></span> </div>
  55. })}
  56. </div> }
  57. </div>: '' } */}
  58. </div>)
  59. }
  60. }
  61. export default TreatDesc;