index.jsx 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  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.close();
  26. const diagType = 1;
  27. this.addDiagodal(diagType)
  28. }
  29. cancel() {
  30. this.close();
  31. const diagType = 2;
  32. this.addDiagodal(diagType)
  33. }
  34. close(){
  35. this.setState({
  36. visible: false
  37. })
  38. }
  39. chooseDiagodal(item) {
  40. const { diagnosticList,getTips, type } = this.props;
  41. // getTips && getTips(item);
  42. if (type == 'search') {
  43. getTips && getTips({id:item.id,type:7});
  44. }
  45. for (let i = 0; i < diagnosticList.length; i++) {
  46. if(diagnosticList[i].id === item.id && diagnosticList[i].name === item.name) {
  47. Notify.info('该诊断已存在');
  48. return
  49. }
  50. }
  51. this.setState({
  52. visible: true
  53. })
  54. }
  55. getTips(item, e) {
  56. e.stopPropagation();
  57. const {getTips } = this.props;
  58. getTips && getTips({id:item.id,type:7});
  59. }
  60. addDiagodal(diagType){
  61. const {item, isChronicMag,mode} = this.props;
  62. item.type = diagType;
  63. // setTimeout(()=>{
  64. // this.setState({
  65. // visible: false,
  66. // },()=>{
  67. const { diagnosticList, addDiagnostic, clearInput, hideSearch } = this.props;
  68. // for (let i = 0; i < diagnosticList.length; i++) {
  69. // if(diagnosticList[i].id === item.id && diagnosticList[i].name === item.name) {
  70. // Notify.info('该诊断已存在');
  71. // return
  72. // }
  73. // }
  74. if(item.type == 2&&mode==0) {
  75. isChronicMag(item);
  76. }
  77. // 从缓存取慢病列表
  78. // let chronicList = JSON.parse(storageLocal.get('chronic'));
  79. // if(!chronicList){
  80. // getChronic();
  81. // chronicList = JSON.parse(storageLocal.get('chronic'));
  82. // }
  83. // console.log(999,chronicList)
  84. // for(let i=0; i<chronicList.length; i++){
  85. // if(chronicList[i].id==item.id&&chronicList[i].name==item.name){
  86. // //弹窗提示 “是否引用往期病例”?--往期病例接口、弹窗、引用
  87. // // 是--引用 否--走慢病流程
  88. // console.log("是慢病!")
  89. // }
  90. // }
  91. addDiagnostic&&addDiagnostic(item);
  92. clearInput&&clearInput();
  93. hideSearch&&hideSearch()
  94. // })
  95. // }, 0)
  96. document.getElementById("diagnosisResult").scrollIntoView(true)
  97. }
  98. handleMouseEnterDrug() {
  99. this.setState({
  100. hasEnterItem: true,
  101. })
  102. }
  103. handleMouseLeaveDrug() {
  104. this.setState({
  105. hasEnterItem: false,
  106. })
  107. }
  108. handleMouseEnterImg() {
  109. this.setState({
  110. hasEnterImg: true
  111. })
  112. }
  113. handleMouseLeaveImg() {
  114. this.setState({
  115. hasEnterImg: false
  116. })
  117. }
  118. render(){
  119. const { visible,hasEnterItem,hasEnterImg } = this.state
  120. const { item, title, type } = this.props
  121. return (<span className={style['diag-item']} >
  122. <span className={style['diag-name']}
  123. title = {title && item.name + (item.showType === 2 || item.showType === 3 ? '('+ item.retrievalName+')': '')}
  124. onMouseEnter={this.handleMouseEnterDrug.bind(this)}
  125. onMouseLeave = {this.handleMouseLeaveDrug.bind(this)}
  126. onClick={() =>{this.chooseDiagodal(item)}}
  127. >
  128. {item.name} {item.showType === 2 || item.showType === 3 ? '('+ item.retrievalName+')': ''}
  129. {type== 'disSelect' &&<img className={style['info-img']}
  130. style ={hasEnterItem ? {display: "inline-block"} : {display: "none"}}
  131. src={hasEnterImg ? infoMove : infoShow}
  132. onMouseEnter={this.handleMouseEnterImg.bind(this)}
  133. onMouseLeave = {this.handleMouseLeaveImg.bind(this)}
  134. onClick={this.getTips.bind(this,item)}
  135. />}
  136. </span>
  137. <ConfirmModal visible={visible} okText='初诊' cancelText='复诊' confirm={this.confirm} cancel={this.cancel} close={this.close}>
  138. <div className={style['confirm-info']}>确定选择“{item.name}”为</div>
  139. </ConfirmModal>
  140. </span>)
  141. }
  142. }
  143. export default DiagnosticItem;