index.jsx 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  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. this.setState({
  36. visible: true
  37. })
  38. const { getTips } = this.props;
  39. getTips && getTips(item);
  40. }
  41. addDiagodal(diagType){
  42. const {item, isChronicMag} = this.props;
  43. item.type = diagType;
  44. // setTimeout(()=>{
  45. // this.setState({
  46. // visible: false,
  47. // },()=>{
  48. const { diagnosticList, addDiagnostic, clearInput, hideSearch } = this.props;
  49. for (let i = 0; i < diagnosticList.length; i++) {
  50. if(diagnosticList[i].id === item.id && diagnosticList[i].name === item.name) {
  51. Notify.info('该诊断已存在');
  52. return
  53. }
  54. }
  55. isChronicMag(item);
  56. // 从缓存取慢病列表
  57. let chronicList = JSON.parse(storageLocal.get('chronic'));
  58. if(!chronicList){
  59. getChronic();
  60. chronicList = JSON.parse(storageLocal.get('chronic'));
  61. }
  62. console.log(999,chronicList)
  63. for(let i=0; i<chronicList.length; i++){
  64. if(chronicList[i].id==item.id&&chronicList[i].name==item.name){
  65. //弹窗提示 “是否引用往期病例”?--往期病例接口、弹窗、引用
  66. // 是--引用 否--走慢病流程
  67. console.log("是慢病!")
  68. }
  69. }
  70. addDiagnostic&&addDiagnostic(item);
  71. clearInput&&clearInput();
  72. hideSearch&&hideSearch()
  73. // })
  74. // }, 0)
  75. }
  76. render(){
  77. const { visible } = this.state
  78. const { item, title } = this.props
  79. return (<span className={style['diag-item']} >
  80. <span className={style['diag-name']}
  81. title = {title && item.name + (item.showType === 2 || item.showType === 3 ? '('+ item.retrievalName+')': '')}
  82. onClick={() =>{this.chooseDiagodal(item)}}>
  83. {item.name} {item.showType === 2 || item.showType === 3 ? '('+ item.retrievalName+')': ''}
  84. </span>
  85. <ConfirmModal visible={visible} okText='初诊' cancelText='复诊' confirm={this.confirm} cancel={this.cancel} close={this.close}>
  86. <div className={style['confirm-info']}>确定选择“{item.name}”为</div>
  87. </ConfirmModal>
  88. </span>)
  89. }
  90. }
  91. export default DiagnosticItem;