index.jsx 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. import React, { Component } from 'react';
  2. import style from './index.less';
  3. import info from './../img/info.png';
  4. import info1 from './../img/info1.png';
  5. import info2 from './../img/info2.png';
  6. import info3 from './../img/info3.png';
  7. import drugIcon from './../img/drug.png';
  8. import more from '@common/images/addItem1.png';
  9. import $ from "jquery";
  10. class DrugTreat extends Component {
  11. constructor(props) {
  12. super(props);
  13. this.state = {
  14. currentImg: -1,
  15. }
  16. this.handleSelect = this.handleSelect.bind(this);
  17. this.setOtherRecommend = this.setOtherRecommend.bind(this);
  18. this.setDrugInfo = this.setDrugInfo.bind(this);
  19. this.showTreatDesc = this.showTreatDesc.bind(this);
  20. this.handleMouseLeaveDrug = this.handleMouseLeaveDrug.bind(this);
  21. this.handleMouseLeaveImg = this.handleMouseLeaveImg.bind(this);
  22. this.getImg = this.getImg.bind(this);
  23. }
  24. handleSelect(index,ii) {
  25. const { selectDrug } = this.props;
  26. selectDrug && selectDrug(index,ii);
  27. }
  28. handleMouseEnterDrug(ii, index, it) {
  29. this.setState({
  30. currentIndex: index,
  31. currentImg: ii
  32. })
  33. }
  34. handleMouseLeaveDrug() {
  35. this.setState({
  36. currentIndex: -1,
  37. })
  38. }
  39. handleMouseEnterImg() {
  40. this.setState({
  41. hasEnterImg: true
  42. })
  43. }
  44. handleMouseLeaveImg() {
  45. this.setState({
  46. hasEnterImg: false
  47. })
  48. }
  49. setOtherRecommend(item, index) {
  50. this.showTreatDesc();
  51. const { setOtherRecommend } = this.props;
  52. setOtherRecommend && setOtherRecommend(item, index);
  53. }
  54. setDrugInfo(item) {
  55. const { setDrugInfo } = this.props;
  56. setDrugInfo && setDrugInfo({name: item.medicitionName, type: 8, position: 5});
  57. }
  58. getImg() {
  59. }
  60. //搜索药品说明书(查看数据用)
  61. handleInputDrug(e) {
  62. this.setState({
  63. drugIdList: e.target.value
  64. })
  65. }
  66. //搜索药品说明书(查看数据用)
  67. searchDrug() {
  68. const { setDrugInfoMore } = this.props
  69. const drugIdList = this.state.drugIdList.split(' ')
  70. setDrugInfoMore({drugIdList: drugIdList})
  71. }
  72. showTreatDesc() {
  73. $('#treatDescBox').css({'display': 'block'});
  74. $('#dragModalWrap').animate({'margin-left': '-471px','left':'50%'}, 300);
  75. $('#treatDescBox').animate({'width': '260px'}, 500);
  76. }
  77. render(){
  78. const { treatment,showDrugInfo } = this.props
  79. const { currentImg, currentIndex, hasEnterImg } = this.state
  80. return(
  81. treatment && treatment.length > 0 && <div className={style['drug-box']}>
  82. <h3 className={style['drug-title']}><img className={style['drug-icon']} src={drugIcon}/> 常用药物治疗</h3>
  83. {/* 查看药物说明书 (添加数据查看数据用)*/}
  84. {/* <div> <input onInput={this.handleInputDrug.bind(this)} style={{border:'1px solid #000'}} type="text"/><button onClick = {this.searchDrug.bind(this)}>搜索药品说明</button></div> */}
  85. {treatment.map((item, index) => {
  86. return(<div className={style['drug-content']}>
  87. <div className={style['drug-name-box']}>
  88. <span style={item.drugsForbidden === '2'? {opacity: '0.3', filter:'alpha(opacity=30)',filter:'progid:DXImageTransform.Microsoft.Alpha(opacity=30)'} : ''}>{index + 1 + '. ' }{item.bigdrugsName}<span>{item.subdrugsName && '('+item.subdrugsName+')'}</span>:&nbsp;</span>
  89. {item.medicitionsList.map((it, ii) => {
  90. return ((it.isShow == 1 || it.selected) && <span >
  91. {ii === 0 ? '' : ', '}
  92. <span onMouseEnter={this.handleMouseEnterDrug.bind(this, ii , index, it)}
  93. onMouseLeave = {this.handleMouseLeaveDrug}
  94. className={style['drug-name-wrapper']}
  95. >
  96. <span className={style['drug-name']}
  97. // onDoubleClick={() =>{this.setDrugInfo(it);showDrugInfo();}} //药品说明双击显示(现在为点击图标显示)
  98. onClick={()=>{it.forbidden === '2' ? '' : this.handleSelect(index,ii)}}
  99. style={it.forbidden === '2' ? {opacity: '0.3', filter:'alpha(opacity=30)',filter:'progid:DXImageTransform.Microsoft.Alpha(opacity=30)'} : it.selected ? {color: '#3B9ED0', borderBottom: '1px solid #3B9ED0'}:''}
  100. >
  101. {it.medicitionName}
  102. </span>
  103. {<img className={style['info-img']}
  104. title='点击i图标可查看详细说明'
  105. style ={currentIndex === index ? (ii === currentImg ? {display: "inline-block"} : {display: "none"}) : {display: "none"}}
  106. src={currentIndex === index ? (ii === currentImg ? (hasEnterImg ? info3 : info2) : info2): info2}
  107. onMouseEnter={this.handleMouseEnterImg.bind(this, ii, index)}
  108. onMouseLeave = {this.handleMouseLeaveImg}
  109. onClick={this.setDrugInfo.bind(this,it)}/>}
  110. </span>
  111. {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={{opacity: '0.3',filter:'alpha(opacity=30)',filter:'progid:DXImageTransform.Microsoft.Alpha(opacity=30)',border: '1px solid #000',marginLeft: '5px'}}>禁用</span> : ''},
  112. <span style={it.forbidden === '2' ? {opacity: '0.3', filter:'alpha(opacity=30)',filter:'progid:DXImageTransform.Microsoft.Alpha(opacity=30)'} : ''}> 使用率{it.rate}</span>
  113. </span>)
  114. })}
  115. </div>
  116. {<div className={style['drug-more']} onClick={() =>this.setOtherRecommend(item, index)} ><img className={style['info-img-more']} src={more} />更多同类药</div> }
  117. </div>)
  118. })}
  119. </div>
  120. )
  121. }
  122. }
  123. export default DrugTreat;