Newer
Older
CloudBrainNew / src / views / cityConstruction / components / projects / components / projectCountBar.vue
wangxitong on 29 Apr 2021 1 KB 0429 submit
<!--
 * @Description: 各行业项目数量
 * @Author: 王晓颖
 * @Date: 2020-12-01 15:23:01
 -->
<template>
  <single-layout title="各类项目数量">
    <div style="width: 100%;height:100%;padding-right:0.1rem">
      <colorful-bar-chart
        :id="options.id"
        :unit="options.unit"
        :height="options.height"
        :xAxisData="options.xAxisData"
        :seriesData="options.seriesData"
      />
    </div>
  </single-layout>
</template>

<script>
import ColorfulBarChart from '@/components/barChart/colorfulBarChart'
import ChartLayout from '@/components/layout/chartLayout'
import {fetchProjectCountByType} from '@/api/projectManage'
import SingleLayout from '@/components/layout/singleLayout'
import {getYear} from '@/utils/formatDate'
export default {
  name: 'projectCountBar',
  components: {SingleLayout, ChartLayout, ColorfulBarChart},
  data () {
    return {
      year: getYear(),
      options: {
        id: 'project_count_bar',
        height: '100%',
        width: '100%',
        unit: '项',
        xAxisData: ['园林项目', '市政项目', '交通项目', '水利项目', '建筑项目'],
        seriesData: [1, 1, 1, 1, 1, 1]
      }
    }
  },
  created () {
    this.getData()
  },
  methods: {
    getData () {
      fetchProjectCountByType(this.year).then(response => {
        if (response.code === 200) {
          const data = response.data
          this.options.xAxisData = data.map(item => { return item.type})
          this.options.seriesData = data.map(item => { return item.value })
        }
      })
    }
  }
}
</script>

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

</style>