Newer
Older
CloudBrainNew / src / views / cityManage / components / parkingSystem / parkDetail.vue
StephanieGitHub on 4 Feb 2021 2 KB first commit
<!--
 * @Description:各停车场车位占用情况:占用数、总车位、占用率
 * @Author: 王晓颖
 * @Date: 2020-10-13 14:32:19
 -->
<template>
  <div style="height: 100%;width:100%">
    <chart-layout title="各停车场车位占用情况" @click="getData">
      <div style="width: 100%;height:100%;padding:0.1rem">
        <scroll-board :config="boardConfig"/>
      </div>
      <Corner1 slot="corner"/>
    </chart-layout>
  </div>
</template>

<script>
import SimplePieChart from '@/components/pieChart/simplePieChart'
import Corner1 from '@/components/corner/Corner1'
import ChartLayout from '@/components/layout/chartLayout'
import {fetchOccupationByPark} from '@/api/cityManage'
import ScrollBoard from '@/components/board/ScrollBoard'
export default {
  name: 'parkDetail',
  components: {ScrollBoard, ChartLayout, Corner1, SimplePieChart},
  data () {
    return {
      boardConfig: {
        header: ['停车场', '车位总数', '车位占用数', '车位占用率'],
        rowNum: 7,
        hoverColor: true,
        headerBGC: 'transparent',
        oddRowBGC: '',
        evenRowBGC: '',
        headerColor: '#FFFFFF',
        rowColor: '#09f2ff',
        data: [
          ['停车场1', 231, 123, '80%'],
          ['停车场2', 231, 123, '80%'],
          ['停车场3', 231, 123, '80%'],
          ['停车场4', 231, 123, '80%'],
          ['停车场5', 231, 123, '80%'],
          ['停车场6', 231, 123, '80%'],
          ['停车场7', 231, 123, '80%'],
          ['停车场8', 231, 123, '80%'],
          ['停车场9', 231, 123, '80%'],
          ['停车场10', 231, 123, '80%']
        ]
      }
    }
  },
  created () {
    this.getData()
  },
  methods: {
    getData () {
      fetchOccupationByPark().then(response => {
        if (response.code === 200) {
          const data = response.data
          const list = data.map(item => {
            const radio = Math.round(item.already / item.total * 100)
            return [item.name, item.total, item.already, radio + '%']
          })
          this.boardConfig.data = list
          const boardConfig = this.boardConfig
          // this.$set(this, 'boardConfig', boardConfig)
          this.boardConfig = Object.assign({}, boardConfig)
        }
      })
    }
  }
}
</script>

<style rel="stylesheet/scss" lang="scss" scoped>

</style>