Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
柳 佳乐
finance
Commits
66a048ad
Commit
66a048ad
authored
Nov 17, 2022
by
cx49085
Browse files
文件下载bug
parent
7c43290b
Changes
4
Show whitespace changes
Inline
Side-by-side
src/utils/download.js
View file @
66a048ad
...
@@ -2,7 +2,8 @@
...
@@ -2,7 +2,8 @@
* @param {string} url
* @param {string} url
* @param {string} fileName
* @param {string} fileName
*/
*/
import
axios
from
'
axios
'
import
{
getFileUrl
}
from
"
@/api/companyFile
"
;
import
axios
from
'
axios
'
export
const
downloadPDFFile
=
function
(
url
,
fileName
)
{
export
const
downloadPDFFile
=
function
(
url
,
fileName
)
{
axios
({
axios
({
method
:
'
get
'
,
method
:
'
get
'
,
...
@@ -26,9 +27,11 @@ export const downloadPDFFile = function (url, fileName) {
...
@@ -26,9 +27,11 @@ export const downloadPDFFile = function (url, fileName) {
})
})
}
}
export
const
previewPDF
=
(
url
)
=>
{
export
const
previewPDF
=
async
(
filename
)
=>
{
const
a
=
document
.
createElement
(
"
a
"
);
//创建一个<a></a>标签
const
a
=
document
.
createElement
(
"
a
"
);
//创建一个<a></a>标签
a
.
href
=
url
;
// 给a标签的href属性值加上地址,注意,这里是绝对路径,不用加 点.
// a.href = url; // 给a标签的href属性值加上地址,注意,这里是绝对路径,不用加 点.
a
.
href
=
(
await
getFileUrl
(
filename
)).
data
debugger
a
.
target
=
"
_blank
"
;
a
.
target
=
"
_blank
"
;
a
.
style
.
display
=
"
none
"
;
// 障眼法藏起来a标签
a
.
style
.
display
=
"
none
"
;
// 障眼法藏起来a标签
document
.
body
.
appendChild
(
a
);
// 将a标签追加到文档对象中
document
.
body
.
appendChild
(
a
);
// 将a标签追加到文档对象中
...
...
src/views/contract/components/addContract.vue
View file @
66a048ad
...
@@ -418,8 +418,8 @@ export default {
...
@@ -418,8 +418,8 @@ export default {
},
},
handleDownload
(
file
)
{
handleDownload
(
file
)
{
let
{
filePath
}
=
file
let
{
filePath
}
=
file
let
url
=
process
.
env
.
VUE_APP_BASE_API
+
filePath
;
//
let url = process.env.VUE_APP_BASE_API + filePath;
previewPDF
(
url
)
previewPDF
(
filePath
)
},
},
handleRemove
(
file
)
{
handleRemove
(
file
)
{
...
...
src/views/pettyMoney/addPettyMoneyRecord.vue
View file @
66a048ad
...
@@ -168,8 +168,7 @@ export default {
...
@@ -168,8 +168,7 @@ export default {
},
},
handleDownload
()
{
handleDownload
()
{
let
{
pettyEnclosure
:
filePath
}
=
this
.
formData
let
{
pettyEnclosure
:
filePath
}
=
this
.
formData
let
url
=
process
.
env
.
VUE_APP_BASE_API
+
filePath
;
previewPDF
(
filePath
)
previewPDF
(
url
)
},
},
handleRemove
(
file
)
{
handleRemove
(
file
)
{
...
...
src/views/pettyMoney/components/applicateDetail.vue
View file @
66a048ad
...
@@ -104,8 +104,8 @@ export default {
...
@@ -104,8 +104,8 @@ export default {
methods
:
{
methods
:
{
handleDownload
()
{
handleDownload
()
{
let
{
pettyEnclosure
:
filePath
}
=
this
.
checkedRow
let
{
pettyEnclosure
:
filePath
}
=
this
.
checkedRow
let
url
=
process
.
env
.
VUE_APP_BASE_API
+
filePath
;
//
let url = process.env.VUE_APP_BASE_API + filePath;
previewPDF
(
url
)
previewPDF
(
filePath
)
},
},
}
}
}
}
...
...
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