index.vue 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. <template>
  2. <div v-show="route.name === 'ImageCheck'" class="page-box">
  3. <a-table
  4. :columns="columns"
  5. :row-key="(record) => record.subjectCode"
  6. :data-source="dataList"
  7. :pagination="false"
  8. :loading="loading"
  9. bordered
  10. >
  11. <template #bodyCell="{ column, index }">
  12. <template v-if="column.dataIndex === 'operation'">
  13. <qm-button type="link" @click="onViewFailed(index)"
  14. >查看异常</qm-button
  15. >
  16. </template>
  17. </template>
  18. </a-table>
  19. </div>
  20. <router-view />
  21. </template>
  22. <script setup lang="ts">
  23. import { ref, onMounted } from "vue";
  24. import { useRoute, useRouter } from "vue-router";
  25. import type { TableProps } from "ant-design-vue";
  26. import { ImageCheckListItem } from "@/ap/types/imageCheck";
  27. import { imageCheckList } from "@/ap/imageCheck";
  28. import { useUserStore } from "@/store";
  29. defineOptions({
  30. name: "ImageCheck",
  31. });
  32. const userStore = useUserStore();
  33. const router = useRouter();
  34. const route = useRoute();
  35. const columns: TableProps["columns"] = [
  36. {
  37. title: "科目代码",
  38. dataIndex: "subjectCode",
  39. },
  40. {
  41. title: "科目名称",
  42. dataIndex: "subjectName",
  43. },
  44. {
  45. title: "异常数量",
  46. dataIndex: "failedCount",
  47. width: "180px",
  48. },
  49. {
  50. title: "操作",
  51. dataIndex: "operation",
  52. width: "100px",
  53. customCell: () => {
  54. return {
  55. class: "operation-cell",
  56. };
  57. },
  58. },
  59. ];
  60. const loading = ref(false);
  61. const dataList = ref<ImageCheckListItem[]>([]);
  62. async function getData() {
  63. const res = await imageCheckList({ examId: userStore.curExam.id });
  64. dataList.value = res || [];
  65. }
  66. function onViewFailed(index: number) {
  67. const record = dataList.value[index];
  68. router.push({
  69. name: "ImageFailed",
  70. params: {
  71. examId: userStore.curExam.id,
  72. subjectCode: record.subjectCode,
  73. },
  74. });
  75. }
  76. onMounted(() => {
  77. getData();
  78. });
  79. </script>