index.jsx 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. import React, { Component } from 'react';
  2. import style from './index.less';
  3. import {ConfirmModal} from '@commonComp';
  4. import Notify from '@commonComp/Notify';
  5. import infoShow from '@common/images/info-show.png';
  6. import infoMove from '@common/images/info-move.png';
  7. import {getChronic} from '@store/async-actions/homePage.js';
  8. import {storageLocal} from '@utils/tools';
  9. class DiagnosticItem extends Component{
  10. constructor(props){
  11. super(props);
  12. this.state = {
  13. visible: false,
  14. hasEnterItem: false,
  15. hasEnterImg: false
  16. }
  17. this.addDiagodal = this.addDiagodal.bind(this);
  18. this.chooseDiagodal = this.chooseDiagodal.bind(this);
  19. this.confirm = this.confirm.bind(this);
  20. this.cancel = this.cancel.bind(this)
  21. this.close = this.close.bind(this)
  22. this.getTips = this.getTips.bind(this)
  23. }
  24. confirm() {
  25. this.props.setHighter&&this.props.setHighter(48)
  26. this.close();
  27. const diagType = 1;
  28. this.addDiagodal(diagType)
  29. }
  30. cancel() {
  31. this.props.setHighter&&this.props.setHighter(48)
  32. this.close();
  33. const diagType = 2;
  34. this.addDiagodal(diagType)
  35. }
  36. close(){
  37. this.setState({
  38. visible: false
  39. })
  40. }
  41. chooseDiagodal(item) {
  42. const { diagnosticList,getTips, type } = this.props;
  43. // getTips && getTips(item);
  44. // if (type == 'search') {
  45. // getTips && getTips({type:7,name: item.name, position: 1});
  46. // }
  47. for (let i = 0; i < diagnosticList.length; i++) {
  48. if(diagnosticList[i].id === item.id && diagnosticList[i].name === item.name) {
  49. Notify.info('该诊断已存在');
  50. return
  51. }
  52. }
  53. this.setState({
  54. visible: true
  55. })
  56. }
  57. getTips(item, e) {
  58. e.stopPropagation();
  59. const {getTips } = this.props;
  60. getTips && getTips({id:item.id,type:7,name: item.name, position: 1});
  61. }
  62. addDiagodal(diagType){
  63. const {item, isChronicMag} = this.props;
  64. item.type = diagType;
  65. const { addDiagnostic, clearInput, hideSearch } = this.props;
  66. if(item.type == 2) {
  67. isChronicMag(item);
  68. }
  69. addDiagnostic&&addDiagnostic(item);
  70. clearInput&&clearInput();
  71. hideSearch&&hideSearch();
  72. this.context.scrollArea&&this.context.scrollArea.refresh();
  73. //document.getElementById("diagnosisResult").scrollIntoView(true)
  74. }
  75. handleMouseEnterDrug() {
  76. this.setState({
  77. hasEnterItem: true,
  78. })
  79. }
  80. handleMouseLeaveDrug() {
  81. this.setState({
  82. hasEnterItem: false,
  83. })
  84. }
  85. handleMouseEnterImg() {
  86. this.setState({
  87. hasEnterImg: true
  88. })
  89. }
  90. handleMouseLeaveImg() {
  91. this.setState({
  92. hasEnterImg: false
  93. })
  94. }
  95. render(){
  96. const { visible,hasEnterItem,hasEnterImg } = this.state
  97. const { item, title, type } = this.props
  98. return (<span className={style['diag-item']} >
  99. <span className={`${style['diag-name']}`}
  100. title = {title && item.name + (item.showType === 2 || item.showType === 3 ? '('+ item.retrievalName+')': '')}
  101. onMouseEnter={this.handleMouseEnterDrug.bind(this)}
  102. onMouseLeave = {this.handleMouseLeaveDrug.bind(this)}
  103. onClick={() =>{this.chooseDiagodal(item)}}
  104. >
  105. <p className={`${style['diag-name-box']} ${type == 'search'?style['diag-name-search']:style['diag-name-disSelect']}`}>{item.name} {item.retrievalName ? '('+ item.retrievalName+')': ''}</p>
  106. {type== 'disSelect' &&<img className={style['info-img']}
  107. title='点击i图标可查看详细说明'
  108. style ={hasEnterItem ? {display: "inline-block"} : {display: "none"}}
  109. src={hasEnterImg ? infoMove : infoShow}
  110. onMouseEnter={this.handleMouseEnterImg.bind(this)}
  111. onMouseLeave = {this.handleMouseLeaveImg.bind(this)}
  112. onClick={this.getTips.bind(this,item)}
  113. />}
  114. </span>
  115. <ConfirmModal visible={visible} okText='初诊' cancelText='复诊' confirm={this.confirm} cancel={this.cancel} close={this.close}>
  116. <div className={style['confirm-info']}>确定选择“{item.name}”为</div>
  117. </ConfirmModal>
  118. </span>)
  119. }
  120. }
  121. DiagnosticItem.contextTypes = {
  122. scrollArea: React.PropTypes.object
  123. };
  124. export default DiagnosticItem;