Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
glsx-business
/
supply-web
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit 0fe0755f
authored
Sep 24, 2020
by
wangql
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
解决发货单下载为图片时跳转问题
1 parent
6aee7a8b
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
55 additions
and
2 deletions
src/common/common.js
src/views/orderManage/assignOrder.vue
src/views/orderManage/assignShipment.vue
src/common/common.js
View file @
0fe0755
...
@@ -35,6 +35,7 @@ const common = {
...
@@ -35,6 +35,7 @@ const common = {
}));
}));
let
link
=
document
.
createElement
(
'a'
);
let
link
=
document
.
createElement
(
'a'
);
link
.
style
.
display
=
'none'
;
link
.
style
.
display
=
'none'
;
link
.
target
=
'_blank'
;
link
.
href
=
url
;
link
.
href
=
url
;
link
.
setAttribute
(
'download'
,
options
.
fileName
||
'excel.xlsx'
);
link
.
setAttribute
(
'download'
,
options
.
fileName
||
'excel.xlsx'
);
document
.
body
.
appendChild
(
link
);
document
.
body
.
appendChild
(
link
);
...
...
src/views/orderManage/assignOrder.vue
View file @
0fe0755
...
@@ -474,7 +474,59 @@ export default {
...
@@ -474,7 +474,59 @@ export default {
* 下载发货单
* 下载发货单
*/
*/
downloadInvoice
:
function
(
row
){
downloadInvoice
:
function
(
row
){
window
.
location
.
href
=
row
.
urlDispatchBills
console
.
log
(
row
.
urlDispatchBills
)
// window.location.href = row.urlDispatchBills
// let a = document.createElement('a')
// a.href = row.urlDispatchBills // 这里的请求方式为get,如果需要认证,接口上需要带上token
// a.click()
let
fileUrl
=
row
.
urlDispatchBills
if
(
this
.
isPicture
(
fileUrl
)){
//当文件是图片格式时
let
image
=
new
Image
();
// 解决跨域 Canvas 污染问题
image
.
setAttribute
(
"crossOrigin"
,
"anonymous"
);
image
.
onload
=
function
()
{
let
canvas
=
document
.
createElement
(
"canvas"
);
canvas
.
width
=
image
.
width
;
canvas
.
height
=
image
.
height
;
let
context
=
canvas
.
getContext
(
"2d"
);
context
.
drawImage
(
image
,
0
,
0
,
image
.
width
,
image
.
height
);
let
url
=
canvas
.
toDataURL
(
"image/png"
);
//得到图片的base64编码数据
let
a
=
document
.
createElement
(
"a"
);
// 生成一个a元素
let
event
=
new
MouseEvent
(
"click"
);
// 创建一个单击事件
a
.
download
=
"发货单"
;
// 设置图片名称
a
.
href
=
url
;
// 将生成的URL设置为a.href属性
a
.
dispatchEvent
(
event
);
// 触发a的单击事件
};
image
.
src
=
row
.
urlDispatchBills
;
}
else
{
const
params
=
{
'fileName'
:
'发货单'
}
params
.
url
=
row
.
urlDispatchBills
params
.
method
=
'get'
params
.
data
=
{}
exportExcel
(
params
)
}
},
/**
* 判断是否为图片
*/
isPicture
:
function
(
str
){
//判断是否是图片 - strFilter必须是小写列举
var
strFilter
=
".jpeg|.gif|.jpg|.png|.bmp|.pic|.svg|"
if
(
str
.
indexOf
(
"."
)
>-
1
)
{
var
p
=
str
.
lastIndexOf
(
"."
);
var
strPostfix
=
str
.
substring
(
p
,
str
.
length
)
+
'|'
;
strPostfix
=
strPostfix
.
toLowerCase
();
if
(
strFilter
.
indexOf
(
strPostfix
)
>-
1
)
{
return
true
;
}
}
return
false
;
},
},
/**
/**
...
...
src/views/orderManage/assignShipment.vue
View file @
0fe0755
...
@@ -483,7 +483,7 @@ export default {
...
@@ -483,7 +483,7 @@ export default {
}
else
{
//有联网信息,显示套餐选项
}
else
{
//有联网信息,显示套餐选项
this
.
packageOneShow
=
true
this
.
packageOneShow
=
true
}
}
list
.
splice
(
key
,
1
);
//
x
先将需要排到第一位的对象删除
list
.
splice
(
key
,
1
);
//先将需要排到第一位的对象删除
break
;
break
;
}
else
{
}
else
{
this
.
noCode
=
true
this
.
noCode
=
true
...
...
Write
Preview
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