index.jsx 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. import React, { Component } from 'react';
  2. import style from './index.less';
  3. import {ConfirmModal} from '@commonComp';
  4. import Notify from '@commonComp/Notify';
  5. class DiagnosticItem extends Component{
  6. constructor(props){
  7. super(props);
  8. this.state = {
  9. visible: false
  10. }
  11. this.addDiagodal = this.addDiagodal.bind(this);
  12. this.chooseDiagodal = this.chooseDiagodal.bind(this);
  13. this.confirm = this.confirm.bind(this);
  14. this.cancel = this.cancel.bind(this)
  15. this.close = this.close.bind(this)
  16. }
  17. confirm() {
  18. this.close();
  19. const diagType = 1;
  20. this.addDiagodal(diagType)
  21. }
  22. cancel() {
  23. this.close();
  24. const diagType = 2;
  25. this.addDiagodal(diagType)
  26. }
  27. close(){
  28. this.setState({
  29. visible: false
  30. })
  31. }
  32. chooseDiagodal(item) {
  33. const { diagnosticList,getTips } = this.props;
  34. getTips && getTips(item);
  35. for (let i = 0; i < diagnosticList.length; i++) {
  36. if(diagnosticList[i].id === item.id && diagnosticList[i].name === item.name) {
  37. Notify.info('该诊断已存在');
  38. return
  39. }
  40. }
  41. this.setState({
  42. visible: true
  43. })
  44. }
  45. addDiagodal(diagType){
  46. const {item} = this.props;
  47. item.type = diagType;
  48. // setTimeout(()=>{
  49. // this.setState({
  50. // visible: false,
  51. // },()=>{
  52. const { diagnosticList, addDiagnostic, clearInput, hideSearch } = this.props;
  53. for (let i = 0; i < diagnosticList.length; i++) {
  54. if(diagnosticList[i].id === item.id && diagnosticList[i].name === item.name) {
  55. Notify.info('该诊断已存在');
  56. return
  57. }
  58. }
  59. addDiagnostic&&addDiagnostic(item);
  60. clearInput&&clearInput();
  61. hideSearch&&hideSearch()
  62. // })
  63. // }, 0)
  64. }
  65. render(){
  66. const { visible } = this.state
  67. const { item, title } = this.props
  68. return (<span className={style['diag-item']} >
  69. <span className={style['diag-name']}
  70. title = {title && item.name + (item.showType === 2 || item.showType === 3 ? '('+ item.retrievalName+')': '')}
  71. onClick={() =>{this.chooseDiagodal(item)}}>
  72. {item.name} {item.showType === 2 || item.showType === 3 ? '('+ item.retrievalName+')': ''}
  73. </span>
  74. <ConfirmModal visible={visible} okText='初诊' cancelText='复诊' confirm={this.confirm} cancel={this.cancel} close={this.close}>
  75. <div className={style['confirm-info']}>确定选择“{item.name}”为</div>
  76. </ConfirmModal>
  77. </span>)
  78. }
  79. }
  80. export default DiagnosticItem;