import React from 'react'; import {connect} from 'react-redux'; import OtherHistory from "../components/OtherHistory"; import {SETSELECTED,CLEARSELECTED,CONFIRMSELECTED,SELECTOTHERSEARCHDATA,SETDATA,SETTEXTMODEVALUE,OTHEREDICLEAR} from '@types/otherHistory'; import {HIDE,RESET,ISREAD} from '@store/types/homePage.js'; import {getModule} from '@store/async-actions/fetchModules.js'; import {billing} from '@store/async-actions/pushMessage'; import {fullfillText} from '@common/js/func'; import {didPushParamChange} from '@utils/tools.js'; function mapStateToProps(state){ const {otherHistory,homePage,typeConfig,mainSuit} = state; const hasMain = mainSuit.saveText.join('');//||mainSuit.data.length; return { data: otherHistory.data, //initData:state.homePage.initData.otherHis, update:otherHistory.update, //用于触发更新 showArr:homePage.showDrop, totalHide:homePage.totalHide, saveText:otherHistory.saveText, type: typeConfig.typeConfig, hasMain,//主诉是否有数据 searchData:otherHistory.searchData, //延迟搜索结果 focusTextIndex:otherHistory.focusIndex, //聚焦的自由文本标签index span:otherHistory.span, selecteds:otherHistory.selecteds, //普通多选选中状态 editClear:otherHistory.editClear, //编辑状态 isRead:state.homePage.isRead } } function mapDispatchToProps(dispatch,store){ return { setInitData(){ //先获取最近记录,没有的话显示模板 dispatch((dispatch,getStore)=>{ const initData = getStore().homePage.initData; const arr = JSON.parse(JSON.stringify(initData.otherHis)); const arrSave = JSON.parse(JSON.stringify(initData.otherHisSave||null)); const isHis = initData.otherIsHis; const listObj = isHis?{newArr:arr,saveText:arrSave||[]}:fullfillText(arr); dispatch({ type:SETDATA, data:listObj.newArr, save:listObj.saveText }); dispatch({ type:ISREAD }) }); //右侧推送 setTimeout(function(){ //延迟待确定后的数据更新后推送,避免获取的参数还是旧的 if(didPushParamChange()){ //操作后内容有变化才推送 dispatch(billing); } },500); }, fetchModules(param){ const {id,name,index,span} = param; getModule(id).then((res)=>{ if(res.data.code=='0'){ dispatch({ type:SELECTOTHERSEARCHDATA, index, name, data: res.data.data, span, isReplace:false }); dispatch({ type:ISREAD }); } }); }, //右侧推送 fetchPushInfos(){ //调右侧推送 dispatch(billing); }, handleInput(obj){ //文本模式值保存 dispatch({ type:SETTEXTMODEVALUE, text:obj.text }) }, changeEditClear(bool){ //文本编辑模式 dispatch({ type:OTHEREDICLEAR, bool:bool }) } } } const OtherHistoryCont = connect(mapStateToProps,mapDispatchToProps)(OtherHistory); export default OtherHistoryCont;