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
b4f46b1b
authored
2025-01-06 16:39:46 +0800
by
lihua
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
解决文件下载问题
1 parent
9bca7e98
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
16 additions
and
13 deletions
src/api/modules/obsService.ts
src/components/Form/index.vue
src/views/data_meta/analysisReports.vue
src/views/importFile.vue
src/api/modules/obsService.ts
View file @
b4f46b1
...
...
@@ -23,6 +23,7 @@ export const parseAndDecodeUrl = (url:string) => {
// 返回去掉主机信息和开头斜杠后的解码部分以及最后一个斜杠后面的内容
return
{
fileName
:
pathname
,
decodedPath
:
pathname
+
search
+
hash
,
lastPart
:
lastPart
};
...
...
src/components/Form/index.vue
View file @
b4f46b1
...
...
@@ -337,7 +337,8 @@ const handlePictureCardPreview = (file, item) => {
const
onUploadFilePreview
=
async
(
file
,
item
)
=>
{
let
f
=
formInline
.
value
[
item
.
field
].
find
(
i
=>
i
.
name
==
file
.
name
);
let
url
=
f
.
url
;
const
refSignInfo
:
any
=
await
getDownFileSignByUrl
(
parseAndDecodeUrl
(
url
).
decodedPath
);
let
fileName
:
string
=
parseAndDecodeUrl
(
url
).
fileName
;
const
refSignInfo
:
any
=
await
getDownFileSignByUrl
(
fileName
);
if
(
!
refSignInfo
?.
data
)
{
refSignInfo
?.
msg
&&
ElMessage
.
error
(
refSignInfo
?.
msg
);
return
;
...
...
@@ -360,7 +361,7 @@ const onUploadFilePreview = async (file, item) => {
}
const
downloadTemplate
=
async
(
url
)
=>
{
const
refSignInfo
:
any
=
await
getDownFileSignByUrl
(
parseAndDecodeUrl
(
url
).
decodedPath
);
const
refSignInfo
:
any
=
await
getDownFileSignByUrl
(
parseAndDecodeUrl
(
url
).
fileName
);
if
(
!
refSignInfo
?.
data
)
{
refSignInfo
?.
msg
&&
ElMessage
.
error
(
refSignInfo
?.
msg
);
return
;
...
...
@@ -379,7 +380,7 @@ const downloadTemplate = async (url) => {
const
onUploadFileDownload
=
async
(
file
,
item
)
=>
{
let
url
=
file
.
url
;
const
refSignInfo
:
any
=
await
getDownFileSignByUrl
(
parseAndDecodeUrl
(
url
).
decodedPath
);
const
refSignInfo
:
any
=
await
getDownFileSignByUrl
(
parseAndDecodeUrl
(
url
).
fileName
);
if
(
!
refSignInfo
?.
data
)
{
refSignInfo
?.
msg
&&
ElMessage
.
error
(
refSignInfo
?.
msg
);
return
;
...
...
src/views/data_meta/analysisReports.vue
View file @
b4f46b1
...
...
@@ -129,19 +129,19 @@ const tableBtnClick = async (scope, btn) => {
rowData
.
value
=
row
currTableData
.
value
=
row
;
if
(
type
==
'view'
)
{
const
refSignInfo
:
any
=
await
getDownFileSignByUrl
(
parseAndDecodeUrl
(
row
.
analysisReportUrl
).
decodedPath
);
let
fileName
:
string
=
parseAndDecodeUrl
(
row
.
analysisReportUrl
).
fileName
;
const
refSignInfo
:
any
=
await
getDownFileSignByUrl
(
fileName
);
if
(
!
refSignInfo
?.
data
)
{
refSignInfo
?.
msg
&&
ElMessage
.
error
(
refSignInfo
?.
msg
);
return
;
}
obsDownloadRequest
(
refSignInfo
?.
data
).
then
((
res
:
any
)
=>
{
if
(
res
&&
!
res
.
msg
)
{
let
name
=
row
.
analysisReportUrl
;
var
fileSuffix
=
name
?
name
.
substring
(
name
.
lastIndexOf
(
'.'
)
+
1
)
:
''
;
var
fileSuffix
=
fileName
?
fileName
.
substring
(
fileName
.
lastIndexOf
(
'.'
)
+
1
)
:
''
;
if
(
fileSuffix
===
'png'
)
{
//浏览器可以支持图片和pdf预览
let
fileUrl
=
<
string
>
getDownloadUrl
(
res
,
name
,
fileSuffix
);
let
win
=
window
.
open
(
fileUrl
,
name
);
win
&&
(
win
.
document
.
title
=
name
);
let
win
=
window
.
open
(
fileUrl
,
row
.
analysisReportName
+
fileSuffix
);
win
&&
(
win
.
document
.
title
=
row
.
analysisReportName
+
fileSuffix
);
}
else
{
download
(
res
,
row
.
analysisReportName
,
fileSuffix
);
}
...
...
@@ -150,15 +150,16 @@ const tableBtnClick = async (scope, btn) => {
}
});
}
else
if
(
type
==
'export'
)
{
const
refSignInfo
:
any
=
await
getDownFileSignByUrl
(
parseAndDecodeUrl
(
row
.
analysisReportUrl
).
decodedPath
);
let
fileName
:
string
=
parseAndDecodeUrl
(
row
.
analysisReportUrl
).
fileName
;
const
refSignInfo
:
any
=
await
getDownFileSignByUrl
(
fileName
);
if
(
!
refSignInfo
?.
data
)
{
refSignInfo
?.
msg
&&
ElMessage
.
error
(
refSignInfo
?.
msg
);
return
;
}
obsDownloadRequest
(
refSignInfo
?.
data
).
then
((
res
:
any
)
=>
{
if
(
res
&&
!
res
.
msg
)
{
let
name
=
row
.
analysisReportUrl
;
var
fileSuffix
=
name
?
name
.
substring
(
n
ame
.
lastIndexOf
(
'.'
)
+
1
)
:
''
;
//
let name = row.analysisReportUrl;
var
fileSuffix
=
fileName
?
fileName
.
substring
(
fileN
ame
.
lastIndexOf
(
'.'
)
+
1
)
:
''
;
download
(
res
,
row
.
analysisReportName
,
fileSuffix
);
}
else
{
res
?.
msg
&&
ElMessage
.
error
(
res
?.
msg
);
...
...
src/views/importFile.vue
View file @
b4f46b1
...
...
@@ -221,7 +221,7 @@ const tableBtnClick = async (scope, btn) => {
const
row
=
scope
.
row
;
currTableData
.
value
=
row
;
if
(
type
==
"export_file"
)
{
const
refSignInfo
:
any
=
await
getDownFileSignByUrl
(
parseAndDecodeUrl
(
row
.
filePath
).
decodedPath
);
const
refSignInfo
:
any
=
await
getDownFileSignByUrl
(
parseAndDecodeUrl
(
row
.
filePath
).
fileName
);
if
(
!
refSignInfo
?.
data
)
{
refSignInfo
?.
msg
&&
ElMessage
.
error
(
refSignInfo
?.
msg
);
return
;
...
...
@@ -236,7 +236,7 @@ const tableBtnClick = async (scope, btn) => {
//downFile(row.filePath, row.fileName)
}
else
if
(
type
==
'export_abnormal_data'
)
{
//downFile(row.errorFilePath, '')
const
refSignInfo
:
any
=
await
getDownFileSignByUrl
(
parseAndDecodeUrl
(
row
.
errorFilePath
).
decodedPath
);
const
refSignInfo
:
any
=
await
getDownFileSignByUrl
(
parseAndDecodeUrl
(
row
.
errorFilePath
).
fileName
);
if
(
!
refSignInfo
?.
data
)
{
refSignInfo
?.
msg
&&
ElMessage
.
error
(
refSignInfo
?.
msg
);
return
;
...
...
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