
const telWebsocket = {
  state: {
    telIsConnected: false, // 链接是否建立
    telMessageData: null, // telWebsocket数据
    telIsLogin: Number(window.sessionStorage.getItem('telIsLogin')), // 是否签入
    telSeatState: 2, // 坐席状态 1: 登陆中、2:空闲、3:通话中、4:话后处理、5:小休、6:被请求
    telLineState: 1, // 线路状态 1:空闲、2:摘机等待拨号、3:正在拨号、4:呼出振铃、5:来电振铃、6:通话中 10:通话保持
    telTopRightState: '未签入', // 右上角 状态提示信息
    telTopRightLamp: false, // 右上角 状态灯(默认 红色)
    telCallNum: '', // 顶部电话号码
    telCallType: 'MakeCall', // 发送的通话类型（默认是外呼）
    telIsVisCallout: false, // 外呼操作面板是否显示
    telOutboundScreen: true, //是否显示外呼弹屏
    telIsVisTask: false, // 外呼任务信息是否显示
    telIsVisTaskFirst: true, // 外呼任务信息是否是第一次弹出
    telTaskIsRefresh: false, // 是否刷新右上角外呼任务信息/自动外呼监控/外呼分配/我的呼叫任务
    telCallTime: { // 通话时间
      hh: '00',
      mm: '00',
      ss: '00'
    },
    telMonitor: false, // 监听操作是否成功
    monitorState: '', //状态监控
    monitorAgent: '', //监控的坐席工号
  },
  mutations: {
    SOCKET_CONNECT (state) {
      state.telIsConnected = true
    },
    SOCKET_DISCONNECT (state) {
      state.telIsConnected = false
    },
    SOCKET_LOGIN (state) {
      // window.sessionStorage.setItem('telIsLogin', 1)
      // state.telIsLogin = Number(window.sessionStorage.getItem('telIsLogin'))
      state.telIsLogin = 1
    },
    SOCKET_LOGOUT (state) {
      window.sessionStorage.setItem('telIsLogin', 0)
      state.telIsLogin = Number(window.sessionStorage.getItem('telIsLogin'))
    },
    SOCKET_SEATSTATE (state, message) {
      state.telSeatState = message
    },
    SOCKET_LINESTATE (state, message) {
      state.telLineState = message
    },
    SOCKET_TOPRIGHTSTATE (state, message) {
      state.telTopRightState = message
    },
    SOCKET_TOPRIGHTLAMP (state, message) {
      state.telTopRightLamp = message
    },
    SOCKET_CALLNUM (state, message) {
      state.telCallNum = message
    },
    SOCKET_CALLTYPE (state, message) {
      state.telCallType = message
    },
    SOCKET_CALLOUTSCREEN (state, message) {
      state.telIsVisCallout = message
    },
    SOCKET_OUTBOUNDSCREEN (state, message) {
      state.telOutboundScreen = message
    },
    SOCKET_CALLTELTIME (state, message) {
      state.telCallTime = message
    },
    SOCKET_MESSAGE (state, message) {
      state.telMessageData = message
    },
    SOCKET_TELMONITOR (state, message) {
      state.telMonitor = message
    },
    SOCKET_MONITORSTATE (state, message) {
      state.monitorState = message
    },
    SOCKET_MONITORAGENT (state, message) {
      state.monitorAgent = message
    },
    SOCKET_TELISVISTASK (state, message) {
      state.telIsVisTask = message
    },
    SOCKET_TELISVISTASKFIRST (state, message) {
      state.telIsVisTaskFirst = message
    },
    SOCKET_TELTASKISREFRESH (state, message) {
      state.telTaskIsRefresh = message
    },
  },
  actions: {
    // 建立连接
    ConnectWs ({ commit }, msg) {
      commit('SOCKET_CONNECT', msg)
    },
    // 连接失败
    DisConnectWs ({ commit }, msg) {
      commit('SOCKET_DISCONNECT', msg)
    },
    // 签入
    LoginWs ({ commit }, msg) {
      commit('SOCKET_LOGIN', msg)
    },
    // 签出
    LogoutWs ({ commit }, msg) {
      commit('SOCKET_LOGOUT', msg)
    },
    // 坐席状态
    ChangeSeatState ({ commit }, msg) {
      commit('SOCKET_SEATSTATE', msg)
    },
    // 线路状态
    ChangeLineState ({ commit }, msg) {
      commit('SOCKET_LINESTATE', msg)
    },
    // 右上角状态
    ChangeTopRightState ({ commit }, msg) {
      commit('SOCKET_TOPRIGHTSTATE', msg[0])
      commit('SOCKET_TOPRIGHTLAMP', msg[1])
    },
    // 顶部电话号码
    ChangeCallNum ({ commit }, msg) {
      commit('SOCKET_CALLNUM', msg)
    },
    // 发送的通话类型
    ChangeCallType ({ commit }, msg) {
      commit('SOCKET_CALLTYPE', msg)
    },
    // 外呼操作面板是否显示
    UpdateCalloutScreen ({ commit }, msg) {
      commit('SOCKET_CALLOUTSCREEN', msg)
    },
    //外呼是否显示外呼弹屏
    UpdateOutboundScreen ({ commit }, msg) {
      commit('SOCKET_OUTBOUNDSCREEN', msg)
    },
    // 通话时间
    UpdateCallTime ({ commit }, msg) {
      commit('SOCKET_CALLTELTIME', msg)
    },
    // 修改telWebsocket数据
    ChangeTelWSMsg ({ commit }, msg) {
      commit('SOCKET_MESSAGE', msg)
    },
    // 修改监听操作是否成功
    ChangeMonitor ({ commit }, msg) {
      commit('SOCKET_TELMONITOR', msg)
    },
    // 监控状态
    ChangeMonitorstate ({ commit }, msg) {
      commit('SOCKET_MONITORSTATE', msg)
    },
    // 监控坐席工号
    ChangeMonitoragent ({ commit }, msg) {
      commit('SOCKET_MONITORAGENT', msg)
    },
    // 任务信息是否显示
    ChangeTask ({ commit }, msg) {
      commit('SOCKET_TELISVISTASK', msg)
    },
    // 任务信息是否是第一次弹出
    ChangeTaskFirst ({ commit }, msg) {
      commit('SOCKET_TELISVISTASKFIRST', msg)
    },
    // 是否刷新右上角外呼任务信息/自动外呼监控/外呼分配/我的呼叫任务
    ChangeTaskInfo ({ commit }, msg) {
      commit('SOCKET_TELTASKISREFRESH', msg)
    },
  }
}

export default telWebsocket
