index.jsx 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  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 {getChronic} from '@store/async-actions/homePage.js';
  6. import {storageLocal} from '@utils/tools';
  7. class DiagnosticItem extends Component{
  8. constructor(props){
  9. super(props);
  10. this.state = {
  11. visible: false
  12. }
  13. this.addDiagodal = this.addDiagodal.bind(this);
  14. this.chooseDiagodal = this.chooseDiagodal.bind(this);
  15. this.confirm = this.confirm.bind(this);
  16. this.cancel = this.cancel.bind(this)
  17. this.close = this.close.bind(this)
  18. }
  19. confirm() {
  20. this.close();
  21. const diagType = 1;
  22. this.addDiagodal(diagType)
  23. }
  24. cancel() {
  25. this.close();
  26. const diagType = 2;
  27. this.addDiagodal(diagType)
  28. }
  29. close(){
  30. this.setState({
  31. visible: false
  32. })
  33. }
  34. chooseDiagodal(item) {
  35. const { diagnosticList,getTips } = this.props;
  36. // getTips && getTips(item);
  37. getTips && getTips({id:item.id,type:7});
  38. for (let i = 0; i < diagnosticList.length; i++) {
  39. if(diagnosticList[i].id === item.id && diagnosticList[i].name === item.name) {
  40. Notify.info('该诊断已存在');
  41. return
  42. }
  43. }
  44. this.setState({
  45. visible: true
  46. })
  47. }
  48. addDiagodal(diagType){
  49. const {item, isChronicMag,mode} = this.props;
  50. item.type = diagType;
  51. // setTimeout(()=>{
  52. // this.setState({
  53. // visible: false,
  54. // },()=>{
  55. const { diagnosticList, addDiagnostic, clearInput, hideSearch } = this.props;
  56. // for (let i = 0; i < diagnosticList.length; i++) {
  57. // if(diagnosticList[i].id === item.id && diagnosticList[i].name === item.name) {
  58. // Notify.info('该诊断已存在');
  59. // return
  60. // }
  61. // }
  62. if(item.type == 2&&mode==0) {
  63. isChronicMag(item);
  64. }
  65. // 从缓存取慢病列表
  66. // let chronicList = JSON.parse(storageLocal.get('chronic'));
  67. // if(!chronicList){
  68. // getChronic();
  69. // chronicList = JSON.parse(storageLocal.get('chronic'));
  70. // }
  71. // console.log(999,chronicList)
  72. // for(let i=0; i<chronicList.length; i++){
  73. // if(chronicList[i].id==item.id&&chronicList[i].name==item.name){
  74. // //弹窗提示 “是否引用往期病例”?--往期病例接口、弹窗、引用
  75. // // 是--引用 否--走慢病流程
  76. // console.log("是慢病!")
  77. // }
  78. // }
  79. addDiagnostic&&addDiagnostic(item);
  80. clearInput&&clearInput();
  81. hideSearch&&hideSearch()
  82. // })
  83. // }, 0)
  84. document.getElementById("diagnosisResult").scrollIntoView(true)
  85. }
  86. render(){
  87. const { visible } = this.state
  88. const { item, title } = this.props
  89. return (<span className={style['diag-item']} >
  90. <span className={style['diag-name']}
  91. title = {title && item.name + (item.showType === 2 || item.showType === 3 ? '('+ item.retrievalName+')': '')}
  92. onClick={() =>{this.chooseDiagodal(item)}}>
  93. {item.name} {item.showType === 2 || item.showType === 3 ? '('+ item.retrievalName+')': ''}
  94. </span>
  95. <ConfirmModal visible={visible} okText='初诊' cancelText='复诊' confirm={this.confirm} cancel={this.cancel} close={this.close}>
  96. <div className={style['confirm-info']}>确定选择“{item.name}”为</div>
  97. </ConfirmModal>
  98. </span>)
  99. }
  100. }
  101. export default DiagnosticItem;