import Pannel from '@/components/pannel/index.vue';
import Bar from '@/components/charts/bar/index.vue';
import { mapGetters } from 'vuex';
import { analysisOfLargeFundExpenditureWarning } from '../../../../api/index.js';
export default {
  components: {
    Bar,
    Pannel
  },
  computed: {
    ...mapGetters(['year', 'deptId'])
  },
  watch: {
    year: {
      handler () {
        this.getData();
      },
      immediate: true, // 立即执行
    },
    deptId: {
      handler () {
        this.getData();
      },
      immediate: true, // 立即执行
    }
  },
  data () {
    return {
      isLoad: false,
      data: []
    };
  },
  created () {
  },
  mounted () {
  },
  methods: {
    getData () {
      if (this.year, this.deptId) {
        this.isLoad = false;
        analysisOfLargeFundExpenditureWarning(this.deptId, this.year).then(res => {
          let arr = res.data.map(item => {
            return {
              name: item.name,
              value: item.value
            }
          })
          this.data = arr;
          this.isLoad = true;
        })
      }
    },
    openTable(){
      this.$emit('openTable','大额')
    }
  }
};
