CurrentIll.js 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  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,SAVE_CURR_FREE} from '@store/types/currentIll';
  5. import {pushMessage} from '../store/async-actions/pushContainer';
  6. import {getModules} from '../store/async-actions/fetchModules.js';
  7. import {HIDE,RESET,CLICKCOUNT,ISREAD,SETDROPSHOW} from '@store/types/homePage';
  8. import {billing} from '@store/async-actions/pushMessage';
  9. import {getModule} from '@store/async-actions/fetchModules';
  10. import {didPushParamChange} from '@utils/tools';
  11. import {Notify} from '@commonComp';
  12. function mapStateToProps(state) {
  13. const {homePage,currentIll,mainSuit,diagnosticList} = state;
  14. return {
  15. data:currentIll.data,//主诉模板
  16. emptyData:currentIll.emptyData,//空模板
  17. searchData:currentIll.searchDatas,//搜索结果
  18. focusIndex:currentIll.focusIndex,
  19. processModule:currentIll.processModule,//病程变化模板
  20. showArr:homePage.showDrop,
  21. span:currentIll.span,
  22. update:currentIll.update,//用于更新
  23. mainText:mainSuit.saveText,//主诉选中的数据
  24. mainData:mainSuit.data,//主诉使用的模板
  25. symptomFeature:mainSuit.symptomFeature,//主诉分词数据
  26. moduleNum:mainSuit.moduleNum,//主诉使用的模板
  27. type: state.typeConfig.typeConfig,
  28. mainIds:mainSuit.mainIds,//主诉症状选中的id(去重用)
  29. mainTailIds:mainSuit.mainTailIds,//主诉症状选中的id(去重用)
  30. totalHide: homePage.totalHide,
  31. saveText:currentIll.saveText,
  32. selecteds:currentIll.selecteds, //普通多选选中状态
  33. editClear:currentIll.editClear,
  34. symptomIds:currentIll.symptomIds,//症状id,去重用
  35. isRead:homePage.isRead,
  36. fuzhen:diagnosticList.mainSuitStr,//诊断第一个复诊值
  37. allModules:homePage.allModules,
  38. // isChronic:!!diagnosticList.chronicMagItem,
  39. isChronic:mainSuit.chronicDesease?mainSuit.chronicDesease:diagnosticList.chronicMagItem,
  40. }
  41. }
  42. function mapDispatchToProps(dispatch) {
  43. return {
  44. insertProcess(obj,allModules){//点击病程变化
  45. // 埋点dispatch
  46. dispatch({
  47. type:CLICKCOUNT,
  48. data:{id:obj.id},
  49. clickType:'单击',
  50. num:1
  51. });
  52. dispatch({
  53. type:INSERT_PROCESS,
  54. });
  55. dispatch({
  56. type:ISREAD
  57. })
  58. },
  59. async setData(info){//设置现病史使用模板
  60. // let idsArr = info.mainIds;
  61. let idsArr = info.mainTailIds.filter((it,i)=>{return it});
  62. // let ids = idsArr.join(",");
  63. let labelModule = await getModules(idsArr);
  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. pushMessage: (data) => {
  82. dispatch(() => pushMessage(data))
  83. },
  84. //文本模式下推送
  85. fetchPushInfos(){
  86. //调右侧推送
  87. if(didPushParamChange()) {
  88. dispatch(billing());
  89. }
  90. },
  91. handleInput(obj){ //文本模式值保存
  92. dispatch({
  93. type:SETTEXTMODEVALUE,
  94. text:obj.text
  95. })
  96. },
  97. fetchModules(param){
  98. const {id,name,index,span,conceptId} = param;
  99. getModule(id).then((res)=>{
  100. if(res.data.code=='0'){
  101. dispatch({
  102. type:SELECT_SEARCHDATA,
  103. index,
  104. name,
  105. data: res.data.data,
  106. span,
  107. isReplace:false,
  108. conceptId
  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. freeText(item){//自由输入
  127. dispatch({
  128. type: SAVE_CURR_FREE,
  129. data:item
  130. })
  131. //右侧推送
  132. setTimeout(function(){
  133. if(didPushParamChange()){
  134. dispatch(billing());
  135. }
  136. },500);
  137. }
  138. }
  139. }
  140. const CurrentIllContainer = connect(
  141. mapStateToProps,
  142. mapDispatchToProps
  143. )(CurrentIll);
  144. export default CurrentIllContainer;