Ver código fonte

导入失败提示

qinchao 4 anos atrás
pai
commit
34f8a41afa
1 arquivos alterados com 29 adições e 9 exclusões
  1. 29 9
      src/modules/examwork/view/examIpLimit.vue

+ 29 - 9
src/modules/examwork/view/examIpLimit.vue

@@ -383,6 +383,19 @@
             </el-row>
           </el-form>
         </el-dialog>
+        <!-- 导入错误信息列表 -->
+        <el-dialog title="错误提示" :visible.sync="errDialog">
+          <div
+            v-for="errMessage in errMessages"
+            :key="errMessage.lineNum"
+            class="text-danger"
+          >
+            第{{ errMessage.lineNum }}行:{{ errMessage.msg }}
+          </div>
+          <span slot="footer" class="dialog-footer">
+            <el-button @click="errDialog = false">确定</el-button>
+          </span>
+        </el-dialog>
       </div>
     </div>
   </section>
@@ -478,6 +491,7 @@ export default {
       uploadAction: EXAM_WORK_API + "/exam/ipLimited/import",
       uploadData: {},
       fileLoading: false,
+      errDialog: false,
       fileList: [],
       uploadHeaders: {},
     };
@@ -737,15 +751,21 @@ export default {
       this.ipLimitImportDialog = true;
       this.initUpload();
     },
-    uploadSuccess() {
-      console.log("uploadSuccess");
-      this.$notify({
-        message: "上传成功",
-        type: "success",
-      });
-      this.fileLoading = false;
-      this.ipLimitImportDialog = false;
-      this.searchForm();
+    uploadSuccess(response) {
+      if (!response.hasError) {
+        this.$notify({
+          message: "上传成功",
+          type: "success",
+        });
+        this.fileLoading = false;
+        this.ipLimitImportDialog = false;
+        this.searchForm();
+      } else {
+        this.fileLoading = false;
+        this.ipLimitImportDialog = false;
+        this.errMessages = response.failRecords;
+        this.errDialog = true;
+      }
     },
     uploadError(response) {
       console.log("uploadError");