import Pannel from '@/components/pannel/index.vue';
import ScrollTable from '@/components/scroll-table/index.vue';
import {mapGetters} from "vuex";
import { listDebtOrganizations } from '../../../../api/index.js';
export default {
  components: {
    ScrollTable,
    Pannel
  },
  computed: {
    ...mapGetters(['year', 'deptId'])
  },
  watch: {
    year: {
      handler () {
        this.getData();
      },
      immediate: true, // 立即执行
    },
    deptId: {
      handler () {
        this.getData();
      },
      immediate: true, // 立即执行
    }
  },
  data () {
    return {
      headers: ['组织名称', '负债总额(万元)', '资产总额(万元)', '负债率'],
      data: [
        ['组织名称', '负债总额', '资产总额', '负债率']
      ]
    };
  },
  methods: {
    getData () {
      if (this.year, this.deptId) {
        this.isLoad = false;
        listDebtOrganizations(this.deptId, this.year).then(res => {
          let data = res.rows.map(item => {
            return [item.name, item.fzze, item.zcze, item.zcfzl]
          })
          this.data = data;
          this.isLoad = true;
        })
      }
    },
    tabChange (info) {
      this.tabIndex = info.id;
      this.getData();
    }
  }
};
