From c91d33e4ab58bdee9d4328adc2248495cc656c25 Mon Sep 17 00:00:00 2001 From: 疯狂的狮子li <15040126243@163.com> Date: 星期三, 18 八月 2021 19:15:03 +0800 Subject: [PATCH] update 优化 OSS 模块与上传组件 异常处理 --- ruoyi-ui/src/components/ImageUpload/index.vue | 32 +++++++++++++++++++------------- 1 files changed, 19 insertions(+), 13 deletions(-) diff --git a/ruoyi-ui/src/components/ImageUpload/index.vue b/ruoyi-ui/src/components/ImageUpload/index.vue index e074b38..ba088b9 100644 --- a/ruoyi-ui/src/components/ImageUpload/index.vue +++ b/ruoyi-ui/src/components/ImageUpload/index.vue @@ -118,9 +118,14 @@ }, // 涓婁紶鎴愬姛鍥炶皟 handleUploadSuccess(res) { - this.fileList.push({ name: res.data.fileName, url: res.data.url }); - this.$emit("input", this.listToString(this.fileList)); - this.loading.close(); + if (res.code == 200) { + this.fileList.push({ name: res.data.fileName, url: res.data.url }); + this.$emit("input", this.listToString(this.fileList)); + this.loading.close(); + } else { + this.$message.error(res.msg); + this.loading.close(); + } }, // 涓婁紶鍓峫oading鍔犺浇 handleBeforeUpload(file) { @@ -130,7 +135,7 @@ if (file.name.lastIndexOf(".") > -1) { fileExtension = file.name.slice(file.name.lastIndexOf(".") + 1); } - isImg = this.fileType.some(type => { + isImg = this.fileType.some((type) => { if (file.type.indexOf(type) > -1) return true; if (fileExtension && fileExtension.indexOf(type) > -1) return true; return false; @@ -163,7 +168,7 @@ this.$message.error(`涓婁紶鏂囦欢鏁伴噺涓嶈兘瓒呰繃 ${this.limit} 涓�!`); }, // 涓婁紶澶辫触 - handleUploadError() { + handleUploadError(res) { this.$message({ type: "error", message: "涓婁紶澶辫触", @@ -182,25 +187,26 @@ for (let i in list) { strs += list[i].url + separator; } - return strs != '' ? strs.substr(0, strs.length - 1) : ''; - } - } + return strs != "" ? strs.substr(0, strs.length - 1) : ""; + }, + }, }; </script> <style scoped lang="scss"> // .el-upload--picture-card 鎺у埗鍔犲彿閮ㄥ垎 ::v-deep.hide .el-upload--picture-card { - display: none; + display: none; } // 鍘绘帀鍔ㄧ敾鏁堟灉 ::v-deep .el-list-enter-active, ::v-deep .el-list-leave-active { - transition: all 0s; + transition: all 0s; } -::v-deep .el-list-enter, .el-list-leave-active { - opacity: 0; - transform: translateY(0); +::v-deep .el-list-enter, +.el-list-leave-active { + opacity: 0; + transform: translateY(0); } </style> -- Gitblit v1.9.3