CurrentIll.js 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  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. symptomFeature:state.mainSuit.symptomFeature,//主诉分词数据
  28. moduleNum:state.mainSuit.moduleNum,//主诉使用的模板
  29. type: state.typeConfig.typeConfig,
  30. mainIds:state.mainSuit.mainIds,//主诉症状选中的id(去重用)
  31. fillInfo: state.fillInfo,
  32. showArr:homePage.showDrop,
  33. totalHide: homePage.totalHide,
  34. saveText:state.currentIll.saveText,
  35. selecteds:state.currentIll.selecteds, //普通多选选中状态
  36. editClear:state.currentIll.editClear,
  37. symptomIds:state.currentIll.symptomIds,//症状id,去重用
  38. isRead:state.homePage.isRead,
  39. fuzhen:state.diagnosticList.mainSuitStr,//诊断第一个复诊值
  40. boxTop:state.homePage.boxTop,
  41. boxLeft:state.homePage.boxLeft,
  42. allModules:state.homePage.allModules,
  43. // isChronic:!!state.diagnosticList.chronicMagItem,
  44. isChronic:state.mainSuit.chronicDesease,
  45. }
  46. }
  47. function mapDispatchToProps(dispatch) {
  48. return {
  49. insertProcess(obj,allModules){//点击病程变化
  50. // 埋点dispatch
  51. dispatch({
  52. type:CLICKCOUNT,
  53. data:{id:obj.id},
  54. clickType:'单击',
  55. num:1
  56. });
  57. dispatch({
  58. type:INSERT_PROCESS,
  59. id:obj.relationModule,
  60. allModules:allModules
  61. });
  62. dispatch({
  63. type:ISREAD
  64. })
  65. },
  66. async setData(info){//设置现病史使用模板
  67. let idsArr = info.mainIds;
  68. let ids = idsArr.join(",");
  69. let labelModule = await getModules(ids);
  70. if(labelModule.data.code==0){//根据id获取标签模板
  71. dispatch({
  72. type:SET_LABEL_MODULE,
  73. data:labelModule.data.data
  74. })
  75. }
  76. dispatch({
  77. type:SET_CURRENT_DATA,
  78. info
  79. })
  80. //右侧推送
  81. setTimeout(function(){ //延迟待确定后的数据更新后推送,避免获取的参数还是旧的
  82. if(didPushParamChange()){ //操作后内容有变化才推送
  83. dispatch(billing());
  84. }
  85. },500);
  86. },
  87. setCurrentIll: value => {
  88. dispatch({type: SET_CURRENT_ILL, value})
  89. },
  90. pushMessage: (data) => {
  91. dispatch(() => pushMessage(data))
  92. },
  93. //文本模式下推送
  94. fetchPushInfos(){
  95. //调右侧推送
  96. dispatch(billing());
  97. },
  98. handleInput(obj){ //文本模式值保存
  99. dispatch({
  100. type:SETTEXTMODEVALUE,
  101. text:obj.text
  102. })
  103. },
  104. fetchModules(param){
  105. const {id,name,index,span} = param;
  106. getModule(id).then((res)=>{
  107. if(res.data.code=='0'){
  108. dispatch({
  109. type:SELECT_SEARCHDATA,
  110. index,
  111. name,
  112. data: res.data.data,
  113. span,
  114. isReplace:false
  115. })
  116. dispatch({
  117. type:ISREAD
  118. })
  119. }
  120. });
  121. //右侧推送
  122. setTimeout(function(){
  123. dispatch(billing());
  124. },200);
  125. },
  126. changeEditIll(bool){
  127. dispatch({
  128. type:CLEAR_CURRENT_EDIT,
  129. editClear:bool
  130. })
  131. },
  132. getSearchLocation(top,left){
  133. dispatch({
  134. type:SEARCH_DROP_LOCATION,
  135. top:top,
  136. left:left,
  137. dis:0
  138. })
  139. }
  140. }
  141. }
  142. const CurrentIllContainer = connect(
  143. mapStateToProps,
  144. mapDispatchToProps
  145. )(CurrentIll);
  146. export default CurrentIllContainer;