Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
江名洋
/
linkwe-scrm
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 e536442b
authored
Oct 10, 2023
by
xinla
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
修复 智能表单二维码下载问题
1 parent
e895b95c
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
42 deletions
vue3-lw-pc/src/utils/common.js
vue3-lw-pc/src/views/drainageCode/smartForms/components/Channels.vue
vue3-lw-pc/src/utils/common.js
View file @
e536442
...
...
@@ -120,7 +120,7 @@ export function downloadBlob(blob, downloadName, type, callback) {
a
.
remove
()
URL
.
revokeObjectURL
(
url
)
// 释放内存
callback
&&
callback
()
}
else
if
(
/^
http
/
.
test
(
blob
)
&&
type
===
'image'
)
{
}
else
if
(
/^
(
http|data:image
)
/
.
test
(
blob
)
&&
type
===
'image'
)
{
let
image
=
new
Image
()
image
.
setAttribute
(
'crossOrigin'
,
'anonymous'
)
image
.
src
=
blob
...
...
@@ -428,6 +428,21 @@ export function $exportData(requestExport, exportFileName = '导出.xlsx', callb
})
}
// 文件预览路径处理
export
function
$previewFile
(
url
)
{
if
(
!
url
)
return
return
window
.
lwConfig
.
PRIVIEW_URL
?
window
.
lwConfig
.
PRIVIEW_URL
+
encodeURIComponent
(
base64Encode
(
url
))
:
url
function
base64Encode
(
url
)
{
return
btoa
(
encodeURIComponent
(
url
).
replace
(
/%
([
0-9A-F
]{2})
/g
,
function
toSolidBytes
(
match
,
p1
)
{
return
String
.
fromCharCode
(
'0x'
+
p1
)
}),
)
}
}
/**
* 通用js方法封装处理,挂载到 Vue.prototype
*/
vue3-lw-pc/src/views/drainageCode/smartForms/components/Channels.vue
View file @
e536442
...
...
@@ -20,7 +20,7 @@
<el-table-column
label=
"操作"
align=
"center"
prop=
"createTime"
show-overflow-tooltip
>
<
template
#
default=
"{ row, $index }"
>
<el-button
text
class=
"copy-btn"
:data-clipboard-text=
"baseFormUrl4 + '&dataSource=' + row"
>
复制
</el-button>
<el-button
text
@
click=
"
btnDownload($index
)"
>
下载二维码
</el-button>
<el-button
text
@
click=
"
downloadBlob(eImgList[$index], '表单二维码.png', 'image'
)"
>
下载二维码
</el-button>
</
template
>
</el-table-column>
</el-table>
...
...
@@ -35,7 +35,7 @@ export default {
return
{
loading
:
true
,
eImgList
:
[],
formId
:
'
1551375031790080000
'
,
formId
:
''
,
ChannelsList
:
''
,
channelsPathList
:
''
,
baseFormUrl4
:
''
,
...
...
@@ -50,45 +50,6 @@ export default {
this
.
clipboard
.
destroy
()
},
methods
:
{
btnDownload
(
index
)
{
console
.
log
(
'this.$refs.qrCodeUrl'
,
this
.
$refs
.
ewmTAddEwm
.
childNodes
[
index
*
2
+
1
].
src
)
this
.
downloadFile
(
'表单二维码'
,
this
.
$refs
.
ewmTAddEwm
.
childNodes
[
index
*
2
+
1
].
src
)
//创建一个具有指定的命名空间URI和限定名称的元素
// var save_link = document.createElementNS('http://www.w3.org/1999/xhtml', 'a');
// save_link.href = data;
// save_link.download = filename;
// // 绑定下载事件
// var event = document.createEvent('MouseEvents');
// event.initMouseEvent('click', true, false, window, 0, 0, 0, 0, 0, false, false, false, false, 0, null);
// save_link.dispatchEvent(event);
},
//base64转blob
base64ToBlob
(
code
)
{
let
parts
=
code
.
split
(
';base64,'
)
let
contentType
=
parts
[
0
].
split
(
':'
)[
1
]
let
raw
=
window
.
atob
(
parts
[
1
])
let
rawLength
=
raw
.
length
let
uInt8Array
=
new
Uint8Array
(
rawLength
)
for
(
let
i
=
0
;
i
<
rawLength
;
++
i
)
{
uInt8Array
[
i
]
=
raw
.
charCodeAt
(
i
)
}
return
new
Blob
([
uInt8Array
],
{
type
:
contentType
})
},
//下载
downloadFile
(
fileName
,
content
)
{
let
aLink
=
document
.
createElement
(
'a'
)
let
blob
=
this
.
base64ToBlob
(
content
)
//new Blob([content]);
let
evt
=
document
.
createEvent
(
'HTMLEvents'
)
evt
.
initEvent
(
'click'
,
true
,
true
)
//initEvent 不加后两个参数在FF下会报错 事件类型,是否冒泡,是否阻止浏览器的默认行为
aLink
.
download
=
fileName
aLink
.
href
=
URL
.
createObjectURL
(
blob
)
// aLink.dispatchEvent(evt);
aLink
.
click
()
},
//获取详情
selectInfoToSurvey
()
{
let
that
=
this
...
...
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