• neogcg's avatar
    3/4 · ebd42b59
    neogcg authored
    ebd42b59
station.js 890 Bytes
import { sitelist } from "../../views/setting/api"
const state = {
    list: [],
    pageNum:1,
    pageSize:10,
}
const mutations = {
    changeList(state, arr) {
        state.list = arr
       
    },
    changePagesize(state,total){
         state.pageSize=total
    }
}
const actions = {
    asyncList(context) {
        sitelist( {
            current: context.state.pageNum,
            size: context.state.pageSize,
          }).then(res => {
        let total=res.total
       if (res.total>state.pageSize) {
        context.commit("changePagesize", total)
        context.dispatch("asyncList")
       }
        let arr = res.records?res.records:[]
     
            context.commit("changeList", arr)
        })
    }
}
const getters = {
    list(state) {
        return state.list
    }
}
export default {
    state,
    mutations,
    actions,
    getters,
    namespaced: true
}