<template>
  <view class="pb-30">
    <view v-if="examType === EnumExamRecordType.SIMULATED" class="px-30">
      <view class="sibling-border-top px-20 py-30" v-for="(item, index) in simulatedRecordList" :key="index">
        <ie-exam-record-item :data="item" />
      </view>
    </view>
    <template v-else>
      <template v-if="paperWorkRecordList.length > 0">
        <view class="sibling-border-top" v-for="(item, index) in paperWorkRecordList" :key="index">
          <paper-work-item :data="item" />
        </view>
      </template>
      <view v-else class="mt-50 mx-30 bg-[#F6F8FA] text-center py-50 text-26 text-fore-light rounded-5">暂无数据</view>
    </template>
  </view>
</template>
<script lang="ts" setup>
import { getSimulatedRecord, getPaperWorkList } from '@/api/modules/study';
import { EnumExamRecordType, EnumPaperWorkState } from '@/common/enum';
import IeExamRecordItem from '@/pagesStudy/components/ie-exam-record-item.vue';
import { Study } from '@/types';
import PaperWorkItem from '@/pagesStudy/components/paper-work-item.vue';
const props = defineProps({
  examType: {
    type: String,
    default: 'test'
  }
});
const simulatedRecordList = ref<Study.SimulatedRecord[]>([]);
const paperWorkRecordList = ref<Study.PaperWork[]>([]);
const loadData = async (type: string) => {
  simulatedRecordList.value = [];
  paperWorkRecordList.value = [];
  if (type === EnumExamRecordType.SIMULATED) {
    const { data } = await getSimulatedRecord();
    simulatedRecordList.value = data;
  } else {
    const { rows } = await getPaperWorkList({ state: EnumPaperWorkState.COMPLETED });
    paperWorkRecordList.value = rows;
  }
}

watch(() => props.examType, (newVal) => {
  loadData(newVal);
}, {
  immediate: false
});
onShow(() => {
  console.log(44)
});
onMounted(() => {
  console.log(4)
  loadData(props.examType);
});
</script>
<style lang="scss" scoped></style>