BlockInpContainer.js 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. import React from 'react';
  2. import {connect} from 'react-redux';
  3. import {SETTEXTMODEVALUE} from '@store/types/mainSuit';
  4. import {SETCURRENTTEXTMODEVALUE} from '@store/types/currentIll';
  5. import {SETOTHERTEXTMODEVALUE} from '@store/types/otherHistory';
  6. import {SETCHECKTEXTMODEVALUE} from '@store/types/checkBody';
  7. import { SETPASTTEXTMODEVALUE } from '@store/types/pastHistory'
  8. import { SETPERSONALTEXTMODEVALUE } from '@store/types/personalHistory'
  9. import { SETFAMILYTEXTMODEVALUE } from '@store/types/familyHistory'
  10. import { SETMARRIAGETEXTMODEVALUE } from '@store/types/marriageHistory'
  11. import { SETMENSTRUATIONTEXTMODEVALUE } from '@store/types/menstruationHistory'
  12. import BlockInp from '@common/components/BlockInp';
  13. import {didPushParamChange,isAllPartClear,getAllDataList,getAllDataStringList,isAllClear} from '@utils/tools';
  14. import {embedPush} from '@store/async-actions/pushMessage';
  15. function mapStateToProps(state){
  16. const {homePage} = state;
  17. return {
  18. isRead:homePage.isRead,
  19. }
  20. }
  21. const actionsType = {
  22. '1': SETTEXTMODEVALUE, // 主述
  23. '2': SETCURRENTTEXTMODEVALUE, // 现病史
  24. // '3': SETOTHERTEXTMODEVALUE, // 其他史
  25. '4': SETCHECKTEXTMODEVALUE, // 查体
  26. '13': SETPASTTEXTMODEVALUE, // 设置既往史
  27. '14': SETPERSONALTEXTMODEVALUE, // 设置个人史
  28. '15': SETFAMILYTEXTMODEVALUE, // 设置家族史
  29. '16': SETMARRIAGETEXTMODEVALUE, // 设置婚育史
  30. '17': SETMENSTRUATIONTEXTMODEVALUE, // 设置月经史
  31. };
  32. const formatMode = mode => {
  33. switch (mode) {
  34. case '0':
  35. return 'patientia'; // 非空切非输入状态
  36. case '1':
  37. return 'chief'; // 主述
  38. case '2':
  39. return 'symptom'; // 现代史
  40. case '4':
  41. return 'vital'; // 现代史
  42. case '13':
  43. return 'other'; //其他史
  44. case '14':
  45. return 'other'; //其他史
  46. case '15':
  47. return 'other'; //其他史
  48. case '16':
  49. return 'other'; //其他史
  50. case '17':
  51. return 'other'; //其他史
  52. default:
  53. return 'null';
  54. }
  55. };
  56. function mapDispatchToProps(dispatch){
  57. return {
  58. handleInput(obj){ //自由模式值保存
  59. dispatch({
  60. type:actionsType[obj.boxMark],
  61. text:obj.text
  62. })
  63. },
  64. handlePush(obj={}){
  65. const {boxMark,isFocus,state} = obj;
  66. // console.log(boxMark, 'boxMark盒子标记');
  67. const notClear=state?isAllClear(getAllDataStringList(state)):false;
  68. // if(isFocus&&(boxMark==='1'||boxMark==='2')&&!notClear){
  69. // // dispatch(embedPush({mode:+boxMark+1}));
  70. // dispatch(embedPush({ mode: +boxMark + 1, action: formatMode(boxMark) }));
  71. // return;
  72. // }
  73. // if (isFocus && !notClear) {
  74. if (isFocus) {
  75. // dispatch(embedPush({mode:+boxMark+1}));
  76. dispatch(embedPush({ mode: +boxMark + 1, action: formatMode(boxMark) }));
  77. return;
  78. }
  79. if(!isFocus&&didPushParamChange()) { //输入的情况
  80. // dispatch(embedPush({mode:+boxMark+3}));
  81. dispatch(embedPush({ mode: +boxMark + 100, action: formatMode(boxMark) }));
  82. }
  83. }
  84. }
  85. }
  86. const BlockInpCont = connect(
  87. mapStateToProps,
  88. mapDispatchToProps
  89. )(BlockInp);
  90. export default BlockInpCont;