FormList.vue
2.99 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
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
<template>
<div class="form-list">
<PlacedTop classNodeId="form-list--content"></PlacedTop>
<nav-bar
:title="formListName"
:is-custom="true"
@go-back="handleGoBack"
></nav-bar>
<ht-template-preview
ref="templatePreview"
:template-key="key"
:single="single"
:task-type="taskType"
:def-key="defKey"
:data-view="dataView"
:is-join-flow="isJoinFlow"
:parameterq-querys="querys"
:key="key"
/>
</div>
</template>
<script>
const PlacedTop = () => import('@/components/PlacedTop.vue')
export default {
name: 'FormList',
components: {
PlacedTop,
},
props: {
templateKey: {
type: String,
default: '',
},
parameterqQuerys: {
type: String,
default: '',
},
single: {
type: String,
default: '',
},
taskType: {
type: String,
default: '',
},
defKey: {
type: String,
default: '',
},
dataView: {
type: Object,
default: function () {
return null
},
},
isJoinFlow: {
type: Boolean,
default: false,
},
},
data() {
return {
key: this.templateKey,
querys: this.parameterqQuerys,
curScrollTop: 0,
isFromTemplateDetail: false,
}
},
watch: {
'$route.query.alias'(newValue) {
this.key = newValue ? newValue : ''
},
},
activated() {
if (!this.key && this.$route.query.alias) {
this.key = this.$route.query.alias
}
if (!this.parameterqQuerys && this.$route.params.parameterqQuerys) {
this.querys = this.$route.params.parameterqQuerys
}
const formListContent =
document.getElementsByClassName('form-list--content')[0]
if (this.curScrollTop && formListContent) {
setTimeout(() => {
formListContent.scrollTop = this.curScrollTop
}, 1000)
}
this.$nextTick(() => {
if (
!this.isFromTemplateDetail &&
this.$refs.templatePreview.$refs &&
this.$refs.templatePreview.$refs.dataViewTemplate
) {
this.$refs.templatePreview.$refs.dataViewTemplate.resetMobileSearchQuery()
this.$refs.templatePreview.$refs.dataViewTemplate.handleUpdateList()
}
})
},
beforeRouteEnter(to, from, next) {
next((vm) => {
if (from.name === 'templateFormDetail') {
vm.isFromTemplateDetail = true
}
})
},
beforeRouteLeave(to, from, next) {
this.curScrollTop =
(document.getElementsByClassName('form-list--content')[0] &&
document.getElementsByClassName('form-list--content')[0].scrollTop) ||
0
next()
},
computed: {
formListName() {
return this.$route.query.name
},
},
methods: {
handleGoBack() {
this.$router.go(-1)
},
},
}
</script>
<style lang="scss" scoped></style>