<template>
  <div class="info-list-container">
    <el-row :gutter="10" v-if="total > 0">
      <el-col
        class="evaluation-card-wrapper"
        v-for="item in dataList"
        :key="item.id"
        :span="24"
      >
        <el-card>
          <info-card
            :date="item.sendDate"
            :name="item.title"
            @click.native="detail(item)"
          />
        </el-card>
      </el-col>
    </el-row>
    <evaluation-empty class="mt10" v-else />
    <pagination
      v-show="total > queryParams.pageSize"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      :page-size="20"
      :pageSizes="[20, 40, 100]"
      @pagination="getList"
    />
  </div>
</template>
<script>
import infoCard from "./infoCard.vue";
import * as career from "@/api/webApi/career-news";

export default {
  components: { infoCard },
  props: {
    type: {
      type: String | Number,
      default: "",
    },
  },
  watch: {
    type(newVal, oldVal) {
      this.queryParams.pageNum = 1;
      this.getList();
    },
  },
  data() {
    return {
      queryParams: {
        pageNum: 1,
        pageSize: 20,
        tag: ''
      },
      dataList: [],
      total: 0,
    };
  },
  methods: {
    detail(item) {
      this.$emit("click", item);
    },
    getList() {
      if (!this.type) return;
      career.list({ ...this.queryParams, type: this.type }).then((res) => {
        console.log("career news list res", res);
        if (res.code == 200 || res.code == 0) {
          this.dataList = res.rows;
          this.total = res.total;
        } else {
          this.msgError(res.msg || "career news list 请求异常");
        }
      });
    },
  },
};
</script>
<style lang="scss" scoped>
</style>