index.jsx 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195
  1. import React, { Component } from "react";
  2. import { connect } from "react-redux";
  3. import BannerContainer from '@containers/TypeConfigContainer';
  4. // 引入组件
  5. import BodyContainer from "@components/BodyContainer";
  6. import {ConfirmModal} from '@commonComp';
  7. import store from '@store';
  8. import {HIDEDROP,SETMINSCREEN,SETSYSTEMCONFIG,SETPRE,SETREADDITEMS,RESET_SELECT_TAG,ISREAD} from '@store/types/homePage.js';
  9. import {billing,getMRAnalyse} from '@store/async-actions/pushMessage';
  10. import {CLEAR_SEARCH,DELETE_MAIN_SELECTED_TAGS} from '@types/mainSuit';
  11. import {CURRENT_CLEAR,DELETE_CURRENT_SELECTED_TAGS} from '@types/currentIll';
  12. import {OTHERHIS_CLEAR,DELETE_OTHER_SELECTED_TAGS} from '@types/otherHistory';
  13. import {CHECKBODY_CLEAR,DELETE_CHECK_SELECTED_TAGS} from '@types/checkBody';
  14. import style from './index.less';
  15. import {getInitModules,getChronic,getSystemConfig} from '@store/async-actions/homePage.js';
  16. import {getPreMsg} from '@store/async-actions/patInfo.js';
  17. import { getUrlArgObject,parseNameVal,pushAllDataList } from "@utils/tools";
  18. import $ from 'jquery';
  19. import loading from '@common/images/loading.gif';
  20. class HomePage extends Component {
  21. constructor() {
  22. super();
  23. this.state={
  24. timer:null,
  25. };
  26. this.hidePops = this.hidePops.bind(this);
  27. }
  28. componentDidMount(){
  29. const {setWindow,getChronicList,getConfig,clearAddItems} = this.props;
  30. //清除已保存的血压标签数据
  31. clearAddItems();
  32. //获取配置
  33. getConfig();
  34. getChronicList&&getChronicList();//获取慢病列表
  35. // 获取并监听窗口宽度,用于有横向滚动条时患者信息和打印预览跟随滚动
  36. let width = $(window).width();
  37. let height = $(window).height();
  38. setWindow && setWindow({width,height});
  39. $(window).resize(function(){
  40. let reWidth = $(window).width();
  41. let reHeight = $(window).height();
  42. setWindow && setWindow({width:reWidth,height:reHeight});
  43. })
  44. //光标没落到元素上继续backspace防止页面回退
  45. $(window).on("keydown",(e)=>{
  46. let ev = e || window.event;
  47. if(ev.keyCode==8){
  48. const elem = ev.srcElement || ev.target;
  49. const nodeN = elem.nodeName;
  50. if(nodeN != "SPAN" && nodeN != "DIV" && nodeN != "INPUT" && nodeN != "TEXTAREA"){
  51. return false;
  52. }
  53. }
  54. })
  55. }
  56. hidePops(){
  57. const {hideAllDrop,handleClear,resetSelect } = this.props;
  58. //重置选中范围
  59. resetSelect();
  60. if(!this.isBar){ //onMousrdown的目标为滚动条时,标签填写单不关闭
  61. hideAllDrop(); //隐藏填写单
  62. handleClear&&handleClear(); //清空搜索结果
  63. }
  64. }
  65. setElem(e){
  66. //onMousedown的目标为滚动条时,标签填写单不关闭
  67. if(e.target.className=='scrollbar'){
  68. this.isBar = true;
  69. }else{
  70. this.isBar = false;
  71. }
  72. }
  73. handleKeyUp(e){
  74. const {deleteLabels} = this.props;
  75. //删除选中标签
  76. if(e.keyCode==8||e.keyCode==46){ //backspace或del都可删除
  77. deleteLabels();
  78. }
  79. }
  80. render() {
  81. const {flag,showPre,noReferRecord,referRecord} = this.props;
  82. return <div className={style['home-page']}
  83. onClick={this.hidePops} onmousedown={this.setElem.bind(this)} onkeyup={this.handleKeyUp.bind(this)}>
  84. <BannerContainer />
  85. {/* <InfoTitle /> */}
  86. <BodyContainer></BodyContainer>
  87. <ConfirmModal visible={showPre} okText='是' cancelText='否' confirm={referRecord} cancel={noReferRecord} close={noReferRecord}>
  88. <div className={style['confirm-info']}>是否引用预问诊信息?</div>
  89. <p className={style.tip}>(引用数据会清除当前内容)</p>
  90. </ConfirmModal>
  91. {/* {flag?<div className={style['mask']}>
  92. <img src={loading} className={style['load']}/>
  93. </div>:""} */}
  94. </div>;
  95. }
  96. }
  97. const mapStateToProps = function (state) {
  98. return {
  99. flag:state.homePage.loadingFlag,
  100. showPre:state.homePage.showPre
  101. }
  102. };
  103. const boxMap = {
  104. '1':DELETE_MAIN_SELECTED_TAGS,
  105. '2':DELETE_CURRENT_SELECTED_TAGS,
  106. '3':DELETE_OTHER_SELECTED_TAGS,
  107. '4':DELETE_CHECK_SELECTED_TAGS
  108. };
  109. const mapDispatchToProps = function (dispatch) {
  110. return {
  111. clearAddItems(){
  112. dispatch({
  113. type:SETREADDITEMS
  114. })
  115. },
  116. referRecord(){
  117. const state = store.getState();
  118. const {homePage} = state;
  119. pushAllDataList(1,'push',homePage.preData,'preIcss');
  120. dispatch(billing())
  121. dispatch(getMRAnalyse())
  122. dispatch({type:SETPRE,show:false});
  123. },
  124. noReferRecord(){
  125. dispatch({type:SETPRE,show:false});
  126. },
  127. handleClear(){//清空搜索结果
  128. dispatch({type:CLEAR_SEARCH});
  129. dispatch({type:CURRENT_CLEAR});
  130. dispatch({type:OTHERHIS_CLEAR});
  131. dispatch({type:CHECKBODY_CLEAR});
  132. },
  133. hideAllDrop(){
  134. dispatch({
  135. type:HIDEDROP
  136. });
  137. },
  138. /*getInit(){
  139. dispatch(getInitModules);
  140. }*/
  141. setWindow(obj){
  142. dispatch({
  143. type:SETMINSCREEN,
  144. obj:obj
  145. })
  146. },
  147. getChronicList(){
  148. dispatch(getChronic)
  149. },
  150. getConfig(){
  151. getSystemConfig().then((res)=>{
  152. if(res.data.code=='0'){
  153. dispatch({
  154. type:SETSYSTEMCONFIG,
  155. data: parseNameVal(res.data.data)
  156. })
  157. }else{
  158. }
  159. });
  160. },
  161. deleteLabels(){ //选中删除标签
  162. const state = store.getState();
  163. const {homePage} = state;
  164. const start = homePage.select_start;
  165. const end = homePage.select_end;
  166. const boxMark = homePage.select_boxMark;
  167. if(!boxMark||start===undefined||end===undefined)return;
  168. //删除后清除选中标记,放在删除事件后面会有清空不及时的问题
  169. dispatch({
  170. type:RESET_SELECT_TAG
  171. });
  172. dispatch({
  173. type:boxMap[boxMark],
  174. start,
  175. end,
  176. boxMark
  177. });
  178. dispatch({
  179. type:ISREAD
  180. })
  181. },
  182. resetSelect(){
  183. dispatch({
  184. type:RESET_SELECT_TAG
  185. })
  186. }
  187. }
  188. };
  189. export default connect(mapStateToProps, mapDispatchToProps)(HomePage);