123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103 |
- import { message } from 'antd';
- import { routerRedux } from 'dva/router';
- import {
- queryTagTypeList,
- queryTagTypeItem,
- createTagTypeItem,
- updateTagTypeItem,
- deleteTagTypeItem,
- } from '../services/tagType';
- export default {
- namespace: 'tagType',
- state: {
- list: [],
- pageNo: 1,
- pageSize: 15,
- totalSize: 0,
- currentItem: {},
- },
- effects: {
- *fetchTagTypeList({ payload }, { call, put }) {
- const response = yield call(queryTagTypeList, payload);
- if (response.success) {
- yield put({
- type: 'querySuccess',
- payload: {
- list: response.data.list || [],
- pageSize: response.data.pageSize,
- totalSize: response.data.totalSize,
- pageNo: response.data.pageNo,
- },
- });
- }
- },
- *fetchTagTypeItem({ payload }, { call, put }) {
- const response = yield call(queryTagTypeItem, payload);
- if (response.success) {
- yield put({
- type: 'querySuccess',
- payload: {
- currentItem: response.data || {},
- },
- });
- }
- },
- *createTagTypeItem({ payload, state }, { call, put }) {
- const response = yield call(createTagTypeItem, payload);
- if (response.success) {
- message.success('创建标签类型成功');
- yield put(routerRedux.push({
- state,
- pathname: '/frontend/tagType',
- }));
- }
- },
- *deleteTagTypeItem({ payload, states }, { call, put }) {
- const response = yield call(deleteTagTypeItem, payload);
- if (response.success) {
- message.success('删除标签类型成功');
- yield put({
- type: 'fetchTagTypeList',
- payload: states.Queryers,
- });
- }
- },
- *updateTagTypeItem({ payload, states }, { call, put }) {
- const response = yield call(updateTagTypeItem, payload);
- if (response.success) {
- message.success('修改标签类型成功');
- yield put(routerRedux.push({
- pathname: '/frontend/tagType',
- state: states,
- }));
- }
- },
- },
- reducers: {
- querySuccess(state, action) {
- return {
- ...state,
- ...action.payload,
- };
- },
- fixCurrentItem(state, action) {
- return {
- ...state,
- currentItem: {
- ...state.currentItem,
- ...action.payload,
- },
- };
- },
- cleanItemState(state) {
- return {
- ...state,
- currentItem: {},
- };
- },
- },
- };
|