<template>
  <div class="app-container container">
    <SearchBar ref="SearchBar" @search="loadData" />
    <Table :list="list" @getList="loadData" />
  </div>
</template>
<script>
import SearchBar from "../components/searchBar/index.vue";
import Table from "../components/table/index.vue";
import {
  getNewspaperList,
  getPeriodicalsList, //期刊
  getConferenceList, //会议
  getThesisList, //论文
} from "@/api/resource/index";
export default {
  components: {
    SearchBar,
    Table,
  },
  data() {
    return {
      list: {
        records: [],
        total: 0,
        size: 10,
        current: 1,
      },
    };
  },

  methods: {
    async loadData() {
      const { keyword, activeTab } = this.$refs.SearchBar;
      const { current, size } = this.list;
      const params = {
        keyword,
        pageNo: current,
        pageSize: size,
      };
      console.log("keyword", keyword);
      // const activeTab = this.
      // console.log(keyword, activeTab);
      // return
      let request;
      switch (activeTab) {
        case "报纸":
          request = getNewspaperList;
          break;
        case "期刊":
          request = getPeriodicalsList;
          break;
        case "会议":
          request = getConferenceList;
          break;
        case "论文":
          request = getThesisList;
          break;
      }
      let res = await request(params);
      if (res.code == 200) {
        this.lsit = res.data;
      }
    },
  },
};
</script>
<style lang="scss" scoped>
.container {
  background-color: #f7f8fa;
  padding: 20px 40px;
}
</style>
