index.jsx 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. import React,{Component} from 'react';
  2. import style from './index.less';
  3. import infoShow from '@common/images/info-show.png';
  4. import infoMove from '@common/images/info-move.png';
  5. import $ from 'jquery';
  6. class HasInfoItem extends Component {
  7. constructor(props) {
  8. super(props)
  9. this.state = {
  10. hasEnterItem: false,
  11. hasEnterImg: false
  12. }
  13. }
  14. handleMouseEnterDrug(){
  15. this.setState({
  16. hasEnterItem: true
  17. })
  18. }
  19. handleMouseLeaveDrug(){
  20. this.setState({
  21. hasEnterItem: false
  22. })
  23. }
  24. handleMouseEnterImg(){
  25. this.setState({
  26. hasEnterImg: true
  27. })
  28. }
  29. handleMouseLeaveImg(){
  30. this.setState({
  31. hasEnterImg: false
  32. })
  33. }
  34. setDrugInfo(item,e){
  35. e.stopPropagation();
  36. const{ setDrugInfo } = this.props
  37. setDrugInfo && setDrugInfo(item)
  38. }
  39. handleSelect(){
  40. const{ handleSelect, position } = this.props
  41. handleSelect && handleSelect(position)
  42. }
  43. render(){
  44. const { item } = this.props
  45. const { hasEnterItem, hasEnterImg} = this.state
  46. return (<span className={style['drug-name-wrapper']} >
  47. <span className={`${style['drug-name']} ${item.forbidden === '2' ? style['disabled']: item.selected ? style['selected'] : ''}`}
  48. // onDoubleClick={() =>{this.setDrugInfo(it);showDrugInfo();}} //药品说明双击显示(现在为点击图标显示)
  49. onClick={()=>{item.forbidden === '2' ? '' : this.handleSelect()}}
  50. onMouseEnter={this.handleMouseEnterDrug.bind(this)}
  51. onMouseLeave = {this.handleMouseLeaveDrug.bind(this)}
  52. >
  53. {item.medicitionName}
  54. {<img className={`${style['info-img']} ${hasEnterItem?style['show-content']:style['hide-content']}`}
  55. title='点击i图标可查看详细说明'
  56. src={hasEnterImg?infoMove:infoShow}
  57. onMouseEnter={this.handleMouseEnterImg.bind(this)}
  58. onMouseLeave = {this.handleMouseLeaveImg.bind(this)}
  59. onClick={this.setDrugInfo.bind(this,item)}/>}
  60. </span>
  61. {(item.forbidden === '1'||item.forbidden === '2') && <span className={`${style['info-flag']} ${item.forbidden === '1' ? style['cautious']:item.forbidden === '2'?style['disabled']:''}`}>
  62. {item.forbidden === '1' ? "慎用":item.forbidden === '2'? "禁用":""}
  63. </span>}
  64. {/*<span style={item.forbidden === '2' ? {opacity: '0.3', filter:'alpha(opacity=30)',filter:'progid:DXImageTransform.Microsoft.Alpha(opacity=30)'} : ''}> 使用率{item.rate}</span>*/}
  65. </span>)
  66. }
  67. }
  68. export default HasInfoItem;