From b4668a820cb11703613c59d6529898e230be0b28 Mon Sep 17 00:00:00 2001 From: zhanghua <314079846@qq.com> Date: 星期一, 04 八月 2025 14:57:18 +0800 Subject: [PATCH] bug修改 --- src/views/student/components/upload-student.vue | 107 +++++++++++++++++++++++++++++++++++++++++++++-------- 1 files changed, 90 insertions(+), 17 deletions(-) diff --git a/src/views/student/components/upload-student.vue b/src/views/student/components/upload-student.vue index cbc7afc..db23140 100644 --- a/src/views/student/components/upload-student.vue +++ b/src/views/student/components/upload-student.vue @@ -10,7 +10,7 @@ @fileSuccess="fatherMethod" @file-uploading="showUploadProcess" :type="'AUDIENCE'" - :action="'/dream_dev/player/importPlayer'" + :action="'/dream/player/importPlayer'" > <div class="uploading-btn-to"> <i class="iconfont iconAdd"></i> 涓婁紶 @@ -49,6 +49,7 @@ <script> import dragUpload from "@/components/drag-upload"; var self = null; +var eventSource = null; export default { inject: ["reload"], name: "Creation", @@ -59,7 +60,8 @@ hasAudience: false, progress: false, percentage: 0, - progressStatus: "" + progressStatus: "", + over: false }; }, components: { dragUpload }, @@ -72,57 +74,128 @@ this.hasAudience = false; }, fatherMethod(res, type) { - // if (res.falseLst === null) { + this.progress = false; + // if (res.falseLst === null || res.falseLst.length === 0) { // this.$message.success("涓婁紶鏁版嵁鎴愬姛"); // this.$emit("load-success"); - // } else if (res.falseLst.length >= 1) { + // } + // else { // let errortips = ""; // res.falseLst.map((item) => { - // errortips += (`${item.playerRoll}` + `${item.cause} \r\n`).replace('[]', ''); + // errortips += ( + // `${item.playerRoll}` + + // `${item.cause} </div><div style='line-height: 1.5;'>` + // ).replace("[]", ""); // }); // this.$message({ - // message: `瀵煎叆鏁版嵁鎴愬姛瀵煎叆${res.successNum}鏉�,閿欒淇℃伅:${errortips}`, + // dangerouslyUseHTMLString: true, + // message: `<div style='line-height: 1.5;'>瀵煎叆鏁版嵁鎴愬姛瀵煎叆${res.successNum || 0 + // }鏉�,閿欒淇℃伅:</div><div style='line-height: 1.5;'>${errortips}</div>`, // type: "error", // duration: 6000, + // showClose: true, // }); // } + + if (res.success) { + var ojb = JSON.parse(res.message); + if (ojb.falseLst === null) { + this.$message.success("涓婁紶鏁版嵁鎴愬姛"); + this.$emit("load-success"); + } else if (ojb.falseLst.length >= 1) { + let errortips = ""; + ojb.falseLst.map((item) => { + errortips += ( + `${item.playerRoll}` + + `${item.cause} </div><div style='line-height: 1.5;'>` + ).replace("[]", ""); + }); + this.$message({ + dangerouslyUseHTMLString: true, + message: `<div style='line-height: 1.5;'>瀵煎叆鏁版嵁鎴愬姛瀵煎叆${ojb.successNum || 0 + }鏉�,閿欒淇℃伅:</div><div style='line-height: 1.5;'>${errortips}</div>`, + type: "error", + duration: 6000, + showClose: true, + }); + } + } else { + this.$message.error(res.message); + } + if (res.falseLst === null) { + this.$message.success("涓婁紶鏁版嵁鎴愬姛"); + this.$emit("load-success"); + } else if (res.falseLst.length >= 1) { + let errortips = ""; + res.falseLst.map((item) => { + errortips += (`${item.playerRoll}` + `${item.cause} \r\n`).replace('[]', ''); + }); + this.$message({ + message: `瀵煎叆鏁版嵁鎴愬姛瀵煎叆${res.successNum}鏉�,閿欒淇℃伅:${errortips}`, + type: "error", + duration: 6000, + }); + } + + + setTimeout(function () { + if (eventSource) + eventSource.close() + }, 5 * 1000); + }, showUploadProcess() { - self.progress = true + self.progress = true; + self.percentage = 0.1; + self.progressStatus = ""; setTimeout(function () { - const eventSource = new EventSource('/dream_dev/sse-stream/' + JSON.parse(localStorage.getItem("selectStaff")).id); + eventSource = new EventSource( + "/dream/sse-stream/" + + JSON.parse(localStorage.getItem("selectStaff")).id + ); eventSource.onmessage = function (event) { - const res = JSON.parse(event.data) - self.percentage = parseInt(res.current * 100 / res.total) + const res = JSON.parse(event.data); + self.percentage = Math.floor((res.current / res.total) * 10000) / 100; + if (res.current == res.total) { - self.progressStatus = 'success' - if (res.falseLst === null) { + self.progressStatus = "success"; + if ((res.falseLst === null || res.falseLst.length === 0) && self.progress) { self.$message.success("涓婁紶鏁版嵁鎴愬姛"); self.$emit("load-success"); } else if (res.falseLst.length >= 1) { let errortips = ""; res.falseLst.map((item) => { - errortips += (`${item.playerRoll}` + `${item.cause} \r\n`).replace('[]', ''); + errortips += ( + `${item.playerRoll}` + + `${item.cause} </div><div style='line-height: 1.5;'>` + ).replace("[]", ""); }); self.$message({ - message: `瀵煎叆鏁版嵁鎴愬姛瀵煎叆${res.successNum}鏉�,閿欒淇℃伅:${errortips}`, + dangerouslyUseHTMLString: true, + message: `<div style='line-height: 1.5;'>瀵煎叆鏁版嵁鎴愬姛瀵煎叆${res.successNum || 0 + }鏉�,閿欒淇℃伅:</div><div style='line-height: 1.5;'>${errortips}</div>`, type: "error", duration: 6000, + showClose: true, }); } + + eventSource.close() + self.progress = false; } }; eventSource.onerror = function (err) { console.error("EventSource failed:", err); eventSource.close(); + // self.showUploadProcess(); }; - }, 3 * 1000); - } + }, 2 * 1000); + }, }, created() { - self = this + self = this; const selectStaff = JSON.parse(localStorage.getItem("selectStaff")); this.orgId = selectStaff.org.id; this.staffId = selectStaff.id; -- Gitblit v1.8.0