index.jsx 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  1. import React, { Component } from "react";
  2. import { connect } from "react-redux";
  3. import style from "./index.less";
  4. import ReactDom from "react-dom";
  5. import logo from "../../common/images/logoa.png";
  6. import prec from "../../common/images/prec.png";
  7. import setup from "../../common/images/setup.png";
  8. import emergIcon from '../../common/images/emergency.png'
  9. import {Notify} from '@commonComp';
  10. import Emergency from '@containers/Emergency';
  11. import PreInIcss from '@containers/PreInIcss';
  12. import {getAllHis} from '@store/async-actions/fetchModules.js';
  13. import {timestampToTime,getCurrentDate} from '@utils/tools.js';
  14. import {dragBox} from '@utils/drag';
  15. import {CLEAR_COMSYMPTOMS} from '@store/types/mainSuit';
  16. import { GET_PREC_LIST,SET_PREC_SHOW } from "@store/types/preIcss";
  17. import {getPreMsg} from '@store/async-actions/preIcss';
  18. import ModeChange from './ModeChange'
  19. class Banner extends Component {
  20. constructor(props){
  21. super(props);
  22. const conf = props.typeConfig;
  23. this.state = {
  24. config0: conf[0], //模式
  25. config1:conf[1], //一般情况默认
  26. config2:conf[2], //其他史默认
  27. config3:conf[3], //字体大小
  28. config4:conf[4], //字体颜色
  29. emergencyBox:false
  30. };
  31. this.showConfigModal = this.showConfigModal.bind(this);
  32. this.changeType = this.changeType.bind(this);
  33. this.confirmType = this.confirmType.bind(this);
  34. this.showHisModal = this.showHisModal.bind(this);
  35. this.handleHisClose = this.handleHisClose.bind(this);
  36. this.setInitConfig = this.setInitConfig.bind(this);
  37. }
  38. showConfigModal(){
  39. this.setInitConfig();
  40. this.props.showConfigModal()
  41. }
  42. changeType(type,typeConfig){
  43. if(type==='config0'&&typeConfig!==0){ //智能模式关闭,一般情况和其他史默认值也关闭
  44. this.setState({
  45. config0: typeConfig,
  46. config1: 0,
  47. config2: 0,
  48. });
  49. return;
  50. }
  51. this.setState({
  52. [type]:typeConfig
  53. });
  54. }
  55. confirmType(){
  56. const {typeConfig,confirmType,clearCommS,closeConfigModal,readMode} = this.props;
  57. // 清空主诉常见症状
  58. clearCommS();
  59. /*if(mode==typeConfig&&typeConfig==readMode){
  60. closeConfigModal();
  61. return;
  62. }*/
  63. const configs= this.parseConf();
  64. confirmType&&confirmType(configs);
  65. closeConfigModal();
  66. }
  67. parseConf(){
  68. let configs = Object.assign({},this.state);
  69. delete configs.emergencyBox;
  70. let obj = {};
  71. for(let i in configs){
  72. obj[i.replace('config','')] = configs[i];
  73. }
  74. return obj;
  75. }
  76. setInitConfig(){
  77. const conf = this.props.typeConfig;
  78. this.setState({
  79. config0: conf[0],
  80. config1:conf[1],
  81. config2:conf[2],
  82. config3:conf[3],
  83. config4:conf[4],
  84. });
  85. }
  86. showHisModal(){
  87. const {getAllRecord} = this.props;
  88. // 进入时默认展示当天的病例
  89. const item = {
  90. current:1,
  91. startDate:getCurrentDate(false)+' 00:00:00',
  92. endDate:getCurrentDate(false)+' 23:59:59'
  93. }
  94. getAllRecord&&getAllRecord(item);
  95. this.setState({
  96. emergencyBox:true,
  97. })
  98. }
  99. handleHisClose(){
  100. this.setState({
  101. emergencyBox:false,
  102. });
  103. dragBox('previewWrapper','previewStatic','del')
  104. }
  105. render() {
  106. const {visible,pre,ifShow,deptName, closeConfigModal,hasMain,hasCurrent,hasOther,preShow,show} = this.props;
  107. const {emergencyBox} = this.state;
  108. const {showConfigModal, changeType, confirmType} = this;
  109. const domNode = document.getElementById('root');
  110. const disabled = !(hasMain||hasCurrent||hasOther);
  111. return (
  112. <div className={style["logo"]} >
  113. <img src={logo} />
  114. <span className={style["logo-name"]}>|&nbsp;&nbsp;智能辅助临床决策系统</span>
  115. <div className={style["buon"]}>
  116. {ifShow==1&&deptName=='急诊科'?<div className={`${style["buon1"]} ${style["buon2"]}`} onClick={this.showHisModal}>
  117. <img className={`${style["st"]} ${style["his"]}`} src={emergIcon} />
  118. <i>本科室近期全部病历</i>
  119. </div>:''}
  120. {pre == 1?<div className={style.prec} onClick={()=>preShow(show)}>
  121. <img className={style["st"]} src={prec} alt="预问诊"/>
  122. <i> 预问诊信息</i>
  123. </div>:null}
  124. <div className={style["buon1"]} onClick={showConfigModal}>
  125. <img className={style["st"]} src={setup} />
  126. <i> 设置</i>
  127. </div>
  128. </div>
  129. {visible&& <ModeChange
  130. {...this.state}
  131. hideBtn={disabled}
  132. closeConfigModal = {closeConfigModal}
  133. changeType = {changeType}
  134. confirmType = {confirmType}
  135. >
  136. </ModeChange>}
  137. {emergencyBox? ReactDom.createPortal(<React.Fragment>
  138. <div className={style['modal']}>
  139. <div className={style['shade']} onClick={this.handleHisClose}></div>
  140. <Emergency show={emergencyBox} close={this.handleHisClose}/>
  141. </div>
  142. </React.Fragment>
  143. , domNode):''}
  144. {show?<PreInIcss></PreInIcss>:null}
  145. </div>
  146. );
  147. }
  148. }
  149. const mapStateToProps = function(state){
  150. const {sysConfig} = state.homePage;
  151. const {message} = state.patInfo;
  152. return {
  153. ifShow:sysConfig.general_show,
  154. deptName:message.selfDeptName,
  155. show:state.preIcss.preShow,
  156. pre:sysConfig.connect_prec
  157. }
  158. }
  159. const mapDispatchToProps = function(dispatch){
  160. return {
  161. getAllRecord(item){
  162. dispatch(getAllHis(item));
  163. },
  164. clearCommS:()=>{//清除主诉常见症状
  165. dispatch({
  166. type: CLEAR_COMSYMPTOMS
  167. })
  168. },
  169. preShow(show){
  170. show?dispatch({type:SET_PREC_SHOW}):getPreMsg()
  171. }
  172. }
  173. }
  174. export default connect(mapStateToProps,mapDispatchToProps)(Banner);