12345678910111213141516171819202122232425262728293031323334353637383940 |
- import { query } from '../services/product';
- import modelExtend from 'dva-model-extend';
- import queryString from 'query-string';
- import { pageModel } from './common';
- import { pageSize } from '../utils/config';
- import { checkSearchParams } from '../utils/utils';
- import { Codes } from '../utils/config';
- export default modelExtend(pageModel, {
- namespace: 'product',
- state: { listLoading: false },
- effects: {
- * query ({ payload = {} }, { call, put }) {
- yield put({ type: 'changeLoading', payload: { listLoading: true }});
- const { data, success } = yield call(query, payload);
- if (success) {
- yield put({
- type: 'querySuccess',
- payload: {
- list: data.list,
- pagination: {
- current: Number(payload.pageNo) || 1,
- pageSize: Number(payload.pageSize) || pageSize,
- total: data.totalSize,
- }
- }
- });
- }
- yield put({ type: 'changeLoading', payload: { listLoading: false }});
- },
- },
- reducers: {
- changeLoading(state, action) {
- return { ...state, ...action.payload };
- },
- }
- })
|