index.jsx 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  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. import store from '@store';
  10. import { initItemList } from '@store/async-actions/historyTemplates';
  11. import { pushAllDataList } from '@utils/tools';
  12. import iconRadioDefault from '@common/images/icon-radio-default.png'
  13. import iconRadioActive from '@common/images/icon-radio-active.png'
  14. class DiagnosticList extends Component {
  15. constructor(props) {
  16. super(props);
  17. this.state = {
  18. visible: false,
  19. delItem: {},
  20. treatTitle: '',
  21. activeHistory: -1
  22. }
  23. this.deleteItem = this.deleteItem.bind(this);
  24. this.cancel = this.cancel.bind(this);
  25. this.close = this.close.bind(this);
  26. this.showTreat = this.showTreat.bind(this);
  27. this.handleClickDiag = this.handleClickDiag.bind(this);
  28. this.referRecord = this.referRecord.bind(this);
  29. this.noReferRecord = this.noReferRecord.bind(this);
  30. this.getHistoryCase = this.getHistoryCase.bind(this);
  31. this.closeHistoryCaseModal = this.closeHistoryCaseModal.bind(this);
  32. this.referCase = this.referCase.bind(this);
  33. }
  34. componentWillReceiveProps(nextprops) {
  35. if (this.props.diagnosticStr != nextprops.diagnosticStr) {
  36. this.props.getBilling();
  37. }
  38. }
  39. upDiagnostic(index) {
  40. const { upDiagnostic } = this.props;
  41. upDiagnostic && upDiagnostic(index)
  42. }
  43. downDiagnostic(index) {
  44. const { downDiagnostic } = this.props;
  45. downDiagnostic && downDiagnostic(index)
  46. }
  47. deleteItem() {
  48. const { delItem } = this.state;
  49. const { delDiagnostic } = this.props;
  50. delDiagnostic && delDiagnostic(delItem);
  51. this.setState({
  52. visible: false,
  53. })
  54. Notify.success('删除成功')
  55. }
  56. cancel() {
  57. this.setState({
  58. visible: false
  59. })
  60. }
  61. close() {
  62. this.setState({
  63. visible: false
  64. })
  65. }
  66. handleDeleteItem(item) {
  67. this.setState({
  68. visible: true,
  69. delItem: item,
  70. })
  71. }
  72. showTreat(item, index) {
  73. // item.treatIndex = index
  74. const { showTreat, getTreatResult } = this.props;
  75. getTreatResult && getTreatResult(item);
  76. showTreat && showTreat();
  77. this.setState({
  78. treatTitle: item.name
  79. })
  80. }
  81. handleClickDiag(item) {
  82. const { getTips } = this.props;
  83. getTips && getTips(item);
  84. }
  85. referRecord() {
  86. const { hideReferRecord, showHistoryCaseModal } = this.props
  87. hideReferRecord && hideReferRecord()
  88. showHistoryCaseModal && showHistoryCaseModal()
  89. store.dispatch(initItemList());
  90. }
  91. noReferRecord() {
  92. const { hideReferRecord } = this.props
  93. hideReferRecord && hideReferRecord()
  94. }
  95. referCase() {
  96. const { hideHistoryCaseModal, items } = this.props
  97. hideHistoryCaseModal && hideHistoryCaseModal()
  98. if (this.state.activeHistory === -1) {
  99. return
  100. }
  101. let baseList = store.getState();
  102. let baseObj = items[this.state.activeHistory];
  103. // store.dispatch({type: CONFIRM_TYPE, confirmType: baseObj.sign});
  104. pushAllDataList(baseObj.sign,'push',baseObj,'history') //引用
  105. this.props.getBilling();
  106. this.setState({
  107. activeHistory: -1
  108. })
  109. }
  110. closeHistoryCaseModal() {
  111. const { hideHistoryCaseModal } = this.props
  112. this.setState({
  113. activeHistory: -1
  114. })
  115. hideHistoryCaseModal && hideHistoryCaseModal()
  116. }
  117. handleQuoteClick(item, index) {
  118. console.log('asadsd', item)
  119. const { handleQuoteClick } = this.props
  120. // handleQuoteClick && handleQuoteClick(item)
  121. this.setState({
  122. activeHistory: index
  123. })
  124. }
  125. getHistoryCase() {
  126. const { items } = this.props
  127. return (<div className={style['history-info']}>
  128. {items.map((item, index) => {
  129. return<div onClick={this.handleQuoteClick.bind(this, item, index)} style={this.state.activeHistory === index ? {color: '#abcdef'} : ''}>
  130. <img src={this.state.activeHistory === index ? iconRadioActive : iconRadioDefault}/>{item.diagnose}
  131. </div>
  132. })}
  133. </div>)
  134. }
  135. render(){
  136. const { list, treatment, showReferRecord, showHistoryCase } = this.props
  137. const { visible, treatTitle } = this.state
  138. const lastIndex = list.length -1;
  139. return(
  140. <div className={style['diaglist-wrap']}>
  141. {list && (list.length > 0) && list.map((item, index) => {
  142. const hasTreat = item.treat && (item.treat.commonTreatment.content || item.treat.surgeryTreatment.content || item.treat.treatment.length>0)
  143. return (<div draggable={true} className={style['diag-box'] + ' clearfix'} key={item.id} >
  144. {index === 0 ? '' : <span className={style['diag-up']} onClick={() => {this.upDiagnostic(index)}}><img className={style["diag-up"]} src={diagUp}/></span>}
  145. {list.length === 1 ? '' : index !== 0 ? '' : <span onClick={() => {this.downDiagnostic(index)}} className={style['diag-down']}><img className={style["diag-down"]} src={diagDown}/></span>}
  146. <span className={style['diag-number']} style={{fontWeight:index === 0 ?'bold':'normal'}}>{index === 0 ? '主' : index+1}</span>
  147. <span className={style['diag-name']} onClick={()=>{this.handleClickDiag(item)}}>{item.name}<span></span></span>
  148. {item.type === 1 ? <span className={style['diag-first']}>初诊</span> :<span className={style['diag-second']}> 复诊</span>}
  149. <span className={style['treat']}
  150. // style ={{ color: hasTreat ?'' : 'gray', border: hasTreat ?'1px solid #3B9ED0' : '1px solid gray', cursor: hasTreat ? '' : 'text'}}
  151. style ={hasTreat ? '' : { color: 'gray', border: '1px solid gray', cursor: 'auto'}}
  152. onClick={() =>{hasTreat && this.showTreat(item, index)}}>
  153. 治疗方案
  154. </span>
  155. <img className={style['diag-del']} src={del_icon} onClick={()=>{this.handleDeleteItem(item)}}/>
  156. </div>)
  157. })}
  158. {treatment&&<Treat title={treatTitle}></Treat>}
  159. <ConfirmModal visible={visible}
  160. okText='删除'
  161. cancelText='取消'
  162. confirm={this.deleteItem}
  163. cancel={this.cancel}
  164. close={this.close}
  165. >
  166. <div className={style['del-msg']}>是否删除该诊断?</div>
  167. </ConfirmModal>
  168. <ConfirmModal visible={showReferRecord} okText='是' cancelText='否' confirm={this.referRecord} cancel={this.noReferRecord} close={this.noReferRecord}>
  169. <div className={style['confirm-info']}>是否引用往期病历</div>
  170. </ConfirmModal>
  171. <ConfirmModal visible={showHistoryCase} noFooter='true' title='请选择历史病历' close={this.closeHistoryCaseModal}>
  172. {this.getHistoryCase()}
  173. <div className={style['confirm-history']}><span className={style['confirm-history-btn']} onClick={this.referCase}>确定</span></div>
  174. </ConfirmModal>
  175. </div>
  176. )
  177. }
  178. }
  179. export default DiagnosticList;