<template>
  <div class="image-item" @click="$emit('goDetail')">
    <img class="image" :src="imageUrl" alt="">
    <div class="info">
      <div class="info-subtitle">{{ imageName }}</div>
      <div class="info-title">{{ item.imageTitle }}</div>
      <div class="info-date">{{ item.uploadTime }}</div>
      <div class="info-tag">
        <el-tag size="small" >{{item.isOpen == 1 ? '公开':'私有'}}</el-tag>
        <el-tag size="small" v-if="item.keyWords" style="margin-left: 3px;">{{ item.keyWords }}</el-tag>
    </div>
    </div>
  </div>
</template>

<script>
export default {
  name: 'ImageItem',
  props: {
    item: {
      type: Object,
      default: () => ({})
    },
  },
  computed: {
    imageUrl() {
      let url = this.item.imagePath;
      if (this.item.file?.length > 0) {
        url = this.item.file[0].attachFileUrl || this.item.imagePath;
      }
      if (url.indexOf("http") === 0) {
          return url;
      }
      return process.env.VUE_APP_BASE_API + url;
    },
    imageName() {
      if (this.item.file?.length > 0) {
        return this.item.file[0].oldName || this.item.imageName;
      }
      return this.item.imageName;
    }
  },
  methods: {

  }
}
</script>

<style lang="scss" scoped>
  .image-item {
    border-radius: 10px;
    box-shadow: 0px 0px 8px #999999;
    overflow: hidden;

    .image {
      width: 100%;
      height: 200px;
    }

    .info {
      padding: 5px 10px 10px;

      .info-title {
        font-size: 18px;
        margin-top: 5px;
      }

      .info-subtitle {
        font-size: 14px;
        color: #999999;
      }

      .info-date {
        margin-top: 2px;
        font-size: 15px;
        color: #999999;
      }

      
    }

    .info-tag {
      margin-top: 4px;
      font-size: 16px;
      color: #409EFF;
      padding: 0 5px 4px;
      display: flex;
      justify-content: flex-end;
    }

  }
</style>