<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="">
        <el-tag v-if="item.type == '普通促销'" size="mini" type="success" class="type">{{item.type}}</el-tag>
        <el-tag v-else size="mini" type="warning" class="type">{{item.type}}</el-tag>
      </div>
      <div class="bottom">
        <p class="title">{{item.promname}}</p>
        <p class="time">活动开始时间:<br/>{{item.createdate}}</p>
        <p class="time">活动结束时间:<br/>{{item.enddate}}</p>
      </div>
    </div>
  </div>
  <el-empty description="暂无数据" v-else></el-empty>
</template>

<script>
export default {
  name: 'list',
  data () {
    return {
      dialogVisible: false,
      currentItem:[]
    };
  },
  props: ['fileData'],
  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;
  position: relative;
}
.list-box .list .top img {
  width: 100%;
  height: 100%;
  border-radius: 4px 4px 0px 0px;
}
.list-box .list .top .type {
  position: absolute;
  left: 10px;
  top: 10px;
}
.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 .item img {
  vertical-align: middle;
}

.list-box .list .bottom .time {
  font-size: 12px;
  margin-bottom: 10px;

}
.list-box .list .bottom .time:last-child {
  margin-bottom: 0;
}
.el-empty {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%,-50%);
}

</style>
