Browse Source

历史病历和治疗方案添加loading

liucf 6 years ago
parent
commit
0f6eb6b2b4

+ 2 - 2
src/components/DiagnosticList/index.jsx

@@ -81,7 +81,7 @@ class DiagnosticList extends Component {
         // item.treatIndex = index
         const  { showTreat, getTreatResult } = this.props;
         getTreatResult && getTreatResult(item);
-        showTreat && showTreat();
+        // showTreat && showTreat();//添加loading,移到async-actions中
         this.setState({
             treatTitle: item.name
         })
@@ -103,7 +103,7 @@ class DiagnosticList extends Component {
               showHistoryCaseModal && showHistoryCaseModal();
             }else{
               if(typeConfig==0){
-                Notify.info("暂无历史病,已默认展示慢病相关内容");
+                Notify.info("暂无历史病,已默认展示慢病相关内容");
                 const timer = setTimeout(function(){
                   autoFillModules && autoFillModules();
                   clearTimeout(timer);

+ 19 - 3
src/components/InfoTitle/index.jsx

@@ -10,6 +10,7 @@ import { initItemList,setInitHistory } from '@store/async-actions/historyTemplat
 import HistoryCases from '@containers/HistoryCases';
 import $ from 'jquery';
 import Notify from '@commonComp/Notify';
+import {MODI_LOADING} from '@store/types/homePage.js';
 class InfoTitle extends Component {
     constructor(props){
         super(props);
@@ -19,15 +20,19 @@ class InfoTitle extends Component {
         this.showHistoryBox = this.showHistoryBox.bind(this)
     }
     showHistoryBox(){
+        const {showLoading,hideLoading}=this.props;
+        showLoading();
         // store.dispatch(initItemList());
         // store.dispatch(showHistory(true))
         initItemList().then((res)=>{
             const result = res.data;
             if(result.code==0 && result.data){
+                hideLoading();
                 store.dispatch(setInitHistory(result.data));
-                store.dispatch(showHistory(true))
+                store.dispatch(showHistory(true));
             }else{
-                Notify.info("暂无历史病例");
+                hideLoading();
+                Notify.info("暂无历史病历");
             }
         })
     }
@@ -66,9 +71,20 @@ function mapStateToProps(state) {
   }
 }
 
+function mapDispatchToProps(dispatch){
+    return{
+        showLoading(){
+            dispatch({type:MODI_LOADING,flag:true});
+        },
+        hideLoading(){
+            dispatch({type:MODI_LOADING,flag:false});
+        }
+    }
+}
+
 const InfoTitleCont = connect(
   mapStateToProps,
-  null
+  mapDispatchToProps
 )(InfoTitle);
 
 

+ 3 - 1
src/containers/DiagnosticList.js

@@ -10,6 +10,7 @@ import { showHistory,sortHistory,activeHistory,visibleHistory } from '@store/act
 import {CURRENT_CHRONIC} from '@store/types/currentIll';
 import {autoFillModules} from '@store/async-actions/fetchModules';
 import { initItemList } from '@store/async-actions/historyTemplates';
+import {MODI_LOADING} from '@store/types/homePage.js';
 
 function mapStateToProps(state) {
     return {
@@ -75,7 +76,8 @@ function mapDispatchToProps(dispatch) {
             })
         },
         getTreatResult: (item) => {
-            dispatch(getTreatResult(item))
+            dispatch({type:MODI_LOADING,flag:true});
+            dispatch(getTreatResult(item));
         },
         getTips: (diagItem) => {
             dispatch(getTips(diagItem))

+ 1 - 1
src/containers/MainSuit.js

@@ -203,7 +203,7 @@ function mapDispatchToProps(dispatch) {
         await dispatch(getInitModules);
         // 模板回来关闭;loading
         dispatch({type:MODI_LOADING,flag:false});
-        // 弹窗是否引用历史病
+        // 弹窗是否引用历史病
         // dispatch({type:SHOW_HISTORY_BOX});
         dispatch({type:SHOW_REFER_RECORD});
 

+ 6 - 2
src/store/async-actions/treat.js

@@ -1,11 +1,13 @@
 import { json } from "@utils/ajax";
-import { SET_TREAT } from '@store/types/diagnosticList';
-import { ADD_DIAGNOSTIC, GET_DIAGNOSTIC_STR} from '@store/types/diagnosticList';
+// import { SET_TREAT } from '@store/types/diagnosticList';
+import { ADD_DIAGNOSTIC, GET_DIAGNOSTIC_STR,SET_TREAT} from '@store/types/diagnosticList';
 import { SET_COMMONTREATMENT } from '@store/types/pushMessage'
 import { SET_DRUG_INFO, SET_TREATMENT, SET_TREAT_INFO, SET_RECOMMEND_BASIC, SET_DRUG_INFO_LIST, IS_FIRST_MAIN_DIAG, SET_ADVERSE_REACTIONS, SET_ALL_ADVERSE_REACTIONS, SET_FOLLOW_UP, DEL_FOLLOW_UP, SET_ALL_FOLLOW_UP } from '@store/types/treat';
 import {storageLocal,getEMRParams} from '@utils/tools';
 import { isAddMainSuit } from '@store/async-actions/diagnosticList';
 import { SAVE_FOLLOW_UP } from "@store/types/pushMessage";
+import {MODI_LOADING} from '@store/types/homePage.js';
+import { SHOW_TREAT} from '@store/types/treat.js';
 
 const api={
     push:'/push/pushInner',
@@ -194,6 +196,8 @@ export const getTreatResult = (item) =>{
 //获取治疗方案
 function getTreatment(item, dispatch, state,url,params, isChronic) {
     json(url, params).then((data) =>{
+        dispatch({type:MODI_LOADING,flag:false});
+        dispatch({type: SHOW_TREAT})
         let treat;
         if(data.data.data) {
              treat = data.data.data.treat || {}