<template>
  <div class="list-box" v-if="fileData.length != 0">
    <div class="list" v-for="(item,index) in fileData" :key="index" @click="itemClick(item)">
      <div class="top">
        <img :src="getCover(item)" alt="">
      </div>
      <div class="bottom">
        <p class="title">{{item.title}}</p>
        <div class="icon-box">
          <div class="item">
            <img src="@/assets/see.png" alt="">
            <span>{{item.readcount}}</span>
          </div>
          <div class="item">
            <img src="@/assets/shark.png" alt="">
            <span>{{item.sharecount}}</span>
          </div>
          <div class="item">
            <img src="@/assets/refreshNum.png" alt="">
            <span>{{item.newcount}}</span>
          </div>
        </div>
        <div class="handle" v-if="isHandle">
          <slot name="edit" :data="item"></slot>
          <slot name="delete" :data="item"></slot>
        </div>
      </div>
    </div>
  </div>
  <el-empty description="暂无数据" v-else></el-empty>
</template>

<script>
export default {
  name: 'list',
  data () {
    return {
      dialogVisible: false,
      currentItem:[]
    };
  },
  props: ['fileData','isHandle'],
  computed: {
    
  },
  components: {
    
  },
  watch: {
  },
  created () {
  },
  methods: {
    //获取封面
    getCover(item) {
      let result = item.attinfos.find(item1 => item1.fileType == 'image')
      if(result) {
        return item.attinfos.find(item => item == result).cover        
      } else if(item.attinfos[0] && item.attinfos[0].subfiles[0]) {
        return item.attinfos[0].subfiles[0].url
      }else {
        return require('@/assets/video.png')
      }
      
    },
    itemClick (data) {
      this.$emit('listItemClick', data)
    },
    
  },
};
</script>

<style scoped>
* {
  box-sizing: border-box;
}
.list-box {
  width: 100%;
  display: flex;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
.list-box .list {
  width: 168px;
  margin: 0 30px 30px 0;
  border-radius: 4px;
  transition: all 0.2s ease-out;
  cursor: pointer;
}
.list-box .list:hover {
  box-shadow: 0px 3px 6px 1px rgba(0, 0, 0, 0.16);
}
.list-box .list .top {
  width: 100%;
  height: 120px;
  border-radius: 4px 4px 0px 0px;
}
.list-box .list .top img {
  width: 100%;
  height: 100%;
  border-radius: 4px 4px 0px 0px;
}
.list-box .list .bottom {
  width: 100%;
  padding: 16px;
  background: #ffffff;
  border-radius: 0px 0px 4px 4px;
  border: 1px solid #cccccc;
}
.list-box .list .bottom p:nth-child(1) {
  font-size: 14px;
  font-weight: 400;
  color: #333333;
  margin-bottom: 10px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.list-box .list .bottom .icon-box {
  display: flex;
  justify-content: space-between;
}
.list-box .list .bottom .icon-box .item {
  
}
.list-box .list .bottom .icon-box .item span {
  font-size: 10px;
  font-weight: 400;
  color: #999999;
  margin-left: 5px;
}
.list-box .list .bottom .icon-box .item img {
  vertical-align: middle;
}

.list-box .list .bottom .handle {
  display: flex;
  justify-content: space-around;
  font-size: 14px;
  font-weight: 400;
  color: #3874f6;
  margin-top: 16px;
}
.list-box .list .bottom .handle span {
  cursor: pointer;
}
.el-empty {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%,-50%);
}

</style>
