| | |
| | | <div> |
| | | <el-upload |
| | | class="upload-demo" |
| | | :accept="uploadData.fileTyp" |
| | | :accept="uploadData.fileType" |
| | | :action="uploadImgUrl" |
| | | :limit="this.fileLength" |
| | | :on-exceed="handleExceed" |
| | |
| | | :before-upload="beforeFileUpload" |
| | | :file-list="fileList"> |
| | | <el-button size="small" type="primary">点击上传</el-button> |
| | | <div slot="tip" class="el-upload__tip" >只能上传{{ this.fileLength }}个文件,数量超过请删除已传附件重新上传</div> |
| | | <div slot="tip" class="el-upload__tip" > |
| | | 只能上传{{ this.fileLength }}个文件, |
| | | {{uploadData.fileType?('只支持上传【'+uploadData.fileType+'】类型文件'):''}} |
| | | 文件大小不能超过30MB, |
| | | 数量超过请删除已传附件重新上传 |
| | | </div> |
| | | </el-upload> |
| | | </div> |
| | | |
| | |
| | | // |
| | | beforeFileUpload(file) { |
| | | if(this.fileList && this.fileList.length >= this.fileLength){ |
| | | this.$message.error('只允许上传【'+this.fileLength+'w文件】') |
| | | this.$message.error('只允许上传【'+this.fileLength+'个文件】') |
| | | return false; |
| | | } |
| | | const isLt2M = file.size / 1024 / 1024 <= 30; // 检查文件大小是否小于30MB |
| | | if (!isLt2M) { |
| | | this.$message.error('上传文件大小不能超过 30MB!'); |
| | | return false; // 不允许上传超过指定大小的文件 |
| | | } |
| | | this.$emit('uploadBegin') |
| | | return true |
| | | } |