Toggle navigation
Toggle navigation
This project
Loading...
Sign in
Fedex
/
imac-vue
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
jinhui.wang
2021-12-20 17:16:23 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
ea1be8bb862dab8b8dab7419181c401f9c1672c3
ea1be8bb
1 parent
24a6b23c
货物查询修改
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
27 additions
and
2 deletions
src/utils/zipdownload.js
src/views/allocationConfig/cargoConfig/index.vue
src/utils/zipdownload.js
View file @
ea1be8b
...
...
@@ -6,7 +6,7 @@ const mimeMap = {
zip
:
'application/zip'
}
const
baseUrl
=
process
.
env
.
VUE_APP_BASE_API
const
baseUrl
=
'http://192.168.1.134:18080'
export
function
downLoadZip
(
str
,
filename
)
{
var
url
=
baseUrl
+
str
axios
({
...
...
@@ -18,6 +18,20 @@ export function downLoadZip(str, filename) {
resolveBlob
(
res
,
mimeMap
.
zip
)
})
}
export
function
cargoXlsx
(
str
,
data
)
{
var
url
=
baseUrl
+
str
axios
({
method
:
'post'
,
url
:
url
,
data
:
data
,
responseType
:
'blob'
,
headers
:
{
'Authorization'
:
getToken
()
}
}).
then
(
res
=>
{
if
(
res
.
status
===
200
){
cargoTableXlsx
(
res
)
}
})
}
/**
* 解析blob响应内容并下载
* @param {*} res blob响应内容
...
...
@@ -25,7 +39,7 @@ export function downLoadZip(str, filename) {
*/
export
function
resolveBlob
(
res
,
mimeType
)
{
const
aLink
=
document
.
createElement
(
'a'
)
var
blob
=
new
Blob
([
res
.
data
],
{
type
:
mimeType
})
var
blob
=
new
Blob
([
res
],
{
type
:
mimeType
})
// //从response的headers中获取filename, 后端response.setHeader("Content-disposition", "attachment; filename=xxxx.docx") 设置的文件名;
var
patt
=
new
RegExp
(
'filename=([^;]+\\.[^\\.;]+);*'
)
var
contentDisposition
=
decodeURI
(
res
.
headers
[
'content-disposition'
])
...
...
@@ -38,3 +52,14 @@ export function resolveBlob(res, mimeType) {
aLink
.
click
()
document
.
body
.
removeChild
(
aLink
);
}
//货物查询表导出
export
function
cargoTableXlsx
(
res
){
const
aLink
=
document
.
createElement
(
'a'
)
const
fileName
=
"货物查询表.xlsx"
aLink
.
href
=
URL
.
createObjectURL
(
res
.
data
)
aLink
.
setAttribute
(
'download'
,
fileName
)
// 设置下载文件名称
document
.
body
.
appendChild
(
aLink
)
aLink
.
click
()
document
.
body
.
removeChild
(
aLink
);
}
...
...
src/views/allocationConfig/cargoConfig/index.vue
View file @
ea1be8b
This diff is collapsed. Click to expand it.
Please
register
or
login
to post a comment