import Pannel from '@/components/pannel/index.vue';
import Block from '@/components/block/index.vue';
import data from './data.js';
import { mapGetters } from 'vuex';
import { lefttopMonetaryFundAnalysis } from '../../../../api/index.js';
export default {
  components: {
    Block,
    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;
        lefttopMonetaryFundAnalysis(this.deptId, this.year).then(res => {

          this.data[0][0].value = res.data.cke // 存款额
          this.data[0][1].value = res.data.ckzzs // 组织数

          this.data[1][0].value = res.data.xje // 现金额（万元）
          this.data[1][1].value = res.data.xjzzs
          this.isLoad = true;
        })
      }
    }
  },
  data () {
    return {
      isLoad: false, // 是否加载完成
      data
    };
  }
};
