Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
project-online-old
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
EzijingWeb
project-online-old
Commits
c2009e8c
提交
c2009e8c
authored
4月 12, 2022
作者:
matian
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
下载图片修改
上级
1682ebc1
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
30 行增加
和
8 行删除
+30
-8
queryCard.vue
src/pages/home/queryCard.vue
+9
-8
downloadPng.js
src/tool/downloadPng.js
+21
-0
没有找到文件。
src/pages/home/queryCard.vue
浏览文件 @
c2009e8c
...
...
@@ -6,10 +6,10 @@
<div
v-for=
"(item, index) in cardListMap"
:key=
"index"
class=
"home-box-content"
>
<div
class=
"home-box-content-btn"
>
<el-button
round
class=
"btn"
@
click=
"handlePrint(item)"
>
打印
</el-button>
<a
:href=
"item.download_info.url"
:download=
"item.download_info.filename"
target=
"_blank"
<
!--
<
a
:href=
"item.download_info.url"
:download=
"item.download_info.filename"
target=
"_blank"
><el-button
round
class=
"btn"
>
下载
</el-button></a
>
<
!--
<el-button
round
class=
"btn"
@
click=
"handleDownload(item)"
>
下载
</el-button>
--
>
>
-->
<
el-button
round
class=
"btn"
@
click=
"handleDownload(item)"
>
下载
</el-button
>
</div>
<div
class=
"home-box-content-list"
>
<img
class=
"home-box-content-img"
:src=
"item.download_info.url"
alt=
""
/>
...
...
@@ -27,7 +27,7 @@
<
script
>
import
printJS
from
'print-js'
import
action
from
'@action'
import
downloadIamge
from
'@tool/downloadPng'
export
default
{
data
()
{
return
{
...
...
@@ -51,11 +51,12 @@ export default {
// 打印
handlePrint
(
item
)
{
printJS
(
item
.
download_info
.
url
,
'image'
)
}
}
,
// 下载
// handleDownload(item) {
// window.open(item.download_info.url, '_blank')
// }
handleDownload
(
item
)
{
downloadIamge
(
item
.
download_info
.
url
,
item
.
download_info
.
filename
)
// window.open(item.download_info.url, '_blank')
}
},
mounted
()
{
// 获取证书
...
...
src/tool/downloadPng.js
0 → 100644
浏览文件 @
c2009e8c
function
downloadIamge
(
imgsrc
,
name
)
{
// 下载图片地址和图片名
var
image
=
new
Image
()
// 解决跨域 Canvas 污染问题
image
.
setAttribute
(
'crossOrigin'
,
'anonymous'
)
image
.
onload
=
function
()
{
const
canvas
=
document
.
createElement
(
'canvas'
)
canvas
.
width
=
image
.
width
canvas
.
height
=
image
.
height
const
context
=
canvas
.
getContext
(
'2d'
)
context
.
drawImage
(
image
,
0
,
0
,
image
.
width
,
image
.
height
)
const
url
=
canvas
.
toDataURL
(
'image/png'
)
// 得到图片的base64编码数据
const
a
=
document
.
createElement
(
'a'
)
// 生成一个a元素
const
event
=
new
MouseEvent
(
'click'
)
// 创建一个单击事件
a
.
download
=
name
||
'photo'
// 设置图片名称
a
.
href
=
url
// 将生成的URL设置为a.href属性
a
.
dispatchEvent
(
event
)
// 触发a的单击事件
}
image
.
src
=
imgsrc
}
export
default
downloadIamge
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论