<template>
  <div class="record-item-container">
    <template v-if="data.length > 0">
      <div class="record-item" v-for="item in data" :key="item.id">
        <section class="record-item__left-section"></section>
        <section class="record-item__right-section">
          <span class="record-item__title">{{ item.title }}</span>
          <div class="record-item__footer">
            <span>{{ item.time }}</span>
            <span>{{ item.department }}</span>
          </div>
        </section>
      </div>
    </template>
    <template v-else>
      <div class="empty-container">
        <img :src="Empty" />
        <span>暂无数据</span>
      </div>
    </template>
  </div>
</template>
<script lang="ts" setup>
  interface recordData {
    id: number;
    title: string;
    time: string;
    department: string;
  }
  defineProps<{
    data: recordData[];
  }>();
  import Empty from 'assets/images/empty@1X.png';
</script>

<style lang="scss" scoped>
  .record-item-container {
    display: flex;
    flex-direction: column;
    gap: 20cpx;
    width: 100%;
    height: 100%;
  }
  .record-item {
    display: flex;
    gap: 12cpx;
    height: 90cpx;
    &__left-section {
      width: 90cpx;
      height: inherit;
      background: linear-gradient(90deg, #7ea7fe 0%, #a4cdc9 100%);
    }
    &__right-section {
      display: flex;
      flex-direction: column;
      justify-content: space-between;
      gap: 12cpx;
      flex: 1;
      height: 100%;
      padding-bottom: 6cpx;
      color: $text-color;
    }
    &__title {
      width: 100%;
      font-size: 16cpx;
      font-weight: 600;
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
    }
    &__footer {
      display: flex;
      flex-direction: column;
      gap: 2cpx;
      font-size: 12cpx;
      font-weight: 500;
      color: rgba($text-color, 0.45);
    }
  }
  .empty-container {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 5cpx;
    width: 100%;
    height: 100%;
    img {
      width: 100%;
    }
  }
</style>
