import Pannel from '@/components/pannel/index.vue';
import Lines from '@/components/charts/line/index.vue';
import { debtTrendAnalysis } from '../../../../api/index.js';
import { mapGetters } from 'vuex';
export default {
  components: {
    Lines,
    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;
        debtTrendAnalysis(this.deptId, this.year).then(res => {
          this.data = res.data;
          this.isLoad = true;
        })
      }
    }
  },
  data () {
    return {
      data: [],
      isLoad: false
    };
  }
};
