<template>
  <div id="newsInfo">
    <el-row>
      <el-col :span="24" class="listRight" :style="`border-color:${Color}`">
        <el-col :span="24" class="topInfo">
          <el-col :span="12" class="top">
            <p :style="`color:${Color}`"><i class="el-icon-document"></i>{{ title }}</p>
          </el-col>
          <el-col :span="12" class="bread">
            <el-breadcrumb separator-class="el-icon-arrow-right">
              <el-breadcrumb-item :to="{ path: '/' }">网站首页</el-breadcrumb-item>
              <el-breadcrumb-item>信息列表</el-breadcrumb-item>
            </el-breadcrumb>
          </el-col>
        </el-col>
        <el-col :span="24" class="list">
          <el-col :span="24" class="rightList" v-for="(item, index) in newsList" :key="index">
            <el-col :span="5" class="image">
              <el-image style="width:150px;height:95px;" :src="item.pic" v-if="item.pic"></el-image>
              <el-image style="width:150px;height:95px;" :src="Nopic" v-else></el-image>
            </el-col>
            <el-col :span="19">
              <el-col :span="24">
                <el-col :span="20" class="title" @click.native="turnTo(item)">
                  <p class="textOver">{{ item.title }}</p>
                </el-col>
                <el-col :span="4" class="date">
                  {{ item.publish_time }}
                </el-col>
              </el-col>
            </el-col>
            <el-col :span="18" class="content textOvers">{{ item.abstract }} </el-col>
          </el-col>
        </el-col>
      </el-col>
      <el-col :span="24" class="page">
        <el-pagination @current-change="search" :current-page="currentPage" :page-size="pageSize" layout="total, prev, pager, next, jumper" :total="total">
        </el-pagination>
      </el-col>
    </el-row>
  </div>
</template>

<script>
export default {
  name: 'newsInfo',
  props: {
    newsList: null,
    Color: null,
    title: { type: String, default: '党员之家' },
    total: { type: Number, defaultl: 0 },
  },
  components: {},
  data: () => ({
    currentPage: 1,
    pageSize: 8,
    Nopic: require('@/assets/noPic.png'),
  }),
  created() {},
  computed: {},
  methods: {
    search(page) {
      let skip = (page - 1) * this.pageSize;
      this.$emit('search', { skip: skip, limit: this.pageSize });
    },
    turnTo(item) {
      let route = this.$route.path;
      if (route.includes('member')) this.$router.push({ path: '/memberDetail', query: { id: item.id } });
      else this.$router.push({ path: `/detail?id=${item.id}` });
    },
  },
};
</script>

<style lang="less" scoped>
p {
  padding: 0;
  margin: 0;
}
.textOver {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.textOvers {
  overflow: hidden;
  text-overflow: ellipsis;
  -webkit-line-clamp: 2;
  word-break: break-all;
  display: -webkit-box;
  -webkit-box-orient: vertical;
}
.listRight {
  height: 930px;
  border-left: 1px solid;
}
.topInfo {
  height: 47px;
  line-height: 47px;
}
.top {
  padding: 0 10px;
}
.top p {
  font-size: 24px;
}
.bread {
  padding: 16px 0px 16px 220px;
}
.dian {
  display: inline-block;
  width: 4px;
  height: 4px;
  background-color: #4f4f4f;
  border-radius: 90px;
  margin: 5px 8px;
}
.list {
  padding: 0 10px;
  height: 883px;
  overflow: hidden;
}
.rightList {
  height: 105px;
  margin: 0 0 6px 0;
  border-bottom: 1px dashed #ccc;
}
.rightList .image {
  width: 150px;
  height: 100px;
}
.rightList .title {
  padding: 10px;
}
.rightList .title p {
  font-size: 16px;
  color: #4f4f4f;
}
.rightList .date {
  font-size: 16px;
  color: #4f4f4f;
  padding: 10px 0;
}
.rightList .content {
  padding: 0 10px;
  height: 40px;
  overflow: hidden;
}
/deep/.rightList .content p {
  font-size: 14px;
  color: #4f4f4f;
  overflow: hidden;
  text-overflow: ellipsis;
  -webkit-line-clamp: 2;
  word-break: break-all;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  padding: 0;
  margin: 0;
}
.rightList:hover .title p {
  cursor: pointer;
  color: #0457c7;
}
.page {
  padding: 51px 0px;
  text-align: center;
}
</style>
