index.jsx 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. import React, { Component } from 'react';
  2. import style from './index.less';
  3. import info from './../img/info.png';
  4. import drugIcon from './../img/drug.png';
  5. import more from '@common/images/addItem1.png';
  6. import $ from "jquery";
  7. class DrugTreat extends Component {
  8. constructor(props) {
  9. super(props);
  10. this.handleSelect = this.handleSelect.bind(this);
  11. this.setOtherRecommend = this.setOtherRecommend.bind(this);
  12. this.setDrugInfo = this.setDrugInfo.bind(this);
  13. this.showTreatDesc = this.showTreatDesc.bind(this);
  14. }
  15. handleSelect(index,ii) {
  16. const { selectDrug } = this.props;
  17. selectDrug && selectDrug(index,ii);
  18. }
  19. setOtherRecommend(item, index) {
  20. this.showTreatDesc();
  21. const { setOtherRecommend } = this.props;
  22. setOtherRecommend && setOtherRecommend(item, index);
  23. }
  24. setDrugInfo(item) {
  25. const { setDrugInfo } = this.props;
  26. setDrugInfo && setDrugInfo(item);
  27. }
  28. showTreatDesc() {
  29. $('#treatDescBox').css({'display': 'block'});
  30. $('#treatWrapper').animate({'margin-left': '-470px'}, 300);
  31. $('#treatDescBox').animate({'width': '260px'}, 500);
  32. }
  33. render(){
  34. const { treatment,showDrugInfo } = this.props
  35. return(
  36. treatment && treatment.length > 0 && <div className={style['drug-box']}>
  37. <h3 className={style['drug-title']}><img className={style['drug-icon']} src={drugIcon}/> 常用药物治疗</h3>
  38. {treatment.map((item, index) => {
  39. return(<div className={style['drug-content']}>
  40. <div className={style['drug-name-box']}>
  41. {index + 1 + '. ' }{item.drugsName}:&nbsp;
  42. {item.medicitionsList.map((it, ii) => {
  43. return ((it.isShow == 1 || it.selected) && <span style={it.forbidden === '2' ? {opacity: '0.3', filter:'alpha(opacity=30)'} : ''}>
  44. {ii === 0 ? '' : ', '}
  45. <span className={style['drug-name']}
  46. onDoubleClick={() =>{this.setDrugInfo(it);showDrugInfo();}}
  47. onClick={()=>{it.forbidden === '2' ? '' : this.handleSelect(index,ii)}} style={it.selected ? {color: '#3B9ED0', borderBottom: '1px solid #3B9ED0'}:''}>
  48. {it.medicitionName}
  49. </span>
  50. {/* {it.showInfo && it.showInfo==='1'&& <img className={style['info-img']} src={info} onClick={() =>{this.setDrugInfo(it);showDrugInfo();}}/>} */}
  51. {it.forbidden === '1' ? <span className={style['info-flag']} style={{border: '1px solid #F4C051', background: '#F4C051',marginLeft: '5px'}}>慎用</span>: it.forbidden === '2' ? <span className={style['info-flag']} style={{border: '1px solid #000',marginLeft: '5px'}}>禁用</span> : ''}, 使用率{it.rate}
  52. </span>)
  53. })}
  54. </div>
  55. {<div className={style['drug-more']} onClick={() =>this.setOtherRecommend(item, index)} ><img className={style['info-img']} src={more} />更多同类药</div> }
  56. </div>)
  57. })}
  58. </div>
  59. )
  60. }
  61. }
  62. export default DrugTreat;