Channels.vue
3.34 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
<template>
<el-table v-loading="loading" :data="ChannelsList" style="width: 1000px">
<el-table-column label="渠道" align="center" prop="createTime">
<template #default="{ row, $index }">
<el-input style="width: 80%" type="text" placeholder="请输入渠道标识" v-model="ChannelsList[$index]" />
</template>
</el-table-column>
<el-table-column label="二维码" align="center" prop="createTime" show-overflow-tooltip>
<template #default="{ row, $index }">
<el-image :src="eImgList[$index]" class="code-image"></el-image>
<!-- <el-popover placement="bottom" trigger="hover" v-if="eImgList[$index]">
<template #reference><el-image :src="eImgList[$index]" class="code-image--small"></el-image></template>
<el-image :src="eImgList[$index]" class="code-image"></el-image>
</el-popover> -->
</template>
</el-table-column>
<el-table-column label="渠道标识" align="center" prop="createTime" show-overflow-tooltip>
<template #default="{ row, $index }">{{ baseFormUrl4 + '&dataSource=' }}{{ row }}</template>
</el-table-column>
<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="downloadBlob(eImgList[$index], '表单二维码.png', 'image')">下载二维码</el-button>
</template>
</el-table-column>
</el-table>
</template>
<script>
import QRCode from 'qrcode'
import { selectInfoToSurvey } from '@/api/drainageCode/smartForms.js'
export default {
props: ['FormIdY'],
data() {
return {
loading: true,
eImgList: [],
formId: '',
ChannelsList: '',
channelsPathList: '',
baseFormUrl4: '',
}
},
mounted() {
this.clipboard = new this.ClipboardJS('.copy-btn')
this.formId = this.FormIdY
this.selectInfoToSurvey()
},
unmounted() {
this.clipboard.destroy()
},
methods: {
//获取详情
selectInfoToSurvey() {
let that = this
if (!this.formId) {
this.loading = false
return
}
selectInfoToSurvey(this.formId).then((response) => {
this.loading = false
that.baseFormUrl4 = window.location.origin + '/formsDetail?id=true&formId=' + that.formId
if (response.data.channelsName) {
that.ChannelsList = response.data.channelsName.split(',')
that.channelsPathList = response.data.channelsPath.split(',')
for (let i = 0; i < that.channelsPathList.length; i++) {
//生成各渠道二维码
for (let w = 0; w < this.ChannelsList.length; w++) {
console.log('二维码转换内容', that.baseFormUrl4 + '&dataSource=' + that.channelsPathList[w])
QRCode.toDataURL(
this.baseFormUrl4 + '&dataSource=' + that.channelsPathList[w], // 需要转换为二维码的内容
{ width: 150, margin: 2, errorCorrectionLevel: 'H' },
).then((url) => (this.eImgList[i] = url))
}
}
this.eImgList.push()
}
})
},
},
}
</script>
<style lang="scss" scoped>
.code-image {
width: 180px;
height: 180px;
}
// .code-image--small {
// width: 200px;
// height: 200px;
// }
</style>