@@ -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);
// 附件