-
Notifications
You must be signed in to change notification settings - Fork 72
/
Copy pathindex.vue
180 lines (165 loc) · 3.96 KB
/
index.vue
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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
<template>
<div class="preview-container">
<el-tabs v-if="formConfig.formKey" type="card">
<el-tab-pane>
<span slot="label"
><i class="el-icon-mobile" />
手机
</span>
<div class="preview-layer">
<div class="preview-bg" />
<div class="preview-phone">
<iframe
id="preview-html"
:src="mobilePreviewUrl"
class="preview-html"
frameborder="0"
name="preview-html"
scrolling="auto"
/>
</div>
</div>
<div v-if="mobilePreviewUrl && previewQrcode" class="qrcode-view">
<p style="font-weight: bold; font-size: 16px">手机扫码预览</p>
<p class="tips-text">* 预览仅查看效果,无法提交数据</p>
<p>
<vue-qr
v-if="mobilePreviewUrl && previewQrcode"
:size="134"
style="border-radius: 10px"
:text="mobilePreviewUrl"
/>
</p>
</div>
</el-tab-pane>
<el-tab-pane>
<span slot="label"
><i class="el-icon-monitor" />
电脑
</span>
<el-scrollbar style="height: 77vh; overflow-x: hidden !important">
<biz-project-form v-if="formConfig.formKey" :form-config="formConfig" />
</el-scrollbar>
</el-tab-pane>
</el-tabs>
</div>
</template>
<script>
import { BizProjectForm } from 'tduck-form-generator'
import 'tduck-form-generator/dist/TduckForm.css'
import VueQr from 'vue-qr'
import mixin from '../TduckFormMixin'
export default {
name: 'PreView',
components: {
BizProjectForm,
VueQr
},
mixins: [mixin],
props: {
previewQrcode: null
},
data() {
return {
formKey: null,
mobilePreviewUrl: '',
formConfig: {
formKey: '',
showBtns: true
}
}
},
mounted() {
this.formKey = this.$route.query.key
let url = window.location.protocol + '//' + window.location.host
// 支持二级目录访问
let publicPath = process.env.BASE_URL || '/'
let modeSign = this.$router.mode == 'hash' ? '#' : ''
this.mobilePreviewUrl = `${url}${publicPath}${modeSign}/project/form/view?key=${this.formKey}`
this.$set(this.formConfig, 'formKey', this.formKey)
}
}
</script>
<style lang="scss" scoped>
.tips-text {
margin-top: 10px;
margin-bottom: 10px;
}
.preview-container {
margin: 0;
padding-top: 30px;
height: 100vh;
overflow: hidden !important;
background-color: var(--color-bg);
}
::v-deep .el-tabs--card > .el-tabs__header .el-tabs__nav {
border: 1px solid #e4e7ed !important;
border-radius: 10px;
background-color: white;
}
::v-deep .el-tabs__header {
width: 300px;
margin: 0 auto;
border: none;
}
::v-deep .el-dialog__body {
max-height: calc(100vh - 200px) !important;
}
::v-deep .el-tabs--card > .el-tabs__header .el-tabs__item {
background-color: transparent;
//border: 1px solid white;
}
::v-deep .project-form {
padding: 20px;
}
::v-deep .project-form-wrapper {
background-color: transparent;
}
div.preview-layer {
width: 500px;
height: 100%;
margin: 10px auto;
right: 0;
text-align: center;
}
div.preview-layer .preview-bg {
width: 500px;
height: 100%;
margin: 20px auto;
z-index: 999;
opacity: 0.7;
}
div.preview-layer .preview-phone {
width: 372px;
height: 744px;
background: url('~@/assets/images/appearset_bgc_big.png');
background-size: 372px 744px;
z-index: 1000;
}
.qrcode-view {
position: absolute;
top: 20px;
right: 260px;
p {
text-align: center;
font-size: 12px;
color: #303133;
}
}
.preview-html {
width: 345px !important;
height: 568px !important;
margin: 74px 0 0;
border-radius: 5px;
outline: none;
background-color: #fff;
border-width: 2px;
border-style: inset;
border-color: initial;
border-image: initial;
border-top-width: 0;
border-right-width: 0;
border-bottom-width: 0;
border-left-width: 0;
}
</style>