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
<template>
<div>
<el-container>
<el-main v-loading="pageLoading" class="transition-box">
<el-empty v-if="!isEmpty" description="暂无数据"></el-empty>
<template v-if="isEmpty">
<div ref="my-form" class="my-form">
<custom-form
ref="customForm"
:options="jsonList[1]"
:form-edit="form"
></custom-form>
<!-- <custom-form ref="form" :options="jsonList[1]"></custom-form>
<custom-form ref="form" :options="jsonList[2]"></custom-form>
<custom-form ref="form" :options="jsonList[3]"></custom-form>
<custom-form ref="form" :options="jsonList[4]"></custom-form> -->
</div>
</template>
</el-main>
<el-aside
:width="sideWidth"
class="transition-box"
:class="{ hidden: !asideShow }"
>
<div class="side-content"></div>
</el-aside>
</el-container>
</div>
</template>
<script>
import { mapGetters } from "vuex"
import CustomForm from "@/components/FormComponents/CustomForm/index"
import { getCurrentFormByType } from "@/api/coop-group.js"
import { getFormDetail } from "@/api/field"
export default {
components: { CustomForm },
data() {
return {
fromLoading: false,
formTabs: [],
formTabsList: [],
jsonList: [],
form: {
name: "123",
phone: "18712412341",
min_age: "18",
},
asideShow: true,
}
},
computed: {
...mapGetters({
group: ["user/group"],
}),
isEmpty() {
return this.jsonList.length
},
sideWidth() {
return this.asideShow ? "200px" : "0px"
},
pageLoading() {
return this.loading || this.formloading
},
},
watch: {},
created() {
this.getCurrentFormByType()
},
mounted() {},
methods: {
getCurrentFormByType(type = 1) {
this.fromLoading = true
getCurrentFormByType({
type,
groupId: this.group.groupId,
})
.then((res) => {
if (res.code === 1) {
const formTabs = []
this.formTabsList = res.data.map((item, index) => {
if (index === 0) {
formTabs.push({
silent: false,
...item,
label: item.tabName,
})
} else {
formTabs.push({
id: item.id,
formId: item.formId,
silent: true,
label: item.tabName,
})
}
return {
...item,
silent: false,
label: item.tabName,
}
})
this.formTabs = formTabs
}
})
.finally(() => {
this.jsonList = []
let i = 0
this.initForm(i)
})
},
initForm(i) {
let formId = this.formTabs[i].formId
this.formloading = true
getFormDetail(formId)
.then((res) => {
if (res.code === 1 && res.data) {
const formJson = res.data.formJson
const obj = eval("(" + formJson + ")")
obj.disabled = true
obj.detail = true
this.jsonList.push(obj)
if (i == 4) {
console.log(this.jsonList)
this.formloading = false
}
}
})
.finally(() => {
if (i < this.formTabs.length - 1) {
i++
this.initForm(i)
}
})
},
},
}
</script>
<style lang="scss" scoped></style>