import Pannel from '@/components/pannel/index.vue';
import Block from '@/components/block/index.vue';
import data from './data.js';
import { assetLiabilityAnalysis } from '../../../../api/index.js';
import { mapGetters } from 'vuex';
export default {
  components: {
    Block,
    Pannel
  },
  computed: {
    ...mapGetters(['year', 'deptId'])
  },
  data () {
    return {
      isLoad: false,
      data
    };
  },
  watch: {
    year: {
      handler () {
        this.getData();
      },
      immediate: true, // 立即执行
    },
    deptId: {
      handler () {
        this.getData();
      },
      immediate: true, // 立即执行
    }
  },
  methods: {
    getData () {
      if (this.year, this.deptId) {
        this.isLoad = false;
        assetLiabilityAnalysis(this.deptId, this.year).then(res => {
          this.data[0][0].value = res.data.zc // 总资产（万元）
          this.data[0][1].value = res.data.fz // 总负债（万元）

          this.data[1][0].value = res.data.sr // 总收入（万元）
          this.data[1][1].value = res.data.zhc // 总支出（万元）
          this.isLoad = true;
        })
      }
    }
  }
};
