12345678910111213141516171819202122232425262728293031323334353637 |
- import { A1ListType, NumListType } from '@/pages/A1record/data'
- // 初始化状态
- const initState = {
- // 列表数据
- tableInfo: {
- list: [] as A1ListType[],
- total: 0
- },
- // 番号列表数据
- numList: [] as NumListType[]
- }
- // 定义 action 类型
- type Props =
- | {
- type: 'A1/getList'
- payload: { list: A1ListType[]; total: number }
- }
- | {
- type: 'A1/getNumList'
- payload: NumListType[]
- }
- // reducer
- export default function userReducer(state = initState, action: Props) {
- switch (action.type) {
- // 获取列表数据
- case 'A1/getList':
- return { ...state, tableInfo: action.payload }
- case 'A1/getNumList':
- return { ...state, numList: action.payload }
- default:
- return state
- }
- }
|