system.js 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. import {
  2. reqFetchDataList
  3. } from "@/request/api.js";
  4. import cloneDeep from 'lodash/cloneDeep'
  5. const stateReset = {
  6. systemInfo: {},
  7. };
  8. const state = cloneDeep(stateReset);
  9. const getters = {};
  10. const mutations = {
  11. // 重置字典数据
  12. resetVxSystem(state) {
  13. Object.assign(state, cloneDeep(stateReset))
  14. },
  15. // 获取数据
  16. vxSystem(state, args) {
  17. state.systemInfo[args.key] = args.data;
  18. },
  19. };
  20. const actions = {
  21. // 获取字典数据
  22. async vxSystem({
  23. commit,
  24. state
  25. }, args) {
  26. const excludeArr = ['updateTipsForNurses']; //无需缓存的keyconfig
  27. const keyconfig = args.systemConfiguration.keyconfig;
  28. if (state.systemInfo[keyconfig]) {
  29. //如果存在
  30. return await Promise.resolve(state.systemInfo[keyconfig]);
  31. } else {
  32. let result = await reqFetchDataList('simple/data', 'systemConfiguration', args);
  33. if (result.status == 200) {
  34. if (!excludeArr.includes(keyconfig)) {
  35. commit("vxSystem", {
  36. key: keyconfig,
  37. data: result
  38. });
  39. }
  40. }
  41. return result;
  42. }
  43. },
  44. };
  45. export default {
  46. namespaced: true,
  47. state,
  48. getters,
  49. mutations,
  50. actions,
  51. };