Browse Source

【BUG】首页报表选中已选tab界面进入无限loading

zhuth 6 years ago
parent
commit
f816690e7a
3 changed files with 6 additions and 8 deletions
  1. 1 2
      src/components/homePage/index.jsx
  2. 0 2
      src/models/dataSource.js
  3. 5 4
      src/models/home.js

+ 1 - 2
src/components/homePage/index.jsx

@@ -95,8 +95,7 @@ class Home extends React.Component {
         const { tabs: allTabs, fixedDashboard } = home;
         const { tabs: allTabs, fixedDashboard } = home;
         let tabs = allTabs.filter(t => (t.code !== targetKey && (!fixedDashboard || t.code !== fixedDashboard.code) ));
         let tabs = allTabs.filter(t => (t.code !== targetKey && (!fixedDashboard || t.code !== fixedDashboard.code) ));
         let tab = allTabs.find(t => t.code === targetKey);
         let tab = allTabs.find(t => t.code === targetKey);
-        dispatch({ type: 'home/closeTabs', tabs });
-        dispatch({ type: 'home/changeTab', tab });
+        dispatch({ type: 'home/closeTabs', tabs, tab });
     }
     }
 
 
     removeAll = () => {
     removeAll = () => {

+ 0 - 2
src/models/dataSource.js

@@ -146,11 +146,9 @@ export default {
                 let l = list[i];
                 let l = list[i];
                 if(l.code === dataSourceCode) {
                 if(l.code === dataSourceCode) {
                     list[i] = { ...l, groupCode }
                     list[i] = { ...l, groupCode }
-                    console.log({ ...l, groupCode });
                     break;
                     break;
                 }
                 }
             }
             }
-            console.log(list);
             return Object.assign({}, state, {list: list});
             return Object.assign({}, state, {list: list});
         },
         },
         reset(state, action) {
         reset(state, action) {

+ 5 - 4
src/models/home.js

@@ -81,15 +81,15 @@ export default {
         },
         },
         *changeTab(action, { select, call, put }) {
         *changeTab(action, { select, call, put }) {
             const home = yield select(state => state.present.home);
             const home = yield select(state => state.present.home);
-            const { tabs } = home;
+            const { tabs, selectedTab } = home;
             const { tab } = action;
             const { tab } = action;
             let fields = [];
             let fields = [];
 
 
-            yield put({ type: 'setSelectedTab', tab });
             let fTab = tabs.find(t => t.code === tab.code);
             let fTab = tabs.find(t => t.code === tab.code);
-            if(!fTab) {
+            if(!fTab || (!!selectedTab && fTab.code === selectedTab.code && !!fTab.config)) {
                 return false;
                 return false;
             }else {
             }else {
+                yield put({ type: 'setSelectedTab', tab });
                 let data = { ...fTab.config };
                 let data = { ...fTab.config };
                 for(let key in data) {
                 for(let key in data) {
                     fields.push({
                     fields.push({
@@ -111,8 +111,9 @@ export default {
             }
             }
         },
         },
         *closeTabs(action, { select, call, put }) {
         *closeTabs(action, { select, call, put }) {
-            const { tabs } = action;
+            const { tabs, tab } = action;
 
 
+            yield put({ type: 'changeTab', tab });
             yield put({ type: 'removeTabs', tabs });
             yield put({ type: 'removeTabs', tabs });
         },
         },
         *closeAllTabs(action, { select, call, put }) {
         *closeAllTabs(action, { select, call, put }) {