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
+1
View File
@@ -1739,4 +1739,5 @@ module.exports = {
verifyConformanceConfirmation:'Verify conformance confirmation', verifyConformanceConfirmation:'Verify conformance confirmation',
designConformanceVerification:'Design conformance verification', designConformanceVerification:'Design conformance verification',
nomorethan:'No more than 10', nomorethan:'No more than 10',
uploadedfilelarger:'The uploaded file is larger than 50 MB',
} }
+1
View File
@@ -1841,4 +1841,5 @@ module.exports = {
verifyConformanceConfirmation:'验证符合性确认', verifyConformanceConfirmation:'验证符合性确认',
designConformanceVerification:'设计符合性确认', designConformanceVerification:'设计符合性确认',
nomorethan:'不能超过10个', nomorethan:'不能超过10个',
uploadedfilelarger:'文件大于50M',
} }
+10 -1
View File
@@ -34,7 +34,7 @@
export default { export default {
name: 'file', 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() { data() {
return { return {
visible: false, visible: false,
@@ -98,6 +98,15 @@
return false 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.isMultiple) {
if ((this.myfileList && this.myfileList.length == 1) || this.myfileList && this.myfileList.length > 1) { if ((this.myfileList && this.myfileList.length == 1) || this.myfileList && this.myfileList.length > 1) {
this.$message.warning(this.$t('onlyOnefileUploaded')) this.$message.warning(this.$t('onlyOnefileUploaded'))
@@ -68,7 +68,7 @@
<a-button type="primary" style='width: 73px;margin-right: 50px' @click='last'>{{$t('last')}}</a-button> <a-button type="primary" style='width: 73px;margin-right: 50px' @click='last'>{{$t('last')}}</a-button>
<a-button type="primary" style='width: 73px' @click='next'>{{$t('next')}}</a-button> <a-button type="primary" style='width: 73px' @click='next'>{{$t('next')}}</a-button>
</div> </div>
<uploadFile ref="uploadFile" :acceptcode="'doc,docx,pdf'" @uploadSuccess="uploadSuccess"></uploadFile> <uploadFile ref="uploadFile" :acceptcode="'doc,docx,pdf'" :size="50" @uploadSuccess="uploadSuccess"></uploadFile>
</div> </div>
</template> </template>
@@ -83,7 +83,7 @@
}} }}
</a-button> </a-button>
<p>{{$t('noteone')}}</p> <p>{{$t('noteone')}}</p>
<uploadFile ref="uploadFile" :acceptcode="'csv'" @uploadSuccess="uploadSuccess"></uploadFile> <uploadFile ref="uploadFile" :acceptcode="'csv'" :size="20" @uploadSuccess="uploadSuccess"></uploadFile>
</a-form-model-item> </a-form-model-item>
</div> </div>
</a-col> </a-col>
@@ -162,7 +162,7 @@
<a-button type="primary" style='width: 73px;margin-right: 50px' @click='last'>{{$t('last')}}</a-button> <a-button type="primary" style='width: 73px;margin-right: 50px' @click='last'>{{$t('last')}}</a-button>
<a-button type="primary" style='width: 73px' @click='next'>{{$t('next')}}</a-button> <a-button type="primary" style='width: 73px' @click='next'>{{$t('next')}}</a-button>
</div> </div>
<uploadFile ref="uploadFile" :acceptcode="'doc,docx,pdf'" @uploadSuccess="uploadSuccess"></uploadFile> <uploadFile ref="uploadFile" :acceptcode="'doc,docx,pdf'" :size="50" @uploadSuccess="uploadSuccess"></uploadFile>
</div> </div>
</template> </template>
@@ -182,7 +182,7 @@
<a-button type="primary" style='width: 73px;margin-right: 50px' @click='last'>{{$t('last')}}</a-button> <a-button type="primary" style='width: 73px;margin-right: 50px' @click='last'>{{$t('last')}}</a-button>
<a-button type="primary" style='width: 73px' @click='next'>{{$t('next')}}</a-button> <a-button type="primary" style='width: 73px' @click='next'>{{$t('next')}}</a-button>
</div> </div>
<uploadFile ref="uploadFile" :acceptcode="'doc,docx,pdf'" @uploadSuccess="uploadSuccess"></uploadFile> <uploadFile ref="uploadFile" :acceptcode="'doc,docx,pdf'" :size="50" @uploadSuccess="uploadSuccess"></uploadFile>
</div> </div>
</template> </template>
@@ -103,7 +103,7 @@
<a-button type="primary" style='width: 73px;margin-right: 50px' @click='last'>{{$t('last')}}</a-button> <a-button type="primary" style='width: 73px;margin-right: 50px' @click='last'>{{$t('last')}}</a-button>
<a-button type="primary" style='width: 73px' @click='next'>{{$t('next')}}</a-button> <a-button type="primary" style='width: 73px' @click='next'>{{$t('next')}}</a-button>
</div> </div>
<uploadFile ref="uploadFile" @uploadSuccess="uploadSuccess"></uploadFile> <uploadFile ref="uploadFile" :acceptcode="'doc,docx,pdf'" :size="50" @uploadSuccess="uploadSuccess"></uploadFile>
</div> </div>
</template> </template>
@@ -47,7 +47,7 @@
<a-button type="primary" style='width: 73px;margin-right: 50px' @click='last'>{{$t('last')}}</a-button> <a-button type="primary" style='width: 73px;margin-right: 50px' @click='last'>{{$t('last')}}</a-button>
<a-button type="primary" style='width: 73px' @click='next'>{{$t('next')}}</a-button> <a-button type="primary" style='width: 73px' @click='next'>{{$t('next')}}</a-button>
</div> </div>
<uploadFile ref="uploadFile" :acceptcode="'doc,docx,pdf'" @uploadSuccess="uploadSuccess"></uploadFile> <uploadFile ref="uploadFile" :acceptcode="'doc,docx,pdf'" :size="50" @uploadSuccess="uploadSuccess"></uploadFile>
</div> </div>
</template> </template>
@@ -34,7 +34,7 @@
<a-button type="primary" style='width: 73px;margin-right: 50px' @click="last">{{ $t('last') }}</a-button> <a-button type="primary" style='width: 73px;margin-right: 50px' @click="last">{{ $t('last') }}</a-button>
<a-button type="primary" style='width: 73px' @click='next'>{{ $t('next') }}</a-button> <a-button type="primary" style='width: 73px' @click='next'>{{ $t('next') }}</a-button>
</div> </div>
<uploadFile ref="uploadFile" :acceptcode="'doc,docx,pdf'" @uploadSuccess="uploadSuccess"></uploadFile> <uploadFile ref="uploadFile" :acceptcode="'doc,docx,pdf'" :size="50" @uploadSuccess="uploadSuccess"></uploadFile>
</div> </div>
</template> </template>
@@ -99,7 +99,7 @@
<a-button type="primary" style='width: 73px' @click='next'>{{$t('next')}}</a-button> <a-button type="primary" style='width: 73px' @click='next'>{{$t('next')}}</a-button>
</div> </div>
<uploadFile ref="uploadFile" @uploadSuccess="uploadSuccess"></uploadFile> <uploadFile ref="uploadFile" @uploadSuccess="uploadSuccess"></uploadFile>
<uploadFileOta ref="uploadFileOta" :acceptcode="'doc,docx,pdf'" @uploadSuccess="uploadSuccessOta"></uploadFileOta> <uploadFileOta ref="uploadFileOta" :acceptcode="'doc,docx,pdf'" :size="50" @uploadSuccess="uploadSuccessOta"></uploadFileOta>
</div> </div>
</template> </template>