index.jsx 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
  1. import React,{Component} from 'react';
  2. import style from './index.less';
  3. import empty from '@common/images/check-circle.png';
  4. import check from '@common/images/check-right.png';
  5. import date from '@common/images/date1.png';
  6. import TimeInterval from '@components/TimeInterval';
  7. import {getCurrentDate} from "@utils/tools";
  8. /**
  9. 科室病历列表
  10. **/
  11. class HisList extends Component {
  12. constructor(props){
  13. super(props);
  14. this.state = {
  15. select:[], //选中ids
  16. hasSecond:-1,
  17. all:false,
  18. index:0,
  19. startTime:getCurrentDate(false,'/')+' 00:00:00',
  20. endTime:getCurrentDate(false,'/')+' 23:59:59',
  21. }
  22. this.handleGetMore = this.handleGetMore.bind(this);
  23. this.handleSelect = this.handleSelect.bind(this);
  24. this.handleAll = this.handleAll.bind(this);
  25. this.handleDownload = this.handleDownload.bind(this);
  26. this.getStartTime = this.getStartTime.bind(this);
  27. this.getEndTime = this.getEndTime.bind(this);
  28. }
  29. getStartTime(date){
  30. this.setState({startTime:date});
  31. const {handleFilter} = this.props;
  32. const {endTime} = this.state;
  33. const obj = {
  34. startDate:date.replace(/\//g,'-'),
  35. endDate:endTime.replace(/\//g,'-'),
  36. flag:999 //自定义以区分筛选条件
  37. }
  38. handleFilter&&handleFilter(obj);
  39. }
  40. getEndTime(date){
  41. this.setState({endTime:date});
  42. const {handleFilter} = this.props;
  43. const {startTime} = this.state;
  44. const obj = {
  45. startDate:startTime.replace(/\//g,'-'),
  46. endDate:data.replace(/\//g,'-'),
  47. flag:999 //自定义以区分筛选条件
  48. }
  49. handleFilter&&handleFilter(obj);
  50. }
  51. handleFilter(flag){
  52. const {handleFilter} = this.props;
  53. this.setState({
  54. hasSecond:flag
  55. })
  56. const obj = {
  57. flag:flag
  58. }
  59. handleFilter&&handleFilter(obj);
  60. }
  61. handleGetMore(){
  62. const {getMore} = this.props;
  63. getMore&&getMore();
  64. }
  65. getClassName(id,ind){
  66. const {select,index} = this.state;
  67. if(select.indexOf(id) !=-1 || ind==index){
  68. return style['select-li']
  69. }
  70. return '';
  71. }
  72. handleSelect(e,id){
  73. e.stopPropagation();
  74. let {select} = this.state;
  75. if(select.indexOf(id)==-1){
  76. select.push(id);
  77. }else{
  78. select.splice(select.indexOf(id),1);
  79. }
  80. this.setState({
  81. select
  82. })
  83. }
  84. getIcon(id){
  85. const {select} = this.state;
  86. if(select.indexOf(id)==-1){
  87. return empty;
  88. }
  89. return check;
  90. }
  91. getAllIcon(){
  92. const {all,select} = this.state;
  93. const {data} = this.props;
  94. if(all || select.length==data.length&&select.length!=0){
  95. return check;
  96. }
  97. return empty;
  98. }
  99. handleAll(){
  100. const {data} = this.props;
  101. let {all} = this.state;
  102. let allIds = [];
  103. if(!all){
  104. data&&data.map((v,i)=>{
  105. allIds.push(v.inquiryId);
  106. })
  107. }
  108. this.setState({
  109. all:!all,
  110. select:allIds
  111. })
  112. }
  113. handleDetail(index){
  114. const {detail} = this.props;
  115. detail&&detail(index);
  116. this.setState({
  117. index:index
  118. })
  119. }
  120. handleDownload(){
  121. const { handleDownload } = this.props;
  122. const {select} = this.state;
  123. handleDownload&&handleDownload(select);
  124. }
  125. getExportStyle(){
  126. const {select} = this.state;
  127. if(select.length>0){
  128. return `${style['export']} ${style['exp-select']}`
  129. }
  130. return style['export'];
  131. }
  132. getList(){
  133. const { data } = this.props;
  134. let list = data&&data.map((v,i)=>{
  135. return <li className={this.getClassName(v.inquiryId,i)} key={v.inquiryId} onClick={this.handleDetail.bind(this,i)}>
  136. <p>{v.diagnose}</p>
  137. <p className={style['name']}>{v.doctorName} {'于'}{v.inquiryTime} {'保存病历'}</p>
  138. {v.diagnoseSecond?<div className={style['second']}>
  139. <p>{v.diagnoseSecond}{'(诊后添加)'}</p>
  140. <p className={style['name']}>{v.doctorNameSecond} {'于'}{v.inquiryTimeSecond} {'添加'}</p>
  141. </div>:''}
  142. <img src={this.getIcon(v.inquiryId)} className={style['check-box']} onClick={(e)=>this.handleSelect(e,v.inquiryId)}/>
  143. </li>
  144. })
  145. return list;
  146. }
  147. render(){
  148. const { data,total } = this.props;
  149. const { hasSecond } = this.state;
  150. return <div className={style['list-Box']}>
  151. <h2>本科室近期全部历史病历</h2>
  152. <div className={style['list-time']}>
  153. <img src={date} />
  154. <TimeInterval getStartTime={this.getStartTime} getEndTime={this.getEndTime}></TimeInterval>
  155. </div>
  156. <div className={style['filter-box']}>
  157. <span className={style['filter']}>筛选:</span>
  158. <span className={hasSecond==-1?`${style['condition']} ${style['select']}`:style['condition']} onClick={this.handleFilter.bind(this,-1)}>默认</span>
  159. <span className={hasSecond==1?`${style['condition']} ${style['select']}`:style['condition']} onClick={this.handleFilter.bind(this,1)}>有二次诊断</span>
  160. <span className={hasSecond==0?`${style['condition']} ${style['select']}`:style['condition']} onClick={this.handleFilter.bind(this,0)}>没有二次诊断</span>
  161. </div>
  162. <div className={style['list']}>
  163. <ul>
  164. {this.getList()}
  165. </ul>
  166. {total>data.length?<p className={style['more']} onClick={this.handleGetMore}>点击查看更多</p>:''}
  167. </div>
  168. <div className={style['all-box']}>
  169. <img src={this.getAllIcon()} className={style['check-all']} onClick={this.handleAll}/>
  170. <span onClick={this.handleAll}>全选</span>
  171. <span className={this.getExportStyle()} onClick={this.handleDownload}>导出已选数据</span>
  172. </div>
  173. </div>
  174. }
  175. }
  176. export default HisList;