CurrentIll.js 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. import React from 'react';
  2. import { connect } from 'react-redux';
  3. import CurrentIll from '@components/CurrentIll';
  4. import {INSERT_PROCESS,SET_CURRENT_DATA,SETTEXTMODEVALUE,SET_LABEL_MODULE,SELECT_SEARCHDATA,CLEAR_CURRENT_EDIT} from '@store/types/currentIll';
  5. import {SET_CURRENT_ILL} from '@store/types/fillInfo'
  6. import {pushMessage} from '../store/async-actions/pushContainer';
  7. import {getModules} from '../store/async-actions/fetchModules.js';
  8. import {SETDROPSHOW} from '@types/homePage.js';
  9. import {HIDE,RESET,CLICKCOUNT,ISREAD,SEARCH_DROP_LOCATION} from '@store/types/homePage.js';
  10. import {billing} from '@store/async-actions/pushMessage';
  11. import {getModule} from '@store/async-actions/fetchModules.js';
  12. import {didPushParamChange} from '@utils/tools.js';
  13. function mapStateToProps(state) { //console.log(111,state);
  14. const {homePage} = state;
  15. return {
  16. data:state.currentIll.data,//主诉模板
  17. emptyData:state.currentIll.emptyData,//空模板
  18. searchData:state.currentIll.searchDatas,//搜索结果
  19. focusIndex:state.currentIll.focusIndex,
  20. processModule:state.currentIll.processModule,//病程变化模板
  21. processModuleName:state.currentIll.processModuleName,//病程变化模板名称
  22. showArr:homePage.showDrop,
  23. span:state.currentIll.span,
  24. update:state.currentIll.update,//用于更新
  25. mainText:state.mainSuit.saveText,//主诉选中的数据
  26. mainData:state.mainSuit.data,//主诉使用的模板
  27. moduleNum:state.mainSuit.moduleNum,//主诉使用的模板
  28. type: state.typeConfig.typeConfig,
  29. mainIds:state.mainSuit.mainIds,//主诉症状选中的id(去重用)
  30. fillInfo: state.fillInfo,
  31. showArr:homePage.showDrop,
  32. totalHide: homePage.totalHide,
  33. saveText:state.currentIll.saveText,
  34. selecteds:state.currentIll.selecteds, //普通多选选中状态
  35. editClear:state.currentIll.editClear,
  36. symptomIds:state.currentIll.symptomIds,//症状id,去重用
  37. isRead:state.homePage.isRead,
  38. fuzhen:state.diagnosticList.mainSuitStr,//诊断第一个复诊值
  39. boxTop:state.homePage.boxTop,
  40. boxLeft:state.homePage.boxLeft,
  41. }
  42. }
  43. function mapDispatchToProps(dispatch) {
  44. return {
  45. insertProcess(obj){//点击病程变化
  46. // 埋点dispatch
  47. dispatch({
  48. type:CLICKCOUNT,
  49. data:{id:obj.id},
  50. clickType:'单击',
  51. num:1
  52. });
  53. dispatch({
  54. type:INSERT_PROCESS,
  55. });
  56. dispatch({
  57. type:ISREAD
  58. })
  59. },
  60. async setData(info){//设置现病史使用模板
  61. let idsArr = info.mainIds;
  62. let ids = idsArr.join(",");
  63. let labelModule = await getModules(ids);
  64. if(labelModule.data.code==0){//根据id获取标签模板
  65. dispatch({
  66. type:SET_LABEL_MODULE,
  67. data:labelModule.data.data
  68. })
  69. }
  70. dispatch({
  71. type:SET_CURRENT_DATA,
  72. info
  73. })
  74. //右侧推送
  75. setTimeout(function(){ //延迟待确定后的数据更新后推送,避免获取的参数还是旧的
  76. if(didPushParamChange()){ //操作后内容有变化才推送
  77. dispatch(billing());
  78. }
  79. },500);
  80. },
  81. setCurrentIll: value => {
  82. dispatch({type: SET_CURRENT_ILL, value})
  83. },
  84. pushMessage: (data) => {
  85. dispatch(() => pushMessage(data))
  86. },
  87. //文本模式下推送
  88. fetchPushInfos(){
  89. //调右侧推送
  90. dispatch(billing());
  91. },
  92. handleInput(obj){ //文本模式值保存
  93. dispatch({
  94. type:SETTEXTMODEVALUE,
  95. text:obj.text
  96. })
  97. },
  98. fetchModules(param){
  99. const {id,name,index,span} = param;
  100. getModule(id).then((res)=>{
  101. if(res.data.code=='0'){
  102. dispatch({
  103. type:SELECT_SEARCHDATA,
  104. index,
  105. name,
  106. data: res.data.data,
  107. span,
  108. isReplace:false
  109. })
  110. dispatch({
  111. type:ISREAD
  112. })
  113. }
  114. });
  115. //右侧推送
  116. setTimeout(function(){
  117. dispatch(billing());
  118. },200);
  119. },
  120. changeEditIll(bool){
  121. dispatch({
  122. type:CLEAR_CURRENT_EDIT,
  123. editClear:bool
  124. })
  125. },
  126. getSearchLocation(top,left){
  127. dispatch({
  128. type:SEARCH_DROP_LOCATION,
  129. top:top,
  130. left:left,
  131. dis:0
  132. })
  133. }
  134. }
  135. }
  136. const CurrentIllContainer = connect(
  137. mapStateToProps,
  138. mapDispatchToProps
  139. )(CurrentIll);
  140. export default CurrentIllContainer;