Newer
Older
CloudBrainNew / src / views / cityManage / components / mobileManage / components / mobileCaseBar.vue
<!--
 * @Description: 青少年犯罪趋势
 * @Author: 王晓颖
 * @Date: 2020-12-03 09:56:31
 -->
<template>
  <single-layout  title="案件趋势">
    <div style="width: 100%;height:100%;">
      <radio-group v-model="type"/>
      <simple-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 {fetchPipeCount} from '@/api/cityManage'
import RadioGroup from '../../../../../components/radioGroup/index1'
import SingleLayout from '@/components/layout/singleLayout'
import SimpleBarChart from '../../../../../components/barChart/simpleBarChart'
import mockData from '../../../../../../static/city.json'
export default {
  name: 'mobileCaseBar',
  components: {RadioGroup, SimpleBarChart, SingleLayout, ChartLayout, ColorfulBarChart},
  data () {
    return {
      type: 'week',
      options: {
        id: 'mobile_case_bar',
        height: '100%',
        width: '100%',
        unit: '件',
        xAxisData: ['周一', '周二', '周三', '周四', '周五', '周六', '周日'],
        seriesData: [0, 0, 0, 0, 0, 0, 0]
      }
    }
  },
  watch: {
    type: {
      handler (newval, oldval) {
        console.log('============', newval)

        if (newval === 'week') {
          this.options.xAxisData = ['周一', '周二', '周三', '周四', '周五', '周六', '周日']
          this.options.seriesData = mockData.urbanManagement.mobileCaseBar.week
        } else if (newval === 'month') {
          this.options.xAxisData = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12', '13', '14', '15', '16', '17', '18', '19', '20', '21', '22']
          this.options.seriesData = mockData.urbanManagement.mobileCaseBar.month
        }
      },
      immediate: true // 添加立即执行选项
    }
  },
  created () {
    this.getData()
  },
  methods: {
    getData () {
      // fetchPipeCount().then(response => {
      //   if (response.code === 200) {
      //     const data = response.data
      //     this.options.xAxisData = data.map(item => { return item.name })
      //     this.options.seriesData = data.map(item => { return item.value })
      //   }
      // })
      // this.type = 'week'
    }
  }
}
</script>

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

</style>