<!--
 * @Author: daidai
 * @Date: 2022-03-01 15:51:43
 * @LastEditors: Please set LastEditors
 * @LastEditTime: 2022-09-29 15:12:46
 * @FilePath: \web-pc\src\pages\big-screen\view\indexs\right-bottom.vue
-->
<template>
  <div class="right_bottom">
    <dv-capsule-chart :config="config" style="width:100%;height:260px" />
  </div>
</template>

<script setup>
import { currentGET } from '/@/api/newDeviceVision/modules'
import { onBeforeMount, onBeforeUnmount, reactive } from 'vue';
import store from '/@/stores/newDeviceVision/modules/setting'

const data = reactive({
  gatewayno: '',
  timer: 0
})
const config = reactive({
  showValue: true,
  unit: "",
  data: []
})

onBeforeMount(() => {
  getData()
})

onBeforeUnmount(() => {
  clearData()
})

const clearData = () => {
  if (data.timer) {
    clearInterval(data.timer)
    data.timer = null
  }
}

//轮询
const switper = () => {
  if (data.timer) {
    return
  }
  let looper = (a) => {
    getData()
  };
  data.timer = setInterval(looper, store.state.echartsAutoTime);
}

const getData = () => {
  // data.pageflag = true

  let json = {
    "success": true,
    "data": [
      {
        "value": 1995,
        "name": "黑龙江"
      },
      {
        "value": 1815,
        "name": "河南"
      },
      {
        "value": 1654,
        "name": "安徽"
      },
      {
        "value": 1503,
        "name": "浙江"
      },
      {
        "value": 1363,
        "name": "河北"
      },
      {
        "value": 1232,
        "name": "湖北"
      },
      {
        "value": 1131,
        "name": "贵州"
      },
      {
        "value": 925,
        "name": "广东"
      }]
  };

  // *** 数据请求失败
  currentGET('big7').then(res => {

    if (!data.timer) {
      console.log('报警排名', JSON.stringify(res));
    }
    if (res.success) {
      data.config = {
        ...data.config,
        data: json.data
      }
      this.switper()
    } else {
      data.pageflag = false
      data.srcList = []
    }
  })
  config.data = json.data
}
</script>
<style lang='scss' scoped>
.list_Wrap {
  height: 100%;
  overflow: hidden;

  :deep(.kong) {
    width: auto;
  }
}

.sbtxSwiperclass {
  .img_wrap {
    overflow-x: auto;
  }

}

.right_bottom {
  box-sizing: border-box;
  padding: 0 16px;

  .searchform {
    height: 80px;
    display: flex;
    align-items: center;
    justify-content: center;

    .searchform_item {
      display: flex;
      justify-content: center;
      align-items: center;

      label {
        margin-right: 10px;
        color: rgba(255, 255, 255, 0.8);
      }

      button {
        margin-left: 30px;
      }
    }
  }

  .img_wrap {
    display: flex;
    // justify-content: space-around;
    box-sizing: border-box;
    padding: 0 0 20px;
    // overflow-x: auto;

    li {
      width: 105px;
      height: 137px;
      border-radius: 6px;
      overflow: hidden;
      cursor: pointer;
      // background: #84ccc9;
      // border: 1px solid #ffffff;
      overflow: hidden;
      flex-shrink: 0;
      margin: 0 10px;

      img {
        flex-shrink: 0;
      }
    }




  }

  .noData {
    width: 100%;
    line-height: 100px;
    text-align: center;
    color: rgb(129, 128, 128);

  }
}
</style>