leaky.js 933 Bytes
Newer Older
neogcg's avatar
neogcg committed
1 2 3
import { leakyCablelist } from "../../views/setting/api"
const state = {
    list: [],
neogcg's avatar
neogcg committed
4 5
    pageNum: 1,
    pageSize: 10,
neogcg's avatar
neogcg committed
6 7 8 9 10
}
const mutations = {
    changeList(state, arr) {
        state.list = arr
    },
neogcg's avatar
neogcg committed
11 12 13
    changePagesize(state, total) {
        state.pageSize = total
    }
neogcg's avatar
neogcg committed
14 15 16
}
const actions = {
    asyncList(context) {
neogcg's avatar
neogcg committed
17
        leakyCablelist({
neogcg's avatar
neogcg committed
18 19
            current: context.state.pageNum,
            size: context.state.pageSize,
neogcg's avatar
neogcg committed
20 21 22 23 24 25 26 27
        }).then(res => {
            let total = res.total
            if (res.total > state.pageSize) {
                context.commit("changePagesize", total)
                context.dispatch("asyncList")
            }
            let arr = res.records ? res.records : []

neogcg's avatar
neogcg committed
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
            context.commit("changeList", arr)
        })
    }
}
const getters = {
    list(state) {
        return state.list
    }
}
export default {
    state,
    mutations,
    actions,
    getters,
    namespaced: true
}