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
13817124
Commit
13817124
authored
Feb 18, 2025
by
wangxl
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' of
http://gitlab.yiboshi.com/XuJun/yn-science-front
parents
376b1b38
cbbd1e6d
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
32 additions
and
58 deletions
+32
-58
index.js
src/api/index.js
+3
-0
file.vue
src/views/manager/project/components/file.vue
+19
-30
index.vue
src/views/manager/project/index.vue
+4
-0
projectView.vue
src/views/report/project/components/projectView.vue
+6
-28
No files found.
src/api/index.js
View file @
13817124
...
@@ -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 @
13817124
<
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
)
=>
{
uploadFile
(
obj
,
index
)
{
const
formData
=
new
FormData
()
this
.
$api
.
base
.
asyncApplyBookUpload
(
this
.
uploadHandle
(
obj
.
file
,
obj
.
name
)).
then
(({
data
=
{}
})
=>
{
formData
.
append
(
'file'
,
fileItem
.
file
)
if
(
data
)
{
obj
.
fileName
=
files
[
0
].
name
// 这里替换成您的实际上传API
obj
.
downloadUrl
=
data
.
downloadUrl
const
xhr
=
new
XMLHttpRequest
()
obj
.
downloadId
=
data
.
id
xhr
.
upload
.
onprogress
=
(
event
)
=>
{
}
else
if
(
event
.
lengthComputable
)
{
this
.
$message
.
error
(
'上传失败'
)
this
.
$set
(
this
.
fileList
[
index
],
'progress'
,
}).
catch
(()
=>
{
Math
.
round
((
event
.
loaded
/
event
.
total
)
*
100
))
this
.
$message
.
error
(
'上传失败'
)
}
}
xhr
.
onload
=
()
=>
{
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 @
13817124
...
@@ -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
:
{
...
...
src/views/report/project/components/projectView.vue
View file @
13817124
<
template
>
<
template
>
<div
class=
"app-content layoutEmbedded"
style=
"height: 76vh;overflow: auto;"
>
<div
class=
"app-content layoutEmbedded"
style=
"height: 76vh;overflow: auto;"
>
<a-spin
:spinning=
"loading"
style=
"width: 100%;height: 100%;"
>
<a-spin
:spinning=
"loading"
style=
"width: 100%;height: 100%;"
>
...
@@ -10,7 +9,7 @@
...
@@ -10,7 +9,7 @@
</div>
</div>
<div
class=
"page-footer"
>
<div
class=
"page-footer"
>
<!-- 申报项目详情 -->
<!-- 申报项目详情 -->
<a-button
type=
"primary"
@
click=
"onExport"
>
导出
</a-button>
<a-button
type=
"primary"
@
click=
"on
Project
Export"
>
导出
</a-button>
<project-info
v-model=
"formData"
:tabsData
.
sync=
"tabsData"
v-if=
"projType=='1'"
/>
<project-info
v-model=
"formData"
:tabsData
.
sync=
"tabsData"
v-if=
"projType=='1'"
/>
<project-info-Key
v-model=
"formData"
:tabsData
.
sync=
"tabsData"
v-if=
"projType=='2'"
/>
<project-info-Key
v-model=
"formData"
:tabsData
.
sync=
"tabsData"
v-if=
"projType=='2'"
/>
</div>
</div>
...
@@ -149,47 +148,26 @@ export default {
...
@@ -149,47 +148,26 @@ export default {
}).
catch
(()
=>
{
this
.
$emit
(
'close'
,
'error'
)
})
}).
catch
(()
=>
{
this
.
$emit
(
'close'
,
'error'
)
})
}
}
},
},
onExport
()
{
onProjectExport
()
{
this
.
loading
=
true
let
headers
=
{
let
headers
=
{
Authorization
:
'Bearer '
+
getToken
()
Authorization
:
'Bearer '
+
getToken
()
}
}
axios
({
axios
({
url
:
"/v1/science-admin/com-project/
e
xport/"
+
this
.
value
,
// 替换为实际文件的URL
url
:
"/v1/science-admin/com-project/
projectE
xport/"
+
this
.
value
,
// 替换为实际文件的URL
method
:
'GET'
,
method
:
'GET'
,
responseType
:
"arraybuffer"
,
// 告诉axios返回的数据类型为Blob
responseType
:
"arraybuffer"
,
// 告诉axios返回的数据类型为Blob
headers
:
headers
headers
:
headers
}).
then
(
response
=>
{
}).
then
(
response
=>
{
console
.
log
(
response
.
data
)
const
url
=
window
.
URL
.
createObjectURL
(
new
Blob
([
response
.
data
]))
const
url
=
window
.
URL
.
createObjectURL
(
new
Blob
([
response
.
data
]))
const
link
=
document
.
createElement
(
'a'
)
const
link
=
document
.
createElement
(
'a'
)
link
.
href
=
url
link
.
href
=
url
link
.
setAttribute
(
"download"
,
"11111
.pdf"
);
// 下载文件的名称
link
.
setAttribute
(
"download"
,
this
.
formData
.
projName
+
"
.pdf"
);
// 下载文件的名称
document
.
body
.
appendChild
(
link
)
document
.
body
.
appendChild
(
link
)
link
.
click
()
link
.
click
()
this
.
loading
=
false
})
})
},
},
onExport1
()
{
var
xhr
=
new
XMLHttpRequest
();
// 用这种原生请求下载后端返回的二进制流打开就不会出现空白
xhr
.
open
(
"get"
,
"/v1/science-admin/com-project/export/"
+
this
.
value
,
true
);
xhr
.
setRequestHeader
(
"Authorization"
,
'Bearer '
+
getToken
())
xhr
.
responseType
=
"blob"
;
xhr
.
onload
=
function
()
{
console
.
log
(
this
)
if
(
this
.
status
==
200
)
{
const
url
=
window
.
URL
.
createObjectURL
(
this
.
response
);
const
link
=
document
.
createElement
(
"a"
);
link
.
style
.
display
=
"none"
;
link
.
href
=
url
;
link
.
setAttribute
(
"download"
,
"结题审核页.pdf"
);
document
.
body
.
appendChild
(
link
);
link
.
click
();
document
.
body
.
removeChild
(
link
);
}
else
{
}
};
xhr
.
send
();
},
callback
(
key
)
{
callback
(
key
)
{
var
index
=
parseInt
(
key
)
var
index
=
parseInt
(
key
)
this
.
tabsData
.
forEach
(
e
=>
{
this
.
tabsData
.
forEach
(
e
=>
{
...
...
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