| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455 |
- import { queryRule, removeRule, addRule, updateRule } 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();
- },
- *update({ payload, callback }, { call, put }) {
- const response = yield call(updateRule, payload);
- yield put({
- type: 'save',
- payload: response,
- });
- if (callback) callback();
- },
- },
- reducers: {
- save(state, action) {
- return {
- ...state,
- data: action.payload,
- };
- },
- },
- };
|