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
import { addPatient, addFollowPatient } from "@/api/patient.js"
import FormTab from "./FormTab"
import { mapGetters } from "vuex"
import { getCurrentFormByType } from "@/api/coop-group.js"
export default {
components: { FormTab },
data() {
return {
activeName: "index0",
fromLoading: false,
patientStandbyId: null, // 备用id
newformRecordId: null, //记录Id
formTabs: [],
formId: "",
formTabsList: [],
isUpdated: false,
}
},
computed: {
...mapGetters({
group: ["user/group"],
}),
},
methods: {
nextTab() {
let i = this.activeName.split("index")[1] - 0
i++
if (i == 6) {
this.onSubmit(3)
return
} else {
this.activeName = "index" + i
this.handleTabClick({ index: i, name: "" })
}
},
prevTab(done) {
let i = this.activeName.split("index")[1] - 0
i--
this.activeName = "index" + i
this.handleTabClick({ index: i, name: "" })
done()
},
handleTabClick({ index, name }) {
const { formId, id, silent } = this.formTabs[index]
this.formId = this.formTabsList[index].formId
console.log("表单项", this.formTabs[index])
if (formId && silent) {
this.formTabs[index]["silent"] = false //控制是否获取接口数据
return
}
if (this.formTabs[index].formName == "风险评估") {
}
this.formTabs.splice(index, 1, {
...this.formTabsList.find((_) => _.id === id),
})
},
async addPatient(data, done, cb, ConfigFormsCallback) {
addPatient(data, "")
.then((res) => {
// this.$message.success("操作成功")
if (res.data) {
this.isUpdated = true
this.patientStandbyId = res.data.patientId
this.newformRecordId = res.data.formRecordId
if (
cb &&
Object.prototype.toString.call(cb) === "[object Function]"
) {
cb(res)
}
}
})
.finally((e) => {
done()
console.log("走了", ConfigFormsCallback)
if (
ConfigFormsCallback &&
Object.prototype.toString.call(ConfigFormsCallback) ===
"[object Function]"
) {
ConfigFormsCallback()
} else {
this.nextTab()
}
})
},
async addFollowPatient(data, done, cb, ConfigFormsCallback) {
addFollowPatient(data, "")
.then((res) => {
// this.$message.success("操作成功")
if (res.data) {
this.isUpdated = true
this.patientStandbyId = res.data.patientId
this.followId = res.data.followId
this.newformRecordId = res.data.formRecordId
if (
cb &&
Object.prototype.toString.call(cb) === "[object Function]"
) {
cb(res)
}
}
})
.finally((e) => {
done()
console.log("走了", ConfigFormsCallback)
if (
ConfigFormsCallback &&
Object.prototype.toString.call(ConfigFormsCallback) ===
"[object Function]"
) {
ConfigFormsCallback()
} else {
this.nextTab()
}
})
},
// json存储
setFormJson(formJson) {
const idx = this.activeName.replace("index", "")
this.formTabs[idx].formJson = formJson
this.formTabsList[idx].formJson = formJson
},
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,
silent: true,
label: item.tabName,
})
}
return {
...item,
silent: false,
label: item.tabName,
}
})
this.formTabs = formTabs
}
})
.finally(() => {
this.fromLoading = false
})
},
},
}