model.js 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. import consts from '@/consts'
  2. import { queryCompilationListV2 } from '@/services/product'
  3. export default {
  4. namespace: 'road',
  5. state: {
  6. compilationv2: {} // 个人
  7. },
  8. // 用于处理异步操作和业务逻辑,由action触发,但不能修改state
  9. effects: {
  10. *fetchCompilationv2({ payload }, { call, put }) {
  11. const response = yield call(queryCompilationListV2, payload)
  12. if (response && response.code === consts.RET_CODE.SUCCESS) {
  13. yield put({
  14. type: 'changeCompilationStatev2',
  15. payload: {
  16. key: payload?.projectType,
  17. data: response.data
  18. }
  19. })
  20. }
  21. }
  22. },
  23. // reducers:用于处理同步操作,由action触发,可修改state
  24. reducers: {
  25. // 通用reducer
  26. changeCompilationStatev2(state, action) {
  27. return {
  28. ...state,
  29. compilationv2: { ...state.compilationv2, [action.payload.key]: action.payload.data }
  30. }
  31. }
  32. }
  33. // reducers: {
  34. // changeCompilationState(state, action) {
  35. // return {
  36. // ...state,
  37. // compilation: { ...state.compilation, [action.payload.key]: action.payload.data }
  38. // }
  39. // }
  40. // }
  41. }