<template>
  <div>
  </div>
</template>

<script>
import { getWhetherOutboundTaskNow } from "@/api/outbound/automaticOutbound";
import { getCallOutprefix } from '@/api/teloperation';
import { Send } from "@/utils/telWebsocket";
import { mapGetters } from 'vuex';

export default {
  name: "OutboundTask",
  data() {
    return {
      loading: false,
      proNoticeDatas: [],
      proScheduleDatas: [],
      topNoticeData: [], //顶部消息数据
      readId: "",
      detailId: "",
      timer: "", //定时器
      timer1: "", //顶部消息定时器
    };
  },
  created() {
  },
  methods: {
    callOut () {
      if (this.telIsLogin == 1) {
        clearInterval(this.timer)
        this.scoketDatas = {
          'Type': 'AutoCall',
          'AgentID': this.usercode,
          'AgentExten': this.extension,
        }
        Send(this.scoketDatas)
      } else {
        this.$message({
          message: '请签入坐席',
          type: 'warning'
        });
      }
      // store.dispatch('UpdateCalloutScreen', false)// 关闭外呼面板
      // store.dispatch('UpdateOutboundScreen', false)// 关闭外呼弹屏
    },
  },
  mounted() {
    this.timer = setInterval(() => {
      const params={
        istop:1,
      }
      if (this.telIsLogin == 1) {
        getWhetherOutboundTaskNow(params).then((response) => {
          if (response.state == "success") {
            if (response.data > 0) {
              this.$confirm('是否要执行自动外呼?', '提示', {
                confirmButtonText: '启动',
                cancelButtonText: '取消',
                type: 'warning'
              }).then(() => {
                this.callOut()
              }).catch(() => {
                this.$message({
                  type: 'info',
                  message: '已取消自动外呼'
                });          
              });
            }
          }
        });
      } 
    }, 120000);
  },
  computed: {
    ...mapGetters([
      'token',
      'userid',
      'username',
      'usercode',
      'userRole',
      'seatflag',
      'extension',
      'mobile',
      'rolename',
      'telIsLogin',
    ])
  },
};
</script>

<style rel="stylesheet/scss" lang="scss" >
.topNoticePop {
  padding: 0;
  .topNotice {
    .scrollbar-wrapper {
      max-height: 488px;
    }
    .footer_menu {
      .el-dropdown-menu__item {
        padding: 20px;
        line-height: 20px;
      }
    }
  }
}
.messageBox {
  position: absolute !important;
  bottom: 0 !important;
  right: 0 !important;
}
</style>