<script setup lang="ts">
import type { ExperimentRecord } from '../types'
interface Props {
  experiment_id?: string
}
const props = defineProps<Props>()

const detail = $ref<ExperimentRecord>(inject('detail'))
const isEmpty = $computed(() => {
  return !props.experiment_id || !detail
})
</script>

<template>
  <el-empty description="暂无数据" v-if="isEmpty" />
  <template v-else>
    <div class="result-score" v-if="detail.status === 2">
      <h2>我的成绩</h2>
      <p class="t1">{{ parseFloat(detail.score) }}</p>
      <p class="t2">批改讲师：{{ detail.checker_user.real_name }}</p>
    </div>
    <h3>实验过程</h3>
    <ul class="picture-list">
      <li v-for="item in detail.pictures" :key="item.url">
        <img :src="item.url" />
        <p>截图时间：{{ item.upload_time }}</p>
        <div class="cover">
          <div class="cover-inner">
            <el-button type="primary" plain round>查看</el-button>
            <el-button type="primary" plain round>删除</el-button>
          </div>
        </div>
      </li>
    </ul>
  </template>
</template>

<style lang="scss" scoped>
.result-score {
  margin-bottom: 40px;
  text-align: center;
  h2 {
    font-size: 18px;
    font-weight: 400;
    line-height: 30px;
    color: #333333;
    text-align: center;
  }
  .t1 {
    margin: 20px auto 10px;
    padding-top: 64px;
    width: 80px;
    height: 110px;
    font-size: 24px;
    font-weight: bold;
    line-height: 1;
    color: #ffffff;
    background: url(@/assets/images/score_bg.png) no-repeat;
    background-size: contain;
    box-sizing: border-box;
  }
  .t2 {
    font-size: 14px;
    line-height: 24px;
    color: #666666;
  }
}
h3 {
  font-size: 16px;
  font-weight: 400;
  line-height: 27px;
  color: #333333;
}
.picture-list {
  li {
    position: relative;
    height: 200px;
    margin: 20px 0;
    img {
      width: 100%;
      height: 100%;
      object-fit: cover;
    }
    p {
      position: absolute;
      left: 0;
      right: 0;
      bottom: 0;
      padding: 0 10px;
      font-size: 14px;
      color: #fff;
      line-height: 30px;
      text-align: right;
      background-color: rgba(0, 0, 0, 0.5);
    }
    &:hover {
      .cover {
        display: block;
      }
    }
  }
  .cover {
    display: none;
    position: absolute;
    left: 0;
    right: 0;
    top: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.5);
  }
  .cover-inner {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    .el-button {
      width: 100px;
      margin: 10px 0;
    }
  }
}
</style>
