import Pannel from '@/components/pannel/index.vue';
import ScrollTable from '@/components/scroll-table/index.vue';
import { mapGetters } from 'vuex';
import { listDebtOrganizations2 } 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 {
      isLoad: false,
      headers: ['组织名称', '债务总额(万元)', '资产总额(万元)', '债务率'],
      data: [
      ]
    };
  },
  created () {
  },
  mounted () {
  },
  methods: {
    getData () {
      if (this.year, this.deptId) {
        this.isLoad = false;
        listDebtOrganizations2(this.deptId, this.year).then(res => {
          let data = res.rows.map(item => {
            return [item.name, item.zwze, item.zcze, item.zczwl]
          })
          this.data = data;
          this.isLoad = true;
        })
      }
    },
  }
};
