<template>
  <div id="export">
    <el-row>
      <el-col :span="24" class="main">
        <el-col :span="24" class="leftTop">
          <span>|</span> <span>{{ menuName }}</span>
        </el-col>
        <el-col class="infoLeftList" :span="24" v-for="(item, index) in list" :key="index" @click.native="clickDetail(item.id)">
          <p>{{ item.publish_time || '暂无' }}</p>
          <p>
            <span class="textOver">{{ item.title }}</span>
            <span>{{ item.titlejj }}</span>
          </p>
        </el-col>
        <el-col :span="24" class="page">
          <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-row>
  </div>
</template>

<script>
import { mapState, createNamespacedHelpers } from 'vuex';
export default {
  name: 'export',
  props: {
    zhuantiList: { type: Array },
    total: { type: Number },
    menuName: null,
  },
  components: {},
  data: function() {
    return {
      currentPage: 1, //默认数据1
      pageSize: 5, //每页显示数据数量
      origin: [], //分割数据
      list: [], //显示数据列表
    };
  },
  created() {},
  methods: {
    searchPage(page = 1) {
      this.$set(this, `list`, this.origin[page - 1]);
    },
    handleCurrentChange(currentPage) {
      this.searchPage(currentPage);
    },
    // 详情
    clickDetail(id) {
      this.$emit('clickDetail', { columnName: '专家问诊', id: id });
    },
  },
  watch: {
    zhuantiList: {
      immediate: true,
      deep: true,
      handler(val) {
        if (val && val.length > 0) this.$set(this, `origin`, _.chunk(val, this.pageSize));
        this.searchPage();
      },
    },
  },
  computed: {
    ...mapState(['user']),
  },
  metaInfo() {
    return { title: this.$route.meta.title };
  },
};
</script>

<style lang="less" scoped>
.main {
  .leftTop {
    font-size: 18px;
    width: 96%;
    height: 41px;
    line-height: 35px;
    border-bottom: 1px solid #e5e5e5;
    position: relative;
    bottom: 1px;
    margin: 10px;
    font-weight: 600;
    color: #22529a;
  }
  .infoLeftList {
    float: left;
    width: 95%;
    border-bottom: 1px dashed #ccc;
    padding: 10px 0 10px 10px;
    height: 87px;
    margin: 0 0 0 5px;
  }
  .infoLeftList:hover p:last-child span:first-child {
    -webkit-transform: translateY(-3px);
    -ms-transform: translateY(-3px);
    transform: translateY(-3px);
    -webkit-box-shadow: 0 0 6px #999;
    box-shadow: 0 0 6px #999;
    -webkit-transition: all 0.5s ease-out;
    transition: all 0.5s ease-out;
    color: #005293;
    cursor: pointer;
  }
  .infoLeftList p:first-child {
    float: left;
    width: 20%;
    font-size: 15px;
    background: #044b79;
    text-align: center;
    color: #fff;
    font-weight: bold;
    padding: 4px 0px;
    margin: 0 0 0 5px;
  }
  .infoLeftList p:last-child {
    float: right;
    width: 70%;
    padding: 0 0 0 10px;
  }
  .infoLeftList p:last-child span:first-child {
    float: left;
    width: 90%;
    font-size: 18px;
  }
  .infoLeftList p:last-child span:last-child {
    float: left;
    width: 90%;
    font-size: 16px;
    overflow: hidden;
    text-overflow: ellipsis;
    -webkit-line-clamp: 2;
    word-break: break-all;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    margin: 5px 0 0 0;
    color: #666;
  }
}
.page {
  text-align: center;
  padding: 15px 0;
}
</style>
