const state = {
   totalCheckNum: 0,
   hasCheckedNum: 0,
   hasCheckedList: [],
   checkList: [],
}
const getters = {
	
}
const mutations = {
	setList(state, list) {
		// 设置列表
		state.checkList = list;
	},
	
	setCheckList(state, list) {
		if (state.hasCheckedList.length === 0) {
			state.hasCheckedList.push(list);
			state.hasCheckedNum ++;
		} else {
			let isExist = false;
			state.hasCheckedList.forEach((item, index) => {
				if (item.id === list.id) {
					state.hasCheckedList.splice(index, 1, list);
					isExist = true;
				}
			});
			if (!isExist) {
				state.hasCheckedList.push(list);
				state.hasCheckedNum ++;
			}
		}
	},
  
	setTotalNum(state, num) {
		state.totalCheckNum = num;  
	},
	
	resetCheckList(state) {
		state.hasCheckedList = [];
	},
	
	resetCheckNum(state) {
		state.hasCheckedNum = 0;
	}
}
const actions = { 

}
export default {
  namespaced:true,
  state,
  getters,
  mutations,
  actions,
}