import Pannel from '@/components/pannel/index.vue';
import BlockIcon from '@/components/block-icon/index.vue';
import data from './data.js';
import { debtOverview } from '../../../../api/index.js';
import { mapGetters } from 'vuex';
export default {
  components: {
    BlockIcon,
    Pannel
  },
  computed: {
    ...mapGetters(['year', 'deptId'])
  },
  watch: {
    year: {
      handler () {
        this.getData();
      },
      immediate: true, // 立即执行
    },
    deptId: {
      handler () {
        this.getData();
      },
      immediate: true, // 立即执行
    }
  },
  data () {
    return {
      isLoad: false, // 是否加载完成
      data
    };
  },
  methods: {
    getData () {
      this.isLoad = false // 是否加载完成
      if (this.year, this.deptId) {
        debtOverview(this.deptId, this.year).then(res => {
          this.data.topData[0][0].value = res.data.zbdz
          this.data.topData[0][1].value = res.data.gfzl
          this.data.topData[1][0].value = res.data.zfzl
          this.data.topData[1][1].value = res.data.dfzl

          this.isLoad = true // 是否加载完成
        })
      }

    }
  }
};
