Bug修复:【ID1000423】仪器管理-仪器列表-新增手写绑定介绍视频/图片和扫码绑定介绍视频/图片未校验上传类型,正常来说视频或图片应该不支持上传PDF文档格式

master
382696293@qq.com 2 years ago
parent c26a3f4d3f
commit 7abdf96ba3

@ -408,6 +408,7 @@
:on-success="manualUploadSuccess"
:on-error="uploadError"
:file-list="manualFile.fileList"
:before-upload="handleBeforeUpload"
>
<el-button size="small" type="primary">点击上传</el-button>
<div slot="tip" class="el-upload__tip">
@ -425,6 +426,7 @@
:on-success="scanUploadSuccess"
:on-error="uploadError"
:file-list="scanFile.fileList"
:before-upload="handleBeforeUpload"
>
<el-button size="small" type="primary">点击上传</el-button>
<div slot="tip" class="el-upload__tip">
@ -1502,6 +1504,15 @@ export default {
sortMode: [],
},
newModeOptionList: [],
fileType: {
type: Array,
default: () => ["bmp", "gif", "jpg", "jpeg", "png", "mp4", "avi", "rmvb"],
},
// (MB)
fileSize: {
type: Number,
default: 1,
},
}
},
created() {
@ -2430,6 +2441,29 @@ export default {
}
this.newModeOptionList = temp
},
//
handleBeforeUpload(file) {
//
if (this.fileType) {
const fileName = file.name.split('.');
const fileExt = fileName[fileName.length - 1];
const isTypeOk = this.fileType.default().indexOf(fileExt) >= 0;
if (!isTypeOk) {
this.$modal.msgError(`文件格式不正确`);
return false;
}
}
//
if (this.fileSize) {
const isLt = file.size / 1024 / 1024 < this.fileSize;
if (!isLt) {
this.$modal.msgError(`上传文件大小不能超过 ${this.fileSize.default} MB!`);
return false;
}
}
return true;
},
},
}
</script>

Loading…
Cancel
Save