<script setup lang="ts" name="ExamCard">
import { ref, reactive, computed, onMounted } from 'vue'
// import teacher from '@/assets/image/train/teacher.png'
import { useDict } from '@/common/utils/dict'
const { examination_type, examination_status } = useDict('examination_type', 'examination_status')
const props = defineProps<{
  item: any
}>()
const emit = defineEmits<{
  'to-exam': [val: any],
  'to-exam-again': [val: any],
  'cat-score': [val: any]
}>()
function toExam() {
  emit('to-exam', props.item)
}

function toExamAgain() {
  emit('to-exam-again', props.item)
}
function catScore() {
  emit('cat-score', props.item)
}
</script>

<template>
  <div class="supply-card-container">
    <!-- <div class="left">
      <img class="item-img" :src="item.courseImage" alt="">
    </div> -->
    <div class="right">
      <div class="title">
        {{ item.examinationName }}
        <!-- <dict-tag :options="examination_type" :value="item.examinationType"/> -->

        <DictTag
          v-if="item.examinationStatusMine"
          :options="examination_status"
          :value="item.examinationStatusMine" />
      </div>
      <div class="bottom">
        <div class="item">
          <div class="label">考试开始时间：</div>
          <div class="value">{{ item.examinationStartTime}}</div>
        </div>
        <div class="item">
          <div class="label">考试结束时间：</div>
          <div class="value">{{ item.examinationEndTime}}</div>
        </div>
        <div class="item">
          <div class="label">考试类型：</div>
          <DictTag
            style="color: rgba(37, 37, 37, 0.45);"
            v-if="item.examinationType"
            :tag="false"
            :options="examination_type"
            :value="item.examinationType" />
        </div>
        <div class="option-container">
          <van-button
            :disabled="!(item.realExaminationEndTime === null && item.examinationScore === null && ['2'].includes(item.examinationStatus) )"
            type="primary"
            size="mini"
            @click="toExam">去考试</van-button>
            &nbsp;
          <van-button
            :disabled="!(['1'].includes(item.isExamination)&&['1'].includes(item.isPass)&&item.examinationEndTime !== null)||item.repairExaminationScore !== null"
            type="primary"
            size="mini"
            @click="toExamAgain">去补考</van-button>
             &nbsp;
          <van-button
            :disabled="item.examinationScore === null"
            type="primary"
            size="mini"
            @click="catScore">查看成绩</van-button>
        </div>
      </div>
    </div>
  </div>
</template>

<style lang="less" scoped>
  .supply-card-container {
  margin-top: 32rpx;          /* 1.6rem → 32rpx */
  padding: 18rpx 16rpx;       /* 0.9rem → 18rpx, 0.8rem → 16rpx */
  background-color: #fff;
  overflow: hidden;
  border-radius: 24rpx;
  box-shadow: 0 4rpx 40rpx rgba(64, 103, 251, 0.14);
  display: flex;

  .right {
    flex: 1;
    margin-left: 16rpx;       /* 0.8rem → 16rpx */
    
    .title {
      font-size: 32rpx;       /* 1.6rem → 32rpx */
      font-weight: 500;
      color: rgba(37, 37, 37, 1);
      display: flex;
      justify-content: space-between;
    }
    
    .bottom {
      .item {
        display: flex;
        margin-top: 10rpx;    /* 0.5rem → 10rpx */
        align-items: center;
        
        .label {
          font-size: 28rpx;   /* 14px → 28rpx (1px ≈ 2rpx) */
          color: rgba(37, 37, 37, 1);
        }
        
        .value {
          font-size: 28rpx;   /* 14px → 28rpx (1px ≈ 2rpx) */
          color: rgba(37, 37, 37, 0.45);
        }
      }
      
      .option-container {
        display: flex;
        justify-content: flex-end;
      }
    }
  }
}
</style>
