<template>
  <view class="bg-white">
    <view class="text-30 text-fore-title">{{ data.name }}</view>
    <view class="mt-32 flex items-center justify-between">
      <view class="text-24 text-fore-light">提交时间： {{ data.date || '-' }}</view>
      <view class="text-28 text-primary flex items-center gap-x-4" @click="handleDetail">
        <text>{{ isFinished ? '查看分析' : '继续考试' }}</text>
        <uv-icon name="arrow-right" size="14" color="var(--primary-color)" />
      </view>
    </view>
    <view
      class="mt-20 border border-solid border-[#FEF6DA] bg-[#FFFBEB] rounded-5 py-20 px-16 flex items-center justify-between">
      <view class="text-24 text-[#F59E0B]">考试科目：{{ data.subjectName }}</view>
      <view class="text-24 text-[#F59E0B]">卷面得分：{{ getScore }}</view>
    </view>
  </view>
</template>
<script lang="ts" setup>
import { Study, Transfer } from '@/types';
import { useTransferPage } from '@/hooks/useTransferPage';
import { EnumPaperType, EnumSimulatedRecordStatus } from '@/common/enum';
import { beginExaminee } from '@/api/modules/study';
const { transferTo } = useTransferPage<any, Transfer.SimulationAnalysisPageOptions | Transfer.ExamAnalysisPageOptions>();
const props = defineProps<{
  data: Study.SimulatedRecord;
}>();
const isFinished = computed(() => {
  return props.data.state === EnumSimulatedRecordStatus.SUBMIT;
});
const getScore = computed(() => {
  if (props.data.score === undefined || props.data.score === null) {
    return '-';
  }
  return props.data.score;
})
const handleDetail = () => {
  if (isFinished.value) {
    transferTo('/pagesStudy/pages/simulation-analysis/simulation-analysis', {
      data: {
        examineeId: props.data.id,
        paperType: EnumPaperType.SIMULATED
      }
    });
  } else {
    transferTo('/pagesStudy/pages/exam-start/exam-start', {
      data: {
        name: '模拟考试-' + props.data.subjectName,
        paperType: EnumPaperType.SIMULATED,
        readonly: false,
        simulationInfo: {
          examineeId: props.data.id,
        }
      }
    });
  }
};
</script>
<style lang="scss" scoped></style>