index.jsx 3.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. import React, { Component } from 'react';
  2. import style from './index.less';
  3. import info2 from './../img/info2.png';
  4. import info3 from './../img/info3.png';
  5. import $ from "jquery";
  6. class AdverseReactions extends Component {
  7. constructor(props){
  8. super(props);
  9. this.state = {
  10. currentIndex: -1
  11. }
  12. this.handleMouseLeaveDrug = this.handleMouseLeaveDrug.bind(this);
  13. this.handleMouseLeaveImg = this.handleMouseLeaveImg.bind(this);
  14. this.setDrugInfo = this.setDrugInfo.bind(this);
  15. }
  16. changeReact(it, index) {
  17. this.props.changeReact(it, index);
  18. }
  19. handleMouseEnterDrug(index, item) {
  20. this.setState({
  21. currentIndex: index,
  22. })
  23. }
  24. handleMouseLeaveDrug() {
  25. this.setState({
  26. currentIndex: -1,
  27. })
  28. }
  29. handleMouseEnterImg() {
  30. this.setState({
  31. hasEnterImg: true
  32. })
  33. }
  34. handleMouseLeaveImg() {
  35. this.setState({
  36. hasEnterImg: false
  37. })
  38. }
  39. setDrugInfo(item) {
  40. const { setDrugInfo } = this.props;
  41. setDrugInfo && setDrugInfo(item, 10, 6);
  42. }
  43. render() {
  44. const { icon, titleStyle,titleBg, filter, title, adversReactionList, showDrugInfo, setDrugInfo } = this.props
  45. const { currentIndex, hasEnterImg } = this.state
  46. return(
  47. <div className={style['last-treat-wrapper']}>
  48. <div className={style['last-treat-title-box']} style={titleStyle}></div>
  49. <div className={style['last-treat-title']} ><img className={style['last-treat-icon']} src={icon}/>{title}</div>
  50. {/* {console.log('adversReactionList', adversReactionList)} */}
  51. {adversReactionList.map((item, index) => {
  52. return (<div className={style['adverse-reactions-item']} key={item.id}>
  53. <span className={style['last-treat-name-box']}
  54. >
  55. <span
  56. className={style['last-treat-big-name-box']}
  57. onMouseEnter={this.handleMouseEnterDrug.bind(this, index, item)}
  58. onMouseLeave = {this.handleMouseLeaveDrug}
  59. >
  60. <span className={style['last-treat-big-name']} >{item.tagName}:
  61. {<img className={style['info-img']}
  62. style ={currentIndex === index ? {display: "inline-block"} : {display: "none"}}
  63. src={currentIndex === index ?(hasEnterImg ? info3 : info2 ): info2}
  64. onMouseEnter={this.handleMouseEnterImg.bind(this)}
  65. onMouseLeave = {this.handleMouseLeaveImg}
  66. onClick={() =>{this.setDrugInfo(item);showDrugInfo();}}/>}
  67. </span>
  68. </span>
  69. </span>
  70. {item.details.map((it, idx) => {
  71. return <span className={style['adverse-reactions-name']} key={item.id + it.name}>
  72. <input type="checkbox" checked={it.select} id={item.id + it.name} onChange={this.changeReact.bind(this, it, index)}/>
  73. <label for={item.id + it.name}> {it.name} </label>
  74. {it.value==1 && <span className={style['adverse-reactions-recommend']}>(智能推荐)</span>}
  75. </span>
  76. })}
  77. </div>)
  78. })}
  79. </div>
  80. )
  81. }
  82. }
  83. export default AdverseReactions;