OtherHistory.js 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. import React from 'react';
  2. import {connect} from 'react-redux';
  3. import OtherHistory from "../components/OtherHistory";
  4. import {SETSELECTED,CLEARSELECTED,CONFIRMSELECTED,SELECTOTHERSEARCHDATA,SETDATA,SETTEXTMODEVALUE,OTHEREDICLEAR} from '@types/otherHistory';
  5. import {HIDE,RESET} from '@store/types/homePage.js';
  6. import {getModule} from '@store/async-actions/fetchModules.js';
  7. import {billing} from '@store/async-actions/pushMessage';
  8. import {fullfillText} from '@common/js/func';
  9. import {didPushParamChange} from '@utils/tools.js';
  10. import {ISREAD} from "../store/types/homePage";
  11. function mapStateToProps(state){
  12. const {otherHistory,homePage,typeConfig,mainSuit} = state;
  13. const hasMain = mainSuit.saveText.join('');//||mainSuit.data.length;
  14. return {
  15. data: otherHistory.data,
  16. //initData:state.homePage.initData.otherHis,
  17. update:otherHistory.update, //用于触发更新
  18. showArr:homePage.showDrop,
  19. totalHide:homePage.totalHide,
  20. saveText:otherHistory.saveText,
  21. type: typeConfig.typeConfig,
  22. hasMain,//主诉是否有数据
  23. searchData:otherHistory.searchData, //延迟搜索结果
  24. focusTextIndex:otherHistory.focusIndex, //聚焦的自由文本标签index
  25. span:otherHistory.span,
  26. selecteds:otherHistory.selecteds, //普通多选选中状态
  27. editClear:otherHistory.editClear, //编辑状态
  28. isRead:state.homePage.isRead
  29. }
  30. }
  31. function mapDispatchToProps(dispatch,store){
  32. return {
  33. setInitData(){
  34. //先获取最近记录,没有的话显示模板
  35. dispatch((dispatch,getStore)=>{
  36. const initData = getStore().homePage.initData;
  37. const arr = JSON.parse(JSON.stringify(initData.otherHis));
  38. const arrSave = JSON.parse(JSON.stringify(initData.otherHisSave||null));
  39. const isHis = initData.otherIsHis;
  40. const listObj = isHis?{newArr:arr,saveText:arrSave||[]}:fullfillText(arr);
  41. dispatch({
  42. type:SETDATA,
  43. data:listObj.newArr,
  44. save:listObj.saveText
  45. });
  46. dispatch({
  47. type:ISREAD
  48. })
  49. });
  50. //右侧推送
  51. setTimeout(function(){ //延迟待确定后的数据更新后推送,避免获取的参数还是旧的
  52. if(didPushParamChange()){ //操作后内容有变化才推送
  53. dispatch(billing);
  54. }
  55. },500);
  56. },
  57. fetchModules(param){
  58. const {id,name,index,span} = param;
  59. getModule(id).then((res)=>{
  60. if(res.data.code=='0'){
  61. dispatch({
  62. type:SELECTOTHERSEARCHDATA,
  63. index,
  64. name,
  65. data: res.data.data,
  66. span,
  67. isReplace:false
  68. })
  69. }
  70. });
  71. },
  72. //右侧推送
  73. fetchPushInfos(){
  74. //调右侧推送
  75. dispatch(billing);
  76. },
  77. handleInput(obj){ //文本模式值保存
  78. dispatch({
  79. type:SETTEXTMODEVALUE,
  80. text:obj.text
  81. })
  82. },
  83. changeEditClear(bool){ //文本编辑模式
  84. dispatch({
  85. type:OTHEREDICLEAR,
  86. bool:bool
  87. })
  88. }
  89. }
  90. }
  91. const OtherHistoryCont = connect(mapStateToProps,mapDispatchToProps)(OtherHistory);
  92. export default OtherHistoryCont;