import Pannel from '@/components/pannel/index.vue';
import ScrollTable from '@/components/scroll-table/index.vue';
import { analysisOfExcessiveDebt } from '../../../../api/index.js';
import { mapGetters } from 'vuex';
export default {
  components: {
    ScrollTable,
    Pannel
  },
  computed: {
    ...mapGetters(['year', 'deptId'])
  },
  watch: {
    year: {
      handler () {
        this.getData();
      },
      immediate: true, // 立即执行
    },
    deptId: {
      handler () {
        this.getData();
      },
      immediate: true, // 立即执行
    }
  },
  data () {
    return {
      isLoad: false,
      headers: ['经济组织名称', '债务金额', '债务率'],
      data: [['经济组织名称', '债务金额', '21%']]
    };
  },
  created () {
  },
  mounted () {
  },
  methods: {
    getData () {
      if (this.year, this.deptId) {
        this.isLoad = false;
        analysisOfExcessiveDebt(this.deptId, this.year, this.type).then(res => {
          let data = res.rows.map(item => {
            return [item.name, item.zwje, item.zwl]
          })
          this.data = data;
          this.isLoad = true;
        })
      }
    },
  }
};
