| | |
| | | > |
| | | <i class="el-icon-plus"></i> |
| | | </el-upload> |
| | | |
| | | |
| | | <!-- 上传提示 --> |
| | | <div class="el-upload__tip" slot="tip" v-if="showTip"> |
| | | 请上传 |
| | |
| | | // 删除图片 |
| | | handleRemove(file, fileList) { |
| | | const findex = this.fileList.map(f => f.name).indexOf(file.name); |
| | | this.fileList.splice(findex, 1); |
| | | this.$emit("input", this.listToString(this.fileList)); |
| | | if(findex > -1) { |
| | | this.fileList.splice(findex, 1); |
| | | this.$emit("input", this.listToString(this.fileList)); |
| | | } |
| | | }, |
| | | // 上传成功回调 |
| | | 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(); |
| | | } |
| | | }, |
| | | // 上传前loading加载 |
| | | handleBeforeUpload(file) { |
| | |
| | | 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; |
| | |
| | | this.$message.error(`上传文件数量不能超过 ${this.limit} 个!`); |
| | | }, |
| | | // 上传失败 |
| | | handleUploadError() { |
| | | handleUploadError(res) { |
| | | this.$message({ |
| | | type: "error", |
| | | message: "上传失败", |
| | |
| | | } |
| | | |
| | | ::v-deep .el-list-enter, .el-list-leave-active { |
| | | opacity: 0; |
| | | transform: translateY(0); |
| | | opacity: 0; |
| | | transform: translateY(0); |
| | | } |
| | | </style> |
| | | |