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
<template>
<div class="h-full flex flex-col diagnose-form">
<DocNavBar :title="`${id ? '修改' : '新增'}慢病诊断`" class="shrink-0"
:backFunc="onBack"></DocNavBar>
<div class="p-4 overflow-y-auto grow" ref="all">
<DiseaseSelect v-if="step == 1"
:excludeType="excludeType"
:value="diseaseType"
ref="DiseaseSelect"/>
<archiveCommon :info="baseInfo" v-else-if="step == 2" ref="archiveCommon"></archiveCommon>
<FormCont :info="diagnoseInfo" v-else-if="step == 3" ref="FormCont"/>
</div>
<div class="shrink-0">
<div class='bottom-small-line'></div>
<div class='px-5 py-2 grow flex justify-between'>
<template v-if='step == 1'>
<van-button type='primary' block round
@click='toNext'>下一步</van-button>
</template>
<template v-else-if="step == 3">
<van-button type='primary' block round
@click='submit'>提交</van-button>
</template>
<template v-else>
<van-button type='primary' round plain style='width: 48%'
@click='toPrev'>上一步
</van-button>
<van-button type='primary' round style='width: 48%'
@click='toNext'>下一步
</van-button>
</template>
</div>
</div>
</div>
</template>
<script>
import DocNavBar from '@/doctor/components/docNavBar/DocNavBar.vue'
import archiveCommon from '@/doctor/components/archiveCommon/archiveCommon.vue'
import DiseaseSelect from './DiseaseSelect.vue'
import FormCont from './FormCont.vue'
import { useStore } from '@/doctor/store/index.js'
import { fetchDataHandle } from '@/utils/common.js'
import { getChronicResidentsId } from '@/api/doctor/generalFU'
import { showSuccessToast } from 'vant'
import { getDiagnoseDetail, getDiagnoseFirst, addDiagnose, updateDiagnose } from '@/api/doctor/disease.js'
export default {
components: {
DocNavBar,
archiveCommon,
DiseaseSelect,
FormCont
},
data() {
return {
store: useStore(),
step: 1,
// 患者基础信息
baseInfo: {},
// 诊断信息
diagnoseInfo: {}
}
},
computed: {
id() {
return this.$route.query.id
},
diseaseType() {
const val = this.$route.query.diseaseType
return val ? +val : undefined
},
residentInfoId() {
return this.$route.query.residentInfoId
},
idCard() {
return this.$route.query.idCard
},
excludeType() {
const excludeType = this.$route.query.excludeType
return excludeType && excludeType.split(',').map(e => Number(e))
}
},
// 路由守卫
beforeRouteLeave(to, from) {
if ([2, 3].includes(this.step)) {
this.onBack()
return false
}
return true
},
created() {
this.init()
},
methods: {
async init() {
if (this.id) {
const res = await getDiagnoseDetail(this.id)
const result = res.data || {}
this.diagnoseInfo = fetchDataHandle(result, {
diagnoseResult: 'strToArrNum'
})
this.baseInfo = result.residentsRecord || {}
} else {
if (this.residentInfoId) {
let res = await getChronicResidentsId(this.residentInfoId)
this.baseInfo = res.data || {}
this.diagnoseInfo.residentInfoId = this.residentInfoId
} else if (this.idCard) {
// 新建用户
this.baseInfo.idCard = this.idCard
}
if (this.diseaseType) {
this.diagnoseInfo.diseaseType = this.diseaseType
const res = await getDiagnoseFirst({
residentInfoId: this.residentInfoId,
diseaseType: this.diseaseType
})
const firstInfo = res.data || {}
this.diagnoseInfo.manageDate = firstInfo.manageDate
this.diagnoseInfo.icdCode = firstInfo.icdCode
this.diagnoseInfo.diseaseName = firstInfo.diseaseName
}
}
},
submit() {
this.$refs.FormCont.submit().then(res => {
if (!res) return
console.log('FormCont.submit', res)
const query = {
...res,
residentsRecord: this.baseInfo
}
const func = query.id ? updateDiagnose : addDiagnose
func(query).then(() => {
this.store.onRefreshMark()
showSuccessToast('提交成功')
setTimeout(() => {
this.step++
this.$router.replace({
path: '/doctor/workbench'
})
}, 600)
})
})
},
// 上一步
toPrev() {
this.onStep(this.step -1)
},
async toNext() {
try {
if (this.step == 1) {
const diseaseType = await this.$refs.DiseaseSelect.submit()
console.log(diseaseType)
this.diagnoseInfo.diseaseType = diseaseType
} else if (this.step == 2) {
const baseInfo = await this.$refs.archiveCommon.onSubmit()
console.log(baseInfo)
this.baseInfo = baseInfo
}
this.onStep(this.step + 1)
} catch (e) {
console.warn(e)
}
},
onStep(val) {
this.$refs.all.scrollTo(0, 0)
this.step = val
},
onBack() {
if (this.step == 1) {
this.$router.back()
} else {
this.step--
}
}
}
}
</script>
<style lang="less" scoped>
</style>