From affe6023661288adb17d191145d45cf5b5efa87c Mon Sep 17 00:00:00 2001 From: jjLv <1981429112@qq.com> Date: Wed, 28 Aug 2024 17:04:34 +0800 Subject: [PATCH] =?UTF-8?q?bug=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/base/project/index.vue | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/src/views/base/project/index.vue b/src/views/base/project/index.vue index b62ecee..b3e4354 100644 --- a/src/views/base/project/index.vue +++ b/src/views/base/project/index.vue @@ -101,7 +101,7 @@ - + @@ -243,6 +243,18 @@ export default { }, }, methods: { + beforeUpload(file) { + const isJPG = file.raw.type === 'image/jpeg' || file.raw.type === 'image/png' || file.raw.type === 'image/jpg' + const isLt2M = file.size / 1024 / 1024 < 5 + // console.log(isJPG) + if (!isJPG) { + this.$message.error('上传图片只能是 JPG ,JPEG或 PNG 格式!') + } + if (!isLt2M) { + this.$message.error('上传图片大小不能超过 5MB!') + } + return isJPG && isLt2M + }, //单选操作-跨页 handlerSelect(val, row) { this.currentSelection.indexOf(row.projectId) === -1 @@ -370,8 +382,14 @@ export default { // 图片上传 handleChange(file, fileList) { console.log(file) + console.log(fileList) + if(this.beforeUpload(file)==false){ + fileList.splice(fileList.length-1,1) + } // this.$refs["form"].clearValidate() this.fileList = fileList; + + }, handleRemove(file, fileList) { let sum = 0 @@ -384,6 +402,7 @@ export default { console.log(this.delFileIdList) this.fileList.splice(sum, 1) }, + //上传组件-图片查看 picturePreview(file) { console.log(file) @@ -475,7 +494,7 @@ export default { }); return; } - this.$modal.confirm('是否确认删除项目名称为"' + projectId + '"的数据项?').then(function() { + this.$modal.confirm('是否确认删除项目部名称为"' + projectId + '"的数据项?').then(function() { return delProject(projectId); }).then(() => { this.getList();