Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
W
web-purchase
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
张冬
web-purchase
Commits
50726f98
Commit
50726f98
authored
Nov 06, 2020
by
张冬
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
文件上传问题全部解决
parent
01f0edcc
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
37 additions
and
17 deletions
+37
-17
Upload.vue
src/components/Upload/Upload.vue
+29
-14
specialUpload.vue
src/components/Upload/specialUpload.vue
+7
-2
message.vue
src/pages/purchaser/bid/releaseProject/message.vue
+1
-1
No files found.
src/components/Upload/Upload.vue
View file @
50726f98
...
@@ -4,10 +4,7 @@
...
@@ -4,10 +4,7 @@
:on-remove=
"handleRemove"
:on-remove=
"handleRemove"
:on-success=
"handleSuccess"
:on-success=
"handleSuccess"
:before-remove=
"beforeRemove"
:before-remove=
"beforeRemove"
:limit=
"limit"
:show-file-list=
"false"
:on-exceed=
"handleExceed"
:file-list=
"fileList"
:list-type=
"listType"
:accept=
"accept"
:accept=
"accept"
:before-upload=
"beforeUpload"
:before-upload=
"beforeUpload"
class=
"upload-demo"
class=
"upload-demo"
...
@@ -20,6 +17,12 @@
...
@@ -20,6 +17,12 @@
{{
tip
}}
{{
tip
}}
</div>
</div>
</el-upload>
</el-upload>
<ul>
<li
class=
"flex link"
v-for=
"(item, index) in fileList"
:key=
"index"
>
<div
style=
"margin-right: 20px"
>
{{
item
.
name
}}
</div>
<div
@
click=
"handleDelete(index, item)"
>
删除
</div>
</li>
</ul>
</div>
</div>
</
template
>
</
template
>
...
@@ -90,19 +93,22 @@ export default {
...
@@ -90,19 +93,22 @@ export default {
this
.
$emit
(
'input'
,
value
);
this
.
$emit
(
'input'
,
value
);
},
},
beforeUpload
(
file
)
{
beforeUpload
(
file
)
{
const
max
=
this
.
max
;
const
isLt2M
=
file
.
size
/
1024
/
1024
<
max
;
if
(
!
isLt2M
)
{
this
.
$message
.
error
(
`上传附件大小不能超过
${
max
}
MB!`
);
return
}
if
(
this
.
fileList
.
length
==
this
.
limit
)
{
this
.
$message
.
warning
(
`每次只能上传
${
this
.
limit
}
个文件`
);
return
;
}
// 生成的文件名称
// 生成的文件名称
let
objName
=
getFileNameUUID
();
let
objName
=
getFileNameUUID
();
// 调用 ali-oss 中的方法
// 调用 ali-oss 中的方法
put
(
`
${
objName
}${
file
.
name
}
`
,
file
).
then
((
res
)
=>
{
put
(
`
${
objName
}${
file
.
name
}
`
,
file
).
then
((
res
)
=>
{
console
.
log
(
file
);
console
.
log
(
file
);
this
.
fileList
.
push
(
res
);
this
.
fileList
.
push
(
res
);
const
max
=
this
.
max
;
const
isLt2M
=
file
.
size
/
1024
/
1024
<
max
;
if
(
!
isLt2M
)
{
this
.
$message
.
error
(
`上传附件大小不能超过
${
max
}
MB!`
);
}
return
isLt2M
;
this
.
emitInput
(
this
.
fileList
);
this
.
emitInput
(
this
.
fileList
);
});
});
},
},
...
@@ -114,9 +120,6 @@ export default {
...
@@ -114,9 +120,6 @@ export default {
// handlePreview(file) {
// handlePreview(file) {
// this.$emit('on-preview', file);
// this.$emit('on-preview', file);
// },
// },
handleExceed
(
files
,
fileList
)
{
this
.
$message
.
warning
(
`每次只能上传
${
this
.
limit
}
个文件`
);
},
beforeRemove
(
file
,
fileList
)
{
beforeRemove
(
file
,
fileList
)
{
return
this
.
$confirm
(
`确定移除
${
file
.
name
}
?`
);
return
this
.
$confirm
(
`确定移除
${
file
.
name
}
?`
);
},
},
...
@@ -126,6 +129,18 @@ export default {
...
@@ -126,6 +129,18 @@ export default {
/**
/**
* 自定义上传方法
* 自定义上传方法
*/
*/
handleDelete
(
index
,
item
)
{
this
.
$confirm
(
`确定要删除
${
item
.
name
}
么?`
,
'提示'
,
{
type
:
'warning'
})
.
then
(()
=>
{
this
.
$message
.
success
(
'删除成功'
);
this
.
fileList
.
splice
(
index
,
1
);
this
.
$emit
(
'input'
,
this
.
fileList
);
})
.
catch
(()
=>
{});
},
handleUpload
(
option
)
{
handleUpload
(
option
)
{
console
.
log
(
option
.
file
);
console
.
log
(
option
.
file
);
}
}
...
...
src/components/Upload/specialUpload.vue
View file @
50726f98
...
@@ -141,12 +141,17 @@ export default {
...
@@ -141,12 +141,17 @@ export default {
this
.
$emit
(
'input'
,
value
);
this
.
$emit
(
'input'
,
value
);
},
},
beforeUpload
(
file
)
{
beforeUpload
(
file
)
{
// 生成的文件名称
const
max
=
this
.
max
;
console
.
log
(
this
.
fileList
.
length
,
this
.
limit
);
const
isLt2M
=
file
.
size
/
1024
/
1024
<
max
;
if
(
!
isLt2M
)
{
this
.
$message
.
error
(
`上传附件大小不能超过
${
max
}
MB!`
);
return
}
if
(
this
.
fileList
.
length
==
this
.
limit
)
{
if
(
this
.
fileList
.
length
==
this
.
limit
)
{
this
.
$message
.
warning
(
`每次只能上传
${
this
.
limit
}
个文件`
);
this
.
$message
.
warning
(
`每次只能上传
${
this
.
limit
}
个文件`
);
return
;
return
;
}
}
// 生成的文件名称
let
objName
=
getFileNameUUID
();
let
objName
=
getFileNameUUID
();
// 调用 ali-oss 中的方法
// 调用 ali-oss 中的方法
put
(
`
${
objName
}${
file
.
name
}
`
,
file
).
then
((
res
)
=>
{
put
(
`
${
objName
}${
file
.
name
}
`
,
file
).
then
((
res
)
=>
{
...
...
src/pages/purchaser/bid/releaseProject/message.vue
View file @
50726f98
...
@@ -169,7 +169,7 @@
...
@@ -169,7 +169,7 @@
</el-input>
</el-input>
</el-form-item>
</el-form-item>
<el-form-item
label=
"附件:"
prop=
"file"
>
<el-form-item
label=
"附件:"
prop=
"file"
>
<upload
:tip=
"tip"
:limit=
"20"
:max=
"1
0
"
accept=
".PDF,.JPG,.JPEG,.ZIP,.RAR,.docx,.doc,.docx"
@
input=
"getfile"
></upload>
<upload
:tip=
"tip"
:limit=
"20"
:max=
"1
5
"
accept=
".PDF,.JPG,.JPEG,.ZIP,.RAR,.docx,.doc,.docx"
@
input=
"getfile"
></upload>
</el-form-item>
</el-form-item>
</el-form>
</el-form>
</div>
</div>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
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 comment