diff --git a/src/components/upload/index.vue b/src/components/upload/index.vue index 3654125..eca6571 100644 --- a/src/components/upload/index.vue +++ b/src/components/upload/index.vue @@ -2,54 +2,59 @@
上传图片
- +
- \ No newline at end of file + diff --git a/src/views/Basic/Employee/depend/form.vue b/src/views/Basic/Employee/depend/form.vue index ab03540..e061194 100644 --- a/src/views/Basic/Employee/depend/form.vue +++ b/src/views/Basic/Employee/depend/form.vue @@ -77,6 +77,7 @@ :file-list="idcardfileList" @preview="handlePreview" @change="idcardhandleChange" + :beforeUpload='beforeUpload' >
@@ -133,6 +134,7 @@ :file-list="fileList" @preview="handlePreview" @change="fileChange" + :beforeUpload='beforeUpload' > 点击上传 @@ -379,6 +381,15 @@ export default { fileChange(info) { this.fileList = info.fileList }, + beforeUpload(f, l) { + const isLt50M = f.size / 1024 / 1024 < 50; + if (!isLt50M) { + this.$message.error(f.name + "文件大小超出限制,请修改后重新上传"); + return false; + } else { + return true; + } + }, }, watch: { editId: { diff --git a/src/views/Basic/EstateInfo/_buildingManage/depend/form.vue b/src/views/Basic/EstateInfo/_buildingManage/depend/form.vue index 1762372..dfa3234 100644 --- a/src/views/Basic/EstateInfo/_buildingManage/depend/form.vue +++ b/src/views/Basic/EstateInfo/_buildingManage/depend/form.vue @@ -36,6 +36,7 @@ :file-list="fileList" @preview="handlePreview" @change="fileChange" + :beforeUpload='beforeUpload' > 点击上传 @@ -62,6 +63,7 @@ :file-list="fileList" @preview="handlePreview" @change="fileChange" + :beforeUpload='beforeUpload' > @@ -210,6 +212,15 @@ export default { edit(){// 楼栋修改 this.formType = 2; }, + beforeUpload(f, l) { + const isLt50M = f.size / 1024 / 1024 < 50; + if (!isLt50M) { + this.$message.error(f.name + "文件大小超出限制,请修改后重新上传"); + return false; + } else { + return true; + } + }, submit(){// 楼栋提交 let file = [] for(let item of this.fileList){ diff --git a/src/views/Basic/EstateInfo/_houseHoldInfo/depend/addForm.vue b/src/views/Basic/EstateInfo/_houseHoldInfo/depend/addForm.vue index 452bc8c..5e19d18 100644 --- a/src/views/Basic/EstateInfo/_houseHoldInfo/depend/addForm.vue +++ b/src/views/Basic/EstateInfo/_houseHoldInfo/depend/addForm.vue @@ -90,6 +90,7 @@ @preview="handlePreview" @change="headChange" :file-list="headList" + :beforeUpload="beforeUpload" >
@@ -110,6 +111,7 @@ @preview="handlePreview" @change="backChange" :file-list="backList" + :beforeUpload="beforeUpload" >
@@ -219,6 +221,7 @@ accept='.jpg,.JPG,.png,.PNG,.jpeg,.JPEG' @preview="handlePreview" @change="picChange" + :beforeUpload="beforeUpload" :file-list="picList" >
@@ -372,6 +375,15 @@ export default { } }) }, + beforeUpload(f, l) { + const isLt50M = f.size / 1024 / 1024 < 50; + if (!isLt50M) { + this.$message.error(f.name + "文件大小超出限制,请修改后重新上传"); + return false; + } else { + return true; + } + }, addClose(){ this.$refs.ruleForm.resetFields(); this.$emit('close') @@ -402,17 +414,6 @@ export default { handleCancel() { this.previewVisible = false; }, - beforeUpload(file) { - const isJpgOrPng = file.type === 'image/jpeg' || file.type === 'image/png'; - if (!isJpgOrPng) { - this.$message.error('You can only upload JPG file!'); - } - const isLt2M = file.size / 1024 / 1024 < 2; - if (!isLt2M) { - this.$message.error('Image must smaller than 2MB!'); - } - return isJpgOrPng && isLt2M; - }, onChange(value, selectedOptions){ if(value.length > 0){ this.form.manageEstateId = value[value.length - 1]; diff --git a/src/views/Basic/EstateInfo/_houseManage/depend/form.vue b/src/views/Basic/EstateInfo/_houseManage/depend/form.vue index 6b0f540..7de47ef 100644 --- a/src/views/Basic/EstateInfo/_houseManage/depend/form.vue +++ b/src/views/Basic/EstateInfo/_houseManage/depend/form.vue @@ -103,6 +103,7 @@ :file-list="fileList" @preview="handlePreview" @change="fileChange" + :beforeUpload="beforeUpload" >
@@ -293,6 +294,15 @@ export default { this.fileList = fileList; console.log(this.fileList); }, + beforeUpload(f, l) { + const isLt50M = f.size / 1024 / 1024 < 50; + if (!isLt50M) { + this.$message.error(f.name + "文件大小超出限制,请修改后重新上传"); + return false; + } else { + return true; + } + }, }, watch: { editId(val){ diff --git a/src/views/Operation/Announcement/depend/form.vue b/src/views/Operation/Announcement/depend/form.vue index 31783cf..adbe323 100644 --- a/src/views/Operation/Announcement/depend/form.vue +++ b/src/views/Operation/Announcement/depend/form.vue @@ -72,6 +72,7 @@ accept=".doc,.DOC,.xls,.XLS,.xlsx,.XLSX,.pdf,.PDF" :headers="uploadHeaders" @change="changeFile" + :beforeUpload='beforeUpload' > 上传附件 @@ -129,6 +130,15 @@ export default { this.$emit("success"); this.addClose(); }, + beforeUpload(f, l) { + const isLt50M = f.size / 1024 / 1024 < 50; + if (!isLt50M) { + this.$message.error(f.name + "文件大小超出限制,请修改后重新上传"); + return false; + } else { + return true; + } + }, submit() { console.log(this.documentList); // 附件