index.ts 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. import Vue from "vue";
  2. import Vuex from "vuex";
  3. import axios from "@/utils/axios";
  4. import api from "@/api/index";
  5. Vue.use(Vuex);
  6. export default new Vuex.Store({
  7. state: {
  8. realTimeData: {}, //实时数据
  9. airCondition: {}, //空调情况
  10. realTimeTemp: [], //实时温度
  11. lastMonthData: {}, //上月数据
  12. },
  13. mutations: {
  14. getRealTimeData(state, data) {
  15. state.realTimeData = data;
  16. },
  17. getAirCondition(state, data) {
  18. state.airCondition = data;
  19. },
  20. getRealTimeTemp(state, data) {
  21. state.realTimeTemp = data;
  22. },
  23. getLastMonthData(state, data) {
  24. state.lastMonthData = data;
  25. },
  26. },
  27. actions: {
  28. getRealTimeData({ state, commit }, payload) {
  29. //实时数据
  30. axios
  31. .post(api.queryEnvironmentData, {
  32. projectId: "Pj1101080259",
  33. })
  34. .then((res: any) => {
  35. commit({
  36. type: "getRealTimeData",
  37. data: res,
  38. });
  39. });
  40. },
  41. getAirCondition({ state, commit }, payload) {
  42. //空调状态
  43. axios
  44. .post(api.queryConditionerStatus, {
  45. projectId: "Pj1101080259",
  46. })
  47. .then((res: any) => {
  48. commit({
  49. type: "getAirCondition",
  50. data: res,
  51. });
  52. });
  53. },
  54. getRealTimeTemp({ state, commit }, payload) {
  55. //实时温度
  56. axios
  57. .post(api.queryIndoorTempList, {
  58. projectId: "Pj1101080259",
  59. })
  60. .then((res: any) => {
  61. // commit({
  62. // type: "getRealTimeTemp",
  63. // data: res,
  64. // });
  65. });
  66. },
  67. getLastMonthData({ state, commit }, payload) {
  68. //上月温度
  69. axios
  70. .post(api.queryLastMonthData, {
  71. projectId: "Pj1101080259",
  72. })
  73. .then((res: any) => {
  74. commit({
  75. type: "getLastMonthData",
  76. data: res,
  77. });
  78. });
  79. },
  80. },
  81. });