1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980 |
- import Vue from 'vue'
- import Vuex from 'vuex'
- import publicType from './publicType.js' // 公共的类型
- import { reqWorkerList, reqBuildList } from "@/api/fileInfo.js";
- import { reqBasicsInfoList } from "@/api/material.js";
- import { reqBatchList } from "@/api/production.js";
- import { reqStoreList } from "@/api/material.js";
- Vue.use(Vuex)
- export default new Vuex.Store({
- strict: true,
- state: {
- token: localStorage.getItem("token"),
- workerList: [{ id: 1 }], // 员工列表 (加{id:1} 是为了防止刷新时报错,因为设置默认值时用到过)
- areaList: [{ id: 1 }], // 栋舍列表
- drugBasicsList: [{ id: 1 }], // 基础药品列表
- batchList: [], // 批次列表
- storeList: [], // 库存列表
- ...publicType
- },
- getters: {},
- mutations: {
- setState(state, [key, val]) {
- state[key] = val
- }
- },
- actions: {
- /* 获取员工列表 登录后再 home、workerInfo时调用了*/
- getWorkerList({ commit }) {
- reqWorkerList({
- searchStr: '',
- pageSize: 1000,
- pageNum: 1
- }).then(res => {
- commit('setState', ['workerList', res.content])
- })
- },
- /* 获取栋舍列表 登录后在 home、areaInfo时调用了*/
- getAreaList({ commit }) {
- reqBuildList({
- searchStr: '',
- pageSize: 1000,
- pageNum: 1
- }).then(res => {
- commit('setState', ['areaList', res.content])
- })
- },
- /* 获取基础药品列表 登录后在 home时调用了*/
- getDrugBasicsList({ commit }) {
- reqBasicsInfoList({
- searchStr: '',
- pageSize: 1000,
- pageNum: 1
- }).then(res => {
- commit('setState', ['drugBasicsList', res.content])
- })
- },
- /* 获取批次列表 登录后在 home、batch.vue时调用了*/
- getBatchList({ commit }) {
- reqBatchList({
- searchStr: '',
- pageSize: 1000,
- pageNum: 1
- }).then(res => {
- commit('setState', ['batchList', res.content])
- })
- },
- /* 获取库存列表 登录后在 storeList.vue时调用了*/
- getStoreList({ commit }) {
- reqStoreList({
- searchStr: '',
- pageSize: 1000,
- pageNum: 1
- }).then(res => {
- commit('setState', ['storeList', res.content])
- })
- }
- }
- })
|