Przeglądaj źródła

考生导入修复

刘洋 8 miesięcy temu
rodzic
commit
acdb3e434d

BIN
build/icons/icon.ico


+ 1 - 0
src/render/views/BaseDataConfig/CardImport.vue

@@ -19,6 +19,7 @@
 
     <ImportCardDialog
       v-model="showImportCardDialog"
+      @success="toPage(1)"
       v-if="showImportCardDialog"
     ></ImportCardDialog>
   </div>

+ 1 - 0
src/render/views/BaseDataConfig/ImportCardDialog.vue

@@ -55,6 +55,7 @@ const getFile = (file: any) => {
 const submitHandle = () => {
   form.value.formRef.validate().then(() => {
     importCard({ examId: userStore.curExam?.id, ...params }).then(() => {
+      emit("success");
       window.$message.success("导入成功");
       visible.value = false;
     });

+ 7 - 2
src/render/views/BaseDataConfig/StuImport.vue

@@ -2,7 +2,9 @@
   <div class="stu-import">
     <qm-low-form :fields="fields">
       <template #tip>
-        <div class="tip">导入参数设置为:考试年度 - 2024;考次 - 1</div>
+        <div class="tip">
+          导入参数设置为:考试年度 - {{ year }};考次 - {{ yearHalf }}
+        </div>
       </template>
     </qm-low-form>
     <a-table :data-source="dataList" :columns="columns" size="middle" bordered>
@@ -41,10 +43,13 @@ const showStuImportFileDialog = ref(false);
 const year = ref();
 const yearHalf = ref();
 const loading = ref(false);
+const fullYear = (num: number) => {
+  return String(num).length == 4 ? num : "20" + num;
+};
 const _getStuImportSet = () => {
   getStuImportSet({ examId: userStore.curExam?.id as number }).then(
     (res: any) => {
-      year.value = res?.year;
+      year.value = res?.year ? fullYear(res.year) : "";
       yearHalf.value = res?.yearHalf;
     }
   );

+ 15 - 9
src/render/views/BaseDataConfig/StuImportFileDialog.vue

@@ -25,6 +25,7 @@
       v-model:open="showProgressDialog"
       title="考生导入进度"
       @cancel="progressClose"
+      @ok="closeSubModal"
     >
       <p>{{ curFileName }}</p>
       <a-progress :percent="progress" :status="progressStatus" />
@@ -80,19 +81,19 @@ const submitHandle = () => {
 const watchProgress = (obj: { taskId: string }) => {
   if (!showProgressDialog.value) return;
   importStuProgress(obj).then((res: any) => {
-    if (res?.progress == 100 && res?.success) {
+    progress.value = res.progress || 0;
+    if (res?.progress == 100 && res?.status === "SUCCESS") {
       progressStatus.value = "success";
       errMsg.value = "";
       window.$message.success("导入成功");
+    } else if (res?.status === "FAILED") {
+      progressStatus.value = "exception";
+      errMsg.value = res?.errMsg || "";
     } else {
-      if (res?.errMsg) {
-        progressStatus.value = "exception";
-        errMsg.value = res?.errMsg;
-      } else {
-        setTimeout(() => {
-          watchProgress(obj);
-        }, 3000);
-      }
+      progressStatus.value = "active";
+      setTimeout(() => {
+        watchProgress(obj);
+      }, 3000);
     }
   });
 };
@@ -104,5 +105,10 @@ const progressClose = () => {
 const downloadTpl = () => {
   exportStu({ examId: userStore.curExam?.id });
 };
+const closeSubModal = () => {
+  if (progressStatus.value === "success") {
+    visible.value = false;
+  }
+};
 </script>
 <style lang="less" scoped></style>