ソースを参照

导入错误信息

zhuangyunsheng 1 年間 前
コミット
86eb378467
1 ファイル変更17 行追加7 行削除
  1. 17 7
      src/components/Upload/tableImport.vue

+ 17 - 7
src/components/Upload/tableImport.vue

@@ -41,11 +41,24 @@ export default {
         },
 
         success(res, file) {
+            this.loading && this.loading.close();
             let os = this.onSuccess(res, file);
             if (os != undefined && os == false) return false;
 
-            ElMessage.success("导入成功");
-            this.$emit("importSuc");
+            const hasSuc = res.findIndex(r => r.isSuccess) != -1;
+            const errorList = res.filter(r => !r.isSuccess);
+            if (!errorList.length) ElMessage.success("导入成功");
+            else {
+                const element = errorList.map(err => `<li>序号${err.index}:${err.errorMsg}</li>`).reduce((p, v) => p + v);
+                ElNotification.error({
+                    title: "导入文件未成功",
+                    duration: 0,
+                    dangerouslyUseHTMLString: true,
+                    message: `<ul style="max-height: calc(100vh - 90px);overflow: auto;">${element}</ul>`
+                })
+            }
+
+            hasSuc && this.$emit("importSuc");
             this.$refs.uploader.clearFiles();
         },
 
@@ -69,11 +82,8 @@ export default {
                 if (upRes.code == 200) {
                     this.loading.setText("导入中请等待…");
                     Folder.import(this.url, upRes.data.link).then(res => {
-                        this.loading.close();
-                        if (res.code == 200) {
-                            if (res.data.length) param.onError(`有${res.data.length}条数据导入失败,序号为: ${res.data.map(d => d.index).join()}`);
-                            else param.onSuccess(res.data);
-                        } else param.onError(res.msg || "未知错误");
+                        if (res.code == 200) param.onSuccess(res.data);
+                        else param.onError(res.msg || "未知错误");
                     }).catch(() => param.onError());
                 } else param.onError(upRes.msg || "未知错误");
             }).catch(() => param.onError());