ImageFailed.vue 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. <template>
  2. <a-card class="image-fialed" :bordered="false">
  3. <template #title>
  4. <a-button @click="goback">
  5. <template #icon><SwapLeftOutlined /> </template>后退
  6. </a-button>
  7. <a-divider type="vertical" />
  8. <a-button type="primary" :loading="downloading" @click="onExport">
  9. <template #icon><ExportOutlined /></template>导出
  10. </a-button>
  11. </template>
  12. <a-table
  13. :columns="columns"
  14. :row-key="(record) => record.subjectCode"
  15. :data-source="dataList"
  16. :pagination="pagination"
  17. :loading="loading"
  18. size="middle"
  19. bordered
  20. >
  21. <template #bodyCell="{ column, text }">
  22. <template v-if="column.dataIndex === 'failed'">
  23. <span :class="text ? 'color-danger' : 'color-gray'">{{
  24. text ? "是" : "否"
  25. }}</span>
  26. </template>
  27. </template>
  28. </a-table>
  29. </a-card>
  30. </template>
  31. <script setup lang="ts">
  32. import { ref, reactive, onMounted } from "vue";
  33. import { useRoute, useRouter } from "vue-router";
  34. import type { TableProps } from "ant-design-vue";
  35. import { message } from "ant-design-vue";
  36. import { SwapLeftOutlined, ExportOutlined } from "@ant-design/icons-vue";
  37. import useTable from "@/hooks/useTable";
  38. import { ImageCheckFailedListItem } from "@/ap/types/imageCheck";
  39. import { imageCheckFailedList, imageCheckFailedExport } from "@/ap/imageCheck";
  40. // import { downloadByApi } from "@/utils/download";
  41. import useLoading from "@/hooks/useLoading";
  42. defineOptions({
  43. name: "ImageFailed",
  44. });
  45. const router = useRouter();
  46. const route = useRoute();
  47. const columns: TableProps["columns"] = [
  48. {
  49. title: "科目代码",
  50. dataIndex: "subjectCode",
  51. width: "140px",
  52. },
  53. {
  54. title: "考点",
  55. dataIndex: "examSiteName",
  56. },
  57. {
  58. title: "校区",
  59. dataIndex: "campusName",
  60. width: "",
  61. },
  62. {
  63. title: "考场号",
  64. dataIndex: "examRoom",
  65. width: "",
  66. },
  67. {
  68. title: "有图片异常",
  69. dataIndex: "failed",
  70. width: "100px",
  71. },
  72. ];
  73. const searchModel = reactive({
  74. examId: Number(route.params.examId),
  75. subjectCode: route.params.subjectCode,
  76. });
  77. const { dataList, pagination, loading } = useTable<ImageCheckFailedListItem>(
  78. imageCheckFailedList,
  79. searchModel,
  80. true
  81. );
  82. const { loading: downloading, setLoading } = useLoading();
  83. async function onExport() {
  84. if (downloading.value) return;
  85. setLoading(true);
  86. const res = await imageCheckFailedExport(searchModel).catch((e: Error) => {
  87. message.error(e.message || "下载失败,请重新尝试!");
  88. });
  89. setLoading(false);
  90. if (!res) return;
  91. message.success("下载成功!");
  92. }
  93. function goback() {
  94. router.back();
  95. }
  96. onMounted(() => {});
  97. </script>
  98. <style lang="less" scoped>
  99. .image-fialed {
  100. box-shadow: none !important;
  101. }
  102. </style>