import BlockValue from '@/components/value/index.vue';
import data from './data.js';
import { mapGetters } from 'vuex';
import { indicatorBelowAverage } from '../../../api/index.js';
export default {
  components: {
    BlockValue
  },
  data () {
    return {
      data
    };
  },
  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;
        indicatorBelowAverage(this.deptId, this.year).then(res => {
          this.data[0][0].value = res.data.cqtz
          this.data[0][1].value = res.data.dqtz
          this.data[0][2].value = res.data.ysk


          this.data[1][0].value = res.data.kcwz
          this.data[1][1].value = res.data.swzc
          this.data[1][2].value = res.data.gdzc
          this.data[1][3].value = res.data.wxzc
          this.data = data
          this.isLoad = true;
        })
      }
    }
  }
};
