<template>
  <van-swipe-cell>
    <div class="relative flex space-x-10 p-10 mb-10 bg-[#fff] rounded-xl">
      <div class="w-147 h-109 border-box">
        <img
          :src="formatImgSrc(data?.tourismUrlsAfterConvert) || noteDraftCoverBg"
          class="w-full h-full shrink-0 object-cover"
        />
      </div>

      <div class="flex w-152 justify-between">
        <div class="pt-15">
          <div
            class="line-clamp-2 whitespace-normal break-words overflow-hidden truncate break-all text-xl font-semibold text-black-3"
          >
            {{ data?.projectTitle || '未命名草稿' }}
          </div>
          <div class="mt-10 text-sm text-black-9">
            {{ $dayjs(data?.updateTime).format('YYYY-MM-DD') }}
          </div>
        </div>
      </div>

      <div class="absolute top-1/2 right-0 -translate-y-1/2 z-1 w-11 h-10">
        <img class="w-full h-full" :src="left_arrow" alt="" />
      </div>
    </div>
    <template #right>
      <div class="pl-2 h-full">
        <van-button
          square
          text="继续写"
          @click="handleWrite"
          type="warning"
          class="delete-button"
        />
        <van-button
          square
          text="删除"
          @click="$emit('onDelete')"
          type="danger"
          class="delete-button"
        />
      </div>
    </template>
  </van-swipe-cell>
</template>

<script setup>
import noteDraftCoverBg from '~/assets/img/note-create/note_draft_cover_bg.jpg'
import left_arrow from '~/assets/img/note-create/left.svg'
const props = defineProps({
  data: {
    type: Object,
    default: () => ({})
  }
})

function handleWrite() {
  navigateTo({
    path: '/note-create',
    query: {
      id: props.data.id
    }
  })
}
</script>

<style lang="scss" scoped>
.delete-button {
  height: 100%;
}
</style>
