<script setup lang="ts" name="ExamCard">
import { ref, reactive, computed, onMounted } from 'vue'
import { getCompanyName } from '../../common/utils/transcoding'
import { useDict } from '@/common/utils/dict'
// import { showToast } from 'vant'
const { examination_type, train_status, questionnaire_type } = useDict('examination_type', 'train_status', 'questionnaire_type')
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() {
  if (!['1'].includes(props.item.isSubmit)) {
    // showToast('请先答题')
    uni.showToast({
      title: '请先答题',
      icon: 'none'
    })
    return
  }
  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="bottom" @click="catScore">
        <div class="item">
          <div class="label">所属公司：</div>
          <div class="value">{{ getCompanyName(item.belongCompany) }}</div>
        </div>
        <div class="item">
          <div class="label">问卷名称：</div>
          <div class="value">{{ item.questionnaireTitle}}</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="questionnaire_type"
            :value="item.examinationType" />
        </div>
        <div class="option-container">
          <!-- <van-button
            style="width:8rem"
            type="primary"
            size="small"
            round
            v-if="['1'].includes(item.isSubmit)"
            @click="catScore">详情</van-button> -->

          <!-- <van-button
            type="primary"
            size="mini"
            :disabled="['1'].includes(item.isSubmit)"
            @click="toExam">问卷答题</van-button> -->
          <uv-button
            style="width:8rem"
            type="primary"
            size="small"
            round
            :disabled="['1'].includes(item.isSubmit)"
            @click.stop="toExam">问卷答题</uv-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>
