<template>
    <div id="digital-flop">
        <div>
          <div class="digtal-flop">
            <div
              class="digital-flop-item"
              v-for="item in digitalFlopData"
              :key="item.title"
              @click="jump(item)"
            >
              <!-- <div class="digital-flop-title">{{ item.title }}</div> -->
              <div class="digital-flop">
                <dv-digital-flop
                  :config="item.number"
                  style="width:100%;height:40px;"
                />
                  <div class="unit">{{ item.unit }}</div>
              </div>
			  <div class="digital-flop-title">{{ item.title }}</div>
            </div>
          </div>
        </div>

    </div>
</template>

<script>
export default {
  name: 'DigitalFlop',
  data () {
    return {
      digitalFlopData: []
    }
  },
  methods: {
    createData () {
      const { randomExtend } = this
      this.digitalFlopData = [
        {
          title: '总社区数',
          number: {
            // number: [randomExtend(400, 500)],
			number: [8],
            content: '{nt}',
            textAlign: 'center',
            style: {
              fill: '#4d99fc',
              fontWeight: 'bold'
            },
          },
          path: '/community/agency'
        },
        {
          title: '总小区数',
          number: {
            // number: [randomExtend(20, 30)],
			number:[75],
            content: '{nt}',
            textAlign: 'center',
            style: {
              fill: '#f46827',
              fontWeight: 'bold'
            }
          },
          path: '/community/residential'
        },
        {
          title: '总单元数',
          number: {
            // number: [randomExtend(20, 30)],
			number: [689],
            content: '{nt}',
            textAlign: 'center',
            style: {
              fill: '#40faee',
              fontWeight: 'bold'
            }
          },
          path: '/community/unit'
        },{
          title: '总房间数',
          number: {
            number: [10352],
            content: '{nt}',
            textAlign: 'center',
            style: {
              fill: '#4d99fc',
              fontWeight: 'bold'
            }
          },
          path: '/community/room'
        },{
          title: '车位',
          number: {
            number: [12563],
            content: '{nt}',
            textAlign: 'center',
            style: {
              fill: '#f46827',
              fontWeight: 'bold'
            }
          },
          // path: '/community/gird'
        },{
          title: '总设备数',
          number: {
            number: [176],
            content: '{nt}',
            textAlign: 'center',
            style: {
              fill: '#40faee',
              fontWeight: 'bold'
            }
          },
          path: '/smartapplication/devicelist'
        },{
          title: '总人口数',
          number: {
            number: [37315],
            content: '{nt}',
            textAlign: 'center',
            style: {
              fill: '#4d99fc',
              fontWeight: 'bold'
            }
          },
          path: '/community/permanentPeople'
        },
        {
          title: '常住人口数',
          number: {
            number: [30212],
            content: '{nt}',
            textAlign: 'center',
            style: {
              fill: '#f46827',
              fontWeight: 'bold'
            }
          },
          path: '/community/permanentPeople'
        },
        {
          title: '外来人口数',
          number: {
            number: [7103],
            content: '{nt}',
            textAlign: 'center',
            style: {
              fill: '#40faee',
              fontWeight: 'bold'
            }
          },
          path: '/community/floatPeople'
        }


      ]
    },
    randomExtend (minNum, maxNum) {
      if (arguments.length === 1) {
        return parseInt(Math.random() * minNum + 1, 10)
      } else {
        return parseInt(Math.random() * (maxNum - minNum + 1) + minNum, 10)
      }
    },
    jump(item){
      this.$router.push({path:item.path})
    }
  },
  mounted () {
    const { createData } = this
    createData()
    setInterval(createData, 30000)
  },

}
</script>

<style lang="less">
#digital-flop {
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
  .rose-chart-title {
      height: 30px;
      font-weight: bold;
      font-size: 18px;
      display: flex;
      align-items: center;
    }
   .digtal-flop{
     position: relative;
     // height: 15%;
     flex-shrink: 0;
     flex-wrap: wrap;
     display: flex;
     justify-content: space-between;
     align-items: center;
   }
  .dv-decoration-10 {
    position: absolute;
    width: 95%;
    left: 2.5%;
    height: 5px;
    bottom: 0px;
  }
  .digital-flop-item {
    cursor: pointer;
    width: 30%;
    height: 30%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
  }
  .digital-flop-title {
    font-size: 16px;
    margin-bottom: 20px;
  }
  .digital-flop {
    display: flex;
    justify-content: center;
    align-items: center;
  }
  .unit {
    margin-left: 10px;
    display: flex;
    align-items: flex-end;
    box-sizing: border-box;
    padding-bottom: 13px;
  }
}
</style>
