index.js 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. import Vue from 'vue'
  2. import Vuex from 'vuex'
  3. import publicType from './publicType.js' // 公共的类型
  4. import { reqWorkerList, reqBuildList } from "@/api/fileInfo.js";
  5. import { reqBasicsInfoList } from "@/api/material.js";
  6. import { reqBatchList } from "@/api/production.js";
  7. import { reqStoreList } from "@/api/material.js";
  8. Vue.use(Vuex)
  9. export default new Vuex.Store({
  10. strict: true,
  11. state: {
  12. token: localStorage.getItem("token"),
  13. workerList: [{ id: 1 }], // 员工列表 (加{id:1} 是为了防止刷新时报错,因为设置默认值时用到过)
  14. areaList: [{ id: 1 }], // 栋舍列表
  15. drugBasicsList: [{ id: 1 }], // 基础药品列表
  16. batchList: [], // 批次列表
  17. storeList: [], // 库存列表
  18. ...publicType
  19. },
  20. getters: {},
  21. mutations: {
  22. setState(state, [key, val]) {
  23. state[key] = val
  24. }
  25. },
  26. actions: {
  27. /* 获取员工列表 登录后再 home、workerInfo时调用了*/
  28. getWorkerList({ commit }) {
  29. reqWorkerList({
  30. searchStr: '',
  31. pageSize: 1000,
  32. pageNum: 1
  33. }).then(res => {
  34. commit('setState', ['workerList', res.content])
  35. })
  36. },
  37. /* 获取栋舍列表 登录后在 home、areaInfo时调用了*/
  38. getAreaList({ commit }) {
  39. reqBuildList({
  40. searchStr: '',
  41. pageSize: 1000,
  42. pageNum: 1
  43. }).then(res => {
  44. commit('setState', ['areaList', res.content])
  45. })
  46. },
  47. /* 获取基础药品列表 登录后在 home时调用了*/
  48. getDrugBasicsList({ commit }) {
  49. reqBasicsInfoList({
  50. searchStr: '',
  51. pageSize: 1000,
  52. pageNum: 1
  53. }).then(res => {
  54. commit('setState', ['drugBasicsList', res.content])
  55. })
  56. },
  57. /* 获取批次列表 登录后在 home、batch.vue时调用了*/
  58. getBatchList({ commit }) {
  59. reqBatchList({
  60. searchStr: '',
  61. pageSize: 1000,
  62. pageNum: 1
  63. }).then(res => {
  64. commit('setState', ['batchList', res.content])
  65. })
  66. },
  67. /* 获取库存列表 登录后在 storeList.vue时调用了*/
  68. getStoreList({ commit }) {
  69. reqStoreList({
  70. searchStr: '',
  71. pageSize: 1000,
  72. pageNum: 1
  73. }).then(res => {
  74. commit('setState', ['storeList', res.content])
  75. })
  76. }
  77. }
  78. })