NumberUnitDrop.js 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204
  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 {CURRENT_NUMBER,CURRENT_TEXT_LABEL} from '@store/types/currentIll.js';
  9. import {Notify} from '@commonComp';
  10. import {didPushParamChange,filterDataArr,getLabelIndex} 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. mainData:state.mainSuit.data,
  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,mainData} = params;
  49. const type = params.ikey.substr(0,1); //当前所在的项目
  50. let ikey = getLabelIndex(params.ikey);
  51. switch (+type){
  52. case 1:
  53. if(mark){//选中才限制,清空和回退无需验证
  54. let text = filterDataArr(mainSaveText);
  55. const item = mainData[+ikey];
  56. const nextItem = mainData[+ikey+1];
  57. let lengths = text.length;
  58. if(nextItem&&nextItem.tagType==8 && nextItem.tagName==',' && item.value){
  59. lengths = text.length + 1;
  60. }
  61. if(lengths >= config.limited){
  62. Notify.info(config.limitText);
  63. return
  64. }
  65. }
  66. mainSelect(dispatch,params);
  67. break;
  68. case 2:
  69. currentSelect(dispatch,params);
  70. break;
  71. case 3:
  72. otherSelect(dispatch,params);
  73. break;
  74. case 4:
  75. checkSelect(dispatch,params);
  76. break;
  77. default:
  78. }
  79. }
  80. /**************************双击标签输入*********************************/
  81. // 主诉
  82. function mainSuitLabel(dispatch,params){
  83. const index = params.ikey;
  84. let ikey = getLabelIndex(index);
  85. const {changeVal,totalVal} = params;
  86. dispatch({
  87. type:CHANGE_LABELVAL,
  88. // data:{changeVal:changeVal,ikey:ikey,totalVal}
  89. data:Object.assign({},params,{ikey})
  90. })
  91. }
  92. // 现病史
  93. function currentLabel(dispatch,params){
  94. const index = params.ikey;
  95. let ikey = getLabelIndex(index);
  96. dispatch({
  97. type:CURRENT_TEXT_LABEL,
  98. // data:{changeVal:params.changeVal,ikey:ikey}
  99. data:Object.assign({},params,{ikey})
  100. })
  101. }
  102. //其他史
  103. function otherHisLabelEdit(dispatch,params){
  104. const index = params.ikey;
  105. const {changeVal,totalVal} = params;
  106. let ikey = getLabelIndex(index);
  107. dispatch({
  108. type:CHANGEOTHERTEXTLABEL,
  109. // data:{changeVal:changeVal,ikey:ikey,totalVal}
  110. data:Object.assign({},params,{ikey})
  111. })
  112. }
  113. //查体
  114. function checkBodyLabelEdit(dispatch,params){
  115. const index = params.ikey;
  116. let ikey = getLabelIndex(index);
  117. const {changeVal,totalVal} = params;
  118. dispatch({
  119. type:CHANGECHECKTEXTLABEL,
  120. // data:{changeVal:changeVal,ikey:ikey,totalVal}
  121. data:Object.assign({},params,{ikey})
  122. })
  123. }
  124. function mapDispatchToProps(dispatch,store){
  125. return {
  126. handleSelect(params){
  127. handleModuleDiff(dispatch,params);
  128. //右侧推送
  129. clearTimeout(timer);
  130. let timer = setTimeout(function(){ //延迟待确定后的数据更新后推送,避免获取的参数还是旧的
  131. if(didPushParamChange()){ //操作后内容有变化才推送
  132. dispatch(billing());
  133. clearTimeout(timer);
  134. }
  135. },config.delayPushTime);
  136. if(!params.text.trim()){
  137. dispatch({
  138. type:ISREAD
  139. })
  140. }
  141. dispatch({
  142. type: ISREAD
  143. });
  144. },
  145. handleDbclick(obj){
  146. dispatch({
  147. type:CLICKCOUNT,
  148. data:obj,
  149. clickType:'双击',
  150. num:1
  151. });
  152. },
  153. handleHide(){
  154. dispatch({
  155. type:HIDEDROP
  156. })
  157. },
  158. handleShow(params) {
  159. dispatch({
  160. type:CLICKCOUNT,
  161. data:params,
  162. clickType:'单击',
  163. num:1
  164. });
  165. dispatch({
  166. type:SETDROPSHOW,
  167. data:params
  168. });
  169. /*dispatch({
  170. type: RESET
  171. });*/
  172. },
  173. handleLabelChange(params){
  174. const {type} = params;
  175. switch (+type){
  176. case 1:
  177. mainSuitLabel(dispatch,params);
  178. break;
  179. case 2:
  180. currentLabel(dispatch,params);
  181. break;
  182. case 3:
  183. otherHisLabelEdit(dispatch,params);
  184. break;
  185. case 4:
  186. checkBodyLabelEdit(dispatch,params);
  187. break;
  188. default:
  189. }
  190. dispatch({
  191. type: ISREAD
  192. });
  193. }
  194. }
  195. }
  196. const NumberUnitDropCont = connect(mapStateToProps,mapDispatchToProps)(NumberUnitDrop);
  197. export default NumberUnitDropCont;