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 14:15:49 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
cdc48e6fdb35b06cf0940dafa99ab60757ca16a6
cdc48e6f
1 parent
85cb1959
fix 文件上传控件新增文件数量和大小控制
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
5 deletions
src/components/FileUploaderField/index.vue
src/components/ImageUploaderField/index.vue
src/components/FileUploaderField/index.vue
View file @
cdc48e6
...
...
@@ -11,7 +11,13 @@
{{ item.component_props.label
}}<span v-if="item.component_props.required"> *</span>
</div>
<div style="font-size: 0.9rem; padding-top: 0.5rem">
<div
v-if="item.component_props.note"
style="font-size: 0.9rem; margin-left: 1rem; color: gray; padding-bottom: 0.5rem"
>
{{ item.component_props.note }}
</div>
<div style="font-size: 0.9rem">
<p
v-for="file in fileList"
:key="index"
...
...
@@ -32,7 +38,6 @@
:before-read="beforeRead"
:after-read="afterRead"
:before-delete="beforeDelete"
:multiple="item.component_props.multiple"
>
<van-button icon="plus" type="primary">上传文件</van-button>
</van-uploader>
...
...
@@ -92,13 +97,25 @@ const fileList = ref([
// 上传前置处理
const beforeRead = (file) => {
// TODO: 需要file_type集合
// 类型限制
// const file_types = _.map(
// props.item.component_props.file_type.split("/"),
// (item) => `video/${item}`
// );
let flag = true;
if (fileList.value.length + 1 > props.item.component_props.max_count) {
// 数量限制
flag = false;
showFailToast(`最大上传数量为${props.item.component_props.max_count}`);
}
if (file.size > props.item.component_props.max_size) {
// 体积限制
flag = false;
showFailToast(
`最大文件体积为${(props.item.component_props.max_size / 1024 / 1024).toFixed(2)}MB`
);
}
// if (_.isArray(file)) {
// // 多张文件
// const types = _.difference(_.uniq(_.map(file, (item) => item.type)), file_types); // 数组返回不能上传的类型
...
...
@@ -152,7 +169,6 @@ const afterRead = async (files) => {
show_empty.value = false;
// 完整数据回调到表单上
emit("active", props.item.value);
console.warn(fileList.value);
};
// 文件删除前的回调函数
...
...
src/components/ImageUploaderField/index.vue
View file @
cdc48e6
...
...
@@ -136,7 +136,6 @@ const afterRead = async (files) => {
show_empty.value = false;
// 完整数据回调到表单上
emit("active", props.item.value);
console.warn(fileList.value);
};
// 文件删除前的回调函数
...
...
Please
register
or
login
to post a comment