<script setup>
import { useRouter } from 'vue-router';
import LayoutCard from './LayoutCard.vue';

defineProps({
  gongyiData: {
    type: Array,
    default: []
  }
})

const router = useRouter()
const types = ['水质报警', '生化报警', '预测报警']
const toGongyi = (item) => {
  router.push('water-warn');
}

</script>

<template>
  <LayoutCard title="工艺管控助手" name="gongyi" width="100%">
    <template #headerRight>
      <RouterLink to="/water-warn" class="flex items-center space-x-[0.4rem] text-[14px]">
        <div class="jump-btn"></div>
      </RouterLink>
    </template>
    <div class="gongyi-wrap">
      <div class="gongyi-wrap-top gongyi-wrap-item">
        <span>告警类型</span>
        <span>告警信息</span>
        <span>触发时间</span>
      </div>
      <ul class="gongyi-wrap-list">
        <li class="gongyi-wrap-item" v-for="item in gongyiData" @click="toGongyi">
          <span>{{ types[item.type] }}</span>
          <span>{{ item.reason }}</span>
          <span>{{ item.time }}</span>
        </li>
      </ul>
    </div>
  </LayoutCard>
</template>

<style scoped lang="scss">
.jump-btn {
  display: inline-block;
  width: 50px;
  height: 20px;
}

.gongyi-wrap {
  padding: 12px;

  &-list {
    height: 100px;
    overflow-y: auto;

    &::-webkit-scrollbar {
      width: 0px !important;
    }
  }

  &-item {
    margin-bottom: 10px;
    padding: 10px 12px;
    display: flex;
    line-height: 14px;
    background: rgba(97, 163, 217, 0.10);
    justify-content: space-between;
    align-items: center;
    color: #fff;
    cursor: pointer;
    font-size: 14px;

    span {
      text-overflow: ellipsis;
      overflow: hidden;
      word-break: break-all;
      white-space: nowrap;
    }

    >span {
      flex: 1;
    }

    >span:nth-child(2) {
      text-align: center;
    }

    >span:last-child {
      text-align: right;
    }
  }

  &-top {
    background: rgba(13, 80, 135, 0.60);
    font-size: 14px;
    color: #fff;
    font-weight: bold;
  }

  .warning,
  &-item:hover {
    color: #F15A24;
  }

  &-top:hover {
    color: #fff;
  }
}

@media (min-height: 1070px) {
  .gongyi-wrap {
    padding: 12px 12px 0 12px;
    .gongyi-wrap-list {
      height: 134px;
    }
  }
}
</style>