<template>
  <div class="p-2 border-b-4" v-if="!!seletedEmeil.receivedDate">
    <p class="font-bold text-lg leading-6">{{ seletedEmeil.sender }}</p>
    <p class="text-xs leading-5 text-gray-900">{{ seletedEmeil.subject }}</p>
    <p class="text-xs leading-5 text-gray-500">
      <span class="text-gray-900">收件人：</span>
      {{ seletedEmeil.resiver }}
    </p>
    <p class="text-xs leading-5 text-gray-500">
      <span class="text-gray-900">收件时间：</span>
      {{ seletedEmeil.receivedDate }}
    </p>
    <p class="text-xs leading-5 text-gray-900">
      附件：
      <template v-for="path in files">
        <a target="_blank" :href="'/api/sys/static/' + path" class="mr-1.5 text-gray-500 hover:underline hover:text-sky-700">{{ path }}</a>
      </template>
    </p>
    
  </div>
  <iframe class="w-full flex-1" :srcdoc="seletedEmeil?.content" frameborder="0"></iframe>
</template>

<script lang="ts">
import { computed, defineComponent } from 'vue'

export default defineComponent({
  props: {
    seletedEmeil: {
      type: Object,
      default: () => ({})
    }
  },
  setup(props) {
    const files = computed(() => props.seletedEmeil?.files.split(',') || [])

    return {
      files
    }
  }
})
</script>
