<template>
  <div v-if="pageflag" class="right_center_wrap beautify-scroll-def">
    <div class="loading" v-if="loading"><a-spin /></div>
    <div class="rowup">
      <ul class="right_center">
        <li class="right_center_item" v-for="(item, i) in list" :key="i">
          <div class="inner_right">
            <div class="dibu"></div>
            <div class="info col-1">
              <span class="ciyao"> {{ item.dealerName }}</span>
            </div>
            <div class="info col-2">
              <span class="ciyao"> {{ item.dealerLevelDictValue }}</span>
            </div>
            <div class="info col-3">
              <span class="zhuyao"> {{ item.resultQty }}</span>
            </div>
            <div class="info col-4">
              <span class="warning"> {{ item.resultAmount | montionFilter }}</span>
            </div>
          </div>
        </li>
      </ul>
      <ul class="right_center" v-if="list.length>4">
        <li class="right_center_item" v-for="(item, i) in list" :key="i">
          <div class="inner_right">
            <div class="dibu"></div>
            <div class="info col-1">
              <span class="ciyao"> {{ item.dealerName }}</span>
            </div>
            <div class="info col-2">
              <span class="ciyao"> {{ item.dealerLevelDictValue }}</span>
            </div>
            <div class="info col-3">
              <span class="zhuyao"> {{ item.resultQty }}</span>
            </div>
            <div class="info col-4">
              <span class="warning"> {{ item.resultAmount | montionFilter }}</span>
            </div>
          </div>
        </li>
      </ul>
    </div>
  </div>
  <Reacquire v-else @onclick="getData" style="line-height:200px" />

</template>

<script>
import Kong from '@/bigScreenComponents/kong.vue'
import { addKeyFrames } from '@/utils/domUtil.js'
import { querySaleToday } from '@/api/bigScreen.js'
export default {
  components: { Kong },
  data () {
    return {
      list: [],
      pageflag: true,
      timer: null,
      loading: false
    }
  },
  created () {
    this.getData()
  },
  mounted () { },
  beforeDestroy () {
    this.clearData()
  },
  methods: {
    clearData () {
      if (this.timer) {
        clearInterval(this.timer)
        this.timer = null
      }
    },
    // 轮询
    switper () {
      if (this.timer) {
        return
      }
      const looper = (a) => {
        this.getData()
      }
      this.timer = setInterval(looper, this.$store.state.setting.echartsAutoTime)
    },
    getData () {
      this.loading = true
      querySaleToday().then(res => {
        if (res.status == 200) {
          this.list = res.data
          if (!this.timer) {
            console.log('今日销售', res)
            // 无缝滚动
            const len = this.list.length
            if (len > 4) {
              const height = len * 48.5
              const dur = len * 2
              addKeyFrames('rowup', '-' + height + 'px', dur)
            }
          }
          this.switper()
        } else {
          this.pageflag = false
        }
        this.loading = false
      })
    }
  }
}
</script>
<style lang="less" scoped>
.right_center {
  width: 100%;
  height: 100%;

  .right_center_item {
    padding: 13px 0;
    font-size: 14px;
    color: #fff;

    .inner_right {
      display: flex;
      align-items: center;
      position: relative;
      height: 100%;
      width: 100%;
      flex-shrink: 0;
      line-height: 1.5;
      .orderNum {
        width: 10%;
        text-align: center;
        color: #fff;
      }
      .dibu {
        position: absolute;
        height: 2px;
        width: 104%;
        background-image: url("../../../assets/img/zuo_xuxian.png");
        bottom: -12px;
        left: 0;
        background-size: cover;
      }
    }
    .col-1 {
      width: 35%;
    }

    .col-2 {
      width: 25%;
    }

    .col-3 {
      width: 20%;
    }

    .col-4 {
      width: 20%;
    }
    .info {
      text-align: center;
      .zhuyao {
        color: #a6e0ff;
        font-size: 15px;
        font-weight: bold;
      }
      .ciyao {
        color: rgba(255, 255, 255, 0.8);
      }
      .blue {
        color: #00aaff;;
        font-size: 15px;
      }
      .warning {
        color: #ffb442;
        font-size: 15px;
        font-weight: bold;
      }
    }

  }
}

.right_center_wrap {
  overflow: hidden;
  width: 100%;
  height: 390px;
}

.overflow-y-auto {
  overflow-y: auto;
}
</style>
