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
<template>
<div>
<el-skeleton v-if="isEmpty" animated />
<custom-form
v-if="!isEmpty"
class="mb-20"
v-loading="pageLoading"
ref="form"
:options="widgetFormPreview"
:form-edit="formEdit"
></custom-form>
</div>
</template>
<script>
import { getPatientDetail, getFollowDetail } from "@/api/patient.js"
import { getFormDetail } from "@/api/field"
import CustomForm from "@/components/FormComponents/CustomForm/index"
export default {
name: "MyCustomForm",
components: { CustomForm },
props: {
formType: String,
form: {},
patientId: {},
followId: {},
followId: {},
},
data() {
return {
widgetFormPreview: {},
loading: false,
formLoading: false,
formEdit: {},
formRecordId: null,
}
},
computed: {
isEmpty() {
return !(Object.keys(this.widgetFormPreview) || this.widgetFormPreview)
.length
},
getTabFollowId() {
return this.tabFollowId()
},
pageLoading() {
return this.loading || this.formLoading
},
},
watch: {
followId: {
handler() {
this.getFollowDetail()
},
immediate: true,
},
},
created() {
this.initData()
this.initForm()
},
methods: {
initData() {
this.getPatientDetail()
},
initForm() {
this.formLoading = true
getFormDetail(this.form.formId)
.then((res) => {
if (res.code === 1 && res.data) {
const formJson = res.data.formJson
this.$emit("setFormJson", formJson)
const obj = eval("(" + formJson + ")")
obj.disabled = true
obj.closeBtn = true
obj.detail = true
this.widgetFormPreview = obj
}
})
.finally(() => {
this.formLoading = false
})
},
getFollowDetail() {
// 随访数据查询
if (!this.followId) return
this.$nextTick(() => {
this.$refs.form && this.$refs.form.resetForm()
})
this.loading = true
getFollowDetail({
followId: this.followId,
formId: this.form.formId,
})
.then((res) => {
this.formatData(res)
})
.finally(() => {
this.loading = false
})
},
getPatientDetail() {
// 筛查数据查询
this.$nextTick(() => {
this.$refs.form && this.$refs.form.resetForm()
})
if (!this.patientId || this.formType === "2") return
this.loading = true
getPatientDetail({
patientId: this.patientId,
formId: this.form.formId,
})
.then((res) => {
this.formatData(res)
})
.finally(() => {
this.loading = false
})
},
formatData(res, cache) {
const d = res.data || {}
const form = d.data || {}
for (const key in form) {
Object.prototype.toString.call(form[key]) == "[object Number]"
? (form[key] = String(form[key]))
: ""
}
this.formEdit = form
},
},
}
</script>