Commit 2020d6b4 by 姜雷

修改分页以及筛选模块

parent f10eb982
const UPDATE_FILTERS = 'UPDATE_FILTERS';
const RESET_FILTERS = 'RESET_FILTERS';
const initFiltersStore = (
initState = {},
initState = () => ({}),
otherGetters = {},
otherActions = {},
otherMutations = {}
) => {
const state = () => ({
filters: initState,
filters: initState(),
});
const getters = {
filters: state => state.filters,
......@@ -17,6 +18,9 @@ const initFiltersStore = (
updateFilters({ commit }, filters) {
commit(UPDATE_FILTERS, filters);
},
resetFilters({ commit }) {
commit(RESET_FILTERS);
},
...otherActions,
};
const mutations = {
......@@ -26,6 +30,9 @@ const initFiltersStore = (
...filters,
};
},
[RESET_FILTERS]() {
state.filters = initState();
},
...otherMutations,
};
......
import { UPDATE_PAGINATION } from '../mutation-types';
const UPDATE_PAGINATION = 'UPDATE_PAGINATION';
const RESET_PAGINATION = 'RESET_PAGINATION';
const state = () => ({
pageNum: 1, // 当前分页
......@@ -17,6 +18,9 @@ const actions = {
updatePagination({ commit }, pagination) {
commit(UPDATE_PAGINATION, pagination);
},
resetPagination({ commit }) {
commit(RESET_PAGINATION);
},
};
const mutations = {
......@@ -25,6 +29,14 @@ const mutations = {
...pagination,
});
},
[RESET_PAGINATION](state) {
state = Object.assign(state, {
pageNum: 1, // 当前分页
pageSize: 10, // 分页大小
total: 0,
pages: 0,
});
},
};
export default {
......
export const USER_LOGIN = 'USER_LOGIN';
export const FETCH_PRODUCT_LIST = 'FETCH_PRODUCT_LIST';
// pagination
export const UPDATE_PAGINATION = 'UPDATE_PAGINATION';
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment