index.jsx 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205
  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. this.setState({
  34. all:false,
  35. select:[]
  36. })
  37. const obj = {
  38. startDate:date,
  39. endDate:endTime,
  40. flag:999 //自定义以区分筛选条件
  41. }
  42. handleFilter&&handleFilter(obj);
  43. }
  44. getEndTime(date){
  45. this.setState({endTime:date});
  46. const {handleFilter} = this.props;
  47. const {startTime} = this.state;
  48. this.setState({
  49. all:false,
  50. select:[]
  51. })
  52. const obj = {
  53. startDate:startTime,
  54. endDate:date,
  55. flag:999 //自定义以区分筛选条件
  56. }
  57. handleFilter&&handleFilter(obj);
  58. }
  59. handleFilter(flag){
  60. const {handleFilter} = this.props;
  61. const {hasSecond} = this.state;
  62. if(flag == hasSecond){return}
  63. this.setState({
  64. hasSecond:flag,
  65. all:false,
  66. select:[]
  67. })
  68. const obj = {
  69. flag:flag
  70. }
  71. handleFilter&&handleFilter(obj);
  72. }
  73. handleGetMore(){
  74. const {getMore} = this.props;
  75. getMore&&getMore();
  76. }
  77. getClassName(id,ind){
  78. const {select,index} = this.state;
  79. if(select.indexOf(id) !=-1 || ind==index){
  80. return style['select-li']
  81. }
  82. return '';
  83. }
  84. handleSelect(e,id){
  85. e.stopPropagation();
  86. let {select} = this.state;
  87. if(select.indexOf(id)==-1){
  88. select.push(id);
  89. }else{
  90. select.splice(select.indexOf(id),1);
  91. }
  92. this.setState({
  93. select
  94. })
  95. }
  96. getIcon(id){
  97. const {select} = this.state;
  98. if(select.indexOf(id)==-1){
  99. return empty;
  100. }
  101. return check;
  102. }
  103. getAllIcon(){
  104. const {all,select} = this.state;
  105. const {data} = this.props;
  106. if(all || select.length==data.length&&select.length!=0){
  107. return check;
  108. }
  109. return empty;
  110. }
  111. handleAll(){
  112. const {data} = this.props;
  113. let {all} = this.state;
  114. let allIds = [];
  115. if(!all){
  116. data&&data.map((v,i)=>{
  117. allIds.push(v.inquiryId);
  118. })
  119. }
  120. this.setState({
  121. all:!all,
  122. select:allIds
  123. })
  124. }
  125. handleDetail(index){
  126. const {detail} = this.props;
  127. detail&&detail(index);
  128. this.setState({
  129. index:index
  130. })
  131. }
  132. handleDownload(){
  133. const { handleDownload } = this.props;
  134. const {select} = this.state;
  135. if(select.length>0){
  136. handleDownload&&handleDownload(select);
  137. }
  138. }
  139. getExportStyle(){
  140. const {select} = this.state;
  141. if(select.length>0){
  142. return `${style['export']} ${style['exp-select']}`
  143. }
  144. return style['export'];
  145. }
  146. getList(){
  147. const { data } = this.props;
  148. let list = data&&data.map((v,i)=>{
  149. return <li className={this.getClassName(v.inquiryId,i)} key={v.inquiryId} onClick={this.handleDetail.bind(this,i)}>
  150. <p>{v.diagnose}</p>
  151. <p className={style['name']}>{v.doctorName} {'于'}{v.inquiryTime} {'保存病历'}</p>
  152. {v.diagnoseSecond?<div className={style['second']}>
  153. <p>{v.diagnoseSecond}{'(诊后添加)'}</p>
  154. <p className={style['name']}>{v.doctorNameSecond} {'于'}{v.inquiryTimeSecond} {'添加'}</p>
  155. </div>:''}
  156. <img src={this.getIcon(v.inquiryId)} className={style['check-box']} onClick={(e)=>this.handleSelect(e,v.inquiryId)}/>
  157. </li>
  158. })
  159. return list;
  160. }
  161. render(){
  162. const { data,total } = this.props;
  163. const { hasSecond } = this.state;
  164. return <div className={style['list-Box']}>
  165. <div className={style['top']}>
  166. <h2>本科室近期全部历史病历</h2>
  167. <div className={style['list-time']}>
  168. <img src={date} />
  169. <TimeInterval getStartTime={this.getStartTime} getEndTime={this.getEndTime}></TimeInterval>
  170. </div>
  171. <div className={style['filter-box']}>
  172. <span className={style['filter']}>筛选:</span>
  173. <span className={hasSecond==-1?`${style['condition']} ${style['select']}`:style['condition']} onClick={this.handleFilter.bind(this,-1)}>默认</span>
  174. <span className={hasSecond==1?`${style['condition']} ${style['select']}`:style['condition']} onClick={this.handleFilter.bind(this,1)}>有二次诊断</span>
  175. <span className={hasSecond==0?`${style['condition']} ${style['select']}`:style['condition']} onClick={this.handleFilter.bind(this,0)}>没有二次诊断</span>
  176. </div>
  177. </div>
  178. <div className={style['list']}>
  179. <ul>
  180. {this.getList()}
  181. </ul>
  182. {total>data.length?<p className={style['more']} onClick={this.handleGetMore}>点击查看更多</p>:''}
  183. </div>
  184. <div className={style['all-box']}>
  185. <img src={this.getAllIcon()} className={style['check-all']} onClick={this.handleAll}/>
  186. <span onClick={this.handleAll}>全选</span>
  187. <span className={this.getExportStyle()} onClick={this.handleDownload}>导出已选数据</span>
  188. </div>
  189. </div>
  190. }
  191. }
  192. export default HisList;