diff --git a/spug_web/src/pages/system/account/Table.js b/spug_web/src/pages/system/account/Table.js index a7c7306..b40ef79 100644 --- a/spug_web/src/pages/system/account/Table.js +++ b/spug_web/src/pages/system/account/Table.js @@ -22,7 +22,12 @@ class ComTable extends React.Component { } componentDidMount() { - store.fetchRecords() + if (rStore.records.length === 0) { + rStore.fetchRecords() + .then(() => store.fetchRecords()) + } else { + store.fetchRecords() + } } columns = [{ diff --git a/spug_web/src/pages/system/account/index.js b/spug_web/src/pages/system/account/index.js index 695cd57..cadd12a 100644 --- a/spug_web/src/pages/system/account/index.js +++ b/spug_web/src/pages/system/account/index.js @@ -10,15 +10,8 @@ import { SearchForm, AuthDiv, Breadcrumb } from 'components'; import ComTable from './Table'; import ComForm from './Form'; import store from './store'; -import rStore from '../role/store'; export default observer(function () { - useEffect(() => { - if (rStore.records.length === 0) { - rStore.fetchRecords() - } - }, []) - return ( diff --git a/spug_web/src/pages/system/account/store.js b/spug_web/src/pages/system/account/store.js index 6a74e29..d2e8b31 100644 --- a/spug_web/src/pages/system/account/store.js +++ b/spug_web/src/pages/system/account/store.js @@ -9,7 +9,7 @@ import http from 'libs/http'; class Store { @observable records = []; @observable record = {}; - @observable isFetching = false; + @observable isFetching = true; @observable formVisible = false; @observable f_name; diff --git a/spug_web/src/pages/system/role/store.js b/spug_web/src/pages/system/role/store.js index 0f72eed..ad18ed6 100644 --- a/spug_web/src/pages/system/role/store.js +++ b/spug_web/src/pages/system/role/store.js @@ -43,7 +43,7 @@ class Store { fetchRecords = () => { this.isFetching = true; - http.get('/api/account/role/') + return http.get('/api/account/role/') .then(res => this.records = res) .finally(() => this.isFetching = false) };