<template>
  <ul class="gallery-wrap">
    <li v-for="(item, idx) in list" :key="idx" class="gallery-item" @click="fnMoveTo(item)">
      <div class="item">
        <figure class="img-wrap">
          <img v-if="!$isEmpty(item.thumbnail)" :src="item.thumbnail.filePath" :alt="item.sj + ' 썸네일'">
          <img v-else src="client/resources/images/img6.png" alt="Not found image">
        </figure>
        <div class="text-box">
          <h5 class="txt-center">{{ item.sj }}</h5>
          <div class="date mb-20">
           <ul>
              <li class="mb-5">생산연도 <b>{{ item.prdctnYear ? $formatPrdctnDate(item.prdctnYear) : '-' }}</b></li>
              <li>|</li>
              <li>등록 <b>{{ $dotFormatDate(item.rgsde) }}</b></li>
           </ul>
          </div>
          <ul class="category">
            <li v-for="(ctgry, ctgryIdx) of item.ctgrys" :key="ctgryIdx" class="category1">{{ ctgry.ctgryNm }}</li>
          </ul>
        </div>
      </div>
    </li>
  </ul>
</template>
<script>
export default {
  name: "GalleryStyleComponent",

  props: {
    typeText: {
      type: String,
      default: null
    },
    name: {
      type: String,
      default: 'P'
    },
    list: {
      type: Array,
      default: () => [],
    },
  },

  computed: {
    page() {
      switch (this.name) {
        case 'P':
          return 'PicHistoryDetail';
        case 'V':
          return 'VideoHistoryDetail';
        case 'M':
          return 'MediaVideoDetail';
        case 'N':
          return 'NewsReleaseDetail';
      }
    },
  },

  methods: {
    // 페이지 이동
    fnMoveTo(item) {
      let key = null;
      switch (this.name) {
        case 'P':
        case 'V':
          key = 'dcryId';
          break;
        case 'M':
          key = 'mediaVidoId';
          break;
        case 'N':
          key = 'nesDtaId';
          break;
      }
      this.$router.push({ name: this.page, query: { id: item[key] } });
    }
  },
};
</script>