<script setup lang="ts">
import { VideoPlay } from '@element-plus/icons-vue'
interface Props {
  data: any
}
defineProps<Props>()
</script>

<template>
  <div class="list-item">
    <div class="list-item-pic">
      <router-link :to="`/admin/lab/video/${data.id}`" target="_blank">
        <el-image :src="data.cover" fit="cover">
          <template #error>
            <img src="/images/video_poster.png" />
          </template>
        </el-image>
        <el-icon><VideoPlay /></el-icon>
      </router-link>
    </div>
    <div class="list-item-main">
      <p>{{ data.name }}</p>
      <div class="buttons">
        <router-link :to="`/admin/lab/video/${data.id}`" target="_blank" v-permission="'v1-teacher-video-view'">
          <el-button type="primary" auto-insert-space>查看</el-button>
        </router-link>
        <el-button
          plain
          auto-insert-space
          @click="$emit('clickEdit', data)"
          style="margin-left: 10px"
          v-permission="'v1-teacher-video-update'"
          >编辑</el-button
        >
      </div>
    </div>
  </div>
</template>

<style lang="scss" scoped>
.list-item {
  position: relative;
  height: 185px;
  transition: all 0.25s ease-in-out;
  border-radius: 6px;
  overflow: hidden;
  &:hover {
    overflow: unset;
    transform: scale(1.12);
    z-index: 1;
    .el-icon {
      display: block;
    }
    .list-item-main {
      top: 100%;
      bottom: unset;
      padding: 20px;
      background-color: #fff;
      p {
        color: #000;
      }
    }
    .buttons {
      display: block;
    }
  }
}
.list-item-pic {
  position: relative;
  height: 185px;
  .el-image {
    width: 100%;
    height: 100%;
  }
  .el-icon {
    display: none;
    font-size: 40px;
    color: #fff;
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
  }
}
.list-item-main {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 10px 16px;
  p {
    line-height: 1;
    color: #fff;
    white-space: nowrap;
    text-overflow: ellipsis;
    overflow: hidden;
  }
  .buttons {
    margin-top: 16px;
    display: none;
  }
}
</style>
