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
<template>
<van-popup :show="innerShow" position="bottom"
class="doc-unit">
<van-picker :loading="loading"
title="科室选择"
:columns="array"
:columns-field-names="fieldNames"
v-model="innerValue"
@confirm="onConfirm"
@cancel="onCancel"
>
</van-picker>
</van-popup>
</template>
<script>
import { getOfficeList } from '@/api/doctor/generalFU.js'
export default {
name: 'DocOffice',
props: {
show: Boolean,
value: [String, Number],
unitId: [String, Number],
fieldNames: {
type: Object,
default: () => {
return {text: 'officeName', value: 'id'}
}
}
},
emits: ['update:show', 'update:value', 'change'],
data() {
return {
innerValue: undefined,
array: [],
loading: false,
}
},
computed: {
innerShow() {
return this.show
}
},
created() {
this.getData()
},
methods: {
getData() {
this.array = []
if (!this.unitId) return
this.loading = true
getOfficeList(this.unitId).then(res => {
this.array = res.data || []
}).finally(() => {
this.loading = false
})
},
onConfirm({ selectedValues, selectedOptions }) {
this.$emit('update:value', selectedValues[0])
this.$emit('change', selectedOptions[0] || {})
this.$emit('update:show', false)
},
onCancel() {
this.$emit('update:show', false)
}
},
watch: {
value: {
handler(value) {
if (value == null) return
this.innerValue = [value]
},
immediate: true
},
unitId: {
handler() {
this.getData()
}
},
}
}
</script>
<style lang="less" scoped>
</style>