<script setup lang="ts">
import { ref, watch } from "vue";
import { httpList } from "/@/api/components/examRecord";
import { modalProps } from "./types";
import { responseHandle } from "/@/utils/responseHandle";
import { useNav } from "/@/layout/hooks/nav";
const { logout } = useNav();
const props = defineProps(modalProps);
const code = ref("");
const options = ref([]);
defineExpose({
  code
});
async function getList(examCode) {
  const { code, data, message } = await httpList({ examCode });
  responseHandle({
    code,
    message,
    logout,
    handler: () => {
      options.value = data ?? [];
    }
  });
}
watch(
  () => props.examCode,
  newVal => {
    console.log(newVal);
    getList(newVal);

    // code.value = newVal;
  }
);
</script>

<template>
  <el-timeline>
    <el-timeline-item
      v-for="(si, sii) in options"
      :key="'examItem' + si.addtime + sii"
      :timestamp="si.addtime"
      placement="top"
    >
      <el-card>
        <h4>{{ si.action_name }}</h4>
        <p>{{ si.re }}</p>
      </el-card>
    </el-timeline-item>
  </el-timeline>
</template>
