const station = {
  state: {
    stationIp: sessionStorage.getItem('stationIp') ? sessionStorage.getItem('stationIp') : '',
    stationNumber: sessionStorage.getItem('stationNumber') ? sessionStorage.getItem('stationNumber') : '',
    stationName: sessionStorage.getItem('stationName') ? sessionStorage.getItem('stationName') : '',
    classesID: sessionStorage.getItem('classesID') ? sessionStorage.getItem('classesID') : '',
    MesWebCode: sessionStorage.getItem('MesWebCode') ? sessionStorage.getItem('MesWebCode') : '',
    classes: sessionStorage.getItem('classes') ? sessionStorage.getItem('classes') : '',
    engineValue: JSON.parse(sessionStorage.getItem('engineValue')) ? JSON.parse(sessionStorage.getItem('engineValue')) : {},
    stationStatus: 0,
    plcStatus: 0,
    stationUserCount: sessionStorage.getItem('stationUserCount') ? sessionStorage.getItem('stationUserCount') : '',
    stationUserName: sessionStorage.getItem('stationUserName') ? sessionStorage.getItem('stationUserName') : '',
    stationNameUsed: sessionStorage.getItem('stationNameUsed') ? sessionStorage.getItem('stationNameUsed') : '',
    statusValue: JSON.parse(sessionStorage.getItem('statusValue')) ? JSON.parse(sessionStorage.getItem('statusValue')) : {},
    tempDataObject: JSON.parse(sessionStorage.getItem('tempDataObject')) ? JSON.parse(sessionStorage.getItem('tempDataObject')) : {
      checkWorkOverIsShow: 0 // 检查完成按钮
    } // 临时数据对象 用于存储各种PLC的临时信号
  },
  mutations: {
    // 设置临时变量时需要传入key value格式对象进行赋值
    // isCut 参数用于判断是否需要自动切换 可以给自动转换一次
    set_tempDataObject(state, itemObj) {
      // 先设为''做一次差异，防止监视属性检测不到，而后在改为设置的值
      state.tempDataObject[itemObj.key] = ''
      sessionStorage.setItem('tempDataObject', JSON.stringify(state.tempDataObject))
      setTimeout(() => {
        state.tempDataObject[itemObj.key] = itemObj.value
        sessionStorage.setItem('tempDataObject', JSON.stringify(state.tempDataObject))
      }, 0)
    },
    set_statusValue(state, statusValue) {
      sessionStorage.setItem('statusValue', JSON.stringify(statusValue))
      state.statusValue = statusValue
    },
    set_stationIp(state, stationIp) {
      sessionStorage.setItem('stationIp', stationIp)
      state.stationIp = stationIp
    },
    set_stationNumber(state, stationNumber) {
      sessionStorage.setItem('stationNumber', stationNumber)
      state.stationNumber = stationNumber
    },
    set_stationName(state, stationName) {
      sessionStorage.setItem('stationName', stationName)
      state.stationName = stationName
    },
    set_classesID(state, classesID) {
      sessionStorage.setItem('classesID', classesID)
      state.classesID = classesID
    },
    set_stationUserName(state, stationUserName) {
      sessionStorage.setItem('stationUserName', stationUserName)
      state.stationUserName = stationUserName
    },
    set_stationUserCount(state, stationUserCount) {
      sessionStorage.setItem('stationUserCount', stationUserCount)
      state.stationUserCount = stationUserCount
    },
    set_classes(state, classes) {
      sessionStorage.setItem('classes', classes)
      state.classes = classes
    },
    set_MesWebCode(state, MesWebCode) {
      sessionStorage.setItem('MesWebCode', MesWebCode)
      state.MesWebCode = MesWebCode
    },
    set_engineValue(state, engineValue) {
      sessionStorage.setItem('engineValue', JSON.stringify(engineValue))
      state.engineValue = engineValue
    },
    set_stationStatus(state, stationStatus) {
      state.stationStatus = stationStatus
    },
    set_plcStatus(state, plcStatus) {
      state.plcStatus = plcStatus
    }
  }
}
export default station
