<template>
  <ul class="list-wrap">
    <li v-for="(item, idx) in list" :key="idx" class="mb-30" @click="fnMoveTo(item)">
      <div class="text-box">
        <h5>{{ item.sj }}</h5>
        <p v-if="item.hasOwnProperty('adres')" class="address">{{ item.adres }}</p>
        <div class="flex-sp-bw">
          <div class="mb-20">
            <ul class="category">
              <li v-for="(ctgry, idx3) of item.ctgrys" :key="idx3" class="category1">{{ ctgry.ctgryNm }}</li>
            </ul>
          </div>
          <div class="date ">
            <ul>
              <li>생산연도 <b>{{ item.prdctnYear ? $formatPrdctnDate(item.prdctnYear) : '-' }}</b></li>
              <li>|</li>
              <li>등록 <b>{{ $dotFormatDate(item.rgsde) }}</b></li>
            </ul>
          </div>
        </div>
      </div>
    </li>
  </ul>
</template>
<script>
export default {
  name: "ListStyleComponent",

  props: {
    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>