CurrentIll.js 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  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 {SETDROPSHOW} from '@types/homePage.js';
  8. import {HIDE,RESET,CLICKCOUNT,ISREAD,SEARCH_DROP_LOCATION} from '@store/types/homePage.js';
  9. import {billing} from '@store/async-actions/pushMessage';
  10. import {getModule} from '@store/async-actions/fetchModules.js';
  11. import {didPushParamChange} from '@utils/tools.js';
  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. boxTop:homePage.boxTop,
  38. boxLeft:homePage.boxLeft,
  39. allModules:homePage.allModules,
  40. // isChronic:!!diagnosticList.chronicMagItem,
  41. isChronic:mainSuit.chronicDesease?mainSuit.chronicDesease:diagnosticList.chronicMagItem,
  42. }
  43. }
  44. function mapDispatchToProps(dispatch) {
  45. return {
  46. insertProcess(obj,allModules){//点击病程变化
  47. // 埋点dispatch
  48. dispatch({
  49. type:CLICKCOUNT,
  50. data:{id:obj.id},
  51. clickType:'单击',
  52. num:1
  53. });
  54. // 判断是否有子模板数据
  55. const sonId = obj.relationModule;//子模板id
  56. let sonArr = allModules.filter((item)=>{return item.id==sonId})
  57. if(sonArr.length==0){//未匹配到子模板
  58. Notify.info("未找到相关内容");
  59. return
  60. }
  61. dispatch({
  62. type:INSERT_PROCESS,
  63. // id:obj.relationModule,
  64. // allModules:allModules
  65. addSmoduleData:JSON.parse(JSON.stringify(sonArr[0].moduleDetailDTOList))
  66. });
  67. dispatch({
  68. type:ISREAD
  69. })
  70. },
  71. async setData(info){//设置现病史使用模板
  72. // let idsArr = info.mainIds;
  73. let idsArr = info.mainTailIds.filter((it,i)=>{return it});
  74. // let ids = idsArr.join(",");
  75. let labelModule = await getModules(idsArr);
  76. if(labelModule.data.code==0){//根据id获取标签模板
  77. dispatch({
  78. type:SET_LABEL_MODULE,
  79. data:labelModule.data.data
  80. })
  81. }
  82. dispatch({
  83. type:SET_CURRENT_DATA,
  84. info
  85. })
  86. //右侧推送
  87. setTimeout(function(){ //延迟待确定后的数据更新后推送,避免获取的参数还是旧的
  88. if(didPushParamChange()){ //操作后内容有变化才推送
  89. dispatch(billing());
  90. }
  91. },500);
  92. },
  93. pushMessage: (data) => {
  94. dispatch(() => pushMessage(data))
  95. },
  96. //文本模式下推送
  97. fetchPushInfos(){
  98. //调右侧推送
  99. if(didPushParamChange()) {
  100. dispatch(billing());
  101. }
  102. },
  103. handleInput(obj){ //文本模式值保存
  104. dispatch({
  105. type:SETTEXTMODEVALUE,
  106. text:obj.text
  107. })
  108. },
  109. fetchModules(param){
  110. const {id,name,index,span,conceptId} = param;
  111. getModule(id).then((res)=>{
  112. if(res.data.code=='0'){
  113. dispatch({
  114. type:SELECT_SEARCHDATA,
  115. index,
  116. name,
  117. data: res.data.data,
  118. span,
  119. isReplace:false,
  120. conceptId
  121. })
  122. dispatch({
  123. type:ISREAD
  124. })
  125. }
  126. });
  127. //右侧推送
  128. setTimeout(function(){
  129. dispatch(billing());
  130. },200);
  131. },
  132. changeEditIll(bool){
  133. dispatch({
  134. type:CLEAR_CURRENT_EDIT,
  135. editClear:bool
  136. })
  137. },
  138. getSearchLocation(top,left){
  139. dispatch({
  140. type:SEARCH_DROP_LOCATION,
  141. top:top,
  142. left:left,
  143. dis:0
  144. })
  145. },
  146. freeText(item){//自由输入
  147. dispatch({
  148. type: SAVE_CURR_FREE,
  149. data:item
  150. })
  151. //右侧推送
  152. setTimeout(function(){
  153. if(didPushParamChange()){
  154. dispatch(billing());
  155. }
  156. },500);
  157. }
  158. }
  159. }
  160. const CurrentIllContainer = connect(
  161. mapStateToProps,
  162. mapDispatchToProps
  163. )(CurrentIll);
  164. export default CurrentIllContainer;