24
24
<PatientRegistered v-else :new-patient =" newPatient" :sended =" sended" />
25
25
</ModalBase >
26
26
<div class =" searchContainer" >
27
- <SearchField v-model =" inputSearch" />
27
+ <SearchField v-model =" inputSearch" @input = " handleSearch " />
28
28
<SortSelect v-model =" sortSelect" @input =" handleSortSelect" />
29
29
<HiddenSelect v-model =" displaySelect" @input =" handleDisplaySelect" />
30
30
</div >
55
55
</template >
56
56
57
57
<script lang="ts">
58
- import { Component , Vue } from ' vue-property-decorator'
58
+ import { Component , Vue , Watch } from ' vue-property-decorator'
59
59
import ActionButton from ' @/components/ActionButton.vue'
60
60
import PlusIcon from ' @/static/icon-plus.svg'
61
61
import ModalBase from ' @/components/ModalBase.vue'
@@ -90,6 +90,7 @@ export default class CenterId extends Vue {
90
90
showModal = false
91
91
registered = false
92
92
inputSearch = ' '
93
+ searchWord = ' '
93
94
sortSelect = ' '
94
95
displaySelect = ' show-only-display-true'
95
96
patients: Patient [] = []
@@ -115,6 +116,13 @@ export default class CenterId extends Vue {
115
116
}
116
117
}
117
118
119
+ @Watch (' searchWord' )
120
+ onSearchWordChanged(newValue : string , oldValue : string ) {
121
+ if (newValue !== oldValue ) {
122
+ this .fetchPatients ()
123
+ }
124
+ }
125
+
118
126
checkAndFetchPatients(): void {
119
127
authStore .checkIsExpired ().then ((expired ) => {
120
128
if (expired ) {
@@ -140,6 +148,14 @@ export default class CenterId extends Vue {
140
148
? item .display
141
149
: ! item .display
142
150
})
151
+ if (this .searchWord ) {
152
+ this .patients = this .patients .filter ((item ) => {
153
+ const pattern = new RegExp (this .searchWord , ' ig' )
154
+ return (
155
+ pattern .test (item .phone ) || (item .memo && pattern .test (item .memo ))
156
+ )
157
+ })
158
+ }
143
159
this .sortSelect = utilsStore .getSortItem
144
160
this .sortItems (this .sortSelect )
145
161
})
@@ -191,6 +207,10 @@ export default class CenterId extends Vue {
191
207
this .fetchPatients ()
192
208
}
193
209
210
+ handleSearch(value : string ): void {
211
+ this .searchWord = value
212
+ }
213
+
194
214
handleInputTel(): void {
195
215
this .errorMessage = ' '
196
216
}
0 commit comments