RadioDrop.js 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  1. import React from 'react';
  2. import {connect} from 'react-redux';
  3. import RadioDrop from "@components/RadioDrop";
  4. import {SETRADIO,CLEARSELECTED,CONFIRMSELECTED,CHANGEOTHERTEXTLABEL} from '@types/otherHistory';
  5. import {SETSELECTED4,CHANGECHECKTEXTLABEL} from '@types/checkBody';
  6. import {SETDROPSHOW,HIDE,RESET,HIDEDROP,CLICKCOUNT,ISREAD} from '@types/homePage.js';
  7. import {RADIO_SELECT,CHANGE_LABELVAL} from '@store/types/mainSuit.js';
  8. import {CURRENT_RADIO,CURRENT_TEXT_LABEL} from '@store/types/currentIll.js';
  9. import {Notify} from '@commonComp';
  10. import {filterArr,didPushParamChange,filterDataArr,getLabelIndex,fullfillText} from '@utils/tools.js';
  11. import {billing} from '@store/async-actions/pushMessage';
  12. import config from '@config/index.js';
  13. function mapStateToProps(state){
  14. return {
  15. mainSaveText:state.mainSuit.saveText,
  16. }
  17. }
  18. // 主诉选中事件
  19. function mainSelect(dispatch,params){
  20. const {id,ikey,text} = params;
  21. dispatch({
  22. type:RADIO_SELECT,
  23. id,
  24. ikey,
  25. text:text||''
  26. });
  27. }
  28. // 现病史选中事件
  29. function currentSelect(dispatch,params){
  30. const {id,ikey,text} = params;
  31. dispatch({
  32. type:CURRENT_RADIO,
  33. id,
  34. ikey,
  35. text:text||''
  36. });
  37. }
  38. //其他史选中事件
  39. function otherSelect(dispatch,params){
  40. const {id,ikey,text} = params;
  41. dispatch({
  42. type:SETRADIO,
  43. id,
  44. ikey,
  45. text:text||''
  46. });
  47. }
  48. //查体单选下拉选中事件
  49. function checkSelect(dispatch,params){
  50. const {id,ikey,text} = params;
  51. dispatch({
  52. type:SETSELECTED4,
  53. id,
  54. ikey,
  55. text:text||''
  56. });
  57. }
  58. //在不同模块(主诉、现病史等)下拉选中调用不同事件
  59. function handleModuleDiff(dispatch,store,params){
  60. const {mainSaveText,value,text} = params;
  61. const type = params.ikey.substr(0,1); //当前所在的项目
  62. switch (+type){
  63. case 1:
  64. if(text){//有选值才需要判断,清空不需要处理
  65. let mainText = filterDataArr(mainSaveText);
  66. let lengths = value?mainText.length - value.length + text.length:mainText.length + text.length;
  67. if(lengths >= config.limited){
  68. Notify.info(config.limitText);
  69. return
  70. }
  71. }
  72. mainSelect(dispatch,params);
  73. break;
  74. case 2:
  75. currentSelect(dispatch,params);
  76. break;
  77. case 3:
  78. otherSelect(dispatch,params);
  79. break;
  80. case 4:
  81. checkSelect(dispatch,params);
  82. break;
  83. default:
  84. }
  85. }
  86. /**************标签双击输入action types**************/
  87. const dbEditActions = {
  88. 1:CHANGE_LABELVAL,
  89. 2:CURRENT_TEXT_LABEL,
  90. 3:CHANGEOTHERTEXTLABEL,
  91. 4:CHANGECHECKTEXTLABEL
  92. };
  93. function mapDispatchToProps(dispatch,store){
  94. return {
  95. handleSelect(params) {
  96. handleModuleDiff(dispatch, store, params);
  97. //单选选中隐藏弹窗
  98. dispatch({
  99. type: HIDEDROP
  100. });
  101. //右侧推送
  102. setTimeout(function(){ //延迟待确定后的数据更新后推送,避免获取的参数还是旧的
  103. if(didPushParamChange()){ //操作后内容有变化才推送
  104. dispatch(billing('',params.ikey.substr(0,1)));
  105. }
  106. },500);
  107. },
  108. handleDbclick(obj){//双击统计
  109. dispatch({
  110. type:CLICKCOUNT,
  111. data:obj,
  112. clickType:'双击',
  113. num:1
  114. });
  115. },
  116. handleLabelEdit(params){
  117. const {type} = params;
  118. const index = params.ikey;
  119. let ikey = getLabelIndex(index);
  120. dispatch({
  121. type:dbEditActions[+type],
  122. data:{changeVal:params.changeVal,ikey:ikey}
  123. });
  124. dispatch(billing());
  125. dispatch({
  126. type:ISREAD
  127. })
  128. },
  129. handleShow(obj) {
  130. dispatch({
  131. type:CLICKCOUNT,
  132. data:obj,
  133. clickType:'单击',
  134. num:1
  135. });
  136. dispatch({
  137. type:SETDROPSHOW,
  138. data:obj
  139. });
  140. dispatch({
  141. type: RESET
  142. });
  143. }
  144. }
  145. }
  146. const RadioDropCont = connect(mapStateToProps,mapDispatchToProps)(RadioDrop);
  147. export default RadioDropCont;