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
<template>
<van-form ref='form' class="doc-form doctor-info">
<div class="doc-form-label" required>筛查单位</div>
<van-field is-link
v-model='form.diseaseUnitName'
readonly
placeholder='请选择'
name="diseaseUnitId"
/>
<div class="doc-form-label" required>筛查科室</div>
<van-field is-link
v-model='form.diseaseOfficeName'
readonly
placeholder='请选择'
name="diseaseOfficeId"
@click="showOffice = true"
:rules="[{ required: true, message: '请选择' }]"
/>
<DocOffice v-model:show="showOffice"
v-model:value="form.diseaseOfficeId"
:unitId="form.diseaseUnitId"
@change="officeChange"
/>
<div class="doc-form-label" required>筛查医生</div>
<van-field is-link
v-model='form.diseaseDoctorName'
readonly
placeholder='请选择'
name="diseaseDoctorId"
@click="showDoctor = true"
:rules="[{ required: true, message: '请选择' }]"
/>
<DocOfficeDoctor v-model:show="showDoctor"
:allowClear="false"
v-model:value="form.diseaseDoctorId"
:unitId="form.diseaseUnitId"
:officeId="form.diseaseOfficeId"
@change="(option) => { form.diseaseDoctorName = option.staffName }"
/>
</van-form>
</template>
<script>
import { useStore } from '@/doctor/store'
import dayjs from 'dayjs'
import DocOffice from '@/doctor/components/docOffice/DocOffice.vue'
import DocOfficeDoctor from '@/doctor/components/docOfficeDoctor/DocOfficeDoctor.vue'
const defaultForm = (info = {}) => {
const form = {
createDate: undefined,
// 诊断单位
diseaseUnitId: undefined,
diseaseUnitName: undefined,
// 诊断科室
diseaseOfficeId: undefined,
diseaseOfficeName: undefined,
// 诊断医生
diseaseDoctorId: undefined,
diseaseDoctorName: undefined,
// 录入单位
createUnitId: undefined,
createUnitName: undefined,
// 录入科室
createOfficeId: undefined,
createOfficeName: undefined,
// 录入医生
createDoctorId: undefined,
createDoctorName: undefined
}
Reflect.ownKeys(form).forEach(key => {
if (info[key] != undefined) {
form[key] = info[key]
}
})
return form
}
export default {
components: {
DocOffice,
DocOfficeDoctor
},
props: {
info: { default: () => ({}) }
},
data() {
return {
form: {},
store: useStore(),
showUnit: false,
showOffice: false,
showDoctor: false
}
},
computed: {
authInfo() {
return this.store.authInfo
}
},
methods: {
initForm() {
this.form.createDate = dayjs().format('YYYY-MM-DD')
// 诊断单位
this.form.diseaseUnitId = this.authInfo.unitId
this.form.diseaseUnitName = this.authInfo.unitName
// 诊断科室
this.form.diseaseOfficeId = this.authInfo.officeId
this.form.diseaseOfficeName = this.authInfo.officeName
// 诊断医生
this.form.diseaseDoctorId = this.authInfo.relationId
this.form.diseaseDoctorName = this.authInfo.nickName
// 录入单位
this.form.createUnitId = this.authInfo.unitId
this.form.createUnitName = this.authInfo.unitName
// 录入科室
this.form.createOfficeId = this.authInfo.officeId
this.form.createOfficeName = this.authInfo.officeName
// 录入医生
this.form.createDoctorId = this.authInfo.relationId
this.form.createDoctorName = this.authInfo.nickName
},
unitChange(option = {}) {
this.form.diseaseUnitName = option.unitName
this.form.diseaseDoctorId = undefined
this.form.diseaseDoctorName = undefined
this.form.diseaseOfficeId = undefined
this.form.diseaseOfficeName = undefined
},
officeChange(option = {}) {
this.form.diseaseOfficeName = option.officeName
this.form.diseaseDoctorId = undefined
this.form.diseaseDoctorName = undefined
},
submit() {
return new Promise((resolve, reject) => {
this.$refs.form.validate().then(() => {
resolve(this.form)
}).catch((e) => {
reject(e)
})
})
}
},
watch: {
info: {
handler(info) {
this.form = defaultForm(info)
if (!this.info.id) {
this.initForm()
}
},
immediate: true
}
}
}
</script>
<style lang="less" scoped></style>