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
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
<template>
<div>
<van-nav-bar :title="routerDetail.id ? '修改通用随访': '新增通用随访'" left-text='' left-arrow @click-left='toBack'></van-nav-bar>
<div class='p-4 h-overflow'>
<base-info :info='info' v-show='step == 1' ref='baseInfo'
@changeVisitSituation='changeVisitSituation'></base-info>
<general-f-u-form :info='info' :first-form='firstForm' v-show='step == 2'
ref='generalFUForm'></general-f-u-form>
<common-bottom :info='info' v-show='step == 3' ref='commonBottom'></common-bottom>
</div>
<div class='pt-2 pb-2'>
<div class='px-5 grow flex flex-col justify-end' v-if='step == 1'>
<van-button type='primary' block round v-if='visitSituation == 1'
@click='toNext(2)'>下一步
</van-button>
<van-button type='primary' block round v-if='visitSituation == 2'
@click='toNext(3)'>下一步
</van-button>
</div>
<div class='px-5 flex align-center justify-around' v-if='step == 2'>
<van-button type='primary' round plain style='width: 44%'
@click='toNext(1)'>上一步
</van-button>
<van-button type='primary' round style='width: 44%'
@click='toNext(3)'>下一步
</van-button>
</div>
<div class='px-5 grow flex flex-col justify-end' v-if='step == 3'>
<van-button type='primary' block round
@click='onsubmit'>提交
</van-button>
</div>
</div>
</div>
</template>
<script>
import BaseInfo from '@/doctor/followUp/generalFU/form/BaseInfo'
import {
addCurrency,
fetchCurrencyById,
getChronicResidentsId,
updateCurrency,
upLoadMultifile
} from '@/api/doctor/generalFU'
import GeneralFUForm from '@/doctor/followUp/generalFU/form/GeneralFUForm'
import CommonBottom from '@/doctor/followUp/generalFU/form/CommonBottom'
export default {
name: 'Index',
components: { CommonBottom, GeneralFUForm, BaseInfo },
data() {
return {
info: {},
resident: {},
visitSituation: 1,
step: 1,
//第一步提交的表单
firstForm: {},
//居民信息
residentInfo: {}
}
},
created() {
this.init()
},
computed: {
routerDetail() {
return this.$route.query
}
},
methods: {
async init() {
this.info = {}
if (this.routerDetail.id) {
const res = await fetchCurrencyById({ id: this.routerDetail.id })
let result = res.data || {}
const {residentsRecord = {}} = result
const {id, ...others} = residentsRecord
this.info = {
...others,
personId: id,
...result
}
} else {
const res = await getChronicResidentsId(this.routerDetail.residentInfoId)
const {
id,
createDate,
createDoctorId,
createDoctorName,
createOfficeId,
createOfficeName,
createUnitId,
createUnitName,
updated,
...others
} = res.data
this.info = {
personId: id,
...others
}
this.info.diseaseType = this.routerDetail.diseaseType
}
},
async toNext(val) {
if (val == 2) {
this.firstForm = await this.$refs.baseInfo.onSubmit()
}
if (val == 3) {
await this.$refs.generalFUForm.onSubmit()
}
this.step = val
},
changeVisitSituation(val) {
this.visitSituation = val
},
//图片上传
async upload(imgList = []) {
let list = []
if (imgList.length) {
let fileId = Math.random().toString(16).substring(2, 8)
let data = new FormData()
data.append('parentId', fileId)
imgList.forEach(item => {
data.append('files', item)
})
let res = await upLoadMultifile(data)
let result = res.data || []
result.forEach(item => {
list.push(item.id)
})
}
return list
},
//原图片数据处理
baseImgHandle(imgList = []) {
let list = []
imgList.forEach(item => {
list.push(item.id)
})
return list
},
async onsubmit() {
let baseInfo = await this.$refs.baseInfo.onSubmit()
let generalFUForm = await this.$refs.generalFUForm.onSubmit()
let commonBottom = await this.$refs.commonBottom.onSubmit()
let imgInput1List = []
let imgInput2List = []
let uploadVisitRecord = ''
let sceneVisitImage = ''
//图片上传
if (generalFUForm.imgInput1.length) {
imgInput1List = await this.upload(generalFUForm.imgInput1)
}
if (generalFUForm.imgInput2.length) {
imgInput2List = await this.upload(generalFUForm.imgInput2)
}
if (generalFUForm.img1.length) {
let img1List = this.baseImgHandle(generalFUForm.img1)
let lsit1 = [...imgInput1List, ...img1List]
uploadVisitRecord = Array.from(new Set(lsit1)).join()
}
if (generalFUForm.img2.length) {
let img2List = this.baseImgHandle(generalFUForm.img2)
let lsit2 = [...imgInput2List, ...img2List]
sceneVisitImage = Array.from(new Set(lsit2)).join()
}
let params = {
...baseInfo,
...generalFUForm,
...commonBottom,
uploadVisitRecord,
sceneVisitImage,
source: 2
}
if (this.info.id) {
params.visitRecordId = this.info.visitRecordId
}
if (params.visitSituation == 2) {
params.visitWay = 14
}
let fun = this.info.id ? updateCurrency : addCurrency
fun(params, true).then(({ code }) => {
if (code == 'SUCCESS') {
this.$router.back()
}
})
},
toBack() {
if (this.visitSituation == 1) {
if (this.step != 1) {
this.step--
return
}
}
if (this.visitSituation == 2) {
if (this.step != 1) {
this.step = 1
return
}
}
this.$router.back()
}
}
}
</script>
<style scoped lang='less'>
:deep(.van-nav-bar .van-icon) {
color: #000000;
}
.h-overflow {
height: calc(100vh - 110px);
overflow-y: auto;
}
</style>