import { getRemoveList } from '@/services/package/contract';
import { message } from 'antd';

const ContractModel = {
    //model标识
    namespace: 'ContractModel',
    // 数据
    state: {
       list:[],
       page:1,
       totalRow:0,
       type:'Add',
       record:-1,
       loding:true,
    },
    // 同步
    reducers: {
        reGetList(state:any,{ payload }:{payload:any}) {
            return Object.assign({}, state, payload)
            // return {...payload}
        }
    },
    // 异步
    effects: { 
       // 拉取列表
       *getList({payload}:{payload:any}, { put, call}:{ put:any, call:any}) {
            const data = yield call(getRemoveList,payload);
            if(data){
                yield put({
                    type: 'reGetList',
                    payload:{
                        list:data.list,
                        page:payload.page.pageNum,
                        totalRow:data.page.totalRow,
                        loding:false
                    },
                })
            }else{
                message.error('列表获取失败')
            }
            
        },

        *getMove({payload}:{payload:any},{ put, call}:{ put:any, call:any}){
            yield put({
                type: 'reGetList',
                payload:payload,
            })
        }
    },
};
export default ContractModel;