NumberUnitDrop.js 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190
  1. import React from 'react';
  2. import {connect} from 'react-redux';
  3. import NumberUnitDrop from "@components/NumberUnitDrop";
  4. import {SETNUMBER,CHANGEOTHERTEXTLABEL} from '@types/otherHistory';
  5. import {SETNUMBER4,CHANGECHECKTEXTLABEL} from '@types/checkBody.js';
  6. import {SETDROPSHOW,CLICKCOUNT,HIDE,RESET,HIDEDROP,ISREAD} from '@types/homePage.js';
  7. import {NUMBER_SELECT,CHANGE_LABELVAL} from '@store/types/mainSuit.js';
  8. import {getLabelIndex} from '@common/js/func.js';
  9. import {CURRENT_NUMBER,CURRENT_TEXT_LABEL} from '@store/types/currentIll.js';
  10. import {Notify} from '@commonComp';
  11. import {filterArr,didPushParamChange,filterDataArr} from '@utils/tools.js';
  12. import {billing} from '@store/async-actions/pushMessage';
  13. import config from '@config/index.js';
  14. function mapStateToProps(state){
  15. return {
  16. mainSaveText:state.mainSuit.saveText,
  17. }
  18. }
  19. //查体数字键盘选中
  20. function checkSelect(dispatch,params){
  21. dispatch({
  22. type:SETNUMBER4,
  23. params
  24. });
  25. }
  26. //其他史数字键盘选中
  27. function otherSelect(dispatch,params){
  28. dispatch({
  29. type:SETNUMBER,
  30. params
  31. });
  32. }
  33. //主诉
  34. function mainSelect(dispatch,params){
  35. dispatch({
  36. type:NUMBER_SELECT,
  37. params
  38. });
  39. }
  40. //现病史
  41. function currentSelect(dispatch,params){
  42. dispatch({
  43. type:CURRENT_NUMBER,
  44. params
  45. });
  46. }
  47. function handleModuleDiff(dispatch,params){
  48. const {mainSaveText,mark} = params;
  49. const type = params.ikey.substr(0,1); //当前所在的项目
  50. switch (+type){
  51. case 1:
  52. if(mark){//选中才限制,清空和回退无需验证
  53. let text = filterDataArr(mainSaveText);
  54. if(text.length >= config.limited){
  55. Notify.info(config.limitText);
  56. return
  57. }
  58. }
  59. mainSelect(dispatch,params);
  60. break;
  61. case 2:
  62. currentSelect(dispatch,params);
  63. break;
  64. case 3:
  65. otherSelect(dispatch,params);
  66. break;
  67. case 4:
  68. checkSelect(dispatch,params);
  69. break;
  70. default:
  71. }
  72. }
  73. /**************************双击标签输入*********************************/
  74. // 主诉
  75. function mainSuitLabel(dispatch,params){
  76. const index = params.ikey;
  77. let ikey = getLabelIndex(index);
  78. const {changeVal,totalVal} = params;
  79. dispatch({
  80. type:CHANGE_LABELVAL,
  81. data:{changeVal:changeVal,ikey:ikey,totalVal}
  82. })
  83. }
  84. // 现病史
  85. function currentLabel(dispatch,params){
  86. const index = params.ikey;
  87. let ikey = getLabelIndex(index);
  88. dispatch({
  89. type:CURRENT_TEXT_LABEL,
  90. data:{changeVal:params.changeVal,ikey:ikey}
  91. })
  92. }
  93. //其他史
  94. function otherHisLabelEdit(dispatch,params){
  95. const index = params.ikey;
  96. const {changeVal,totalVal} = params;
  97. let ikey = getLabelIndex(index);
  98. dispatch({
  99. type:CHANGEOTHERTEXTLABEL,
  100. data:{changeVal:changeVal,ikey:ikey,totalVal}
  101. })
  102. }
  103. //查体
  104. function checkBodyLabelEdit(dispatch,params){
  105. const index = params.ikey;
  106. let ikey = getLabelIndex(index);
  107. const {changeVal,totalVal} = params;
  108. dispatch({
  109. type:CHANGECHECKTEXTLABEL,
  110. data:{changeVal:changeVal,ikey:ikey,totalVal}
  111. })
  112. }
  113. function mapDispatchToProps(dispatch,store){
  114. return {
  115. handleSelect(params){
  116. handleModuleDiff(dispatch,params);
  117. //右侧推送
  118. clearTimeout(timer);
  119. let timer = setTimeout(function(){ //延迟待确定后的数据更新后推送,避免获取的参数还是旧的
  120. if(didPushParamChange()){ //操作后内容有变化才推送
  121. dispatch(billing());
  122. clearTimeout(timer);
  123. }
  124. },config.delayPushTime);
  125. if(!params.text.trim()){
  126. dispatch({
  127. type:ISREAD
  128. })
  129. }
  130. },
  131. handleDbclick(obj){
  132. dispatch({
  133. type:CLICKCOUNT,
  134. data:obj,
  135. clickType:'双击',
  136. num:1
  137. });
  138. },
  139. handleHide(){
  140. dispatch({
  141. type:HIDEDROP
  142. })
  143. },
  144. handleShow(params) {
  145. dispatch({
  146. type:CLICKCOUNT,
  147. data:params,
  148. clickType:'单击',
  149. num:1
  150. });
  151. dispatch({
  152. type:SETDROPSHOW,
  153. data:params
  154. });
  155. /*dispatch({
  156. type: RESET
  157. });*/
  158. },
  159. handleLabelChange(params){
  160. const {type} = params;
  161. switch (+type){
  162. case 1:
  163. mainSuitLabel(dispatch,params);
  164. break;
  165. case 2:
  166. currentLabel(dispatch,params);
  167. break;
  168. case 3:
  169. otherHisLabelEdit(dispatch,params);
  170. break;
  171. case 4:
  172. checkBodyLabelEdit(dispatch,params);
  173. break;
  174. default:
  175. }
  176. dispatch({
  177. type: ISREAD
  178. });
  179. }
  180. }
  181. }
  182. const NumberUnitDropCont = connect(mapStateToProps,mapDispatchToProps)(NumberUnitDrop);
  183. export default NumberUnitDropCont;