ota文件大小限制

This commit is contained in:
zyx.net
2023-03-29 14:22:50 +08:00
parent 2b750007e2
commit 387c4e036e
11 changed files with 20 additions and 9 deletions
+10 -1
View File
@@ -34,7 +34,7 @@
export default {
name: 'file',
props: ['disableds', 'disabled', 'thisFileUploadUrl','acceptcode', 'readonly', 'thisFileType', 'isUploadFile', 'isMultiple', 'restrictUploads', 'Uploadable'],
props: ['disableds', 'disabled', 'thisFileUploadUrl','size' ,'acceptcode', 'readonly', 'thisFileType', 'isUploadFile', 'isMultiple', 'restrictUploads', 'Uploadable'],
data() {
return {
visible: false,
@@ -98,6 +98,15 @@
return false
}
}
// 根据大小拦截
if(this.size){
const isLt2KB = file.size / 1024 /1024 < this.size
let name = file.name
if (!isLt2KB) {
this.$message.error(name + this.$t('uploadedfilelarger'))
return false
}
}
if (this.isMultiple) {
if ((this.myfileList && this.myfileList.length == 1) || this.myfileList && this.myfileList.length > 1) {
this.$message.warning(this.$t('onlyOnefileUploaded'))