StudentStatus.vue 3.1 KB

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