Toggle navigation
Toggle navigation
This project
Loading...
Sign in
Hooke
/
data-table
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Graphs
Network
Create a new issue
Commits
Issue Boards
Authored by
hookehuyr
2022-12-05 16:38:01 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
dadfab3ff434be33af3567fa41dda185e90f23fa
dadfab3f
1 parent
bb683475
图片上传控件新增最大数量和最大体积控制
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
1 deletions
src/components/ImageUploaderField/index.vue
src/components/ImageUploaderField/index.vue
View file @
dadfab3
...
...
@@ -47,7 +47,7 @@
* @param image_type[Array] 图片上传类型
* @param multiple[Boolean] 图片多选
*/
import { showSuccessToast, showFailToast } from "vant";
import { showSuccessToast, showFailToast
, showToast
} from "vant";
import _ from "lodash";
import { v4 as uuidv4 } from "uuid";
import { qiniuTokenAPI, qiniuUploadAPI, saveFileAPI } from "@/api/common";
...
...
@@ -96,11 +96,30 @@ const beforeRead = (file) => {
flag = false;
showFailToast("请上传指定格式图片");
}
if (fileList.value.length + file.length > props.item.component_props.max_count) {
// 数量限制
flag = false;
showToast(`最大上传数量为${props.item.component_props.max_count}个`);
}
} else {
if (!_.includes(image_types, file.type)) {
showFailToast("请上传指定格式图片");
flag = false;
}
if (fileList.value.length + 1 > props.item.component_props.max_count) {
// 数量限制
flag = false;
showToast(`最大上传数量为${props.item.component_props.max_count}个`);
}
if (file.size > props.item.component_props.max_size) {
// 体积限制
flag = false;
showToast(
`最大文件体积为${(props.item.component_props.max_size / 1024 / 1024).toFixed(
2
)}MB`
);
}
}
return flag;
};
...
...
Please
register
or
login
to post a comment