import BlockValue from '@/components/value/index.vue';
import data from './data.js';
import { Resources } from '../../../api/index.js'
import { mapGetters } from 'vuex'
export default {
  components: {
    BlockValue
  },
  computed: {
    ...mapGetters(['year', 'deptId'])
  },
  watch: {
    year: {
      handler () {
        this.getData();
      },
      immediate: true, // 立即执行
    },
    deptId: {
      handler () {
        this.getData();
      },
      immediate: true, // 立即执行
    }
  },
  data () {
    return {
      data
    };
  },
  created () {
  },
  mounted () {
  },
  methods: {
    getData () {
      if (this.year, this.deptId) {
        this.isLoad = false;
        Resources(this.deptId, this.year).then(res => {
          this.data[0][0].value = res.data.nyd
          this.data[0][1].value = res.data.jsyd
          this.data[0][2].value = res.data.wlydjlm
          this.data[0][3].value = res.data.numNyd
          this.data[0][4].value = res.data.numJsyd
          this.data[0][5].value = res.data.numWlydjlm

          this.data = data
          this.isLoad = true;
        })
      }
    },
  }
};
