index.jsx 5.2 KB

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