import Pannel from '@/components/pannel/index.vue';
import ScrollTable from '@/components/scroll-table/index.vue';
import { mapGetters } from 'vuex';
import { rankingAnalysisOfNonStandardContractManagement } from '../../../../api/index.js';
export default {
  components: {
    ScrollTable,
    Pannel
  },
  computed: {
    ...mapGetters(['year', 'deptId'])
  },
  watch: {
    year: {
      handler () {
        this.getData();
      },
      immediate: true, // 立即执行
    },
    deptId: {
      handler () {
        this.getData();
      },
      immediate: true, // 立即执行
    }
  },
  data () {
    return {
      isLoad: false,
      data: [],
      headers: ['部门名称', '合同数量(个)', '排名']
    };
  },
  created () {
  },
  mounted () {
  },
  methods: {
    getData () {
      if (this.year, this.deptId) {
        this.isLoad = false;
        rankingAnalysisOfNonStandardContractManagement(this.deptId, this.year, 100).then(res => {
          let data = res.data.map(item => {
            return [item.name, item.value, item.index]
          })
          this.data = data
          this.isLoad = true;
        })
      }
    },
  }
};
