<template>
  <div class="record-item-container list-record" @click="dialogVisible = true">
    <img class="record-img" :src="imgUrl" alt="" />
    <div class="record-info">
      <div class="info-title">{{ disasterType }}</div>
      <div>
        <div class="info-time">{{ warnTime }}</div>
        <div class="info-source">{{ source }}</div>
      </div>
    </div>
  </div>
  <el-dialog v-model="dialogVisible" width="984" align-center class="record-dialog">
    <template #header>
      <div class="record-item-container">
        <img class="record-img dialog-record-img" :src="imgUrl" alt="" />
        <div class="record-info">
          <div class="info-title dialog-info-title">{{ disasterType }}</div>
          <div>
            <div class="info-time">{{ warnTime }}</div>
            <div class="info-source">{{ source }}</div>
          </div>
        </div>
      </div>
    </template>
    <div>{{ content ? content : '无发布内容详情' }}</div>
  </el-dialog>
</template>

<script lang="ts" setup>
  import { ref } from 'vue';
  import { ElDialog } from 'element-plus';

  defineProps<{
    imgUrl: string | undefined;
    disasterType: string | undefined;
    warnTime: string;
    source: string;
    content: string;
  }>();

  const dialogVisible = ref(false);
</script>

<style lang="scss" scoped>
  .record-item-container {
    height: 90px;
    display: flex;

    .record-img {
      width: 90px;
      height: 90px;
      border-radius: 2px;
      margin-right: 10px;
    }

    .dialog-record-img {
      margin-right: 25px;
    }

    .record-info {
      flex: 1;
      font-size: 12px;
      color: rgba(0, 0, 0, 0.45);
      display: flex;
      flex-direction: column;
      justify-content: space-between;
      overflow: hidden;

      .info-title {
        font-weight: 500;
        font-size: 16px;
        color: rgba(0, 0, 0, 0.85);
        overflow: hidden;
      }

      .dialog-info-title {
        font-size: 24px;
      }

      .info-time,
      .info-source {
        margin-bottom: 2px;
        overflow: hidden;
        white-space: nowrap;
        text-overflow: ellipsis;
      }
    }
  }

  .list-record {
    cursor: pointer;
    margin-bottom: 10px;
  }

  .list-record:hover {
    background-color: #f5f5f5;
  }
</style>
<style lang="scss">
  .record-dialog {
    padding: 30px;
    background-image: url('@/assets/images/disaster-overview/detail-bg.png');

    .el-dialog__close {
      font-size: 24px;
      color: #000;
    }

    .el-dialog__headerbtn {
      margin: 10px;
    }

    .el-dialog__header {
      padding: 0 0 30px 0;
      border-bottom: 1px solid #dcdfe6;
    }

    .el-dialog__body {
      height: 353px;
      margin-top: 30px;
      overflow: scroll;
      white-space: pre-wrap;
    }
  }
</style>
