index.jsx 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194
  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} from '@store/types/homePage.js';
  9. import {billing} 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({type:SETPRE,show:false});
  122. },
  123. noReferRecord(){
  124. dispatch({type:SETPRE,show:false});
  125. },
  126. handleClear(){//清空搜索结果
  127. dispatch({type:CLEAR_SEARCH});
  128. dispatch({type:CURRENT_CLEAR});
  129. dispatch({type:OTHERHIS_CLEAR});
  130. dispatch({type:CHECKBODY_CLEAR});
  131. },
  132. hideAllDrop(){
  133. dispatch({
  134. type:HIDEDROP
  135. });
  136. },
  137. /*getInit(){
  138. dispatch(getInitModules);
  139. }*/
  140. setWindow(obj){
  141. dispatch({
  142. type:SETMINSCREEN,
  143. obj:obj
  144. })
  145. },
  146. getChronicList(){
  147. dispatch(getChronic)
  148. },
  149. getConfig(){
  150. getSystemConfig().then((res)=>{
  151. if(res.data.code=='0'){
  152. dispatch({
  153. type:SETSYSTEMCONFIG,
  154. data: parseNameVal(res.data.data)
  155. })
  156. }else{
  157. }
  158. });
  159. },
  160. deleteLabels(){ //选中删除标签
  161. const state = store.getState();
  162. const {homePage} = state;
  163. const start = homePage.select_start;
  164. const end = homePage.select_end;
  165. const boxMark = homePage.select_boxMark;
  166. if(!boxMark)return;
  167. dispatch({
  168. type:boxMap[boxMark],
  169. start,
  170. end,
  171. boxMark
  172. });
  173. //删除后清楚选中标记
  174. //setTimeout(()=>{
  175. dispatch({
  176. type:RESET_SELECT_TAG
  177. });
  178. //})
  179. },
  180. resetSelect(){
  181. dispatch({
  182. type:RESET_SELECT_TAG
  183. })
  184. }
  185. }
  186. };
  187. export default connect(mapStateToProps, mapDispatchToProps)(HomePage);