Commit e822179b authored by Andreas Cederström's avatar Andreas Cederström Committed by 偏右

add dva-loading (#587)

parent 474c7468
import '@babel/polyfill'; import '@babel/polyfill';
import dva from 'dva'; import dva from 'dva';
import createHistory from 'history/createHashHistory';
import createLoading from 'dva-loading';
import 'moment/locale/zh-cn'; import 'moment/locale/zh-cn';
import FastClick from 'fastclick'; import FastClick from 'fastclick';
import './rollbar'; import './rollbar';
import onError from './error'; import onError from './error';
// import browserHistory from 'history/createBrowserHistory';
import './index.less'; import './index.less';
// 1. Initialize // 1. Initialize
const app = dva({ const app = dva({
// history: browserHistory(), history: createHistory(),
onError, onError,
}); });
// 2. Plugins // 2. Plugins
// app.use({}); app.use(createLoading());
// 3. Register global model // 3. Register global model
app.model(require('./models/global').default); app.model(require('./models/global').default);
......
...@@ -220,9 +220,9 @@ class BasicLayout extends React.PureComponent { ...@@ -220,9 +220,9 @@ class BasicLayout extends React.PureComponent {
} }
} }
export default connect(state => ({ export default connect(({ user, global, loading }) => ({
currentUser: state.user.currentUser, currentUser: user.currentUser,
collapsed: state.global.collapsed, collapsed: global.collapsed,
fetchingNotices: state.global.fetchingNotices, fetchingNotices: loading.effects['global/fetchNotices'],
notices: state.global.notices, notices: global.notices,
}))(BasicLayout); }))(BasicLayout);
...@@ -5,24 +5,15 @@ export default { ...@@ -5,24 +5,15 @@ export default {
state: { state: {
list: [], list: [],
loading: true,
}, },
effects: { effects: {
*fetchList(_, { call, put }) { *fetchList(_, { call, put }) {
yield put({
type: 'changeLoading',
payload: true,
});
const response = yield call(queryActivities); const response = yield call(queryActivities);
yield put({ yield put({
type: 'saveList', type: 'saveList',
payload: Array.isArray(response) ? response : [], payload: Array.isArray(response) ? response : [],
}); });
yield put({
type: 'changeLoading',
payload: false,
});
}, },
}, },
...@@ -33,11 +24,5 @@ export default { ...@@ -33,11 +24,5 @@ export default {
list: action.payload, list: action.payload,
}; };
}, },
changeLoading(state, action) {
return {
...state,
loading: action.payload,
};
},
}, },
}; };
...@@ -19,10 +19,6 @@ export default { ...@@ -19,10 +19,6 @@ export default {
effects: { effects: {
*fetch(_, { call, put }) { *fetch(_, { call, put }) {
yield put({
type: 'changeLoading',
payload: true,
});
const response = yield call(fakeChartData); const response = yield call(fakeChartData);
yield put({ yield put({
type: 'save', type: 'save',
...@@ -45,7 +41,6 @@ export default { ...@@ -45,7 +41,6 @@ export default {
return { return {
...state, ...state,
...payload, ...payload,
loading: false,
}; };
}, },
clear() { clear() {
...@@ -62,11 +57,5 @@ export default { ...@@ -62,11 +57,5 @@ export default {
radarData: [], radarData: [],
}; };
}, },
changeLoading(state, { payload }) {
return {
...state,
loading: payload,
};
},
}, },
}; };
...@@ -12,50 +12,23 @@ export default { ...@@ -12,50 +12,23 @@ export default {
receiverName: 'Alex', receiverName: 'Alex',
amount: '500', amount: '500',
}, },
regularFormSubmitting: false,
stepFormSubmitting: false,
advancedFormSubmitting: false,
}, },
effects: { effects: {
*submitRegularForm({ payload }, { call, put }) { *submitRegularForm({ payload }, { call }) {
yield put({
type: 'changeRegularFormSubmitting',
payload: true,
});
yield call(fakeSubmitForm, payload); yield call(fakeSubmitForm, payload);
yield put({
type: 'changeRegularFormSubmitting',
payload: false,
});
message.success('提交成功'); message.success('提交成功');
}, },
*submitStepForm({ payload }, { call, put }) { *submitStepForm({ payload }, { call, put }) {
yield put({
type: 'changeStepFormSubmitting',
payload: true,
});
yield call(fakeSubmitForm, payload); yield call(fakeSubmitForm, payload);
yield put({ yield put({
type: 'saveStepFormData', type: 'saveStepFormData',
payload, payload,
}); });
yield put({
type: 'changeStepFormSubmitting',
payload: false,
});
yield put(routerRedux.push('/form/step-form/result')); yield put(routerRedux.push('/form/step-form/result'));
}, },
*submitAdvancedForm({ payload }, { call, put }) { *submitAdvancedForm({ payload }, { call }) {
yield put({
type: 'changeAdvancedFormSubmitting',
payload: true,
});
yield call(fakeSubmitForm, payload); yield call(fakeSubmitForm, payload);
yield put({
type: 'changeAdvancedFormSubmitting',
payload: false,
});
message.success('提交成功'); message.success('提交成功');
}, },
}, },
...@@ -70,23 +43,5 @@ export default { ...@@ -70,23 +43,5 @@ export default {
}, },
}; };
}, },
changeRegularFormSubmitting(state, { payload }) {
return {
...state,
regularFormSubmitting: payload,
};
},
changeStepFormSubmitting(state, { payload }) {
return {
...state,
stepFormSubmitting: payload,
};
},
changeAdvancedFormSubmitting(state, { payload }) {
return {
...state,
advancedFormSubmitting: payload,
};
},
}, },
}; };
...@@ -6,15 +6,10 @@ export default { ...@@ -6,15 +6,10 @@ export default {
state: { state: {
collapsed: false, collapsed: false,
notices: [], notices: [],
fetchingNotices: false,
}, },
effects: { effects: {
*fetchNotices(_, { call, put }) { *fetchNotices(_, { call, put }) {
yield put({
type: 'changeNoticeLoading',
payload: true,
});
const data = yield call(queryNotices); const data = yield call(queryNotices);
yield put({ yield put({
type: 'saveNotices', type: 'saveNotices',
...@@ -49,7 +44,6 @@ export default { ...@@ -49,7 +44,6 @@ export default {
return { return {
...state, ...state,
notices: payload, notices: payload,
fetchingNotices: false,
}; };
}, },
saveClearedNotices(state, { payload }) { saveClearedNotices(state, { payload }) {
...@@ -58,12 +52,6 @@ export default { ...@@ -58,12 +52,6 @@ export default {
notices: state.notices.filter(item => item.type !== payload), notices: state.notices.filter(item => item.type !== payload),
}; };
}, },
changeNoticeLoading(state, { payload }) {
return {
...state,
fetchingNotices: payload,
};
},
}, },
subscriptions: { subscriptions: {
......
...@@ -5,39 +5,22 @@ export default { ...@@ -5,39 +5,22 @@ export default {
state: { state: {
list: [], list: [],
loading: false,
}, },
effects: { effects: {
*fetch({ payload }, { call, put }) { *fetch({ payload }, { call, put }) {
yield put({
type: 'changeLoading',
payload: true,
});
const response = yield call(queryFakeList, payload); const response = yield call(queryFakeList, payload);
yield put({ yield put({
type: 'queryList', type: 'queryList',
payload: Array.isArray(response) ? response : [], payload: Array.isArray(response) ? response : [],
}); });
yield put({
type: 'changeLoading',
payload: false,
});
}, },
*appendFetch({ payload }, { call, put }) { *appendFetch({ payload }, { call, put }) {
yield put({
type: 'changeLoading',
payload: true,
});
const response = yield call(queryFakeList, payload); const response = yield call(queryFakeList, payload);
yield put({ yield put({
type: 'appendList', type: 'appendList',
payload: Array.isArray(response) ? response : [], payload: Array.isArray(response) ? response : [],
}); });
yield put({
type: 'changeLoading',
payload: false,
});
}, },
}, },
...@@ -54,11 +37,5 @@ export default { ...@@ -54,11 +37,5 @@ export default {
list: state.list.concat(action.payload), list: state.list.concat(action.payload),
}; };
}, },
changeLoading(state, action) {
return {
...state,
loading: action.payload,
};
},
}, },
}; };
...@@ -10,10 +10,6 @@ export default { ...@@ -10,10 +10,6 @@ export default {
effects: { effects: {
*login({ payload }, { call, put }) { *login({ payload }, { call, put }) {
yield put({
type: 'changeSubmitting',
payload: true,
});
const response = yield call(fakeAccountLogin, payload); const response = yield call(fakeAccountLogin, payload);
yield put({ yield put({
type: 'changeLoginStatus', type: 'changeLoginStatus',
...@@ -50,13 +46,6 @@ export default { ...@@ -50,13 +46,6 @@ export default {
...state, ...state,
status: payload.status, status: payload.status,
type: payload.type, type: payload.type,
submitting: false,
};
},
changeSubmitting(state, { payload }) {
return {
...state,
submitting: payload,
}; };
}, },
}, },
......
...@@ -5,43 +5,25 @@ export default { ...@@ -5,43 +5,25 @@ export default {
state: { state: {
basicGoods: [], basicGoods: [],
basicLoading: true,
advancedOperation1: [], advancedOperation1: [],
advancedOperation2: [], advancedOperation2: [],
advancedOperation3: [], advancedOperation3: [],
advancedLoading: true,
}, },
effects: { effects: {
*fetchBasic(_, { call, put }) { *fetchBasic(_, { call, put }) {
yield put({
type: 'changeLoading',
payload: { basicLoading: true },
});
const response = yield call(queryBasicProfile); const response = yield call(queryBasicProfile);
yield put({ yield put({
type: 'show', type: 'show',
payload: response, payload: response,
}); });
yield put({
type: 'changeLoading',
payload: { basicLoading: false },
});
}, },
*fetchAdvanced(_, { call, put }) { *fetchAdvanced(_, { call, put }) {
yield put({
type: 'changeLoading',
payload: { advancedLoading: true },
});
const response = yield call(queryAdvancedProfile); const response = yield call(queryAdvancedProfile);
yield put({ yield put({
type: 'show', type: 'show',
payload: response, payload: response,
}); });
yield put({
type: 'changeLoading',
payload: { advancedLoading: false },
});
}, },
}, },
...@@ -52,11 +34,5 @@ export default { ...@@ -52,11 +34,5 @@ export default {
...payload, ...payload,
}; };
}, },
changeLoading(state, { payload }) {
return {
...state,
...payload,
};
},
}, },
}; };
...@@ -5,24 +5,15 @@ export default { ...@@ -5,24 +5,15 @@ export default {
state: { state: {
notice: [], notice: [],
loading: true,
}, },
effects: { effects: {
*fetchNotice(_, { call, put }) { *fetchNotice(_, { call, put }) {
yield put({
type: 'changeLoading',
payload: true,
});
const response = yield call(queryProjectNotice); const response = yield call(queryProjectNotice);
yield put({ yield put({
type: 'saveNotice', type: 'saveNotice',
payload: Array.isArray(response) ? response : [], payload: Array.isArray(response) ? response : [],
}); });
yield put({
type: 'changeLoading',
payload: false,
});
}, },
}, },
...@@ -33,11 +24,5 @@ export default { ...@@ -33,11 +24,5 @@ export default {
notice: action.payload, notice: action.payload,
}; };
}, },
changeLoading(state, action) {
return {
...state,
loading: action.payload,
};
},
}, },
}; };
...@@ -9,19 +9,11 @@ export default { ...@@ -9,19 +9,11 @@ export default {
effects: { effects: {
*submit(_, { call, put }) { *submit(_, { call, put }) {
yield put({
type: 'changeSubmitting',
payload: true,
});
const response = yield call(fakeRegister); const response = yield call(fakeRegister);
yield put({ yield put({
type: 'registerHandle', type: 'registerHandle',
payload: response, payload: response,
}); });
yield put({
type: 'changeSubmitting',
payload: false,
});
}, },
}, },
...@@ -32,11 +24,5 @@ export default { ...@@ -32,11 +24,5 @@ export default {
status: payload.status, status: payload.status,
}; };
}, },
changeSubmitting(state, { payload }) {
return {
...state,
submitting: payload,
};
},
}, },
}; };
...@@ -8,57 +8,30 @@ export default { ...@@ -8,57 +8,30 @@ export default {
list: [], list: [],
pagination: {}, pagination: {},
}, },
loading: true,
}, },
effects: { effects: {
*fetch({ payload }, { call, put }) { *fetch({ payload }, { call, put }) {
yield put({
type: 'changeLoading',
payload: true,
});
const response = yield call(queryRule, payload); const response = yield call(queryRule, payload);
yield put({ yield put({
type: 'save', type: 'save',
payload: response, payload: response,
}); });
yield put({
type: 'changeLoading',
payload: false,
});
}, },
*add({ payload, callback }, { call, put }) { *add({ payload, callback }, { call, put }) {
yield put({
type: 'changeLoading',
payload: true,
});
const response = yield call(addRule, payload); const response = yield call(addRule, payload);
yield put({ yield put({
type: 'save', type: 'save',
payload: response, payload: response,
}); });
yield put({
type: 'changeLoading',
payload: false,
});
if (callback) callback(); if (callback) callback();
}, },
*remove({ payload, callback }, { call, put }) { *remove({ payload, callback }, { call, put }) {
yield put({
type: 'changeLoading',
payload: true,
});
const response = yield call(removeRule, payload); const response = yield call(removeRule, payload);
yield put({ yield put({
type: 'save', type: 'save',
payload: response, payload: response,
}); });
yield put({
type: 'changeLoading',
payload: false,
});
if (callback) callback(); if (callback) callback();
}, },
}, },
...@@ -70,11 +43,5 @@ export default { ...@@ -70,11 +43,5 @@ export default {
data: action.payload, data: action.payload,
}; };
}, },
changeLoading(state, action) {
return {
...state,
loading: action.payload,
};
},
}, },
}; };
...@@ -5,25 +5,16 @@ export default { ...@@ -5,25 +5,16 @@ export default {
state: { state: {
list: [], list: [],
loading: false,
currentUser: {}, currentUser: {},
}, },
effects: { effects: {
*fetch(_, { call, put }) { *fetch(_, { call, put }) {
yield put({
type: 'changeLoading',
payload: true,
});
const response = yield call(queryUsers); const response = yield call(queryUsers);
yield put({ yield put({
type: 'save', type: 'save',
payload: response, payload: response,
}); });
yield put({
type: 'changeLoading',
payload: false,
});
}, },
*fetchCurrent(_, { call, put }) { *fetchCurrent(_, { call, put }) {
const response = yield call(queryCurrent); const response = yield call(queryCurrent);
...@@ -41,12 +32,6 @@ export default { ...@@ -41,12 +32,6 @@ export default {
list: action.payload, list: action.payload,
}; };
}, },
changeLoading(state, action) {
return {
...state,
loading: action.payload,
};
},
saveCurrentUser(state, action) { saveCurrentUser(state, action) {
return { return {
...state, ...state,
......
...@@ -37,7 +37,7 @@ class Dashboard extends PureComponent { ...@@ -37,7 +37,7 @@ class Dashboard extends PureComponent {
}); });
} }
render() { render() {
const { user: { list, loading } } = this.props; const { user: { list }, loading } = this.props;
return ( return (
<div> <div>
<Row gutter={24}> <Row gutter={24}>
...@@ -95,6 +95,7 @@ class Dashboard extends PureComponent { ...@@ -95,6 +95,7 @@ class Dashboard extends PureComponent {
} }
} }
export default connect(state => ({ export default connect(({ user, loading }) => ({
user: state.user, user,
loading: loading.effects['user/fetch'],
}))(Dashboard); }))(Dashboard);
...@@ -42,8 +42,9 @@ for (let i = 0; i < 7; i += 1) { ...@@ -42,8 +42,9 @@ for (let i = 0; i < 7; i += 1) {
}); });
} }
@connect(state => ({ @connect(({ chart, loading }) => ({
chart: state.chart, chart,
loading: loading.effects['chart/fetch'],
})) }))
export default class Analysis extends Component { export default class Analysis extends Component {
state = { state = {
...@@ -113,7 +114,7 @@ export default class Analysis extends Component { ...@@ -113,7 +114,7 @@ export default class Analysis extends Component {
render() { render() {
const { rangePickerValue, salesType, currentTabKey } = this.state; const { rangePickerValue, salesType, currentTabKey } = this.state;
const { chart } = this.props; const { chart, loading } = this.props;
const { const {
visitData, visitData,
visitData2, visitData2,
...@@ -124,7 +125,6 @@ export default class Analysis extends Component { ...@@ -124,7 +125,6 @@ export default class Analysis extends Component {
salesTypeData, salesTypeData,
salesTypeDataOnline, salesTypeDataOnline,
salesTypeDataOffline, salesTypeDataOffline,
loading,
} = chart; } = chart;
const salesPieData = const salesPieData =
......
...@@ -14,8 +14,9 @@ const { Secured } = Authorized; ...@@ -14,8 +14,9 @@ const { Secured } = Authorized;
const targetTime = new Date().getTime() + 3900000; const targetTime = new Date().getTime() + 3900000;
@Secured('admin') @Secured('admin')
@connect(state => ({ @connect(({ monitor, loading }) => ({
monitor: state.monitor, monitor,
loading: loading.models.monitor,
})) }))
export default class Monitor extends PureComponent { export default class Monitor extends PureComponent {
componentDidMount() { componentDidMount() {
...@@ -25,7 +26,7 @@ export default class Monitor extends PureComponent { ...@@ -25,7 +26,7 @@ export default class Monitor extends PureComponent {
} }
render() { render() {
const { monitor } = this.props; const { monitor, loading } = this.props;
const { tags } = monitor; const { tags } = monitor;
return ( return (
...@@ -142,7 +143,7 @@ export default class Monitor extends PureComponent { ...@@ -142,7 +143,7 @@ export default class Monitor extends PureComponent {
</Card> </Card>
</Col> </Col>
<Col xl={6} lg={12} sm={24} xs={24} style={{ marginBottom: 24 }}> <Col xl={6} lg={12} sm={24} xs={24} style={{ marginBottom: 24 }}>
<Card title="热门搜索" bordered={false} bodyStyle={{ overflow: 'hidden' }}> <Card title="热门搜索" loading={loading} bordered={false} bodyStyle={{ overflow: 'hidden' }}>
<TagCloud <TagCloud
data={tags} data={tags}
height={161} height={161}
......
...@@ -70,10 +70,12 @@ const members = [ ...@@ -70,10 +70,12 @@ const members = [
}, },
]; ];
@connect(state => ({ @connect(({ project, activities, chart, loading }) => ({
project: state.project, project,
activities: state.activities, activities,
chart: state.chart, chart,
projectLoading: loading.effects['project/fetchNotice'],
activitiesLoading: loading.effects['activities/fetchList'],
})) }))
export default class Workplace extends PureComponent { export default class Workplace extends PureComponent {
componentDidMount() { componentDidMount() {
...@@ -131,8 +133,9 @@ export default class Workplace extends PureComponent { ...@@ -131,8 +133,9 @@ export default class Workplace extends PureComponent {
render() { render() {
const { const {
project: { loading: projectLoading, notice }, project: { notice },
activities: { loading: activitiesLoading }, projectLoading,
activitiesLoading,
chart: { radarData }, chart: { radarData },
} = this.props; } = this.props;
......
...@@ -284,7 +284,7 @@ class AdvancedForm extends PureComponent { ...@@ -284,7 +284,7 @@ class AdvancedForm extends PureComponent {
} }
} }
export default connect(state => ({ export default connect(({ global, loading }) => ({
collapsed: state.global.collapsed, collapsed: global.collapsed,
submitting: state.form.advancedFormSubmitting, submitting: loading.effects['form/submitAdvancedForm'],
}))(Form.create()(AdvancedForm)); }))(Form.create()(AdvancedForm));
...@@ -11,8 +11,8 @@ const { Option } = Select; ...@@ -11,8 +11,8 @@ const { Option } = Select;
const { RangePicker } = DatePicker; const { RangePicker } = DatePicker;
const { TextArea } = Input; const { TextArea } = Input;
@connect(state => ({ @connect(({ loading }) => ({
submitting: state.form.regularFormSubmitting, submitting: loading.effects['form/submitRegularForm'],
})) }))
@Form.create() @Form.create()
export default class BasicForms extends PureComponent { export default class BasicForms extends PureComponent {
......
...@@ -108,7 +108,7 @@ class Step2 extends React.PureComponent { ...@@ -108,7 +108,7 @@ class Step2 extends React.PureComponent {
} }
} }
export default connect(({ form }) => ({ export default connect(({ form, loading }) => ({
submitting: form.stepFormSubmitting, submitting: loading.effects['form/submitStepForm'],
data: form.step, data: form.step,
}))(Step2); }))(Step2);
...@@ -25,8 +25,9 @@ const formatWan = (val) => { ...@@ -25,8 +25,9 @@ const formatWan = (val) => {
/* eslint react/no-array-index-key: 0 */ /* eslint react/no-array-index-key: 0 */
@Form.create() @Form.create()
@connect(state => ({ @connect(({ list, loading }) => ({
list: state.list, list,
loading: loading.models.list,
})) }))
export default class FilterCardList extends PureComponent { export default class FilterCardList extends PureComponent {
componentDidMount() { componentDidMount() {
...@@ -57,7 +58,7 @@ export default class FilterCardList extends PureComponent { ...@@ -57,7 +58,7 @@ export default class FilterCardList extends PureComponent {
} }
render() { render() {
const { list: { list, loading }, form } = this.props; const { list: { list }, loading, form } = this.props;
const { getFieldDecorator } = form; const { getFieldDecorator } = form;
const CardInfo = ({ activeUser, newUser }) => ( const CardInfo = ({ activeUser, newUser }) => (
......
...@@ -13,8 +13,9 @@ const FormItem = Form.Item; ...@@ -13,8 +13,9 @@ const FormItem = Form.Item;
const pageSize = 5; const pageSize = 5;
@Form.create() @Form.create()
@connect(state => ({ @connect(({ list, loading }) => ({
list: state.list, list,
loading: loading.models.list,
})) }))
export default class SearchList extends Component { export default class SearchList extends Component {
componentDidMount() { componentDidMount() {
...@@ -38,7 +39,7 @@ export default class SearchList extends Component { ...@@ -38,7 +39,7 @@ export default class SearchList extends Component {
} }
render() { render() {
const { form, list: { list, loading } } = this.props; const { form, list: { list }, loading } = this.props;
const { getFieldDecorator } = form; const { getFieldDecorator } = form;
const owners = [ const owners = [
......
...@@ -11,8 +11,9 @@ const RadioButton = Radio.Button; ...@@ -11,8 +11,9 @@ const RadioButton = Radio.Button;
const RadioGroup = Radio.Group; const RadioGroup = Radio.Group;
const { Search } = Input; const { Search } = Input;
@connect(state => ({ @connect(({ list, loading }) => ({
list: state.list, list,
loading: loading.models.list,
})) }))
export default class BasicList extends PureComponent { export default class BasicList extends PureComponent {
componentDidMount() { componentDidMount() {
...@@ -25,7 +26,7 @@ export default class BasicList extends PureComponent { ...@@ -25,7 +26,7 @@ export default class BasicList extends PureComponent {
} }
render() { render() {
const { list: { list, loading } } = this.props; const { list: { list }, loading } = this.props;
const Info = ({ title, value, bordered }) => ( const Info = ({ title, value, bordered }) => (
<div className={styles.headerInfo}> <div className={styles.headerInfo}>
......
...@@ -7,8 +7,9 @@ import Ellipsis from '../../components/Ellipsis'; ...@@ -7,8 +7,9 @@ import Ellipsis from '../../components/Ellipsis';
import styles from './CardList.less'; import styles from './CardList.less';
@connect(state => ({ @connect(({ list, loading }) => ({
list: state.list, list,
loading: loading.models.list,
})) }))
export default class CardList extends PureComponent { export default class CardList extends PureComponent {
componentDidMount() { componentDidMount() {
...@@ -21,7 +22,7 @@ export default class CardList extends PureComponent { ...@@ -21,7 +22,7 @@ export default class CardList extends PureComponent {
} }
render() { render() {
const { list: { list, loading } } = this.props; const { list: { list }, loading } = this.props;
const content = ( const content = (
<div className={styles.pageHeaderContent}> <div className={styles.pageHeaderContent}>
......
...@@ -14,8 +14,9 @@ const FormItem = Form.Item; ...@@ -14,8 +14,9 @@ const FormItem = Form.Item;
/* eslint react/no-array-index-key: 0 */ /* eslint react/no-array-index-key: 0 */
@Form.create() @Form.create()
@connect(state => ({ @connect(({ list, loading }) => ({
list: state.list, list,
loading: loading.models.list,
})) }))
export default class CoverCardList extends PureComponent { export default class CoverCardList extends PureComponent {
componentDidMount() { componentDidMount() {
...@@ -46,7 +47,7 @@ export default class CoverCardList extends PureComponent { ...@@ -46,7 +47,7 @@ export default class CoverCardList extends PureComponent {
} }
render() { render() {
const { list: { list = [], loading }, form } = this.props; const { list: { list = [] }, loading, form } = this.props;
const { getFieldDecorator } = form; const { getFieldDecorator } = form;
const cardList = list ? ( const cardList = list ? (
......
...@@ -10,8 +10,9 @@ const FormItem = Form.Item; ...@@ -10,8 +10,9 @@ const FormItem = Form.Item;
const { Option } = Select; const { Option } = Select;
const getValue = obj => Object.keys(obj).map(key => obj[key]).join(','); const getValue = obj => Object.keys(obj).map(key => obj[key]).join(',');
@connect(state => ({ @connect(({ rule, loading }) => ({
rule: state.rule, rule,
loading: loading.models.rule,
})) }))
@Form.create() @Form.create()
export default class TableList extends PureComponent { export default class TableList extends PureComponent {
...@@ -268,7 +269,7 @@ export default class TableList extends PureComponent { ...@@ -268,7 +269,7 @@ export default class TableList extends PureComponent {
} }
render() { render() {
const { rule: { loading: ruleLoading, data } } = this.props; const { rule: { data }, loading } = this.props;
const { selectedRows, modalVisible, addInputValue } = this.state; const { selectedRows, modalVisible, addInputValue } = this.state;
const menu = ( const menu = (
...@@ -304,7 +305,7 @@ export default class TableList extends PureComponent { ...@@ -304,7 +305,7 @@ export default class TableList extends PureComponent {
</div> </div>
<StandardTable <StandardTable
selectedRows={selectedRows} selectedRows={selectedRows}
loading={ruleLoading} loading={loading}
data={data} data={data}
onSelectRow={this.handleSelectRows} onSelectRow={this.handleSelectRows}
onChange={this.handleStandardTableChange} onChange={this.handleStandardTableChange}
......
...@@ -139,8 +139,9 @@ const columns = [{ ...@@ -139,8 +139,9 @@ const columns = [{
key: 'memo', key: 'memo',
}]; }];
@connect(state => ({ @connect(({ profile, loading }) => ({
profile: state.profile, profile,
loading: loading.effects['profile/fetchAdvanced'],
})) }))
export default class AdvancedProfile extends Component { export default class AdvancedProfile extends Component {
state = { state = {
...@@ -185,24 +186,24 @@ export default class AdvancedProfile extends Component { ...@@ -185,24 +186,24 @@ export default class AdvancedProfile extends Component {
render() { render() {
const { stepDirection } = this.state; const { stepDirection } = this.state;
const { profile } = this.props; const { profile, loading } = this.props;
const { advancedLoading, advancedOperation1, advancedOperation2, advancedOperation3 } = profile; const { advancedOperation1, advancedOperation2, advancedOperation3 } = profile;
const contentList = { const contentList = {
tab1: <Table tab1: <Table
pagination={false} pagination={false}
loading={advancedLoading} loading={loading}
dataSource={advancedOperation1} dataSource={advancedOperation1}
columns={columns} columns={columns}
/>, />,
tab2: <Table tab2: <Table
pagination={false} pagination={false}
loading={advancedLoading} loading={loading}
dataSource={advancedOperation2} dataSource={advancedOperation2}
columns={columns} columns={columns}
/>, />,
tab3: <Table tab3: <Table
pagination={false} pagination={false}
loading={advancedLoading} loading={loading}
dataSource={advancedOperation3} dataSource={advancedOperation3}
columns={columns} columns={columns}
/>, />,
......
...@@ -32,8 +32,9 @@ const progressColumns = [{ ...@@ -32,8 +32,9 @@ const progressColumns = [{
key: 'cost', key: 'cost',
}]; }];
@connect(state => ({ @connect(({ profile, loading }) => ({
profile: state.profile, profile,
loading: loading.effects['profile/fetchBasic'],
})) }))
export default class BasicProfile extends Component { export default class BasicProfile extends Component {
componentDidMount() { componentDidMount() {
...@@ -44,8 +45,8 @@ export default class BasicProfile extends Component { ...@@ -44,8 +45,8 @@ export default class BasicProfile extends Component {
} }
render() { render() {
const { profile } = this.props; const { profile, loading } = this.props;
const { basicGoods, basicProgress, basicLoading } = profile; const { basicGoods, basicProgress } = profile;
let goodsData = []; let goodsData = [];
if (basicGoods.length) { if (basicGoods.length) {
let num = 0; let num = 0;
...@@ -146,7 +147,7 @@ export default class BasicProfile extends Component { ...@@ -146,7 +147,7 @@ export default class BasicProfile extends Component {
<Table <Table
style={{ marginBottom: 24 }} style={{ marginBottom: 24 }}
pagination={false} pagination={false}
loading={basicLoading} loading={loading}
dataSource={goodsData} dataSource={goodsData}
columns={goodsColumns} columns={goodsColumns}
rowKey="id" rowKey="id"
...@@ -155,7 +156,7 @@ export default class BasicProfile extends Component { ...@@ -155,7 +156,7 @@ export default class BasicProfile extends Component {
<Table <Table
style={{ marginBottom: 16 }} style={{ marginBottom: 16 }}
pagination={false} pagination={false}
loading={basicLoading} loading={loading}
dataSource={basicProgress} dataSource={basicProgress}
columns={progressColumns} columns={progressColumns}
/> />
......
...@@ -7,8 +7,9 @@ import styles from './Login.less'; ...@@ -7,8 +7,9 @@ import styles from './Login.less';
const { Tab, UserName, Password, Mobile, Captcha, Submit } = Login; const { Tab, UserName, Password, Mobile, Captcha, Submit } = Login;
@connect(state => ({ @connect(({ login, loading }) => ({
login: state.login, login,
submitting: loading.effects['login/login'],
})) }))
export default class LoginPage extends Component { export default class LoginPage extends Component {
state = { state = {
...@@ -46,7 +47,7 @@ export default class LoginPage extends Component { ...@@ -46,7 +47,7 @@ export default class LoginPage extends Component {
} }
render() { render() {
const { login } = this.props; const { login, submitting } = this.props;
const { type } = this.state; const { type } = this.state;
return ( return (
<div className={styles.main}> <div className={styles.main}>
...@@ -79,7 +80,7 @@ export default class LoginPage extends Component { ...@@ -79,7 +80,7 @@ export default class LoginPage extends Component {
<Checkbox checked={this.state.autoLogin} onChange={this.changeAutoLogin}>自动登录</Checkbox> <Checkbox checked={this.state.autoLogin} onChange={this.changeAutoLogin}>自动登录</Checkbox>
<a style={{ float: 'right' }} href="">忘记密码</a> <a style={{ float: 'right' }} href="">忘记密码</a>
</div> </div>
<Submit loading={login.submitting}>登录</Submit> <Submit loading={submitting}>登录</Submit>
<div className={styles.other}> <div className={styles.other}>
其他登录方式 其他登录方式
<Icon className={styles.icon} type="alipay-circle" /> <Icon className={styles.icon} type="alipay-circle" />
......
...@@ -20,8 +20,9 @@ const passwordProgressMap = { ...@@ -20,8 +20,9 @@ const passwordProgressMap = {
pool: 'exception', pool: 'exception',
}; };
@connect(state => ({ @connect(({ register, loading }) => ({
register: state.register, register,
submitting: loading.effects['register/submit'],
})) }))
@Form.create() @Form.create()
export default class Register extends Component { export default class Register extends Component {
...@@ -148,7 +149,7 @@ export default class Register extends Component { ...@@ -148,7 +149,7 @@ export default class Register extends Component {
}; };
render() { render() {
const { form, register } = this.props; const { form, submitting } = this.props;
const { getFieldDecorator } = form; const { getFieldDecorator } = form;
const { count, prefix } = this.state; const { count, prefix } = this.state;
return ( return (
...@@ -270,7 +271,7 @@ export default class Register extends Component { ...@@ -270,7 +271,7 @@ export default class Register extends Component {
<FormItem> <FormItem>
<Button <Button
size="large" size="large"
loading={register.submitting} loading={submitting}
className={styles.submit} className={styles.submit}
type="primary" type="primary"
htmlType="submit" htmlType="submit"
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment