123456789101112131415161718192021222324252627282930313233343536373839404142434445464748 |
- import { queryRule, removeRule, addRule } from '../services/api';
-
- export default {
- namespace: 'rule',
-
- state: {
- data: {
- list: [],
- pagination: {},
- },
- },
-
- effects: {
- *fetch({ payload }, { call, put }) {
- const response = yield call(queryRule, payload);
- yield put({
- type: 'save',
- payload: response,
- });
- },
- *add({ payload, callback }, { call, put }) {
- const response = yield call(addRule, payload);
- yield put({
- type: 'save',
- payload: response,
- });
- if (callback) callback();
- },
- *remove({ payload, callback }, { call, put }) {
- const response = yield call(removeRule, payload);
- yield put({
- type: 'save',
- payload: response,
- });
- if (callback) callback();
- },
- },
-
- reducers: {
- save(state, action) {
- return {
- ...state,
- data: action.payload,
- };
- },
- },
- };
|