Newer
Older
CloudBrainNew / src / views / cityManage / cityManageRight2.vue
StephanieGitHub on 4 Feb 2021 1 KB first commit
<!--
 * @Description: 城市治理右半,三行四列
 * @Author: 王晓颖
 * @Date: 2020-09-04 13:59:13
 -->
<template>
  <div class="chart-container">
    <div class="right">
      <div class="modular">
        <transition mode="out-in">
          <component :is="currentComps[currentComp]" @mouseover.native="stopCompChange" @mouseout.native="compChange"/>
        </transition>
        <!--<case-all/>-->
        <!--<traffic-all/>-->
      </div>
    </div>
  </div>
</template>

<script>
import CaseAll from './components/cityManage/caseAll'
import TrafficAll from './components/wisdomTraffic/trafficAll'
export default {
  name: 'CityManageRight',
  components: {
    TrafficAll,
    CaseAll
  },
  data () {
    return {
      currentComp: 0, // 人口组件
      currentComps: ['case-all', 'traffic-all'],
      compsTimer: null
    }
  },
  mounted () {
    this.compChange()
  },
  methods: {
    // 交通、社会治理面板切换
    compChange () {
      this.compsTimer = setTimeout(() => {
        const max = this.currentComps.length - 1
        if (this.currentComp < max) {
          this.currentComp++
        } else {
          this.currentComp = 0
        }
        this.compChange()
      }, 20000)
    },
    // 停止切换人口组件
    stopCompChange () {
      clearInterval(this.compsTimer)
      this.compsTimer = null
    }
  },
  beforeDestroy () {
    this.stopCompChange()
  }
}
</script>

<style rel="stylesheet/scss" lang="scss" scoped>
  .chart-container{
    position: absolute;
    padding: 0 0.1rem 0.1rem 0.3rem;
    top:0;
    right:0.2rem;
    width: 30%;
    height:100%;
    display: flex;
    z-index: 20;
    justify-content: space-between;
    background: transparent;
    .right{
      width:100%;
      height:100%;
      display: flex;
      justify-content: center;
      /*position: relative;*/
    }

  }
</style>