import { createStore } from 'vuex'

// 创建一个新的 store 实例
const store = createStore({
     // 值的存储  获取: this.$store.state.xxxx
     state() {
          return {
               windturbinelist: Object,  // 服务器推送的风机详细信息
               warning: Object,
               suggestion: [],
               stationList: [],
               observers: true,
               titleInfo: Object,
               token: "",
               current: 1,
               faultList: [],
               currentStation: "",
               syzAlarmArray: [],
               syzDialogShow: false,
               syzAlarmRank: "6", // 升压站报警级别， === 此级别会报警
               fjAlarmRank: "6", // 风机报警级别， >= 此级别会报警
               currentWarningCardClass: "", // 升压站弹窗右下角表格 class 
               syzBtnFlicker: false, // 升压站按钮本身是否闪烁以提示有未处理报警
               // 升压站列表
               syzArray: [],
               activeTab: "", // 升压站弹窗所停留的tab页
               showWarningMask: false, // 是否显示全屏报警遮罩
               changeCount: 0, // 升压站变更次数
          }
     },

     //计算state的值  获取: this.$store.getters.xxxx
     getters: {
          windturbinelist(state) {
               return state.windturbinelist;
          },
          titleInfo(state) {
               return state.titleInfo;
          },
          current(state) {
               return state.current;
          },
          token(state) {
               return state.token;
          },
          stationList(state) {
               return state.stationList;
          },
          faultList(state) {
               return state.faultList;
          },
          currentStation(state) {
               return state.currentStation;
          },
          syzAlarmArray(state) {
               return state.syzAlarmArray;
          },
          syzArray(state) {
               return state.syzArray;
          },
     },

     // 数据更新 使用: this.$store.commit('函数名','val')
     mutations: {
          windturbinelist(state, data) {
               state.changeCount++;
               state.windturbinelist = data;
          },
          warning(state, data) {
               state.warning = data;
          },
          suggestion(state, data) {
               state.suggestion = data;
          },
          stationList(state, data) {
               state.stationList = data;
          },
          observers(state, data) {
               state.observers = data;
          },
          titleInfo(state, data) {
               state.titleInfo = data;
          },
          current(state, data) {
               state.current = data;
          },
          token(state, data) {
               state.token = data;
          },
          faultList(state, data) {
               state.faultList = data;
          },
          currentStation(state, data) {
               state.currentStation = data;
          },
          syzAlarmArray(state, data) {
               state.syzAlarmArray = data;
          },
          syzDialogShow(state, data) {
               state.syzDialogShow = data;
          },
          currentWarningCardClass(state, data) {
               state.currentWarningCardClass = data;
          },
          syzBtnFlicker(state, data) {
               state.syzBtnFlicker = data;
          },
          syzArray(state, data) {
               state.syzArray = data;
          },
          activeTab(state, data) {
               state.activeTab = data;
          },
          showWarningMask(state, data) {
               state.showWarningMask = data;
          },
     }
})

export default store