Newer
Older
CloudBrainNew / src / views / socialLive / components / community / troubleCount.vue
StephanieGitHub on 4 Feb 2021 2 KB first commit
<!--
 * @Description:隐患数量统计
 * @Author: 王晓颖
 * @Date: 2020-11-27 13:44:52
 -->
<template>
  <chart-layout title="隐患" @click="getData">
    <div class="block-container">
      <div class="block" style="width:40%">
        <!--<trouble-data ref="troubleData"/>-->
        <transition mode="out-in">
          <component :is="troubleComps1[troubleComp1]" @mouseover.native="stopTrouble1Change" @mouseout.native="trouble1Change"/>
        </transition>
      </div>
      <div class="block" style="width:60%">
        <trouble-detail ref="troubleDetail"/>
      </div>
    </div>
    <corner1 slot="corner"/>
  </chart-layout>
</template>

<script>

import TroubleData from './components/troubleData'
import TroublePie from './components/troublePie'
import TroubleDetail from './components/troubleDetail'
export default {
  name: 'TroubleCount',
  components: {TroubleDetail, TroublePie, TroubleData},
  data () {
    return {
      troubleChangeTime: 30, // 隐患整体情况组件切换时间
      troubleTimer: null, // 隐患整体情况组件切换计时器
      troubleComp1: 0, // 隐患整体情况当前组件
      troubleComps1: ['trouble-data', 'trouble-pie'] // 隐患整体情况组件切换列表
    }
  },
  mounted () {
    this.trouble1Change()
  },
  methods: {
    getData () {
      this.$refs.troubleData.getData()
      this.$refs.troubleDetail.getData()
    },
    // 人口组件切换
    trouble1Change () {
      this.troubleTimer = setTimeout(() => {
        const max = this.troubleComps1.length - 1
        if (this.troubleComp1 < max) {
          this.troubleComp1++
        } else {
          this.troubleComp1 = 0
        }
        this.trouble1Change()
      }, this.troubleChangeTime * 1000)
    },
    // 停止切换人口组件
    stopTrouble1Change () {
      clearInterval(this.troubleTimer)
      this.troubleTimer = null
    }
  },
  beforeDestroy () {
    this.stopTrouble1Change()
  }
}
</script>

<style rel="stylesheet/scss" lang="scss" scoped>
  .block-container{
    height: 100%;
    width: 100%;
    display: flex;
    justify-content: space-between;
    /*padding:0.1rem;*/
    .block{

    }
  }
</style>