123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115 |
- import Vue from "vue";
- import Vuex from "vuex";
- import axios from "@/utils/axios";
- import api from "@/api/index";
- Vue.use(Vuex);
- let projectId:any=(<any>window).projectId;
- export default new Vuex.Store({
- state: {
- realTimeData: [],
- airCondition: {},
- lastMonthData: [],
- lastAllEnergy: {},
- weatherCont: {},
- bodyWidth: null,
- bodyHeight: null
- },
- getters: {
- getBodyWidthHeight(state) {
- return [state.bodyWidth, state.bodyHeight];
- },
- },
- mutations: {
- setBodyWidth(state, width) {
-
- state.bodyWidth = width;
- },
- setBodyHeight(state, height) {
- state.bodyHeight = height;
- },
- getRealTimeData(state, data) {
-
- state.realTimeData = data;
- },
- getAirCondition(state, data) {
- state.airCondition = data;
- },
- getLastMonthData(state, data) {
- state.lastMonthData = data;
- },
- getLastAllEnergy(state, data) {
- state.lastAllEnergy = data;
- },
- getWeahter(state, data) {
- state.weatherCont = data;
- },
- },
- actions: {
- getRealTimeData({ state, commit }, data) {
- console.log("projectId",projectId);
-
- axios
- .get(api.queryEnvCurrent + `?projectId=${projectId}`)
- .then((res: any) => {
-
- var resdata = res.data.data || [];
- commit("getRealTimeData", resdata);
- });
- },
- getAirCondition({ state, commit }, data) {
-
- axios
- .get(api.queryConditionerStatus + `?projectId=${projectId}`)
- .then((res: any) => {
- var resdata = res.data.data || {};
-
- commit("getAirCondition", resdata);
- });
- },
- getRealTimeTemp({ state, commit }, data) {
-
- return axios.get(
- api.queryIndoorTempList + `?projectId=${projectId}`
- );
- },
- getLastMonthData({ state, commit }, data) {
-
- axios
- .get(api.queryEnvHistory + `?projectId=${projectId}`)
- .then((res: any) => {
-
- var resdata = res.data.data || [];
- commit("getLastMonthData", resdata);
- });
- },
- getLastAllEnergy({ state, commit }, data) {
-
- axios
- .post(api.queryLastAllEnergy, {
- criteria: {
- projectId: projectId,
- },
- })
- .then((res: any) => {
-
- var resdata = res.data.content[0] || {};
- commit("getLastAllEnergy", resdata);
- });
- },
- getWeahter({ state, commit }, data) {
- axios
- .get(api.getWeatherCurrent + `?projectId=${projectId}`)
- .then((res: any) => {
-
-
- var weatherCont = res.data.content || {};
- commit("getWeahter", weatherCont);
- });
- },
- },
- });
|