From 59aca8971dda67212fcc886f5c4ef60f119104e7 Mon Sep 17 00:00:00 2001 From: "382696293@qq.com" <382696293@qq.com> Date: Tue, 27 Feb 2024 11:36:09 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90ID1000422=E3=80=91=E4=BB=AA=E5=99=A8?= =?UTF-8?q?=E7=AE=A1=E7=90=86-=E4=BB=AA=E5=99=A8=E5=88=97=E8=A1=A8-?= =?UTF-8?q?=E6=96=B0=E5=A2=9E=E6=89=8B=E5=86=99=E7=BB=91=E5=AE=9A=E4=BB=8B?= =?UTF-8?q?=E7=BB=8D=E8=A7=86=E9=A2=91/=E5=9B=BE=E7=89=87=E3=80=81?= =?UTF-8?q?=E6=89=AB=E7=A0=81=E7=BB=91=E5=AE=9A=E4=BB=8B=E7=BB=8D=E8=A7=86?= =?UTF-8?q?=E9=A2=91/=E5=9B=BE=E7=89=87=E4=B8=8A=E4=BC=A0=E5=A4=A7?= =?UTF-8?q?=E4=BA=8E10M=EF=BC=8C=E6=88=96=E5=B0=8F=E4=BA=8E10M=E7=9A=84?= =?UTF-8?q?=E8=A7=86=E9=A2=91=EF=BC=8C=E5=A4=A7=E4=BA=8E1M=EF=BC=8C?= =?UTF-8?q?=E6=88=96=E5=B0=8F=E4=BA=8E1M=E7=9A=84=E5=9B=BE=E7=89=87?= =?UTF-8?q?=EF=BC=8C=E5=9D=87=E6=8F=90=E7=A4=BA=EF=BC=9A=E4=B8=8A=E4=BC=A0?= =?UTF-8?q?=E6=96=87=E4=BB=B6=E5=A4=A7=E5=B0=8F=E4=B8=8D=E8=83=BD=E8=B6=85?= =?UTF-8?q?=E8=BF=87=201=20MB!?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/views/system/instrument/index.vue | 42 ++++++++++++------- 1 file changed, 27 insertions(+), 15 deletions(-) diff --git a/flossom-ui/src/views/system/instrument/index.vue b/flossom-ui/src/views/system/instrument/index.vue index 7d613b0..e9babda 100644 --- a/flossom-ui/src/views/system/instrument/index.vue +++ b/flossom-ui/src/views/system/instrument/index.vue @@ -1291,13 +1291,21 @@ export default { components: { Treeselect, draggable }, props: { // 大小限制(MB) - fileSize: { + imageFileSize: { type: Number, default: 1, }, - fileType: { + imageFileType: { type: Array, - default: () => ["bmp", "gif", "jpg", "jpeg", "png", "mp4", "avi", "rmvb"], + default: () => ["bmp", "gif", "jpg", "jpeg", "png"], + }, + videoFileSize: { + type: Number, + default: 10, + }, + videoFileType: { + type: Array, + default: () => ["mp4", "avi", "rmvb"], }, pdfFileSize: { type: Number, @@ -1484,7 +1492,6 @@ export default { ], }, /** 初次护理规则 */ - imageFileType: ['png', 'jpg', 'jpeg', 'gif'], nurseIndex: 0, nurseList: [ { @@ -2494,21 +2501,26 @@ export default { // 上传前校检格式和大小 handleBeforeUpload(file) { // 校检文件类型 - if (this.fileType) { - const fileName = file.name.split('.'); - const fileExt = fileName[fileName.length - 1]; - const isTypeOk = this.fileType.indexOf(fileExt) >= 0; - if (!isTypeOk) { - this.$modal.msgError(`文件格式不正确`); + const fileName = file.name.split('.'); + const fileExt = fileName[fileName.length - 1]; + const isImageTypeOk = this.imageFileType.indexOf(fileExt) >= 0; + const isVideoTypeOk = this.videoFileType.indexOf(fileExt) >= 0; + if (!(isImageTypeOk || isVideoTypeOk)) { + this.$modal.msgError(`文件格式不正确`); + return false; + } + // 校检文件大小 + if(isImageTypeOk) { + const isLt = file.size / 1024 / 1024 < this.imageFileSize; + if (!isLt) { + this.$modal.msgError(`上传图片大小不能超过 ${this.imageFileSize} MB!`); return false; } } - - // 校检文件大小 - if (this.fileSize) { - const isLt = file.size / 1024 / 1024 < this.fileSize; + if(isVideoTypeOk) { + const isLt = file.size / 1024 / 1024 < this.videoFileSize; if (!isLt) { - this.$modal.msgError(`上传文件大小不能超过 ${this.fileSize} MB!`); + this.$modal.msgError(`上传视频大小不能超过 ${this.videoFileSize} MB!`); return false; } }