Commit 649098ec by chenwq

fix(DeliverList): 添加上传凭证文件类型校验

在上传凭证前增加文件类型检查,仅允许 jpg、jpeg、png 格式。同时将类型校验和大小校验的结果共同作为上传条件,避免无效文件上传。
1 parent 3d57c311
......@@ -200,6 +200,16 @@ export default {
},
beforeUpload(file) {
const isLt2M = file.size / 1024 / 1024 < 2
const typeList = ['image/jpeg', 'image/png', 'image/jpg']
const isType = typeList.includes(file.type)
if (!isType) {
this.$message({
message: '上传凭证只能是 jpg, jpeg, png 格式!',
type: 'error',
customClass: 'message-Z-zinde'
})
}
if (!isLt2M) {
this.$message({
message: '上传图片大小不能超过 2MB!',
......@@ -207,7 +217,7 @@ export default {
customClass: 'message-Z-zinde'
})
}
return isLt2M
return isLt2M && isType
},
handleRemove(file, fileList) {
this.uploadFileList = fileList
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!