<template>
  <div id="recruitLists">
    <el-row>
      <el-col :span="24" class="list">
        <el-col :span="24" class="topTitle">
          {{ columnName }}
        </el-col>
        <el-col :span="24">
          <el-table :data="list" style="width: 100%" border>
            <el-table-column label="名称" align="center">
              <template slot-scope="scoped">
                <el-tooltip effect="dark" content="点击显示详情" placement="left">
                  <el-col :span="24" @click.native="clickDetailcm(scoped.row)">{{ scoped.row.name }}</el-col>
                </el-tooltip>
              </template>
            </el-table-column>
            <el-table-column prop="infotype" label="信息类型" align="center"> </el-table-column>
            <el-table-column prop="user_name" label="发布人" align="center"> </el-table-column>
          </el-table>
          <el-col class="page" :span="24">
            <el-pagination
              @current-change="handleCurrentChange"
              :current-page="currentPage"
              layout="total, prev, pager, next, jumper"
              :total="total"
              :page-size="pageSize"
            >
            </el-pagination>
          </el-col>
        </el-col>
      </el-col>
    </el-row>
  </div>
</template>

<script>
import _ from 'lodash';
export default {
  name: 'recruitLists',
  props: {
    recruitData: null,
    columnName: null,
    total: null,
  },
  components: {},
  data: () => ({
    currentPage: 1,
    pageSize: 12,
    origin: [],
    list: [],
  }),
  created() {},
  computed: {},
  methods: {
    search(page = 1) {
      this.$set(this, `list`, this.origin[page - 1]);
    },
    handleCurrentChange(currentPage) {
      this.search(currentPage);
    },
    clickDetailcm(row) {
      this.$emit('detailcm', { data: row });
    },
  },
  watch: {
    recruitData: {
      immediate: true,
      deep: true,
      handler(val) {
        if (val && val.length > 0) this.$set(this, `origin`, _.chunk(val, this.pageSize));
        this.search();
      },
    },
  },
};
</script>

<style lang="less" scoped>
.list {
  height: 740px;
  padding: 20px;
  overflow: hidden;
}
.topTitle {
  font-size: 22px;
  color: #22529a;
  margin: 0 0 20px 0;
}
.info {
  height: 600px;
}
.page {
  padding: 11px 0 0 0;
  text-align: center;
}
</style>
