From 4ba9e116740d2c018f6bad72020f361f6c8b23b2 Mon Sep 17 00:00:00 2001 From: vapao Date: Thu, 27 Oct 2022 09:46:46 +0800 Subject: [PATCH] =?UTF-8?q?F=20=E4=BF=AE=E5=A4=8D=E8=B4=A6=E6=88=B7?= =?UTF-8?q?=E6=89=80=E5=B1=9E=E8=A7=92=E8=89=B2=E6=9F=90=E4=BA=9B=E6=83=85?= =?UTF-8?q?=E5=86=B5=E4=B8=8B=E6=9C=AA=E6=AD=A3=E7=A1=AE=E5=B1=95=E7=A4=BA?= =?UTF-8?q?=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- spug_web/src/pages/system/account/Table.js | 7 ++++++- spug_web/src/pages/system/account/index.js | 7 ------- spug_web/src/pages/system/account/store.js | 2 +- spug_web/src/pages/system/role/store.js | 2 +- 4 files changed, 8 insertions(+), 10 deletions(-) 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) };