import Pannel from '@/components/pannel/index.vue';
import Pies from '@/components/charts/pies/index.vue';
import { debtOverviewAnalysis } from '../../../../api/index.js';
import { mapGetters } from 'vuex';
export default {
  components: {
    Pies,
    Pannel
  },
  computed: {
    ...mapGetters(['year', 'deptId'])
  },
  watch: {
    year: {
      handler () {
        this.getData();
      },
      immediate: true, // 立即执行
    },
    deptId: {
      handler () {
        this.getData();
      },
      immediate: true, // 立即执行
    }
  },
  methods: {
    getData () {
      if (this.year, this.deptId) {
        this.isLoad = false;
        debtOverviewAnalysis(this.deptId, this.year).then(res => {
          let data = [
            {
              name: '债务规模',
              value: res.data.zwgm,
              unit: '万'
            },
            {
              name: '负债规模',
              value: res.data.fzgm,
              unit: '万'
            },
            {
              name: '集体资产',
              value: res.data.jtzc,
              unit: '万'
            }
          ]
          this.data = data;
          this.isLoad = true;
        })
      }
    }
  },
  data () {
    return {
      isLoad: false,
      data: []
    };
  }
};
