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
2024-11-14 13:08:07 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
c78773bcf1ecd8ce6db8614b3c7facfb65e132b7
c78773bc
1 parent
ef9972b8
✨ feat(文件和图片上传组件): 表单数据默认值,因为是自定义绑定数据,需要手动同步到提交结构上。
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
27 additions
and
3 deletions
src/components/FileUploaderField/index.vue
src/components/ImageUploaderField/index.vue
src/components/FileUploaderField/index.vue
View file @
c78773b
<!--
* @Date: 2022-08-31 16:16:49
* @LastEditors: hookehuyr hookehuyr@gmail.com
* @LastEditTime: 2024-
08-12 18:12:00
* @LastEditTime: 2024-
11-14 13:05:31
* @FilePath: /data-table/src/components/FileUploaderField/index.vue
* @Description: 文件上传控件
-->
...
...
@@ -118,6 +118,18 @@ onMounted(() => {
// 非只读模式并且有默认值时
if (!props.item.component_props.readonly && props.item.component_props.default) {
fileList.value = default_file.value;
// TAG:把存在的默认值同步到表单数据列表里
// 过滤非包含URL的文件
fileList.value = fileList.value.filter((item) => {
if (item.url) return item;
});
props.item.value = {
key: "file_uploader",
filed_name: props.item.key,
value: fileList.value,
};
// 完整数据回调到表单上
emit("active", props.item.value);
}
})
...
...
src/components/ImageUploaderField/index.vue
View file @
c78773b
<!--
* @Date: 2022-08-31 16:16:49
* @LastEditors: hookehuyr hookehuyr@gmail.com
* @LastEditTime: 2024-
08-07 18:14:21
* @LastEditTime: 2024-
11-14 13:06:43
* @FilePath: /data-table/src/components/ImageUploaderField/index.vue
* @Description: 图片上传控件
-->
...
...
@@ -102,7 +102,19 @@ onMounted(() => {
if (!props.item.component_props.readonly) {
// 默认图片显示
if (default_tmp.value && default_tmp.value.length) {
fileList.value = default_tmp.value
fileList.value = default_tmp.value;
// TAG:把存在的默认值同步到表单数据列表里
// 过滤非包含URL的文件
fileList.value = fileList.value.filter((item) => {
if (item.url) return item;
});
props.item.value = {
key: "image_uploader",
filed_name: props.item.key,
value: fileList.value,
};
// 完整数据回调到表单上
emit("active", props.item.value);
}
} else {
// 默认图片显示
...
...
Please
register
or
login
to post a comment