import React from 'react'; import { connect } from 'react-redux'; import CurrentIll from '@components/CurrentIll'; import {INSERT_PROCESS,SET_CURRENT_DATA,SETTEXTMODEVALUE,SET_LABEL_MODULE,SELECT_SEARCHDATA,CLEAR_CURRENT_EDIT,SAVE_CURR_FREE} from '@store/types/currentIll'; import {pushMessage} from '../store/async-actions/pushContainer'; import {getModules} from '../store/async-actions/fetchModules.js'; import {SETDROPSHOW} from '@types/homePage.js'; import {HIDE,RESET,CLICKCOUNT,ISREAD,SEARCH_DROP_LOCATION} from '@store/types/homePage.js'; import {billing} from '@store/async-actions/pushMessage'; import {getModule} from '@store/async-actions/fetchModules.js'; import {didPushParamChange} from '@utils/tools.js'; import {Notify} from '@commonComp'; function mapStateToProps(state) { const {homePage,currentIll,mainSuit,diagnosticList} = state; return { data:currentIll.data,//主诉模板 emptyData:currentIll.emptyData,//空模板 searchData:currentIll.searchDatas,//搜索结果 focusIndex:currentIll.focusIndex, processModule:currentIll.processModule,//病程变化模板 showArr:homePage.showDrop, span:currentIll.span, update:currentIll.update,//用于更新 mainText:mainSuit.saveText,//主诉选中的数据 mainData:mainSuit.data,//主诉使用的模板 symptomFeature:mainSuit.symptomFeature,//主诉分词数据 moduleNum:mainSuit.moduleNum,//主诉使用的模板 type: state.typeConfig.typeConfig, mainIds:mainSuit.mainIds,//主诉症状选中的id(去重用) mainTailIds:mainSuit.mainTailIds,//主诉症状选中的id(去重用) totalHide: homePage.totalHide, saveText:currentIll.saveText, selecteds:currentIll.selecteds, //普通多选选中状态 editClear:currentIll.editClear, symptomIds:currentIll.symptomIds,//症状id,去重用 isRead:homePage.isRead, fuzhen:diagnosticList.mainSuitStr,//诊断第一个复诊值 boxTop:homePage.boxTop, boxLeft:homePage.boxLeft, allModules:homePage.allModules, // isChronic:!!diagnosticList.chronicMagItem, isChronic:mainSuit.chronicDesease?mainSuit.chronicDesease:diagnosticList.chronicMagItem, } } function mapDispatchToProps(dispatch) { return { insertProcess(obj,allModules){//点击病程变化 // 埋点dispatch dispatch({ type:CLICKCOUNT, data:{id:obj.id}, clickType:'单击', num:1 }); // 判断是否有子模板数据 const sonId = obj.relationModule;//子模板id let sonArr = allModules.filter((item)=>{return item.id==sonId}) if(sonArr.length==0){//未匹配到子模板 Notify.info("未找到相关内容"); return } dispatch({ type:INSERT_PROCESS, // id:obj.relationModule, // allModules:allModules addSmoduleData:JSON.parse(JSON.stringify(sonArr[0].moduleDetailDTOList)) }); dispatch({ type:ISREAD }) }, async setData(info){//设置现病史使用模板 // let idsArr = info.mainIds; let idsArr = info.mainTailIds.filter((it,i)=>{return it}); // let ids = idsArr.join(","); let labelModule = await getModules(idsArr); if(labelModule.data.code==0){//根据id获取标签模板 dispatch({ type:SET_LABEL_MODULE, data:labelModule.data.data }) } dispatch({ type:SET_CURRENT_DATA, info }) //右侧推送 setTimeout(function(){ //延迟待确定后的数据更新后推送,避免获取的参数还是旧的 if(didPushParamChange()){ //操作后内容有变化才推送 dispatch(billing()); } },500); }, pushMessage: (data) => { dispatch(() => pushMessage(data)) }, //文本模式下推送 fetchPushInfos(){ //调右侧推送 if(didPushParamChange()) { dispatch(billing()); } }, handleInput(obj){ //文本模式值保存 dispatch({ type:SETTEXTMODEVALUE, text:obj.text }) }, fetchModules(param){ const {id,name,index,span,conceptId} = param; getModule(id).then((res)=>{ if(res.data.code=='0'){ dispatch({ type:SELECT_SEARCHDATA, index, name, data: res.data.data, span, isReplace:false, conceptId }) dispatch({ type:ISREAD }) } }); //右侧推送 setTimeout(function(){ dispatch(billing()); },200); }, changeEditIll(bool){ dispatch({ type:CLEAR_CURRENT_EDIT, editClear:bool }) }, getSearchLocation(top,left){ dispatch({ type:SEARCH_DROP_LOCATION, top:top, left:left, dis:0 }) }, freeText(item){//自由输入 dispatch({ type: SAVE_CURR_FREE, data:item }) //右侧推送 setTimeout(function(){ if(didPushParamChange()){ dispatch(billing()); } },500); } } } const CurrentIllContainer = connect( mapStateToProps, mapDispatchToProps )(CurrentIll); export default CurrentIllContainer;