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: [
        {
          date: '2016-05-02',
          name: '王小虎',
          address: '上海市普陀区金沙江路 1518 弄'
        },
        {
          date: '2016-05-04',
          name: '王小虎',
          address: '上海市普陀区金沙江路 1517 弄'
        },
        {
          date: '2016-05-01',
          name: '王小虎',
          address: '上海市普陀区金沙江路 1519 弄'
        },
        {
          date: '2016-05-03',
          name: '王小虎',
          address: '上海市普陀区金沙江路 1516 弄'
        }
      ]
    };
  },
  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;
        })
      }
    },
  }
};
