<template>
  <div class="group-praise">
    <div class="group-praise__content">
      <div class="group-praise__circle">
        <header class="group-praise__title">待接单</header>
        <div class="group-praise__circleContent">
          <p class="group-praise__circlePercent">
            {{ dataInfo.waitCount || 0 }}
          </p>
          <div class="lineTopRight"></div>
          <div class="lineBottomLeft"></div>
        </div>
      </div>
      <div class="group-praise__circle">
        <header class="group-praise__title">处理中</header>
        <div class="group-praise__circleContent">
          <p class="group-praise__circlePercent">
            {{ dataInfo.doingCount || 0 }}
          </p>
          <div class="lineTopRight"></div>
          <div class="lineBottomLeft"></div>
        </div>
      </div>
      <div class="group-praise__circle">
        <header class="group-praise__title">紧急工单</header>
        <div class="group-praise__circleContent">
          <p class="group-praise__circlePercent">
            {{ dataInfo.emergencyCount || 0 }}
          </p>
          <div class="lineTopRight"></div>
          <div class="lineBottomLeft"></div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import { post, timerCommon } from './../http/http'
export default {
  name: 'RealTimeDeliveryOrder',
  inject: ['parentDutyId', 'hosId', 'dutyId'],
  data () {
    return {
      timer: null,
      dataInfo: {}
    }
  },
  methods: {
    // 故障工单实时动态
    async getRealTimeDeliveryOrder () {
      const startTime = this.$moment()
        .startOf('day')
        .format('YYYY-MM-DD HH:mm:ss') // 今日
      const endTime = this.$moment()
        .endOf('day')
        .format('YYYY-MM-DD HH:mm:ss') // 今日
      const result = await post(
        '/itsm/report/index',
        {
          parentDutyId: this.parentDutyId,
          hosId: this.hosId,
          dutyId: this.dutyId,
          startDate: startTime,
          endDate: endTime,
          type: 'hsmsOrderCount',
          businessType: 'hsms'
        }
      )
      this.dataInfo = result.data ? result.data[0] : {}
      this.polling()
    },
    // 轮询请求
    polling () {
      clearTimeout(this.timer)
      this.timer = setTimeout(() => {
        this.getRealTimeDeliveryOrder()
      }, timerCommon)
    }
  },
  mounted () {
    this.getRealTimeDeliveryOrder()
  },
  beforeDestroy () {
    clearTimeout(this.timer)
  }
}
</script>

<style lang="less" scoped>
.group-praise {
  height: 2.6625rem;
  .group-praise__content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 .2rem;
    height: 100%;
    .group-praise__title {
      color: #fff;
      font-size: .2rem;
      text-align: center;
    }
    .group-praise__circleContent {
      color: #fff;
      font-size: 0.175rem;
      height: .7875rem;
      display: flex;
      align-items: center;
      justify-content: center;
      margin-top: .2rem;
      background: linear-gradient( 90deg, #032430 0%, #023645 13%, #0B4D61 38%, #105A70 61%, #023645 87%, #06252B 100%);
      position: relative;
      .group-praise__circlePercent{
        font-size: .475rem;
      }
    }
    .group-praise__circle {
      width: 1.425rem;
    }
  }
}
</style>
