import Pannel from '@/components/pannel/index.vue';
import ScrollTable from '@/components/scroll-table/index.vue';
import { contractPaymentDueWarning } from '../../../../api/index.js';
import { mapGetters } from 'vuex';
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,
      headers: ['合同编码', '合同名称', '预结款日期', '结款金额', '部门'],
      data: [['合同编码', '合同名称', '预结款日期', '结款金额', '部门']]
    };
  },
  created () {
  },
  mounted () {
  },
  methods: {
    getData () {
      if (this.year, this.deptId) {
        this.isLoad = false;
        contractPaymentDueWarning(this.deptId, this.year).then(res => {
          let data = res.data.map(item => {
            return [item.code, item.name, item.settlementDate, item.settlementAmount, item.deptName]
          })
          this.data = data;
          this.isLoad = true;
        })
      }
    },
  }
};
