common.js 726 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. import modelExtend from 'dva-model-extend';
  2. const model = {
  3. reducers: {
  4. updateState (state, { payload }) {
  5. return {
  6. ...state,
  7. ...payload,
  8. }
  9. },
  10. },
  11. }
  12. const pageModel = modelExtend(model, {
  13. state: {
  14. list: [],
  15. pagination: {
  16. showSizeChanger: true,
  17. showQuickJumper: true,
  18. showTotal: total => `共 ${total} 条`,
  19. current: 1,
  20. total: 0,
  21. },
  22. },
  23. reducers: {
  24. querySuccess (state, { payload }) {
  25. const { list, pagination } = payload
  26. return {
  27. ...state,
  28. list,
  29. pagination: {
  30. ...state.pagination,
  31. ...pagination,
  32. },
  33. }
  34. },
  35. },
  36. })
  37. module.exports = {
  38. model,
  39. pageModel,
  40. }