<!--
 * @Author: WangQiBiao
 * @Date: 2019-09-26 08:46:04
 * @LastEditors: wjc
 * @LastEditTime: 2025-11-18 09:48:09
 * @Description: 近1年应实收统计
 -->
<template>
  <div class="paid-in">
    <TitleCom>近12个月实收统计</TitleCom>
    <div class="map">
      <div class="map-item" id="paid"></div>
      <div class="map-item">
        <IncomeCom/>
      </div>
    </div>
  </div>
</template>
<script>
import TitleCom from '@/components/title'
import IncomeCom from './../income'
import * as echarts from 'echarts'
import { api } from '@/api'

export default {
  data () {
    return {
      yearTotal: []
    }
  },
  components: {
    TitleCom,
    IncomeCom
  },
  mounted () {
    api.getBillSumMonth().then(res => {
      this.yearTotal = res.data.data
      this.createMapPaid()
    })
  },
  methods: {
    createMapPaid () {
      var myChart = echarts.init(document.getElementById('paid'))
      var dataAxis = []
      var data = []
      if (this.yearTotal && this.yearTotal.length !== 0) {
        this.yearTotal.forEach(item => {
          dataAxis.push(item.type)
          data.push(item.total)
        })
      }
      var option = {
        name: '近12个月实收统计',
        legendHoverLink: true,
        grid: {
          top: 26,
          right: 0,
          bottom: 36
        },
        xAxis: {
          data: dataAxis,
          position: 'bottom',
          inverse: false,
          minInterval: 7,
          axisLine: { // 坐标轴
            show: true,
            lineStyle: {
              color: '#1C293F',
              width: 1
            }
          },
          axisTick: { // 坐标轴刻度
            show: false
          },
          axisLabel: { // 坐标轴label
            show: true,
            inside: false,
            rotate: 30,
            color: '#5774A2',
            fontWeight: 400
          },
          splitLine: { // x轴线
            show: true,
            interval: 1000,
            lineStyle: {
              type: 'solid',
              color: '#1C293F'
            }
          },
          splitArea: { // 分隔区域
            show: false,
            interval: 0,
            areaStyle: {
              opacity: 0.36
            }
          }
        },
        yAxis: {
          show: true,
          position: 'left',
          name: '单位(万元)',
          nameTextStyle: {
            color: '#5774A2',
            fontSize: 10,
            fontWeight: 400
          },
          axisLine: {
            show: true,
            lineStyle: {
              color: '#1C293F',
              width: 1
            }
          },
          axisTick: { // 坐标轴刻度
            show: false
          },
          axisLabel: { // 坐标轴label
            show: true,
            inside: false,
            // rotate: 30,
            color: '#5774A2',
            fontWeight: 400
          },
          splitLine: { // x轴线
            show: true,
            interval: 0,
            lineStyle: {
              type: 'solid',
              color: '#1C293F'
            }
          },
          splitArea: { // 分隔区域
            show: false,
            interval: 0,
            areaStyle: {
              opacity: 0.36
            }
          }
        },
        series: [
          {
            type: 'bar',
            barWidth: 20,
            label: {
              show: true,
              position: 'top',
              color: '#99C1EF'
            },
            itemStyle: {
              normal: {
                color: new echarts.graphic.LinearGradient(
                  0, 0, 0, 1,
                  [
                    { offset: 0, color: '#12BAC5' },
                    { offset: 1, color: '#2D32F0' }
                  ]
                )
              }
            },
            data: data
          }
        ]
      }
      myChart.setOption(option)
    }
  }
}
</script>
<style lang="scss" scoped>
@import './index.scss';
</style>
