import { mapGetters } from 'vuex';
import { ResourceList } from '../../../../../api/index.js';
const map = {
  '1': '农用地',
  '2': '建设用地',
  '3': '未利用地、林木'
}
export default {
  components: {
  },
  computed: {
    ...mapGetters(['year', 'deptId'])
  },
  watch: {
    year: {
      handler () {
        this.getData();
      },
      immediate: true, // 立即执行
    },
    deptId: {
      handler () {
        this.getData();
      },
      immediate: true, // 立即执行
    }
  },
  data () {
    return {
      tableData: []
    };
  },
  filters: {
    fmtresourceType: function (val) {
      return map[val]
    }
  },
  methods: {
    look (info) {
      if (info.attachments) {
        window.open(info.attachments.fileUrl)
      } else {
        return
      }
    },
    getData () {
      if (this.year, this.deptId) {
        this.isLoad = false;
        ResourceList(this.deptId, this.year).then(res => {
          this.tableData = res.rows;
          this.isLoad = true;
        })
      }
    },
  }
};
