import { Effect , Reducer } from 'umi' ; import { queryTableList } from '@/services/list' ; interface TableListProps { [ key ] : any ; } export interface QueryTableState { searchContentVal : string ; statusVal : string ; queryTableSource : TableListProps [ ] ; } export interface QueryTableType { namespace : 'queryTable' ; state : QueryTableState ; effects : { queryTableList : Effect ; } ; reducers : { save : Reducer < QueryTableState > ; } ; } const QueryTableModel = { namespace : 'queryTable' , state : { searchContentVal : '' , statusVal : '' , queryTableSource : [ ] , } , effects : { * queryTableList ( _ , { call , put , select } ) { const { searchContentVal , statusVal } = yield select ( ( state ) => state ) ; const response = yield call ( queryTableList , { searchContentVal , statusVal , } ) ; if ( response . status === 'ok' ) { yield put ( { type : 'save' , payload : { queryTableSource : response . data , } , } ) ; } } , } , reducers : { save ( state , action ) { return { ... state , ... action . payload , } ; } , } , } ; export default QueryTableModel ;