import Vue from 'vue'
import Vuex from 'vuex'
import publicType from './publicType.js' // 公共的类型 

import { reqSlaughterBatchIdList } from "@/api/slaughterManagment.js";

Vue.use(Vuex)

export default new Vuex.Store({
	strict: true,
	state: {
		...publicType,
		slaughterBatchIdList: [] // 屠宰批次 id 列表
	},
	getters: {
	},
	mutations: {
		setState(state, [key, val]) {
			state[key] = val
		}
	},
	actions: {
		/* 获取屠宰批次 登录后再 home时调用了*/
		getSlaughterBatchIdList({ commit }) {
			reqSlaughterBatchIdList().then(res => {
				commit('setState', ['slaughterBatchIdList', res])
			})
		},
	}
})
