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(80)
  30. this.close();
  31. const diagType = 1;
  32. this.addDiagodal(diagType)
  33. }
  34. cancel() {
  35. this.props.setHighter&&this.props.setHighter(80)
  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,isTcm,tcmList,symList,showSym} = this.props;
  47. const list = isTcm?(showSym?symList:tcmList):diagnosticList;
  48. const tipName = isTcm?(showSym?'中医症候':'中医诊断'):'诊断';
  49. for (let i = 0; i < list.length; i++) {
  50. if(list[i].name === item.name) {
  51. Notify.info('该'+tipName+'已存在');
  52. return
  53. }
  54. }
  55. this.props.setHighter&&this.props.setHighter(80)
  56. const diagType = 1;
  57. this.addDiagodal(diagType)
  58. this.setState({
  59. visible: true
  60. })
  61. }
  62. getTips(item, e) {
  63. e.stopPropagation();
  64. const {getTips } = this.props;
  65. getTips && getTips({id:item.id,type:7,name: item.name, position: 1});
  66. }
  67. addDiagodal(diagType){
  68. const {item,EMRScrollCont,isTcm,showSym,type,addDiagnostic, clearInput, hideSearch} = this.props;
  69. item.type = diagType;
  70. /*if(item.type == 2&&mode=='0') { //文本模式不走慢病。6.0慢病取消
  71. isChronicMag(item);
  72. }*/
  73. addDiagnostic&&addDiagnostic(item,isTcm,showSym);
  74. clearInput&&clearInput();
  75. hideSearch&&hideSearch();
  76. this.context.scrollArea&&this.context.scrollArea.refresh();
  77. //document.getElementById("diagnosisResult").scrollIntoView(true)
  78. if(type == 'disSelect') {
  79. const scrollTop = document.getElementById("diagnosisResult").offsetTop
  80. setTimeout(() =>{
  81. EMRScrollCont.scrollYTo(scrollTop);
  82. })
  83. }
  84. store.dispatch(getMRAnalyse())
  85. }
  86. handleMouseEnterDrug() {
  87. this.setState({
  88. hasEnterItem: true,
  89. })
  90. }
  91. handleMouseLeaveDrug() {
  92. this.setState({
  93. hasEnterItem: false,
  94. })
  95. }
  96. handleMouseEnterImg() {
  97. this.setState({
  98. hasEnterImg: true
  99. })
  100. }
  101. handleMouseLeaveImg() {
  102. this.setState({
  103. hasEnterImg: false
  104. })
  105. }
  106. render(){
  107. const { visible,hasEnterItem,hasEnterImg } = this.state
  108. const { item, title, type } = this.props
  109. return (<span className={style['diag-item']} >
  110. <span className={`${style['diag-name']}`}
  111. title = {item.name}
  112. onMouseEnter={this.handleMouseEnterDrug.bind(this)}
  113. onMouseLeave = {this.handleMouseLeaveDrug.bind(this)}
  114. onClick={() =>{this.chooseDiagodal(item)}}
  115. >
  116. <p className={`${style['diag-name-box']} ${type == 'search'?style['diag-name-search']:style['diag-name-disSelect']}`}>{item.name} </p>
  117. {/* {type== 'disSelect' &&<img className={style['info-img']}
  118. title='点击i图标可查看详细说明'
  119. style ={hasEnterItem ? {display: "inline-block"} : {display: "none"}}
  120. src={hasEnterImg ? infoMove : infoShow}
  121. onMouseEnter={this.handleMouseEnterImg.bind(this)}
  122. onMouseLeave = {this.handleMouseLeaveImg.bind(this)}
  123. onClick={this.getTips.bind(this,item)}
  124. />} */}
  125. </span>
  126. {/* <ConfirmModal visible={visible} okText='初诊' cancelText='复诊' confirm={this.confirm} cancel={this.cancel} close={this.close}>
  127. <div className={style['confirm-info']}>确定选择“{item.name}”为</div>
  128. </ConfirmModal> */}
  129. </span>)
  130. }
  131. }
  132. DiagnosticItem.contextTypes = {
  133. scrollArea: React.PropTypes.object
  134. };
  135. export default DiagnosticItem;