/*包含n个用于直接更新状态的方法的对象模块*/
import {
    SAVE_USER,
    RESET_USER,
    CLEAR_SCREEN,
    SPLIT_SCREEN,
    UPDATE_SIGNALPRELIST,
    SAVE_BIGSCREEN,
    SAVE_SIGNALLIST,
    SAVE_DEVICE,
    UPDATE_SCALE,
    UPDATE_POSITIONNUM,
    UPDATE_BIGSCREENOBJ
} from './mutation-types'

import storageUtils from "../../utils/storageUtils"

export default {
  // 保存用户信息
  [SAVE_USER] (state, {user}) {  // 方法名不是SAVE_USER, 而是save_user
    state.user = user
    storageUtils.saveUser(user)
  },

  // 重置用户信息
  [RESET_USER] (state) {
    state.user = {}
    storageUtils.removeUser()
  },

  // 清屏
  [CLEAR_SCREEN] (state) {
    state.signalPreList = []
  },

  // 分屏
  [SPLIT_SCREEN] (state,{number}) {
    state.splitScreenStatus = number
  },

  // 更新大屏中的信号源数量
  [UPDATE_SIGNALPRELIST] (state,{signalPreList}) {
    state.signalPreList = signalPreList
  },

  // 保存大屏数据
  [SAVE_BIGSCREEN] (state,{bigScreenJson}) {
    state.bigScreenJson = bigScreenJson
  },

  // 保存信号源数据
  [SAVE_SIGNALLIST] (state,{signalListJson}) {
    state.signalListJson = signalListJson
  },

  // 保存设备数据
  [SAVE_DEVICE] (state,{deviceJson}) {
    state.deviceJson = deviceJson
  },

  // 更新元素缩放比例
  [UPDATE_SCALE] (state,{bigScale}) {
    state.bigScale = bigScale
  },

  // 更新信号源被拖带第几个栅格中
  [UPDATE_POSITIONNUM] (state,{positionNum}) {
    state.positionNum = positionNum
  },

  // 更新大屏对象
  [UPDATE_BIGSCREENOBJ] (state,{obj}) {
    state.bigScreenObj = obj
  },
}
