Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
Y
yn-science-front
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
徐俊
yn-science-front
Commits
cbbd1e6d
Commit
cbbd1e6d
authored
Feb 18, 2025
by
徐俊
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
xujun
parent
6c26da42
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
25 additions
and
29 deletions
+25
-29
index.js
src/api/index.js
+3
-0
file.vue
src/views/manager/project/components/file.vue
+18
-29
index.vue
src/views/manager/project/index.vue
+4
-0
No files found.
src/api/index.js
View file @
cbbd1e6d
...
@@ -59,6 +59,9 @@ export default {
...
@@ -59,6 +59,9 @@ export default {
asyncUpload
(
params
)
{
asyncUpload
(
params
)
{
return
fetch
(
`/v1/science-admin/com-download/asyncUpload`
,
params
,
'post'
,
'file'
)
return
fetch
(
`/v1/science-admin/com-download/asyncUpload`
,
params
,
'post'
,
'file'
)
},
},
asyncApplyBookUpload
(
params
)
{
return
fetch
(
`/v1/science-admin/com-download/asyncApplyBookUpload`
,
params
,
'post'
,
'file'
)
},
deletefile
(
params
)
{
deletefile
(
params
)
{
return
fetch
(
`/v1/science-admin/com-download/delete/
${
params
.
id
}
`
,
params
,
'delete'
,
'json'
)
return
fetch
(
`/v1/science-admin/com-download/delete/
${
params
.
id
}
`
,
params
,
'delete'
,
'json'
)
},
},
...
...
src/views/manager/project/components/file.vue
View file @
cbbd1e6d
<
template
>
<
template
>
<div
class=
"upload-container"
>
<div
class=
"upload-container"
>
<
el-button
type=
"primary"
@
click=
"handleClick"
>
选择文件
</el
-button>
<
a-button
type=
"primary"
@
click=
"handleClick"
>
选择文件
</a
-button>
<input
type=
"file"
ref=
"fileInput"
multiple
style=
"display: none"
@
change=
"handleFileChange"
/>
<input
type=
"file"
ref=
"fileInput"
multiple
style=
"display: none"
@
change=
"handleFileChange"
/>
<div
class=
"file-list"
v-if=
"fileList.length"
>
<div
class=
"file-list"
v-if=
"fileList.length"
>
<div
v-for=
"(file, index) in fileList"
:key=
"index"
class=
"file-item"
>
<div
v-for=
"(file, index) in fileList"
:key=
"index"
class=
"file-item"
>
<span>
{{
file
.
name
}}
</span>
<span>
{{
file
.
name
}}
</span>
<span>
{{
(
file
.
size
/
1024
/
1024
).
toFixed
(
2
)
}}
MB
</span>
<span>
{{
(
file
.
size
/
1024
/
1024
).
toFixed
(
2
)
}}
MB
</span>
<el-progress
:percentage=
"file.progress || 0"
/>
</div>
</div>
</div>
</div>
</div>
</div>
...
@@ -48,35 +47,25 @@ export default {
...
@@ -48,35 +47,25 @@ export default {
}
}
}
}
},
},
uploadFile
(
fileItem
,
index
)
{
return
new
Promise
((
resolve
,
reject
)
=>
{
const
formData
=
new
FormData
()
formData
.
append
(
'file'
,
fileItem
.
file
)
// 这里替换成您的实际上传API
uploadFile
(
obj
,
index
)
{
const
xhr
=
new
XMLHttpRequest
()
this
.
$api
.
base
.
asyncApplyBookUpload
(
this
.
uploadHandle
(
obj
.
file
,
obj
.
name
)).
then
(({
data
=
{}
})
=>
{
xhr
.
upload
.
onprogress
=
(
event
)
=>
{
if
(
data
)
{
if
(
event
.
lengthComputable
)
{
obj
.
fileName
=
files
[
0
].
name
this
.
$set
(
this
.
fileList
[
index
],
'progress'
,
obj
.
downloadUrl
=
data
.
downloadUrl
Math
.
round
((
event
.
loaded
/
event
.
total
)
*
100
))
obj
.
downloadId
=
data
.
id
}
}
else
}
this
.
$message
.
error
(
'上传失败'
)
}).
catch
(()
=>
{
xhr
.
onload
=
()
=>
{
this
.
$message
.
error
(
'上传失败'
)
if
(
xhr
.
status
===
200
)
{
resolve
()
}
else
{
reject
(
new
Error
(
'上传失败'
))
}
}
xhr
.
onerror
=
()
=>
reject
(
new
Error
(
'上传失败'
))
// 替换成实际的上传地址
xhr
.
open
(
'POST'
,
'/api/upload'
)
xhr
.
send
(
formData
)
})
})
}
},
uploadHandle
(
file
,
fileName
)
{
let
formData
=
new
FormData
()
formData
.
append
(
'file'
,
file
)
formData
.
append
(
'fileName'
,
fileName
)
return
formData
},
}
}
}
}
</
script
>
</
script
>
...
...
src/views/manager/project/index.vue
View file @
cbbd1e6d
...
@@ -22,6 +22,7 @@
...
@@ -22,6 +22,7 @@
<a-form-item>
<a-form-item>
<a-button
type=
"primary"
icon=
"search"
@
click=
"search"
>
搜索
</a-button>
<a-button
type=
"primary"
icon=
"search"
@
click=
"search"
>
搜索
</a-button>
<a-button
icon=
"reload"
style=
"margin-left: 10px"
@
click=
"reset"
class=
"bt-normal"
>
重置
</a-button>
<a-button
icon=
"reload"
style=
"margin-left: 10px"
@
click=
"reset"
class=
"bt-normal"
>
重置
</a-button>
<a-button
type=
"primary"
icon=
"upload"
style=
"margin-left: 10px"
@
click=
"batchFileUpload"
>
批量上传
</a-button>
</a-form-item>
</a-form-item>
</a-form>
</a-form>
<a-divider
style=
"height: 1px; background-color: #e8e8e8;"
/>
<a-divider
style=
"height: 1px; background-color: #e8e8e8;"
/>
...
@@ -207,6 +208,9 @@ export default {
...
@@ -207,6 +208,9 @@ export default {
}).
catch
(()
=>
{
}).
catch
(()
=>
{
this
.
loading
=
false
this
.
loading
=
false
})
})
},
batchFileUpload
()
{
this
.
visibleFile
=
true
}
}
},
},
watch
:
{
watch
:
{
...
...
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