<template>
  <div class="card-box card-box-list">
    <div class="card-box-title">预警列表</div>
    <ul class="card-box-list-content">
      <li
        class="card-box card-box-list-item"
        v-for="item in list"
        :key="item.warningId"
        @click="$emit('warnClick', item)"
      >
        <span class="icon icon-warn"></span>
        <span class="ellipsis card-box-list-item-user">
          {{ item.name }}
        </span>
        <span class="ellipsis early-warning-reason" :title="item.info">
          {{ item.info }}
        </span>
      </li>
    </ul>
  </div>
</template>

<script>
export default {
  name: "EarlyWarningList",
  props: {
    list: {
      type: Array,
      default: () => [],
    },
  },
};
</script>

<style lang="scss" scoped>
.ellipsis {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.card-box-list {
  padding: 0 10px 10px;
  list-style: none;
  .card-box-title {
    font-size: 14px;
    font-weight: bold;
    color: #ffffff;
    line-height: 1;
    padding: 20px 0;
  }
  .card-box-list-content {
    margin: 0;
    padding: 0;
    padding-right: 10px;
    height: 500px; // 7
    overflow-y: auto;
    .card-box-list-item {
      width: unset;
      background-color: #3f444d;
      padding: 10px;
      line-height: 1;
      display: flex;
      align-items: center;
      color: #fff;
      font-size: 12px;
      &:not(:last-child) {
        margin-bottom: 6px;
      }
      .icon {
        width: 24px;
        height: 24px;
      }
      .card-box-list-item-user {
        font-weight: bold;
        margin: 0 10px;
        width: 48px;
      }
      .early-warning-reason {
        color: #a1a8b3;
        margin-left: auto;
        flex: 1;
        text-align: right;
      }
    }
  }
}
</style>
