浏览代码

查体在现病史推送时获取模板优化

zhouna 6 年之前
父节点
当前提交
25ebaffade

+ 2 - 2
src/containers/CheckBody.js

@@ -29,10 +29,10 @@ function mapStateToProps(state){
   }
 }
 
-function mapDispatchToProps(dispatch,state){
+function mapDispatchToProps(dispatch){
   return {
     getInit(){
-      dispatch({type:MODI_LOADING,flag:true});
+      //dispatch({type:MODI_LOADING,flag:true});
       dispatch(getInitData());
     },
     fetchModules(param){

+ 1 - 1
src/containers/EditableSpan.js

@@ -182,7 +182,7 @@ function mapDispatchToProps(dispatch,state) {
       clearTimeout(timer);
       let timer = setTimeout(function(){      //延迟待确定后的数据更新后推送,避免获取的参数还是旧的
         if(didPushParamChange()){     //操作后内容有变化才推送
-          dispatch(billing());
+          dispatch(billing('',obj.boxMark));
           clearTimeout(timer);
         }
       },config.delayPushTime);

+ 1 - 1
src/containers/NumberDrop.js

@@ -128,7 +128,7 @@ function mapDispatchToProps(dispatch,store){
       clearTimeout(timer);
       let timer = setTimeout(function(){      //延迟待确定后的数据更新后推送,避免获取的参数还是旧的
         if(didPushParamChange()){     //操作后内容有变化才推送
-          dispatch(billing());
+          dispatch(billing('',params.ikey.substr(0,1)));
           clearTimeout(timer);
         }
       },config.delayPushTime);

+ 1 - 1
src/containers/NumberUnitDrop.js

@@ -136,7 +136,7 @@ function mapDispatchToProps(dispatch,store){
       clearTimeout(timer);
       let timer = setTimeout(function(){      //延迟待确定后的数据更新后推送,避免获取的参数还是旧的
         if(didPushParamChange()){     //操作后内容有变化才推送
-          dispatch(billing());
+          dispatch(billing('',params.ikey.substr(0,1)));
           clearTimeout(timer);
         }
       },config.delayPushTime);

+ 1 - 1
src/containers/RadioDrop.js

@@ -110,7 +110,7 @@ function mapDispatchToProps(dispatch,store){
       //右侧推送
       setTimeout(function(){      //延迟待确定后的数据更新后推送,避免获取的参数还是旧的
         if(didPushParamChange()){     //操作后内容有变化才推送
-          dispatch(billing());
+          dispatch(billing('',params.ikey.substr(0,1)));
         }
       },500);
     },

+ 1 - 1
src/containers/RadioInpDrop.js

@@ -138,7 +138,7 @@ function mapDispatchToProps(dispatch,store){
       //右侧推送
       setTimeout(function(){      //延迟待确定后的数据更新后推送,避免获取的参数还是旧的
         if(didPushParamChange()){     //操作后内容有变化才推送
-          dispatch(billing());
+          dispatch(billing('',params.ikey.substr(0,1)));
         }
       },500);
     },

+ 1 - 1
src/containers/SpreadDrop.js

@@ -457,7 +457,7 @@ function handleLabel(dispatch,params){
       break;
     default:
   }
-  dispatch(billing());
+  dispatch(billing('',type));
   dispatch({
     type:ISREAD
   })

+ 9 - 0
src/store/actions/checkBody.js

@@ -1,6 +1,14 @@
 import config from '@config/index.js';
 import {getLabelIndex,fullfillText} from '@common/js/func.js';
 import {formatContinueDots} from '@utils/tools.js';
+
+export function preSetCheckbody(state,action) {
+  let res = Object.assign({},state);
+  const {data} = action;
+  res.preData = data;
+  return res;
+}
+
 //设置查体数据
 export function set(state,action){
   let res = Object.assign({},state);
@@ -401,6 +409,7 @@ export const changeNumLabelVal = (state,action)=>{
 export function clearCheckBody(state,action){  //清空
   let res = Object.assign({},state);
   res.data = action.data;
+  res.preData = [];
   res.saveText = action.saveText;
   res.isEmpty = action.isEmpty;
   res.selecteds = action.selecteds?action.selecteds:[];

+ 34 - 16
src/store/async-actions/fetchModules.js

@@ -1,5 +1,5 @@
 import {json} from '@utils/ajax.js';
-import {SET} from '@types/checkBody.js';
+import {SET,PRESET} from '@types/checkBody.js';
 import {fullfillText,_fullfillText} from '@common/js/func';
 import {SETDATA} from '@store/types/otherHistory';
 import store from '@store';
@@ -138,9 +138,12 @@ export const getOtherHisRecord = ()=>{
   }
 };
 
-//查体模板数据获取
-export function getInitData(){
+//预取查体模板数据-现病史触发推送时获取
+export function pregetCheckbodyData(flag){     //flag=true获取到数据后立即显示
   return (dispatch)=>{
+    if(flag){
+      dispatch({type:MODI_LOADING,flag:true});
+    }
     const emrData = getEMRParams();
     const param = {
       age: emrData.age,
@@ -155,29 +158,44 @@ export function getInitData(){
     };
     json(api.getBigPush,param).then((res)=>{
       if(+res.data.code === 0){
-        dispatch({type:MODI_LOADING,flag:false});
         const data = res.data.data&&res.data.data.vital;
-        const str = JSON.stringify(data);
-        const arr = fullfillText(JSON.parse(str),false,false,false).newArr;
         dispatch({
-          type:SET,
-          data:arr,
-          isEmpty:false
+          type:PRESET,
+          data:data
         });
+        if(flag){
+          const arr = fullfillText(data,false,false,false).newArr;
+          dispatch({
+            type:SET,
+            data:arr,
+            isEmpty:false
+          });
+          dispatch({type:MODI_LOADING,flag:false});
+        }
       }else{
-        dispatch({type:MODI_LOADING,flag:false});
-        const block = Object.assign(JSON.parse(config.textLabel),{full:true});      //无数据时保留一个自由文本标签可输入
-        dispatch({
-          type:SET,
-          data:[block],
-          isEmpty:true
-        });
         Notify.error(res.data.msg);
       }
     });
   }
 }
 
+//查体模板数据获取
+export function getInitData(){
+  return (dispatch,getStore)=>{
+    const state =  getStore();
+    const preData = [...state.checkBody.preData];
+    if(!preData||preData.length==0){
+      dispatch(pregetCheckbodyData(true));
+    }
+      const arr = fullfillText(preData,false,false,false).newArr;
+      dispatch({
+        type:SET,
+        data:arr,
+        isEmpty:false
+      });
+  }
+}
+
 //其他史模板填充-先取最近记录,无则用模板
 export function setOtherHisModule(){
   return (dispatch, getStore) => {

+ 9 - 2
src/store/async-actions/pushMessage.js

@@ -4,6 +4,7 @@ import { SET_CLICK_DIAG } from '../types/diagnosticList';
 import {storageLocal,getEMRParams} from '@utils/tools';
 import {SET_IMPORT_CHECKBODY_LABEL} from "../types/checkBody";
 import { Notify} from '@commonComp';
+import {pregetCheckbodyData} from '@store/async-actions/fetchModules';
 
 const api={
   push:'/push/pushInner',
@@ -12,7 +13,7 @@ const api={
 }
 
 //获取右侧推送信息
-export const billing = (mdata) => {
+export const billing = (mdata,boxMark) => {
  return (dispatch, getState) =>{
   const state = getState();
   let url = api.push;
@@ -85,7 +86,13 @@ export const billing = (mdata) => {
      });
    }).catch((e) =>{
      console.log(e)
-   })
+   });
+
+   //调查体,现病史触发推送且查体无数据时获取查体模板
+   const checkBody = state.checkBody.data;
+   if(boxMark==2&&!(checkBody&&checkBody.length>0&&!checkBody[0].full)){
+     dispatch(pregetCheckbodyData());
+   }
  }
 };
 

+ 6 - 3
src/store/reducers/checkBody.js

@@ -1,10 +1,10 @@
 import {SET,SETNUMBER4,SETSELECTED4,SETCHECKBOX,ADDLABELITEM,SETCHECKTEXT,SETSEARCHDATA,
   SELECTSEARCHDATA,CHANGECHECKTEXTLABEL,CLEARCHECKBODY,CHECK_FOCUS_INDEX,CHECKBODY_CLEAR,
   SETCHECKINPUT,DEL_CHECKBODY,CHANGECHECKTEXTLABEL_NUMBER,CHECKCONFIRMSELECTED,
-  CHECKBODY_MUL,DEL_CHECKBODY_LABLE,SET_CK_RADIO_INPUT_VAL,SET_IMPORT_CHECKBODY_LABEL} from '../types/checkBody.js';
+  CHECKBODY_MUL,DEL_CHECKBODY_LABLE,SET_CK_RADIO_INPUT_VAL,SET_IMPORT_CHECKBODY_LABEL,PRESET} from '../types/checkBody.js';
 import {set,setNumberValue,setRadioValue,setCheckBoxValue,addLabelItem,setCheckText,
   setSearchData,insertLabelData,changeLabelVal,clearCheckBody,setInputLabel,backspaceText,
-  changeNumLabelVal,confirm,multipleComfirn,delSingleLable,setRadioInputValue,setImportCheckbodyLabel} from '../actions/checkBody.js';
+  changeNumLabelVal,confirm,multipleComfirn,delSingleLable,setRadioInputValue,setImportCheckbodyLabel,preSetCheckbody} from '../actions/checkBody.js';
 import config from '@config/index.js';
 
 const block = Object.assign(JSON.parse(config.textLabel),{full:true});//空白时保留一个自由文本标签
@@ -16,11 +16,14 @@ const initState = {
                 focusIndex:'',
                 isEmpty:true,      //是否为空白,需要请求数据
                 showSearchBox:false,
-                importLabel:[]//[430,436,40,278,435,279,28,442,447,448,449,450,453,454,457,456,282]
+                importLabel:[],//[430,436,40,278,435,279,28,442,447,448,449,450,453,454,457,456,282]
+                preData:[],     //预存的查体模板
           };
 export default function(state=initState,action){
   let res = Object.assign({},state);
   switch(action.type){
+    case PRESET:
+      return preSetCheckbody(state,action);
     case SET:
       return set(state,action);
     case SETNUMBER4:

+ 2 - 4
src/store/reducers/pushMessage.js

@@ -1,8 +1,8 @@
 import {CHANGE_ASSAY, CHANGE_CHECK, BILLING_ADVICE, ADD_SCHEME, SET_TIPS,  SET_TIPS_DETAILS, 
         SET_CHANGE_ADVICE_TREATMENT, SET_CHANGE_ADVICE_ASSAY, SET_CHANGE_ADVICE_CHECK, ADD_BILLING,
-        CLEAR_ALL_PUSH_MESSAGE,SHOW_TIPS_DETAILS, HIDE_TIPS_DETAILS, SET_COMMONTREATMENT, IS_FIRST_MAIN_DIAG, 
+        CLEAR_ALL_PUSH_MESSAGE,SHOW_TIPS_DETAILS, HIDE_TIPS_DETAILS, SET_COMMONTREATMENT,
         SET_ADVICE_INPUT ,SET_CHRONIC_TABLELIST,SHOW_TABLE_LIST,SET_SCALE_INFO,SET_CHRONIC_PUSHS,
-        SAVE_TABLE_RESULT, SAVE_FOLLOW_UP, DEL_FOLLOW_UP} from '../types/pushMessage';
+        SAVE_TABLE_RESULT, SAVE_FOLLOW_UP, DEL_FOLLOW_UP,PRESET} from '../types/pushMessage';
 import {changeAssay, changeCheck, setAdvice, addScheme, setTips, setTipsDetails, setChangeAdviceTreatment, 
         setChangeAdviceAssay, setChangeAdviceCheck, addBilling, clearAllPushMessage, showTipsDetails, hideTipsDetails, 
         setCommontreatment, isFirstMainDiag, setAdviceInput, saveFollowUp, delFollowUp } from '../actions/pushMessage';
@@ -55,8 +55,6 @@ export default function(state = initState, action) {
       return hideTipsDetails(state, action);
     case SET_COMMONTREATMENT:
       return setCommontreatment(state, action);
-    case IS_FIRST_MAIN_DIAG:
-      return isFirstMainDiag(state, action);
     case SET_ADVICE_INPUT:
       return setAdviceInput(state, action);
     case SAVE_FOLLOW_UP: 

+ 2 - 1
src/store/types/checkBody.js

@@ -18,4 +18,5 @@ export const CHECKCONFIRMSELECTED = 'spread_check_body_labels';
 export const CHECKBODY_MUL = 'CHECKBODY_MUL';//单列多选
 export const DEL_CHECKBODY_LABLE = 'DEL_CHECKBODY_LABLE';
 export const SET_CK_RADIO_INPUT_VAL = 'SET_CK_RADIO_INPUT_VAL';
-export const SET_IMPORT_CHECKBODY_LABEL='SET_IMPORT_CHECKBODY_LABEL';
+export const SET_IMPORT_CHECKBODY_LABEL='SET_IMPORT_CHECKBODY_LABEL';
+export const PRESET = 'PRESET_CHECKBODY_DATA';