index.jsx 5.6 KB

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