Skip to content
Toggle navigation
Toggle navigation
This project
Loading...
Sign in
csbr-daop
/
fe-data-trusted-space
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
80f73978
authored
2025-12-16 10:49:59 +0800
by
lihua
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
解决上传文件删除问题,可能是Element版本导致
1 parent
001a07b2
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
5 additions
and
5 deletions
src/components/Form/index.vue
src/components/Form/index.vue
View file @
80f7397
...
...
@@ -475,19 +475,19 @@ const setItemRef = (el: any, field: string) => {
const
uploadFile
=
(
file
,
item
)
=>
{
if
(
formInline
.
value
[
item
.
field
]?.
some
(
f
=>
f
.
name
===
file
.
file
.
name
))
{
uploadRef
.
value
[
'ref'
+
item
.
field
].
handleRemove
(
file
);
uploadRef
.
value
[
'ref'
+
item
.
field
].
handleRemove
(
file
.
file
);
return
Promise
.
resolve
();
}
const
is200M
=
file
.
file
.
size
/
1024
/
1024
<
(
item
.
limitSize
??
200
);
// 限制小于200MB
if
(
!
is200M
)
{
uploadRef
.
value
[
"ref"
+
item
.
field
].
handleRemove
(
file
);
uploadRef
.
value
[
"ref"
+
item
.
field
].
handleRemove
(
file
.
file
);
ElMessage
.
error
(
`上传文件大小不超过
${
item
.
limitSize
??
200
}
MB
`);
return Promise.resolve();
}
if (item.isExcel) {
const isExcel = file.file.type === 'application/vnd.ms-excel' || file.file.type === 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' || file.file.type == 'text/csv';
if (!isExcel) {
uploadRef.value["ref" + item.field].handleRemove(file);
uploadRef.value["ref" + item.field].handleRemove(file
.file
);
ElMessage.error('上传文件只能是 .xls, .xlsx 格式');
return Promise.resolve();
}
...
...
@@ -547,13 +547,13 @@ const uploadFile = (file, item) => {
ElMessage.success('上传成功');
emits("uploadFileChange", formInline.value[item.field]);
} else {
uploadRef.value['ref' + item.field].handleRemove(file);
uploadRef.value['ref' + item.field].handleRemove(file
.file
);
ElMessage.error('上传失败,请重新上传!');
}
})
})
.catch(() => {
uploadRef.value['ref' + item.field].handleRemove(file);
uploadRef.value['ref' + item.field].handleRemove(file
.file
);
ElMessage.error('上传失败,请重新上传');
});
}
...
...
Write
Preview
Styling with
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment