index.jsx 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. import React, { Component } from 'react';
  2. import style from './index.less';
  3. import del_icon from './img/delete.png'
  4. import diagUp from './img/diagUp.png'
  5. import diagDown from './img/diagDown.png'
  6. import {ConfirmModal, Message} from '@commonComp';
  7. import Notify from '@commonComp/Notify';
  8. import Treat from '@containers/Treat'
  9. class DiagnosticList extends Component {
  10. constructor(props) {
  11. super(props);
  12. this.state = {
  13. visible: false,
  14. delId: '',
  15. treatTitle: ''
  16. }
  17. this.deleteItem = this.deleteItem.bind(this);
  18. this.cancel = this.cancel.bind(this);
  19. this.close = this.close.bind(this);
  20. this.showTreat = this.showTreat.bind(this);
  21. this.handleClickDiag = this.handleClickDiag.bind(this);
  22. }
  23. componentWillReceiveProps() {
  24. this.props.getBilling();
  25. }
  26. upDiagnostic(index) {
  27. const { upDiagnostic } = this.props;
  28. upDiagnostic && upDiagnostic(index)
  29. }
  30. downDiagnostic(index) {
  31. const { downDiagnostic } = this.props;
  32. downDiagnostic && downDiagnostic(index)
  33. }
  34. deleteItem() {
  35. const { delId } = this.state;
  36. const { delDiagnostic } = this.props;
  37. delDiagnostic && delDiagnostic(delId);
  38. this.setState({
  39. visible: false,
  40. })
  41. Notify.success('删除成功')
  42. }
  43. cancel() {
  44. this.setState({
  45. visible: false
  46. })
  47. }
  48. close() {
  49. this.setState({
  50. visible: false
  51. })
  52. }
  53. handleDeleteItem(id) {
  54. this.setState({
  55. visible: true,
  56. delId: id,
  57. })
  58. }
  59. showTreat(item) {
  60. const { showTreat, getTreatResult } = this.props;
  61. getTreatResult && getTreatResult(item);
  62. showTreat && showTreat();
  63. this.setState({
  64. treatTitle: item.name
  65. })
  66. }
  67. handleClickDiag(item) {
  68. const { getTips } = this.props;
  69. getTips && getTips(item);
  70. }
  71. render(){
  72. const { list, treatment } = this.props
  73. const { visible, treatTitle } = this.state
  74. const lastIndex = list.length -1;
  75. return(
  76. <div className={style['diaglist-wrap']}>
  77. {list && (list.length > 0) && list.map((item, index) => {
  78. const hasTreat = item.treat && (item.treat.commonTreatment || item.treat.surgeryTreatment || item.treat.treatment.length>0)
  79. return (<div draggable={true} className={style['diag-box'] + ' clearfix'} key={item.id} >
  80. {index === 0 ? '' : <span className={style['diag-up']} onClick={() => {this.upDiagnostic(index)}}><img className={style["diag-up"]} src={diagUp}/></span>}
  81. {list.length === 1 ? '' : index !== 0 ? '' : <span onClick={() => {this.downDiagnostic(index)}} className={style['diag-down']}><img className={style["diag-down"]} src={diagDown}/></span>}
  82. <span className={style['diag-number']} style={{fontWeight:index === 0 ?'bold':'normal'}}>{index === 0 ? '主' : index+1}</span>
  83. <span className={style['diag-name']} onClick={()=>{this.handleClickDiag(item)}}>{item.name}<span></span></span>
  84. {item.type === 1 ? <span className={style['diag-first']}>初诊</span> :<span className={style['diag-second']}> 复诊</span>}
  85. <span className={style['treat']}
  86. style ={{ color: hasTreat ?'' : 'gray', border: hasTreat ?'1px solid #3B9ED0' : '1px solid gray'}}
  87. onClick={() =>{hasTreat && this.showTreat(item)}}>
  88. 治疗方案
  89. </span>
  90. <img className={style['diag-del']} src={del_icon} onClick={()=>{this.handleDeleteItem(item.id)}}/>
  91. </div>)
  92. })}
  93. {treatment&&<Treat title={treatTitle}></Treat>}
  94. <ConfirmModal visible={visible}
  95. okText='删除'
  96. cancelText='取消'
  97. confirm={this.deleteItem}
  98. cancel={this.cancel}
  99. close={this.close}
  100. >
  101. <div className={style['del-msg']}>是否删除该诊断?</div>
  102. </ConfirmModal>
  103. </div>
  104. )
  105. }
  106. }
  107. export default DiagnosticList;