CheckBody.js 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. import {connect} from 'react-redux';
  2. import CheckBody from '@components/CheckBody';
  3. import {getModule,getInitData} from '@store/async-actions/fetchModules.js';
  4. import {HIDE,RESET,SETDROPSHOW,ISREAD,SEARCH_DROP_LOCATION,MODI_LOADING} from '@store/types/homePage.js';
  5. import {SELECTSEARCHDATA} from "@store/types/checkBody";
  6. import {billing} from '@store/async-actions/pushMessage';
  7. import {didPushParamChange,filterDataArr} from '@utils/tools.js';
  8. function mapStateToProps(state){
  9. const {homePage,mainSuit,checkBody} = state;
  10. const hasMain = filterDataArr(mainSuit.saveText);//||mainSuit.data.length;
  11. return {
  12. data:checkBody.data,
  13. defaultShowAll:checkBody.showAll,
  14. isEmpty:checkBody.isEmpty,
  15. update:checkBody.update, //用于触发更新
  16. showArr:homePage.showDrop,
  17. totalHide:homePage.totalHide,
  18. saveText:checkBody.saveText,
  19. searchData:checkBody.searchData, //延迟搜索结果
  20. hasMain,//主诉选中的数据
  21. focusTextIndex:checkBody.focusIndex, //聚焦的自由文本标签index
  22. span:checkBody.span,
  23. searchInEnd:checkBody.searchInEnd, //是否在搜索末尾插入结果
  24. selecteds:checkBody.selecteds, //普通多选选中状态
  25. boxTop:state.homePage.boxTop,
  26. boxLeft:state.homePage.boxLeft,
  27. importLabel:checkBody.importLabel, //需高亮的标签id
  28. }
  29. }
  30. function mapDispatchToProps(dispatch){
  31. return {
  32. getInit(){
  33. //dispatch({type:MODI_LOADING,flag:true});
  34. dispatch(getInitData());
  35. },
  36. fetchModules(param){
  37. const {id,name,index,span,searchInEnd} = param;
  38. getModule(id).then((res)=>{
  39. if(res.data.code=='0'){
  40. dispatch({
  41. type:SELECTSEARCHDATA,
  42. index,
  43. name,
  44. data: res.data.data,
  45. span,
  46. isReplace:false,
  47. searchInEnd
  48. });
  49. dispatch({
  50. type:ISREAD
  51. });
  52. //调右侧推送
  53. if(didPushParamChange()) {
  54. dispatch(billing());
  55. }
  56. }
  57. });
  58. },
  59. getSearchLocation(top,left){
  60. dispatch({
  61. type:SEARCH_DROP_LOCATION,
  62. top:top,
  63. left:left,
  64. dis:0
  65. })
  66. }
  67. }
  68. }
  69. const CheckBodyCont = connect(mapStateToProps,mapDispatchToProps)(CheckBody);
  70. export default CheckBodyCont;