userSetCenterApi.js 1.1 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
// import config from '@/webPublic/one_stop_public/config';
import { apiRequest } from '../utils/request';

const api = '/UserSetCenterApi';
const Search = {
  namespace: 'UserSetCenterApi',
  state: {
    result: [], // 初始请求,默认条件为全选
    options: {}, // 初始化请求条件
  },
  effects: {
    // 新增或则修改1
    *addOrUpdate({ payload, callback }, { call, put }) {
      const response = yield call(apiRequest, `${api}/addOrUpdate`, payload);
      if (response == null) {
        yield put({ type: 'nom' });
        return;
      }

      yield put({
        type: 'nom',
        payload: response,
      });
      if (callback) callback(response);
    },
    // 查询
    *queryUserSet({ payload, callback }, { call, put }) {
      const response = yield call(apiRequest, `${api}/queryUserSet`, payload);
      if (response == null) {
        yield put({ type: 'nom' });
        return;
      }

      yield put({
        type: 'nom',
        payload: response,
      });
      if (callback) callback(response);
    },
  },
  reducers: {
    nom(state, action) {
      return { ...state };
    },
  },
};
export default Search;