A1record.ts 766 B

12345678910111213141516171819202122232425262728293031323334353637
  1. import { A1ListType, NumListType } from '@/pages/A1record/data'
  2. // 初始化状态
  3. const initState = {
  4. // 列表数据
  5. tableInfo: {
  6. list: [] as A1ListType[],
  7. total: 0
  8. },
  9. // 番号列表数据
  10. numList: [] as NumListType[]
  11. }
  12. // 定义 action 类型
  13. type Props =
  14. | {
  15. type: 'A1/getList'
  16. payload: { list: A1ListType[]; total: number }
  17. }
  18. | {
  19. type: 'A1/getNumList'
  20. payload: NumListType[]
  21. }
  22. // reducer
  23. export default function userReducer(state = initState, action: Props) {
  24. switch (action.type) {
  25. // 获取列表数据
  26. case 'A1/getList':
  27. return { ...state, tableInfo: action.payload }
  28. case 'A1/getNumList':
  29. return { ...state, numList: action.payload }
  30. default:
  31. return state
  32. }
  33. }