<template>
  <div id="rightcont">
    <el-col class="zhengce">
      <el-col :span="24" class="btn"><el-button type="primary" size="mini" @click="back()">返回</el-button></el-col>
      <el-col :span="24" class="topTitle">
        {{ columnName }}
      </el-col>
      <el-col :span="24" class="info">
        <ul>
          <li v-for="(item, index) in contentList" :key="index" @click="$emit('fetch', item.id)">
            <el-col :span="21" class="title textOver">{{ item.name }}</el-col>
            <el-col :span="3" class="date">
              {{ item.meta && item.meta.createdAt ? new Date(item.meta.createdAt).toLocaleDateString() : '' || '' }}
            </el-col>
          </li>
        </ul>
        <el-col class="page" :span="24">
          <el-pagination
            @size-change="handleSizeChange"
            @current-change="handleCurrentChange"
            :current-page="currentPage"
            layout="total,  prev, pager, next, jumper"
            :total="total"
          >
          </el-pagination>
        </el-col>
      </el-col>
    </el-col>
  </div>
</template>

<script>
export default {
  name: 'rightcont',
  props: {
    columnName: null,
    contentList: null,
    total: null,
  },
  components: {},
  data: () => ({
    currentPage: 0,
    pageSize: 10,
  }),
  created() {},
  computed: {},
  methods: {
    handleSizeChange(pageSize) {
      // this.$emit('handleSizeChange', pageSize);
    },
    handleCurrentChange(currentPage) {
      console.log(currentPage);
      this.$emit('handleCurrentChange', { skip: (currentPage - 1) * this.pageSize, limit: this.pageSize, currentPage });
    },
    back() {
      history.back(-1);
    },
  },
};
</script>

<style lang="less" scoped>
ul {
  margin: 0;
}
li {
  padding: 0;
  margin: 0;
  color: #a8abb7;
}
.zhengce {
  height: 660px;
  padding: 20px;
  overflow: hidden;
}
.topTitle {
  font-size: 22px;
  color: #22529a;
  margin: 0 0 20px 0;
}
.info {
  height: 570px;
  overflow: hidden;
}
.info ul {
  height: 510px;
  overflow: hidden;
  padding: 0 0 0 20px;
}
.info ul li {
  float: left;
  width: 100%;
  padding: 0 0 13px 0;
}
.info ul li .title {
  font-size: 16px;
  color: #60636d;
}
.info ul li .date {
  font-size: 16px;
  color: #a8abb7;
  text-align: right;
}
.info ul li:hover {
  cursor: pointer;
}
.info ul li:hover .title {
  color: #22529a;
}
.info ul li:hover .date {
  color: #22529a;
}
.page {
  padding: 11px 0;
  text-align: center;
}
.btn {
  text-align: right;
}
</style>
