<template>
  <div
    :class="[
      'area-card',
      'is-hover',
      tag.length ? 'cursor-pointer' : 'cursor-not-allowed',
    ]"
    @click="handleClick"
  >
    <div class="banner">
      <img class="banner-img" :src="data.bigPath" />
    </div>
    <div class="content">
      <!-- 对接时间 -->
      <div class="w-full">
        <span class="time" v-if="tag.length">
          对接时间：{{ data.createTime | dateDayFormat }}
        </span>
      </div>
      <!-- name -->
      <span class="name">{{ data.areaName }}</span>
      <div class="flex gap-2" v-if="tag.length">
        <span class="item" v-for="(v, i) in tag" :key="i">{{ v }}</span>
      </div>
      <span class="item-2" v-else>等待对接</span>
    </div>
  </div>
</template>

<script>
export default {
  props: {
    data: {
      type: Object,
      default() {
        return {};
      },
    },
  },
  data() {
    return {};
  },
  computed: {
    tag() {
      if (this.data.tag) {
        return this.data.tag.split(",");
      } else {
        return [];
      }
    },
  },
  methods: {
    handleClick() {
      if (this.tag.length) {
        this.$emit("click", this.data);
        this.$router.push({
          name: "queueupreport",
          params: {
            siteId: this.data.siteId + "",
          },
        });
      }
    },
  },
};
</script>

<style lang="less" scoped>
.area-card {
  width: 100%;
  height: 150px;
  font-family: Source Han Sans CN;
  border-radius: 8px;
  position: relative;
  overflow: hidden;
  background: #fff;

  .banner {
    width: 100%;
    height: 110px;
    mask: linear-gradient(to top, transparent 0%, #000 20%);
    position: absolute;
    left: 0px;
    top: 0px;
    overflow: hidden;
    .banner-img {
      width: 100%;
      height: 100%;
      transition: all 0.5s;
    }
  }
  .content {
    width: 100%;
    height: 100%;
    padding: 10px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: space-between;
    position: absolute;
    left: 0px;
    top: 0px;
    z-index: 1;
  }
  .time {
    padding: 2px 10px;
    background: rgba(35, 35, 35, 0.1);
    border-radius: 4px;
    font-size: 14px;
    color: #ffffff;
  }
  .name {
    padding: 4px 10px;
    font-weight: bold;
    color: #ffffff;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 8px;
    position: relative;
    z-index: 1;
  }
  .item {
    padding: 4px 10px;
    font-weight: bold;
    background: rgba(8, 87, 232, 0.1);
    border-radius: 8px;
    color: #0857e8;
  }
  .item-2 {
    padding: 4px 10px;
    font-weight: bold;
    background: rgba(49, 64, 91, 0.1);
    border-radius: 8px;
    color: #6e7f9e;
  }
}
.is-hover {
  &:hover {
    .banner-img {
      transform: scale(1.1);
    }
  }
}
</style>
