index.jsx 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  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. delItem: {},
  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(nextprops) {
  24. if (this.props.diagnosticStr != nextprops.diagnosticStr) {
  25. this.props.getBilling();
  26. }
  27. }
  28. upDiagnostic(index) {
  29. const { upDiagnostic } = this.props;
  30. upDiagnostic && upDiagnostic(index)
  31. }
  32. downDiagnostic(index) {
  33. const { downDiagnostic } = this.props;
  34. downDiagnostic && downDiagnostic(index)
  35. }
  36. deleteItem() {
  37. const { delItem } = this.state;
  38. const { delDiagnostic } = this.props;
  39. delDiagnostic && delDiagnostic(delItem);
  40. this.setState({
  41. visible: false,
  42. })
  43. Notify.success('删除成功')
  44. }
  45. cancel() {
  46. this.setState({
  47. visible: false
  48. })
  49. }
  50. close() {
  51. this.setState({
  52. visible: false
  53. })
  54. }
  55. handleDeleteItem(item) {
  56. this.setState({
  57. visible: true,
  58. delItem: item,
  59. })
  60. }
  61. showTreat(item, index) {
  62. item.treatIndex = index
  63. const { showTreat, getTreatResult } = this.props;
  64. getTreatResult && getTreatResult(item);
  65. showTreat && showTreat();
  66. this.setState({
  67. treatTitle: item.name
  68. })
  69. }
  70. handleClickDiag(item) {
  71. const { getTips } = this.props;
  72. getTips && getTips(item);
  73. }
  74. render(){
  75. const { list, treatment } = this.props
  76. const { visible, treatTitle } = this.state
  77. const lastIndex = list.length -1;
  78. return(
  79. <div className={style['diaglist-wrap']}>
  80. {list && (list.length > 0) && list.map((item, index) => {
  81. const hasTreat = item.treat && (item.treat.commonTreatment.content || item.treat.surgeryTreatment.content || item.treat.treatment.length>0)
  82. return (<div draggable={true} className={style['diag-box'] + ' clearfix'} key={item.id} >
  83. {index === 0 ? '' : <span className={style['diag-up']} onClick={() => {this.upDiagnostic(index)}}><img className={style["diag-up"]} src={diagUp}/></span>}
  84. {list.length === 1 ? '' : index !== 0 ? '' : <span onClick={() => {this.downDiagnostic(index)}} className={style['diag-down']}><img className={style["diag-down"]} src={diagDown}/></span>}
  85. <span className={style['diag-number']} style={{fontWeight:index === 0 ?'bold':'normal'}}>{index === 0 ? '主' : index+1}</span>
  86. <span className={style['diag-name']} onClick={()=>{this.handleClickDiag(item)}}>{item.name}<span></span></span>
  87. {item.type === 1 ? <span className={style['diag-first']}>初诊</span> :<span className={style['diag-second']}> 复诊</span>}
  88. <span className={style['treat']}
  89. style ={{ color: hasTreat ?'' : 'gray', border: hasTreat ?'1px solid #3B9ED0' : '1px solid gray'}}
  90. onClick={() =>{hasTreat && this.showTreat(item, index)}}>
  91. 治疗方案
  92. </span>
  93. <img className={style['diag-del']} src={del_icon} onClick={()=>{this.handleDeleteItem(item)}}/>
  94. </div>)
  95. })}
  96. {treatment&&<Treat title={treatTitle}></Treat>}
  97. <ConfirmModal visible={visible}
  98. okText='删除'
  99. cancelText='取消'
  100. confirm={this.deleteItem}
  101. cancel={this.cancel}
  102. close={this.close}
  103. >
  104. <div className={style['del-msg']}>是否删除该诊断?</div>
  105. </ConfirmModal>
  106. </div>
  107. )
  108. }
  109. }
  110. export default DiagnosticList;