index.jsx 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191
  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,
  35. endDate:endTime,
  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,
  46. endDate:date,
  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. if(select.length>0){
  124. handleDownload&&handleDownload(select);
  125. }
  126. }
  127. getExportStyle(){
  128. const {select} = this.state;
  129. if(select.length>0){
  130. return `${style['export']} ${style['exp-select']}`
  131. }
  132. return style['export'];
  133. }
  134. getList(){
  135. const { data } = this.props;
  136. let list = data&&data.map((v,i)=>{
  137. return <li className={this.getClassName(v.inquiryId,i)} key={v.inquiryId} onClick={this.handleDetail.bind(this,i)}>
  138. <p>{v.diagnose}</p>
  139. <p className={style['name']}>{v.doctorName} {'于'}{v.inquiryTime} {'保存病历'}</p>
  140. {v.diagnoseSecond?<div className={style['second']}>
  141. <p>{v.diagnoseSecond}{'(诊后添加)'}</p>
  142. <p className={style['name']}>{v.doctorNameSecond} {'于'}{v.inquiryTimeSecond} {'添加'}</p>
  143. </div>:''}
  144. <img src={this.getIcon(v.inquiryId)} className={style['check-box']} onClick={(e)=>this.handleSelect(e,v.inquiryId)}/>
  145. </li>
  146. })
  147. return list;
  148. }
  149. render(){
  150. const { data,total } = this.props;
  151. const { hasSecond } = this.state;
  152. return <div className={style['list-Box']}>
  153. <h2>本科室近期全部历史病历</h2>
  154. <div className={style['list-time']}>
  155. <img src={date} />
  156. <TimeInterval getStartTime={this.getStartTime} getEndTime={this.getEndTime}></TimeInterval>
  157. </div>
  158. <div className={style['filter-box']}>
  159. <span className={style['filter']}>筛选:</span>
  160. <span className={hasSecond==-1?`${style['condition']} ${style['select']}`:style['condition']} onClick={this.handleFilter.bind(this,-1)}>默认</span>
  161. <span className={hasSecond==1?`${style['condition']} ${style['select']}`:style['condition']} onClick={this.handleFilter.bind(this,1)}>有二次诊断</span>
  162. <span className={hasSecond==0?`${style['condition']} ${style['select']}`:style['condition']} onClick={this.handleFilter.bind(this,0)}>没有二次诊断</span>
  163. </div>
  164. <div className={style['list']}>
  165. <ul>
  166. {this.getList()}
  167. </ul>
  168. {total>data.length?<p className={style['more']} onClick={this.handleGetMore}>点击查看更多</p>:''}
  169. </div>
  170. <div className={style['all-box']}>
  171. <img src={this.getAllIcon()} className={style['check-all']} onClick={this.handleAll}/>
  172. <span onClick={this.handleAll}>全选</span>
  173. <span className={this.getExportStyle()} onClick={this.handleDownload}>导出已选数据</span>
  174. </div>
  175. </div>
  176. }
  177. }
  178. export default HisList;