BreachImport.vue 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. <template>
  2. <my-quote
  3. message="注:系统已自动将所有考生违纪字段置为“0”,导入后会更新该字段,导入只更新导入的考生信息,其它考生不更新。"
  4. type="error"
  5. style="margin-bottom: 16px"
  6. >
  7. </my-quote>
  8. <a-table
  9. :columns="columns"
  10. :row-key="(record) => record.subjectCode"
  11. :data-source="dataList"
  12. :pagination="false"
  13. :loading="loading"
  14. bordered
  15. >
  16. <template #bodyCell="{ column, index }">
  17. <template v-if="column.dataIndex === 'operation'">
  18. <qm-button type="link" @click="onImport(index)">导入</qm-button>
  19. </template>
  20. </template>
  21. </a-table>
  22. <!-- ImportDialog -->
  23. <ImportDialog
  24. ref="importDialogRef"
  25. title="违纪导入"
  26. upload-url="/api/admin/student/breach/import"
  27. :upload-data="uploadData"
  28. download-btn-title="违纪导入模版"
  29. :download-handle="downloadHandle"
  30. />
  31. </template>
  32. <script setup lang="ts">
  33. import { ref, onMounted } from "vue";
  34. import { ExclamationCircleOutlined } from "@ant-design/icons-vue";
  35. import type { TableProps } from "ant-design-vue";
  36. import { message } from "ant-design-vue";
  37. import { BreachListItem } from "@/ap/types/resultExport";
  38. import { breachList, breachTemplateDownload } from "@/ap/resultExport";
  39. import { downloadByApi } from "@/utils/download";
  40. import { useUserStore } from "@/store";
  41. import ImportDialog from "@/components/ImportDialog/index.vue";
  42. defineOptions({
  43. name: "BreachImport",
  44. });
  45. const userStore = useUserStore();
  46. const loading = ref(false);
  47. const dataList = ref<BreachListItem[]>([]);
  48. const columns: TableProps["columns"] = [
  49. {
  50. title: "科目代码",
  51. dataIndex: "subjectCode",
  52. },
  53. {
  54. title: "科目名称",
  55. dataIndex: "subjectName",
  56. },
  57. {
  58. title: "已导入违纪考生数",
  59. dataIndex: "breachCount",
  60. width: "180px",
  61. },
  62. {
  63. title: "操作",
  64. dataIndex: "operation",
  65. width: "100px",
  66. customCell: () => {
  67. return {
  68. class: "operation-cell",
  69. };
  70. },
  71. },
  72. ];
  73. async function getData() {
  74. const res = await breachList({ examId: userStore.curExam.id });
  75. dataList.value = res || [];
  76. }
  77. const importDialogRef = ref();
  78. const uploadData = ref<Record<string, string>>({});
  79. async function onImport(index: number) {
  80. const record = dataList.value[index];
  81. uploadData.value = {
  82. examId: userStore.curExam.id,
  83. subjectCode: "",
  84. };
  85. importDialogRef.value?.open();
  86. }
  87. async function downloadHandle() {
  88. const res = await downloadByApi(() => breachTemplateDownload()).catch(
  89. (e: Error) => {
  90. message.error(e.message || "下载失败,请重新尝试!");
  91. }
  92. );
  93. if (!res) return;
  94. message.success("下载成功!");
  95. }
  96. onMounted(() => {
  97. dataList.value = [
  98. { subjectCode: "8956145235", subjectName: "语法基础", breachCount: 12 },
  99. ];
  100. // getData()
  101. });
  102. </script>